use of net.openid.conformance.condition.PreEnvironment in project conformance-suite by openid-certification.
the class CreateLoginRequiredErrorResponse method evaluate.
@Override
@PreEnvironment(required = CreateAuthorizationEndpointResponseParams.ENV_KEY)
@PostEnvironment(required = ERROR_RESPONSE_PARAMS, strings = ERROR_RESPONSE_URL)
public Environment evaluate(Environment env) {
JsonObject originalResponseParams = env.getObject(CreateAuthorizationEndpointResponseParams.ENV_KEY);
JsonObject errorResponseParams = new JsonObject();
if (originalResponseParams.has("state")) {
errorResponseParams.add("state", originalResponseParams.get("state"));
}
errorResponseParams.addProperty("error", "login_required");
errorResponseParams.addProperty("error_description", "This is a login_required error response");
env.putObject(ERROR_RESPONSE_PARAMS, errorResponseParams);
String responseUrl = OIDFJSON.getString(originalResponseParams.remove("redirect_uri"));
env.putString(ERROR_RESPONSE_URL, responseUrl);
log("Created login_required error", args(ERROR_RESPONSE_PARAMS, errorResponseParams, ERROR_RESPONSE_URL, responseUrl));
return env;
}
use of net.openid.conformance.condition.PreEnvironment in project conformance-suite by openid-certification.
the class CreateTokenEndpointResponse method evaluate.
@Override
// note the others are optional
@PreEnvironment(strings = { "access_token", "token_type" })
@PostEnvironment(required = "token_endpoint_response")
public Environment evaluate(Environment env) {
String accessToken = env.getString("access_token");
String tokenType = env.getString("token_type");
String idToken = env.getString("id_token");
String refreshToken = env.getString("refresh_token");
String scope = env.getString("scope");
String accessTokenExpiration = env.getString("access_token_expiration");
if (Strings.isNullOrEmpty(accessToken) || Strings.isNullOrEmpty(tokenType)) {
throw error("Missing required access_token or token_type");
}
JsonObject tokenEndpointResponse = new JsonObject();
tokenEndpointResponse.addProperty("access_token", accessToken);
tokenEndpointResponse.addProperty("token_type", tokenType);
if (!Strings.isNullOrEmpty(idToken)) {
tokenEndpointResponse.addProperty("id_token", idToken);
}
if (!Strings.isNullOrEmpty(refreshToken)) {
tokenEndpointResponse.addProperty("refresh_token", refreshToken);
}
if (!Strings.isNullOrEmpty(scope)) {
tokenEndpointResponse.addProperty("scope", scope);
}
if (!Strings.isNullOrEmpty(accessTokenExpiration)) {
tokenEndpointResponse.addProperty("expires_in", Integer.parseInt(accessTokenExpiration));
}
env.putObject("token_endpoint_response", tokenEndpointResponse);
logSuccess("Created token endpoint response", tokenEndpointResponse);
return env;
}
use of net.openid.conformance.condition.PreEnvironment in project conformance-suite by openid-certification.
the class CreateWebfingerResponse method evaluate.
@Override
@PreEnvironment(required = { "incoming_webfinger_request" }, strings = { "incoming_webfinger_resource" })
@PostEnvironment(required = "webfinger_response")
public Environment evaluate(Environment env) {
JsonObject response = new JsonObject();
response.addProperty("subject", env.getString("incoming_webfinger_resource"));
JsonArray linksArray = new JsonArray();
JsonObject linkEntry = new JsonObject();
linkEntry.addProperty("rel", "http://openid.net/specs/connect/1.0/issuer");
linkEntry.addProperty("href", env.getString("issuer"));
linksArray.add(linkEntry);
response.add("links", linksArray);
env.putObject("webfinger_response", response);
log("Created webfinger response", args("webfinger_response", response));
return env;
}
use of net.openid.conformance.condition.PreEnvironment in project conformance-suite by openid-certification.
the class EncryptIdToken method evaluate.
@Override
@PreEnvironment(strings = "id_token", required = "client")
@PostEnvironment(strings = "id_token")
public Environment evaluate(Environment env) {
String idToken = env.getString("id_token");
String alg = env.getString("client", "id_token_encrypted_response_alg");
String enc = env.getString("client", "id_token_encrypted_response_enc");
String clientSecret = env.getString("client", "client_secret");
// client jwks may be null
JsonElement clientJwksElement = env.getElementFromObject("client", "jwks");
JsonObject clientJwks = null;
if (clientJwksElement != null) {
clientJwks = clientJwksElement.getAsJsonObject();
}
String encryptedIdToken = encrypt("client", idToken, clientSecret, clientJwks, alg, enc, "id_token_encrypted_response_alg", "id_token_encrypted_response_enc");
log("Encrypted the id token", args("id_token", encryptedIdToken, "id_token_encrypted_response_alg", alg, "id_token_encrypted_response_enc", enc));
env.putString("id_token", encryptedIdToken);
return env;
}
use of net.openid.conformance.condition.PreEnvironment in project conformance-suite by openid-certification.
the class EncryptJARMResponse method evaluate.
@Override
@PreEnvironment(strings = "jarm_response", required = "client")
@PostEnvironment(strings = "jarm_response")
public Environment evaluate(Environment env) {
String response = env.getString("jarm_response");
String alg = env.getString("client", "authorization_encrypted_response_alg");
String enc = env.getString("client", "authorization_encrypted_response_enc");
String clientSecret = env.getString("client", "client_secret");
// client jwks may be null
JsonElement clientJwksElement = env.getElementFromObject("client", "jwks");
JsonObject clientJwks = null;
if (clientJwksElement != null) {
clientJwks = clientJwksElement.getAsJsonObject();
}
String encryptedResponse = encrypt("client", response, clientSecret, clientJwks, alg, enc, "authorization_encrypted_response_alg", "authorization_encrypted_response_enc");
log("Encrypted the JARM response", args("response", encryptedResponse, "authorization_encrypted_response_alg", alg, "authorization_encrypted_response_enc", enc));
env.putString("jarm_response", encryptedResponse);
return env;
}
Aggregations