Search in sources :

Example 1 with ConcreteLSInput

use of org.apache.xml.security.stax.impl.util.ConcreteLSInput in project santuario-java by apache.

the class XMLSecurityUtils method loadXMLSecuritySchemas.

public static Schema loadXMLSecuritySchemas() throws SAXException {
    SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
    schemaFactory.setResourceResolver(new LSResourceResolver() {

        @Override
        public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) {
            if ("http://www.w3.org/2001/XMLSchema.dtd".equals(systemId)) {
                ConcreteLSInput concreteLSInput = new ConcreteLSInput();
                concreteLSInput.setByteStream(ClassLoaderUtils.getResourceAsStream("bindings/schemas/XMLSchema.dtd", XMLSecurityConstants.class));
                return concreteLSInput;
            } else if ("XMLSchema.dtd".equals(systemId)) {
                ConcreteLSInput concreteLSInput = new ConcreteLSInput();
                concreteLSInput.setByteStream(ClassLoaderUtils.getResourceAsStream("bindings/schemas/XMLSchema.dtd", XMLSecurityConstants.class));
                return concreteLSInput;
            } else if ("datatypes.dtd".equals(systemId)) {
                ConcreteLSInput concreteLSInput = new ConcreteLSInput();
                concreteLSInput.setByteStream(ClassLoaderUtils.getResourceAsStream("bindings/schemas/datatypes.dtd", XMLSecurityConstants.class));
                return concreteLSInput;
            } else if ("http://www.w3.org/TR/2002/REC-xmldsig-core-20020212/xmldsig-core-schema.xsd".equals(systemId)) {
                ConcreteLSInput concreteLSInput = new ConcreteLSInput();
                concreteLSInput.setByteStream(ClassLoaderUtils.getResourceAsStream("bindings/schemas/xmldsig-core-schema.xsd", XMLSecurityConstants.class));
                return concreteLSInput;
            } else if ("http://www.w3.org/2001/xml.xsd".equals(systemId)) {
                ConcreteLSInput concreteLSInput = new ConcreteLSInput();
                concreteLSInput.setByteStream(ClassLoaderUtils.getResourceAsStream("bindings/schemas/xml.xsd", XMLSecurityConstants.class));
                return concreteLSInput;
            }
            return null;
        }
    });
    Schema schema = schemaFactory.newSchema(new Source[] { new StreamSource(ClassLoaderUtils.getResourceAsStream("bindings/schemas/exc-c14n.xsd", XMLSecurityConstants.class)), new StreamSource(ClassLoaderUtils.getResourceAsStream("bindings/schemas/xmldsig-core-schema.xsd", XMLSecurityConstants.class)), new StreamSource(ClassLoaderUtils.getResourceAsStream("bindings/schemas/xenc-schema.xsd", XMLSecurityConstants.class)), new StreamSource(ClassLoaderUtils.getResourceAsStream("bindings/schemas/xenc-schema-11.xsd", XMLSecurityConstants.class)), new StreamSource(ClassLoaderUtils.getResourceAsStream("bindings/schemas/xmldsig11-schema.xsd", XMLSecurityConstants.class)) });
    return schema;
}
Also used : SchemaFactory(javax.xml.validation.SchemaFactory) LSResourceResolver(org.w3c.dom.ls.LSResourceResolver) ConcreteLSInput(org.apache.xml.security.stax.impl.util.ConcreteLSInput) LSInput(org.w3c.dom.ls.LSInput) Schema(javax.xml.validation.Schema) StreamSource(javax.xml.transform.stream.StreamSource) ConcreteLSInput(org.apache.xml.security.stax.impl.util.ConcreteLSInput)

Aggregations

StreamSource (javax.xml.transform.stream.StreamSource)1 Schema (javax.xml.validation.Schema)1 SchemaFactory (javax.xml.validation.SchemaFactory)1 ConcreteLSInput (org.apache.xml.security.stax.impl.util.ConcreteLSInput)1 LSInput (org.w3c.dom.ls.LSInput)1 LSResourceResolver (org.w3c.dom.ls.LSResourceResolver)1