Search in sources :

Example 91 with PostEnvironment

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

the class AddRedirectUriToClientConfigurationRequest method evaluate.

@Override
@PreEnvironment(required = "registration_client_endpoint_request_body", strings = "redirect_uri")
@PostEnvironment(required = "registration_client_endpoint_request_body")
public Environment evaluate(Environment env) {
    JsonObject clientConfigRequest = env.getObject("registration_client_endpoint_request_body");
    String redirectUri = env.getString("redirect_uri");
    if (Strings.isNullOrEmpty(redirectUri)) {
        throw error("No redirect_uri found");
    }
    JsonArray redirectUris = new JsonArray();
    redirectUris.add(redirectUri);
    clientConfigRequest.add("redirect_uris", redirectUris);
    log("Added redirect_uris array to client configuration endpoint request", args("registration_client_endpoint_request", clientConfigRequest));
    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 92 with PostEnvironment

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

the class AddRedirectUriToDynamicRegistrationRequest method evaluate.

@Override
@PreEnvironment(required = "dynamic_registration_request", strings = "redirect_uri")
@PostEnvironment(required = "dynamic_registration_request")
public Environment evaluate(Environment env) {
    JsonObject dynamicRegistrationRequest = env.getObject("dynamic_registration_request");
    String redirectUri = env.getString("redirect_uri");
    if (Strings.isNullOrEmpty(redirectUri)) {
        throw error("No redirect_uri found");
    }
    JsonArray redirectUris = new JsonArray();
    redirectUris.add(redirectUri);
    dynamicRegistrationRequest.add("redirect_uris", redirectUris);
    env.putObject("dynamic_registration_request", dynamicRegistrationRequest);
    log("Added redirect_uris array to dynamic registration request", args("dynamic_registration_request", dynamicRegistrationRequest));
    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 93 with PostEnvironment

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

the class AddNbfToRequestObject method evaluate.

@Override
@PreEnvironment(required = { "request_object_claims" })
@PostEnvironment(required = { "request_object_claims" })
public Environment evaluate(Environment env) {
    JsonObject requestObjectClaims = env.getObject("request_object_claims");
    Instant nbf = Instant.now();
    requestObjectClaims.addProperty("nbf", nbf.getEpochSecond());
    env.putObject("request_object_claims", requestObjectClaims);
    logSuccess("Added nbf to request object claims", args("nbf", requestObjectClaims.getAsJsonPrimitive("nbf")));
    return env;
}
Also used : Instant(java.time.Instant) JsonObject(com.google.gson.JsonObject) PostEnvironment(net.openid.conformance.condition.PostEnvironment) PreEnvironment(net.openid.conformance.condition.PreEnvironment)

Example 94 with PostEnvironment

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

the class AddNbfValueIs10MinutesInFutureToRequestObject method evaluate.

@Override
@PreEnvironment(required = "request_object_claims")
@PostEnvironment(required = "request_object_claims")
public Environment evaluate(Environment env) {
    JsonObject requestObjectClaims = env.getObject("request_object_claims");
    Instant nbf = Instant.now().plusSeconds(10 * 60);
    requestObjectClaims.addProperty("nbf", nbf.getEpochSecond());
    env.putObject("request_object_claims", requestObjectClaims);
    logSuccess("Added invalid nbf value to request object which is 10 minutes in the future", args("request_object_claims", requestObjectClaims, "nbf_is_10_minutes_in_the_future", nbf));
    return env;
}
Also used : Instant(java.time.Instant) JsonObject(com.google.gson.JsonObject) PostEnvironment(net.openid.conformance.condition.PostEnvironment) PreEnvironment(net.openid.conformance.condition.PreEnvironment)

Example 95 with PostEnvironment

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

the class AddNonceToAuthorizationEndpointRequest method evaluate.

@Override
@PreEnvironment(strings = "nonce", required = "authorization_endpoint_request")
@PostEnvironment(required = "authorization_endpoint_request")
public Environment evaluate(Environment env) {
    String nonce = env.getString("nonce");
    if (Strings.isNullOrEmpty(nonce)) {
        throw error("Couldn't find nonce value");
    }
    JsonObject authorizationEndpointRequest = env.getObject("authorization_endpoint_request");
    authorizationEndpointRequest.addProperty("nonce", nonce);
    env.putObject("authorization_endpoint_request", authorizationEndpointRequest);
    logSuccess("Added nonce parameter to request", authorizationEndpointRequest);
    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