in ws-security-stax/src/main/java/org/apache/wss4j/stax/setup/ConfigurationConverter.java [164:290]
public static void parseCrypto(
Map<String, Object> config,
WSSSecurityProperties properties
) {
Object passwordEncryptorObj =
config.get(ConfigurationConstants.PASSWORD_ENCRYPTOR_INSTANCE);
PasswordEncryptor passwordEncryptor = null;
if (passwordEncryptorObj instanceof PasswordEncryptor) {
passwordEncryptor = (PasswordEncryptor)passwordEncryptorObj;
}
if (passwordEncryptor == null) {
CallbackHandler callbackHandler = properties.getCallbackHandler();
if (callbackHandler != null) {
passwordEncryptor = new JasyptPasswordEncryptor(callbackHandler);
}
}
String sigPropRef = getString(ConfigurationConstants.SIG_PROP_REF_ID, config);
boolean foundSigRef = false;
if (sigPropRef != null) {
Object sigRef = config.get(sigPropRef);
if (sigRef instanceof Crypto) {
foundSigRef = true;
properties.setSignatureCrypto((Crypto)sigRef);
} else if (sigRef instanceof Properties) {
foundSigRef = true;
properties.setSignatureCryptoProperties((Properties)sigRef, passwordEncryptor);
}
if (foundSigRef && properties.getSignatureUser() == null) {
properties.setSignatureUser(getDefaultX509Identifier(properties, true));
}
}
if (!foundSigRef) {
String sigPropFile = getString(ConfigurationConstants.SIG_PROP_FILE, config);
if (sigPropFile != null) {
try {
Properties sigProperties =
CryptoFactory.getProperties(sigPropFile, getClassLoader());
properties.setSignatureCryptoProperties(sigProperties, passwordEncryptor);
if (properties.getSignatureUser() == null) {
properties.setSignatureUser(getDefaultX509Identifier(properties, true));
}
} catch (WSSecurityException e) {
LOG.error(e.getMessage(), e);
}
}
}
String sigVerPropRef = getString(ConfigurationConstants.SIG_VER_PROP_REF_ID, config);
boolean foundSigVerRef = false;
if (sigVerPropRef != null) {
Object sigVerRef = config.get(sigVerPropRef);
if (sigVerRef instanceof Crypto) {
foundSigVerRef = true;
properties.setSignatureVerificationCrypto((Crypto)sigVerRef);
} else if (sigVerRef instanceof Properties) {
foundSigVerRef = true;
properties.setSignatureVerificationCryptoProperties((Properties)sigVerRef, passwordEncryptor);
}
}
if (!foundSigVerRef) {
String sigPropFile = getString(ConfigurationConstants.SIG_VER_PROP_FILE, config);
if (sigPropFile != null) {
try {
Properties sigProperties =
CryptoFactory.getProperties(sigPropFile, getClassLoader());
properties.setSignatureVerificationCryptoProperties(sigProperties, passwordEncryptor);
} catch (WSSecurityException e) {
LOG.error(e.getMessage(), e);
}
}
}
String encPropRef = getString(ConfigurationConstants.ENC_PROP_REF_ID, config);
boolean foundEncRef = false;
if (encPropRef != null) {
Object encRef = config.get(encPropRef);
if (encRef instanceof Crypto) {
foundEncRef = true;
properties.setEncryptionCrypto((Crypto)encRef);
} else if (encRef instanceof Properties) {
foundEncRef = true;
properties.setEncryptionCryptoProperties((Properties)encRef, passwordEncryptor);
}
}
if (!foundEncRef) {
String encPropFile = getString(ConfigurationConstants.ENC_PROP_FILE, config);
if (encPropFile != null) {
try {
Properties encProperties =
CryptoFactory.getProperties(encPropFile, getClassLoader());
properties.setEncryptionCryptoProperties(encProperties, passwordEncryptor);
} catch (WSSecurityException e) {
LOG.error(e.getMessage(), e);
}
}
}
String decPropRef = getString(ConfigurationConstants.DEC_PROP_REF_ID, config);
boolean foundDecRef = false;
if (decPropRef != null) {
Object decRef = config.get(decPropRef);
if (decRef instanceof Crypto) {
foundDecRef = true;
properties.setDecryptionCrypto((Crypto)decRef);
} else if (decRef instanceof Properties) {
foundDecRef = true;
properties.setDecryptionCryptoProperties((Properties)decRef, passwordEncryptor);
}
}
if (!foundDecRef) {
String encPropFile = getString(ConfigurationConstants.DEC_PROP_FILE, config);
if (encPropFile != null) {
try {
Properties encProperties =
CryptoFactory.getProperties(encPropFile, getClassLoader());
properties.setDecryptionCryptoProperties(encProperties, passwordEncryptor);
} catch (WSSecurityException e) {
LOG.error(e.getMessage(), e);
}
}
}
}