def _extract_response(self, method, soap_response): if method == "RequestMultipleSecurityTokens": paths =("./wst:RequestSecurityTokenResponseCollection", "./wst:TokenType", "./wsp:AppliesTo/wsa:EndpointReference/wsa:Address", "./wst:LifeTime/wsu:Created", "./wst:LifeTime/wsu:Expires", "./wst:RequestedSecurityToken/wsse:BinarySecurityToken", "./wst:RequestedSecurityToken/xmlenc:EncryptedData/xmlenc:CipherData/xmlenc:CipherValue", "./wst:RequestedProofToken/wst:BinarySecret") result = self.__response_tokens + [soap_response] soap_utils = SOAPUtils(NS_SHORTHANDS) responses = soap_utils.find_ex(soap_response.body, paths[0]) for response in responses: token = SecurityToken() token.type = soap_utils.find_ex(response, paths[1]).text token.service_address = soap_utils.find_ex(response, paths[2]).text token.lifetime[0] = iso8601.parse(soap_utils.find_ex(response, paths[3]).text) token.lifetime[1] = iso8601.parse(soap_utils.find_ex(response, paths[4]).text) t = soap_utils.find_ex(response, paths[5]) if t is not None: token.security_token = t.text else: token.security_token = soap_utils.find_ex(response, paths[6]).text proof_token = soap_utils.find_ex(response, paths[7]) if proof_token is not None: token.proof_token = proof_token.text self.__storage[token.service_address] = token result.append(token) self.__response_tokens = [] return result else: return SOAPService._extract_response(self, method, soap_response)
def __init__(self, username, password, https_proxy=None): self.__credentials = (username, password) self.__storage = pymsn.storage.get_storage(username, "security_tokens") self.__response_tokens = [] SOAPService.__init__(self, SERVICE_URL, https_proxy)