Changeset 6901 for TI12-security/trunk/ndg_saml
- Timestamp:
- 28/05/10 12:45:03 (11 years ago)
- Location:
- TI12-security/trunk/ndg_saml/ndg/saml
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
TI12-security/trunk/ndg_saml/ndg/saml/common/__init__.py
r6900 r6901 201 201 @param version: SAML version to test 202 202 @type version: SAMLVersion, basestring, tuple or list 203 @return: True if input and this object match 204 @rtype: bool 203 205 @raise TypeError: unexpected type for version input 204 206 """ … … 220 222 @param version: SAML version to test 221 223 @type version: SAMLVersion, basestring, tuple or list 224 @return: True if input and this object don't match 225 @rtype: bool 222 226 @raise TypeError: unexpected type for version input 223 227 """ … … 229 233 @param version: SAML version to test 230 234 @type version: SAMLVersion, basestring, tuple or list 235 @return: True if this instance version greater than input version 236 @rtype: bool 231 237 @raise TypeError: unexpected type for version input 232 238 """ … … 244 250 @param version: SAML version to test 245 251 @type version: SAMLVersion, basestring, tuple or list 252 @return: True if this instance version less than input version 253 @rtype: bool 246 254 @raise TypeError: unexpected type for version input 247 255 """ … … 260 268 @param version: SAML version to test 261 269 @type version: SAMLVersion, basestring, tuple or list 270 @return: True if this instance version greater than or equal to input 271 version 272 @rtype: bool 262 273 @raise TypeError: unexpected type for version input 263 274 """ … … 276 287 @param version: SAML version to test 277 288 @type version: SAMLVersion, basestring, tuple or list 289 @return: True if this instance version less than or equal to input 290 version 291 @rtype: bool 278 292 @raise TypeError: unexpected type for version input 279 293 """ -
TI12-security/trunk/ndg_saml/ndg/saml/common/xml.py
r6900 r6901 31 31 from ndg.saml.xml import XMLConstants 32 32 33 33 34 class SAMLConstants(XMLConstants): 34 '''XML related constants used in the SAML specifications.''' 35 '''XML related constants used in the SAML specifications. 36 @cvar POST_METHOD: HTTP Request Method - POST. 37 @type POST_METHOD: string 38 @cvar GET_METHOD: HTTP Method - GET. 39 @type GET_METHOD: string 40 @cvar SCHEMA_DIR: Directory, on the classpath, schemas are located in. 41 @type SCHEMA_DIR: string 42 @cvar XML_SCHEMA_LOCATION: XML core schema system Id. 43 @type XML_SCHEMA_LOCATION: string 44 @cvar XMLSIG_SCHEMA_LOCATION: XML Signature schema Id. 45 @type XMLSIG_SCHEMA_LOCATION: string 46 @cvar XMLENC_SCHEMA_LOCATION: XML Encryption schema Id. 47 @type XMLENC_SCHEMA_LOCATION: string 48 @cvar SOAP11ENV_SCHEMA_LOCATION: SOAP 1.1 schema Id. 49 @type SOAP11ENV_SCHEMA_LOCATION: string 50 @cvar SOAP11ENV_NS: SOAP 1.1 Envelope XML namespace. 51 @type SOAP11ENV_NS: string 52 @cvar SOAP11ENV_PREFIX: SOAP 1.1 Envelope QName prefix. 53 @type SOAP11ENV_PREFIX: string 54 @cvar PAOS_NS: Liberty PAOS XML Namespace. 55 @type PAOS_NS: string 56 @cvar PAOS_PREFIX: Liberty PAOS QName prefix. 57 @type PAOS_PREFIX: string 58 @cvar SAML10_SCHEMA_LOCATION: SAML 1.0 Assertion schema system Id. 59 @type SAML10_SCHEMA_LOCATION: string 60 @cvar SAML11_SCHEMA_LOCATION: SAML 1.1 Assertion schema system Id. 61 @type SAML11_SCHEMA_LOCATION: string 62 @cvar SAML1_NS: SAML 1.X XML namespace. 63 @type SAML1_NS: string 64 @cvar SAML10P_SCHEMA_LOCATION: SAML 1.0 Protocol schema system Id. 65 @type SAML10P_SCHEMA_LOCATION: string 66 @cvar SAML11P_SCHEMA_LOCATION: SAML 1.1 Protocol schema system Id. 67 @type SAML11P_SCHEMA_LOCATION: string 68 @cvar SAML10P_NS: SAML 1.X protocol XML namespace. 69 @type SAML10P_NS: string 70 @cvar SAML11P_NS: SupportEnumeration. 71 @type SAML11P_NS: string 72 @cvar SAML1P_PREFIX: SAML 1.X Protocol QName prefix. 73 @type SAML1P_PREFIX: string 74 @cvar SAML1_PREFIX: SAML 1.X Assertion QName prefix. 75 @type SAML1_PREFIX: string 76 @cvar SAML1MD_NS: SAML 1 Metadata extension XML namespace. 77 @type SAML1MD_NS: string 78 @cvar SAML1MD_SCHEMA_LOCATION: SAML 1 Metadata extension schema system Id. 79 @type SAML1MD_SCHEMA_LOCATION: string 80 @cvar SAML1MD_PREFIX: SAML 1 Metadata extension namespace prefix. 81 @type SAML1MD_PREFIX: string 82 @cvar SAML1_ARTIFACT_BINDING_URI: URI for SAML 1 Artifact binding. 83 @type SAML1_ARTIFACT_BINDING_URI: string 84 @cvar SAML1_POST_BINDING_URI: URI for SAML 1 POST binding. 85 @type SAML1_POST_BINDING_URI: string 86 @cvar SAML1_SOAP11_BINDING_URI: URI for SAML 1 SOAP 1.1 binding. 87 @type SAML1_SOAP11_BINDING_URI: string 88 @cvar SAML20_SCHEMA_LOCATION: SAML 2.0 Assertion schema Id. 89 @type SAML20_SCHEMA_LOCATION: string 90 @cvar SAML20_NS: SAML 2.0 Assertion XML Namespace. 91 @type SAML20_NS: string 92 @cvar SAML20_PREFIX: SAML 2.0 Assertion QName prefix. 93 @type SAML20_PREFIX: string 94 @cvar SAML20P_SCHEMA_LOCATION: SAML 2.0 Protocol schema Id. 95 @type SAML20P_SCHEMA_LOCATION: string 96 @cvar SAML20P_NS: SAML 2.0 Protocol XML Namespace. 97 @type SAML20P_NS: string 98 @cvar SAML20P_PREFIX: SAML 2.0 Protocol QName prefix. 99 @type SAML20P_PREFIX: string 100 @cvar SAML20PTHRPTY_SCHEMA_LOCATION: SAML 2.0 Protocol Third-party extension schema Id. 101 @type SAML20PTHRPTY_SCHEMA_LOCATION: string 102 @cvar SAML20PTHRPTY_NS: SAML 2.0 Protocol XML Namespace. 103 @type SAML20PTHRPTY_NS: string 104 @cvar SAML20PTHRPTY_PREFIX: SAML 2.0 Protocol QName prefix. 105 @type SAML20PTHRPTY_PREFIX: string 106 @cvar SAML20MD_SCHEMA_LOCATION: SAML 2.0 Metadata schema Id. 107 @type SAML20MD_SCHEMA_LOCATION: string 108 @cvar SAML20MD_NS: SAML 2.0 Metadata XML Namespace. 109 @type SAML20MD_NS: string 110 @cvar SAML20MDQUERY_NS: SAML 2.0 Standalone Query Metadata extension XML namespace. 111 @type SAML20MDQUERY_NS: string 112 @cvar SAML20MDQUERY_SCHEMA_LOCATION: SAML 2.0 Standalone Query Metadata extension schema system Id. 113 @type SAML20MDQUERY_SCHEMA_LOCATION: string 114 @cvar SAML20MDQUERY_PREFIX: SAML 2.0 Standalone Query Metadata extension prefix. 115 @type SAML20MDQUERY_PREFIX: string 116 @cvar SAML20MD_PREFIX: SAML 2.0 Metadata QName prefix. 117 @type SAML20MD_PREFIX: string 118 @cvar SAML20AC_SCHEMA_LOCATION: SAML 2.0 Authentication Context schema Id. 119 @type SAML20AC_SCHEMA_LOCATION: string 120 @cvar SAML20AC_NS: SAML 2.0 Authentication Context XML Namespace. 121 @type SAML20AC_NS: string 122 @cvar SAML20AC_PREFIX: SAML 2.0 Authentication Context QName prefix. 123 @type SAML20AC_PREFIX: string 124 @cvar SAML20ECP_SCHEMA_LOCATION: SAML 2.0 Enhanced Client/Proxy SSO Profile schema Id. 125 @type SAML20ECP_SCHEMA_LOCATION: string 126 @cvar SAML20ECP_NS: SAML 2.0 Enhanced Client/Proxy SSO Profile XML Namespace. 127 @type SAML20ECP_NS: string 128 @cvar SAML20ECP_PREFIX: SAML 2.0 Enhanced Client/Proxy SSO Profile QName prefix. 129 @type SAML20ECP_PREFIX: string 130 @cvar SAML20DCE_SCHEMA_LOCATION: SAML 2.0 DCE PAC Attribute Profile schema Id. 131 @type SAML20DCE_SCHEMA_LOCATION: string 132 @cvar SAML20DCE_NS: SAML 2.0 DCE PAC Attribute Profile XML Namespace. 133 @type SAML20DCE_NS: string 134 @cvar SAML20DCE_PREFIX: SAML 2.0 DCE PAC Attribute Profile QName prefix. 135 @type SAML20DCE_PREFIX: string 136 @cvar SAML20X500_SCHEMA_LOCATION: SAML 2.0 X.500 Attribute Profile schema Id. 137 @type SAML20X500_SCHEMA_LOCATION: string 138 @cvar SAML20X500_NS: SAML 2.0 X.500 Attribute Profile XML Namespace. 139 @type SAML20X500_NS: string 140 @cvar SAML20X500_PREFIX: SAML 2.0 X.500 Attribute Profile QName prefix. 141 @type SAML20X500_PREFIX: string 142 @cvar SAML20XACML_SCHEMA_LOCATION: SAML 2.0 XACML Attribute Profile schema Id. 143 @type SAML20XACML_SCHEMA_LOCATION: string 144 @cvar SAML20XACML_NS: SAML 2.0 XACML Attribute Profile XML Namespace. 145 @type SAML20XACML_NS: string 146 @cvar SAML20XACML_PREFIX: SAML 2.0 XACML Attribute Profile QName prefix. 147 @type SAML20XACML_PREFIX: string 148 @cvar SAML2_ARTIFACT_BINDING_URI: URI for SAML 2 Artifact binding. 149 @type SAML2_ARTIFACT_BINDING_URI: string 150 @cvar SAML2_POST_BINDING_URI: URI for SAML 2 POST binding. 151 @type SAML2_POST_BINDING_URI: string 152 @cvar SAML2_POST_SIMPLE_SIGN_BINDING_URI: URI for SAML 2 POST-SimpleSign binding. 153 @type SAML2_POST_SIMPLE_SIGN_BINDING_URI: string 154 @cvar SAML2_REDIRECT_BINDING_URI: URI for SAML 2 HTTP redirect binding. 155 @type SAML2_REDIRECT_BINDING_URI: string 156 @cvar SAML2_SOAP11_BINDING_URI: URI for SAML 2 SOAP binding. 157 @type SAML2_SOAP11_BINDING_URI: string 158 ''' 35 159 36 160 # HTTP Constants … … 241 365 242 366 class QName(object): 243 """XML Qualified Name""" 367 """XML Qualified Name 368 @ivar __namespaceURI: the namespace the element is in 369 @type __namespaceURI: basestring 370 @ivar __localPart: the local name of the XML element 371 @type __localPart: basestring 372 @ivar __prefix: the prefix for the given namespace 373 @type __prefix: basestring 374 """ 244 375 245 376 def __init__(self, namespaceURI, localPart, prefix): 377 ''' 378 @param namespaceURI: the namespace the element is in 379 @type namespaceURI: basestring 380 @param localPart: the local name of the XML element 381 @type localPart: basestring 382 @param prefix: the prefix for the given namespace 383 @type prefix: basestring 384 ''' 246 385 self.namespaceURI = namespaceURI 247 386 self.localPart = localPart … … 249 388 250 389 def _getPrefix(self): 390 """Get prefix 391 @return: prefix 392 @rtype: string 393 """ 251 394 return self.__prefix 252 395 253 396 def _setPrefix(self, value): 397 """Set prefix 398 @param: prefix 399 @type: string 400 @raise TypeError: invalid input value type 401 """ 254 402 if not isinstance(value, basestring): 255 403 raise TypeError('Expected string type for "prefix"; got %r' % … … 260 408 261 409 def _getLocalPart(self): 410 """Get local part 411 @return: local part 412 @rtype: string 413 """ 262 414 return self.__localPart 263 415 264 416 def _setLocalPart(self, value): 417 """Set local part 418 @param: local part 419 @type: string 420 @raise TypeError: invalid input value type 421 """ 265 422 if not isinstance(value, basestring): 266 423 raise TypeError('Expected string type for "localPart"; got %r' % … … 271 428 272 429 def _getNamespaceURI(self): 430 """Get namespace URI 431 @return: namespace URI 432 @rtype: string 433 """ 273 434 return self.__namespaceURI 274 435 275 436 def _setNamespaceURI(self, value): 437 """Set namespace URI 438 @param: namespace URI 439 @type: string 440 @raise TypeError: invalid input value type 441 """ 276 442 if not isinstance(value, basestring): 277 443 raise TypeError('Expected string type for "namespaceURI"; got %r' % … … 286 452 @type qname: saml.common.xml.QName 287 453 @param qname: Qualified Name to compare with self 454 @return: True if input and this object match 455 @rtype: bool 288 456 """ 289 457 if not isinstance(qname, QName): … … 297 465 @type qname: saml.common.xml.QName 298 466 @param qname: Qualified Name to compare with self 467 @return: True if input and this object don't match 468 @rtype: bool 299 469 """ 300 470 return not self.__eq__(qname) -
TI12-security/trunk/ndg_saml/ndg/saml/saml2/core.py
r6900 r6901 39 39 40 40 class Attribute(SAMLObject): 41 '''SAML 2.0 Core Attribute.''' 41 '''SAML 2.0 Core Attribute. 42 @cvar DEFAULT_ELEMENT_LOCAL_NAME: Local name of the Attribute element. 43 @type DEFAULT_ELEMENT_LOCAL_NAME: string 44 @cvar DEFAULT_ELEMENT_NAME: Default element name. 45 @type DEFAULT_ELEMENT_NAME: ndg.saml.common.xml.QName 46 @cvar TYPE_LOCAL_NAME: Local name of the XSI type. 47 @type TYPE_LOCAL_NAME: string 48 @cvar TYPE_NAME: QName of the XSI type. 49 @type TYPE_NAME: ndg.saml.common.xml.QName 50 @cvar NAME_ATTRIB_NAME: Name of the Name attribute. 51 @type NAME_ATTRIB_NAME: string 52 @cvar NAME_FORMAT_ATTRIB_NAME: Name for the NameFormat attribute. 53 @type NAME_FORMAT_ATTRIB_NAME: string 54 @cvar FRIENDLY_NAME_ATTRIB_NAME: Name of the FriendlyName attribute. 55 @type FRIENDLY_NAME_ATTRIB_NAME: string 56 @cvar UNSPECIFIED: Unspecified attribute format ID. 57 @type UNSPECIFIED: string 58 @cvar URI_REFERENCE: URI reference attribute format ID. 59 @type URI_REFERENCE: string 60 @cvar BASIC: Basic attribute format ID. 61 @type BASIC: string 62 63 @ivar __name: attribute name 64 @type __name: NoneType / basestring 65 @ivar __nameFormat: name format 66 @type __nameFormat: NoneType / basestring 67 @ivar __friendlyName: friendly name for attribute 68 @type __friendlyName: NoneType / basestring 69 @ivar __attributeValues: list of values 70 @type __attributeValues: list / tuple 71 ''' 42 72 43 73 # Local name of the Attribute element. … … 83 113 84 114 def __init__(self, **kw): 85 """Initialise Attribute Class attributes""" 115 """Initialise Attribute Class attributes 116 @param **kw: keywords SAMLObject parent instantiation 117 @type **kw: dict 118 """ 86 119 super(Attribute, self).__init__(**kw) 87 120 … … 92 125 93 126 def __getstate__(self): 94 '''Enable pickling''' 127 '''Enable pickling 128 129 @return: object's attribute dictionary 130 @rtype: dict 131 ''' 95 132 _dict = super(Attribute, self).__getstate__() 96 133 for attrName in Attribute.__slots__: … … 105 142 106 143 def _get_name(self): 144 """Get name 145 @return: name 146 @rtype: string 147 """ 107 148 return self.__name 108 149 109 150 def _set_name(self, name): 151 """Set name 152 @param: name 153 @type: name 154 @raise TypeError: invalid input value type 155 """ 110 156 if not isinstance(name, basestring): 111 157 raise TypeError("Expecting basestring type for name, got %r"% … … 119 165 120 166 def _get_nameFormat(self): 167 """Get name format 168 @return: name format 169 @rtype: string 170 """ 121 171 return self.__nameFormat 122 172 123 173 def _set_nameFormat(self, nameFormat): 174 """Set name format 175 @param: name format 176 @type: string 177 @raise TypeError: invalid input value type 178 """ 124 179 if not isinstance(nameFormat, basestring): 125 180 raise TypeError("Expecting basestring type for nameFormat, got %r" … … 133 188 134 189 def _get_friendlyName(self): 190 """Get friendly name 191 @return: friendly name 192 @rtype: string 193 """ 135 194 return self.__friendlyName 136 195 137 196 def _set_friendlyName(self, friendlyName): 197 """Set friendly name 198 @param: friendly name 199 @type: string 200 @raise TypeError: invalid input value type 201 """ 138 202 if not isinstance(friendlyName, basestring): 139 203 raise TypeError("Expecting basestring type for friendlyName, got " … … 147 211 148 212 def _get_attributeValues(self): 213 """Get attribute values 214 @return: attribute values 215 @rtype: string 216 """ 149 217 return self.__attributeValues 150 218 151 219 def _set_attributeValues(self, attributeValues): 220 """Set attribute values 221 @param: attribute values 222 @type: string 223 @raise TypeError: invalid input value type 224 """ 152 225 if not isinstance(attributeValues, (list, tuple)): 153 raise TypeError("Expecting basestringtype for attributeValues, "226 raise TypeError("Expecting list/tuple type for attributeValues, " 154 227 "got %r" % type(attributeValues)) 155 228 … … 164 237 class Statement(SAMLObject): 165 238 '''SAML 2.0 Core Statement. Abstract base class which all statement 166 types must implement.''' 239 types must implement. 240 241 @cvar DEFAULT_ELEMENT_LOCAL_NAME: Element local name 242 @type DEFAULT_ELEMENT_LOCAL_NAME: string 243 @cvar DEFAULT_ELEMENT_NAME: Default element name 244 @type DEFAULT_ELEMENT_NAME: ndg.saml.common.xml.QName 245 @cvar TYPE_LOCAL_NAME: Local name of the XSI type 246 @type TYPE_LOCAL_NAME: string 247 @cvar TYPE_NAME: QName of the XSI type 248 @type TYPE_NAME: ndg.saml.common.xml.QName 249 ''' 167 250 __slots__ = () 168 251 … … 185 268 186 269 class AttributeStatement(Statement): 187 '''SAML 2.0 Core AttributeStatement''' 270 '''SAML 2.0 Core AttributeStatement 271 272 @cvar DEFAULT_ELEMENT_LOCAL_NAME: Element local name 273 @type DEFAULT_ELEMENT_LOCAL_NAME: string 274 @cvar DEFAULT_ELEMENT_NAME: Default element name. 275 @type DEFAULT_ELEMENT_NAME: ndg.saml.common.xml.QName 276 @cvar TYPE_LOCAL_NAME: Local name of the XSI type. 277 @type TYPE_LOCAL_NAME: string 278 @cvar TYPE_NAME: QName of the XSI type. 279 @type TYPE_NAME: ndg.saml.common.xml.QName 280 281 @ivar __attributes: list of ndg.saml.saml2.core.Attribute type attributes 282 @type __attributes: ndg.saml.utils.TypedList 283 @ivar __encryptedAttributes: list of encrypted attributes of type 284 ndg.saml.saml2.core.Attribute 285 @type __encryptedAttributes: ndg.saml.utils.TypedList 286 ''' 188 287 189 288 # Element local name … … 206 305 207 306 def __init__(self, **kw): 307 """ 308 @param **kw: keywords Statement parent class instantiation 309 @type **kw: dict 310 """ 208 311 super(AttributeStatement, self).__init__(**kw) 209 312 … … 212 315 213 316 def __getstate__(self): 214 '''Enable pickling''' 317 '''Enable pickling 318 319 @return: object's attribute dictionary 320 @rtype: dict 321 ''' 322 215 323 _dict = super(AttributeStatement, self).__getstate__() 216 324 for attrName in AttributeStatement.__slots__: … … 226 334 def _get_attributes(self): 227 335 '''@return: the attributes expressed in this statement 336 @rtype: ndg.saml.utils.TypedList 228 337 ''' 229 338 return self.__attributes … … 233 342 def _get_encryptedAttributes(self): 234 343 '''@return: the encrypted attribtues expressed in this statement 344 @rtype: ndg.saml.utils.TypedList 235 345 ''' 236 346 return self.__encryptedAttributes … … 242 352 '''SAML 2.0 Core AuthnStatement. Currently implemented in abstract form 243 353 only 354 355 @cvar DEFAULT_ELEMENT_LOCAL_NAME: Element local name 356 @type DEFAULT_ELEMENT_LOCAL_NAME: string 357 @cvar DEFAULT_ELEMENT_NAME: Default element name 358 @type DEFAULT_ELEMENT_NAME: ndg.saml.common.xml.QName 359 @cvar TYPE_LOCAL_NAME: Local name of the XSI type 360 @type TYPE_LOCAL_NAME: string 361 @cvar TYPE_NAME: QName of the XSI type 362 @type TYPE_NAME: ndg.saml.common.xml.QName 363 @cvar AUTHN_INSTANT_ATTRIB_NAME: AuthnInstant attribute name 364 @type AUTHN_INSTANT_ATTRIB_NAME: string 365 @cvar SESSION_INDEX_ATTRIB_NAME: SessionIndex attribute name 366 @type SESSION_INDEX_ATTRIB_NAME: string 367 @cvar SESSION_NOT_ON_OR_AFTER_ATTRIB_NAME: SessionNoOnOrAfter attribute name 368 @type SESSION_NOT_ON_OR_AFTER_ATTRIB_NAME: string 244 369 ''' 245 370 … … 272 397 273 398 def _getAuthnInstant(self): 274 ''' Gets the time when the authentication took place.399 '''Abstract method. Gets the time when the authentication took place. 275 400 276 401 @return: the time when the authentication took place 402 @rtype: datetime.datetime 403 @raise NotImplementedError: abstract method 277 404 ''' 278 405 raise NotImplementedError() … … 282 409 283 410 @param value: the time when the authentication took place 411 @type: datetime.datetime 412 @raise NotImplementedError: abstract method 284 413 ''' 285 414 raise NotImplementedError() … … 291 420 @return: the session index between the principal and the authenticating 292 421 authority 422 @rtype: ? 423 @raise NotImplementedError: abstract method 293 424 ''' 294 425 raise NotImplementedError() … … 300 431 @param value: the session index between the principal and the 301 432 authenticating authority 433 @type: ? 434 @raise NotImplementedError: abstract method 302 435 ''' 303 436 raise NotImplementedError() … … 309 442 @return: the time when the session between the principal and the SAML 310 443 authority ends 444 @rtype: datetime.datetime 445 @raise NotImplementedError: abstract method 311 446 ''' 312 447 raise NotImplementedError() … … 318 453 @param value: the time when the session between the 319 454 principal and the SAML authority ends 455 @type: datetime.datetime 456 @raise NotImplementedError: abstract method 320 457 ''' 321 458 raise NotImplementedError() … … 327 464 @return: the DNS domain and IP address of the system where the principal 328 465 was authenticated 466 @rtype: ? 467 @raise NotImplementedError: abstract method 329 468 ''' 330 469 raise NotImplementedError() … … 336 475 @param value: the DNS domain and IP address of the system where 337 476 the principal was authenticated 477 @type: ? 478 @raise NotImplementedError: abstract method 338 479 ''' 339 480 raise NotImplementedError() … … 343 484 344 485 @return: the context used to authenticate the subject 486 @type: ? 487 @raise NotImplementedError: abstract method 345 488 ''' 346 489 raise NotImplementedError() … … 350 493 351 494 @param value: the context used to authenticate the subject 495 @type: ? 496 @raise NotImplementedError: abstract method 352 497 ''' 353 498 raise NotImplementedError() … … 355 500 356 501 class DecisionType(object): 357 """Define decision types for the authorisation decisions""" 502 """Define decision types for the authorisation decisions 503 504 @cvar PERMIT_STR: "Permit" decision type 505 @type PERMIT_STR: string 506 @cvar DENY_STR: "Deny" decision type 507 @type DENY_STR: string 508 @cvar INDETERMINATE_STR: "Indeterminate" decision type 509 @type INDETERMINATE_STR: string 510 @cvar TYPES: Permissable type strings 511 @type TYPES: string 512 513 @cvar PERMIT: permit as a decision type subclass 514 @type PERMIT: ndg.saml.saml2.core.PermitDecisionType 515 @cvar DENY: deny as a decision type subclass 516 @type DENY: ndg.saml.saml2.core.DenyDecisionType 517 @cvar INDETERMINATE: indeterminate as a decision type subclass 518 @type INDETERMINATE: ndg.saml.saml2.core.IndeterminateDecisionType 519 520 @ivar __value: decision value 521 @type __value: string 522 """ 358 523 359 524 # "Permit" decision type … … 365 530 # "Indeterminate" decision type 366 531 INDETERMINATE_STR = "Indeterminate" 367 532 533 # Permissable type strings 368 534 TYPES = (PERMIT_STR, DENY_STR, INDETERMINATE_STR) 369 535 … … 371 537 372 538 def __init__(self, decisionType): 539 '''@param decisionType: decision value 540 @type decisionType: string/ndg.saml.saml2.core.DecisionType 541 ''' 373 542 self.__value = None 374 543 self.value = decisionType 375 544 376 545 def __getstate__(self): 377 '''Enable pickling''' 546 '''Enable pickling 547 548 @return: object's attribute dictionary 549 @rtype: dict 550 ''' 551 378 552 _dict = {} 379 553 for attrName in DecisionType.__slots__: … … 388 562 389 563 def __setstate__(self, attrDict): 390 '''Enable pickling''' 564 '''Enable pickling 565 566 @param attrDict: object's attribute dictionary 567 @type attrDict: dict 568 ''' 391 569 for attrName, val in attrDict.items(): 392 570 setattr(self, attrName, val) 393 571 394 572 def _setValue(self, value): 573 '''Set decision type 574 @param value: decision value 575 @type value: string/ndg.saml.saml2.core.DecisionType 576 ''' 395 577 if isinstance(value, DecisionType): 396 578 # Cast to string … … 407 589 408 590 def _getValue(self): 591 '''Get decision type 592 @return: decision value 593 @rtype: string/ndg.saml.saml2.core.DecisionType 594 ''' 409 595 return self.__value 410 596 … … 412 598 413 599 def __str__(self): 600 '''Representation of decision type as a string 601 @return: decision value 602 @rtype: string 603 ''' 414 604 return self.__value 415 605 416 606 def __eq__(self, decision): 607 """Test for equality against an input decision type 608 609 @param version: decision type 610 @type version: ndg.saml.saml2.core.DecisionType or basestring 611 @return: True if input and this object match 612 @rtype: bool 613 @raise TypeError: unexpected type for decision type input 614 """ 417 615 if isinstance(decision, DecisionType): 418 616 # Cast to string … … 439 637 440 638 def __init__(self): 639 """Initialise with permit decision setting""" 441 640 super(PermitDecisionType, self).__init__(DecisionType.PERMIT_STR) 442 641 443 def _setValue(self): 642 def _setValue(self): 643 """ 644 @raise AttributeError: instances have read only decision type 645 """ 444 646 raise AttributeError("can't set attribute") 445 647 … … 450 652 451 653 def __init__(self): 654 """Initialise with deny decision setting""" 452 655 super(DenyDecisionType, self).__init__(DecisionType.DENY_STR) 453 656 454 657 def _setValue(self, value): 658 """ 659 @raise AttributeError: instances have read only decision type 660 """ 455 661 raise AttributeError("can't set attribute") 456 662 … … 461 667 462 668 def __init__(self): 669 """Initialise with indeterminate decision setting""" 463 670 super(IndeterminateDecisionType, self).__init__( 464 671 DecisionType.INDETERMINATE_STR) 465 672 466 673 def _setValue(self, value): 674 """ 675 @raise AttributeError: instances have read only decision type 676 """ 467 677 raise AttributeError("can't set attribute") 468 678 … … 527 737 528 738 def __getstate__(self): 529 '''Enable pickling''' 739 '''Enable pickling 740 741 @return: object's attribute dictionary 742 @rtype: dict 743 ''' 744 530 745 _dict = super(AuthzDecisionStatement, self).__getstate__() 531 746 for attrName in AuthzDecisionStatement.__slots__: … … 729 944 730 945 def __getstate__(self): 731 '''Enable pickling''' 946 '''Enable pickling 947 948 @return: object's attribute dictionary 949 @rtype: dict 950 ''' 951 732 952 _dict = super(Subject, self).__getstate__() 733 953 for attrName in Subject.__slots__: … … 875 1095 876 1096 def __getstate__(self): 877 '''Enable pickling''' 1097 '''Enable pickling 1098 1099 @return: object's attribute dictionary 1100 @rtype: dict 1101 ''' 1102 878 1103 _dict = super(AbstractNameIDType, self).__getstate__() 879 1104 for attrName in AbstractNameIDType.__slots__: … … 1031 1256 1032 1257 def __getstate__(self): 1033 '''Enable pickling''' 1258 '''Enable pickling 1259 1260 @return: object's attribute dictionary 1261 @rtype: dict 1262 ''' 1263 1034 1264 _dict = super(Conditions, self).__getstate__() 1035 1265 for attrName in Conditions.__slots__: … … 1233 1463 1234 1464 def __getstate__(self): 1235 '''Enable pickling''' 1465 '''Enable pickling 1466 1467 @return: object's attribute dictionary 1468 @rtype: dict 1469 ''' 1470 1236 1471 _dict = super(Assertion, self).__getstate__() 1237 1472 for attrName in Assertion.__slots__: … … 1419 1654 1420 1655 def __getstate__(self): 1421 '''Enable pickling''' 1656 '''Enable pickling 1657 1658 @return: object's attribute dictionary 1659 @rtype: dict 1660 ''' 1661 1422 1662 _dict = super(XSStringAttributeValue, self).__getstate__() 1423 1663 for attrName in XSStringAttributeValue.__slots__: … … 1472 1712 1473 1713 def __getstate__(self): 1474 '''Enable pickling''' 1714 '''Enable pickling 1715 1716 @return: object's attribute dictionary 1717 @rtype: dict 1718 ''' 1719 1475 1720 _dict = super(StatusDetail, self).__getstate__() 1476 1721 for attrName in StatusDetail.__slots__: … … 1524 1769 1525 1770 def __getstate__(self): 1526 '''Enable pickling''' 1771 '''Enable pickling 1772 1773 @return: object's attribute dictionary 1774 @rtype: dict 1775 ''' 1776 1527 1777 _dict = super(StatusMessage, self).__getstate__() 1528 1778 for attrName in StatusMessage.__slots__: … … 1663 1913 1664 1914 def __getstate__(self): 1665 '''Enable pickling''' 1915 '''Enable pickling 1916 1917 @return: object's attribute dictionary 1918 @rtype: dict 1919 ''' 1920 1666 1921 _dict = super(StatusCode, self).__getstate__() 1667 1922 for attrName in StatusCode.__slots__: … … 1736 1991 1737 1992 def __getstate__(self): 1738 '''Enable pickling''' 1993 '''Enable pickling 1994 1995 @return: object's attribute dictionary 1996 @rtype: dict 1997 ''' 1998 1739 1999 _dict = super(Status, self).__getstate__() 1740 2000 for attrName in Status.__slots__: … … 1931 2191 1932 2192 def __getstate__(self): 1933 '''Enable pickling''' 2193 '''Enable pickling 2194 2195 @return: object's attribute dictionary 2196 @rtype: dict 2197 ''' 2198 1934 2199 _dict = super(Action, self).__getstate__() 1935 2200 for attrName in Action.__slots__: … … 2113 2378 2114 2379 def __getstate__(self): 2115 '''Enable pickling''' 2380 '''Enable pickling 2381 2382 @return: object's attribute dictionary 2383 @rtype: dict 2384 ''' 2385 2116 2386 _dict = super(RequestAbstractType, self).__getstate__() 2117 2387 for attrName in RequestAbstractType.__slots__: … … 2275 2545 2276 2546 def __getstate__(self): 2277 '''Enable pickling''' 2547 '''Enable pickling 2548 2549 @return: object's attribute dictionary 2550 @rtype: dict 2551 ''' 2552 2278 2553 _dict = super(SubjectQuery, self).__getstate__() 2279 2554 for attrName in SubjectQuery.__slots__: … … 2332 2607 2333 2608 def __getstate__(self): 2334 '''Enable pickling''' 2609 '''Enable pickling 2610 2611 @return: object's attribute dictionary 2612 @rtype: dict 2613 ''' 2614 2335 2615 _dict = super(AttributeQuery, self).__getstate__() 2336 2616 for attrName in AttributeQuery.__slots__: … … 2383 2663 2384 2664 def __getstate__(self): 2385 '''Enable pickling''' 2665 '''Enable pickling 2666 2667 @return: object's attribute dictionary 2668 @rtype: dict 2669 ''' 2670 2386 2671 _dict = super(AssertionURIRef, self).__getstate__() 2387 2672 for attrName in AssertionURIRef.__slots__: … … 2437 2722 2438 2723 def __getstate__(self): 2439 '''Enable pickling''' 2724 '''Enable pickling 2725 2726 @return: object's attribute dictionary 2727 @rtype: dict 2728 ''' 2729 2440 2730 _dict = super(AssertionIDRef, self).__getstate__() 2441 2731 for attrName in AssertionIDRef.__slots__: … … 2546 2836 2547 2837 def __getstate__(self): 2548 '''Enable pickling''' 2838 '''Enable pickling 2839 2840 @return: object's attribute dictionary 2841 @rtype: dict 2842 ''' 2843 2549 2844 _dict = super(Evidence, self).__getstate__() 2550 2845 for attrName in Evidence.__slots__: … … 2661 2956 2662 2957 def __getstate__(self): 2663 '''Enable pickling''' 2958 '''Enable pickling 2959 2960 @return: object's attribute dictionary 2961 @rtype: dict 2962 ''' 2963 2664 2964 _dict = super(AuthzDecisionQuery, self).__getstate__() 2665 2965 for attrName in AuthzDecisionQuery.__slots__: … … 2877 3177 2878 3178 def __getstate__(self): 2879 '''Enable pickling''' 3179 '''Enable pickling 3180 3181 @return: object's attribute dictionary 3182 @rtype: dict 3183 ''' 3184 2880 3185 _dict = super(StatusResponseType, self).__getstate__() 2881 3186 for attrName in StatusResponseType.__slots__: … … 3101 3406 3102 3407 def __getstate__(self): 3103 '''Enable pickling''' 3408 '''Enable pickling 3409 3410 @return: object's attribute dictionary 3411 @rtype: dict 3412 ''' 3413 3104 3414 _dict = super(Response, self).__getstate__() 3105 3415 for attrName in Response.__slots__: -
TI12-security/trunk/ndg_saml/ndg/saml/test/test_saml.py
r6900 r6901 40 40 41 41 from ndg.saml.saml2.core import (SAMLVersion, Attribute, AttributeStatement, 42 AuthzDecisionStatement, Assertion, AttributeQuery, 43 Response, Issuer, Subject, NameID, StatusCode, 44 StatusMessage, Status, Conditions, DecisionType, 45 XSStringAttributeValue, Action, 46 AuthzDecisionQuery) 42 AuthzDecisionStatement, Assertion, 43 AttributeQuery, Response, Issuer, Subject, 44 NameID, StatusCode, StatusMessage, Status, 45 Conditions, DecisionType, 46 XSStringAttributeValue, Action, 47 AuthzDecisionQuery) 47 48 48 49 from ndg.saml.common.xml import SAMLConstants -
TI12-security/trunk/ndg_saml/ndg/saml/xml/__init__.py
r6900 r6901 32 32 33 33 class XMLConstants(object): 34 '''XML related constants.''' 34 '''XML related constants. 35 36 @cvar XMLTOOLING_CONFIG_NS: Configuration namespace 37 @type XMLTOOLING_CONFIG_NS: string 38 @cvar XMLTOOLING_CONFIG_PREFIX: Configuration namespace prefix 39 @type XMLTOOLING_CONFIG_PREFIX: string 40 @cvar XMLTOOLING_DEFAULT_OBJECT_PROVIDER: object provider 41 @type XMLTOOLING_DEFAULT_OBJECT_PROVIDER: string 42 @cvar XML_NS: XML core namespace 43 @type XML_NS: string 44 @cvar XML_PREFIX: XML core prefix for xml attributes 45 @type XML_PREFIX: string 46 @cvar XMLNS_NS: XML namespace for xmlns attributes 47 @type XMLNS_NS: string 48 @cvar XMLNS_PREFIX: XML namespace prefix for xmlns attributes 49 @type XMLNS_PREFIX: string 50 @cvar XSD_NS: XML Schema namespace 51 @type XSD_NS: string 52 @cvar XSD_PREFIX: XML Schema QName prefix 53 @type XSD_PREFIX: string 54 @cvar XSI_NS: XML Schema Instance namespace 55 @type XSI_NS: string 56 @cvar XSI_PREFIX: XML Schema Instance QName prefix 57 @type XSI_PREFIX: string 58 @cvar XMLSIG_NS: XML XMLSecSignatureImpl namespace 59 @type XMLSIG_NS: string 60 @cvar XMLSIG_PREFIX: XML XMLSecSignatureImpl QName prefix 61 @type XMLSIG_PREFIX: string 62 @cvar XMLENC_NS: XML Encryption namespace 63 @type XMLENC_NS: string 64 @cvar XMLENC_PREFIX: XML Encryption QName prefix 65 @type XMLENC_PREFIX: string 66 @cvar XMLENC_ENCDATA_LOCAL_NAME: Local name of EncryptedData element 67 @type XMLENC_ENCDATA_LOCAL_NAME: string 68 @cvar XMLENC_ENCKEY_LOCAL_NAME: Local name of EncryptedKey element 69 @type XMLENC_ENCKEY_LOCAL_NAME: string 70 ''' 35 71 36 72 # XML Tooling … … 92 128 93 129 class XMLTypeError(Exception): 94 pass130 """Generic XML type exception""" 95 131 96 132 class XMLTypeParseError(XMLTypeError): 97 pass133 """Parse error for XML type""" 98 134 99 135 class UnknownAttrProfile(XMLTypeError):
Note: See TracChangeset
for help on using the changeset viewer.