本文整理汇总了Python中suds.sudsobject.Object.signatureAlgorithm方法的典型用法代码示例。如果您正苦于以下问题:Python Object.signatureAlgorithm方法的具体用法?Python Object.signatureAlgorithm怎么用?Python Object.signatureAlgorithm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类suds.sudsobject.Object
的用法示例。
在下文中一共展示了Object.signatureAlgorithm方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: visitOther
# 需要导入模块: from suds.sudsobject import Object [as 别名]
# 或者: from suds.sudsobject.Object import signatureAlgorithm [as 别名]
def visitOther(self, elt):
policy = self.policy
wsdl_policy = self.wsdl_policy
if elt.name == 'TransportBinding' or elt.name == 'SymmetricBinding' or elt.name == 'AsymmetricBinding':
self.bindingType = elt.name
binding = elt.getChild('Policy')
policy.wsseEnabled = True
if binding.getChild("IncludeTimestamp") is not None:
policy.includeTimestamp = True
if binding.getChild("EncryptBeforeSigning") is not None:
policy.encryptThenSign = True
if binding.getChild("EncryptSignature") is not None:
if policy.encryptThenSign:
self.secondPassEncryptedParts.append(('signature',))
else:
self.baseEncryptedParts.append(('signature',))
if binding.getChild("OnlySignEntireHeadersAndBody") is not None:
policy.onlySignEntireHeadersAndBody = True
if binding.getChild("ProtectTokens") is not None:
policy.protectTokens = True
if binding.getChild("Layout") is not None:
layout = binding.getChild("Layout").getChild("Policy")[0]
policy.headerLayout = layout.name
if elt.name == 'TransportBinding':
transport_token = binding.getChild("TransportToken")
if transport_token is not None:
if transport_token.getChild("Policy").getChild("HttpsToken") is not None:
https_token = transport_token.getChild("Policy").getChild("HttpsToken")
client_cert_req = https_token.get("RequireClientCertificate")
if client_cert_req is None or client_cert_req == "false":
policy.clientCertRequired = False
elif client_cert_req == "true":
policy.clientCertRequired = True
if binding.getChild("InitiatorToken") is not None or binding.getChild("ProtectionToken") is not None:
token = binding.getChild("InitiatorToken") or binding.getChild("ProtectionToken")
if token.getChild("Policy").getChild("X509Token") is not None:
signature = Object()
signature.signedParts = self.buildParts(token.getChild("Policy").getChild("SignedParts"))
signature.signedParts.append(('timestamp',))
# This would technically be the correct behavior, but WCF specifies that thumbprint references
# are supported, but it can't use them for a primary signature. Support for BinarySecurityTokens
# is always required, so just use them
#if token.getChild("Policy").getChild("X509Token").getChild("Policy").getChild("RequireThumbprintReference") is not None:
# signature.keyReference = KEY_REFERENCE_FINGERPRINT
#elif token.getChild("Policy").getChild("X509Token").getChild("Policy").getChild("RequireIssuerSerialReference") is not None:
# signature.keyReference = KEY_REFERENCE_ISSUER_SERIAL
#else:
# signature.keyReference = KEY_REFERENCE_BINARY_SECURITY_TOKEN
if elt.name == 'AsymmetricBinding':
signature.keyReference = KEY_REFERENCE_BINARY_SECURITY_TOKEN
signature.signatureAlgorithm = SIGNATURE_RSA_SHA1
elif elt.name == 'SymmetricBinding':
signature.keyReference = KEY_REFERENCE_ENCRYPTED_KEY
signature.signatureAlgorithm = SIGNATURE_HMAC_SHA1
policy.signatures[0] = signature
if (binding.getChild("InitiatorToken") is not None and binding.getChild("RecipientToken") is not None) or \
binding.getChild("ProtectionToken") is not None:
key = Object()
token = binding.getChild("RecipientToken") or binding.getChild("ProtectionToken")
if token.getChild("Policy").getChild("X509Token").getChild("Policy").getChild("RequireThumbprintReference") is not None:
key.keyReference = KEY_REFERENCE_FINGERPRINT
elif token.getChild("Policy").getChild("X509Token").getChild("Policy").getChild("RequireIssuerSerialReference") is not None:
key.keyReference = KEY_REFERENCE_ISSUER_SERIAL
else:
key.keyReference = KEY_REFERENCE_ISSUER_SERIAL
if elt.name == 'AsymmetricBinding':
key.includeRefList = True
elif elt.name == 'SymmetricBinding':
key.includeRefList = False
key.encryptedParts = self.buildParts(token.getChild("Policy").getChild("EncryptedParts"))
key.secondPassEncryptedParts = []
policy.keys.append(key)
if policy.blockEncryption is None:
algorithm_suite = binding.getChild("AlgorithmSuite")
if algorithm_suite is not None:
if algorithm_suite.getChild("Policy") is not None:
algorithm_policy_name = algorithm_suite.getChild("Policy").getChildren()[0].name
if "Basic128" in algorithm_policy_name:
policy.blockEncryption = BLOCK_ENCRYPTION_AES128_CBC
elif "Basic192" in algorithm_policy_name:
policy.blockEncryption = BLOCK_ENCRYPTION_AES192_CBC
elif "Basic256" in algorithm_policy_name:
policy.blockEncryption = BLOCK_ENCRYPTION_AES256_CBC
elif "TripleDes" in algorithm_policy_name:
policy.blockEncryption = BLOCK_ENCRYPTION_3DES_CBC
if "Sha256" in algorithm_policy_name:
policy.digestAlgorithm = DIGEST_SHA256
else:
policy.digestAlgorithm = DIGEST_SHA1
if "Rsa15" in algorithm_policy_name:
policy.keyTransport = KEY_TRANSPORT_RSA_1_5
else:
policy.keyTransport = KEY_TRANSPORT_RSA_OAEP
if elt.name.endswith("Tokens") and self.initiator:
type = None
index = None
if elt.getChild("Policy").getChild("UsernameToken") is not None:
#.........这里部分代码省略.........