Java Code Examples for org.apache.xml.security.Init

The following examples show how to use org.apache.xml.security.Init. These examples are extracted from open source projects. 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
public void init(Configuration config) throws TechnicalConnectorException {
   LOG.debug("Initializing ConfigurationModule " + this.getClass().getName());
   if (!Init.isInitialized()) {
      LOG.info("Initializing xmlsec");
      Init.init();
      LOG.info("Setting jsr105Provider with value [org.apache.jcp.xml.dsig.internal.dom.XMLDSigRI]");
      this.oldValues.put("jsr105Provider", System.getProperty("jsr105Provider"));
      System.setProperty("jsr105Provider", "org.apache.jcp.xml.dsig.internal.dom.XMLDSigRI");
   }

}
 
Example 2
public void init(Configuration config) throws TechnicalConnectorException {
   LOG.debug("Initializing ConfigurationModule " + this.getClass().getName());
   if (!Init.isInitialized()) {
      LOG.info("Initializing xmlsec");
      Init.init();
      LOG.info("Setting jsr105Provider with value [org.apache.jcp.xml.dsig.internal.dom.XMLDSigRI]");
      this.oldValues.put("jsr105Provider", System.getProperty("jsr105Provider"));
      System.setProperty("jsr105Provider", "org.apache.jcp.xml.dsig.internal.dom.XMLDSigRI");
   }

}
 
Example 3
public void init(Configuration config) throws TechnicalConnectorException {
   LOG.debug("Initializing ConfigurationModule " + this.getClass().getName());
   if (!Init.isInitialized()) {
      LOG.info("Initializing xmlsec");
      Init.init();
      LOG.info("Setting jsr105Provider with value [org.apache.jcp.xml.dsig.internal.dom.XMLDSigRI]");
      this.oldValues.put("jsr105Provider", System.getProperty("jsr105Provider"));
      System.setProperty("jsr105Provider", "org.apache.jcp.xml.dsig.internal.dom.XMLDSigRI");
   }

}
 
Example 4
public void init(Configuration config) throws TechnicalConnectorException {
   LOG.debug("Initializing ConfigurationModule " + this.getClass().getName());
   if (!Init.isInitialized()) {
      LOG.info("Initializing xmlsec");
      Init.init();
      LOG.info("Setting jsr105Provider with value [org.apache.jcp.xml.dsig.internal.dom.XMLDSigRI]");
      this.oldValues.put("jsr105Provider", System.getProperty("jsr105Provider"));
      System.setProperty("jsr105Provider", "org.apache.jcp.xml.dsig.internal.dom.XMLDSigRI");
   }

}
 
Example 5
public void init(Configuration config) throws TechnicalConnectorException {
   LOG.debug("Initializing ConfigurationModule " + this.getClass().getName());
   if (!Init.isInitialized()) {
      LOG.info("Initializing xmlsec");
      Init.init();
      LOG.info("Setting jsr105Provider with value [org.apache.jcp.xml.dsig.internal.dom.XMLDSigRI]");
      this.oldValues.put("jsr105Provider", System.getProperty("jsr105Provider"));
      System.setProperty("jsr105Provider", "org.apache.jcp.xml.dsig.internal.dom.XMLDSigRI");
   }

}
 
Example 6
Source Project: lams   Source File: SignatureUnmarshaller.java    License: GNU General Public License v2.0 5 votes vote down vote up
/** Constructor. */
public SignatureUnmarshaller() {
    if (!Init.isInitialized()) {
        log.debug("Initializing XML security library");
        Init.init();
    }
}
 
Example 7
Source Project: lams   Source File: SignatureMarshaller.java    License: GNU General Public License v2.0 5 votes vote down vote up
/** Constructor. */
public SignatureMarshaller() {
    if (!Init.isInitialized()) {
        log.debug("Initializing XML security library");
        Init.init();
    }
}
 
Example 8
Source Project: lams   Source File: DefaultBootstrap.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Initializes the Apache XMLSecurity libary.
 * 
 * @throws ConfigurationException thrown is there is a problem initializing the library
 */
protected static void initializeXMLSecurity() throws ConfigurationException {
    Logger log = getLogger();
    String lineBreakPropName = "org.apache.xml.security.ignoreLineBreaks";
    // Don't override if it was set explicitly
    if (System.getProperty(lineBreakPropName) == null) {
        System.setProperty(lineBreakPropName, "true");
    }
    if (!Init.isInitialized()) {
        log.debug("Initializing Apache XMLSecurity library");
        Init.init();
    }
}
 
