throw new WSSecurityException(WSSecurityException.ErrorCode.INVALID_SECURITY, "invalidTimestamp",
"Message contains two or more timestamps");
}
wssecurityContextInbound.put(WSSConstants.TIMESTAMP_PROCESSED, Boolean.TRUE);
@SuppressWarnings("unchecked")
final TimestampType timestampType =
((JAXBElement<TimestampType>) parseStructure(eventQueue, index, securityProperties)).getValue();
final List<XMLSecEvent> xmlSecEvents = getResponsibleXMLSecEvents(eventQueue, index);
List<QName> elementPath = getElementPath(eventQueue);
checkBSPCompliance(inputProcessorChain, timestampType, xmlSecEvents);
if (timestampType.getId() == null) {
timestampType.setId(IDGenerator.generateID(null));
}
TimestampValidator timestampValidator = wssSecurityProperties.getValidator(WSSConstants.TAG_wsu_Timestamp);
if (timestampValidator == null) {
timestampValidator = new TimestampValidatorImpl();
}
TokenContext tokenContext = new TokenContext(wssSecurityProperties, wssecurityContextInbound, xmlSecEvents, elementPath);
timestampValidator.validate(timestampType, tokenContext);
TimestampSecurityEvent timestampSecurityEvent = new TimestampSecurityEvent();
if (timestampType.getCreated() != null) {
try {
timestampSecurityEvent.setCreated(
timestampType.getCreated().getAsXMLGregorianCalendar().toGregorianCalendar());
} catch (IllegalArgumentException e) { //NOPMD
//ignore
}
}
if (timestampType.getExpires() != null) {
try {
timestampSecurityEvent.setExpires(
timestampType.getExpires().getAsXMLGregorianCalendar().toGregorianCalendar());
} catch (IllegalArgumentException e) { //NOPMD
//ignore
}
}
timestampSecurityEvent.setCorrelationID(timestampType.getId());
wssecurityContextInbound.registerSecurityEvent(timestampSecurityEvent);
wssecurityContextInbound.put(WSSConstants.PROP_TIMESTAMP_SECURITYEVENT, timestampSecurityEvent);
}