Search in sources :

Example 81 with PostEnvironment

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

the class FAPICIBAAddAcrValuesToAuthorizationEndpointRequest method evaluate.

@Override
@PreEnvironment(required = "authorization_endpoint_request")
@PostEnvironment(required = "authorization_endpoint_request")
public Environment evaluate(Environment env) {
    JsonObject authorizationEndpointRequest = env.getObject("authorization_endpoint_request");
    String requestedACRs = env.getString("client", "acr_value");
    if (requestedACRs == null) {
        throw error("Couldn't find acr_value in configuration");
    }
    // Check provided acr_values is supported by server or not
    boolean acrValueIsSupportedFlg = false;
    JsonArray acrValuesSupported = env.getElementFromObject("server", "acr_values_supported").getAsJsonArray();
    for (JsonElement jsonElementAcrValue : acrValuesSupported) {
        if (OIDFJSON.getString(jsonElementAcrValue).equals(requestedACRs)) {
            acrValueIsSupportedFlg = true;
            break;
        }
    }
    if (!acrValueIsSupportedFlg) {
        throw error("Provided acr value is not supported by server", args("supported_acr_values", acrValuesSupported, "received_value", requestedACRs));
    }
    authorizationEndpointRequest.addProperty("acr_values", requestedACRs);
    env.putObject("authorization_endpoint_request", authorizationEndpointRequest);
    logSuccess(String.format("Added acr_values of '%s' to authorization endpoint request", requestedACRs), authorizationEndpointRequest);
    return env;
}
Also used : JsonArray(com.google.gson.JsonArray) JsonElement(com.google.gson.JsonElement) JsonObject(com.google.gson.JsonObject) PostEnvironment(net.openid.conformance.condition.PostEnvironment) PreEnvironment(net.openid.conformance.condition.PreEnvironment)

Example 82 with PostEnvironment

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

the class AddRandomJwksUriToServerConfiguration method evaluate.

@Override
@PreEnvironment(required = "server", strings = "random_jwks_uri_suffix")
@PostEnvironment(required = "server")
public Environment evaluate(Environment env) {
    JsonObject server = env.getObject("server");
    String currentJwksUri = OIDFJSON.getString(server.get("jwks_uri"));
    String randomSuffix = env.getString("random_jwks_uri_suffix");
    String newJwksUri = currentJwksUri + randomSuffix;
    server.addProperty("jwks_uri", newJwksUri);
    env.putObject("server", server);
    log("Added random jwks_uri to server configuration", args("jwks_uri", newJwksUri));
    return env;
}
Also used : JsonObject(com.google.gson.JsonObject) PostEnvironment(net.openid.conformance.condition.PostEnvironment) PreEnvironment(net.openid.conformance.condition.PreEnvironment)

Example 83 with PostEnvironment

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

the class AddResponseTypeCodeIdTokenToServerConfiguration method evaluate.

@Override
@PreEnvironment(required = "server")
@PostEnvironment(required = "server")
public Environment evaluate(Environment env) {
    JsonArray data = new JsonArray();
    data.add("code id_token");
    JsonObject server = env.getObject("server");
    server.add("response_types_supported", data);
    logSuccess("Added code id_token as response type supported", args("response_types_supported", 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 84 with PostEnvironment

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

the class AddSHashToIdTokenClaims method evaluate.

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

Example 85 with PostEnvironment

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

the class AddTLSClientAuthToServerConfiguration method evaluate.

@Override
@PreEnvironment(required = "server")
@PostEnvironment(required = "server")
public Environment evaluate(Environment env) {
    JsonArray data = new JsonArray();
    data.add("tls_client_auth");
    JsonObject server = env.getObject("server");
    server.add("token_endpoint_auth_methods_supported", data);
    logSuccess("Added tls_client_auth for token_endpoint_auth_methods_supported");
    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)

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