Search in sources :

Example 1 with ClientProvider

use of uk.gov.ida.restclient.ClientProvider in project verify-hub by alphagov.

the class SamlSoapProxyModule method jsonClient.

@Provides
@Singleton
public JsonClient jsonClient(JsonResponseProcessor jsonResponseProcessor, Environment environment, SamlSoapProxyConfiguration configuration) {
    Client client = new ClientProvider(environment, configuration.getJerseyClientConfiguration(), configuration.getEnableRetryTimeOutConnections(), "samlSoapProxyClient").get();
    ErrorHandlingClient errorHandlingClient = new ErrorHandlingClient(client);
    return new JsonClient(errorHandlingClient, jsonResponseProcessor);
}
Also used : JsonClient(uk.gov.ida.jerseyclient.JsonClient) DefaultClientProvider(uk.gov.ida.jerseyclient.DefaultClientProvider) ClientProvider(uk.gov.ida.restclient.ClientProvider) HealthCheckSoapRequestClient(uk.gov.ida.hub.samlsoapproxy.client.HealthCheckSoapRequestClient) MatchingServiceHealthCheckClient(uk.gov.ida.hub.samlsoapproxy.client.MatchingServiceHealthCheckClient) PrometheusClient(uk.gov.ida.hub.samlsoapproxy.client.PrometheusClient) Client(javax.ws.rs.client.Client) AttributeQueryRequestClient(uk.gov.ida.hub.samlsoapproxy.client.AttributeQueryRequestClient) JsonClient(uk.gov.ida.jerseyclient.JsonClient) SoapRequestClient(uk.gov.ida.hub.samlsoapproxy.client.SoapRequestClient) ErrorHandlingClient(uk.gov.ida.jerseyclient.ErrorHandlingClient) ErrorHandlingClient(uk.gov.ida.jerseyclient.ErrorHandlingClient) Singleton(javax.inject.Singleton) Provides(com.google.inject.Provides)

Example 2 with ClientProvider

use of uk.gov.ida.restclient.ClientProvider in project verify-hub by alphagov.

the class SamlEngineModule method jsonClient.

@Provides
@Singleton
private JsonClient jsonClient(JsonResponseProcessor jsonResponseProcessor, Environment environment, SamlEngineConfiguration configuration) {
    Client client = new ClientProvider(environment, configuration.getJerseyClientConfiguration(), configuration.getEnableRetryTimeOutConnections(), "samlEngineClient").get();
    ErrorHandlingClient errorHandlingClient = new ErrorHandlingClient(client);
    return new JsonClient(errorHandlingClient, jsonResponseProcessor);
}
Also used : JsonClient(uk.gov.ida.jerseyclient.JsonClient) DefaultClientProvider(uk.gov.ida.jerseyclient.DefaultClientProvider) ClientProvider(uk.gov.ida.restclient.ClientProvider) JsonClient(uk.gov.ida.jerseyclient.JsonClient) Client(javax.ws.rs.client.Client) ErrorHandlingClient(uk.gov.ida.jerseyclient.ErrorHandlingClient) RedisClient(io.lettuce.core.RedisClient) ErrorHandlingClient(uk.gov.ida.jerseyclient.ErrorHandlingClient) Singleton(javax.inject.Singleton) Provides(com.google.inject.Provides)

Example 3 with ClientProvider

use of uk.gov.ida.restclient.ClientProvider in project verify-hub by alphagov.

the class PolicyModule method jsonClient.

@Provides
@Singleton
public JsonClient jsonClient(JsonResponseProcessor jsonResponseProcessor, Environment environment, PolicyConfiguration configuration) {
    Client client = new ClientProvider(environment, configuration.getJerseyClientConfiguration(), configuration.getEnableRetryTimeOutConnections(), "policyClient").get();
    ErrorHandlingClient errorHandlingClient = new ErrorHandlingClient(client);
    return new JsonClient(errorHandlingClient, jsonResponseProcessor);
}
Also used : JsonClient(uk.gov.ida.jerseyclient.JsonClient) DefaultClientProvider(uk.gov.ida.jerseyclient.DefaultClientProvider) ClientProvider(uk.gov.ida.restclient.ClientProvider) Client(javax.ws.rs.client.Client) JsonClient(uk.gov.ida.jerseyclient.JsonClient) ErrorHandlingClient(uk.gov.ida.jerseyclient.ErrorHandlingClient) RedisClient(io.lettuce.core.RedisClient) ErrorHandlingClient(uk.gov.ida.jerseyclient.ErrorHandlingClient) Singleton(javax.inject.Singleton) Provides(com.google.inject.Provides)

