Search in sources :

Example 1 with PostEnvironment

use of net.openid.conformance.condition.PostEnvironment in project conformance-suite by openid-certification.

the class AddACRClaimToIdTokenClaims method evaluate.

@Override
@PreEnvironment(required = "id_token_claims", strings = "requested_id_token_acr_values")
@PostEnvironment(required = "id_token_claims")
public Environment evaluate(Environment env) {
    JsonObject claims = env.getObject("id_token_claims");
    String acr = env.getString("requested_id_token_acr_values");
    JsonArray acrValues = (JsonArray) JsonParser.parseString(acr);
    if (acrValues == null || !acrValues.isJsonPrimitive()) {
        String[] acrValuesString = new Gson().fromJson(acrValues, String[].class);
        List<String> requestedACRs;
        requestedACRs = Arrays.asList(acrValuesString);
        List<String> acceptableAcrValues = new ArrayList<>();
        acceptableAcrValues.add("urn:openbanking:psd2:sca");
        acceptableAcrValues.add("urn:openbanking:psd2:ca");
        String acrValue = null;
        for (String singleACRValue : requestedACRs) {
            if (singleACRValue.contains(acceptableAcrValues.get(0))) {
                acrValue = singleACRValue;
                break;
            } else if (singleACRValue.contains(acceptableAcrValues.get(1))) {
                acrValue = singleACRValue;
            } else {
                throw error("Unsupported acr value in id_token_claims", args("supported_acr_values", acceptableAcrValues, "received_value", requestedACRs));
            }
        }
        claims.addProperty("acr", acrValue);
        env.putObject("id_token_claims", claims);
        logSuccess("Added acr value to id_token_claims", args("claims", claims, "acr_value", acrValue));
    }
    return env;
}
Also used : JsonArray(com.google.gson.JsonArray) ArrayList(java.util.ArrayList) JsonObject(com.google.gson.JsonObject) Gson(com.google.gson.Gson) PostEnvironment(net.openid.conformance.condition.PostEnvironment) PreEnvironment(net.openid.conformance.condition.PreEnvironment)

Example 2 with PostEnvironment

use of net.openid.conformance.condition.PostEnvironment in project conformance-suite by openid-certification.

the class AddAuthorizationSigningAlgValuesSupportedToServerConfiguration method evaluate.

@Override
@PreEnvironment(required = { "server" }, strings = "signing_algorithm")
@PostEnvironment(required = "server")
public Environment evaluate(Environment env) {
    String alg = env.getString("signing_algorithm");
    JsonArray data = new JsonArray();
    data.add(alg);
    JsonObject server = env.getObject("server");
    server.add("authorization_signing_alg_values_supported", data);
    logSuccess("Added authorization_signing_alg_values_supported to server configuration", args("alg_values", data));
    return env;
}
Also used : JsonArray(com.google.gson.JsonArray) JsonObject(com.google.gson.JsonObject) PostEnvironment(net.openid.conformance.condition.PostEnvironment) PreEnvironment(net.openid.conformance.condition.PreEnvironment)

Example 3 with PostEnvironment

use of net.openid.conformance.condition.PostEnvironment in project conformance-suite by openid-certification.

the class AddCHashToIdTokenClaims method evaluate.

@Override
@PreEnvironment(required = "id_token_claims", strings = "c_hash")
@PostEnvironment(required = "id_token_claims")
public Environment evaluate(Environment env) {
    JsonObject claims = env.getObject("id_token_claims");
    String hash = env.getString("c_hash");
    claims.addProperty("c_hash", hash);
    env.putObject("id_token_claims", claims);
    logSuccess("Added c_hash to ID token claims", args("id_token_claims", claims, "c_hash", hash));
    return env;
}
Also used : JsonObject(com.google.gson.JsonObject) PostEnvironment(net.openid.conformance.condition.PostEnvironment) PreEnvironment(net.openid.conformance.condition.PreEnvironment)

Example 4 with PostEnvironment

use of net.openid.conformance.condition.PostEnvironment in project conformance-suite by openid-certification.

the class AddCodeToAuthorizationEndpointResponseParams method evaluate.

@Override
@PreEnvironment(required = CreateAuthorizationEndpointResponseParams.ENV_KEY, strings = "authorization_code")
@PostEnvironment(required = CreateAuthorizationEndpointResponseParams.ENV_KEY)
public Environment evaluate(Environment env) {
    JsonObject params = env.getObject(CreateAuthorizationEndpointResponseParams.ENV_KEY);
    String code = env.getString("authorization_code");
    params.addProperty("code", code);
    env.putObject(CreateAuthorizationEndpointResponseParams.ENV_KEY, params);
    logSuccess("Added code to authorization endpoint response params", args(CreateAuthorizationEndpointResponseParams.ENV_KEY, params));
    return env;
}
Also used : JsonObject(com.google.gson.JsonObject) PostEnvironment(net.openid.conformance.condition.PostEnvironment) PreEnvironment(net.openid.conformance.condition.PreEnvironment)

Example 5 with PostEnvironment

use of net.openid.conformance.condition.PostEnvironment in project conformance-suite by openid-certification.

the class AddIdTokenToAuthorizationEndpointResponseParams method evaluate.

@Override
@PreEnvironment(required = CreateAuthorizationEndpointResponseParams.ENV_KEY, strings = "id_token")
@PostEnvironment(required = CreateAuthorizationEndpointResponseParams.ENV_KEY)
public Environment evaluate(Environment env) {
    JsonObject params = env.getObject(CreateAuthorizationEndpointResponseParams.ENV_KEY);
    String idToken = env.getString("id_token");
    params.addProperty("id_token", idToken);
    env.putObject(CreateAuthorizationEndpointResponseParams.ENV_KEY, params);
    logSuccess("Added id_token to authorization endpoint response params", args(CreateAuthorizationEndpointResponseParams.ENV_KEY, params));
    return env;
}
Also used : JsonObject(com.google.gson.JsonObject) PostEnvironment(net.openid.conformance.condition.PostEnvironment) PreEnvironment(net.openid.conformance.condition.PreEnvironment)

Aggregations

PostEnvironment (net.openid.conformance.condition.PostEnvironment)399 PreEnvironment (net.openid.conformance.condition.PreEnvironment)379 JsonObject (com.google.gson.JsonObject)372 JsonElement (com.google.gson.JsonElement)61 JsonArray (com.google.gson.JsonArray)49 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)22 Instant (java.time.Instant)21 ParseException (java.text.ParseException)17 CertificateException (java.security.cert.CertificateException)16 IOException (java.io.IOException)15 KeyManagementException (java.security.KeyManagementException)15 KeyStoreException (java.security.KeyStoreException)15 UnrecoverableKeyException (java.security.UnrecoverableKeyException)15 InvalidKeySpecException (java.security.spec.InvalidKeySpecException)15 RestClientException (org.springframework.web.client.RestClientException)15 RestTemplate (org.springframework.web.client.RestTemplate)15 JOSEException (com.nimbusds.jose.JOSEException)9 JWK (com.nimbusds.jose.jwk.JWK)9 RestClientResponseException (org.springframework.web.client.RestClientResponseException)9 JWKSet (com.nimbusds.jose.jwk.JWKSet)7