|
91 | 91 | _b64_encode_fn = getattr(base64, 'encodebytes', base64.encodestring)
|
92 | 92 |
|
93 | 93 |
|
94 |
| -def _decode_attribute_value(typ, text): |
95 |
| - if typ == XSD + "string": |
96 |
| - return text or "" |
97 |
| - if typ == XSD + "integer" or typ == XSD + "int": |
98 |
| - return str(int(text)) |
99 |
| - if typ == XSD + "float" or typ == XSD + "double": |
100 |
| - return str(float(text)) |
101 |
| - if typ == XSD + "boolean": |
102 |
| - return str(text.lower() == "true") |
103 |
| - if typ == XSD + "base64Binary": |
104 |
| - return _b64_decode_fn(text) |
105 |
| - raise ValueError("type %s not supported" % type) |
106 |
| - |
107 |
| - |
108 |
| -def _verify_value_type(typ, val): |
109 |
| - # print("verify value type: %s, %s" % (typ, val)) |
110 |
| - if typ == XSD + "string": |
111 |
| - try: |
112 |
| - return str(val) |
113 |
| - except UnicodeEncodeError: |
114 |
| - if six.PY2: |
115 |
| - return unicode(val) |
116 |
| - else: |
117 |
| - return val.decode('utf8') |
118 |
| - if typ == XSD + "integer" or typ == XSD + "int": |
119 |
| - return int(val) |
120 |
| - if typ == XSD + "float" or typ == XSD + "double": |
121 |
| - return float(val) |
122 |
| - if typ == XSD + "boolean": |
123 |
| - if val.lower() == "true" or val.lower() == "false": |
124 |
| - pass |
125 |
| - else: |
126 |
| - raise ValueError("Faulty boolean value") |
127 |
| - if typ == XSD + "base64Binary": |
128 |
| - return _b64_decode_fn(val.encode()) |
129 |
| - |
130 |
| - |
131 | 94 | class AttributeValueBase(SamlBase):
|
132 | 95 | def __init__(self,
|
133 | 96 | text=None,
|
@@ -325,11 +288,6 @@ def harvest_element_tree(self, tree):
|
325 | 288 | self.set_text(tree.text)
|
326 | 289 | if XSI_NIL in self.extension_attributes:
|
327 | 290 | del self.extension_attributes[XSI_NIL]
|
328 |
| - try: |
329 |
| - typ = self.extension_attributes[XSI_TYPE] |
330 |
| - _verify_value_type(typ, getattr(self, "text")) |
331 |
| - except KeyError: |
332 |
| - pass |
333 | 291 |
|
334 | 292 |
|
335 | 293 | class BaseIDAbstractType_(SamlBase):
|
|
0 commit comments