org.opensaml.xml.parse.BasicParserPool Java Examples

The following examples show how to use org.opensaml.xml.parse.BasicParserPool. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XMLConfigurator.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructor.
 * 
 * @param retainXML whether to retain the XML configuration elements within the {@link Configuration}.
 * 
 * @throws ConfigurationException thrown if the validation schema for configuration files can not be created
 * 
 * @deprecated this method will be removed once {@link Configuration} no longer has the option to store the XML configuration fragements
 */
public XMLConfigurator(boolean retainXML) throws ConfigurationException {
    retainXMLConfiguration = retainXML;
    parserPool = new BasicParserPool();
    SchemaFactory factory = SchemaFactory.newInstance(javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI);
    Source schemaSource = new StreamSource(XMLConfigurator.class
            .getResourceAsStream(XMLConstants.XMLTOOLING_SCHEMA_LOCATION));
    try {
        configurationSchema = factory.newSchema(schemaSource);

        parserPool.setIgnoreComments(true);
        parserPool.setIgnoreElementContentWhitespace(true);
        parserPool.setSchema(configurationSchema);
    } catch (SAXException e) {
        throw new ConfigurationException("Unable to read XMLTooling configuration schema", e);
    }
}
 
Example #2
Source File: Decrypter.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructor.
 * 
 * @param newResolver resolver for data encryption keys.
 * @param newKEKResolver resolver for key encryption keys.
 * @param newEncKeyResolver resolver for EncryptedKey elements
 */
public Decrypter(KeyInfoCredentialResolver newResolver, KeyInfoCredentialResolver newKEKResolver,
        EncryptedKeyResolver newEncKeyResolver) {
    resolver = newResolver;
    kekResolver = newKEKResolver;
    encKeyResolver = newEncKeyResolver;

    resolverCriteria = null;
    kekResolverCriteria = null;

    // Note: this is hopefully only temporary, until Xerces implements DOM 3 LSParser.parseWithContext().
    parserPool = new BasicParserPool();
    parserPool.setNamespaceAware(true);

    // Note: this is necessary due to an unresolved Xerces deferred DOM issue/bug
    HashMap<String, Boolean> features = new HashMap<String, Boolean>();
    features.put("http://apache.org/xml/features/dom/defer-node-expansion", Boolean.FALSE);
    parserPool.setBuilderFeatures(features);

    unmarshallerFactory = Configuration.getUnmarshallerFactory();
    
    defaultRootInNewDocument = false;
}
 
Example #3
Source File: MetadataDescriptorUtil.java    From MaxKey with Apache License 2.0 6 votes vote down vote up
public EntityDescriptor getEntityDescriptor(File file)
		throws Exception {
	try {
		FilesystemMetadataProvider filesystemMetadataProvider = new FilesystemMetadataProvider(
				file);
		filesystemMetadataProvider.setRequireValidMetadata(true); // Enable
		// validation
		filesystemMetadataProvider.setParserPool(new BasicParserPool());
		filesystemMetadataProvider.initialize();
		EntityDescriptor entityDescriptor = (EntityDescriptorImpl) filesystemMetadataProvider.getMetadata();
		return entityDescriptor;
	} catch (MetadataProviderException e) {
		logger.error("元数据解析出错", e);
		throw new Exception("元数据文件解析出错", e);
	}

}
 
Example #4
Source File: MetadataDescriptorUtil.java    From MaxKey with Apache License 2.0 6 votes vote down vote up
public EntityDescriptor getEntityDescriptor(Element elementMetadata)
		throws Exception {
	try {
		DOMMetadataProvider dOMMetadataProvider = new DOMMetadataProvider(elementMetadata);
		dOMMetadataProvider.setRequireValidMetadata(true); // Enable
															// validation
		dOMMetadataProvider.setParserPool(new BasicParserPool());
		dOMMetadataProvider.initialize();
		EntityDescriptor entityDescriptor = (EntityDescriptorImpl) dOMMetadataProvider.getMetadata();
		return entityDescriptor;
	} catch (MetadataProviderException e) {
		logger.error("元数据解析出错", e);
		throw new Exception("元数据解析出错", e);
	}

}
 
Example #5
Source File: SAMLClient.java    From saml-sdk-java with Apache License 2.0 6 votes vote down vote up
/**
 * 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);
}
 
Example #6
Source File: MetadataGenerator.java    From MaxKey with Apache License 2.0 5 votes vote down vote up
/** Constructor. */
public MetadataGenerator() {
	try {
		parser = new BasicParserPool();
		parser.setNamespaceAware(true);
		DefaultBootstrap.bootstrap();
		builderFactory = org.opensaml.xml.Configuration.getBuilderFactory();
		marshallerFactory = org.opensaml.xml.Configuration.getMarshallerFactory();
		unmarshallerFactory = org.opensaml.xml.Configuration.getUnmarshallerFactory();
	} catch (ConfigurationException e) {
		e.printStackTrace();
	}

}
 
Example #7
Source File: Saml20AutoConfiguration.java    From MaxKey with Apache License 2.0 5 votes vote down vote up
/**
 * OpenHTTPPostSimpleSignDecoder.
 * @return openHTTPPostSimpleSignDecoder
 */
@Bean(name = "openHTTPPostSimpleSignDecoder")
public OpenHTTPPostSimpleSignDecoder openHTTPPostSimpleSignDecoder(BasicParserPool samlParserPool,
        @Value("${config.saml.v20.idp.receiver.endpoint}") String receiverEndpoint) {
    OpenHTTPPostSimpleSignDecoder decoder = new OpenHTTPPostSimpleSignDecoder(samlParserPool);
    decoder.setReceiverEndpoint(receiverEndpoint);
    return decoder;
}
 
Example #8
Source File: Saml20AutoConfiguration.java    From MaxKey with Apache License 2.0 5 votes vote down vote up
/**
 * OpenHTTPPostDecoder.
 * @return openHTTPPostDecoder
 */
@Bean(name = "openHTTPPostDecoder")
public OpenHTTPPostDecoder openHTTPPostDecoder(BasicParserPool samlParserPool,
        @Value("${config.saml.v20.idp.receiver.endpoint}") String receiverEndpoint) {
    OpenHTTPPostDecoder decoder = new OpenHTTPPostDecoder(samlParserPool);
    decoder.setReceiverEndpoint(receiverEndpoint);
    return decoder;
}
 
Example #9
Source File: Saml20AutoConfiguration.java    From MaxKey with Apache License 2.0 5 votes vote down vote up
/**
 * OpenHTTPRedirectDecoder.
 * @return openHTTPRedirectDecoder
 */
@Bean(name = "openHTTPRedirectDecoder")
public OpenHTTPRedirectDecoder openHTTPRedirectDecoder(BasicParserPool samlParserPool,
        @Value("${config.saml.v20.idp.receiver.endpoint}") String receiverEndpoint) {
    OpenHTTPRedirectDecoder decoder = new OpenHTTPRedirectDecoder(samlParserPool);
    decoder.setReceiverEndpoint(receiverEndpoint);
    return decoder;
}
 
Example #10
Source File: BaseMessageDecoder.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/** Constructor. */
public BaseMessageDecoder() {
    parserPool = new BasicParserPool();
}