NegotiationUtils.getAllAssertionsByLocalname(aim, SPConstants.ISSUED_TOKEN);
if (ais.isEmpty()) {
return;
}
if (isRequestor(message)) {
IssuedToken itok = (IssuedToken)ais.iterator().next().getAssertion();
assertIssuedToken(itok, aim);
SecurityToken tok = retrieveCachedToken(message);
if (tok == null) {
tok = issueToken(message, aim, itok);
} else {
tok = renewToken(message, aim, itok, tok);
}
if (tok != null) {
for (AssertionInfo ai : ais) {
ai.setAsserted(true);
}
boolean cacheIssuedToken =
MessageUtils.getContextualBoolean(
message, SecurityConstants.CACHE_ISSUED_TOKEN_IN_ENDPOINT, true
) && !isOneTimeUse(tok);
if (cacheIssuedToken) {
message.getExchange().get(Endpoint.class).put(SecurityConstants.TOKEN, tok);
message.getExchange().put(SecurityConstants.TOKEN, tok);
message.getExchange().put(SecurityConstants.TOKEN_ID, tok.getId());
message.getExchange().get(Endpoint.class).put(SecurityConstants.TOKEN_ID,
tok.getId());
} else {
message.put(SecurityConstants.TOKEN, tok);
message.put(SecurityConstants.TOKEN_ID, tok.getId());
}
WSS4JUtils.getTokenStore(message).add(tok);
}
} else {
//server side should be checked on the way in
for (AssertionInfo ai : ais) {
ai.setAsserted(true);
}
IssuedToken itok = (IssuedToken)ais.iterator().next().getAssertion();
assertIssuedToken(itok, aim);
}
}
}