Example 4 with ClientProvider

use of uk.gov.ida.restclient.ClientProvider in project verify-hub by alphagov.

the class PolicyModule method forSamlSoapProxy.

@Provides
@Singleton
@Named("samlSoapProxyClient")
public JsonClient forSamlSoapProxy(JsonResponseProcessor responseProcessor, PolicyConfiguration configuration, Environment environment) {
    Client client = new ClientProvider(environment, configuration.getSamlSoapProxyClient(), configuration.getEnableRetryTimeOutConnections(), "SamlSoapProxyClient").get();
    ErrorHandlingClient errorHandlingClient = new ErrorHandlingClient(client);
    return new JsonClient(errorHandlingClient, responseProcessor);
}
Also used : JsonClient(uk.gov.ida.jerseyclient.JsonClient) DefaultClientProvider(uk.gov.ida.jerseyclient.DefaultClientProvider) ClientProvider(uk.gov.ida.restclient.ClientProvider) Client(javax.ws.rs.client.Client) JsonClient(uk.gov.ida.jerseyclient.JsonClient) ErrorHandlingClient(uk.gov.ida.jerseyclient.ErrorHandlingClient) RedisClient(io.lettuce.core.RedisClient) ErrorHandlingClient(uk.gov.ida.jerseyclient.ErrorHandlingClient) Named(javax.inject.Named) Singleton(javax.inject.Singleton) Provides(com.google.inject.Provides)

Example 5 with ClientProvider

use of uk.gov.ida.restclient.ClientProvider in project verify-hub by alphagov.

the class MatchingServiceRequestSenderTest method setBackOffClient.

private static void setBackOffClient() {
    final List<String> exceptionsToCatch = List.of(ConnectTimeoutException.class.getName(), SocketException.class.getName(), SocketTimeoutException.class.getName(), NoHttpResponseException.class.getName());
    JerseyClientWithRetryBackoffConfiguration jerseyClientConfiguration = aJerseyClientWithRetryBackoffHandlerConfiguration().withTimeout(Duration.seconds(1)).withRetryBackoffPeriod(Duration.seconds(1)).withRetryExceptionList(exceptionsToCatch).withChunkedEncodingEnabled(false).withNumRetries(2).build();
    ClientProvider provider = new ClientProvider(samlSoapProxyApp.getEnvironment(), jerseyClientConfiguration, true, MatchingServiceRequestSenderTest.class.getSimpleName());
    backOffClient = provider.get();
}
Also used : NoHttpResponseException(org.apache.http.NoHttpResponseException) SocketException(java.net.SocketException) SocketTimeoutException(java.net.SocketTimeoutException) ClientProvider(uk.gov.ida.restclient.ClientProvider) JerseyClientWithRetryBackoffConfiguration(uk.gov.ida.configuration.JerseyClientWithRetryBackoffConfiguration) ConnectTimeoutException(org.apache.http.conn.ConnectTimeoutException)

Aggregations

ClientProvider (uk.gov.ida.restclient.ClientProvider)6 Provides (com.google.inject.Provides)5 Singleton (javax.inject.Singleton)5 Client (javax.ws.rs.client.Client)5 DefaultClientProvider (uk.gov.ida.jerseyclient.DefaultClientProvider)5 ErrorHandlingClient (uk.gov.ida.jerseyclient.ErrorHandlingClient)5 JsonClient (uk.gov.ida.jerseyclient.JsonClient)5 RedisClient (io.lettuce.core.RedisClient)3 SocketException (java.net.SocketException)1 SocketTimeoutException (java.net.SocketTimeoutException)1 Named (javax.inject.Named)1 NoHttpResponseException (org.apache.http.NoHttpResponseException)1 ConnectTimeoutException (org.apache.http.conn.ConnectTimeoutException)1 JerseyClientWithRetryBackoffConfiguration (uk.gov.ida.configuration.JerseyClientWithRetryBackoffConfiguration)1 AttributeQueryRequestClient (uk.gov.ida.hub.samlsoapproxy.client.AttributeQueryRequestClient)1 HealthCheckSoapRequestClient (uk.gov.ida.hub.samlsoapproxy.client.HealthCheckSoapRequestClient)1 MatchingServiceHealthCheckClient (uk.gov.ida.hub.samlsoapproxy.client.MatchingServiceHealthCheckClient)1 PrometheusClient (uk.gov.ida.hub.samlsoapproxy.client.PrometheusClient)1 SoapRequestClient (uk.gov.ida.hub.samlsoapproxy.client.SoapRequestClient)1