Search in sources :

Example 1 with RestIssuedTokenValidatorParameters

use of org.forgerock.openam.sts.rest.token.validator.RestIssuedTokenValidatorParameters in project OpenAM by OpenRock.

the class TokenRequestMarshallerImpl method buildOpenIdConnectIssuedTokenValidatorParameters.

private RestIssuedTokenValidatorParameters<OpenIdConnectIdToken> buildOpenIdConnectIssuedTokenValidatorParameters(JsonValue receivedToken) throws TokenMarshalException {
    if (!receivedToken.get(AMSTSConstants.OPEN_ID_CONNECT_ID_TOKEN_KEY).isString()) {
        String message = "Exception: json representation of a to-be-validated OIDC token does not contain a " + AMSTSConstants.OPEN_ID_CONNECT_ID_TOKEN_KEY + " field containing the " + "to-be-validated token. The representation: " + receivedToken;
        throw new TokenMarshalException(ResourceException.BAD_REQUEST, message);
    } else {
        final String tokenValue = receivedToken.get(AMSTSConstants.OPEN_ID_CONNECT_ID_TOKEN_KEY).asString();
        final OpenIdConnectIdToken openIdConnectIdToken = new OpenIdConnectIdToken(tokenValue);
        return new RestIssuedTokenValidatorParameters<OpenIdConnectIdToken>() {

            @Override
            public OpenIdConnectIdToken getInputToken() {
                return openIdConnectIdToken;
            }
        };
    }
}
Also used : RestIssuedTokenValidatorParameters(org.forgerock.openam.sts.rest.token.validator.RestIssuedTokenValidatorParameters) TokenMarshalException(org.forgerock.openam.sts.TokenMarshalException) OpenIdConnectIdToken(org.forgerock.openam.sts.token.model.OpenIdConnectIdToken)

Example 2 with RestIssuedTokenValidatorParameters

use of org.forgerock.openam.sts.rest.token.validator.RestIssuedTokenValidatorParameters in project OpenAM by OpenRock.

the class TokenRequestMarshallerImpl method buildSAML2IssuedTokenValidatorParameters.

private RestIssuedTokenValidatorParameters<SAML2TokenState> buildSAML2IssuedTokenValidatorParameters(JsonValue receivedToken) throws TokenMarshalException {
    if (!receivedToken.get(AMSTSConstants.SAML2_TOKEN_KEY).isString()) {
        String message = "Exception: json representation of a to-be-validated SAML2 token does not contain a " + AMSTSConstants.SAML2_TOKEN_KEY + " field containing the " + "to-be-validated token. The representation: " + receivedToken;
        throw new TokenMarshalException(ResourceException.BAD_REQUEST, message);
    } else {
        final String tokenValue = receivedToken.get(AMSTSConstants.SAML2_TOKEN_KEY).asString();
        final SAML2TokenState saml2TokenState = SAML2TokenState.builder().tokenValue(tokenValue).build();
        return new RestIssuedTokenValidatorParameters<SAML2TokenState>() {

            @Override
            public SAML2TokenState getInputToken() {
                return saml2TokenState;
            }
        };
    }
}
Also used : SAML2TokenState(org.forgerock.openam.sts.user.invocation.SAML2TokenState) RestIssuedTokenValidatorParameters(org.forgerock.openam.sts.rest.token.validator.RestIssuedTokenValidatorParameters) TokenMarshalException(org.forgerock.openam.sts.TokenMarshalException)

Aggregations

TokenMarshalException (org.forgerock.openam.sts.TokenMarshalException)2 RestIssuedTokenValidatorParameters (org.forgerock.openam.sts.rest.token.validator.RestIssuedTokenValidatorParameters)2 OpenIdConnectIdToken (org.forgerock.openam.sts.token.model.OpenIdConnectIdToken)1 SAML2TokenState (org.forgerock.openam.sts.user.invocation.SAML2TokenState)1