Search in sources :

Example 1 with STSIssuedTokenState

use of org.forgerock.openam.sts.user.invocation.STSIssuedTokenState in project OpenAM by OpenRock.

the class CTSTokenPersistenceImpl method listTokens.

@Override
public List<STSIssuedTokenState> listTokens(QueryFilter<CoreTokenField> queryFilter) throws CTSTokenPersistenceException {
    Collection<PartialToken> partialTokens;
    try {
        partialTokens = ctsPersistentStore.attributeQuery(buildTokenFilter(queryFilter));
    } catch (CoreTokenException e) {
        throw new CTSTokenPersistenceException(ResourceException.INTERNAL_ERROR, e.getMessage(), e);
    }
    List<STSIssuedTokenState> issuedTokens = new ArrayList<>(partialTokens.size());
    for (PartialToken partialToken : partialTokens) {
        issuedTokens.add(marshalIssuedTokenState(partialToken));
    }
    return issuedTokens;
}
Also used : PartialToken(org.forgerock.openam.sm.datalayer.api.query.PartialToken) ArrayList(java.util.ArrayList) CoreTokenException(org.forgerock.openam.cts.exceptions.CoreTokenException) STSIssuedTokenState(org.forgerock.openam.sts.user.invocation.STSIssuedTokenState) CTSTokenPersistenceException(org.forgerock.openam.sts.CTSTokenPersistenceException)

Example 2 with STSIssuedTokenState

use of org.forgerock.openam.sts.user.invocation.STSIssuedTokenState 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)2 STSIssuedTokenState (org.forgerock.openam.sts.user.invocation.STSIssuedTokenState)2 ArrayList (java.util.ArrayList)1 JsonPointer (org.forgerock.json.JsonPointer)1 BadRequestException (org.forgerock.json.resource.BadRequestException)1 CoreTokenException (org.forgerock.openam.cts.exceptions.CoreTokenException)1 PartialToken (org.forgerock.openam.sm.datalayer.api.query.PartialToken)1 CoreTokenField (org.forgerock.openam.tokens.CoreTokenField)1