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)  

msperson.py
Go to the documentation of this file.
1# -*- coding: ascii -*-
2"""
3web2ldap plugin classes for attributes defined for msPerson
4"""
5
6import re
7import os.path
8
9# try to import vatnumber module
10try:
11 import vatnumber
12except ImportError:
13 VATNUMBER_AVAIL = False
14else:
15 VATNUMBER_AVAIL = True
16
17from ... import ETC_DIR
18from ..schema.syntaxes import (
19 DateOfBirth,
20 DirectoryString,
21 IA5String,
22 PropertiesSelectList,
23 syntax_registry,
24)
25
26
28 """
29 Plugin for reading ISO 5218 standard representation of gender
30 from configured properties file
31 """
32 oid: str = 'Gender-oid'
33 desc: str = 'Representation of human sex (see ISO 5218)'
34 properties_pathname = os.path.join(
35 ETC_DIR, 'properties', 'attribute_select_gender.properties'
36 )
37
38syntax_registry.reg_at(
39 Gender.oid, [
40 '1.3.6.1.4.1.5427.1.389.4.7', # gender (defined for msPerson)
41 ]
42)
43
44
45syntax_registry.reg_at(
46 DateOfBirth.oid, [
47 '1.3.6.1.4.1.5427.1.389.4.2', # dateOfBirth
48 ]
49)
50
51
53 """
54 More information:
55 https://de.wikipedia.org/wiki/International_Bank_Account_Number
56 http://www.pruefziffernberechnung.de/I/IBAN.shtml
57 """
58 oid: str = 'LabeledBICandIBAN-oid'
59 desc: str = 'International bank account number (IBAN) syntax (see ISO 13616:1997)'
60
61syntax_registry.reg_at(
62 LabeledBICandIBAN.oid, [
63 '1.3.6.1.4.1.5427.1.389.4.13', # labeledBICandIBAN
64 ]
65)
66
67
69 """
70 More information:
71 http://www.bzst.de/DE/Steuern_International/USt_Identifikationsnummer/Merkblaetter/Aufbau_USt_IdNr.pdf
72 https://de.wikipedia.org/wiki/Umsatzsteuer-Identifikationsnummer
73 """
74 oid: str = 'EuVATId-oid'
75 desc: str = 'Value Added Tax Ident Number of organizations within European Union'
76 pattern = re.compile((
77 '^('
78 '(AT)?U[0-9]{8}|'
79 '(BE)?[0-9]{10}|'
80 '(BG)?[0-9]{9,10}|'
81 '(CY)?[0-9]{8}L|'
82 '(CZ)?[0-9]{8,10}|'
83 '(DE)?[0-9]{9}|'
84 '(DK)?[0-9]{8}|'
85 '(EE)?[0-9]{9}|'
86 '(EL|GR)?[0-9]{9}|'
87 '(ES)?[0-9A-Z][0-9]{7}[0-9A-Z]|'
88 '(FI)?[0-9]{8}|'
89 '(FR)?[0-9A-Z]{2}[0-9]{9}|'
90 '(GB)?([0-9]{9}([0-9]{3})?|[A-Z]{2}[0-9]{3})|'
91 '(HU)?[0-9]{8}|'
92 '(IE)?[0-9]S[0-9]{5}L|'
93 '(IT)?[0-9]{11}|'
94 '(LT)?([0-9]{9}|[0-9]{12})|'
95 '(LU)?[0-9]{8}|'
96 '(LV)?[0-9]{11}|'
97 '(MT)?[0-9]{8}|'
98 '(NL)?[0-9]{9}B[0-9]{2}|'
99 '(PL)?[0-9]{10}|'
100 '(PT)?[0-9]{9}|'
101 '(RO)?[0-9]{2,10}|'
102 '(SE)?[0-9]{12}|'
103 '(SI)?[0-9]{8}|'
104 '(SK)?[0-9]{10}'
105 ')$'
106 ))
107
108 def _validate(self, attr_value: bytes) -> bool:
109 if VATNUMBER_AVAIL:
110 try:
111 av_u = self._app.ls.uc_decode(attr_value)[0]
112 except UnicodeDecodeError:
113 return False
114 return vatnumber.check_vat(av_u)
115 return IA5String._validate(self, attr_value)
116
117 def sanitize(self, attr_value: bytes) -> bytes:
118 return attr_value.upper().replace(b' ', b'')
119
120syntax_registry.reg_at(
121 EuVATId.oid, [
122 '1.3.6.1.4.1.5427.1.389.4.11', # euVATId
123 ]
124)
125
126
127# Register all syntax classes in this module
128syntax_registry.reg_syntaxes(__name__)
bool _validate(self, bytes attr_value)
Definition: msperson.py:108
bytes sanitize(self, bytes attr_value)
Definition: msperson.py:117