Search in sources :

Example 71 with PostEnvironment

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

the class FAPIBrazilAddConsentIdToClientScope method evaluate.

@Override
@PreEnvironment(strings = "consent_id", required = "client")
@PostEnvironment(required = "client")
public Environment evaluate(Environment env) {
    String consentId = env.getString("consent_id");
    JsonObject client = env.getObject("client");
    JsonElement scopeElement = client.get("scope");
    if (scopeElement == null) {
        throw error("scope missing in client object");
    }
    String scope = OIDFJSON.getString(scopeElement);
    if (Strings.isNullOrEmpty(scope)) {
        throw error("scope empty in client object");
    }
    scope += " consent:" + consentId;
    client.addProperty("scope", scope);
    logSuccess("Added scope of '" + scope + "' to client's scope", client);
    return env;
}
Also used : JsonElement(com.google.gson.JsonElement) JsonObject(com.google.gson.JsonObject) PostEnvironment(net.openid.conformance.condition.PostEnvironment) PreEnvironment(net.openid.conformance.condition.PreEnvironment)

Example 72 with PostEnvironment

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

the class ExtractExpiresInFromTokenEndpointResponse method evaluate.

@Override
@PreEnvironment(required = "token_endpoint_response")
@PostEnvironment(required = "expires_in")
public Environment evaluate(Environment env) {
    JsonObject tokenEndpoint = env.getObject("token_endpoint_response");
    JsonElement expiresInValue = tokenEndpoint.get("expires_in");
    if (expiresInValue == null) {
        throw error("'expires_in' not present in the token endpoint response. RFC6749 recommends expires_in is included.", tokenEndpoint);
    }
    /* Create our cut down JsonObject with just a single value in it */
    JsonObject value = new JsonObject();
    value.add("expires_in", expiresInValue);
    env.putObject("expires_in", value);
    logSuccess("Extracted 'expires_in'", value);
    return env;
}
Also used : JsonElement(com.google.gson.JsonElement) JsonObject(com.google.gson.JsonObject) PostEnvironment(net.openid.conformance.condition.PostEnvironment) PreEnvironment(net.openid.conformance.condition.PreEnvironment)

Example 73 with PostEnvironment

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

the class ExtractIdTokenFromTokenResponse method evaluate.

@Override
@PreEnvironment(required = "token_endpoint_response")
@PostEnvironment(required = "id_token")
public Environment evaluate(Environment env) {
    JsonObject client = env.getObject("client");
    JsonObject clientJwks = env.getObject("client_jwks");
    return extractJWT(env, "token_endpoint_response", "id_token", "id_token", client, clientJwks);
}
Also used : JsonObject(com.google.gson.JsonObject) PostEnvironment(net.openid.conformance.condition.PostEnvironment) PreEnvironment(net.openid.conformance.condition.PreEnvironment)

Example 74 with PostEnvironment

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

the class ExtractImplicitHashToCallbackResponse method evaluate.

@Override
@PreEnvironment(strings = "implicit_hash")
@PostEnvironment(required = "callback_params")
public Environment evaluate(Environment env) {
    String implicit_hash = env.getString("implicit_hash");
    if (!Strings.isNullOrEmpty(implicit_hash)) {
        // strip off the leading # character
        String hash = implicit_hash.substring(1);
        List<NameValuePair> parameters = URLEncodedUtils.parse(hash, Charset.defaultCharset(), '&');
        log("Extracted response from URL fragment", args("parameters", parameters));
        JsonObject o = new JsonObject();
        for (NameValuePair pair : parameters) {
            o.addProperty(pair.getName(), pair.getValue());
        }
        env.putObject("callback_params", o);
        logSuccess("Extracted the hash values", o);
        return env;
    }
    JsonObject o = new JsonObject();
    env.putObject("callback_params", o);
    logSuccess("implicit_hash is empty", o);
    return env;
}
Also used : NameValuePair(org.apache.http.NameValuePair) JsonObject(com.google.gson.JsonObject) PostEnvironment(net.openid.conformance.condition.PostEnvironment) PreEnvironment(net.openid.conformance.condition.PreEnvironment)

Example 75 with PostEnvironment

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

the class ExtractJWKSDirectFromClientConfiguration method evaluate.

@Override
@PreEnvironment(required = "config")
@PostEnvironment(required = { "client_jwks", "client_public_jwks" })
public Environment evaluate(Environment env) {
    // bump the client's internal JWK up to the root
    JsonElement jwks = env.getElementFromObject("config", "client.jwks");
    extractJwks(env, jwks);
    return env;
}
Also used : JsonElement(com.google.gson.JsonElement) 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