All Downloads are FREE. Search and download functionalities are using the official Maven repository.

br.com.esec.icpm.signer.security.CryptoProvider Maven / Gradle / Ivy

The newest version!
package br.com.esec.icpm.signer.security;

import java.io.IOException;
import java.util.Properties;

import org.apache.ws.security.components.crypto.CredentialException;
import org.apache.ws.security.components.crypto.Merlin;
import org.apache.ws.security.util.Loader;

public class CryptoProvider extends Merlin {
	
	public CryptoProvider() {}

	/**
	 * @see Merlin#Merlin(Properties)
	 * @param properties
	 * @throws CredentialException
	 * @throws IOException
	 */
	public CryptoProvider(Properties properties) throws CredentialException, IOException {
		super(overrideProperties(properties), Loader.getClassLoader(CryptoProvider.class));
	}

	/**
	 * @see Merlin#Merlin(Properties, ClassLoader)
	 * @param properties
	 * @param loader
	 * @throws CredentialException
	 * @throws IOException
	 */
	public CryptoProvider(Properties properties, ClassLoader loader) throws CredentialException, IOException {
		super(overrideProperties(properties), loader);
	}

	/**
	 * Write the password in the properties after loaded, so we don't need to save it to disk.
	 * 
	 * @param src
	 * @return
	 * @throws IOException
	 */
	private static Properties overrideProperties(Properties src) throws IOException {
		Properties over = SecurityConfig.getConfig();
		for (String p : over.stringPropertyNames()) {
			src.setProperty(p, over.getProperty(p));
		}
		return src;
	}
	
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy