web2ldap  1.7.7
About: web2ldap is a full-featured web-based LDAPv3 client.
  Fossies Dox: web2ldap-1.7.7.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

schac.py
Go to the documentation of this file.
1# -*- coding: ascii -*-
2"""
3web2ldap plugin classes for attributes defined in SCHAC
4
5See https://www.terena.org/activities/tf-emc2/schac.html
6"""
7
8import re
9import datetime
10
11from ..schema.syntaxes import (
12 DateOfBirth,
13 DirectoryString,
14 IA5String,
15 NumericString,
16 CountryString,
17 DNSDomain,
18 syntax_registry,
19)
20from .msperson import Gender
21
22
23syntax_registry.reg_at(
24 CountryString.oid, [
25 '1.3.6.1.4.1.25178.1.2.5', # schacCountryOfCitizenship
26 '1.3.6.1.4.1.25178.1.2.11', # schacCountryOfResidence
27 ]
28)
29
30syntax_registry.reg_at(
31 DNSDomain.oid, [
32 '1.3.6.1.4.1.25178.1.2.9', # schacHomeOrganization
33 ]
34)
35
37 oid: str = 'SchacMotherTongue-oid'
38 desc: str = 'Language tag of the language a person learns first (see RFC 3066).'
39 pattern = re.compile('^[a-zA-Z]{2,8}(-[a-zA-Z0-9]{2,8})*$')
40
41syntax_registry.reg_at(
42 SchacMotherTongue.oid, [
43 '1.3.6.1.4.1.25178.1.2.1', # schacMotherTongue
44 ]
45)
46
47
48syntax_registry.reg_at(
49 Gender.oid, [
50 '1.3.6.1.4.1.25178.1.2.2', # schacGender
51 ]
52)
53
54
56 oid: str = 'SchacDateOfBirth-oid'
57 desc: str = 'Date of birth: syntax YYYYMMDD'
58 storage_format = '%Y%m%d'
59
60syntax_registry.reg_at(
61 SchacDateOfBirth.oid, [
62 '1.3.6.1.4.1.25178.1.2.3', # schacDateOfBirth
63 ]
64)
65
66
68 oid: str = 'SchacYearOfBirth-oid'
69 desc: str = 'Year of birth: syntax YYYY'
70 max_len: str = 4
71 input_pattern: str = '^[0-9]{4}$'
72 pattern = re.compile(input_pattern)
73
74 def _validate(self, attr_value: bytes) -> bool:
75 try:
76 birth_year = int(attr_value)
77 except ValueError:
78 return False
79 return birth_year <= datetime.date.today().year
80
81syntax_registry.reg_at(
82 SchacYearOfBirth.oid, [
83 '1.3.6.1.4.1.25178.1.0.2.3', # schacYearOfBirth
84 ]
85)
86
87
89 oid: str = 'SchacUrn-oid'
90 desc: str = 'Generic URN for SCHAC'
91 input_pattern: str = '^urn:mace:terena.org:schac:.+$'
92 pattern = re.compile(input_pattern)
93
94syntax_registry.reg_at(
95 SchacUrn.oid, [
96 '1.3.6.1.4.1.25178.1.2.10', # schacHomeOrganizationType
97 '1.3.6.1.4.1.25178.1.2.13', # schacPersonalPosition
98 '1.3.6.1.4.1.25178.1.2.14', # schacPersonalUniqueCode
99 '1.3.6.1.4.1.25178.1.2.15', # schacPersonalUniqueID
100 '1.3.6.1.4.1.25178.1.2.19', # schacUserStatus
101 ]
102)
103
104
105# Register all syntax classes in this module
106syntax_registry.reg_syntaxes(__name__)
bool _validate(self, bytes attr_value)
Definition: schac.py:74