// Create a SAML Token with no "OneTimeUse" Condition
((BindingProvider)saml2Port).getRequestContext().put(
"ws-security.saml-callback-handler", new SamlCallbackHandler()
);
Client cxfClient = ClientProxy.getClient(saml2Port);
SecurityHeaderCacheInterceptor cacheInterceptor =
new SecurityHeaderCacheInterceptor();
cxfClient.getOutInterceptors().add(cacheInterceptor);
// Make two invocations...should succeed
saml2Port.doubleIt(25);
saml2Port.doubleIt(25);
// Now create a SAML Token with a "OneTimeUse" Condition
ConditionsBean conditions = new ConditionsBean();
conditions.setTokenPeriodMinutes(5);
conditions.setOneTimeUse(true);
SamlCallbackHandler callbackHandler = new SamlCallbackHandler();
callbackHandler.setConditions(conditions);
((BindingProvider)saml2Port).getRequestContext().put(
"ws-security.saml-callback-handler", callbackHandler
);
cxfClient.getOutInterceptors().remove(cacheInterceptor);
cacheInterceptor = new SecurityHeaderCacheInterceptor();
cxfClient.getOutInterceptors().add(cacheInterceptor);
// Make two invocations...should fail on the second one
saml2Port.doubleIt(25);
try {