Search in sources :

Example 1 with RestIssuedTokenCanceller

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?");
}
Also used : TokenTypeId(org.forgerock.openam.sts.TokenTypeId) TokenCancellationException(org.forgerock.openam.sts.TokenCancellationException) RestIssuedTokenCanceller(org.forgerock.openam.sts.rest.token.canceller.RestIssuedTokenCanceller)

Aggregations

TokenCancellationException (org.forgerock.openam.sts.TokenCancellationException)1 TokenTypeId (org.forgerock.openam.sts.TokenTypeId)1 RestIssuedTokenCanceller (org.forgerock.openam.sts.rest.token.canceller.RestIssuedTokenCanceller)1