private Map<String, SecurityContextTokenInfo> securityContextTokenMap
= new HashMap<String, SecurityContextTokenInfo>();
private boolean tokenExpired = false;
public void issue(IssuedTokenContext ctx)throws WSTrustException{
SCTokenConfiguration sctConfig = (SCTokenConfiguration)ctx.getSecurityPolicy().get(0);
if(issuedTokenContextMap.get(sctConfig.getTokenId()) != null ){
IssuedTokenContext tmpCtx = null;
try{
tmpCtx = getSecurityContextToken(sctConfig.getTokenId(), sctConfig.checkTokenExpiry());
}catch(WSSecureConversationException ex){
if(sctConfig.isClientOutboundMessage()){
if(log.isLoggable(Level.FINE)){
log.log(Level.FINE, "SecureConversationToken expired");
}
tokenExpired = true;
renew(ctx);
tokenExpired = false;
tmpCtx = issuedTokenContextMap.get(sctConfig.getTokenId());
}else{
throw new WSSecureConversationException(ex);
}
}
if(tmpCtx != null){
ctx.setCreationTime(tmpCtx.getCreationTime());
ctx.setExpirationTime(tmpCtx.getExpirationTime());
ctx.setProofKey(tmpCtx.getProofKey());
ctx.setSecurityToken(tmpCtx.getSecurityToken());
ctx.setAttachedSecurityTokenReference(tmpCtx.getAttachedSecurityTokenReference());
ctx.setUnAttachedSecurityTokenReference(tmpCtx.getUnAttachedSecurityTokenReference());
if(tmpCtx.getSecurityToken() != null &&
((SecurityContextToken)tmpCtx.getSecurityToken()).getInstance() != null){
String sctInfoKey = ((SecurityContextToken)tmpCtx.getSecurityToken()).getIdentifier().toString()+"_"+
((SecurityContextToken)tmpCtx.getSecurityToken()).getInstance();
ctx.setSecurityContextTokenInfo(getSecurityContextTokenInfo(sctInfoKey));
}
}else{
throw new WSTrustException("IssuedTokenContext for Token id "+sctConfig.getTokenId() +" not found in the client cache.");
}
}else if(!sctConfig.isClientOutboundMessage()){
ctx.getSecurityPolicy().clear();
}else{
scp.process(ctx);
String sctId = ((SecurityContextToken)ctx.getSecurityToken()).getIdentifier().toString();
sctConfig = new DefaultSCTokenConfiguration((DefaultSCTokenConfiguration)sctConfig, sctId);