/** * getInstance * <p/> * Returns an instance of Crypto. The supplied map is handed over the the crypto * implementation. The map can be <code>null</code>. It is dependent on the * Crypto implementation how the initialization is done in this case. * <p/> * * @param cryptoClass This is the crypto implementation class. No default is * provided here. * @param map The Maps that is forwarded to the crypto implementation. * These contents of the map are dependent on the * underlying crypto implementation specified in the * cryptoClassName parameter. * @return The crypto implementation or null if no cryptoClassName was defined * @throws WSSecurityException if there is an error in loading the crypto properties */ public static Crypto getInstance( Class<? extends Crypto> cryptoClass, Map<Object, Object> map ) throws WSSecurityException { return loadClass(cryptoClass, map, Loader.getClassLoader(CryptoFactory.class)); }
/** * getInstance * <p/> * Returns an instance of Crypto. The properties are handed over the the crypto * implementation. The properties must at least contain the Crypto implementation * class name as the value of the property : org.apache.wss4j.crypto.provider * <p/> * * @param properties The Properties that are forwarded to the crypto implementation * and the Crypto impl class name. * These properties are dependent on the crypto implementation * @return The cyrpto implementation or null if no cryptoClassName was defined * @throws WSSecurityException if there is an error in loading the crypto properties */ public static Crypto getInstance(Properties properties) throws WSSecurityException { if (properties == null) { LOG.debug("Cannot load Crypto instance as properties object is null"); throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "empty", new Object[] {"Cannot load Crypto instance as properties object is null"}); } return getInstance(properties, Loader.getClassLoader(CryptoFactory.class), null); }
public static Crypto getInstance( String propFilename, ClassLoader customClassLoader ) throws WSSecurityException { Properties properties = getProperties(propFilename, customClassLoader); return getInstance(properties, customClassLoader, null); }
if (obj instanceof Properties) { crypto = CryptoFactory.getInstance((Properties)obj, Loader.getClassLoader(CryptoFactory.class), getPasswordEncryptor(requestData)); cryptos.put(refId, crypto);
public static Crypto getEncryptionCrypto( Object e, SoapMessage message, PasswordEncryptor passwordEncryptor ) throws WSSecurityException { Crypto encrCrypto = null; if (e instanceof Crypto) { encrCrypto = (Crypto)e; } else if (e != null) { URL propsURL = SecurityUtils.loadResource(message, e); Properties props = WSS4JUtils.getProps(e, propsURL); if (props == null) { LOG.fine("Cannot find Crypto Encryption properties: " + e); Exception ex = new Exception("Cannot find Crypto Encryption properties: " + e); throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, ex); } encrCrypto = CryptoFactory.getInstance(props, Loader.getClassLoader(CryptoFactory.class), passwordEncryptor); EndpointInfo info = message.getExchange().getEndpoint().getEndpointInfo(); synchronized (info) { info.setProperty(SecurityConstants.ENCRYPT_CRYPTO, encrCrypto); } } return encrCrypto; }
protected Crypto getCrypto( String cryptoKey, String propKey ) throws WSSecurityException { Crypto crypto = (Crypto)SecurityUtils.getSecurityPropertyValue(cryptoKey, message); if (crypto != null) { return crypto; } Object o = SecurityUtils.getSecurityPropertyValue(propKey, message); if (o == null) { return null; } crypto = getCryptoCache().get(o); if (crypto != null) { return crypto; } URL propsURL = SecurityUtils.loadResource(message, o); Properties properties = WSS4JUtils.getProps(o, propsURL); if (properties != null) { crypto = CryptoFactory.getInstance(properties, Loader.getClassLoader(CryptoFactory.class), WSS4JUtils.getPasswordEncryptor(message)); getCryptoCache().put(o, crypto); } return crypto; }
public static Crypto getEncryptionCrypto( Object e, SoapMessage message, PasswordEncryptor passwordEncryptor ) throws WSSecurityException { Crypto encrCrypto = null; if (e instanceof Crypto) { encrCrypto = (Crypto)e; } else if (e != null) { URL propsURL = SecurityUtils.loadResource(message, e); Properties props = WSS4JUtils.getProps(e, propsURL); if (props == null) { LOG.fine("Cannot find Crypto Encryption properties: " + e); Exception ex = new Exception("Cannot find Crypto Encryption properties: " + e); throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, ex); } encrCrypto = CryptoFactory.getInstance(props, Loader.getClassLoader(CryptoFactory.class), passwordEncryptor); EndpointInfo info = message.getExchange().getEndpoint().getEndpointInfo(); synchronized (info) { info.setProperty(SecurityConstants.ENCRYPT_CRYPTO, encrCrypto); } } return encrCrypto; }
public static Crypto getSignatureCrypto( Object s, SoapMessage message, PasswordEncryptor passwordEncryptor ) throws WSSecurityException { Crypto signCrypto = null; if (s instanceof Crypto) { signCrypto = (Crypto)s; } else if (s != null) { URL propsURL = SecurityUtils.loadResource(message, s); Properties props = WSS4JUtils.getProps(s, propsURL); if (props == null) { LOG.fine("Cannot find Crypto Signature properties: " + s); Exception ex = new Exception("Cannot find Crypto Signature properties: " + s); throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, ex); } signCrypto = CryptoFactory.getInstance(props, Loader.getClassLoader(CryptoFactory.class), passwordEncryptor); EndpointInfo info = message.getExchange().getEndpoint().getEndpointInfo(); synchronized (info) { info.setProperty(SecurityConstants.SIGNATURE_CRYPTO, signCrypto); } } return signCrypto; }
protected Crypto getCrypto( String cryptoKey, String propKey ) throws WSSecurityException { Crypto crypto = (Crypto)SecurityUtils.getSecurityPropertyValue(cryptoKey, message); if (crypto != null) { return crypto; } Object o = SecurityUtils.getSecurityPropertyValue(propKey, message); if (o == null) { return null; } crypto = getCryptoCache().get(o); if (crypto != null) { return crypto; } URL propsURL = SecurityUtils.loadResource(message, o); Properties properties = WSS4JUtils.getProps(o, propsURL); if (properties != null) { crypto = CryptoFactory.getInstance(properties, Loader.getClassLoader(CryptoFactory.class), WSS4JUtils.getPasswordEncryptor(message)); getCryptoCache().put(o, crypto); } return crypto; }
public static Crypto getSignatureCrypto( Object s, SoapMessage message, PasswordEncryptor passwordEncryptor ) throws WSSecurityException { Crypto signCrypto = null; if (s instanceof Crypto) { signCrypto = (Crypto)s; } else if (s != null) { URL propsURL = SecurityUtils.loadResource(message, s); Properties props = WSS4JUtils.getProps(s, propsURL); if (props == null) { LOG.fine("Cannot find Crypto Signature properties: " + s); Exception ex = new Exception("Cannot find Crypto Signature properties: " + s); throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, ex); } signCrypto = CryptoFactory.getInstance(props, Loader.getClassLoader(CryptoFactory.class), passwordEncryptor); EndpointInfo info = message.getExchange().getEndpoint().getEndpointInfo(); synchronized (info) { info.setProperty(SecurityConstants.SIGNATURE_CRYPTO, signCrypto); } } return signCrypto; }
cryptoClass.getConstructor(Properties.class, ClassLoader.class, PasswordEncryptor.class); crypto = (Merlin)ctor.newInstance(cryptoProperties, Loader.getClassLoader(CryptoFactory.class), passwordEncryptor); keyStore = crypto.getKeyStore();