source: TI12-security/trunk/python/ndg.security.saml/saml/common/xml.py @ 5597

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI12-security/trunk/python/ndg.security.saml/saml/common/xml.py@5597
Revision 5597, 9.5 KB checked in by pjkersha, 11 years ago (diff)

Refactored SAML package structure into saml2, core and common sub-packages

Line 
1"""SAML Common XML module
2
3Implementation of SAML 2.0 for NDG Security
4
5NERC DataGrid Project
6
7This implementation is adapted from the Java OpenSAML implementation.  The
8copyright and licence information are included here:
9
10Copyright [2005] [University Corporation for Advanced Internet Development, Inc.]
11
12Licensed under the Apache License, Version 2.0 (the "License");
13you may not use this file except in compliance with the License.
14You may obtain a copy of the License at
15
16http://www.apache.org/licenses/LICENSE-2.0
17
18Unless required by applicable law or agreed to in writing, software
19distributed under the License is distributed on an "AS IS" BASIS,
20WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21See the License for the specific language governing permissions and
22limitations under the License.
23"""
24__author__ = "P J Kershaw"
25__date__ = "23/07/09"
26__copyright__ = "(C) 2009 Science and Technology Facilities Council"
27__contact__ = "Philip.Kershaw@stfc.ac.uk"
28__license__ = "BSD - see LICENSE file in top-level directory"
29__contact__ = "Philip.Kershaw@stfc.ac.uk"
30__revision__ = "$Id$"
31
32class XMLConstants(object):
33    '''XML related constants.'''
34
35    # XML Tooling
36
37    # Configuration namespace
38    XMLTOOLING_CONFIG_NS = "http:#www.opensaml.org/xmltooling-config"
39
40    # Configuration namespace prefix
41    XMLTOOLING_CONFIG_PREFIX = "xt"
42   
43    # Name of the object provider used for objects that don't have a registered
44    # object provider
45    XMLTOOLING_DEFAULT_OBJECT_PROVIDER = "DEFAULT"
46
47    # Core XML
48
49    # XML core namespace
50    XML_NS = "http:#www.w3.org/XML/1998/namespace"
51   
52    # XML core prefix for xml attributes
53    XML_PREFIX = "xml"
54
55    # XML namespace for xmlns attributes
56    XMLNS_NS = "http://www.w3.org/2000/xmlns/"
57
58    # XML namespace prefix for xmlns attributes
59    XMLNS_PREFIX = "xmlns"
60
61    # XML Schema namespace
62    XSD_NS = "http://www.w3.org/2001/XMLSchema"
63
64    # XML Schema QName prefix
65    XSD_PREFIX = "xs"
66
67    # XML Schema Instance namespace
68    XSI_NS = "http://www.w3.org/2001/XMLSchema-instance"
69
70    # XML Schema Instance QName prefix
71    XSI_PREFIX = "xsi"
72
73    # XML XMLSecSignatureImpl namespace
74    XMLSIG_NS = "http://www.w3.org/2000/09/xmldsig#"
75
76    # XML XMLSecSignatureImpl QName prefix
77    XMLSIG_PREFIX = "ds"
78
79    # XML Encryption namespace
80    XMLENC_NS = "http://www.w3.org/2001/04/xmlenc#"
81
82    # XML Encryption QName prefix
83    XMLENC_PREFIX = "xenc"
84   
85    # Local name of EncryptedData element
86    XMLENC_ENCDATA_LOCAL_NAME = "EncryptedData"
87   
88    # Local name of EncryptedKey element
89    XMLENC_ENCKEY_LOCAL_NAME = "EncryptedKey"
90   
91
92class SAMLConstants(XMLConstants):
93    '''XML related constants used in the SAML specifications.'''
94   
95    # HTTP Constants
96   
97    # HTTP Request Method - POST.
98    POST_METHOD = "POST"
99   
100    # HTTP Method - GET.
101    GET_METHOD = "GET"
102   
103    # OpenSAML 2
104   
105    # Directory, on the classpath, schemas are located in.
106    SCHEMA_DIR = "/schema/"
107   
108    #    Core XML
109   
110    # XML core schema system Id.
111    XML_SCHEMA_LOCATION = SCHEMA_DIR + "xml.xsd"
112   
113    #  XML Signature schema Id.
114    XMLSIG_SCHEMA_LOCATION = SCHEMA_DIR + "xmldsig-core-schema.xsd"
115   
116    # XML Encryption schema Id.
117    XMLENC_SCHEMA_LOCATION = SCHEMA_DIR + "xenc-schema.xsd"
118
119   
120    #    SOAP
121   
122    #  SOAP 1.1 schema Id.
123    SOAP11ENV_SCHEMA_LOCATION = SCHEMA_DIR + SCHEMA_DIR + "soap-envelope.xsd"
124   
125    #  SOAP 1.1 Envelope XML namespace.
126    SOAP11ENV_NS = "http://schemas.xmlsoap.org/soap/envelope/"
127   
128    #  SOAP 1.1 Envelope QName prefix.
129    SOAP11ENV_PREFIX = "SOAP-ENV"
130   
131    #  Liberty PAOS XML Namespace.
132    PAOS_NS = "urn:liberty:paos:2003-08"
133   
134    #  Liberty PAOS QName prefix.
135    PAOS_PREFIX = "paos"
136   
137    #    SAML 1.X
138   
139    # SAML 1.0 Assertion schema system Id.
140    SAML10_SCHEMA_LOCATION = SCHEMA_DIR + "cs-sstc-schema-assertion-01.xsd"
141   
142    # SAML 1.1 Assertion schema system Id.
143    SAML11_SCHEMA_LOCATION = SCHEMA_DIR + "cs-sstc-schema-assertion-1.1.xsd"
144   
145    # SAML 1.X XML namespace.
146    SAML1_NS = "urn:oasis:names:tc:SAML:1.0:assertion"
147   
148    # SAML 1.0 Protocol schema system Id.
149    SAML10P_SCHEMA_LOCATION = SCHEMA_DIR + "cs-sstc-schema-protocol-01.xsd"
150   
151    # SAML 1.1 Protocol schema system Id.
152    SAML11P_SCHEMA_LOCATION = SCHEMA_DIR + "cs-sstc-schema-protocol-1.1.xsd"
153
154    # SAML 1.X protocol XML namespace.
155    SAML10P_NS = "urn:oasis:names:tc:SAML:1.0:protocol"
156   
157    # SAML 1.1 protocol XML namespace, used only in SAML 2 metadata protocol
158    # SupportEnumeration.
159    SAML11P_NS = "urn:oasis:names:tc:SAML:1.1:protocol"
160   
161    # SAML 1.X Protocol QName prefix.
162    SAML1P_PREFIX = "samlp"
163
164    # SAML 1.X Assertion QName prefix.
165    SAML1_PREFIX = "saml"
166   
167    # SAML 1 Metadata extension XML namespace.
168    SAML1MD_NS = "urn:oasis:names:tc:SAML:profiles:v1metadata"
169   
170    # SAML 1 Metadata extension schema system Id.
171    SAML1MD_SCHEMA_LOCATION = SCHEMA_DIR + "sstc-saml1x-metadata.xsd"
172   
173    # SAML 1 Metadata extension namespace prefix.
174    SAML1MD_PREFIX = "saml1md"
175   
176    # URI for SAML 1 Artifact binding.
177    SAML1_ARTIFACT_BINDING_URI = \
178        "urn:oasis:names:tc:SAML:1.0:profiles:artifact-01"
179   
180    # URI for SAML 1 POST binding.
181    SAML1_POST_BINDING_URI = \
182        "urn:oasis:names:tc:SAML:1.0:profiles:browser-post"
183   
184    # URI for SAML 1 SOAP 1.1 binding.
185    SAML1_SOAP11_BINDING_URI = \
186        "urn:oasis:names:tc:SAML:1.0:bindings:SOAP-binding"
187   
188    #    SAML 2.0
189   
190    # SAML 2.0 Assertion schema Id.
191    SAML20_SCHEMA_LOCATION = SCHEMA_DIR + "saml-schema-assertion-2.0.xsd"
192   
193    # SAML 2.0 Assertion XML Namespace.
194    SAML20_NS = "urn:oasis:names:tc:SAML:2.0:assertion"
195   
196    # SAML 2.0 Assertion QName prefix.
197    SAML20_PREFIX ="saml"
198   
199    # SAML 2.0 Protocol schema Id.
200    SAML20P_SCHEMA_LOCATION = SCHEMA_DIR + "saml-schema-protocol-2.0.xsd"
201   
202    # SAML 2.0 Protocol XML Namespace.
203    SAML20P_NS = "urn:oasis:names:tc:SAML:2.0:protocol"
204   
205    # SAML 2.0 Protocol QName prefix.
206    SAML20P_PREFIX ="samlp"
207   
208    # SAML 2.0 Protocol Third-party extension schema Id.
209    SAML20PTHRPTY_SCHEMA_LOCATION = SCHEMA_DIR + \
210                                    "sstc-saml-protocol-ext-thirdparty.xsd"
211   
212    # SAML 2.0 Protocol XML Namespace.
213    SAML20PTHRPTY_NS = "urn:oasis:names:tc:SAML:protocol:ext:third-party"
214   
215    # SAML 2.0 Protocol QName prefix.
216    SAML20PTHRPTY_PREFIX ="thrpty"
217   
218    # SAML 2.0 Metadata schema Id.
219    SAML20MD_SCHEMA_LOCATION = SCHEMA_DIR + "saml-schema-metadata-2.0.xsd"
220   
221    # SAML 2.0 Metadata XML Namespace.
222    SAML20MD_NS ="urn:oasis:names:tc:SAML:2.0:metadata"
223   
224    # SAML 2.0 Standalone Query Metadata extension XML namespace.
225    SAML20MDQUERY_NS = "urn:oasis:names:tc:SAML:metadata:ext:query"
226   
227    # SAML 2.0 Standalone Query Metadata extension schema system Id.
228    SAML20MDQUERY_SCHEMA_LOCATION = SCHEMA_DIR + \
229                                    "sstc-saml-metadata-ext-query.xsd"
230   
231    # SAML 2.0 Standalone Query Metadata extension prefix.
232    SAML20MDQUERY_PREFIX = "query"
233   
234    # SAML 2.0 Metadata QName prefix.
235    SAML20MD_PREFIX = "md"
236   
237    # SAML 2.0 Authentication Context schema Id.
238    SAML20AC_SCHEMA_LOCATION = SCHEMA_DIR + "saml-schema-authn-context-2.0.xsd"
239   
240    # SAML 2.0 Authentication Context XML Namespace.
241    SAML20AC_NS ="urn:oasis:names:tc:SAML:2.0:ac"
242   
243    # SAML 2.0 Authentication Context QName prefix.
244    SAML20AC_PREFIX = "ac"
245   
246    # SAML 2.0 Enhanced Client/Proxy SSO Profile schema Id.
247    SAML20ECP_SCHEMA_LOCATION = SCHEMA_DIR + "saml-schema-ecp-2.0.xsd"
248   
249    # SAML 2.0 Enhanced Client/Proxy SSO Profile XML Namespace.
250    SAML20ECP_NS = "urn:oasis:names:tc:SAML:2.0:profiles:SSO:ecp"
251   
252    # SAML 2.0 Enhanced Client/Proxy SSO Profile QName prefix.
253    SAML20ECP_PREFIX = "ecp"
254   
255    # SAML 2.0 DCE PAC Attribute Profile schema Id.
256    SAML20DCE_SCHEMA_LOCATION = SCHEMA_DIR + "saml-schema-dce-2.0.xsd"
257   
258    # SAML 2.0 DCE PAC Attribute Profile XML Namespace.
259    SAML20DCE_NS = "urn:oasis:names:tc:SAML:2.0:profiles:attribute:DCE"
260   
261    # SAML 2.0 DCE PAC Attribute Profile QName prefix.
262    SAML20DCE_PREFIX = "DCE"
263   
264    # SAML 2.0 X.500 Attribute Profile schema Id.
265    SAML20X500_SCHEMA_LOCATION = SCHEMA_DIR + "saml-schema-x500-2.0.xsd"
266   
267    # SAML 2.0 X.500 Attribute Profile XML Namespace.
268    SAML20X500_NS = "urn:oasis:names:tc:SAML:2.0:profiles:attribute:X500"
269   
270    # SAML 2.0 X.500 Attribute Profile QName prefix.
271    SAML20X500_PREFIX = "x500"
272   
273    # SAML 2.0 XACML Attribute Profile schema Id.
274    SAML20XACML_SCHEMA_LOCATION = SCHEMA_DIR + "saml-schema-xacml-2.0.xsd"
275   
276    # SAML 2.0 XACML Attribute Profile XML Namespace.
277    SAML20XACML_NS = "urn:oasis:names:tc:SAML:2.0:profiles:attribute:XACML"
278   
279    # SAML 2.0 XACML Attribute Profile QName prefix.
280    SAML20XACML_PREFIX = "xacmlprof"
281   
282    # URI for SAML 2 Artifact binding.
283    SAML2_ARTIFACT_BINDING_URI = \
284                        "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Artifact"
285   
286    # URI for SAML 2 POST binding.
287    SAML2_POST_BINDING_URI = "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"
288   
289    # URI for SAML 2 POST-SimpleSign binding.
290    SAML2_POST_SIMPLE_SIGN_BINDING_URI = \
291                "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST-SimpleSign"
292   
293    # URI for SAML 2 HTTP redirect binding.
294    SAML2_REDIRECT_BINDING_URI = \
295                "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect"
296   
297    # URI for SAML 2 SOAP binding.
298    SAML2_SOAP11_BINDING_URI = "urn:oasis:names:tc:SAML:2.0:bindings:SOAP"
Note: See TracBrowser for help on using the repository browser.