Example 9
private void configureSystemProperties() {
    Init.init();

    final boolean crlDownloadEnabled = Boolean.getBoolean("com.sun.security.enableCRLDP");
    final boolean checkRevocationEnabled = Boolean.getBoolean("com.sun.net.ssl.checkRevocation");
    final String value = Security.getProperty("com.sun.security.onlyCheckRevocationOfEECert");
    final boolean onlyCheckRevocationOfEECert = (value != null) && value.equalsIgnoreCase("true");

    if (!crlDownloadEnabled || !checkRevocationEnabled || !onlyCheckRevocationOfEECert) {
        logger.info("System properties will be configured to enable certificate revocation checks.");
        System.setProperty("com.sun.security.enableCRLDP", "true");
        System.setProperty("com.sun.net.ssl.checkRevocation", "true");
        Security.setProperty("com.sun.security.onlyCheckRevocationOfEECert", "true"); // verify only revocation of the last cert in path (the EET cert)
    }
}
 
Example 10
Source Project: SAMLRaider   Source File: XMLHelpers.java    License: MIT License 5 votes vote down vote up
/**
 * Sign assertions in SAML message
 *
 * @param document
 *            Document in assertions should be signed
 * @param signAlgorithm
 *            Signature algorithm in uri form, default if an unknown
 *            algorithm is provided:
 *            http://www.w3.org/2001/04/xmldsig-more#rsa-sha256
 * @param digestAlgorithm
 *            Digest algorithm in uri form, default if an unknown algorithm
 *            is provided: http://www.w3.org/2001/04/xmlenc#sha256
 */
public void signAssertion(Document document, String signAlgorithm, String digestAlgorithm, X509Certificate cert, PrivateKey key)
		throws CertificateException, FileNotFoundException, NoSuchAlgorithmException, InvalidKeySpecException,
		MarshalException, XMLSignatureException, IOException {
	try {
		if(Thread.currentThread().getContextClassLoader() == null){
			Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); 
		}
		setIDAttribute(document);
		XPath xpath = XPathFactory.newInstance().newXPath();
		XPathExpression expr = xpath.compile("//*[local-name()='Assertion']/@ID");
		NodeList nlURIs = (NodeList) expr.evaluate(document, XPathConstants.NODESET);

		String[] sigIDs = new String[nlURIs.getLength()];

		for (int i = 0; i < nlURIs.getLength(); i++) {
			sigIDs[i] = nlURIs.item(i).getNodeValue();
		}

		Init.init();
		for (String id : sigIDs) {
			signElement(document, id, cert, key, signAlgorithm, digestAlgorithm);
		}
	} catch (XPathExpressionException e) {
		e.printStackTrace();
	}
}
 
Example 11
Source Project: SAMLRaider   Source File: XMLHelpers.java    License: MIT License 5 votes vote down vote up
/**
 * Sign whole SAML Message
 *
 * @param document
 *            Document with the response to sign
 * @param signAlgorithm
 *            Signature algorithm in uri form, default if an unknown
 *            algorithm is provided:
 *            http://www.w3.org/2001/04/xmldsig-more#rsa-sha256
 * @param digestAlgorithm
 *            Digest algorithm in uri form, default if an unknown algorithm
 *            is provided: http://www.w3.org/2001/04/xmlenc#sha256
 */
public void signMessage(Document document, String signAlgorithm, String digestAlgorithm, X509Certificate cert, PrivateKey key)
		throws CertificateException, FileNotFoundException, NoSuchAlgorithmException, InvalidKeySpecException,
		MarshalException, XMLSignatureException, IOException {
	try {
		if(Thread.currentThread().getContextClassLoader() == null){
			Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); 
		}
		setIDAttribute(document);
		XPath xpath = XPathFactory.newInstance().newXPath();
		XPathExpression expr = xpath.compile("//*[local-name()='Response']/@ID");
		NodeList nlURIs = (NodeList) expr.evaluate(document, XPathConstants.NODESET);

		String[] sigIDs = new String[nlURIs.getLength()];

		for (int i = 0; i < nlURIs.getLength(); i++) {
			sigIDs[i] = nlURIs.item(i).getNodeValue();
		}

		Init.init();
		for (String id : sigIDs) {
			signElement(document, id, cert, key, signAlgorithm, digestAlgorithm);
		}
	} catch (XPathExpressionException e) {
		e.printStackTrace();
	}
}
 
Example 12
/**
 * Method isInitialized
 * 
 * @return true if the library is already initialized.
 */
public static final synchronized boolean isInitialized() {
	if (Init.isInitialized()) {
		LOG.info("Santuario is already initialized with its default configuration");
		return true;
	}
	return SantuarioInitializer.alreadyInitialized;
}