}
}
} else if (WSConstants.UT == actInt.intValue()) {
WSUsernameTokenPrincipal userNameTokenPrincipal = (WSUsernameTokenPrincipal) wser
.get(WSSecurityEngineResult.TAG_PRINCIPAL);
String username = userNameTokenPrincipal.getName();
msgCtx.setProperty(RampartMessageData.USERNAME, username);
if (userNameTokenPrincipal.getNonce() != null) {
// Check whether this is a replay attack. To verify that we need to check
// whether nonce value
// is a repeating one
int nonceLifeTimeInSeconds = 0;
if (rpd.getRampartConfig() != null) {
String stringLifeTime = rpd.getRampartConfig().getNonceLifeTime();
try {
nonceLifeTimeInSeconds = Integer.parseInt(stringLifeTime);
} catch (NumberFormatException e) {
log.error(
"Invalid value for nonceLifeTime in rampart configuration file.",
e);
throw new RampartException("invalidNonceLifeTime", e);
}
}
String serviceEndpointName = msgCtx.getAxisService().getEndpointName();
boolean valueRepeating = serviceNonceCache.isNonceRepeatingForService(
serviceEndpointName, username, userNameTokenPrincipal.getNonce());
if (valueRepeating) {
throw new RampartException("repeatingNonceValue", new Object[] {
userNameTokenPrincipal.getNonce(), username });
}
serviceNonceCache.addNonceForService(serviceEndpointName, username,
userNameTokenPrincipal.getNonce(), nonceLifeTimeInSeconds);
}
} else if (WSConstants.SIGN == actInt.intValue()) {
X509Certificate cert = (X509Certificate) wser
.get(WSSecurityEngineResult.TAG_X509_CERTIFICATE);
msgCtx.setProperty(RampartMessageData.X509_CERT, cert);