) throws WSSecurityException {
if (properties == null) {
if (LOG.isDebugEnabled()) {
LOG.debug("Cannot load Crypto instance as properties object is null");
}
throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE,
"empty", null, "Cannot load Crypto instance as properties object is null");
}
String cryptoClassName = properties.getProperty("org.apache.wss4j.crypto.provider");
if (cryptoClassName == null) {
cryptoClassName = properties.getProperty("org.apache.ws.security.crypto.provider");
}
Class<? extends Crypto> cryptoClass = null;
if (cryptoClassName == null
|| cryptoClassName.equals("org.apache.wss4j.common.crypto.Merlin")
|| cryptoClassName.equals("org.apache.ws.security.components.crypto.Merlin")) {
try {
return new Merlin(properties, classLoader, passwordEncryptor);
} catch (java.lang.Exception e) {
if (LOG.isDebugEnabled()) {
LOG.debug("Unable to instantiate Merlin", e);
}
throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE,
"empty", e, "Cannot create Crypto class "
+ cryptoClassName);
}
} else {
try {
// instruct the class loader to load the crypto implementation
cryptoClass = Loader.loadClass(cryptoClassName, Crypto.class);
} catch (ClassNotFoundException ex) {
if (LOG.isDebugEnabled()) {
LOG.debug(ex.getMessage(), ex);
}
throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE,
"empty", ex, cryptoClassName + " Not Found");
}
}
return loadClass(cryptoClass, properties, classLoader);
}