Changeset 2178 for TI12-security
- Timestamp:
- 16/02/07 15:51:32 (13 years ago)
- Location:
- TI12-security/trunk/python
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
TI12-security/trunk/python/ndg.security.common/ndg/security/common/AttAuthority/AttAuthority_services.py
r2107 r2178 29 29 # no ws-addressing 30 30 31 # op: <ZSI.wstools.WSDLTools.Message instance at 0xb6cf4 60c>32 def getAttCert(self, user Cert,userAttCert):31 # op: <ZSI.wstools.WSDLTools.Message instance at 0xb6cf48ac> 32 def getAttCert(self, userId,userCert,userAttCert): 33 33 34 34 request = getAttCertInputMsg() 35 request._userId = userId 35 36 request._userCert = userCert 36 37 request._userAttCert = userAttCert … … 45 46 return attCert,msg 46 47 47 # op: <ZSI.wstools.WSDLTools.Message instance at 0xb6cf4 92c>48 # op: <ZSI.wstools.WSDLTools.Message instance at 0xb6cf4bcc> 48 49 def getHostInfo(self): 49 50 … … 60 61 return hostname,aaURI,loginURI 61 62 62 # op: <ZSI.wstools.WSDLTools.Message instance at 0xb6cfb 2ac>63 # op: <ZSI.wstools.WSDLTools.Message instance at 0xb6cfb56c> 63 64 def getTrustedHostInfo(self, role): 64 65 … … 74 75 return trustedHosts 75 76 76 # op: <ZSI.wstools.WSDLTools.Message instance at 0xb6cfb 42c>77 # op: <ZSI.wstools.WSDLTools.Message instance at 0xb6cfb6ec> 77 78 def getX509Cert(self): 78 79 -
TI12-security/trunk/python/ndg.security.common/ndg/security/common/AttAuthority/AttAuthority_services_types.py
r2085 r2178 46 46 def __init__(self, **kw): 47 47 ns = ns0.getAttCert_Dec.schema 48 TClist = [ZSI.TC.String(pname="user Cert", aname="_userCert", minOccurs=0, maxOccurs=1, nillable=False, typed=False, encoded=kw.get("encoded")), ZSI.TC.String(pname="userAttCert", aname="_userAttCert", minOccurs=0, maxOccurs=1, nillable=False, typed=False, encoded=kw.get("encoded"))]48 TClist = [ZSI.TC.String(pname="userId", aname="_userId", minOccurs=0, maxOccurs=1, nillable=False, typed=False, encoded=kw.get("encoded")), ZSI.TC.String(pname="userCert", aname="_userCert", minOccurs=0, maxOccurs=1, nillable=False, typed=False, encoded=kw.get("encoded")), ZSI.TC.String(pname="userAttCert", aname="_userAttCert", minOccurs=0, maxOccurs=1, nillable=False, typed=False, encoded=kw.get("encoded"))] 49 49 kw["pname"] = ("urn:ndg:security:attAuthority","getAttCert") 50 50 kw["aname"] = "_getAttCert" … … 56 56 def __init__(self): 57 57 # pyclass 58 self._userId = None 58 59 self._userCert = None 59 60 self._userAttCert = None -
TI12-security/trunk/python/ndg.security.common/ndg/security/common/AttAuthority/__init__.py
r2136 r2178 276 276 277 277 #_________________________________________________________________________ 278 def getAttCert(self, user Cert=None, userAttCert=None):278 def getAttCert(self, userId=None, userCert=None, userAttCert=None): 279 279 """Request attribute certificate from NDG Attribute Authority Web 280 280 Service. 281 282 @type userId: string 283 @keyword userId: DN of the X.509 certificate used in SOAP digital 284 signature corresponds to the *holder* of the Attribute Certificate 285 that is issued. Set this additional field to specify an alternate 286 user ID to associate with the AC. This is useful in the case where, 287 as in the DEWS project, the holder will be a server cert. rather than 288 a user proxy cert. 289 290 If this keword is omitted, userId in the AC will default to the same 291 value as the holder DN. 281 292 282 293 @type userCert: string … … 302 313 303 314 try: 304 sAttCert, msg = self.__srv.getAttCert(user Cert,userAttCert)315 sAttCert, msg = self.__srv.getAttCert(userId,userCert,userAttCert) 305 316 306 317 except Exception, e: -
TI12-security/trunk/python/ndg.security.common/ndg/security/common/AttCert.py
r2175 r2178 80 80 #_____________________________________________________________________________ 81 81 class AttCert(dict, XMLSecDoc): 82 """NDG Attribute Certificate (Authorisation or Access Token).""" 82 """NDG Attribute Certificate (Authorisation or Access Token). 83 84 @type __validProvenanceSettings: tuple 85 @cvar: string constants for allowable certificate provenance settings 86 87 @type namespace: string 88 @cvar namespace: namespace for Attribute Certificate""" 83 89 84 90 __metaclass__ = _MetaAttCert … … 87 93 # certificate 88 94 __validProvenanceSettings = ('original', 'mapped') 89 95 namespace = "urn:ndg.security" 90 96 91 97 #_________________________________________________________________________ … … 126 132 self.__holderDN = None 127 133 128 self. setProvenance(provenance)134 self.__setProvenance(provenance) 129 135 130 136 # Certificate life time interval in seconds … … 210 216 #_________________________________________________________________________ 211 217 def __setitem__(self, key, item): 212 """Set an item from the __dat, __dat['validity'] or 213 __dat['attributes'] dictionaries. This class behaves as data 218 """Set an item from the __dat dictionary. This class behaves as data 214 219 dictionary of Attribute Certificate properties 215 220 221 @type key: string 216 222 @param key: name of key - key can be specified belonging to validity 217 223 or the attributes sub dictionaries 224 225 @type item: string / int 218 226 @param item: value to set dictionary item to 219 227 """ … … 223 231 224 232 # key recognised - check if setting provenance 225 if key is"provenance":226 self. setProvenance(item)233 if key == "provenance": 234 self.__setProvenance(item) 227 235 236 elif key == "version": 237 self.__setVersion(item) 238 239 elif key == "holder": 240 self.__setHolder(item) 241 242 elif key == "issuer": 243 self.__setIssuer(item) 244 245 elif key == "issuerName": 246 self.__setIssuerName(item) 247 248 elif key == "issuerSerialNumber": 249 self.__setIssuerSerialNumber(item) 250 251 elif key == "userId": 252 self.__setUserId(item) 253 228 254 elif key == "validity": 229 255 raise KeyError, "'%s': use setValidityTime method " % \ … … 234 260 key + "set list of role attributes" 235 261 else: 236 self.__dat[key] = item 262 raise KeyError, "Key '%s' not recognised for %s'" % \ 263 (key, self.__class__.__name__) 237 264 238 265 elif key in self.__dat['attributes'] or \ … … 374 401 375 402 #_________________________________________________________________________ 403 def __setIssuerName(self, issuerName): 404 """Set the name of the issuer""" 405 if not isinstance(issuerName, basestring): 406 raise AttributeError, "issuerName must be a string" 407 408 self.__dat['issuerName'] = issuerName 409 410 #_________________________________________________________________________ 411 def __getIssuerName(self): 412 """@return the name of the issuer""" 413 return self.__dat['issuerName'] 414 415 issuerName = property(fget=__getIssuerName, 416 fset=__setIssuerName, 417 doc="Certificate Issuer name") 418 419 #_________________________________________________________________________ 420 def __setIssuerSerialNumber(self, serialNumber): 421 """@param serialNumber: the issuer serial number""" 422 if not isinstance(serialNumber, int): 423 raise AttributeError, "issuerSerialNumber must be an integer" 424 425 self.__dat['issuerSerialNumber'] = serialNumber 426 427 #_________________________________________________________________________ 428 def __getIssuerSerialNumber(self): 429 """@return the issuer serial number""" 430 return self.__dat['issuerSerialNumber'] 431 432 issuerSerialNumber = property(fget=__getIssuerSerialNumber, 433 fset=__setIssuerSerialNumber, 434 doc="Certificate Issuer Serial Number") 435 436 437 #_________________________________________________________________________ 376 438 def __setUserId(self, userId): 377 439 """Set the name of the userId … … 381 443 raise AttributeError, "userId must be a string" 382 444 383 self.__dat['userId'] = issuerName445 self.__dat['userId'] = userId 384 446 385 447 #_________________________________________________________________________ … … 391 453 userId = property(fget=__getUserId, 392 454 fset=__setUserId, 393 doc="Certificate Issuer DN") 394 395 #_________________________________________________________________________ 396 def __setIssuerName(self, issuerName): 397 """Set the name of the issuer""" 398 if not isinstance(issuerName, basestring): 399 raise AttributeError, "issuerName must be a string" 400 401 self.__dat['issuerName'] = issuerName 402 403 #_________________________________________________________________________ 404 def __getIssuerName(self): 405 """@return the name of the issuer""" 406 return self.__dat['issuerName'] 407 408 issuerName = property(fget=__getIssuerName, 409 fset=__setIssuerName, 410 doc="Certificate Issuer name") 411 412 #_________________________________________________________________________ 413 def __setIssuerSerialNumber(self, serialNumber): 414 """@param serialNumber: the issuer serial number""" 415 if not isinstance(issuerSerialNumber, int): 416 raise AttributeError, "issuerSerialNumber must be an integer" 417 418 self.__dat['issuerSerialNumber'] = serialNumber 419 420 #_________________________________________________________________________ 421 def __getIssuerSerialNumber(self): 422 """@return the issuer serial number""" 423 return self.__dat['issuerSerialNumber'] 424 425 issuerSerialNumber = property(fget=__getIssuerSerialNumber, 426 fset=__setIssuerSerialNumber, 427 doc="Certificate Issuer Serial Number") 428 455 doc="Certificate user identifier") 456 429 457 430 458 # Nb. no setValidityNotBefore/setValidityNotAfter methods - use … … 444 472 return self.__dat['validity']['notBefore'] 445 473 474 validityNotBefore = property(fget=getValidityNotBefore, 475 doc="Validity not before time as a string") 476 446 477 447 478 #_________________________________________________________________________ … … 458 489 return self.__dat['validity']['notAfter'] 459 490 460 461 #_________________________________________________________________________ 462 def getRoleSet(self): 463 """@return the roleSet as a list of role dictionaries.""" 491 validityNotAfter = property(fget=getValidityNotAfter, 492 doc="Validity not after time as a string") 493 494 495 #_________________________________________________________________________ 496 def __getRoleSet(self): 497 """@rtype: list of dict type 498 @return the roleSet as a list of role dictionaries.""" 464 499 return self.__dat['attributes']['roleSet'] 465 500 466 467 #_________________________________________________________________________ 468 def getRoles(self): 501 roleSet = property(fget=__getRoleSet, 502 doc="Role set dictionary") 503 504 #_________________________________________________________________________ 505 def __getRoles(self): 469 506 """Return roles as a list 470 507 … … 476 513 except: 477 514 return [] 478 479 480 #_________________________________________________________________________ 481 def setProvenance(self, provenance): 515 516 roles = property(fget=__getRoles, 517 doc="List of roles in Attribute Certificate") 518 519 520 #_________________________________________________________________________ 521 def __setProvenance(self, provenance): 482 522 """Set the provenance for the certificate: 'original' or 'mapped'. 483 523 … … 492 532 493 533 #_________________________________________________________________________ 494 def getProvenance(self):534 def __getProvenance(self): 495 535 """Get the provenance for the certificate. 496 536 497 537 @return provenance of certificate mapped or original""" 498 538 return self.__dat['provenance'] 499 539 540 provenance = property(fget=__getProvenance, 541 fset=__setProvenance, 542 doc="Provenance of the cert. - original or mapped") 543 500 544 501 545 #_________________________________________________________________________ … … 715 759 716 760 # Create string of all XML content 717 xmlTxt = """<attributeCertificate targetNamespace="urn:ndg:security"> 761 xmlTxt = '<attributeCertificate targetNamespace="%s">' % \ 762 self.__class__.namespace + \ 763 """ 718 764 <acInfo> 719 765 <version>""" + self.__dat['version'] + """</version> -
TI12-security/trunk/python/ndg.security.common/ndg/security/common/CredWallet.py
r2165 r2178 994 994 995 995 if hostName in trustedHostInfo and attCert.isOriginal(): 996 for role in attCert. getRoles():996 for role in attCert.roles: 997 997 if role in trustedHostInfo[hostName]['role']: 998 998 extAttCertList.append(attCert) … … 1013 1013 # Check the certificate contains at least one of 1014 1014 # the required roles 1015 roles = extAttCert.getRoles()1016 if [True for r in rolesif r in info['role']]:1015 if [True for r in extAttCert.roles \ 1016 if r in info['role']]: 1017 1017 extAttCertList.append(extAttCert) 1018 1018 -
TI12-security/trunk/python/ndg.security.common/ndg/security/common/Gatekeeper/Gatekeeper.py
r2058 r2178 177 177 try: 178 178 input.isValid(raiseExcep=True, 179 certFilePathList=self.__prop['caCertFilePath'])179 certFilePathList=self.__prop['caCertFilePath']) 180 180 except Exception, e: 181 181 raise GatekeeperError, "Access denied for input: %s" % str(e) 182 182 183 return input. getRoles()183 return input.roles 184 184 else: 185 185 raise GatekeeperError("Input must be a role, role list or " + \ -
TI12-security/trunk/python/ndg.security.common/ndg/security/common/X509.py
r2072 r2178 574 574 return sDN 575 575 576 576 serialize = serialise 577 577 578 def deserialise(self, dn, separator=None): 578 579 … … 623 624 (dn, str(excep))) 624 625 625 626 deserialize = deserialise 627 626 628 def parseSeparator(self, dn): 627 629 -
TI12-security/trunk/python/ndg.security.common/ndg/security/common/XMLSec.py
r2136 r2178 349 349 xmlTxt=None, 350 350 inclX509Cert=True, 351 refC14nKw={'unsuppressedPrefixes': ['xmlns' , 'ns1']},351 refC14nKw={'unsuppressedPrefixes': ['xmlns']}, 352 352 signedInfoC14nKw={'unsuppressedPrefixes': ['ds']}): 353 353 … … 386 386 387 387 parentNode.setAttributeNS(XMLNS.BASE, 'xmlns:%s' % 'ds', DSIG.BASE) 388 parentNode.setAttributeNS(XMLNS.BASE, 'xmlns:%s'%'ec', DSIG.C14N_EXCL) 389 390 # Serialize and re-parse prior to reference generation - calculating 391 # canonicalization based on soapWriter.dom.node seems to give an 392 # error: the order of wsu:Id attribute is not correct 393 #docNode = Reader().fromString(str(soapWriter)) 388 parentNode.setAttributeNS(XMLNS.BASE,'xmlns:%s' % 'ec',DSIG.C14N_EXCL) 394 389 395 390 # Namespaces for XPath searches -
TI12-security/trunk/python/ndg.security.server/ndg/security/server/AttAuthority/AttAuthority_services_server.py
r2107 r2178 29 29 <xsd:complexType> 30 30 <xsd:sequence> 31 <xsd:element maxOccurs=\"1\" minOccurs=\"0\" name=\"userId\" type=\"xsd:string\"/> 31 32 <xsd:element maxOccurs=\"1\" minOccurs=\"0\" name=\"userCert\" type=\"xsd:string\"/> 32 33 <xsd:element maxOccurs=\"1\" minOccurs=\"0\" name=\"userAttCert\" type=\"xsd:string\"/> … … 211 212 def soap_getAttCert(self, ps): 212 213 self.request = ps.Parse(getAttCertInputMsg.typecode) 213 parameters = (self.request._user Cert, self.request._userAttCert)214 215 # If we have an implementation object use it 216 if hasattr(self,'impl'): 217 parameters = self.impl.getAttCert(parameters[0],parameters[1] )214 parameters = (self.request._userId, self.request._userCert, self.request._userAttCert) 215 216 # If we have an implementation object use it 217 if hasattr(self,'impl'): 218 parameters = self.impl.getAttCert(parameters[0],parameters[1],parameters[2]) 218 219 219 220 result = getAttCertOutputMsg() -
TI12-security/trunk/python/ndg.security.server/ndg/security/server/AttAuthority/__init__.py
r2136 r2178 297 297 #_________________________________________________________________________ 298 298 def getAttCert(self, 299 proxyCert=None, 300 proxyCertFilePath=None, 299 userId=None, 300 holderCert=None, 301 holderCertFilePath=None, 301 302 userAttCert=None, 302 303 userAttCertFilePath=None): … … 304 305 """Request a new Attribute Certificate for use in authorisation 305 306 306 getAttCert([ proxyCert=px|proxyCertFilePath=pxFile, ]307 getAttCert([userId=uid][holderCert=px|holderCertFilePath=pxFile, ] 307 308 [userAttCert=cert|userAttCertFilePath=certFile]) 308 309 @type proxyCert: string / ndg.security.common.X509.X509Cert type 310 @keyword proxyCert: base64 encoded string containing user proxy cert./ 311 X.509 cert object 312 313 @keyword proxyCertFilePath: string 314 @param proxyCertFilePath: file path to proxy certificate. 309 310 @type userId: string 311 @keyword userId: identifier for the user who is entitled to the roles 312 in the certificate that is issued. If this keyword is omitted, then 313 the userId will be set to the DN of the holder. 314 315 holder = the holder of the certificate - an inidividual user or an 316 organisation to which the user belongs who vouches for that user's ID 317 318 userId = the identifier for the user who is entitled to the roles 319 specified in the Attribute Certificate that is issued. 320 321 @type holderCert: string / ndg.security.common.X509.X509Cert type 322 @keyword holderCert: base64 encoded string containing proxy cert./ 323 X.509 cert object corresponding to the ID who will be the HOLDER of 324 the Attribute Certificate that will be issued. - Normally, using 325 proxy certificates, the holder and user ID are the same but there 326 may be cases where the holder will be an organisation ID. This is the 327 case for NDG security with the DEWS project 328 329 @keyword holderCertFilePath: string 330 @param holderCertFilePath: file path to proxy/X.509 certificate of 331 candidate holder 315 332 316 333 @type userAttCert: string or AttCert type … … 327 344 328 345 329 # Read proxycertificate346 # Read X.509 certificate 330 347 try: 331 if proxyCertFilePath is not None:348 if holderCertFilePath is not None: 332 349 333 350 # Proxy Certificate input as a file 334 userProxyCert = X509Cert()335 userProxyCert.read(proxyCertFilePath)336 337 elif isinstance( proxyCert, basestring):351 holderCert = X509Cert() 352 holderCert.read(holderCertFilePath) 353 354 elif isinstance(holderCert, basestring): 338 355 339 356 # Proxy Certificate input as string text 340 userProxyCert = X509Cert() 341 userProxyCert.parse(proxyCert) 342 343 elif isinstance(proxyCert, X509Cert): 344 345 # Proxy is an NDG X509Cert type 346 userProxyCert = proxyCert 347 348 else: 357 holderCert = X509CertParse(holderCert) 358 359 elif not isinstance(holderCert, X509Cert): 349 360 raise AttAuthorityError, \ 350 "No input proxycertificate file path or cert text/object set"361 "No input X.509 certificate file path or cert text/object set" 351 362 352 363 except Exception, e: … … 356 367 # Check proxy certificate hasn't expired 357 368 try: 358 userProxyCert.isValidTime(raiseExcep=True)369 holderCert.isValidTime(raiseExcep=True) 359 370 360 371 except Exception, e: … … 364 375 365 376 # Get Distinguished name from certificate as an X500DN type 366 userDN = userProxyCert.dn 367 377 if userId is None: 378 try: 379 userId = holderCert.dn.serialise(\ 380 separator=self.__prop['dnSeparator']) 381 except Exception, e: 382 raise AttAuthorityError, \ 383 "Setting user Id from holder certificate DN: %s" % e 384 368 385 369 386 # Make a new Attribute Certificate instance passing in certificate … … 384 401 try: 385 402 attCert['holder'] = \ 386 userDN.serialise(separator=self.__prop['dnSeparator']) 387 388 except Exception, e: 389 raise AttAuthorityError, "User DN: %s" % e 403 holderCert.dn.serialise(separator=self.__prop['dnSeparator']) 404 except Exception, e: 405 raise AttAuthorityError, "Holder DN: %s" % e 390 406 391 407 … … 394 410 try: 395 411 attCert['issuer'] = \ 396 issuerDN.serialise(separator=self.__prop['dnSeparator']) 397 412 issuerDN.serialise(separator=self.__prop['dnSeparator']) 398 413 except Exception, e: 399 414 raise AttAuthorityError, "Issuer DN: %s" % e … … 402 417 attCert['issuerSerialNumber'] = self.__issuerSerialNumber 403 418 404 419 attCert['userId'] = userId 420 405 421 # Set validity time 406 422 try: … … 410 426 411 427 # Check against the proxy certificate's expiry 412 dt UsrProxyNotAfter = userProxyCert.notAfter428 dtHolderCertNotAfter = holderCert.notAfter 413 429 414 430 if attCert.getValidityNotAfter(asDatetime=True) > \ 415 dt UsrProxyNotAfter:431 dtHolderCertNotAfter: 416 432 417 433 # Adjust the attribute certificate's expiry date time … … 419 435 # ... but also make ensure that the not before skew is still 420 436 # applied 421 attCert.setValidityTime(dtNotAfter=dt UsrProxyNotAfter,437 attCert.setValidityTime(dtNotAfter=dtHolderCertNotAfter, 422 438 notBeforeOffset=self.__prop['attCertNotBeforeOff']) 423 439 … … 428 444 # Check name is registered with this Attribute Authority - if no 429 445 # user roles are found, the user is not registered 430 userRoles = self.getRoles( str(userDN))446 userRoles = self.getRoles(userId) 431 447 if userRoles: 432 448 # Set as an Original Certificate … … 488 504 489 505 490 # Check that's it's holder matches the user certificate DN 491 try: 492 holderDN = X500DN(dn=userAttCert['holder']) 493 494 except Exception, e: 495 raise AttAuthorityError, \ 496 "Error creating X500DN for holder: %s" + e 497 498 if holderDN != userDN: 506 # Check that's it's holder matches the candidate holder 507 # certificate DN 508 if userAttCert.holderDN != holderCert.dn: 499 509 raise AttAuthorityError, \ 500 510 "User certificate and Attribute Certificate DNs " + \ 501 "don't match: %s and %s" % (userDN, holderDN) 511 'don\'t match: "%s" and "%s"' % (holderCert.dn, 512 userAttCert.holderDN) 502 513 503 514 504 515 # Get roles from external Attribute Certificate 505 trustedHostRoles = userAttCert. getRoles()516 trustedHostRoles = userAttCert.roles 506 517 507 518 … … 519 530 520 531 # Mark new Attribute Certificate as mapped 521 attCert ['provenance']= AttCert.mappedProvenance532 attCert.provenance = AttCert.mappedProvenance 522 533 523 534 # End set mapped certificate block … … 773 784 774 785 #_________________________________________________________________________ 775 def userIsRegistered(self, user DN):786 def userIsRegistered(self, userId): 776 787 """Check a particular user is registered with the Data Centre that the 777 788 Attribute Authority represents … … 779 790 Nb. this method is not used internally by AttAuthority class 780 791 781 @type user DN: string782 @param user DN: userDistinguished Name792 @type userId: string 793 @param userId: user identity - could be a X500 Distinguished Name 783 794 @rtype: bool 784 795 @return: True if user is registered, False otherwise""" 785 return self.__userRoles.userIsRegistered(user DN)796 return self.__userRoles.userIsRegistered(userId) 786 797 787 798 788 799 #_________________________________________________________________________ 789 def getRoles(self, dn):790 """Get the roles available to the registered user identified user DN.800 def getRoles(self, userId): 801 """Get the roles available to the registered user identified userId. 791 802 792 803 @type dn: string 793 @param dn: user Distinguished Name794 @return: list of roles for the given user DN"""804 @param dn: user identifier - could be a X500 Distinguished Name 805 @return: list of roles for the given user ID""" 795 806 796 807 # Call to AAUserRoles derived class. Each Attribute Authority … … 798 809 # define how roles are accessed 799 810 try: 800 return self.__userRoles.getRoles( dn)811 return self.__userRoles.getRoles(userId) 801 812 802 813 except Exception, e: … … 972 983 973 984 974 def userIsRegistered(self, dn):985 def userIsRegistered(self, userId): 975 986 """Derived method should return True if user is known otherwise 976 987 False … … 979 990 to be implemented in a derived class. 980 991 981 @type dn: string982 @param dn: user Distinguished Name to look up.992 @type userId: string 993 @param userId: user Distinguished Name to look up. 983 994 @rtype: bool 984 995 @return: True if user is registered, False otherwise""" 985 996 raise NotImplementedError, \ 986 self. UserIsRegistered.__doc__.replace('\n ','')987 988 989 def getRoles(self, dn):997 self.userIsRegistered.__doc__.replace('\n ','') 998 999 1000 def getRoles(self, userId): 990 1001 """Derived method should return the roles for the given user's 991 DNor else raise an exception992 993 @type dn: string994 @param dn:user Distinguished Name1002 Id or else raise an exception 1003 1004 @type userId: string 1005 @param userId: user identity e.g. user Distinguished Name 995 1006 @rtype: list 996 @return: list of roles for the given user DN"""1007 @return: list of roles for the given user ID""" 997 1008 raise NotImplementedError, \ 998 1009 self.getRoles.__doc__.replace('\n ','') -
TI12-security/trunk/python/ndg.security.server/ndg/security/server/AttAuthority/server-config.tac
r2136 r2178 50 50 # Get certificate corresponding to private key that signed the 51 51 # message - i.e. the user's proxy 52 proxyCert = WSSecurityHandler.signatureHandler.verifyingCert52 holderCert = WSSecurityHandler.signatureHandler.verifyingCert 53 53 54 54 try: 55 attCert = self.aa.getAttCert(proxyCert=proxyCert, 55 attCert = self.aa.getAttCert(userId=request.UserId, 56 holderCert=holderCert, 56 57 userAttCert=request.UserAttCert) 57 58 response.AttCert = attCert.toString() -
TI12-security/trunk/python/ndg.security.server/ndg/security/server/ca/server-config.tac
r2153 r2178 1 1 #!/usr/bin/env python 2 """NDG Security Session Manager.tac file2 """NDG Security Certificate Authority .tac file 3 3 4 4 This file enables the Session Manager web service to be -
TI12-security/trunk/python/ndg.security.test/ndg/security/test/AttAuthority/AttAuthorityClientTest.py
r2085 r2178 95 95 attCert.filePath = self.cfg['test5GetAttCert']['attcertfilepath'] 96 96 attCert.write() 97 98 def test6GetAttCertWithUserIdSet(self): 99 """test6GetAttCertWithUserIdSet: Request attribute certificate from 100 NDG Attribute Authority Web Service setting a specific user Id 101 independent of the signer of the SOAP request.""" 102 103 # Read user Certificate into a string ready for passing via WS 104 try: 105 userCertFilePath = \ 106 self.cfg['test6GetAttCertWithUserIdSet'].get('issuingusercertfilepath') 107 userCertTxt = open(userCertFilePath, 'r').read() 108 109 except TypeError: 110 # No issuing cert set 111 userCertTxt = None 112 113 except IOError, ioErr: 114 raise "Error reading certificate file \"%s\": %s" % \ 115 (ioErr.filename, ioErr.strerror) 97 116 117 # Make attribute certificate request 118 userId = self.cfg['test6GetAttCertWithUserIdSet']['userid'] 119 attCert = self.clnt.getAttCert(userId=userId, 120 userCert=userCertTxt) 121 122 print "Attribute Certificate: \n\n:" + str(attCert) 123 124 attCert.filePath = self.cfg['test5GetAttCert']['attcertfilepath'] 125 attCert.write() 98 126 99 def test 6GetMappedAttCert(self):100 """test 6GetMappedAttCert: Request mapped attribute certificate from127 def test7GetMappedAttCert(self): 128 """test7GetMappedAttCert: Request mapped attribute certificate from 101 129 NDG Attribute Authority Web Service.""" 102 130 … … 104 132 try: 105 133 userCertFilePath = \ 106 self.cfg['test 6GetMappedAttCert'].get('issuingusercertfilepath')134 self.cfg['test7GetMappedAttCert'].get('issuingusercertfilepath') 107 135 userCertTxt = open(userCertFilePath, 'r').read() 108 136 … … 119 147 try: 120 148 userAttCert = AttCertRead(\ 121 self.cfg['test 6GetMappedAttCert']['userattcertfilepath'])149 self.cfg['test7GetMappedAttCert']['userattcertfilepath']) 122 150 123 151 except IOError, ioErr: … … 127 155 # Make client to site B Attribute Authority 128 156 clnt = AttAuthorityClient( 129 uri=self.cfg['test 6GetMappedAttCert']['uri'],130 signingCertFilePath=self.cfg['test 6GetMappedAttCert']['usercertfilepath'],131 signingPriKeyFilePath=self.cfg['test 6GetMappedAttCert']['userprikeyfilepath'],157 uri=self.cfg['test7GetMappedAttCert']['uri'], 158 signingCertFilePath=self.cfg['test7GetMappedAttCert']['usercertfilepath'], 159 signingPriKeyFilePath=self.cfg['test7GetMappedAttCert']['userprikeyfilepath'], 132 160 tracefile=sys.stderr) 133 161 … … 148 176 "test4GetTrustedHostInfoWithNoRole", 149 177 "test5GetAttCert", 150 "test6GetMappedAttCert", 178 "test6GetAttCertWithUserIdSet", 179 "test7GetMappedAttCert", 151 180 )) 152 181 unittest.TestSuite.__init__(self, map) -
TI12-security/trunk/python/ndg.security.test/ndg/security/test/AttAuthority/attAuthorityClientTest.cfg
r2170 r2178 35 35 attCertFilePath = ./ac.xml 36 36 37 [test6GetMappedAttCert] 37 [test6GetAttCertWithUserIdSet] 38 userId = userWhoIsEntitledToTheRolesInThisCert 39 40 [test7GetMappedAttCert] 38 41 userprikeypwd = 39 42 usercertfilepath = ./proxy-cert.pem -
TI12-security/trunk/python/ndg.security.test/ndg/security/test/AttAuthority/siteAUserRoles.py
r2051 r2178 24 24 25 25 26 def userIsRegistered(self, dn):26 def userIsRegistered(self, userId): 27 27 return True 28 28 29 29 30 def getRoles(self, dn):30 def getRoles(self, userId): 31 31 return ['staff', 'postdoc', 'undergrad'] -
TI12-security/trunk/python/ndg.security.test/ndg/security/test/AttAuthority/siteBUserRoles.py
r2051 r2178 24 24 25 25 26 def userIsRegistered(self, dn):26 def userIsRegistered(self, userId): 27 27 return False 28 28 29 29 30 def getRoles(self, dn):30 def getRoles(self, userId): 31 31 # Make so that Site B never returns any roles - the only way to 32 32 # get an Attribute Certificate is then through the role mapping -
TI12-security/trunk/python/ndg.security.test/ndg/security/test/AttCert/AttCertTest.py
r1970 r2178 76 76 self.attCert.addRoles('atsr') 77 77 78 print "test6AddRoles: " + ', '.join(self.attCert. getRoles())78 print "test6AddRoles: " + ', '.join(self.attCert.roles) 79 79 80 80 81 def test6aDictSet(self): 82 'test6aDictSet: test __setitem__' 81 def test6aSet(self): 82 'test6aSet: test __setitem__ and property methods' 83 self.attCert.version = "1.0" 83 84 self.attCert['issuer'] = '/O=NDG/OU=BADC/CN=Attribute Authority' 84 85 self.attCert['issuerName'] = 'BADC' 85 self.attCert['holder'] = '/O=NDG/OU=BADC/CN=pjkershaw' 86 self.attCert.issuerSerialNumber = 1234 87 self.attCert['holder'] = '/O=NDG/OU=BADC/CN=server.cert.ac.uk' 88 self.attCert.userId = '/O=NDG/OU=BADC/CN=pjkershaw' 86 89 87 90 try: 88 91 self.attCert['validity'] = 'invalid' 89 92 except KeyError, e: 90 print "test6a DictSet: PASSED - %s" % e93 print "test6aSet: PASSED - %s" % e 91 94 92 95 try: 93 96 self.attCert['attributes'] = 'roleSet' 94 97 except KeyError, e: 95 print "test6a DictSet: PASSED - %s" % e98 print "test6aSet: PASSED - %s" % e 96 99 97 100 try: 98 101 self.attCert['attributes']['roleSet'] = ['role1', 'role2'] 99 102 except KeyError, e: 100 print "test6aDictSet: PASSED - %s" % e 101 102 def test6bDictGet(self): 103 'test6bDictGet: test __getitem__' 104 print "test6bDictGet ..." 105 print self.test2SetProvenance() 106 print self.test4SetValidityTime() 107 print self.test6AddRoles() 108 print self.test6aDictSet() 109 print self.attCert['issuer'] 110 print self.attCert['holder'] 111 print self.attCert['validity'] 112 print self.attCert['attributes'] 113 print self.attCert['attributes']['roleSet'] 103 print "test6aSet: PASSED - %s" % e 104 105 def test6bGet(self): 106 'test6bGet: test __getitem__ and property methods' 107 print "test6bGet ..." 108 self.test2SetProvenance() 109 self.test4SetValidityTime() 110 self.test6AddRoles() 111 self.test6aSet() 112 113 print "self.attCert['version'] = %s" % self.attCert['version'] 114 print "self.attCert.version = %s" % self.attCert.version 115 116 print "self.attCert['issuer'] = %s" % self.attCert['issuer'] 117 print "self.attCert.issuer = %s" % self.attCert.issuer 118 print "self.attCert.issuerDN = %s" % self.attCert.issuerDN 119 120 print "self.attCert['issuerName'] = %s" % self.attCert['issuerName'] 121 print "self.attCert.issuerName = %s" % self.attCert.issuerName 122 123 print "self.attCert['issuerSerialNumber'] = %s" % \ 124 self.attCert['issuerSerialNumber'] 125 print "self.attCert.issuerSerialNumber = %s" % \ 126 self.attCert.issuerSerialNumber 127 128 print "self.attCert['holder'] = %s" % self.attCert['holder'] 129 print "self.attCert.holder = %s" % self.attCert.holder 130 print "self.attCert.holderDN = %s" % self.attCert.holderDN 131 132 print "self.attCert['userId'] = %s" % self.attCert['userId'] 133 print "self.attCert.userId = %s" % self.attCert.userId 134 135 print "self.attCert['validity'] = %s" % self.attCert['validity'] 136 print "self.attCert.validityNotBefore = %s" % \ 137 self.attCert.validityNotBefore 138 print "self.attCert.validityNotAfter = %s" % \ 139 self.attCert.validityNotAfter 140 141 print "self.attCert.getValidityNotBefore(asDatetime=True) = %s" % \ 142 self.attCert.getValidityNotBefore(asDatetime=True) 143 print "self.attCert.getValidityNotAfter(asDatetime=True) = %s" % \ 144 self.attCert.getValidityNotAfter(asDatetime=True) 145 146 print "self.attCert['attributes'] = %s" % self.attCert['attributes'] 147 print "self.attCert['attributes']['roleSet'] %s: " % \ 148 self.attCert['attributes']['roleSet'] 149 print "self.attCert.roleSet = %s" % self.attCert.roleSet 150 print "self.attCert.roles = %s" % self.attCert.roles 114 151 115 152 def test7CreateXML(self): … … 131 168 self.test5SetDefaultValidityTime() 132 169 self.test6AddRoles() 133 self.test6a DictSet()170 self.test6aSet() 134 171 135 172 self.attCert.filePath = self.cfg['test9Sign']['filepath'] -
TI12-security/trunk/python/ndg.security.test/ndg/security/test/MyProxy/Makefile
r2085 r2178 16 16 initAttAuthorityClientUnittest: ${PROXYFILES} 17 17 @echo Set-up AttAuthority unit test by copying proxy file output from this test... 18 ./MyProxyClientTest.py MyProxyClientTestCase.test2GetDelegation 18 19 cp ${PROXYFILES} ../AttAuthority -
TI12-security/trunk/python/www/html/attAuthority.wsdl
r2107 r2178 25 25 <xsd:complexType> 26 26 <xsd:sequence> 27 <xsd:element name="userId" type="xsd:string" minOccurs="0" maxOccurs="1"/> 27 28 <xsd:element name="userCert" type="xsd:string" minOccurs="0" maxOccurs="1"/> 28 29 <xsd:element name="userAttCert" type="xsd:string" minOccurs="0" maxOccurs="1"/>
Note: See TracChangeset
for help on using the changeset viewer.