protected void configureProperties(SoapMessage msg) throws XMLSecurityException {
WSSSecurityProperties securityProperties = getSecurityProperties();
Map<String, Object> config = getProperties();
// Configure replay caching
ReplayCache nonceCache = null;
if (isNonceCacheRequired(msg)) {
nonceCache = WSS4JUtils.getReplayCache(
msg, SecurityConstants.ENABLE_NONCE_CACHE, SecurityConstants.NONCE_CACHE_INSTANCE
);
}
if (nonceCache == null) {
if (config != null) {
config.put(ConfigurationConstants.ENABLE_NONCE_CACHE, "false");
config.remove(ConfigurationConstants.NONCE_CACHE_INSTANCE);
} else {
securityProperties.setEnableNonceReplayCache(false);
securityProperties.setNonceReplayCache(null);
}
} else {
if (config != null) {
config.put(ConfigurationConstants.ENABLE_NONCE_CACHE, "true");
config.put(ConfigurationConstants.NONCE_CACHE_INSTANCE, nonceCache);
} else {
securityProperties.setEnableNonceReplayCache(true);
securityProperties.setNonceReplayCache(nonceCache);
}
}
ReplayCache timestampCache = null;
if (isTimestampCacheRequired(msg)) {
timestampCache = WSS4JUtils.getReplayCache(
msg, SecurityConstants.ENABLE_TIMESTAMP_CACHE, SecurityConstants.TIMESTAMP_CACHE_INSTANCE
);
}
if (timestampCache == null) {
if (config != null) {
config.put(ConfigurationConstants.ENABLE_TIMESTAMP_CACHE, "false");
config.remove(ConfigurationConstants.TIMESTAMP_CACHE_INSTANCE);
} else {
securityProperties.setEnableTimestampReplayCache(false);
securityProperties.setTimestampReplayCache(null);
}
} else {
if (config != null) {
config.put(ConfigurationConstants.ENABLE_TIMESTAMP_CACHE, "true");
config.put(ConfigurationConstants.TIMESTAMP_CACHE_INSTANCE, timestampCache);
} else {
securityProperties.setEnableTimestampReplayCache(true);
securityProperties.setTimestampReplayCache(timestampCache);
}
}
ReplayCache samlCache = null;
if (isSamlCacheRequired(msg)) {
samlCache = WSS4JUtils.getReplayCache(
msg, SecurityConstants.ENABLE_SAML_ONE_TIME_USE_CACHE,
SecurityConstants.SAML_ONE_TIME_USE_CACHE_INSTANCE
);