Changeset 2746 for TI12-security/trunk
- Timestamp:
- 26/07/07 16:43:00 (13 years ago)
- Location:
- TI12-security/trunk/python
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
TI12-security/trunk/python/ndg.security.common/ndg/security/common/AttAuthority/__init__.py
r2739 r2746 330 330 331 331 try: 332 sAttCert, msg = self.__srv.getAttCert(userId, userCert,userAttCert)332 sAttCert, msg = self.__srv.getAttCert(userId,userCert,userAttCert) 333 333 except httplib.BadStatusLine, e: 334 334 raise AttAuthorityClientError, "HTTP bad status line: %s" % e -
TI12-security/trunk/python/ndg.security.common/ndg/security/common/CredWallet.py
r2686 r2746 77 77 78 78 def __init__(self, msg=None, extAttCertList=[], trustedHostInfo={}): 79 """Raise exception for a uthorisationdenied with option to give79 """Raise exception for attribute request denied with option to give 80 80 caller hint to certificates that could used to try to obtain a 81 81 mapped certificate … … 788 788 The procedure is: 789 789 790 1) Try a uthorisationusing proxy certificate790 1) Try attribute request using proxy certificate 791 791 2) If the Attribute Authority (AA) doesn't recognise the certificate, 792 792 find out any other hosts which have a trust relationship to the AA. … … 830 830 831 831 @type rtnExtAttCertList: bool / None 832 @keyword rtnExtAttCertList: If authorisationfails, make a list of832 @keyword rtnExtAttCertList: If request fails, make a list of 833 833 candidate certificates from other Attribute Authorities which the user 834 834 could use to retry and get a mapped certificate. … … 1076 1076 raise CredWalletAttributeRequestDenied(msg=msg, 1077 1077 extAttCertList=extAttCertList, 1078 trustedHostInfo=trustedHostInfo) 1079 1080 except Exception, authorisationError: 1081 # Authorisation request raised an error other than access 1082 # denied 1083 raise authorisationError 1084 1078 trustedHostInfo=trustedHostInfo) 1085 1079 1086 1080 -
TI12-security/trunk/python/ndg.security.common/ndg/security/common/SessionMgr/__init__.py
r2739 r2746 26 26 from ndg.security.common.wsSecurity import SignatureHandler 27 27 from ndg.security.common.X509 import * 28 from ndg.security.common.AttCert import AttCert Parse28 from ndg.security.common.AttCert import AttCert, AttCertParse 29 29 from ndg.security.common.m2CryptoSSLUtility import HTTPSConnection, \ 30 30 HostCheck … … 39 39 class AttributeRequestDenied(Exception): 40 40 """Raise when a getAttCert call to the Attribute Authority is denied""" 41 42 def __init__(self, msg=None, extAttCertList=[]): 43 """Raise exception for attribute request denied with option to give 44 caller hint to certificates that could used to try to obtain a 45 mapped certificate 46 47 @type msg: string 48 @keyword msg: error message 49 50 @type extAttCertList: list 51 @keyword extAttCertList: list of candidate Attribute Certificates that 52 could be used to try to get a mapped certificate from the target 53 Attribute Authority""" 54 55 self.__msg = msg 56 57 # Prevent None type setting 58 self.__extAttCertList = [] 59 if extAttCertList is not None: 60 for ac in extAttCertList: 61 if isinstance(ac, basestring): 62 ac = AttCertParse(ac) 63 elif not isinstance(ac, AttCert): 64 raise SessionMgrClientError, \ 65 "Input external Attribute Cert. must be AttCert type" 66 67 self.__extAttCertList += [ac] 68 69 def __str__(self): 70 return self.__msg 71 72 def __getMsg(self): 73 """Get message text""" 74 return self.__msg 75 76 msg = property(fget=__getMsg, doc="Error message text") 77 78 def __getExtAttCertList(self): 79 """Return list of candidate Attribute Certificates that could be used 80 to try to get a mapped certificate from the target Attribute Authority 81 """ 82 return self.__extAttCertList 83 84 extAttCertList = property(fget=__getExtAttCertList, 85 doc="list of candidate Attribute " + \ 86 "Certificates that could be used " + \ 87 "to try to get a mapped certificate " + \ 88 "from the target Attribute Authority") 41 89 42 90 #_____________________________________________________________________________ … … 351 399 user's credential wallet held by the session manager. 352 400 353 getAttCert([sessID=i]|[proxyCert=p][key=arg, ...]) 354 355 proxyCert: proxy certificate - use as ID instead of 356 session ID. This can be omitted if the 357 message is signed with a proxy certificate. 358 In this case the proxy certificate is passed 359 in the BinarySecurityToken of the WS-Security 360 header 361 sessID: session ID. Input this as an alternative to 362 proxyCert in the case of a browser client. 363 attAuthorityURI: URI for Attribute Authority WS. 364 attAuthorityCert: The Session Manager uses the Public key of the 365 Attribute Authority to encrypt requests to it. 366 reqRole: The required role for access to a data set. 367 This can be left out in which case the 368 Attribute Authority just returns whatever 369 Attribute Certificate it has for the user 370 mapFromTrustedHosts: Allow a mapped Attribute Certificate to be 371 created from a user certificate from another 372 trusted host. 373 rtnExtAttCertList: Set this flag True so that if authorisation is 374 denied, a list of potential attribute 375 certificates for mapping may be returned. 376 extAttCertList: A list of Attribute Certificates from other 377 trusted hosts from which the target Attribute 378 Authority can make a mapped certificate 379 extTrustedHostList: A list of trusted hosts that can be used to 380 get Attribute Certificates for making a mapped 381 AC. 382 """ 401 ac = getAttCert([sessID=i]|[proxyCert=p][key=arg, ...]) 402 403 @raise AttributeRequestDenied: this is raised if the request is 404 denied because the user is not registered with the Attribute 405 Authority. In this case, a list of candidate attribute certificates 406 may be returned which could be used to retry with a request for a 407 mapped AC. These are assigned to the raised exception's 408 extAttCertList attribute 409 410 @type proxyCert: string 411 @keyword proxyCert: proxy certificate - use as ID instead of session 412 ID. This can be omitted if the message is signed with a proxy 413 certificate. In this case the proxy certificate is passed in the 414 BinarySecurityToken of the WS-Security header 415 416 @type sessID: string 417 @keyword sessID: session ID. Input this as an alternative to 418 proxyCert in the case of a browser client. 419 420 @type attAuthorityURI: string 421 @keyword attAuthorityURI: URI for Attribute Authority WS. 422 423 @type attAuthorityCert: string 424 @keyword attAuthorityCert: The Session Manager uses the Public key of 425 the Attribute Authority to encrypt requests to it. 426 427 @type reqRole: string 428 @keyword reqRole: The required role for access to a data set. This 429 can be left out in which case the Attribute Authority just returns 430 whatever Attribute Certificate it has for the user 431 432 @type mapFromTrustedHosts: bool 433 @keyword mapFromTrustedHosts: Allow a mapped Attribute Certificate to 434 be created from a user certificate from another trusted host. 435 436 @type rtnExtAttCertList: bool 437 @keyword rtnExtAttCertList: Set this flag True so that if the 438 attribute request is denied, a list of potential attribute 439 certificates for mapping may be returned. 440 441 @type extAttCertList: list 442 @keyword extAttCertList: A list of Attribute Certificates from other 443 trusted hosts from which the target Attribute Authority can make a 444 mapped certificate 445 446 @type extTrustedHostList: list 447 @keyword extTrustedHostList: A list of trusted hosts that can be used 448 to get Attribute Certificates for making a mapped AC. 449 450 @rtype: ndg.security.common.AttCert.AttCert 451 @return: if successful, an attribute certificate.""" 383 452 384 453 # Make request … … 393 462 extTrustedHostList) 394 463 if not attCert: 395 raise AttributeRequestDenied, msg 396 397 return attCert, extAttCertList464 raise AttributeRequestDenied, msg, extAttCertList 465 466 return AttCertParse(attCert) 398 467 399 468 -
TI12-security/trunk/python/ndg.security.common/ndg/security/common/XMLSec.py
r2437 r2746 39 39 from sha import sha 40 40 from M2Crypto import X509, BIO, RSA 41 from ndg.security.common.X509 import X509CertRead, X509Stack 41 42 import base64 42 43 … … 548 549 InvalidSignature exception if the signature is invalid 549 550 550 @param xmlTxt: string buffer containing the text from the XML file to 551 be checked. If omitted, the filePath argument is used instead. 552 553 @param filePath: file path to XML file to be checked. This 554 argument is used if no xmlTxt was provided. If filePath itself is 555 omitted the file set by self.__filePath is read instead. 556 557 @param certFilePathList: Certificate used to sign the document.""" 558 559 551 @type xmlTxt: string 552 @keyword xmlTxt: text from the XML file to be checked. If omitted, the 553 the existing parse document is used instead.""" 554 560 555 if xmlTxt: 561 556 self.parse(xmlTxt) … … 774 769 if not verify: 775 770 raise InvalidSignature, "Invalid signature" 771 772 # Verify chain of trust if list cert list is present 773 if self.__certFilePathList: 774 # Make a stack object for CA certs 775 caX509Stack = X509Stack() 776 for cert in self.__certFilePathList: 777 caX509Stack.push(X509CertRead(cert)) 778 779 # Make a stack object for certs to be verified 780 x509Stack = X509Stack() 781 x509Stack.push(x509Cert) 782 x509Stack.verifyCertChain(caX509Stack=caX509Stack) 776 783 777 784 -
TI12-security/trunk/python/ndg.security.server/ndg/security/server/MyProxy.py
r2715 r2746 226 226 self.__prop['gridSecurityDir'] = os.environ['GRID_SECURITY_DIR'] 227 227 228 self.__openSSLConf.filePath = \ 228 if 'openSSLConfFileName' in self.__prop: 229 self.__openSSLConf.filePath = \ 229 230 os.path.join(self.__prop['gridSecurityDir'], 230 231 self.__prop['openSSLConfFileName']) 231 self.__openSSLConf.read()232 self.__openSSLConf.read() 232 233 233 234 … … 245 246 246 247 # Update openssl conf file path 247 if 'gridSecurityDir' in prop or 'openSSLConfFileName' in prop: 248 # 249 # Check 'prop' to see if they've been in THIS update 250 # Check 'self.__prop' to ensure both are present in 251 # order to construct a file path 252 if 'gridSecurityDir' in prop or \ 253 'openSSLConfFileName' in prop and \ 254 'gridSecurityDir' in self.__prop and \ 255 'openSSLConfFileName' in self.__prop: 248 256 self.__openSSLConf.filePath = \ 249 257 os.path.join(self.__prop['gridSecurityDir'], -
TI12-security/trunk/python/ndg.security.server/ndg/security/server/SessionMgr/__init__.py
r2732 r2746 1052 1052 1053 1053 except CredWalletAttributeRequestDenied, e: 1054 # Exception object contain aa list of attribute certificates1054 # Exception object contains a list of attribute certificates 1055 1055 # which could be used to re-try to get authorisation via a mapped 1056 1056 # certificate -
TI12-security/trunk/python/ndg.security.server/ndg/security/server/conf/sessionMgrProperties.xml
r2733 r2746 26 26 Delete this element and take setting from MYPROXY_SERVER environment 27 27 variable if required 28 --> 28 29 <hostname>localhost</hostname> 29 -->30 30 <!-- 31 31 Delete this element to take default setting 7512 or read -
TI12-security/trunk/python/ndg.security.test/ndg/security/test/AttCert/AttCertTest.py
r2686 r2746 204 204 '''test12IsValid: check signature of XML document''' 205 205 self.test11Read() 206 self.attCert.certFilePathList=self.cfg['test12IsValid']['certfile'] 206 self.attCert.certFilePathList = \ 207 self.cfg['test12IsValid']['certfilepathlist'].split() 207 208 self.attCert.isValid(raiseExcep=True) 209 print 'test12IsValid: passed' 208 210 209 211 … … 215 217 216 218 self.attCert.certFilePathList = \ 217 self.cfg['test13IsValidStressTest']['certfile']219 self.cfg['test13IsValidStressTest']['certfilepathlist'].split() 218 220 self.attCert.signingKeyFilePath = \ 219 221 self.cfg['test13IsValidStressTest']['keyfile'] … … 237 239 238 240 # Write AC file names by index 239 self.attCert.filePath = " %03d.xml" % i241 self.attCert.filePath = "stress-test-ac-%03d.xml" % i 240 242 241 243 self.attCert.applyEnvelopedSignature() 242 244 self.attCert.write() 243 244 self.attCert.certFilePathList = \245 self.cfg['test13IsValidStressTest']['certfile']246 245 247 246 try: … … 258 257 self.attCert.read() 259 258 260 self.attCert.certFilePathList=self.cfg['test14IsValidSignature']['certfile'] 259 self.attCert.certFilePathList = \ 260 self.cfg['test14IsValidSignature']['certfilepathlist'].split() 261 261 self.attCert.verifyEnvelopedSignature() 262 262 -
TI12-security/trunk/python/ndg.security.test/ndg/security/test/AttCert/attCertTest.cfg
r2437 r2746 18 18 filePath: ./ac.xml 19 19 20 [test11Read] ]]]20 [test11Read] 21 21 filePath: ./ac.xml 22 22 23 23 [test12IsValid] 24 certFile : ./cert.pem24 certFilePathList: ./cacert.pem 25 25 26 26 [test13IsValidStressTest] 27 certFile: ./cert.pem 27 # First cert is added to the signature, both certs are used in the 28 # verification 29 certFilepathlist: ./cert.pem ./cacert.pem 28 30 keyFile: ./key.pem 29 31 #keyPwd: 30 nruns: 10032 nruns: 30 31 33 32 34 [test14IsValidSignature] 33 certFile : ./cert.pem34 filePath: ./ badSignature.xml35 certFilePathList: ./cacert.pem 36 filePath: ./ac.xml 35 37 36 38 -
TI12-security/trunk/python/ndg.security.test/ndg/security/test/SessionMgr/SessionMgrClientTest.py
r2685 r2746 220 220 self.test2Connect() 221 221 222 attCert , extAttCertList= self.clnt.getAttCert(\222 attCert = self.clnt.getAttCert(\ 223 223 sessID=self.sessID, 224 224 attAuthorityURI=self.cfg['test6GetAttCertUsingSessID']['aauri']) 225 225 226 226 print "Attribute Certificate:\n%s" % attCert 227 print "External Attribute Certificate List:\n%s" % extAttCertList228 227 229 228 … … 239 238 240 239 try: 241 attCert, extAttCertList = self.clnt.getAttCert(\ 242 sessID=self.sessID, 243 attAuthorityURI=aaURI, 244 mapFromTrustedHosts=False) 240 attCert = self.clnt.getAttCert(sessID=self.sessID, 241 attAuthorityURI=aaURI, 242 mapFromTrustedHosts=False) 245 243 except AttributeRequestDenied, e: 246 244 print "SUCCESS - obtained expected result: %s" % e … … 259 257 aaURI = self.cfg['test6bGetMappedAttCertUsingSessID']['aauri'] 260 258 261 attCert, extAttCertList = self.clnt.getAttCert(sessID=self.sessID, 262 attAuthorityURI=aaURI) 259 attCert=self.clnt.getAttCert(sessID=self.sessID,attAuthorityURI=aaURI) 263 260 264 261 print "Attribute Certificate:\n%s" % attCert 265 print "External Attribute Certificate List:\n%s" % extAttCertList266 262 267 263 … … 277 273 self.cfg['test6cGetAttCertWithExtAttCertListUsingSessID']['aauri'] 278 274 279 attCert, extAttCertList = self.clnt.getAttCert(\ 280 sessID=self.sessID, 281 attAuthorityURI=aaURI, 282 extAttCertList=['AC1', 'AC2', 'AC3']) 275 attCert = self.clnt.getAttCert(sessID=self.sessID, 276 attAuthorityURI=aaURI, 277 extAttCertList=['AC1', 'AC2', 'AC3']) 283 278 284 279 print "Attribute Certificate:\n%s" % attCert 285 print "External Attribute Certificate List:\n%s" % extAttCertList286 280 287 281 … … 301 295 302 296 aaURI = self.cfg['test7GetAttCertUsingProxyCert']['aauri'] 303 attCert , extAttCertList= self.clnt.getAttCert(attAuthorityURI=aaURI)297 attCert = self.clnt.getAttCert(attAuthorityURI=aaURI) 304 298 305 299 print "Attribute Certificate:\n%s" % attCert 306 print "External Attribute Certificate List:\n%s" % extAttCertList307 300 308 301 -
TI12-security/trunk/python/ndg.security.test/ndg/security/test/SessionMgr/sessionMgrClientTest.cfg
r2685 r2746 10 10 # $Id:$ 11 11 [setUp] 12 smuri = https://localhost:5700/SessionManager 12 #smuri = https://localhost:5700/SessionManager 13 smuri = https://glue.badc.rl.ac.uk:50000/SessionManager 13 14 14 15 # For https connections only. !Omit ssl* settings if using http! 15 16 # sslpeercertcn is the expected CommonName of peer cert. Omit if it's the 16 17 # same as peer hostname. 17 sslpeercertcn = webSphereTest18 #sslpeercertcn = webSphereTest 18 19 sslcacertfilepathlist = cacert.pem 19 20 … … 52 53 53 54 [test2Connect] 54 username = raphaelTest 55 username = lawrence 56 #username = raphaelTest 55 57 #username = gabriel 56 58 #passphrase = … … 74 76 75 77 [test7GetAttCertUsingProxyCert] 76 aaURI = https://localhost:5000/AttributeAuthority 77 78 79 78 #aaURI = https://localhost:5000/AttributeAuthority 79 aaURI = http://glue.badc.rl.ac.uk/services/ndg/security/AttributeAuthority
Note: See TracChangeset
for help on using the changeset viewer.