1# -*- coding: ascii -*-
2"""
3web2ldap plugin classes for attributes defined eduPerson
4
5See http://middleware.internet2.edu/eduperson/
6"""
7
8import re
9from typing import Dict
10
11from ..schema.syntaxes import IA5String, SelectList, DynamicDNSelectList, syntax_registry
12
13
14class EduPersonAffiliation(SelectList):
15    oid: str = 'EduPersonAffiliation-oid'
16    desc: str = 'Affiliation (see eduPerson)'
17
18    attr_value_dict: Dict[str, str] = {
19        '': '',
20        'faculty': 'faculty',
21        'student': 'student',
22        'staff': 'staff',
23        'alum': 'alum',
24        'member': 'member',
25        'affiliate': 'affiliate',
26        'employee': 'employee',
27        'library-walk-in': 'library-walk-in',
28    }
29
30syntax_registry.reg_at(
31    EduPersonAffiliation.oid, [
32        '1.3.6.1.4.1.5923.1.1.1.1', # eduPersonAffiliation
33        '1.3.6.1.4.1.5923.1.1.1.5', # eduPersonPrimaryAffiliation
34    ]
35)
36
37
38class EduPersonScopedAffiliation(IA5String):
39    oid: str = 'EduPersonScopedAffiliation-oid'
40    desc: str = 'Scoped affiliation (see eduPerson)'
41    pattern = re.compile(
42        '^(faculty|student|staff|alum|member|affiliate|employee|library-walk-in)@[a-zA-Z0-9.-]+$'
43    )
44
45syntax_registry.reg_at(
46    EduPersonScopedAffiliation.oid, [
47        '1.3.6.1.4.1.5923.1.1.1.9', # eduPersonScopedAffiliation
48    ]
49)
50
51
52class EduPersonOrgUnitDN(DynamicDNSelectList):
53    oid: str = 'EduPersonOrgUnitDN-oid'
54    desc: str = 'DN of associated organizational unit entry (see eduPerson)'
55    ldap_url = 'ldap:///_??sub?(objectClass=organizationalUnit)'
56
57syntax_registry.reg_at(
58    EduPersonOrgUnitDN.oid, [
59        '1.3.6.1.4.1.5923.1.1.1.4', # eduPersonOrgUnitDN
60        '1.3.6.1.4.1.5923.1.1.1.8', # eduPersonPrimaryOrgUnitDN
61    ]
62)
63
64
65class EduPersonOrgDN(DynamicDNSelectList):
66    oid: str = 'EduPersonOrgDN-oid'
67    desc: str = 'DN of associated organization entry (see eduPerson)'
68    ldap_url = 'ldap:///_??sub?(objectClass=organization)'
69
70syntax_registry.reg_at(
71    EduPersonOrgDN.oid, [
72        '1.3.6.1.4.1.5923.1.1.1.3', # eduPersonOrgDN
73    ]
74)
75
76
77# Register all syntax classes in this module
78syntax_registry.reg_syntaxes(__name__)
79