com.sun.jersey.api.client.filter.ClientFilter Java Examples

The following examples show how to use com.sun.jersey.api.client.filter.ClientFilter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EurekaClientOAuth2AutoConfiguration.java    From spring-cloud-services-starters with Apache License 2.0 7 votes vote down vote up
@Bean
@ConditionalOnMissingBean(DiscoveryClientOptionalArgs.class)
public DiscoveryClientOptionalArgs discoveryClientOptionalArgs(
		EurekaClientOAuth2Properties eurekaClientOAuth2Properties) {
	List<ClientFilter> filters = new ArrayList<>();
	ClientRegistration clientRegistration = ClientRegistration.withRegistrationId("eureka-client")
			.clientId(eurekaClientOAuth2Properties.getClientId())
			.clientSecret(eurekaClientOAuth2Properties.getClientSecret())
			.tokenUri(eurekaClientOAuth2Properties.getAccessTokenUri())
			.authorizationGrantType(AuthorizationGrantType.CLIENT_CREDENTIALS).build();
	filters.add(new EurekaOAuth2ClientFilterAdapter(clientRegistration));

	DiscoveryClientOptionalArgs args = new DiscoveryClientOptionalArgs();
	args.setAdditionalFilters(filters);

	return args;
}
 
Example #2
Source File: OccurrenceWsClientIT.java    From occurrence with Apache License 2.0 6 votes vote down vote up
@Before
public void init() throws Exception {
  Properties properties = new Properties();
  wsBaseUrl = new URIBuilder(getBaseURI()).setPath(contextPath).toString();
  properties.put("occurrence.ws.url", wsBaseUrl);
  properties.put("httpTimeout", HTTP_TO);
  Injector clientInjector =
    Guice.createInjector(new OccurrenceWsClientModule(properties), new AbstractModule() {
      @Override
      protected void configure() {
        //ClientFilter is required by the OccurrenceDownloadClient for authentication
        bind(ClientFilter.class).toInstance(Mockito.mock(ClientFilter.class));
      }
    });
  client = clientInjector.getInstance(OccurrenceService.class);
}
 
Example #3
Source File: MetadataClient.java    From conductor with Apache License 2.0 5 votes vote down vote up
/**
 * @param config              REST Client configuration
 * @param clientConfiguration Specific properties configured for the client, see {@link ConductorClientConfiguration}
 * @param handler             Jersey client handler. Useful when plugging in various http client interaction modules (e.g. ribbon)
 * @param filters             Chain of client side filters to be applied per request
 */
public MetadataClient(ClientConfig config, ConductorClientConfiguration clientConfiguration, ClientHandler handler, ClientFilter... filters) {
    super(config, clientConfiguration, handler);
    for (ClientFilter filter : filters) {
        super.client.addFilter(filter);
    }
}
 
Example #4
Source File: TaskClient.java    From conductor with Apache License 2.0 5 votes vote down vote up
/**
 * @param config              REST Client configuration
 * @param clientConfiguration Specific properties configured for the client, see {@link ConductorClientConfiguration}
 * @param handler             Jersey client handler. Useful when plugging in various http client interaction modules (e.g. ribbon)
 * @param filters             Chain of client side filters to be applied per request
 */
public TaskClient(ClientConfig config, ConductorClientConfiguration clientConfiguration, ClientHandler handler, ClientFilter... filters) {
    super(config, clientConfiguration, handler);
    for (ClientFilter filter : filters) {
        super.client.addFilter(filter);
    }
}
 
Example #5
Source File: WorkflowClient.java    From conductor with Apache License 2.0 5 votes vote down vote up
/**
 * @param config              REST Client configuration
 * @param clientConfiguration Specific properties configured for the client, see {@link ConductorClientConfiguration}
 * @param handler             Jersey client handler. Useful when plugging in various http client interaction modules (e.g. ribbon)
 * @param filters             Chain of client side filters to be applied per request
 */
public WorkflowClient(ClientConfig config, ConductorClientConfiguration clientConfiguration, ClientHandler handler, ClientFilter... filters) {
    super(config, clientConfiguration, handler);
    for (ClientFilter filter : filters) {
        super.client.addFilter(filter);
    }
}
 
