Search in sources :

Example 6 with CTSTokenPersistenceException

use of org.forgerock.openam.sts.CTSTokenPersistenceException in project OpenAM by OpenRock.

the class TokenGenerationService method queryCollection.

@Override
public Promise<QueryResponse, ResourceException> queryCollection(final Context serverContext, final QueryRequest queryRequest, final QueryResourceHandler queryResultHandler) {
    QueryFilter<JsonPointer> queryFilter = queryRequest.getQueryFilter();
    if (queryFilter == null) {
        return new BadRequestException(getUsageString()).asPromise();
    }
    try {
        final QueryFilter<CoreTokenField> coreTokenFieldQueryFilter = convertToCoreTokenFieldQueryFilter(queryFilter);
        final List<STSIssuedTokenState> issuedTokens = ctsTokenPersistence.listTokens(coreTokenFieldQueryFilter);
        for (STSIssuedTokenState tokenState : issuedTokens) {
            queryResultHandler.handleResource(newResourceResponse(tokenState.getTokenId(), EMPTY_STRING, tokenState.toJson()));
        }
        return newResultPromise(newQueryResponse());
    } catch (CTSTokenPersistenceException e) {
        logger.error("Exception caught obtaining list of sts-issued tokens: " + e, e);
        return e.asPromise();
    }
}
Also used : BadRequestException(org.forgerock.json.resource.BadRequestException) STSIssuedTokenState(org.forgerock.openam.sts.user.invocation.STSIssuedTokenState) CoreTokenField(org.forgerock.openam.tokens.CoreTokenField) JsonPointer(org.forgerock.json.JsonPointer) CTSTokenPersistenceException(org.forgerock.openam.sts.CTSTokenPersistenceException)

Aggregations

CTSTokenPersistenceException (org.forgerock.openam.sts.CTSTokenPersistenceException)6 CoreTokenException (org.forgerock.openam.cts.exceptions.CoreTokenException)2 PartialToken (org.forgerock.openam.sm.datalayer.api.query.PartialToken)2 TokenCreationException (org.forgerock.openam.sts.TokenCreationException)2 STSIssuedTokenState (org.forgerock.openam.sts.user.invocation.STSIssuedTokenState)2 Assertion (com.sun.identity.saml2.assertion.Assertion)1 EncryptedAssertion (com.sun.identity.saml2.assertion.EncryptedAssertion)1 SAML2Exception (com.sun.identity.saml2.common.SAML2Exception)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 ArrayList (java.util.ArrayList)1 Calendar (java.util.Calendar)1 Date (java.util.Date)1 JsonPointer (org.forgerock.json.JsonPointer)1 JwsAlgorithm (org.forgerock.json.jose.jws.JwsAlgorithm)1 JwsAlgorithmType (org.forgerock.json.jose.jws.JwsAlgorithmType)1 SignedJwt (org.forgerock.json.jose.jws.SignedJwt)1 BadRequestException (org.forgerock.json.resource.BadRequestException)1 Token (org.forgerock.openam.cts.api.tokens.Token)1 TokenIdGenerationException (org.forgerock.openam.sts.TokenIdGenerationException)1 OpenIdConnectTokenConfig (org.forgerock.openam.sts.config.user.OpenIdConnectTokenConfig)1