0
我使用OpenSAML 2.6.5作爲SAML2庫。 我還沒有找到有關如何編組表示來自服務提供者的AuthnRequest的字符串(XML文檔)的文檔。 任何人都可以幫助我嗎?將SAML2 AuthnRequest轉換爲Java類
我使用OpenSAML 2.6.5作爲SAML2庫。 我還沒有找到有關如何編組表示來自服務提供者的AuthnRequest的字符串(XML文檔)的文檔。 任何人都可以幫助我嗎?將SAML2 AuthnRequest轉換爲Java類
讀取來自SP的要求,你需要編碼解組輸入字符串,像這樣:
DefaultBootstrap.bootstrap(); //crucial in SAML2
byte[] decodedSamlAsBytes = Base64.decode(incomingEncodedSaml);
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = documentBuilderFactory.newDocumentBuilder();
Document document = docBuilder.parse(new ByteArrayInputStream(decodedSamlAsBytes));
Element element = document.getDocumentElement();
UnmarshallerFactory unmarshallerFactory = Configuration.getUnmarshallerFactory();
Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(element);
XMLObject requestXmlObj = unmarshaller.unmarshall(element);
AuthnRequest request = (AuthnRequest) requestXmlObj;