summaryrefslogtreecommitdiff
path: root/src/saml2/ws/wspol.py
blob: 3ef49a6e10b6bbe23e1ca3431a28b9985426494e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
#!/usr/bin/env python

#
# Generated Sun Jun 14 13:35:32 2015 by parse_xsd.py version 0.5.
#

import saml2
from saml2 import SamlBase
from saml2.ws import wssec as wsse
from saml2.ws import wsutil as wsu


NAMESPACE = "http://schemas.xmlsoap.org/ws/2004/09/policy"


class PolicyReference(SamlBase):
    """The http://schemas.xmlsoap.org/ws/2004/09/policy:PolicyReference element"""

    c_tag = "PolicyReference"
    c_namespace = NAMESPACE
    c_children = SamlBase.c_children.copy()
    c_attributes = SamlBase.c_attributes.copy()
    c_child_order = SamlBase.c_child_order[:]
    c_cardinality = SamlBase.c_cardinality.copy()
    c_attributes["URI"] = ("uri", "anyURI", True)
    c_attributes["Digest"] = ("digest", "base64Binary", False)
    c_attributes["DigestAlgorithm"] = ("digest_algorithm", "anyURI", False)

    def __init__(
        self,
        uri=None,
        digest=None,
        digest_algorithm="http://schemas.xmlsoap.org/ws/2004/09/policy/Sha1Exc",
        text=None,
        extension_elements=None,
        extension_attributes=None,
    ):
        SamlBase.__init__(
            self,
            text=text,
            extension_elements=extension_elements,
            extension_attributes=extension_attributes,
        )
        self.uri = uri
        self.digest = digest
        self.digest_algorithm = digest_algorithm


def policy_reference_from_string(xml_string):
    return saml2.create_class_from_xml_string(PolicyReference, xml_string)


class AppliesTo(SamlBase):
    """The http://schemas.xmlsoap.org/ws/2004/09/policy:AppliesTo element"""

    c_tag = "AppliesTo"
    c_namespace = NAMESPACE
    c_children = SamlBase.c_children.copy()
    c_attributes = SamlBase.c_attributes.copy()
    c_child_order = SamlBase.c_child_order[:]
    c_cardinality = SamlBase.c_cardinality.copy()


def applies_to_from_string(xml_string):
    return saml2.create_class_from_xml_string(AppliesTo, xml_string)


class PolicyAttachment(SamlBase):
    """The http://schemas.xmlsoap.org/ws/2004/09/policy:PolicyAttachment element"""

    c_tag = "PolicyAttachment"
    c_namespace = NAMESPACE
    c_children = SamlBase.c_children.copy()
    c_attributes = SamlBase.c_attributes.copy()
    c_child_order = SamlBase.c_child_order[:]
    c_cardinality = SamlBase.c_cardinality.copy()
    c_children["{http://schemas.xmlsoap.org/ws/2004/09/policy}AppliesTo"] = ("applies_to", AppliesTo)
    c_cardinality["policy"] = {"min": 0}
    c_children["{http://schemas.xmlsoap.org/ws/2004/09/policy}PolicyReference"] = (
        "policy_reference",
        [PolicyReference],
    )
    c_cardinality["policy_reference"] = {"min": 0}
    c_child_order.extend(["applies_to", "policy", "policy_reference"])

    def __init__(
        self,
        applies_to=None,
        policy=None,
        policy_reference=None,
        text=None,
        extension_elements=None,
        extension_attributes=None,
    ):
        SamlBase.__init__(
            self,
            text=text,
            extension_elements=extension_elements,
            extension_attributes=extension_attributes,
        )
        self.applies_to = applies_to
        self.policy = policy or []
        self.policy_reference = policy_reference or []


def policy_attachment_from_string(xml_string):
    return saml2.create_class_from_xml_string(PolicyAttachment, xml_string)


class OperatorContentType_(SamlBase):
    """The http://schemas.xmlsoap.org/ws/2004/09/policy:OperatorContentType element"""

    c_tag = "OperatorContentType"
    c_namespace = NAMESPACE
    c_children = SamlBase.c_children.copy()
    c_attributes = SamlBase.c_attributes.copy()
    c_child_order = SamlBase.c_child_order[:]
    c_cardinality = SamlBase.c_cardinality.copy()
    c_cardinality["policy"] = {"min": 0}
    c_cardinality["all"] = {"min": 0}
    c_cardinality["exactly_one"] = {"min": 0}
    c_children["{http://schemas.xmlsoap.org/ws/2004/09/policy}PolicyReference"] = (
        "policy_reference",
        [PolicyReference],
    )
    c_cardinality["policy_reference"] = {"min": 0}
    c_child_order.extend(["policy", "all", "exactly_one", "policy_reference"])

    def __init__(
        self,
        policy=None,
        all=None,
        exactly_one=None,
        policy_reference=None,
        text=None,
        extension_elements=None,
        extension_attributes=None,
    ):
        SamlBase.__init__(
            self,
            text=text,
            extension_elements=extension_elements,
            extension_attributes=extension_attributes,
        )
        self.policy = policy or []
        self.all = all or []
        self.exactly_one = exactly_one or []
        self.policy_reference = policy_reference or []


