2016-10-31 10 views

答えて

1

OpenSAML2公式ドキュメント(doc1 & doc2)によると、あなたはOpenSAMLとSAML XML応答を検証するために以下のコードを使用しようとすることができます。要素SAMLPの宣言を見つけることができません:

// Initialize the library 
DefaultBootstrap.bootstrap(); 

// Get parser pool manager 
BasicParserPool ppMgr = new BasicParserPool(); 
ppMgr.setNamespaceAware(true); 

// Get org.w3c.dom.Document Object from response 
HttpURLConnection req = (HttpURLConnection) new URL("<saml-xml-url>").openConnection(); 
// Add some necessary headers for the request 
// req.addRequestProperty("...", "..."); 
// ... 
InputStream in = req.getInputStream(); 
Document inCommonMDDoc = ppMgr.parse(in); 

// Get the DOMSource from org.w3c.dom.Document Object 
DOMSource domSource=new DOMSource(document); 

//Add an extension schema via the code SAMLSchemaBuilder.addExtensionSchema(String schema) if necessary 
Schema schema = SAMLSchemaBuilder.getSAML11Schema(); 

// Get a Validator instance. 
Validator validator = schema.newValidator(); 
try { 
    validator.validate(domSource); 
    System.out.println("Result : Valid!"); 
} catch(Exception e) { 
    System.out.println("Result : Invalid!"); 
} 
+0

は妙に私は 'CVC-elt.1を取得し、それを試してみましたレスポンス...' – Gobliins

+0

1:Response'が、XMLの最初の要素は、実際には ' Gobliins

+0

@ゴブリンズ、クラス[SAMLSchemaBuilder#getSAML11Schema](http://www.atetric.com/atetric/javadoc/org.opensaml/opensaml/2.6.1/org/opensaml/common/xml/SAMLSchemaBuilder)のjavadocによると、 html#getSAML11Schema--)、SAML2を検証するための 'SAML11'スキーマがサポートされています。 –

関連する問題