Example #6
Source File: RemoteInstanceRequestClientImpl.java    From exhibitor with Apache License 2.0 5 votes vote down vote up
public RemoteInstanceRequestClientImpl(RemoteConnectionConfiguration configuration)
{
    client = Client.create();
    client.setConnectTimeout(configuration.getConnectionTimeoutMs());
    client.setReadTimeout(configuration.getReadTimeoutMs());
    for ( ClientFilter filter : configuration.getFilters() )
    {
        client.addFilter(filter);
    }
}
 
Example #7
Source File: EurekaOAuth2AutoConfiguration.java    From spring-cloud-services-connector with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean(DiscoveryClientOptionalArgs.class)
public DiscoveryClientOptionalArgs discoveryClientOptionalArgs() {
	List<ClientFilter> filters = new ArrayList<>();
	filters.add(new ClientFilterAdapter(eurekaOauth2RequestDecorator()));

	DiscoveryClientOptionalArgs args = new DiscoveryClientOptionalArgs();
	args.setAdditionalFilters(filters);

	return args;
}
 
Example #8
Source File: WebServicesClient.java    From attic-apex-core with Apache License 2.0 4 votes vote down vote up
public boolean isFilterPresent(ClientFilter clientFilter)
{
  return clientFilters.contains(clientFilter);
}
 
Example #9
Source File: OccurrenceDownloadWsClient.java    From occurrence with Apache License 2.0 4 votes vote down vote up
/**
 * @param resource webapplication root url
 */
@Inject
public OccurrenceDownloadWsClient(WebResource resource, @Nullable ClientFilter authFilter) {
  super(Download.class, resource.path(Constants.OCCURRENCE_DOWNLOAD_PATH), authFilter);
  mapper.getSerializationConfig().addMixInAnnotations(Download.class, LicenseMixin.class);
}
 
Example #10
Source File: MutableDiscoveryClientOptionalArgs.java    From spring-cloud-netflix with Apache License 2.0 4 votes vote down vote up
public Collection<ClientFilter> getAdditionalFilters() {
	return this.additionalFilters;
}
 
Example #11
Source File: MutableDiscoveryClientOptionalArgs.java    From spring-cloud-netflix with Apache License 2.0 4 votes vote down vote up
@Override
public void setAdditionalFilters(Collection<ClientFilter> additionalFilters) {
	additionalFilters = new LinkedHashSet<>(additionalFilters);
	this.additionalFilters = additionalFilters;
	super.setAdditionalFilters(additionalFilters);
}
 
Example #12
Source File: ReplicationClientAdditionalFilters.java    From spring-cloud-netflix with Apache License 2.0 4 votes vote down vote up
public Collection<ClientFilter> getFilters() {
	return this.filters;
}
 
Example #13
Source File: ReplicationClientAdditionalFilters.java    From spring-cloud-netflix with Apache License 2.0 4 votes vote down vote up
public ReplicationClientAdditionalFilters(Collection<ClientFilter> filters) {
	this.filters = new LinkedHashSet<>(filters);
}
 
Example #14
Source File: WebServicesClient.java    From attic-apex-core with Apache License 2.0 4 votes vote down vote up
public void addFilter(ClientFilter clientFilter)
{
  client.addFilter(clientFilter);
  clientFilters.add(clientFilter);
}
 
Example #15
Source File: WebServicesClient.java    From Bats with Apache License 2.0 4 votes vote down vote up
public boolean isFilterPresent(ClientFilter clientFilter)
{
  return clientFilters.contains(clientFilter);
}
 
Example #16
Source File: RemoteConnectionConfiguration.java    From exhibitor with Apache License 2.0 4 votes vote down vote up
public Collection<ClientFilter> getFilters()
{
    return filters;
}
 
Example #17
Source File: RemoteConnectionConfiguration.java    From exhibitor with Apache License 2.0 4 votes vote down vote up
public RemoteConnectionConfiguration(Collection<ClientFilter> filters, int connectionTimeoutMs, int readTimeoutMs)
{
    this.filters = ImmutableList.copyOf(Preconditions.checkNotNull(filters, "filters cannot be null"));
    this.connectionTimeoutMs = connectionTimeoutMs;
    this.readTimeoutMs = readTimeoutMs;
}
 
