context.timestampExported(true);
} else {
// Processing inbound messages
Timestamp timestamp = null;
if (context.getMode() == FilterProcessingContext.ADHOC) {
if (context.makeDynamicPolicyCallback()) {
TimestampPolicy policyClone = (TimestampPolicy)
((TimestampPolicy)context.getSecurityPolicy()).clone();
try {
DynamicApplicationContext dynamicContext =
new DynamicApplicationContext (context.getPolicyContext ());
dynamicContext.setMessageIdentifier (context.getMessageIdentifier ());
dynamicContext.inBoundMessage (true);
DynamicPolicyCallback callback =
new DynamicPolicyCallback (policyClone, dynamicContext);
ProcessingContext.copy (dynamicContext.getRuntimeProperties(), context.getExtraneousProperties());
HarnessUtil.makeDynamicPolicyCallback(callback,
context.getSecurityEnvironment().getCallbackHandler());
} catch (Exception e) {
log.log(Level.SEVERE, LogStringsMessages.WSS_1436_MESSAGE_DOESNOT_CONFORM_TIMESTAMP_POLICY(), e);
throw new XWSSecurityException (e);
}
context.setSecurityPolicy(policyClone);
}
TimestampPolicy policy = (TimestampPolicy) context.getSecurityPolicy();
long maxClockSkew = policy.getMaxClockSkew ();
long timeStampFreshness = policy.getTimestampFreshness ();
SecurityHeader secHeader = context.getSecurableSoapMessage().findSecurityHeader();
if (secHeader == null) {
log.log(Level.SEVERE, com.sun.xml.wss.logging.LogStringsMessages.WSS_0276_INVALID_POLICY_NO_TIMESTAMP_SEC_HEADER());
throw new XWSSecurityException(
"Message does not conform to Timestamp policy: " +
"wsu:Timestamp element not found in header");
}
SOAPElement ts = null;
try {
SOAPFactory factory = SOAPFactory.newInstance();
Name name = factory.createName(
MessageConstants.TIMESTAMP_LNAME,
MessageConstants.WSU_PREFIX,
MessageConstants.WSU_NS);
Iterator i = secHeader.getChildElements (name);
if (i.hasNext()) {
ts = (SOAPElement) i.next();
if (i.hasNext()) {
log.log(Level.SEVERE, com.sun.xml.wss.logging.LogStringsMessages.BSP_3227_SINGLE_TIMESTAMP());
throw new XWSSecurityException("More than one wsu:Timestamp element in the header");
}
} else {
log.log(Level.SEVERE, com.sun.xml.wss.logging.LogStringsMessages.WSS_0276_INVALID_POLICY_NO_TIMESTAMP_SEC_HEADER());
throw new XWSSecurityException(
"Message does not conform to Timestamp policy: " +
"wsu:Timestamp element not found in header");
}
} catch (SOAPException se) {
// log
throw new XWSSecurityRuntimeException (se);
}
try {
timestamp = new Timestamp (ts);
} catch (XWSSecurityException xwsse) {
log.log(Level.SEVERE, LogStringsMessages.WSS_1429_ERROR_TIMESTAMP_INTERNALIZATION(), xwsse);
throw SecurableSoapMessage.newSOAPFaultException(
MessageConstants.WSSE_INVALID_SECURITY,
"Failure in Timestamp internalization.\n" +