领域我有以下XML响应:如何检索XML响应
String response =
+"<saml:AuthnStatement AuthnInstant=\"2016-12-14T12:22:26Z\" SessionIndex=\"s2f1ae3bd7397f10c6fd6b3b3f02d8b0611b2da501\">"
+"<saml:AuthnContext>"
+"<saml:AuthnContextClassRef>urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport</saml:AuthnContextClassRef>"
+"</saml:AuthnContext>"
+"</saml:AuthnStatement>"
+"<saml:AttributeStatement>"
+"<saml:Attribute Name=\"uid\">"
+"<saml:AttributeValue xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"xs:string\">testing1</saml:AttributeValue>"
+"</saml:Attribute>"
+"<saml:Attribute Name=\"SecurityLevel\">"
+"<saml:AttributeValue xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"xs:string\">testing2</saml:AttributeValue>"
+"</saml:Attribute>"
+"<saml:Attribute Name=\"Culture\">"
+"<saml:AttributeValue xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"xs:string\">testing3</saml:AttributeValue>"
+"</saml:Attribute>"
+"<saml:Attribute Name=\"AuthMethod\">"
+"<saml:AttributeValue xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"xs:string\">testing4</saml:AttributeValue>"
+"</saml:Attribute>"
+"</saml:AttributeStatement>"
+"</saml:Assertion>";
使用普通字符串函数,子,长,我可以从领域retreive数据。但它是一个漫长而不便的过程。
我如何使用一些java库来处理这个响应,并从字段中获取信息?
您可以使用OpenSAML库来处理SAML消息。你可以在[这里]找到文档(https://wiki.shibboleth.net/confluence/display/OpenSAML/Home) – nille85