writer.writeEndElement();
writer.writeStartElement(prefix, "RequestedSecurityToken", namespace);
// SecurityContextToken
SecurityContextToken sct =
new SecurityContextToken(
NegotiationUtils.getWSCVersion(tokenType), writer.getDocument()
);
// Lifetime
Date created = new Date();
Date expires = new Date();
expires.setTime(created.getTime() + 300000L);
SecurityToken token = new SecurityToken(sct.getIdentifier(), created, expires);
token.setToken(sct.getElement());
token.setTokenType(sct.getTokenType());
SecurityContext sc = exchange.getInMessage().get(SecurityContext.class);
if (sc != null) {
token.setSecurityContext(sc);
}
writer.getCurrentNode().appendChild(sct.getElement());
writer.writeEndElement();
// References
writer.writeStartElement(prefix, "RequestedAttachedReference", namespace);
token.setAttachedReference(
writeSecurityTokenReference(writer, "#" + sct.getID(), tokenType)
);
writer.writeEndElement();
writer.writeStartElement(prefix, "RequestedUnattachedReference", namespace);
token.setUnattachedReference(
writeSecurityTokenReference(writer, sct.getIdentifier(), tokenType)
);
writer.writeEndElement();
writeLifetime(writer, created, expires, prefix, namespace);