com.nhl.bootique.jersey.client.DefaultHttpClientFactory Maven / Gradle / Ivy
package com.nhl.bootique.jersey.client;
import java.util.Map;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.ClientRequestFilter;
import org.glassfish.jersey.client.ClientConfig;
/**
* @since 0.2
*/
public class DefaultHttpClientFactory implements HttpClientFactory {
private ClientConfig config;
private Map authFilters;
public DefaultHttpClientFactory(ClientConfig config, Map authFilters) {
this.authFilters = authFilters;
this.config = config;
}
@Override
public Client newClient() {
return ClientBuilder.newClient(config);
}
@Override
public Client newAuthenticatedClient(String authName) {
ClientRequestFilter filter = authFilters.get(authName);
if (filter == null) {
throw new IllegalArgumentException("No authenticator configured for name: " + authName);
}
return newClient().register(filter);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy