use of org.forgerock.openam.sts.token.model.OpenAMSessionToken in project OpenAM by OpenRock.
the class TokenRequestMarshallerImpl method buildAMSessionTokenTransformValidatorParameters.
private RestTokenTransformValidatorParameters<OpenAMSessionToken> buildAMSessionTokenTransformValidatorParameters(JsonValue receivedToken) throws TokenMarshalException {
if (!receivedToken.get(AMSTSConstants.AM_SESSION_TOKEN_SESSION_ID).isString()) {
String message = "Exception: json representation of AM Session Token does not contain a session_id field. " + "The representation: " + receivedToken;
throw new TokenMarshalException(ResourceException.BAD_REQUEST, message);
} else {
final String sessionId = receivedToken.get(AMSTSConstants.AM_SESSION_TOKEN_SESSION_ID).asString();
final OpenAMSessionToken openAMSessionToken = new OpenAMSessionToken(sessionId);
return new RestTokenTransformValidatorParameters<OpenAMSessionToken>() {
@Override
public OpenAMSessionToken getInputToken() {
return openAMSessionToken;
}
};
}
}
use of org.forgerock.openam.sts.token.model.OpenAMSessionToken in project OpenAM by OpenRock.
the class TokenRequestMarshallerImplTest method marshallOpenAMToken.
@Test
public void marshallOpenAMToken() throws TokenMarshalException {
JsonValue jsonOpenAM = json(object(field("token_type", "OPENAM"), field("session_id", "super_random")));
RestTokenTransformValidatorParameters<?> params = tokenMarshaller.buildTokenTransformValidatorParameters(jsonOpenAM, null);
assertTrue("super_random".equals(((OpenAMSessionToken) params.getInputToken()).getSessionId()));
}
Aggregations