def operator_content_type__from_string(xml_string):
    return saml2.create_class_from_xml_string(OperatorContentType_, xml_string)


class Policy(OperatorContentType_):
    """The http://schemas.xmlsoap.org/ws/2004/09/policy:Policy element"""

    c_tag = "Policy"
    c_namespace = NAMESPACE
    c_children = OperatorContentType_.c_children.copy()
    c_attributes = OperatorContentType_.c_attributes.copy()
    c_child_order = OperatorContentType_.c_child_order[:]
    c_cardinality = OperatorContentType_.c_cardinality.copy()
    c_attributes["Name"] = ("name", "anyURI", False)
    c_attributes["{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd}Id"] = (
        "Id",
        "tns:OperatorContentType",
        False,
    )

    def __init__(
        self,
        name=None,
        Id=None,
        policy=None,
        all=None,
        exactly_one=None,
        policy_reference=None,
        text=None,
        extension_elements=None,
        extension_attributes=None,
    ):
        OperatorContentType_.__init__(
            self,
            policy=policy,
            all=all,
            exactly_one=exactly_one,
            policy_reference=policy_reference,
            text=text,
            extension_elements=extension_elements,
            extension_attributes=extension_attributes,
        )
        self.name = name
        self.Id = Id


def policy_from_string(xml_string):
    return saml2.create_class_from_xml_string(Policy, xml_string)


class All(OperatorContentType_):
    """The http://schemas.xmlsoap.org/ws/2004/09/policy:All element"""

    c_tag = "All"
    c_namespace = NAMESPACE
    c_children = OperatorContentType_.c_children.copy()
    c_attributes = OperatorContentType_.c_attributes.copy()
    c_child_order = OperatorContentType_.c_child_order[:]
    c_cardinality = OperatorContentType_.c_cardinality.copy()


def all_from_string(xml_string):
    return saml2.create_class_from_xml_string(All, xml_string)


class ExactlyOne(OperatorContentType_):
    """The http://schemas.xmlsoap.org/ws/2004/09/policy:ExactlyOne element"""

    c_tag = "ExactlyOne"
    c_namespace = NAMESPACE
    c_children = OperatorContentType_.c_children.copy()
    c_attributes = OperatorContentType_.c_attributes.copy()
    c_child_order = OperatorContentType_.c_child_order[:]
    c_cardinality = OperatorContentType_.c_cardinality.copy()


def exactly_one_from_string(xml_string):
    return saml2.create_class_from_xml_string(ExactlyOne, xml_string)


PolicyAttachment.c_children["{http://schemas.xmlsoap.org/ws/2004/09/policy}Policy"] = ("policy", [Policy])
OperatorContentType_.c_children["{http://schemas.xmlsoap.org/ws/2004/09/policy}Policy"] = ("policy", [Policy])
Policy.c_children["{http://schemas.xmlsoap.org/ws/2004/09/policy}Policy"] = ("policy", [Policy])
ExactlyOne.c_children["{http://schemas.xmlsoap.org/ws/2004/09/policy}Policy"] = ("policy", [Policy])
All.c_children["{http://schemas.xmlsoap.org/ws/2004/09/policy}Policy"] = ("policy", [Policy])
OperatorContentType_.c_children["{http://schemas.xmlsoap.org/ws/2004/09/policy}All"] = ("all", [All])
Policy.c_children["{http://schemas.xmlsoap.org/ws/2004/09/policy}All"] = ("all", [All])
ExactlyOne.c_children["{http://schemas.xmlsoap.org/ws/2004/09/policy}All"] = ("all", [All])
All.c_children["{http://schemas.xmlsoap.org/ws/2004/09/policy}All"] = ("all", [All])
OperatorContentType_.c_children["{http://schemas.xmlsoap.org/ws/2004/09/policy}ExactlyOne"] = (
    "exactly_one",
    [ExactlyOne],
)
Policy.c_children["{http://schemas.xmlsoap.org/ws/2004/09/policy}ExactlyOne"] = ("exactly_one", [ExactlyOne])
ExactlyOne.c_children["{http://schemas.xmlsoap.org/ws/2004/09/policy}ExactlyOne"] = ("exactly_one", [ExactlyOne])
All.c_children["{http://schemas.xmlsoap.org/ws/2004/09/policy}ExactlyOne"] = ("exactly_one", [ExactlyOne])

ELEMENT_FROM_STRING = {
    Policy.c_tag: policy_from_string,
    All.c_tag: all_from_string,
    ExactlyOne.c_tag: exactly_one_from_string,
    OperatorContentType_.c_tag: operator_content_type__from_string,
    PolicyReference.c_tag: policy_reference_from_string,
    PolicyAttachment.c_tag: policy_attachment_from_string,
    AppliesTo.c_tag: applies_to_from_string,
}

ELEMENT_BY_TAG = {
    "Policy": Policy,
    "All": All,
    "ExactlyOne": ExactlyOne,
    "OperatorContentType": OperatorContentType_,
    "PolicyReference": PolicyReference,
    "PolicyAttachment": PolicyAttachment,
    "AppliesTo": AppliesTo,
}


def factory(tag, **kwargs):
    return ELEMENT_BY_TAG[tag](**kwargs)