use of org.forgerock.openam.sts.TokenMarshalException in project OpenAM by OpenRock.
the class SAML2TokenCreationState method fromJson.
public static SAML2TokenCreationState fromJson(JsonValue jsonValue) throws TokenMarshalException {
String subjectConfirmationString = jsonValue.get(SUBJECT_CONFIRMATION).asString();
if (subjectConfirmationString == null) {
throw new TokenMarshalException(ResourceException.BAD_REQUEST, "Value corresponding to " + SUBJECT_CONFIRMATION + " key is null");
}
SAML2SubjectConfirmation saml2SubjectConfirmation;
try {
saml2SubjectConfirmation = SAML2SubjectConfirmation.valueOf(subjectConfirmationString);
} catch (IllegalArgumentException e) {
throw new TokenMarshalException(ResourceException.BAD_REQUEST, "Invalid subject confirmation type specified.");
}
SAML2TokenStateBuilder builder = SAML2TokenCreationState.builder().saml2SubjectConfirmation(saml2SubjectConfirmation);
JsonValue jsonProofToken = jsonValue.get(PROOF_TOKEN_STATE);
if (!jsonProofToken.isNull()) {
builder.proofTokenState(ProofTokenState.fromJson(jsonProofToken));
}
return builder.build();
}
use of org.forgerock.openam.sts.TokenMarshalException 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;
}
};
}
}
use of org.forgerock.openam.sts.TokenMarshalException in project OpenAM by OpenRock.
the class TokenRequestMarshallerImpl method getTokenType.
@Override
public TokenTypeId getTokenType(JsonValue receivedToken) throws TokenMarshalException {
JsonValue jsonTokenType = receivedToken.get(AMSTSConstants.TOKEN_TYPE_KEY);
if (jsonTokenType.isNull() || !jsonTokenType.isString()) {
String message = "REST STS invocation does not contain " + AMSTSConstants.TOKEN_TYPE_KEY + " String entry. The json token: " + receivedToken;
throw new TokenMarshalException(ResourceException.BAD_REQUEST, message);
}
final String tokenType = jsonTokenType.asString();
return new TokenTypeId() {
@Override
public String getId() {
return tokenType;
}
};
}
use of org.forgerock.openam.sts.TokenMarshalException in project OpenAM by OpenRock.
the class TokenRequestMarshallerImpl method buildOpenIdConnectIssuedTokenCancellerParameters.
private RestIssuedTokenCancellerParameters<OpenIdConnectIdToken> buildOpenIdConnectIssuedTokenCancellerParameters(JsonValue receivedToken) throws TokenMarshalException {
if (!receivedToken.get(AMSTSConstants.OPEN_ID_CONNECT_ID_TOKEN_KEY).isString()) {
String message = "Exception: json representation of a to-be-cancelled OIDC token does not contain a " + AMSTSConstants.OPEN_ID_CONNECT_ID_TOKEN_KEY + " field containing the " + "to-be-cancelled 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 RestIssuedTokenCancellerParameters<OpenIdConnectIdToken>() {
@Override
public OpenIdConnectIdToken getInputToken() {
return openIdConnectIdToken;
}
};
}
}
use of org.forgerock.openam.sts.TokenMarshalException 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;
}
};
}
}
Aggregations