Changeset 7698 for TI12-security/trunk
- Timestamp:
- 04/11/10 13:55:40 (10 years ago)
- Location:
- TI12-security/trunk/NDGSecurity/python
- Files:
-
- 1 deleted
- 26 edited
Legend:
- Unmodified
- Added
- Removed
-
TI12-security/trunk/NDGSecurity/python/Tests/esg_integration/test_attributeserviceclient.cfg
r7681 r7698 16 16 subject = https://esg.prototype.ucar.edu/myopenid/testUser 17 17 18 attributeQuery.deserialise = ndg.security.common.saml_utils.esg .xml.etree:EsgResponseElementTree.fromXML18 attributeQuery.deserialise = ndg.security.common.saml_utils.esgf.xml.etree:ESGFResponseElementTree.fromXML 19 19 attributeQuery.subjectIdFormat = urn:esg:openid 20 20 attributeQuery.clockSkewTolerance = 1. … … 35 35 subject = https://esg.prototype.ucar.edu/myopenid/testUser 36 36 37 attributeQuery.deserialise = ndg.security.common.saml_utils.esg .xml.etree:EsgResponseElementTree.fromXML37 attributeQuery.deserialise = ndg.security.common.saml_utils.esgf.xml.etree:ESGFResponseElementTree.fromXML 38 38 attributeQuery.subjectIdFormat = urn:esg:openid 39 39 attributeQuery.clockSkewTolerance = 1. … … 54 54 subject = https://ceda.ac.uk/openid/Philip.Kershaw 55 55 56 attributeQuery.deserialise = ndg.security.common.saml_utils.esg .xml.etree:EsgResponseElementTree.fromXML56 attributeQuery.deserialise = ndg.security.common.saml_utils.esgf.xml.etree:ESGFResponseElementTree.fromXML 57 57 attributeQuery.subjectIdFormat = urn:esg:openid 58 58 attributeQuery.clockSkewTolerance = 1. -
TI12-security/trunk/NDGSecurity/python/Tests/esg_integration/test_attributeserviceclient.py
r7681 r7698 22 22 AttributeQuerySslSOAPBinding) 23 23 24 from ndg.security.common.saml_utils.esg .xml.etree import EsgResponseElementTree24 from ndg.security.common.saml_utils.esgf.xml.etree import ESGFResponseElementTree 25 25 from ndg.security.common.utils.etree import prettyPrint 26 26 from ndg.security.common.utils.configfileparsers import ( … … 54 54 response = binding.send(uri=uri) 55 55 56 # E sgResponseElementTree has an extension to support ESG Group/Role56 # ESGFResponseElementTree has an extension to support ESG Group/Role 57 57 # Attribute Value 58 samlResponseElem = E sgResponseElementTree.toXML(response)58 samlResponseElem = ESGFResponseElementTree.toXML(response) 59 59 60 60 print("SAML Response ...") -
TI12-security/trunk/NDGSecurity/python/ndg_security_common/ndg/security/common/saml_utils/esgf/__init__.py
r7076 r7698 9 9 __contact__ = "Philip.Kershaw@stfc.ac.uk" 10 10 __revision__ = '$Id$' 11 from ndg.saml.saml2.core import XSStringAttributeValue, AttributeValue, Attribute 11 from ndg.saml.saml2.core import (XSStringAttributeValue, AttributeValue, 12 Attribute) 12 13 from ndg.saml.common.xml import QName, SAMLConstants 13 14 … … 15 16 16 17 17 class _MetaE sgSamlNamespaces(type):18 class _MetaESGFSamlNamespaces(type): 18 19 """Meta class enables read-only constants""" 19 20 @property … … 46 47 47 48 48 class E sgSamlNamespaces(object):49 class ESGFSamlNamespaces(object): 49 50 """Earth System Grid specific constants for use with SAML assertions""" 50 __metaclass__ = _MetaE sgSamlNamespaces51 __metaclass__ = _MetaESGFSamlNamespaces 51 52 52 53 53 class XSGroupRoleAttributeValue(AttributeValue):54 class ESGFGroupRoleAttributeValue(AttributeValue): 54 55 '''ESG Specific Group/Role attribute value. ESG attribute permissions are 55 56 organised into group/role pairs … … 61 62 GROUP_ATTRIB_NAME = "group" 62 63 ROLE_ATTRIB_NAME = "role" 64 DEFAULT_ROLE_NAME = "default" 63 65 64 66 # QName of the XSI type … … 125 127 126 128 def _setGroup(self, group): 129 if not isinstance(group, basestring): 130 raise TypeError('Expecting a string type for "group" attribute; ' 131 'got %r' % type(group)) 127 132 self.__group = group 128 133 129 group = property(fget=_getGroup, fset=_setGroup )134 group = property(fget=_getGroup, fset=_setGroup, doc="Group value") 130 135 131 136 def _getRole(self): … … 133 138 134 139 def _setRole(self, role): 140 if not isinstance(role, basestring): 141 raise TypeError('Expecting a string type for "role" attribute; ' 142 'got %r' % type(role)) 135 143 self.__role = role 136 144 137 role = property(fget=_getRole, fset=_setRole )145 role = property(fget=_getRole, fset=_setRole, doc="Role value") 138 146 147 def _setValue(self, value): 148 if not isinstance(value, (tuple, list)) and len(value) != 2: 149 raise TypeError('Expecting a two element tuple or list for group/' 150 'role value; got %r' % type(value)) 151 152 self.group, self.role = value 153 154 def _getValue(self): 155 return self.group, self.role 156 157 value = property(_getValue, _setValue, 158 doc="group/role attribute value tuple") 159 139 160 def getOrderedChildren(self): 140 161 # no children … … 142 163 143 164 144 class E sgDefaultQueryAttributes(object):165 class ESGFDefaultQueryAttributes(object): 145 166 XSSTRING_NS = "%s#%s" % ( 146 167 SAMLConstants.XSD_NS, … … 150 171 ATTRIBUTES = TypedList(Attribute) 151 172 N_ATTRIBUTES = 3 152 ATTRIBUTES += [Attribute(),]*N_ATTRIBUTES 173 i = 0 174 for i in range(N_ATTRIBUTES): 175 ATTRIBUTES.append(Attribute()) 176 del i 153 177 154 ATTRIBUTES[0].name = E sgSamlNamespaces.FIRSTNAME_ATTRNAME155 ATTRIBUTES[0].friendlyName = E sgSamlNamespaces.FIRSTNAME_FRIENDLYNAME178 ATTRIBUTES[0].name = ESGFSamlNamespaces.FIRSTNAME_ATTRNAME 179 ATTRIBUTES[0].friendlyName = ESGFSamlNamespaces.FIRSTNAME_FRIENDLYNAME 156 180 ATTRIBUTES[0].nameFormat = XSSTRING_NS 157 181 158 ATTRIBUTES[1].name = E sgSamlNamespaces.LASTNAME_ATTRNAME159 ATTRIBUTES[1].friendlyName = E sgSamlNamespaces.LASTNAME_FRIENDLYNAME182 ATTRIBUTES[1].name = ESGFSamlNamespaces.LASTNAME_ATTRNAME 183 ATTRIBUTES[1].friendlyName = ESGFSamlNamespaces.LASTNAME_FRIENDLYNAME 160 184 ATTRIBUTES[1].nameFormat = XSSTRING_NS 161 185 162 ATTRIBUTES[2].name = E sgSamlNamespaces.EMAILADDRESS_ATTRNAME163 ATTRIBUTES[2].friendlyName = E sgSamlNamespaces.EMAILADDRESS_FRIENDLYNAME186 ATTRIBUTES[2].name = ESGFSamlNamespaces.EMAILADDRESS_ATTRNAME 187 ATTRIBUTES[2].friendlyName = ESGFSamlNamespaces.EMAILADDRESS_FRIENDLYNAME 164 188 ATTRIBUTES[2].nameFormat = XSSTRING_NS -
TI12-security/trunk/NDGSecurity/python/ndg_security_common/ndg/security/common/saml_utils/esgf/xml/etree.py
r7287 r7698 19 19 QName) 20 20 21 from ndg.security.common.saml_utils.esg import XSGroupRoleAttributeValue21 from ndg.security.common.saml_utils.esgf import ESGFGroupRoleAttributeValue 22 22 23 23 24 class XSGroupRoleAttributeValueElementTree(AttributeValueElementTreeBase,25 XSGroupRoleAttributeValue):24 class ESGFGroupRoleAttributeValueElementTree(AttributeValueElementTreeBase, 25 ESGFGroupRoleAttributeValue): 26 26 """ElementTree XML representation of Earth System Grid custom Group/Role 27 27 Attribute Value""" … … 32 32 Attribute Value 33 33 34 @type a ssertion: saml.saml2.core.XSGroupRoleAttributeValue35 @param a ssertion: XSGroupRoleAttributeValue to be represented as an36 ElementTree Element34 @type attributeValue: ndg.security.common.saml_utils.esgf.ESGFGroupRoleAttributeValue 35 @param attributeValue: Group/Role Attribute Value to be represented as 36 an ElementTree Element 37 37 @rtype: ElementTree.Element 38 38 @return: ElementTree Element … … 40 40 elem = AttributeValueElementTreeBase.toXML(attributeValue) 41 41 42 if not isinstance(attributeValue, XSGroupRoleAttributeValue):42 if not isinstance(attributeValue, ESGFGroupRoleAttributeValue): 43 43 raise TypeError("Expecting %r type; got: %r" % 44 ( XSGroupRoleAttributeValue, type(attributeValue)))44 (ESGFGroupRoleAttributeValue, type(attributeValue))) 45 45 46 46 ElementTree._namespace_map[attributeValue.namespaceURI … … 62 62 def fromXML(cls, elem): 63 63 """Parse ElementTree ESG Group/Role attribute element into a SAML 64 XSGroupRoleAttributeValue object64 ESGFGroupRoleAttributeValue object 65 65 66 66 @type elem: ElementTree.Element 67 67 @param elem: Attribute value as ElementTree XML element 68 @rtype: saml.saml2.core. XSGroupRoleAttributeValue68 @rtype: saml.saml2.core.ESGFGroupRoleAttributeValue 69 69 @return: SAML ESG Group/Role Attribute value 70 70 """ … … 95 95 96 96 97 attributeValue = XSGroupRoleAttributeValue()97 attributeValue = ESGFGroupRoleAttributeValue() 98 98 groupName = childElem.attrib.get(cls.GROUP_ATTRIB_NAME) 99 99 if groupName is None: … … 105 105 roleName = childElem.attrib.get(cls.ROLE_ATTRIB_NAME) 106 106 if roleName is None: 107 raise XMLTypeParseError('No "%s" attribute found in Group/Role ' 108 'attribute element' % 109 cls.GROUP_ATTRIB_NAME) 107 roleName = cls.DEFAULT_ROLE_NAME 108 110 109 attributeValue.role = roleName 111 110 … … 115 114 def factoryMatchFunc(cls, elem): 116 115 """Match function used by AttributeValueElementTreeFactory to 117 determine whether the given attribute is XSGroupRole type 116 determine whether the given attribute is ESGFGroupRoleAttributeValue 117 type 118 118 119 119 @type elem: ElementTree.Element 120 120 @param elem: Attribute value as ElementTree XML element 121 @rtype: saml.saml2.core.XSGroupRoleAttributeValue or None 122 @return: SAML ESG Group/Role Attribute Value class if elem is an 121 @rtype: ndg.security.common.saml_utils.etree.ESGFGroupRoleAttributeValue 122 or None 123 @return: SAML ESGF Group/Role Attribute Value class if elem is an 123 124 Group/role type element or None if if doesn't match this type 124 125 """ … … 140 141 141 142 142 class E sgResponseElementTree(ResponseElementTree):143 class ESGFResponseElementTree(ResponseElementTree): 143 144 """Extend ResponseElementTree type for Attribute Query Response to include 144 145 ESG custom Group/Role Attribute support""" … … 146 147 @classmethod 147 148 def toXML(cls, response, **kw): 148 # Add mapping for ESG Group/Role Attribute Value to enable ElementTree 149 # Attribute Value factory to render the XML output 149 """Extend base method adding mapping for ESG Group/Role Attribute Value 150 to enable ElementTree Attribute Value factory to render the XML output 151 152 @type response: ndg.security.common.saml_utils.etree.ESGFGroupRoleAttributeValue 153 @param response: ESGF Group/Role attribute value 154 @rtype: ElementTree.Element 155 @return: ESGF Group/Role attribute value as ElementTree.Element 156 """ 150 157 toXMLTypeMap = kw.get('customToXMLTypeMap', {}) 151 toXMLTypeMap[ XSGroupRoleAttributeValue152 ] = XSGroupRoleAttributeValueElementTree158 toXMLTypeMap[ESGFGroupRoleAttributeValue 159 ] = ESGFGroupRoleAttributeValueElementTree 153 160 154 161 kw['customToXMLTypeMap'] = toXMLTypeMap … … 160 167 @classmethod 161 168 def fromXML(cls, elem, **kw): 169 """Extend base method adding mapping for ESG Group/Role Attribute Value 170 171 @type elem: ElementTree.Element 172 @param elem: ESGF Group/Role attribute value as ElementTree.Element 173 @rtype: ndg.security.common.saml_utils.etree.ESGFGroupRoleAttributeValue 174 @return: ESGF Group/Role attribute value 175 """ 162 176 toSAMLTypeMap = kw.get('customToSAMLTypeMap', []) 163 177 toSAMLTypeMap.append( 164 XSGroupRoleAttributeValueElementTree.factoryMatchFunc)178 ESGFGroupRoleAttributeValueElementTree.factoryMatchFunc) 165 179 kw['customToSAMLTypeMap'] = toSAMLTypeMap 166 180 -
TI12-security/trunk/NDGSecurity/python/ndg_security_common/ndg/security/common/utils/factory.py
r7076 r7698 38 38 except ValueError: 39 39 raise ValueError('Invalid module name %r set for import: %s' % 40 (moduleName, traceback.format_exc())) 41 42 objectName = [objectName] 40 (moduleName, traceback.format_exc())) 43 41 else: 44 42 _moduleName = moduleName 45 if isinstance(objectName, basestring): 46 objectName = [objectName] 43 44 if isinstance(objectName, basestring): 45 objectName = [objectName] 47 46 48 47 log.debug("Importing %r ..." % objectName) … … 53 52 for component in components[1:]: 54 53 module = getattr(module, component) 55 except AttributeError , e:54 except AttributeError: 56 55 raise AttributeError("Error importing %r: %s" % 57 56 (objectName, traceback.format_exc())) … … 71 70 72 71 def callModuleObject(moduleName, objectName=None, moduleFilePath=None, 73 objectType=None, objectArgs= (), objectProperties={}):72 objectType=None, objectArgs=None, objectProperties=None): 74 73 ''' 75 74 Create and return an instance of the specified class or invoke callable … … 90 89 @return: object - instance of the class specified 91 90 ''' 92 93 91 94 92 # ensure that properties is a dict - NB, it may be passed in as a null … … 97 95 objectProperties = {} 98 96 97 if not objectArgs: 98 objectArgs = () 99 99 100 # variable to store original state of the system path 100 101 sysPathBak = None … … 131 132 132 133 # Instantiate class 133 log.debug('Instantiating object "%s"' %importedObject.__name__)134 log.debug('Instantiating object "%s"', importedObject.__name__) 134 135 try: 135 136 if objectArgs: -
TI12-security/trunk/NDGSecurity/python/ndg_security_server/ndg/security/server/attributeauthority.py
r7507 r7698 36 36 StatusCode, StatusMessage) 37 37 38 from ndg.security.common.saml_utils.esg import EsgSamlNamespaces38 from ndg.security.common.saml_utils.esgf import ESGFSamlNamespaces 39 39 from ndg.security.common.X509 import X500DN 40 40 from ndg.security.common.utils import TypedList … … 461 461 utcNow = datetime.utcnow() 462 462 if (attributeQuery.subject.nameID.format != 463 E sgSamlNamespaces.NAMEID_FORMAT):463 ESGFSamlNamespaces.NAMEID_FORMAT): 464 464 log.error('SAML Attribute Query subject format is %r; expecting ' 465 465 '%r' % (attributeQuery.subject.nameID.format, 466 E sgSamlNamespaces.NAMEID_FORMAT))466 ESGFSamlNamespaces.NAMEID_FORMAT)) 467 467 samlResponse.status.statusCode.value = StatusCode.REQUESTER_URI 468 468 samlResponse.status.statusMessage.value = \ -
TI12-security/trunk/NDGSecurity/python/ndg_security_server/ndg/security/server/myproxy/certificate_extapp/saml_attribute_assertion.py
r7155 r7698 41 41 from ndg.saml.saml2.binding.soap.client.attributequery import \ 42 42 AttributeQuerySslSOAPBinding 43 from ndg.security.common.saml_utils.esg import (EsgSamlNamespaces,44 E sgDefaultQueryAttributes)43 from ndg.security.common.saml_utils.esgf import (ESGFSamlNamespaces, 44 ESGFDefaultQueryAttributes) 45 45 from ndg.security.common.utils.etree import prettyPrint 46 46 from ndg.security.common.X509 import X500DN … … 104 104 assertion for inclusion by MyProxy into an issued certificate 105 105 """ 106 DEFAULT_QUERY_ATTRIBUTES = E sgDefaultQueryAttributes.ATTRIBUTES106 DEFAULT_QUERY_ATTRIBUTES = ESGFDefaultQueryAttributes.ATTRIBUTES 107 107 N_DEFAULT_QUERY_ATTRIBUTES = len(DEFAULT_QUERY_ATTRIBUTES) 108 ESG_NAME_ID_FORMAT = E sgSamlNamespaces.NAMEID_FORMAT108 ESG_NAME_ID_FORMAT = ESGFSamlNamespaces.NAMEID_FORMAT 109 109 110 110 CONNECTION_STRING_OPTNAME = 'connectionString' -
TI12-security/trunk/NDGSecurity/python/ndg_security_server/ndg/security/server/xacml/ctx_handler/saml_ctx_handler.py
r7413 r7698 32 32 33 33 from ndg.security.server.xacml.pip.saml_pip import PIP 34 from ndg.security.common.utils.factory import importModuleObject 34 35 35 36 … … 79 80 '__issuerProxy', 80 81 '__assertionLifetime', 82 '__xacmlExtFunc' 81 83 ) 82 84 … … 92 94 self.__assertionLifetime = 0. 93 95 self.__policyFilePath = None 94 96 self.__xacmlExtFunc = None 97 98 def _getXacmlExtFunc(self): 99 """Get XACML extensions function""" 100 return self.__xacmlExtFunc 101 102 def _setXacmlExtFunc(self, value): 103 """Set XACML extensions function""" 104 if isinstance(value, basestring): 105 self.__xacmlExtFunc = importModuleObject(value) 106 107 elif callable(value): 108 self.__xacmlExtFunc = value 109 110 else: 111 raise TypeError('Expecting module object import path string or ' 112 'callable; got %r' % type(value)) 113 114 xacmlExtFunc = property(_getXacmlExtFunc, _setXacmlExtFunc, 115 doc="Function or other callable which will be " 116 "called to set any XACML specific " 117 "extensions such as new custom attribute value " 118 "types. The function should accept no input " 119 "arguments and any return value is ignored") 120 121 def load(self): 122 """Load Policy file, mapping file and extensions function. In each case 123 load only if they're set 124 """ 125 if self.policyFilePath: 126 self.pdp = PDP.fromPolicySource(self.policyFilePath, 127 XacmlPolicyReaderFactory) 128 129 if self.pip.mappingFilePath: 130 self.pip.readMappingFile() 131 132 if self.xacmlExtFunc: 133 self.xacmlExtFunc() 134 95 135 @classmethod 96 136 def fromConfig(cls, cfg, **kw): … … 105 145 106 146 # Post initialisation steps - load policy and PIP mapping file 107 if obj.policyFilePath: 108 obj.pdp = PDP.fromPolicySource(obj.policyFilePath, 109 XacmlPolicyReaderFactory) 110 111 if obj.pip.mappingFilePath: 112 obj.pip.readMappingFile() 113 147 obj.load() 148 114 149 return obj 115 150 … … 159 194 160 195 def _setAttr(__optName): 161 # Check for PIP attribute related items 196 """Convenience function to check for PIP attribute related items 197 """ 162 198 if __optName.startswith(pipPrefix): 163 199 if self.pip is None: … … 211 247 212 248 # Post initialisation steps - load policy and PIP mapping file 213 if obj.policyFilePath: 214 obj.pdp = PDP.fromPolicySource(obj.policyFilePath, 215 XacmlPolicyReaderFactory) 216 217 if obj.pip.mappingFilePath: 218 obj.pip.readMappingFile() 249 obj.load() 219 250 220 251 return obj … … 492 523 493 524 return response 525 -
TI12-security/trunk/NDGSecurity/python/ndg_security_server/ndg/security/server/xacml/esgf_ext.py
r7693 r7698 13 13 log = logging.getLogger(__name__) 14 14 15 from ndg.xacml.core.functions import functionMap 15 16 from ndg.xacml.core.functions.v1.bag import BagBase 16 17 from ndg.xacml.core.functions.v1.at_least_one_member_of import \ 17 18 AtLeastOneMemberOfBase 18 from ndg.xacml.core.attributevalue import AttributeValueClassFactory 19 from ndg.xacml.core.attributevalue import (AttributeValue, 20 AttributeValueClassFactory) 19 21 from ndg.xacml.parsers import XMLParseError 20 22 from ndg.xacml.parsers.etree.attributevaluereader import ( … … 68 70 return self.__group 69 71 70 @ property.setter72 @group.setter 71 73 def group(self, value): 72 74 """@param value: new group value to set … … 86 88 return self.__role 87 89 88 @ property.setter90 @role.setter 89 91 def role(self, value): 90 92 """@param value: new role value to set … … 155 157 if localName == attributeValue.__class__.ROLE_ELEMENT_LOCAL_NAME: 156 158 attributeValue.role = subElem.text 159 157 160 elif localName == attributeValue.__class__.GROUP_ELEMENT_LOCAL_NAME: 158 161 attributeValue.group = subElem.text 162 159 163 else: 160 164 raise XMLParseError('%r ESG Group/Role sub-element not ' 161 165 'recognised' % localName) 166 167 168 def addEsgfXacmlSupport(): 169 """Add custom Earth System Grid types to XACML Classes. This includes 170 the Group/Role Attribute type, and associated ElementTree based parser, 171 and XACML bag and at least one member functions 172 """ 173 174 # Add Group/Role type 175 AttributeValueClassFactory.addClass(ESGFGroupRoleAttributeValue.IDENTIFIER, 176 ESGFGroupRoleAttributeValue) 177 178 # Add new parser for this type 179 DataTypeReaderClassFactory.addReader(ESGFGroupRoleAttributeValue.IDENTIFIER, 180 ETreeESGFGroupRoleDataTypeReader) 181 182 # Add extra matching and bag functions 183 functionMap[ESGFGroupRoleBag.FUNCTION_NS] = ESGFGroupRoleBag 184 functionMap[ESGFGroupRoleAtLeastOneMemberOf.FUNCTION_NS 185 ] = ESGFGroupRoleAtLeastOneMemberOf -
TI12-security/trunk/NDGSecurity/python/ndg_security_server/ndg/security/server/xacml/pip/saml_pip.py
r7359 r7698 45 45 __slots__ = ('__session', ) 46 46 47 def __init__(self, _id, data_dir=None ):47 def __init__(self, _id, data_dir=None, timeout=None): 48 48 """ 49 49 @param _id: unique identifier for session to be created, or one to reload … … 55 55 If set to None, sessions are cached in memory only. 56 56 @type data_dir: None type / basestring 57 @param timeout: time in seconds for individual caches' lifetimes. Set 58 to None to set no expiry. 59 @type timeout: float/int/long or None type 57 60 """ 58 61 # Expecting URIs for Ids, make them safe for storage by encoding first … … 64 67 self.__session = beaker.session.Session({}, id=encodedId, 65 68 data_dir=data_dir, 69 timeout=timeout, 66 70 use_cookies=False) 67 71 if 'wallet' not in self.__session: … … 153 157 '__cacheSessions', 154 158 '__sessionCacheDataDir', 159 '__sessionCacheTimeout', 155 160 '__sessionCache' 156 161 ) 157 162 158 def __init__(self, sessionCacheDataDir=None ):163 def __init__(self, sessionCacheDataDir=None, sessionCacheTimeout=None): 159 164 '''Initialise settings for connection to an Attribute Authority 160 165 … … 164 169 If set to None, sessions are cached in memory only. 165 170 @type sessionCacheDataDir: None type / basestring 171 @param sessionCacheTimeout: time in seconds for individual caches' 172 lifetimes. Set to None to set no expiry. 173 @type sessionCacheTimeout: float/int/long/string or None type 166 174 ''' 175 self.sessionCacheDataDir = sessionCacheDataDir 176 self.sessionCacheTimeout = sessionCacheTimeout 177 167 178 self.__subjectAttributeId = None 168 179 self.__mappingFilePath = None … … 175 186 176 187 self.__cacheSessions = True 177 self.__sessionCacheDataDir = sessionCacheDataDir178 188 self.__sessionCache = None 189 190 def _getSessionCacheTimeout(self): 191 return self.__sessionCacheTimeout 192 193 def _setSessionCacheTimeout(self, value): 194 if value is None: 195 self.__sessionCacheTimeout = value 196 197 elif isinstance(value, basestring): 198 self.__sessionCacheTimeout = float(value) 199 200 elif isinstance(value, (int, float, long)): 201 self.__sessionCacheTimeout = value 202 203 else: 204 raise TypeError('Expecting None, float, int, long or string type; ' 205 'got %r' % type(value)) 206 207 sessionCacheTimeout = property(_getSessionCacheTimeout, 208 _setSessionCacheTimeout, 209 doc='Set individual session caches to ' 210 'timeout after this period (seconds). ' 211 'Set to None to have no timeout') 179 212 180 213 def _getCacheSessions(self): … … 423 456 if self.cacheSessions: 424 457 sessionCache = SessionCache(subjectId, 425 data_dir=self.__sessionCacheDataDir) 458 data_dir=self.__sessionCacheDataDir, 459 timeout=self.__sessionCacheTimeout) 426 460 assertions = sessionCache.retrieve(attributeAuthorityURI) 427 461 else: -
TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/config/attributeauthority/sitea/site-a.ini
r7164 r7698 60 60 61 61 # Specialisation to incorporate ESG Group/Role type 62 saml.soapbinding.serialise = ndg.security.common.saml_utils.esg .xml.etree:EsgResponseElementTree.toXML62 saml.soapbinding.serialise = ndg.security.common.saml_utils.esgf.xml.etree:ESGFResponseElementTree.toXML 63 63 64 64 saml.soapbinding.mountPath = /AttributeAuthority -
TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/config/attributeauthority/sitea/sitea_attributeinterface.py
r7077 r7698 15 15 16 16 from ndg.saml.common.xml import SAMLConstants 17 from ndg.saml.saml2.core import (Assertion, Attribute, AttributeStatement, Issuer,18 SAMLVersion, Subject, NameID, Conditions,19 XSStringAttributeValue)17 from ndg.saml.saml2.core import (Assertion, Attribute, AttributeStatement, 18 Issuer, SAMLVersion, Subject, NameID, 19 Conditions, XSStringAttributeValue) 20 20 21 from ndg.security.common.saml_utils.esgf import (ESGFSamlNamespaces, 22 ESGFGroupRoleAttributeValue) 21 23 from ndg.security.common.X509 import X500DN 22 24 from ndg.security.server.attributeauthority import (AttributeInterface, … … 34 36 35 37 SAML_ATTRIBUTE_NAMES = ATTRIBUTE_NAMES + ( 36 'urn:esg:email:address', 37 'urn:esg:first:name', 38 'urn:esg:last:name' 38 ESGFSamlNamespaces.EMAILADDRESS_ATTRNAME, 39 ESGFSamlNamespaces.FIRSTNAME_ATTRNAME, 40 ESGFSamlNamespaces.LASTNAME_ATTRNAME, 41 'urn:esg:sitea:grouprole' 39 42 ) 40 43 … … 43 46 ('p.kershaw@somewhere.ac.uk',), 44 47 ('Philip',), 45 ('Kershaw',) 48 ('Kershaw',), 49 (('siteagroup', 'default'),) 46 50 ) 47 51 … … 49 53 "EmailAddress", 50 54 "FirstName", 51 "LastName" 55 "LastName", 56 "groupRole" 52 57 ) 53 SAML_ATTRIBUTE_FORMATS = (SAMLConstants.XSD_NS+"#"+\ 54 XSStringAttributeValue.TYPE_LOCAL_NAME,) * \ 55 len(SAML_ATTRIBUTE_NAMES) 58 SAML_ATTRIBUTE_FORMATS = ( 59 SAMLConstants.XSD_NS+"#"+XSStringAttributeValue.TYPE_LOCAL_NAME,) * ( 60 len(SAML_ATTRIBUTE_NAMES)-1) + \ 61 (ESGFGroupRoleAttributeValue.TYPE_LOCAL_NAME, ) 62 56 63 SAML_ATTRIBUTES = [] 57 64 65 name, val, vals, format, friendlyName = (None, None, None, None, None) 58 66 for name, vals, format, friendlyName in zip(SAML_ATTRIBUTE_NAMES, 59 SAML_ATTRIBUTE_VALUES,60 SAML_ATTRIBUTE_FORMATS,61 SAML_ATTRIBUTE_FRIENDLY_NAMES):67 SAML_ATTRIBUTE_VALUES, 68 SAML_ATTRIBUTE_FORMATS, 69 SAML_ATTRIBUTE_FRIENDLY_NAMES): 62 70 SAML_ATTRIBUTES.append(Attribute()) 63 71 SAML_ATTRIBUTES[-1].name = name … … 65 73 SAML_ATTRIBUTES[-1].friendlyName = friendlyName 66 74 for val in vals: 67 SAML_ATTRIBUTES[-1].attributeValues.append(XSStringAttributeValue()) 68 SAML_ATTRIBUTES[-1].attributeValues[-1].value = val 75 if isinstance(val, tuple): 76 SAML_ATTRIBUTES[-1].attributeValues.append( 77 ESGFGroupRoleAttributeValue()) 78 SAML_ATTRIBUTES[-1].attributeValues[-1].value = val 79 else: 80 SAML_ATTRIBUTES[-1].attributeValues.append( 81 XSStringAttributeValue()) 82 SAML_ATTRIBUTES[-1].attributeValues[-1].value = val 69 83 70 84 del name, val, vals, format, friendlyName -
TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/integration/full_system/securityservices.ini
r7517 r7698 377 377 378 378 # Specialisation to incorporate ESG Group/Role type 379 saml.soapbinding.serialise = ndg.security.common.saml_utils.esg .xml.etree:EsgResponseElementTree.toXML379 saml.soapbinding.serialise = ndg.security.common.saml_utils.esgf.xml.etree:ESGFResponseElementTree.toXML 380 380 381 381 saml.soapbinding.mountPath = /AttributeAuthority -
TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/unit/attributeauthority/test_attributeauthority.py
r7077 r7698 37 37 StatusCode) 38 38 from ndg.saml.xml import XMLConstants 39 from ndg.security.common.saml_utils.esg import EsgSamlNamespaces39 from ndg.security.common.saml_utils.esgf import ESGFSamlNamespaces 40 40 41 41 THIS_DIR = path.dirname(__file__) … … 139 139 # Define queries for SAML attribute names 140 140 attributeInterface.samlAttribute2SqlQuery_firstName = '"%s" "%s"' % ( 141 E sgSamlNamespaces.FIRSTNAME_ATTRNAME,141 ESGFSamlNamespaces.FIRSTNAME_ATTRNAME, 142 142 SQLAlchemyAttributeInterfaceTestCase.SAML_FIRSTNAME_SQLQUERY) 143 143 144 144 setattr(attributeInterface, 145 145 'samlAttribute2SqlQuery.lastName', 146 "%s %s" % (E sgSamlNamespaces.LASTNAME_ATTRNAME,146 "%s %s" % (ESGFSamlNamespaces.LASTNAME_ATTRNAME, 147 147 SQLAlchemyAttributeInterfaceTestCase.SAML_LASTNAME_SQLQUERY)) 148 148 149 149 attributeInterface.samlAttribute2SqlQuery[ 150 E sgSamlNamespaces.EMAILADDRESS_ATTRNAME] = (150 ESGFSamlNamespaces.EMAILADDRESS_ATTRNAME] = ( 151 151 SQLAlchemyAttributeInterfaceTestCase.SAML_EMAILADDRESS_SQLQUERY) 152 152 … … 170 170 171 171 'samlAttribute2SqlQuery.firstname': '"%s" "%s"' % ( 172 E sgSamlNamespaces.FIRSTNAME_ATTRNAME,172 ESGFSamlNamespaces.FIRSTNAME_ATTRNAME, 173 173 SQLAlchemyAttributeInterfaceTestCase.SAML_FIRSTNAME_SQLQUERY), 174 174 175 175 'samlAttribute2SqlQuery.blah': '"%s" "%s"' % ( 176 E sgSamlNamespaces.LASTNAME_ATTRNAME,176 ESGFSamlNamespaces.LASTNAME_ATTRNAME, 177 177 SQLAlchemyAttributeInterfaceTestCase.SAML_LASTNAME_SQLQUERY), 178 178 179 179 'samlAttribute2SqlQuery.3': '%s "%s"' % ( 180 E sgSamlNamespaces.EMAILADDRESS_ATTRNAME,180 ESGFSamlNamespaces.EMAILADDRESS_ATTRNAME, 181 181 SQLAlchemyAttributeInterfaceTestCase.SAML_EMAILADDRESS_SQLQUERY), 182 182 … … 195 195 self.assert_( 196 196 attributeInterface.samlAttribute2SqlQuery[ 197 E sgSamlNamespaces.FIRSTNAME_ATTRNAME] == \197 ESGFSamlNamespaces.FIRSTNAME_ATTRNAME] == \ 198 198 SQLAlchemyAttributeInterfaceTestCase.SAML_FIRSTNAME_SQLQUERY) 199 199 … … 219 219 self.assert_( 220 220 attributeInterface.samlAttribute2SqlQuery[ 221 E sgSamlNamespaces.EMAILADDRESS_ATTRNAME] == \221 ESGFSamlNamespaces.EMAILADDRESS_ATTRNAME] == \ 222 222 SQLAlchemyAttributeInterfaceTestCase.SAML_EMAILADDRESS_SQLQUERY) 223 223 … … 239 239 attributeQuery.subject = Subject() 240 240 attributeQuery.subject.nameID = NameID() 241 attributeQuery.subject.nameID.format = E sgSamlNamespaces.NAMEID_FORMAT241 attributeQuery.subject.nameID.format = ESGFSamlNamespaces.NAMEID_FORMAT 242 242 attributeQuery.subject.nameID.value = \ 243 243 SQLAlchemyAttributeInterfaceTestCase.OPENID_URI 244 244 245 245 fnAttribute = Attribute() 246 fnAttribute.name = E sgSamlNamespaces.FIRSTNAME_ATTRNAME246 fnAttribute.name = ESGFSamlNamespaces.FIRSTNAME_ATTRNAME 247 247 fnAttribute.nameFormat = XSStringAttributeValue.DEFAULT_FORMAT 248 248 fnAttribute.friendlyName = "FirstName" … … 251 251 252 252 lnAttribute = Attribute() 253 lnAttribute.name = E sgSamlNamespaces.LASTNAME_ATTRNAME253 lnAttribute.name = ESGFSamlNamespaces.LASTNAME_ATTRNAME 254 254 lnAttribute.nameFormat = XSStringAttributeValue.DEFAULT_FORMAT 255 255 lnAttribute.friendlyName = "LastName" … … 258 258 259 259 emailAddressAttribute = Attribute() 260 emailAddressAttribute.name = E sgSamlNamespaces.EMAILADDRESS_ATTRNAME260 emailAddressAttribute.name = ESGFSamlNamespaces.EMAILADDRESS_ATTRNAME 261 261 emailAddressAttribute.nameFormat = XSStringAttributeValue.DEFAULT_FORMAT 262 262 emailAddressAttribute.friendlyName = "EmailAddress" … … 295 295 # Define queries for SAML attribute names 296 296 samlAttribute2SqlQuery = { 297 E sgSamlNamespaces.FIRSTNAME_ATTRNAME:297 ESGFSamlNamespaces.FIRSTNAME_ATTRNAME: 298 298 SQLAlchemyAttributeInterfaceTestCase.SAML_FIRSTNAME_SQLQUERY, 299 299 300 E sgSamlNamespaces.LASTNAME_ATTRNAME:300 ESGFSamlNamespaces.LASTNAME_ATTRNAME: 301 301 SQLAlchemyAttributeInterfaceTestCase.SAML_LASTNAME_SQLQUERY, 302 302 303 E sgSamlNamespaces.EMAILADDRESS_ATTRNAME:303 ESGFSamlNamespaces.EMAILADDRESS_ATTRNAME: 304 304 SQLAlchemyAttributeInterfaceTestCase.SAML_EMAILADDRESS_SQLQUERY, 305 305 … … 357 357 attributeQuery.subject = Subject() 358 358 attributeQuery.subject.nameID = NameID() 359 attributeQuery.subject.nameID.format = E sgSamlNamespaces.NAMEID_FORMAT359 attributeQuery.subject.nameID.format = ESGFSamlNamespaces.NAMEID_FORMAT 360 360 attributeQuery.subject.nameID.value = \ 361 361 SQLAlchemyAttributeInterfaceTestCase.OPENID_URI 362 362 363 363 emailAddressAttribute = Attribute() 364 emailAddressAttribute.name = E sgSamlNamespaces.EMAILADDRESS_ATTRNAME364 emailAddressAttribute.name = ESGFSamlNamespaces.EMAILADDRESS_ATTRNAME 365 365 emailAddressAttribute.nameFormat = "InvalidFormat" 366 366 emailAddressAttribute.friendlyName = "EmailAddress" … … 399 399 # Define queries for SAML attribute names 400 400 samlAttribute2SqlQuery = { 401 E sgSamlNamespaces.FIRSTNAME_ATTRNAME:401 ESGFSamlNamespaces.FIRSTNAME_ATTRNAME: 402 402 SQLAlchemyAttributeInterfaceTestCase.SAML_FIRSTNAME_SQLQUERY, 403 403 404 E sgSamlNamespaces.LASTNAME_ATTRNAME:404 ESGFSamlNamespaces.LASTNAME_ATTRNAME: 405 405 SQLAlchemyAttributeInterfaceTestCase.SAML_LASTNAME_SQLQUERY, 406 406 407 E sgSamlNamespaces.EMAILADDRESS_ATTRNAME:407 ESGFSamlNamespaces.EMAILADDRESS_ATTRNAME: 408 408 SQLAlchemyAttributeInterfaceTestCase.SAML_EMAILADDRESS_SQLQUERY, 409 409 -
TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/unit/attributeauthorityclient/test_samlattributeauthorityclient.cfg
r7164 r7698 34 34 saml.deserialise = ndg.saml.xml.etree:ResponseElementTree.fromXML 35 35 36 [test05AttributeQuerySOAPBindingInterface] 36 [test05AttributeQueryWithESGFAttributeType] 37 uri = http://localhost:5000/AttributeAuthority/ 38 subject = https://openid.localhost/philip.kershaw 39 prefix = saml. 40 saml.serialise = ndg.saml.xml.etree:AttributeQueryElementTree.toXML 41 saml.deserialise = ndg.security.common.saml_utils.esgf.xml.etree:ESGFResponseElementTree.fromXML 42 43 [test06AttributeQuerySOAPBindingInterface] 37 44 uri = http://localhost:5000/AttributeAuthority/ 38 45 subject = https://openid.localhost/philip.kershaw 39 46 40 [test0 6AttributeQueryFromConfig]47 [test07AttributeQueryFromConfig] 41 48 uri = http://localhost:5000/AttributeAuthority/ 42 49 subject = https://openid.localhost/philip.kershaw … … 48 55 attributeQuery.queryAttributes.roles = urn:siteA:security:authz:1.0:attr, , http://www.w3.org/2001/XMLSchema#string 49 56 50 [test0 7AttributeQuerySslSOAPBindingInterface]57 [test08AttributeQuerySslSOAPBindingInterface] 51 58 uri = https://localhost:5443/AttributeAuthority/ 52 59 subject = https://openid.localhost/philip.kershaw -
TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/unit/attributeauthorityclient/test_samlattributeauthorityclient.py
r7155 r7698 28 28 AttributeQuerySOAPBinding, 29 29 AttributeQuerySslSOAPBinding) 30 from ndg.security.common.saml_utils.esg import (EsgSamlNamespaces, 31 EsgDefaultQueryAttributes) 30 from ndg.security.common.saml_utils.esgf import (ESGFSamlNamespaces, 31 ESGFDefaultQueryAttributes, 32 ESGFGroupRoleAttributeValue) 33 from ndg.security.common.saml_utils.esgf.xml.etree import ( 34 ESGFGroupRoleAttributeValueElementTree, 35 ESGFResponseElementTree) 36 from ndg.security.common.utils.etree import prettyPrint 32 37 from ndg.security.test.unit.attributeauthorityclient import \ 33 38 AttributeAuthorityClientBaseTestCase 34 from ndg.security.common.utils.etree import prettyPrint 35 39 36 40 37 41 class AttributeAuthoritySAMLInterfaceTestCase( … … 64 68 attributeQuery.subject = Subject() 65 69 attributeQuery.subject.nameID = NameID() 66 attributeQuery.subject.nameID.format = E sgSamlNamespaces.NAMEID_FORMAT70 attributeQuery.subject.nameID.format = ESGFSamlNamespaces.NAMEID_FORMAT 67 71 attributeQuery.subject.nameID.value = _cfg['subject'] 68 72 xsStringNs = SAMLConstants.XSD_NS+"#"+\ 69 73 XSStringAttributeValue.TYPE_LOCAL_NAME 70 74 fnAttribute = Attribute() 71 fnAttribute.name = E sgSamlNamespaces.FIRSTNAME_ATTRNAME75 fnAttribute.name = ESGFSamlNamespaces.FIRSTNAME_ATTRNAME 72 76 fnAttribute.nameFormat = xsStringNs 73 77 fnAttribute.friendlyName = "FirstName" … … 76 80 77 81 lnAttribute = Attribute() 78 lnAttribute.name = E sgSamlNamespaces.LASTNAME_ATTRNAME82 lnAttribute.name = ESGFSamlNamespaces.LASTNAME_ATTRNAME 79 83 lnAttribute.nameFormat = xsStringNs 80 84 lnAttribute.friendlyName = "LastName" … … 83 87 84 88 emailAddressAttribute = Attribute() 85 emailAddressAttribute.name = E sgSamlNamespaces.EMAILADDRESS_ATTRNAME89 emailAddressAttribute.name = ESGFSamlNamespaces.EMAILADDRESS_ATTRNAME 86 90 emailAddressAttribute.nameFormat = xsStringNs 87 91 emailAddressAttribute.friendlyName = "emailAddress" … … 132 136 attributeQuery.subject = Subject() 133 137 attributeQuery.subject.nameID = NameID() 134 attributeQuery.subject.nameID.format = E sgSamlNamespaces.NAMEID_FORMAT138 attributeQuery.subject.nameID.format = ESGFSamlNamespaces.NAMEID_FORMAT 135 139 attributeQuery.subject.nameID.value = _cfg['subject'] 136 140 xsStringNs = SAMLConstants.XSD_NS+"#"+\ … … 172 176 attributeQuery.subject = Subject() 173 177 attributeQuery.subject.nameID = NameID() 174 attributeQuery.subject.nameID.format = E sgSamlNamespaces.NAMEID_FORMAT178 attributeQuery.subject.nameID.format = ESGFSamlNamespaces.NAMEID_FORMAT 175 179 attributeQuery.subject.nameID.value = _cfg['subject'] 176 180 xsStringNs = SAMLConstants.XSD_NS+"#"+\ … … 212 216 attributeQuery.subject = Subject() 213 217 attributeQuery.subject.nameID = NameID() 214 attributeQuery.subject.nameID.format = E sgSamlNamespaces.NAMEID_FORMAT218 attributeQuery.subject.nameID.format = ESGFSamlNamespaces.NAMEID_FORMAT 215 219 attributeQuery.subject.nameID.value = _cfg['subject'] 216 220 xsStringNs = SAMLConstants.XSD_NS+"#"+\ … … 238 242 self.assert_(response.status.statusCode.value==\ 239 243 StatusCode.INVALID_ATTR_NAME_VALUE_URI) 240 241 def test05AttributeQuerySOAPBindingInterface(self): 242 _cfg = self.cfg['test05AttributeQuerySOAPBindingInterface'] 244 245 def test05AttributeQueryWithESGFAttributeType(self): 246 # Test interface with custom ESGF Group/Role attribute type 247 thisSection = 'test05AttributeQueryWithESGFAttributeType' 248 _cfg = self.cfg[thisSection] 249 250 attributeQuery = AttributeQuery() 251 attributeQuery.version = SAMLVersion(SAMLVersion.VERSION_20) 252 attributeQuery.id = str(uuid4()) 253 attributeQuery.issueInstant = datetime.utcnow() 254 255 attributeQuery.issuer = Issuer() 256 attributeQuery.issuer.format = Issuer.X509_SUBJECT 257 attributeQuery.issuer.value = "/CN=Authorisation Service/O=Site A" 258 259 attributeQuery.subject = Subject() 260 attributeQuery.subject.nameID = NameID() 261 attributeQuery.subject.nameID.format = ESGFSamlNamespaces.NAMEID_FORMAT 262 attributeQuery.subject.nameID.value = _cfg['subject'] 263 264 groupRoleAttribute = Attribute() 265 groupRoleAttribute.name = 'urn:esg:sitea:grouprole' 266 groupRoleAttribute.nameFormat = \ 267 ESGFGroupRoleAttributeValue.TYPE_LOCAL_NAME 268 269 attributeQuery.attributes.append(groupRoleAttribute) 270 271 binding = SOAPBinding.fromConfig( 272 AttributeAuthoritySAMLInterfaceTestCase.CONFIG_FILEPATH, 273 prefix='saml.', 274 section=thisSection) 275 276 response = binding.send(attributeQuery, _cfg['uri']) 277 278 samlResponseElem = ResponseElementTree.toXML(response) 279 280 print("SAML Response ...") 281 print(ElementTree.tostring(samlResponseElem)) 282 print("Pretty print SAML Response ...") 283 print(prettyPrint(samlResponseElem)) 284 285 self.assert_(response.assertions[0].attributeStatements[0].attributes[0 286 ].attributeValues[0].value == ('siteagroup', 'default')) 287 288 self.assert_(response.status.statusCode.value == StatusCode.SUCCESS_URI) 289 290 def test06AttributeQuerySOAPBindingInterface(self): 291 _cfg = self.cfg['test06AttributeQuerySOAPBindingInterface'] 243 292 244 293 binding = AttributeQuerySOAPBinding() 245 294 246 295 binding.subjectID = AttributeAuthoritySAMLInterfaceTestCase.OPENID_URI 247 binding.subjectIdFormat = E sgSamlNamespaces.NAMEID_FORMAT296 binding.subjectIdFormat = ESGFSamlNamespaces.NAMEID_FORMAT 248 297 binding.issuerName = \ 249 298 str(AttributeAuthoritySAMLInterfaceTestCase.VALID_REQUESTOR_IDS[0]) 250 299 binding.issuerFormat = Issuer.X509_SUBJECT 251 300 252 binding.queryAttributes = E sgDefaultQueryAttributes.ATTRIBUTES301 binding.queryAttributes = ESGFDefaultQueryAttributes.ATTRIBUTES 253 302 254 303 response = binding.send(uri=_cfg['uri']) … … 262 311 self.assert_(response.status.statusCode.value==StatusCode.SUCCESS_URI) 263 312 264 def test0 6AttributeQueryFromConfig(self):265 thisSection = 'test0 6AttributeQueryFromConfig'313 def test07AttributeQueryFromConfig(self): 314 thisSection = 'test07AttributeQueryFromConfig' 266 315 _cfg = self.cfg[thisSection] 267 316 … … 280 329 self.assert_(response.status.statusCode.value==StatusCode.SUCCESS_URI) 281 330 282 def test0 7AttributeQuerySslSOAPBindingInterface(self):283 thisSection = 'test0 7AttributeQuerySslSOAPBindingInterface'331 def test08AttributeQuerySslSOAPBindingInterface(self): 332 thisSection = 'test08AttributeQuerySslSOAPBindingInterface' 284 333 _cfg = self.cfg[thisSection] 285 334 -
TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/unit/authz/xacml/saml_ctx_handler.cfg
r7339 r7698 21 21 saml_ctx_handler.issuerFormat = urn:oasis:names:tc:SAML:1.1:nameid-format:x509SubjectName 22 22 saml_ctx_handler.assertionLifetime = 86400 23 24 # Add Earth System Grid custom types and functions to XACML 25 saml_ctx_handler.xacmlExtFunc = ndg.security.server.xacml.esgf_ext:addEsgfXacmlSupport 23 26 24 27 # -
TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/unit/authz/xacml/saml_pip.cfg
r7358 r7698 23 23 saml_pip.sessionCacheDataDir = %(here)s/query-results-cache 24 24 25 # Timeout cache in 30mins 26 saml_pip.sessionCacheTimeout = 1800 27 25 28 # The attribute ID of the subject value to extract from the XACML request 26 29 # context and pass in the SAML attribute query -
TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/unit/authz/xacml/test_saml_ctx_handler.py
r7339 r7698 56 56 self.assert_(handler.issuerFormat) 57 57 self.assert_(handler.assertionLifetime) 58 self.assert_(handler.xacmlExtFunc) 59 58 60 59 61 if __name__ == "__main__": -
TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/unit/authz/xacml/test_saml_pip.py
r7517 r7698 59 59 60 60 setattr(pip, 'sessionCacheDataDir', 'My data dir') 61 self.assert_(pip.sessionCacheDataDir == 'My data dir') 62 self.assert_(pip.sessionCacheTimeout is None) 63 64 try: 65 pip.sessionCacheTimeout = {} 66 self.fail("pip.sessionCacheTimeout accepts only float/int/long/" 67 "string or None type value") 68 except TypeError: 69 pass 70 71 pip.sessionCacheTimeout = 86400L 72 self.assert_(pip.sessionCacheTimeout == 86400L) 61 73 62 74 def test02ReadMappingFile(self): … … 69 81 print(pip.attribute2AttributeAuthorityMap) 70 82 71 def _createXacmlRequestCtx(self): 83 @classmethod 84 def _createXacmlRequestCtx(cls): 85 """Helper to create a XACML request context""" 72 86 ctx = Request() 73 87 … … 75 89 openidAttr = Attribute() 76 90 ctx.subjects[-1].attributes.append(openidAttr) 77 openidAttr.attributeId = self.__class__.OPENID_ATTR_ID91 openidAttr.attributeId = cls.OPENID_ATTR_ID 78 92 openidAttr.dataType = 'http://www.w3.org/2001/XMLSchema#anyURI' 79 93 80 anyUriAttrValue = self.__class__.attributeValueClassFactory( 81 openidAttr.dataType) 94 anyUriAttrValue = cls.attributeValueClassFactory(openidAttr.dataType) 82 95 83 openidAttrVal = anyUriAttrValue( self.__class__.OPENID_URI)96 openidAttrVal = anyUriAttrValue(cls.OPENID_URI) 84 97 openidAttr.attributeValues.append(openidAttrVal) 85 98 86 99 return ctx 87 100 88 def _createPIP(self): 101 @classmethod 102 def _createPIP(cls): 89 103 """Create PIP from test attribute settings""" 90 104 pip = PIP() 91 pip.mappingFilePath = self.__class__.MAPPING_FILEPATH105 pip.mappingFilePath = cls.MAPPING_FILEPATH 92 106 pip.readMappingFile() 93 pip.subjectAttributeId = self.__class__.OPENID_ATTR_ID107 pip.subjectAttributeId = cls.OPENID_ATTR_ID 94 108 95 109 pip.attributeQueryBinding.issuerName = \ 96 'O=NDG, OU=Security, CN=localhost'110 'O=NDG, OU=Security, CN=localhost' 97 111 pip.attributeQueryBinding.issuerFormat = SamlIssuer.X509_SUBJECT 98 pip.attributeQueryBinding.sslCertFilePath = \ 99 self.__class__.CLNT_CERT_FILEPATH 100 pip.attributeQueryBinding.sslPriKeyFilePath = \ 101 self.__class__.CLNT_PRIKEY_FILEPATH 112 pip.attributeQueryBinding.sslCertFilePath = cls.CLNT_CERT_FILEPATH 113 pip.attributeQueryBinding.sslPriKeyFilePath = cls.CLNT_PRIKEY_FILEPATH 102 114 103 pip.attributeQueryBinding.sslCACertDir = self.__class__.CACERT_DIR115 pip.attributeQueryBinding.sslCACertDir = cls.CACERT_DIR 104 116 105 117 return pip 106 118 107 def _createSubjectAttributeDesignator(self): 119 @classmethod 120 def _createSubjectAttributeDesignator(cls): 108 121 '''Make attribute designator - in practice this would be passed back 109 122 from the PDP via the context handler 110 123 ''' 111 124 designator = SubjectAttributeDesignator() 112 designator.attributeId = self.__class__.NDGS_ATTR_ID125 designator.attributeId = cls.NDGS_ATTR_ID 113 126 designator.dataType = 'http://www.w3.org/2001/XMLSchema#string' 114 127 115 stringAttrValue = self.__class__.attributeValueClassFactory(128 stringAttrValue = cls.attributeValueClassFactory( 116 129 'http://www.w3.org/2001/XMLSchema#string') 117 130 118 131 return designator 119 132 120 def _initQuery(self): 133 @classmethod 134 def _initQuery(cls): 121 135 '''Convenience method to set-up the parameters needed for a query''' 122 pip = self._createPIP()123 designator = self._createSubjectAttributeDesignator()124 ctx = self._createXacmlRequestCtx()136 pip = cls._createPIP() 137 designator = cls._createSubjectAttributeDesignator() 138 ctx = cls._createXacmlRequestCtx() 125 139 return pip, designator, ctx 126 140 … … 129 143 port=self.__class__.SITEA_SSL_ATTRIBUTEAUTHORITY_PORTNUM) 130 144 131 pip, designator, ctx = self._ initQuery()145 pip, designator, ctx = self.__class__._initQuery() 132 146 133 147 # Avoid caching to avoid impacting other tests in this class … … 144 158 pip = PIP.fromConfig(self.__class__.CONFIG_FILEPATH) 145 159 self.assert_(pip.mappingFilePath) 160 self.assert_(pip.sessionCacheTimeout == 1800) 146 161 147 162 # TODO: fix test - left out for now because can't get threading to correctly -
TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/unit/myproxy/certificate_extapp/test_saml_attribute_assertion.py
r7517 r7698 19 19 import unittest 20 20 21 from ndg.security.common.saml_utils.esg import EsgSamlNamespaces21 from ndg.security.common.saml_utils.esgf import ESGFSamlNamespaces 22 22 from ndg.security.test.unit import BaseTestCase 23 23 from ndg.security.server.myproxy.certificate_extapp.saml_attribute_assertion \ … … 53 53 "/CN=Authorisation Service/O=Site A" 54 54 myProxyCertExtApp.attributeQuery.subjectIdFormat = \ 55 E sgSamlNamespaces.NAMEID_FORMAT55 ESGFSamlNamespaces.NAMEID_FORMAT 56 56 myProxyCertExtApp.attributeQuery.subjectID = \ 57 57 CertExtAppTestCase.OPENID_URI … … 86 86 87 87 myProxyCertExtApp.attributeQuery.subjectIdFormat = \ 88 E sgSamlNamespaces.NAMEID_FORMAT88 ESGFSamlNamespaces.NAMEID_FORMAT 89 89 myProxyCertExtApp.attributeQuery.sslCACertDir = \ 90 90 CertExtAppTestCase.CACERT_DIR -
TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/unit/wsgi/attributeauthority/test.ini
r7077 r7698 46 46 47 47 # Specialisation to incorporate ESG Group/Role type 48 saml.soapbinding.serialise = ndg.security.common.saml_utils.esg .xml.etree:EsgResponseElementTree.toXML48 saml.soapbinding.serialise = ndg.security.common.saml_utils.esgf.xml.etree:ESGFResponseElementTree.toXML 49 49 50 50 saml.soapbinding.pathMatchList = /AttributeAuthority -
TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/unit/wsgi/saml/attribute-interface.ini
r7153 r7698 28 28 29 29 # Specialisation to incorporate ESG Group/Role type 30 saml.serialise = ndg.security.common.saml_utils.esg .xml.etree:EsgResponseElementTree.toXML30 saml.serialise = ndg.security.common.saml_utils.esgf.xml.etree:ESGFResponseElementTree.toXML 31 31 32 32 #______________________________________________________________________________ -
TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/unit/wsgi/saml/policy.xml
r7444 r7698 96 96 </Condition> 97 97 </Rule> 98 <Rule RuleId="Rule with ESGF Custom types" Effect="Permit"> 99 <Target> 100 <Resources> 101 <Resource> 102 <ResourceMatch MatchId="urn:oasis:names:tc:xacml:2.0:function:anyURI-regexp-match"> 103 <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#anyURI">^http://localhost/test_esgf$</AttributeValue> 104 <ResourceAttributeDesignator 105 AttributeId="urn:siteA:security:authz:1.0:attr:resourceURI" 106 DataType="http://www.w3.org/2001/XMLSchema#anyURI"/> 107 </ResourceMatch> 108 </Resource> 109 </Resources> 110 </Target> 111 <Condition> 112 <Apply FunctionId="urn:esg:security:xacml:2.0:function:grouprole-at-least-one-member-of"> 113 <SubjectAttributeDesignator 114 AttributeId="urn:ndg:security:authz:1.0:attr" 115 DataType="grouprole"/> 116 <Apply FunctionId="urn:esg:security:xacml:2.0:function:grouprole-bag"> 117 <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">forbidden</AttributeValue> 118 <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">keepout</AttributeValue> 119 </Apply> 120 </Apply> 121 </Condition> 122 </Rule> 98 123 </Policy> -
TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/unit/wsgi/saml/test_soapattributeinterface.py
r7077 r7698 22 22 23 23 from ndg.security.common.soap.etree import SOAPEnvelope 24 from ndg.security.common.saml_utils.esg import EsgSamlNamespaces24 from ndg.security.common.saml_utils.esgf import ESGFSamlNamespaces 25 25 from ndg.security.test.unit.wsgi.saml import SoapSamlInterfaceMiddlewareTestCase 26 26 … … 44 44 attributeQuery.subject = Subject() 45 45 attributeQuery.subject.nameID = NameID() 46 attributeQuery.subject.nameID.format = E sgSamlNamespaces.NAMEID_FORMAT46 attributeQuery.subject.nameID.format = ESGFSamlNamespaces.NAMEID_FORMAT 47 47 attributeQuery.subject.nameID.value = subject 48 48 … … 50 50 # special case handling for 'FirstName' attribute 51 51 fnAttribute = Attribute() 52 fnAttribute.name = E sgSamlNamespaces.FIRSTNAME_ATTRNAME52 fnAttribute.name = ESGFSamlNamespaces.FIRSTNAME_ATTRNAME 53 53 fnAttribute.nameFormat = "http://www.w3.org/2001/XMLSchema#string" 54 54 fnAttribute.friendlyName = "FirstName" … … 58 58 # special case handling for 'LastName' attribute 59 59 lnAttribute = Attribute() 60 lnAttribute.name = E sgSamlNamespaces.LASTNAME_ATTRNAME60 lnAttribute.name = ESGFSamlNamespaces.LASTNAME_ATTRNAME 61 61 lnAttribute.nameFormat = "http://www.w3.org/2001/XMLSchema#string" 62 62 lnAttribute.friendlyName = "LastName" … … 66 66 # special case handling for 'LastName' attribute 67 67 emailAddressAttribute = Attribute() 68 emailAddressAttribute.name = E sgSamlNamespaces.EMAILADDRESS_ATTRNAME68 emailAddressAttribute.name = ESGFSamlNamespaces.EMAILADDRESS_ATTRNAME 69 69 emailAddressAttribute.nameFormat = XMLConstants.XSD_NS+"#"+\ 70 70 XSStringAttributeValue.TYPE_LOCAL_NAME -
TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/unit/wsgi/saml/test_soapauthzdecisioninterface.py
r7153 r7698 22 22 23 23 from ndg.security.common.soap.etree import SOAPEnvelope 24 from ndg.security.common.saml_utils.esg import EsgSamlNamespaces24 from ndg.security.common.saml_utils.esgf import ESGFSamlNamespaces 25 25 from ndg.security.test.unit.wsgi.saml import SoapSamlInterfaceMiddlewareTestCase 26 26 … … 115 115 query.subject = Subject() 116 116 query.subject.nameID = NameID() 117 query.subject.nameID.format = E sgSamlNamespaces.NAMEID_FORMAT117 query.subject.nameID.format = ESGFSamlNamespaces.NAMEID_FORMAT 118 118 query.subject.nameID.value = subject 119 119
Note: See TracChangeset
for help on using the changeset viewer.