Changeset 674
- Timestamp:
- 14/03/06 17:03:18 (15 years ago)
- Location:
- TI12-security/trunk/python
- Files:
-
- 2 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
TI12-security/trunk/python/NDG/AttAuthority.py
r661 r674 190 190 """Request a new Attribute Certificate for authorisation 191 191 192 reqXMLtxt: input keywords as tags in formatted XML string 193 String must follow format for 194 AttAuthorityIO.AuthorisationReq class to 195 parse. 196 192 197 proxyCertFilePath|proxyCert: 193 198 … … 215 220 # parameters 216 221 if not isinstance(reqXMLtxt, basestring): 217 raise SessionMgrError(\222 raise AttAuthorityError(\ 218 223 "XML Authorisation request must be a string") 219 224 … … 232 237 233 238 except Exception, e: 234 raise SessionMgrError(\239 raise AttAuthorityError(\ 235 240 "Error parsing authorisation request: %s" % e) 236 241 … … 324 329 # user roles are found, the user is not registered 325 330 usrRoles = self.getRoles(str(usrDN)) 326 if usrRoles: 327 331 if usrRoles: 328 332 # Set as an Original Certificate 329 333 # … … 335 339 attCert['provenance'] = 'original' 336 340 337 else: 338 341 else: 339 342 # Set as a Mapped Certificate 340 343 # … … 342 345 # Check for an externally provided certificate from another 343 346 # trusted data centre 344 extAttCert = AttCert(certFilePathList=self.__prop['caCertFile']) 345 346 if userAttCertFilePath is None: 347 if not reqKeys['userAttCert']: 348 raise AttAuthorityAccessDenied(\ 347 if userAttCertFilePath: 348 349 # Read externally provided certificate 350 try: 351 extAttCert = AttCertRead(userAttCertFilePath) 352 353 except Exception, e: 354 raise AttAuthorityError(\ 355 "Reading external Attribute Certificate: %s" + e) 356 357 elif 'userAttCert' in reqKeys and reqKeys['userAttCert']: 358 extAttCert = reqKeys['userAttCert'] 359 360 else: 361 raise AttAuthorityAccessDenied(\ 349 362 "User \"%s\" is not registered " % attCert['holder'] + \ 350 363 "and no external attribute certificate is available " + \ 351 364 "to make a mapping.") 352 353 else:354 # Parse externally provided certificate355 try:356 extAttCert.parse(reqKeys['userAttCert'])357 358 except Exception, e:359 raise AttAuthorityError(\360 "External Attribute Certificate: %s" + e)361 else:362 # Read externally provided certificate363 try:364 extAttCert.read(userAttCertFilePath)365 366 except Exception, e:367 raise AttAuthorityError(\368 "External Attribute Certificate: %s" + e)369 365 370 366 … … 379 375 # Check it's valid and signed 380 376 try: 381 extAttCert.isValid(raiseExcep=True) 377 # Give path to CA cert to allow check 378 extAttCert.isValid(raiseExcep=True, 379 certFilePathList=self.__prop['caCertFile']) 382 380 383 381 except Exception, e: … … 418 416 attCert['provenance'] = 'mapped' 419 417 420 # End ifmapped certificate block418 # End set mapped certificate block 421 419 422 420 … … 627 625 628 626 629 def getTrustedHostInfo(self, localRole=None):627 def getTrustedHostInfo(self, reqXMLtxt=None, **reqKeys): 630 628 """Return a dictionary of the hosts that have trust relationships 631 629 with this AA. The dictionary is indexed by the trusted host name … … 636 634 their possible roles 637 635 638 Returns None if localRole isn't recognised""" 639 636 Returns None if role isn't recognised 637 638 reqXMLtxt: input keywords as tags in formatted XML string 639 String must follow format for 640 AttAuthorityIO.TrustedHostInfoReq class to 641 parse. 642 """ 643 644 if reqXMLtxt is not None: 645 # Parse XML text into keywords corresponding to the input 646 # parameters 647 if not isinstance(reqXMLtxt, basestring): 648 raise AttAuthorityError(\ 649 "XML Authorisation request must be a string") 650 651 # Parse and decrypt as necessary 652 try: 653 # 1st assume that the request was encrypted 654 reqKeys = TrustedHostInfoReq(encrXMLtxt=reqXMLtxt, 655 encrPriKeyFilePath=self.__prop['keyFile'], 656 encrPriKeyPwd=self.__prop['keyPwd']) 657 except Exception, e: 658 659 # Error occured decrypting - Trying parsing again, but this 660 # time assuming non-encrypted 661 try: 662 reqKeys = TrustedHostInfoReq(xmlTxt=reqXMLtxt) 663 664 except Exception, e: 665 raise AttAuthorityError(\ 666 "Error parsing authorisation request: %s" % e) 667 668 640 669 if not self.__localRole2Trusted: 641 670 raise AttAuthorityError("Roles to host look-up is not set - " + \ … … 643 672 644 673 645 if localRole is None:674 if 'role' not in reqKeys: 646 675 # No role input - return all trusted hosts with their WSDL URIs 647 676 # and roles 648 trustedHostInfo = dict([(i[0], \ 649 {'wsdl': i[1]['wsdl'], \ 650 'role': [role['remote'] for role in i[1]['role']]}) \ 651 for i in self.__mapConfig.items()]) 652 653 return trustedHostInfo 654 655 656 # Get trusted hosts for given input local role 657 try: 658 trustedHosts = self.__localRole2TrustedHost[localRole] 659 except: 660 return None 661 662 663 # Get associated WSDL URI and roles for the trusted hosts identified 664 # and return as a dictionary indexed by host name 665 trustedHostInfo = dict([(host, \ 666 {'wsdl': self.__mapConfig[host]['wsdl'], \ 667 'role': self.__localRole2Trusted[host][localRole]}) \ 668 for host in trustedHosts]) 677 trustedHostInfo = dict([\ 678 (k, \ 679 {'wsdl': v['wsdl'], \ 680 'role': [role['remote'] for role in v['role']]}) \ 681 for k, v in self.__mapConfig.items()]) 682 else: 683 # Get trusted hosts for given input local role 684 try: 685 trustedHosts = self.__localRole2TrustedHost[reqKeys['role']] 686 except: 687 return None 688 689 690 # Get associated WSDL URI and roles for the trusted hosts 691 # identified and return as a dictionary indexed by host name 692 trustedHostInfo = dict([(host, \ 693 {'wsdl': self.__mapConfig[host]['wsdl'], \ 694 'role': self.__localRole2Trusted[host][reqKeys['role']]}) \ 695 for host in trustedHosts]) 669 696 670 697 return trustedHostInfo … … 672 699 673 700 674 675 def mapTrusted2LocalRoles(self, trustedHost,trustedHostRoles):701 702 def mapTrusted2LocalRoles(self, trustedHost, trustedHostRoles): 676 703 """Map roles of trusted hosts to roles for this data centre 677 704 -
TI12-security/trunk/python/NDG/AttAuthorityIO.py
r540 r674 39 39 40 40 xmlMandTags = ["proxyCert"] 41 42 43 #_________________________________________________________________________ 44 def update(self, userAttCert=None, **xmlTags): 45 """Override base class implementation to include extra code 46 to allow setting of userAttCert tag""" 47 48 if userAttCert: 49 if isinstance(userAttCert, basestring): 50 attCert = AttCertParse(userAttCert) 51 52 elif isinstance(userAttCert, AttCert): 53 attCert = userAttCert 54 else: 55 raise TypeError(\ 56 "userAttCert keyword must contain string or AttCert type") 57 58 else: 59 attCert = None 60 61 # Call super class update with revised attribute certificate list 62 super(self.__class__, self).update(userAttCert=attCert, **xmlTags) 63 64 65 #_________________________________________________________________________ 66 def updateXML(self, **xmlTags): 67 """Override base class implementation to include extra code 68 to allow attribute certificate to be set from a string or AttCert 69 type""" 70 71 # Update dictionary 72 self.update(**xmlTags) 73 74 # Create XML formatted string ready for encryption 75 try: 76 xmlTxt = self.xmlHdr + os.linesep + \ 77 "<" + self.__class__.__name__ + ">" + os.linesep 78 79 for tag, val in self.items(): 80 if tag == "userAttCert": 81 # Remove any XML header - 82 # update() call will have converted val to AttCert type 83 val = val.asString(stripXMLhdr=True) 84 85 xmlTxt += " <%s>%s</%s>%s" % (tag, val, tag, os.linesep) 86 87 xmlTxt += "</" + self.__class__.__name__ + ">" + os.linesep 88 self.xmlTxt = xmlTxt 89 90 except Exception, e: 91 raise XMLMsgError("Creating XML: %s" % e) 92 93 94 #_________________________________________________________________________ 95 def parseXML(self): 96 """Override base class implementation to include extra code 97 to parse userAttCert tag - if left with the default, elementtree 98 adds extra "ns0" namespaces which invalidate the signature(!)""" 99 100 rootElem = super(self.__class__, self).parseXML(rtnRootElem=True) 101 if 'userAttCert' in self: 102 103 # Convert attribute certificate to AttCert instance 104 try: 105 attCertPat = re.compile(\ 106 '<attributeCertificate>.*</attributeCertificate>', re.S) 107 attCertTxt = attCertPat.findall(self.xmlTxt)[0] 108 109 self['userAttCert'] = AttCertParse(attCertTxt) 110 111 except Exception, e: 112 raise AuthorisationRespError(\ 113 "Error parsing Attribute Certificate: " + str(e)) 41 114 42 115 … … 88 161 to allow setting of extAttCertList tag""" 89 162 90 if credential is not None:163 if credential: 91 164 if isinstance(credential, basestring): 92 165 attCert = AttCertParse(credential) … … 119 192 "<" + self.__class__.__name__ + ">" + os.linesep 120 193 121 for tag, val in xmlTags.items():194 for tag, val in self.items(): 122 195 if tag == "credential": 123 196 # Remove any XML header - … … 160 233 def parseXML(self): 161 234 """Override base class implementation to include extra code 162 to parse extAttCertList tag""" 235 to parse extAttCertList tag - if left with the default, elementtree 236 adds extra "ns0" namespaces which invalidate the signature(!)""" 163 237 164 238 rootElem = super(self.__class__, self).parseXML(rtnRootElem=True) … … 179 253 180 254 #_____________________________________________________________________________ 181 class GetTrustedHostInfoReqError(XMLMsgError):255 class TrustedHostInfoReqError(XMLMsgError): 182 256 """Exception handling for NDG AttAuthority WS GetTrustedHostInfo request 183 257 class.""" … … 186 260 187 261 #_____________________________________________________________________________ 188 class GetTrustedHostInfoReq(XMLMsg):262 class TrustedHostInfoReq(XMLMsg): 189 263 """For client to Attribute Authority WS GetTrustedHostInfo(): formats 190 264 inputs for request into XML and encrypts. … … 194 268 # Override base class class variables 195 269 xmlTagTmpl = { "role": ""} 196 197 xmlMandTags = ["role"] 198 199 200 #_____________________________________________________________________________ 201 class GetTrustedHostInfoRespError(XMLMsgError): 270 271 272 #_____________________________________________________________________________ 273 class TrustedHostInfoRespError(XMLMsgError): 202 274 """Exception handling for NDG AttAuthority WS GetTrustedHostInfo response 203 275 class.""" … … 206 278 207 279 #_____________________________________________________________________________ 208 class GetTrustedHostInfoResp(XMLMsg):280 class TrustedHostInfoResp(XMLMsg): 209 281 """For client to Attribute Authority WS getTrustedInfo(): formats 210 282 response from AttAuthority. … … 213 285 214 286 # Override base class class variables 215 xmlTagTmpl = {"trustedHostInfo": "", "errMsg": ""} 216 217 xmlMandTags = ["errMsg"] 287 xmlTagTmpl = {"trustedHosts": "", "errMsg": ""} 218 288 219 289 … … 229 299 # Allow user credentials to be access like dictionary keys 230 300 super(self.__class__, self).__init__(**xmlMsgKeys) 301 #_________________________________________________________________________ 302 def updateXML(self, **xmlTags): 303 """Override base class implementation to include extra code 304 to allow attribute certificate to be set from a string or AttCert 305 type""" 306 307 # Update dictionary 308 self.update(**xmlTags) 309 310 # Create XML formatted string ready for encryption 311 try: 312 xmlTxt = self.xmlHdr + os.linesep + \ 313 "<" + self.__class__.__name__ + ">" + os.linesep 314 315 if "trustedHosts" in xmlTags: 316 xmlTxt += " <trustedHosts>%s" % os.linesep 317 318 for host, hostInfo in xmlTags['trustedHosts'].items(): 319 xmlTxt += " <trusted name=\"%s\">" % host 320 xmlTxt += os.linesep 321 xmlTxt += " <wsdl>%s</wsdl>" % hostInfo['wsdl'] 322 xmlTxt += os.linesep 323 xmlTxt += " <roleSet>" + os.linesep 324 xmlTxt += ''.join([" <role>%s</role>%s" % \ 325 (role, os.linesep) \ 326 for role in hostInfo['role']]) 327 xmlTxt += " </roleSet>" + os.linesep 328 xmlTxt += " </trusted>" + os.linesep 329 330 xmlTxt += " </trustedHosts>%s" % os.linesep 331 332 if "errMsg" in xmlTags: 333 xmlTxt += " <errMsg>%s</errMsg>%s" % \ 334 (xmlTags['errMsg'], os.linesep) 335 336 xmlTxt += "</" + self.__class__.__name__ + ">" + os.linesep 337 self.xmlTxt = xmlTxt 338 339 340 except Exception, e: 341 raise XMLMsgError("Creating XML: %s" % e) 342 343 344 #_________________________________________________________________________ 345 def parseXML(self): 346 """Override base class implementation to include extra code 347 to parse trusted hosts info""" 348 349 rootElem = super(self.__class__, self).parseXML(rtnRootElem=True) 350 self['trustedHosts'] = {} 351 352 trustedHostsElem = rootElem.find('trustedHosts') 353 if not trustedHostsElem: 354 raise TrustedHostInfoRespError(\ 355 "\"trustedHosts\" tag not found in trusted host info response") 356 357 for trusted in trustedHostsElem: 358 try: 359 host = trusted.items()[0][1] 360 361 # Add key for trusted host name 362 self['trustedHosts'][host] = {} 363 364 # Add WSDL URI and role set for that host 365 self['trustedHosts'][host]['wsdl'] = \ 366 trusted.find('wsdl').text.strip() 367 368 self['trustedHosts'][host]['role'] = \ 369 [role.text.strip() for role in trusted.find('roleSet')] 370 371 except Exception, e: 372 raise TrustedHostInfoRespError(\ 373 "Error parsing tag \"%s\" in trusted host info response: %s" \ 374 % (trusted.tag, str(e))) -
TI12-security/trunk/python/NDG/AttCert.py
r660 r674 202 202 203 203 204 def __nonzero__(self): 205 """Ensure if <attCertInstance> test yields True""" 206 return True 207 208 204 209 def clear(self): 205 raise AttCertError("Data cannot be cleared from " + self.__class__.__name__) 210 raise AttCertError("Data cannot be cleared from " + \ 211 self.__class__.__name__) 206 212 207 213 … … 771 777 by self.__filePath is read instead. 772 778 773 certFilePathList: list of files paths must contain certificate of774 trusted authority used to validate the775 signature. If set, it is copied 776 intoself.__certFilePathList. If omitted779 certFilePathList: list of files paths must contain certificate 780 of trusted authority used to validate the 781 signature. If set, it is copied into 782 self.__certFilePathList. If omitted 777 783 self.__certFilePathList is used unchanged. 778 784 """ -
TI12-security/trunk/python/NDG/CredWallet.py
r661 r674 443 443 self.__credRepos.addCredentials(self.__dn, attCertList) 444 444 445 446 445 447 446 def __reqAuthorisation(self, … … 482 481 raise CredWalletError(\ 483 482 "Input Attribute Certificate must be AttCert type") 484 485 extAttCertTxt = extAttCert.asString()486 else:487 extAttCertTxt = '' # None488 489 483 490 484 if aaWSDL is not None: 491 492 485 if not isinstance(aaWSDL, basestring): 493 486 raise CredWalletError("Attribute Authority WSDL file " + \ … … 517 510 authorisationReq = AuthorisationReq(\ 518 511 proxyCert=self.__proxyCertTxt, 519 userAttCert=extAttCert Txt,512 userAttCert=extAttCert, 520 513 clntCert=clntCertTxt, 521 514 encrPubKeyFilePath=aaCertFilePath) … … 569 562 # Authority 570 563 attCert = aa.authorise(proxyCert=self.__proxyCertTxt, 571 userAttCert Txt=extAttCertTxt)564 userAttCert=extAttCert) 572 565 573 566 except AttAuthorityAccessDenied, e: … … 609 602 """Wrapper to Attribute Authority getTrustedHostInfo 610 603 611 userRole: get hosts which have a m pping to this role604 userRole: get hosts which have a mapping to this role 612 605 aaWSDL|aaPropFilePath: to call as a web service, specify the file 613 606 path or URI for the Attribute Authority's … … 630 623 aaSrv = ServiceProxy(aaWSDL, use_wsdl=True) 631 624 625 # Format request 626 trustedHostInfoReq = TrustedHostInfoReq(role=userRole) 627 632 628 # Call Attribute Authority's Web service 633 resp = aaSrv.getTrustedHostInfo(usrRole=userRole) 634 if resp['errMsg']: 635 raise Exception(resp['errMsg']) 636 637 # De-serialise output into a dictionary of roles indexed by 638 # host name 639 hostList = [] 640 for host in resp['trustedHostInfo']: 641 hostSplit = re.split("\s*:\s*", str(host)) 642 roleList = re.split("\s*,\s*", hostSplit[2]) 643 644 hostList.append((hostSplit[0], \ 645 {'wsdl': hostSplit[1], 'role': roleList})) 646 647 return dict(hostList) 629 resp = aaSrv.getTrustedHostInfo(\ 630 trustedHostInfoReq=trustedHostInfoReq()) 631 632 # Parse response 633 trustedHostInfoResp = TrustedHostInfoResp(\ 634 xmlTxt=str(resp['trustedHostInfoResp'])) 635 if 'errMsg' in trustedHostInfoResp and \ 636 trustedHostInfoResp['errMsg']: 637 raise Exception(trustedHostInfoResp['errMsg']) 638 639 return trustedHostInfoResp['trustedHosts'] 648 640 649 641 except socket.error, e: -
TI12-security/trunk/python/NDG/Session.py
r668 r674 365 365 366 366 except Exception, e: 367 raise SessionMgrError("Error parsing properties file: %s" % e) 367 raise SessionMgrError(\ 368 "Error parsing properties file: \"%s\": %s" % \ 369 (propFilePath, e)) 368 370 369 371 if propElem is None: … … 378 380 dbPPhrase=credReposPPhrase) 379 381 elif elem.tag in self.__validKeys: 380 # Check for environment variables in file paths 381 tagCaps = elem.tag.upper() 382 if 'FILE' in tagCaps or 'PATH' in tagCaps or 'DIR' in tagCaps: 383 elem.text = os.path.expandvars(elem.text) 382 try: 383 # Check for environment variables in file paths 384 tagCaps = elem.tag.upper() 385 if 'FILE' in tagCaps or \ 386 'PATH' in tagCaps or \ 387 'DIR' in tagCaps: 388 elem.text = os.path.expandvars(elem.text) 389 390 self.__prop[elem.tag] = elem.text 384 391 385 self.__prop[elem.tag] = elem.text 386 387 # Strip white space but not in the case of pass-phrase field 388 # as pass-phrase might contain leading or trailing white space 389 if elem.tag != 'keyPPhrase': 390 self.__prop[elem.tag].strip() 392 # Strip white space but not in the case of pass-phrase 393 # field as pass-phrase might contain leading or trailing 394 # white space 395 if elem.tag != 'keyPPhrase' and \ 396 isinstance(self.__prop[elem.tag], basestring): 397 self.__prop[elem.tag].strip() 398 399 except Exception, e: 400 raise SessionMgrError(\ 401 "Error parsing properties file tag: \"%s\": %s" % \ 402 (elem.tag, e)) 403 391 404 else: 392 405 raise SessionMgrError(\ -
TI12-security/trunk/python/NDG/attAuthority_services_server.py
r540 r674 60 60 61 61 try: 62 resp._trustedHostInfoResp = self.__srv.getTrustedHostInfo(\ 63 reqTxt=reqTxt) 62 trustedHosts = self.__srv.getTrustedHostInfo(reqXMLtxt=reqTxt) 63 trustedHostInfoResp = TrustedHostInfoResp(\ 64 trustedHosts=trustedHosts) 64 65 except Exception, e: 65 resp._trustedHostInfoResp=str(TrustedHostInfoResp(errMsg=str(e)))66 trustedHostInfoResp = TrustedHostInfoResp(errMsg=str(e)) 66 67 68 resp._trustedHostInfoResp = str(trustedHostInfoResp) 67 69 return resp 68 70 -
TI12-security/trunk/python/ndgSessionClient.py
r668 r674 150 150 sys.exit(1) 151 151 152 # Use long options to make a di sctionary153 arg s= {}.fromkeys([opt.split('=')[0] for opt in optLongNames])152 # Use long options to make a dictionary 153 argDict = {}.fromkeys([opt.split('=')[0] for opt in optLongNames]) 154 154 155 155 extTrustedHostList = None … … 163 163 164 164 elif opt in ("-n", "--add-user"): 165 arg s['add-user'] = True165 argDict['add-user'] = True 166 166 167 167 elif opt in ("-c", "--connect"): 168 arg s['connect'] = True168 argDict['connect'] = True 169 169 170 170 elif opt in ("-r", "--req-autho"): 171 arg s['req-autho'] = True171 argDict['req-autho'] = True 172 172 173 173 elif opt in ("-s", "--session-mgr-wsdl-uri"): 174 arg s['session-mgr-wsdl-uri'] = arg174 argDict['session-mgr-wsdl-uri'] = arg 175 175 176 176 elif opt in ("-a", "--att-authority-wsdl-uri"): 177 arg s['att-authority-wsdl-uri'] = arg177 argDict['att-authority-wsdl-uri'] = arg 178 178 179 179 elif opt in ("-u", "--username"): 180 arg s['username'] = arg180 argDict['username'] = arg 181 181 182 182 elif opt in ("-p", "--pass-phrase-from-stdin"): 183 arg s['pass-phrase-from-stdin'] = True183 argDict['pass-phrase-from-stdin'] = True 184 184 185 185 elif opt in ("-i", "--session-id"): 186 arg s['session-id'] = arg186 argDict['session-id'] = arg 187 187 188 188 elif opt in ("-e", "--encr-sess-mgr-wsdl-uri"): 189 arg s['encr-sess-mgr-wsdl-uri'] = arg189 argDict['encr-sess-mgr-wsdl-uri'] = arg 190 190 191 191 elif opt in ("-d", "--soap-debug"): 192 arg s['soap-debug'] = sys.stderr192 argDict['soap-debug'] = sys.stderr 193 193 194 194 elif opt in ("-m", "--map-from-trusted-hosts"): 195 arg s['map-from-trusted-hosts'] = True195 argDict['map-from-trusted-hosts'] = True 196 196 197 197 elif opt in ("-q", "--req-role"): 198 arg s['req-role'] = arg198 argDict['req-role'] = arg 199 199 200 200 elif opt in ("-l", "--rtn-ext-att-cert-list"): 201 arg s['rtn-ext-att-cert-list'] = True201 argDict['rtn-ext-att-cert-list'] = True 202 202 203 203 elif opt in ("-f", "--ext-att-cert-list-file"): 204 arg s['ext-att-cert-list-file'] = arg204 argDict['ext-att-cert-list-file'] = arg 205 205 206 206 try: 207 207 # Open and read file removing any <?xml ... ?> headers 208 fpExtAttCertList = open(arg s['ext-att-cert-list-file'])208 fpExtAttCertList = open(argDict['ext-att-cert-list-file']) 209 209 sAttCertList = \ 210 210 re.sub("\s*<\?xml.*\?>\s*", "", fpExtAttCertList.read()) … … 221 221 try: 222 222 extTrustedHostList = \ 223 re.split("\s*,\s*",open(args['ext-trusted-host-file']).read()) 223 re.split("\s*,\s*", 224 open(argDict['ext-trusted-host-file']).read()) 224 225 225 226 except Exception, e: … … 235 236 236 237 # For connect/addUser a pass-phrase is needed 237 if arg s['add-user'] or args['connect']:238 239 if arg s['pass-phrase-from-stdin']:238 if argDict['add-user'] or argDict['connect']: 239 240 if argDict['pass-phrase-from-stdin']: 240 241 # Read from standard input 241 242 passPhrase = sys.stdin.read().strip() … … 245 246 import getpass 246 247 try: 247 passPhrase = getpass.getpass(prompt="pass-phrase: ") 248 # passPhrase = getpass.getpass(prompt="pass-phrase: ") 249 passPhrase = open('./Tests/tmp').read().strip() 248 250 except KeyboardInterrupt: 249 251 sys.exit(1) … … 252 254 # Initialise session client 253 255 try: 254 sessClnt = SessionClient(smWSDL=arg s['session-mgr-wsdl-uri'],255 traceFile=arg s['soap-debug'])256 sessClnt = SessionClient(smWSDL=argDict['session-mgr-wsdl-uri'], 257 traceFile=argDict['soap-debug']) 256 258 except Exception, e: 257 259 sys.stderr.write("Initialising client: %s\n" % str(e)) … … 259 261 260 262 try: 261 if arg s['add-user']:262 sessClnt.addUser(userName=arg s['username'], pPhrase=passPhrase)263 if argDict['add-user']: 264 sessClnt.addUser(userName=argDict['username'], pPhrase=passPhrase) 263 265 sys.exit(0) 264 266 265 if arg s['connect']:266 sSessCookie = sessClnt.connect(userName=arg s['username'],267 if argDict['connect']: 268 sSessCookie = sessClnt.connect(userName=argDict['username'], 267 269 pPhrase=passPhrase) 268 270 print sSessCookie 269 271 # Don't exit here - req-autho may have been set too 270 272 271 if arg s['req-autho']:272 if arg s['connect']:273 if argDict['req-autho']: 274 if argDict['connect']: 273 275 # Connect was set also - parse cookie in order to session ID 274 276 # and WSDL address … … 276 278 sessCookie = SimpleCookie(sSessCookie) 277 279 278 arg s['session-id'] = sessCookie['NDG-ID1'].value279 arg s['encr-sess-mgr-wsdl-uri'] =sessCookie['NDG-ID2'].value280 argDict['session-id'] = sessCookie['NDG-ID1'].value 281 argDict['encr-sess-mgr-wsdl-uri']=sessCookie['NDG-ID2'].value 280 282 281 283 authResp = sessClnt.reqAuthorisation(\ 282 sessID=arg s['session-id'],283 encrSessMgrWSDLuri=arg s['encr-sess-mgr-wsdl-uri'],284 aaWSDL=arg s['att-authority-wsdl-uri'],285 mapFromTrustedHosts=arg s['map-from-trusted-hosts'],286 reqRole=arg s['req-role'],287 rtnExtAttCertList=arg s['rtn-ext-att-cert-list'],284 sessID=argDict['session-id'], 285 encrSessMgrWSDLuri=argDict['encr-sess-mgr-wsdl-uri'], 286 aaWSDL=argDict['att-authority-wsdl-uri'], 287 mapFromTrustedHosts=argDict['map-from-trusted-hosts'], 288 reqRole=argDict['req-role'], 289 rtnExtAttCertList=argDict['rtn-ext-att-cert-list'], 288 290 extAttCertList=extAttCertList, 289 291 extTrustedHostList=extTrustedHostList)
Note: See TracChangeset
for help on using the changeset viewer.