}
private BaseSTSResponse createRenewResponse(final RenewTarget renewTgt, final Entropy serverEntropy, final URI con, final byte[] secret, final RequestedProofToken proofToken, final IssuedTokenContext context, final URI tokenType) throws WSSecureConversationException {
final SecurityTokenReference str = renewTgt.getSecurityTokenReference();
final SessionManager sm = (SessionManager)context.getOtherProperties().get("SessionManager");
String id = null;
final Reference ref = str.getReference();
if (ref.getType().equals("Reference")){
id = ((DirectReference)ref).getURIAttr().toString();
}
final SecurityContextToken token = WSTrustUtil.createSecurityContextToken(wsscEleFac, id);
final RequestedSecurityToken rst = wsscEleFac.createRequestedSecurityToken(token);
final SecurityTokenReference attachedReference = createSecurityTokenReferenceForRenew(token.getWsuId(),false, token.getInstance());
final RequestedAttachedReference rar = wsscEleFac.createRequestedAttachedReference(attachedReference);
final IssuedTokenContext ctx = sm.getSecurityContext(id, false);
if (ctx == null || ctx.getSecurityToken() == null){
log.log(Level.SEVERE,
LogStringsMessages.WSSC_0015_UNKNOWN_CONTEXT(id));
throw new WSSecureConversationException(LogStringsMessages.WSSC_0015_UNKNOWN_CONTEXT(id));
}
// Create Lifetime
final Lifetime lifetime = createLifetime();
final BaseSTSResponse rstr;
if(wsscVer.getNamespaceURI().equals(WSSCVersion.WSSC_13.getNamespaceURI())){
try{
RequestSecurityTokenResponse resp = wsscEleFac.createRSTRForRenew(tokenType, con, rst, rar, null, proofToken, serverEntropy, lifetime);
List<RequestSecurityTokenResponse> list = new ArrayList<RequestSecurityTokenResponse>();
list.add(resp);
rstr = ((WSSCElementFactory13)wsscEleFac).createRSTRCollectionForIssue(list);
}catch(WSTrustException ex){
log.log(Level.SEVERE,
LogStringsMessages.WSSC_0020_PROBLEM_CREATING_RSTR(), ex);
throw new WSSecureConversationException(LogStringsMessages.WSSC_0020_PROBLEM_CREATING_RSTR(), ex);
}
}else{
try{
rstr = wsscEleFac.createRSTRForRenew(tokenType, con, rst, rar, null, proofToken, serverEntropy, lifetime);
}catch (WSTrustException ex){
log.log(Level.SEVERE,
LogStringsMessages.WSSC_0020_PROBLEM_CREATING_RSTR(), ex);
throw new WSSecureConversationException(LogStringsMessages.WSSC_0020_PROBLEM_CREATING_RSTR(), ex);
}
}
if (log.isLoggable(Level.FINE)) {
log.log(Level.FINE,
LogStringsMessages.WSSC_0014_RSTR_RESPONSE(WSTrustUtil.elemToString(rstr, wsTrustVer)));
}
final Session session = sm.getSession(token.getIdentifier().toString());
populateRenewedITC(session, secret, token, ctx, attachedReference);
sm.addSecurityContext(token.getIdentifier().toString(), ctx);
return rstr;
}