Example #18
Source File: RemoteConnectionConfiguration.java    From exhibitor with Apache License 2.0 4 votes vote down vote up
public RemoteConnectionConfiguration(Collection<ClientFilter> filters)
{
    this(filters, DEFAULT_CONNECTION_TIMEOUT_MS, DEFAULT_READ_TIMEOUT_MS);
}
 
Example #19
Source File: RemoteConnectionConfiguration.java    From exhibitor with Apache License 2.0 4 votes vote down vote up
public RemoteConnectionConfiguration()
{
    this(Lists.<ClientFilter>newArrayList(), DEFAULT_CONNECTION_TIMEOUT_MS, DEFAULT_READ_TIMEOUT_MS);
}
 
Example #20
Source File: WebServicesClient.java    From Bats with Apache License 2.0 4 votes vote down vote up
public void addFilter(ClientFilter clientFilter)
{
  client.addFilter(clientFilter);
  clientFilters.add(clientFilter);
}
 
Example #21
Source File: WorkflowClient.java    From conductor with Apache License 2.0 2 votes vote down vote up
/**
 * @param config  REST Client configuration
 * @param handler Jersey client handler.  Useful when plugging in various http client interaction modules (e.g. ribbon)
 * @param filters Chain of client side filters to be applied per request
 */
public WorkflowClient(ClientConfig config, ClientHandler handler, ClientFilter... filters) {
    this(config, new DefaultConductorClientConfiguration(), handler, filters);
}
 
Example #22
Source File: TaskClient.java    From conductor with Apache License 2.0 2 votes vote down vote up
/**
 * @param config  REST Client configuration
 * @param handler Jersey client handler. Useful when plugging in various http client interaction modules (e.g. ribbon)
 * @param filters Chain of client side filters to be applied per request
 */
public TaskClient(ClientConfig config, ClientHandler handler, ClientFilter... filters) {
    this(config, new DefaultConductorClientConfiguration(), handler, filters);
}
 
Example #23
Source File: RegistryClientUtil.java    From occurrence with Apache License 2.0 2 votes vote down vote up
/**
 * Sets up a registry DatasetService client avoiding the use of guice as our gbif jackson libraries clash with the
 * hadoop versions.
 * Sets up an http client with a one minute timeout and http support only.
 */
public DatasetService setupDatasetService(String uri) {
  return new DatasetWsClient(httpClient.resource(uri), injector.getInstance(ClientFilter.class));
}
 
Example #24
Source File: RegistryClientUtil.java    From occurrence with Apache License 2.0 2 votes vote down vote up
/**
 * Sets up a DatasetOccurrenceDownloadUsageService client avoiding the use of guice as our gbif jackson libraries
 * clash with the hadoop versions.
 * Sets up an http client with a one minute timeout and http support only.
 */
public DatasetOccurrenceDownloadUsageService setupDatasetUsageService(String uri) {
  return new DatasetOccurrenceDownloadUsageWsClient(httpClient.resource(uri),
                                                    injector.getInstance(ClientFilter.class));
}
 
Example #25
Source File: RegistryClientUtil.java    From occurrence with Apache License 2.0 2 votes vote down vote up
/**
 * Sets up a OccurrenceDownloadService client avoiding the use of guice as our gbif jackson libraries
 * clash with the hadoop versions.
 * Sets up an http client with a one minute timeout and http support only.
 */
public OccurrenceDownloadService setupOccurrenceDownloadService(String uri) {
  return new OccurrenceDownloadWsClient(httpClient.resource(uri), injector.getInstance(ClientFilter.class));
}
 
Example #26
Source File: MetadataClient.java    From conductor with Apache License 2.0 2 votes vote down vote up
/**
 * @param config  config REST Client configuration
 * @param handler handler Jersey client handler. Useful when plugging in various http client interaction modules (e.g. ribbon)
 * @param filters Chain of client side filters to be applied per request
 */
public MetadataClient(ClientConfig config, ClientHandler handler, ClientFilter... filters) {
    this(config, new DefaultConductorClientConfiguration(), handler, filters);
}