io.fabric8.kubernetes.client.utils.ImpersonatorInterceptor Java Examples

The following examples show how to use io.fabric8.kubernetes.client.utils.ImpersonatorInterceptor. 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: OpenShiftClientFactory.java    From che with Eclipse Public License 2.0 5 votes vote down vote up
private OpenShiftClient createOC(Config config) {
  OkHttpClient clientHttpClient =
      getHttpClient().newBuilder().authenticator(Authenticator.NONE).build();
  OkHttpClient.Builder builder = clientHttpClient.newBuilder();
  builder.interceptors().clear();
  clientHttpClient =
      builder
          .addInterceptor(
              new OpenShiftOAuthInterceptor(clientHttpClient, OpenShiftConfig.wrap(config)))
          .addInterceptor(new ImpersonatorInterceptor(config))
          .build();

  return new UnclosableOpenShiftClient(clientHttpClient, config);
}
 
Example #2
Source File: KubernetesClientFactory.java    From che with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Creates instance of {@link KubernetesClient} that uses an {@link OkHttpClient} instance derived
 * from the shared {@code httpClient} instance in which interceptors are overridden to
 * authenticate with the credentials (user/password or Oauth token) contained in the {@code
 * config} parameter.
 */
private KubernetesClient create(Config config) {
  OkHttpClient clientHttpClient =
      httpClient.newBuilder().authenticator(Authenticator.NONE).build();
  OkHttpClient.Builder builder = clientHttpClient.newBuilder();
  builder.interceptors().clear();
  clientHttpClient =
      builder
          .addInterceptor(buildKubernetesInterceptor(config))
          .addInterceptor(new ImpersonatorInterceptor(config))
          .build();

  return new UnclosableKubernetesClient(clientHttpClient, config);
}
 
Example #3
Source File: DefaultOpenShiftClient.java    From kubernetes-client with Apache License 2.0 5 votes vote down vote up
private static OkHttpClient clientWithOpenShiftOAuthInterceptor(OkHttpClient httpClient, Config config) {
  OkHttpClient.Builder builder = httpClient != null ?
    httpClient.newBuilder().authenticator(Authenticator.NONE) :
    new OkHttpClient.Builder().authenticator(Authenticator.NONE);

  builder.interceptors().clear();
  return builder.addInterceptor(new OpenShiftOAuthInterceptor(httpClient, OpenShiftConfig.wrap(config)))
    .addInterceptor(new ImpersonatorInterceptor(config))
    .addInterceptor(new BackwardsCompatibilityInterceptor())
    .build();
}