1
我有一个如下所示的XML文件。使用JDOM获取XML元素
<samlp:AuthnRequest xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol"
Destination="https://hostname.example.com:4444/fed/idp/samlv20"
ID="id-OPIfhD3il2eK816THPlj2Nk38KM-"
IssueInstant="2014-09-02T14:36:02Z"
ProtocolBinding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"
Version="2.0"
>
<saml:Issuer xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"
Format="urn:oasis:names:tc:SAML:2.0:nameid-format:entity"
>https://federation.example.com/sp</saml:Issuer>
<samlp:NameIDPolicy AllowCreate="true"
Format="urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified"
/>
<samlp:RequestedAuthnContext Comparison="exact">
<saml:AuthnContextClassRef xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport</saml:AuthnContextClassRef>
</samlp:RequestedAuthnContext>
</samlp:AuthnRequest>
怎样才能使用JDOM上面的XML内容 “https://federation.example.com/sp”?
我正在尝试下面的代码,并能够成功地检索“IssueInstant”&“ProtocolBinding”。但无法检索内容“https://federation.example.com/sp”。请帮忙。
private String[] getRequestAttributes(String xmlString) throws SamlException {
Document doc = Util.createJdomDoc(xmlString);
if (doc != null) {
String[] samlRequestAttributes = new String[2];
samlRequestAttributes[0] = doc.getRootElement().getAttributeValue(
"IssueInstant");
samlRequestAttributes[2] = doc.getRootElement().getAttributeValue(
"ProtocolBinding");
return samlRequestAttributes;
}
}
你是我的救星。非常感谢这个明确的解释! – prasee 2014-09-05 09:10:38