Search in sources :

Example 21 with StringResponse

use of io.airlift.http.client.StringResponseHandler.StringResponse in project airlift by airlift.

the class JwksService method fetchKeys.

private Map<String, PublicKey> fetchKeys() {
    Request request = prepareGet().setUri(address).build();
    StringResponse response;
    try {
        response = httpClient.execute(request, createStringResponseHandler());
    } catch (RuntimeException e) {
        throw new RuntimeException("Error reading JWKS keys from " + address, e);
    }
    if (response.getStatusCode() != 200) {
        throw new RuntimeException("Unexpected response code " + response.getStatusCode() + " from JWKS service at " + address);
    }
    try {
        return decodeKeys(response.getBody());
    } catch (RuntimeException e) {
        throw new RuntimeException("Unable to decode JWKS response from " + address, e);
    }
}
Also used : Request(io.airlift.http.client.Request) StringResponse(io.airlift.http.client.StringResponseHandler.StringResponse)

Aggregations

StringResponse (io.airlift.http.client.StringResponseHandler.StringResponse)21 Test (org.testng.annotations.Test)13 JettyHttpClient (io.airlift.http.client.jetty.JettyHttpClient)7 Request (io.airlift.http.client.Request)6 HttpClient (io.airlift.http.client.HttpClient)4 HttpUriBuilder (io.airlift.http.client.HttpUriBuilder)3 URI (java.net.URI)3 MediaType (com.google.common.net.MediaType)2 ObjectMapperProvider (io.airlift.json.ObjectMapperProvider)2 File (java.io.File)2 Throwables.getStackTraceAsString (com.google.common.base.Throwables.getStackTraceAsString)1 ImmutableListMultimap (com.google.common.collect.ImmutableListMultimap)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ListMultimap (com.google.common.collect.ListMultimap)1 CONTENT_TYPE (com.google.common.net.HttpHeaders.CONTENT_TYPE)1 Injector (com.google.inject.Injector)1 Bootstrap (io.airlift.bootstrap.Bootstrap)1 AbstractEventClient (io.airlift.event.client.AbstractEventClient)1 EventClient (io.airlift.event.client.EventClient)1 InMemoryEventModule (io.airlift.event.client.InMemoryEventModule)1