private XMLObject unmarshallObject(String xmlString) throws UnmarshallingException, XMLParserException, UnsupportedEncodingException { BasicParserPool parser = new BasicParserPool(); parser.setNamespaceAware(true); /* Base64URL encoded */ byte bytes[] = xmlString.getBytes("utf-8"); if (bytes == null || bytes.length == 0) throw new InsufficientAuthenticationException("Invalid assertion encoding"); Reader reader = new InputStreamReader(new ByteArrayInputStream(bytes)); Document doc = parser.parse(reader); Element samlElement = doc.getDocumentElement(); UnmarshallerFactory unmarshallerFactory = Configuration.getUnmarshallerFactory(); Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(samlElement); if (unmarshaller == null) { throw new InsufficientAuthenticationException("Unsuccessful to unmarshal assertion string"); } return unmarshaller.unmarshall(samlElement); }
/** {@inheritDoc} */ public synchronized void setSchema(Schema newSchema) { schema = newSchema; if (schema != null) { setNamespaceAware(true); builderAttributes.remove("http://java.sun.com/xml/jaxp/properties/schemaSource"); builderAttributes.remove("http://java.sun.com/xml/jaxp/properties/schemaLanguage"); } dirtyBuilderConfiguration = true; }
/** {@inheritDoc} */ public synchronized void setSchema(Schema newSchema) { schema = newSchema; if (schema != null) { setNamespaceAware(true); builderAttributes.remove("http://java.sun.com/xml/jaxp/properties/schemaSource"); builderAttributes.remove("http://java.sun.com/xml/jaxp/properties/schemaLanguage"); } dirtyBuilderConfiguration = true; }
// 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!"); }
String inCommonMDFile = "/data/org/opensaml/saml2/metadata/InCommon-metadata.xml"; // Initialize the library DefaultBootstrap.bootstrap(); // Get parser pool manager BasicParserPool ppMgr = new BasicParserPool(); ppMgr.setNamespaceAware(true); // Parse metadata file InputStream in = MetadataTest.class.getResourceAsStream(inCommonMDFile); Document inCommonMDDoc = ppMgr.parse(in); Element metadataRoot = inCommonMDDoc.getDocumentElement(); // Get apropriate unmarshaller UnmarshallerFactory unmarshallerFactory = Configuration.getUnmarshallerFactory(); Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(metadataRoot); // Unmarshall using the document root element, an EntitiesDescriptor in this case EntitiesDescriptor inCommonMD = (EntitiesDescriptor) unmarshaller.unmarshall(metadataRoot);
parserPool.setNamespaceAware(true);
/** * Create a new SAMLClient, using the IdPConfig for * endpoints and validation. */ public SAMLClient(SPConfig spConfig, IdPConfig idpConfig) throws SAMLException { this.spConfig = spConfig; this.idpConfig = idpConfig; BasicCredential cred = new BasicCredential(); cred.setEntityId(idpConfig.getEntityId()); cred.setPublicKey(idpConfig.getCert().getPublicKey()); sigValidator = new SignatureValidator(cred); // create xml parsers parsers = new BasicParserPool(); parsers.setNamespaceAware(true); }
_pool.setNamespaceAware(true);
/** * Create a new SAMLClient, using the IdPConfig for endpoints and * validation. * * @param config * @throws org.adeptnet.auth.saml.SAMLException */ public SAMLClient(final SAMLConfig config) throws SAMLException { SAMLInit.initialize(); this.config = config; final BasicCredential _cred = new BasicCredential(); _cred.setEntityId(config.getIdPConfig().getEntityId()); _cred.setPublicKey(config.getIdPConfig().getCert().getPublicKey()); cred = _cred; sigValidator = new SignatureValidator(cred); // create xml parsers parsers = new BasicParserPool(); parsers.setNamespaceAware(true); }
parsers.setNamespaceAware(true);
parsers.setNamespaceAware(true);
parsers.setNamespaceAware(true);
parsers.setNamespaceAware(true);