use of org.forgerock.openam.sts.rest.token.canceller.RestIssuedTokenCanceller in project OpenAM by OpenRock.
the class IssuedTokenCancelOperationImpl method cancelToken.
@Override
@SuppressWarnings("unchecked")
public JsonValue cancelToken(RestSTSTokenCancellationInvocationState invocationState) throws TokenCancellationException, TokenMarshalException {
TokenTypeId tokenTypeId = tokenRequestMarshaller.getTokenType(invocationState.getCancelledTokenState());
RestIssuedTokenCancellerParameters<?> cancellerParameters = tokenRequestMarshaller.buildIssuedTokenCancellerParameters(invocationState.getCancelledTokenState());
for (RestIssuedTokenCanceller tokenCanceller : tokenCancellers) {
if (tokenCanceller.canCancelToken(tokenTypeId)) {
tokenCanceller.cancelToken(cancellerParameters);
return json(object(field(RESULT, tokenTypeId.getId() + " token cancelled successfully.")));
}
}
throw new TokenCancellationException(ResourceException.BAD_REQUEST, "No IssuedTokenCancellers available for " + "token type: " + tokenTypeId.getId() + ". Does this sts issue tokens of the specified type?");
}
Aggregations