0
我正在使用jQuery ajax調用WS-Trust服務來檢索SAML斷言。我的服務的響應包括完整的WS-Trust響應,並且我只需要doc中間的斷言。從XML文檔jQuery提取和顯示節點
的XML文檔是:
<ns3:RequestSecurityTokenResponse xmlns:ns1="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:ns10="http://www.w3.org/2000/09/xmldsig#" xmlns:ns2="http://www.w3.org/2005/08/addressing" xmlns:ns3="http://docs.oasis-open.org/ws-sx/ws-trust/200512/" xmlns:ns4="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:ns5="http://docs.oasis-open.org/ws-sx/ws-trust/200802" xmlns:ns6="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:ns7="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:ns8="http://schemas.xmlsoap.org/ws/2005/02/sc" xmlns:ns9="http://schemas.xmlsoap.org/ws/2006/02/addressingidentity">
<ns3:RequestedSecurityToken>
<saml2:Assertion xmlns:ns2="http://www.w3.org/2000/09/xmldsig#" xmlns:ns3="http://www.w3.org/2001/04/xmlenc#" xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion" ID="SAML_4e367081-34ab-11e4-b48c-e062ecbc9f52" IssueInstant="2014-09-04T20:18:28.420-07:00" Version="2.0">
<saml2:Issuer>pmdomain</saml2:Issuer>
<saml2:Subject>
<saml2:NameID Format="urn:com:soa:saml:nameid-format:QualifiedName" NameQualifier="PolicyManager">Local LDAP\igoldsmith</saml2:NameID>
<saml2:SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:sender-vouches" />
</saml2:Subject>
<saml2:Conditions NotOnOrAfter="2014-09-05T00:18:28.420-07:00" />
<saml2:AuthnStatement AuthnInstant="2014-09-04T20:18:28.420-07:00">
<saml2:AuthnContext>
<saml2:AuthnContextClassRef>urn:oasis:names:tc:SAML:2.0:ac:classes:unspecified</saml2:AuthnContextClassRef>
</saml2:AuthnContext>
</saml2:AuthnStatement>
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:SignedInfo>
<ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
<ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" />
<ds:Reference URI="#SAML_4e367081-34ab-11e4-b48c-e062ecbc9f52">
<ds:Transforms>
<ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />
<ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
</ds:Transforms>
<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
<ds:DigestValue>/9WRlKPTL5N2SJOYe9pSw9Coy4I=</ds:DigestValue>
</ds:Reference>
</ds:SignedInfo>
<ds:SignatureValue>
Lgxq9PdlgSTU5R6JvhFBLbGv6PZUo64DhZvlovtg/sfTSZcljHKld9XQvE5cWT4Q2O0EVhxb332O
XBipazlw8Tluvlf5s/k2m8L9LhtR2X/kdI+HooGEyHFBFLg4cX4nKP8Mbmc+bJegOtMlFSy/Zj5y
gZr+bNwPk0xdniblmco=
</ds:SignatureValue>
<ds:KeyInfo>
<ds:X509Data>
<ds:X509Certificate>
MIICATCCAWqgAwIBAgIIZ7i81vjsmF0wDQYJKoZIhvcNAQEFBQAwQzELMAkGA1UEBhMCVVMxCzAJ
BgNVBAgTAkNBMQwwCgYDVQQKEwNTT0ExDDAKBgNVBAsTA1NPQTELMAkGA1UEAxMCcG0wHhcNMTQw
NjE3MjA0ODIxWhcNMTkwNjE4MTM0NTAwWjBDMQswCQYDVQQGEwJVUzELMAkGA1UECBMCQ0ExDDAK
BgNVBAoTA1NPQTEMMAoGA1UECxMDU09BMQswCQYDVQQDEwJwbTCBnzANBgkqhkiG9w0BAQEFAAOB
jQAwgYkCgYEAlyVusLGwuaFjL7nFdnvqbLVMq7T0wONpLTYDGMFwg5gEz+8gDzi7nZrtwxOe31V8
gEz6u6KdZXfjBUNkp0JgDt8uBGWr55Rol6kYnxix5r/UwvU2gRCAl0TGwipyShqW+FmWyK/y/+R6
5mtdD8FgmrmuBVwTGc2DxZxWJQOcqhMCAwEAATANBgkqhkiG9w0BAQUFAAOBgQAnoiHMEdGvVa57
o+f+o6oknHsZDz8ipWG0vLzE+Pv3ordsVLKb2iG2o8DZAG7WuECirbXiLmZQ7cV+CqBiIqm82apZ
Aw2pnD1uTBxaakf4KRkOct/Dk8MDr/2RyOUUQcxOnW3GeJV2q6YiIiGqAPN1/7Qf9cYSSQQC7/uV
kFPf1g==
</ds:X509Certificate>
</ds:X509Data>
</ds:KeyInfo>
</ds:Signature>
</saml2:Assertion>
</ns3:RequestedSecurityToken>
<ns3:TokenType>http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV2.0</ns3:TokenType>
<ns3:RequestedAttachedReference>
<ns4:SecurityTokenReference>
<ns4:Reference URI="#SAML_4e367081-34ab-11e4-b48c-e062ecbc9f52" ValueType="http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV2.0" />
</ns4:SecurityTokenReference>
</ns3:RequestedAttachedReference>
<ns3:Lifetime>
<ns1:Created>2014-09-05T03:18:28.450Z</ns1:Created>
<ns1:Expires>2014-09-05T07:18:28.420Z</ns1:Expires>
</ns3:Lifetime>
</ns3:RequestSecurityTokenResponse>
我有2個問題:
1 - 什麼是提取SAML2的最佳方式:斷言節點到一個新的XML對象?
2 - 然後將此對象轉換爲字符串以顯示在我的頁面主體中的最佳方式是什麼?
謝謝。
我並不想這樣的作品,主要是因爲它迫使它的HTML,這使得一切小寫。另外,我需要嘗試並顯示原始XML,這只是顯示標籤的內容,而不是標籤本身。 – IanG 2014-09-05 06:12:26
查看更新後的帖子。謝謝 – guest271314 2014-09-05 06:40:13
謝謝,那釘了。 – IanG 2014-09-05 16:12:37