Codota Logo
Config.getOauthToken
Code IndexAdd Codota to your IDE (free)

How to use
getOauthToken
method
in
io.fabric8.kubernetes.client.Config

Best Java code snippets using io.fabric8.kubernetes.client.Config.getOauthToken (Showing top 20 results out of 315)

  • Common ways to obtain Config
private void myMethod () {
Config c =
  • Codota IconString str;new ConfigBuilder().withMasterUrl(str).build()
  • Codota Iconnew Config()
  • Codota Iconnew ConfigBuilder().build()
  • Smart code suggestions by Codota
}
origin: fabric8io/kubernetes-client

 @Override
 public Response intercept(Chain chain) throws IOException {
  Request request = chain.request();
  if (Utils.isNotNullOrEmpty(config.getUsername()) && Utils.isNotNullOrEmpty(config.getPassword())) {
   Request authReq = chain.request().newBuilder().addHeader("Authorization", Credentials.basic(config.getUsername(), config.getPassword())).build();
   return chain.proceed(authReq);
  } else if (Utils.isNotNullOrEmpty(config.getOauthToken())) {
   Request authReq = chain.request().newBuilder().addHeader("Authorization", "Bearer " + config.getOauthToken()).build();
   return chain.proceed(authReq);
  }
  return chain.proceed(request);
 }
}).addInterceptor(new ImpersonatorInterceptor(config))
origin: fabric8io/kubernetes-client

@Test
public void honorClientAuthenticatorCommands() throws Exception {
 if (SystemUtils.IS_OS_WINDOWS) {
  System.setProperty(Config.KUBERNETES_KUBECONFIG_FILE, TEST_KUBECONFIG_EXEC_WIN_FILE);
 } else {
  Files.setPosixFilePermissions(Paths.get(TEST_TOKEN_GENERATOR_FILE), PosixFilePermissions.fromString("rwxrwxr-x"));
  System.setProperty(Config.KUBERNETES_KUBECONFIG_FILE, TEST_KUBECONFIG_EXEC_FILE);
 }
 Config config = Config.autoConfigure(null);
 assertNotNull(config);
 assertEquals("HELLO WORLD", config.getOauthToken());
}
origin: fabric8io/kubernetes-client

@Test
public void testWithKubeConfig() {
 System.setProperty(Config.KUBERNETES_KUBECONFIG_FILE, TEST_KUBECONFIG_FILE);
 Config config = new Config();
 assertNotNull(config);
 assertEquals("https://172.28.128.4:8443/", config.getMasterUrl());
 assertEquals("testns", config.getNamespace());
 assertEquals("token", config.getOauthToken());
 assertTrue(config.getCaCertFile().endsWith("testns/ca.pem".replace("/", File.separator)));
 assertTrue(new File(config.getCaCertFile()).isAbsolute());
}
origin: fabric8io/kubernetes-client

@Test
public void testWithMultipleKubeConfigAndOverrideContext() {
 System.setProperty(Config.KUBERNETES_KUBECONFIG_FILE, TEST_KUBECONFIG_FILE + File.pathSeparator + "some-other-file");
 Config config = Config.autoConfigure("production/172-28-128-4:8443/root");
 assertNotNull(config);
 assertEquals("https://172.28.128.4:8443/", config.getMasterUrl());
 assertEquals("production", config.getNamespace());
 assertEquals("supertoken", config.getOauthToken());
 assertTrue(config.getCaCertFile().endsWith("testns/ca.pem".replace("/", File.separator)));
 assertTrue(new File(config.getCaCertFile()).isAbsolute());
}
origin: fabric8io/kubernetes-client

@Test
public void testWithKubeConfigAndOverrideContext() {
 System.setProperty(Config.KUBERNETES_KUBECONFIG_FILE, TEST_KUBECONFIG_FILE);
 Config config = Config.autoConfigure("production/172-28-128-4:8443/root");
 assertNotNull(config);
 assertEquals("https://172.28.128.4:8443/", config.getMasterUrl());
 assertEquals("production", config.getNamespace());
 assertEquals("supertoken", config.getOauthToken());
 assertTrue(config.getCaCertFile().endsWith("testns/ca.pem".replace("/", File.separator)));
 assertTrue(new File(config.getCaCertFile()).isAbsolute());
}
origin: fabric8io/kubernetes-client

config.setPassword(currentAuthInfo.getPassword());
if (Utils.isNullOrEmpty(config.getOauthToken()) && currentAuthInfo.getAuthProvider() != null && !Utils.isNullOrEmpty(currentAuthInfo.getAuthProvider().getConfig().get(ACCESS_TOKEN))) {
 config.setOauthToken(currentAuthInfo.getAuthProvider().getConfig().get(ACCESS_TOKEN));
} else { // https://kubernetes.io/docs/reference/access-authn-authz/authentication/#client-go-credential-plugins
origin: fabric8io/kubernetes-client

@Test
public void testWithKubeConfigAndSystemProperties() {
 System.setProperty(Config.KUBERNETES_KUBECONFIG_FILE, TEST_KUBECONFIG_FILE);
 System.setProperty(Config.KUBERNETES_MASTER_SYSTEM_PROPERTY, "http://somehost:80");
 Config config = new Config();
 assertNotNull(config);
 assertEquals("http://somehost:80/", config.getMasterUrl());
 assertEquals("testns", config.getNamespace());
 assertEquals("token", config.getOauthToken());
}
origin: fabric8io/kubernetes-client

@Test
public void testWithKubeConfigAndSytemPropertiesAndBuilder() {
 System.setProperty(Config.KUBERNETES_KUBECONFIG_FILE, TEST_KUBECONFIG_FILE);
 System.setProperty(Config.KUBERNETES_MASTER_SYSTEM_PROPERTY, "http://somehost:80");
 Config config = new ConfigBuilder()
  .withNamespace("testns2")
  .build();
 assertNotNull(config);
 assertEquals("http://somehost:80/", config.getMasterUrl());
 assertEquals("token", config.getOauthToken());
 assertEquals("testns2", config.getNamespace());
}
origin: fabric8io/kubernetes-client

config.setKeyStoreFile(Utils.getSystemPropertyOrEnvVar(KUBERNETES_KEYSTORE_FILE_PROPERTY, config.getKeyStoreFile()));
config.setOauthToken(Utils.getSystemPropertyOrEnvVar(KUBERNETES_OAUTH_TOKEN_SYSTEM_PROPERTY, config.getOauthToken()));
config.setUsername(Utils.getSystemPropertyOrEnvVar(KUBERNETES_AUTH_BASIC_USERNAME_SYSTEM_PROPERTY, config.getUsername()));
config.setPassword(Utils.getSystemPropertyOrEnvVar(KUBERNETES_AUTH_BASIC_PASSWORD_SYSTEM_PROPERTY, config.getPassword()));
origin: fabric8io/kubernetes-client

@Test
public void shouldInstantiateClientUsingSerializeDeserialize() throws MalformedURLException {
 DefaultKubernetesClient original = new DefaultKubernetesClient();
 String json = Serialization.asJson(original.getConfiguration());
 DefaultKubernetesClient copy = DefaultKubernetesClient.fromConfig(json);
 Assert.assertEquals(original.getConfiguration().getMasterUrl(), copy.getConfiguration().getMasterUrl());
 Assert.assertEquals(original.getConfiguration().getOauthToken(), copy.getConfiguration().getOauthToken());
 Assert.assertEquals(original.getConfiguration().getNamespace(), copy.getConfiguration().getNamespace());
 Assert.assertEquals(original.getConfiguration().getUsername(), copy.getConfiguration().getUsername());
 Assert.assertEquals(original.getConfiguration().getPassword(), copy.getConfiguration().getPassword());
}
origin: org.domeos/kubernetes-client

 @Override
 public Response intercept(Chain chain) throws IOException {
  Request request = chain.request();
  if (isNotNullOrEmpty(config.getUsername()) && isNotNullOrEmpty(config.getPassword())) {
   Request authReq = chain.request().newBuilder().addHeader("Authorization", Credentials.basic(config.getUsername(), config.getPassword())).build();
   return chain.proceed(authReq);
  } else if (isNotNullOrEmpty(config.getOauthToken())) {
   Request authReq = chain.request().newBuilder().addHeader("Authorization", "Bearer " + config.getOauthToken()).build();
   return chain.proceed(authReq);
  }
  return chain.proceed(request);
 }
});
origin: fabric8io/kubernetes-client

 @Test
 public void shouldInstantiateClientUsingSerializeDeserialize() throws MalformedURLException {
  DefaultOpenShiftClient original = new DefaultOpenShiftClient();
  String json = Serialization.asJson(original.getConfiguration());
  DefaultOpenShiftClient copy = DefaultOpenShiftClient.fromConfig(json);

  Assert.assertEquals(original.getConfiguration().getMasterUrl(), copy.getConfiguration().getMasterUrl());
  Assert.assertEquals(original.getConfiguration().getOauthToken(), copy.getConfiguration().getOauthToken());
  Assert.assertEquals(original.getConfiguration().getNamespace(), copy.getConfiguration().getNamespace());
  Assert.assertEquals(original.getConfiguration().getUsername(), copy.getConfiguration().getUsername());
  Assert.assertEquals(original.getConfiguration().getPassword(), copy.getConfiguration().getPassword());
 }
}
origin: vert-x3/vertx-config

private JsonObject config() {
 String token = client.getConfiguration().getOauthToken();
 if (token == null  || token.trim().isEmpty()) {
  token = "some-token";
 }
 return new JsonObject()
  .put("token", token)
  .put("host", "localhost")
  .put("ssl", false)
  .put("port", port);
}
origin: io.vertx/vertx-service-discovery-bridge-kubernetes

private JsonObject config() {
 String token = client.getConfiguration().getOauthToken();
 if (token == null) {
  token = "some-token";
 }
 return new JsonObject()
  .put("token", token)
  .put("host", "localhost")
  .put("ssl", false)
  .put("port", port);
}
origin: vert-x3/vertx-service-discovery

private JsonObject config() {
 String token = client.getConfiguration().getOauthToken();
 if (token == null) {
  token = "some-token";
 }
 return new JsonObject()
  .put("token", token)
  .put("host", "localhost")
  .put("ssl", false)
  .put("port", port);
}
origin: fabric8io/kubernetes-client

kubernetesConfig.getClientKeyFile(), kubernetesConfig.getClientKeyData(),
kubernetesConfig.getClientKeyAlgo(), kubernetesConfig.getClientKeyPassphrase(),
kubernetesConfig.getUsername(), kubernetesConfig.getPassword(), kubernetesConfig.getOauthToken(),
kubernetesConfig.getWatchReconnectInterval(), kubernetesConfig.getWatchReconnectLimit(),
kubernetesConfig.getConnectionTimeout(), kubernetesConfig.getRequestTimeout(),
origin: EnMasseProject/enmasse

private void ensureCredentialsExist(NamespacedOpenShiftClient client, ServiceBrokerOptions options) {
  Secret secret = client.secrets().withName(options.getServiceCatalogCredentialsSecretName()).get();
  if (secret == null) {
    client.secrets().createNew()
        .editOrNewMetadata()
        .withName(options.getServiceCatalogCredentialsSecretName())
        .addToLabels("app", "enmasse")
        .endMetadata()
        .addToData("token", Base64.getEncoder().encodeToString(client.getConfiguration().getOauthToken().getBytes(StandardCharsets.UTF_8)))
        .done();
  }
}
origin: EnMasseProject/enmasse

@Override
public void start(Future<Void> startPromise) throws Exception {
  SchemaApi schemaApi = KubeSchemaApi.create(client, client.getNamespace(), true);
  CachingSchemaProvider schemaProvider = new CachingSchemaProvider();
  schemaApi.watchSchema(schemaProvider, options.getResyncInterval());
  ensureRouteExists(client, options);
  ensureCredentialsExist(client, options);
  AddressSpaceApi addressSpaceApi = new ConfigMapAddressSpaceApi(client);
  AuthApi authApi = new KubeAuthApi(client, client.getConfiguration().getOauthToken());
  UserApi userApi = createUserApi(options);
  ConsoleProxy consoleProxy = addressSpace -> {
    Route route = client.routes().withName(options.getConsoleProxyRouteName()).get();
    if (route == null) {
      return null;
    }
    return String.format("https://%s/console/%s", route.getSpec().getHost(), addressSpace.getMetadata().getName());
  };
  vertx.deployVerticle(new HTTPServer(addressSpaceApi, schemaProvider, authApi, options.getCertDir(), options.getEnableRbac(), userApi, options.getListenPort(), consoleProxy),
      result -> {
        if (result.succeeded()) {
          log.info("EnMasse Service Broker started");
          startPromise.complete();
        } else {
          startPromise.fail(result.cause());
        }
      });
}
origin: fabric8io/kubernetes-client

assertEquals("http://somehost:80/", config.getMasterUrl());
assertEquals("testns", config.getNamespace());
assertEquals("token", config.getOauthToken());
assertEquals("user", config.getUsername());
assertEquals("pass", config.getPassword());
origin: amoAHCP/vxms

 private void updateKubeConfig(Config kubeConfig, JsonObject config, K8SDiscovery annotation) {
  final String user = ConfigurationUtil.getStringConfiguration(config, USER, annotation.user());
  final String password =
    ConfigurationUtil.getStringConfiguration(config, PASSWORD, annotation.password());
  final String api_token =
    ConfigurationUtil.getStringConfiguration(config, API_TOKEN, annotation.api_token());
  final String master_url =
    ConfigurationUtil.getStringConfiguration(config, MASTER_URL, annotation.master_url());
  final String namespace =
    ConfigurationUtil.getStringConfiguration(config, NAMESPACE, annotation.namespace());
  if (StringUtil.isNullOrEmpty(kubeConfig.getUsername())) kubeConfig.setUsername(user);
  if (StringUtil.isNullOrEmpty(kubeConfig.getPassword())) kubeConfig.setPassword(password);
  if (StringUtil.isNullOrEmpty(kubeConfig.getOauthToken())) kubeConfig.setOauthToken(api_token);
  if (StringUtil.isNullOrEmpty(kubeConfig.getMasterUrl())) kubeConfig.setMasterUrl(master_url);
  if (StringUtil.isNullOrEmpty(kubeConfig.getNamespace())) kubeConfig.setNamespace(namespace);
  // check oauthToken
  if (StringUtil.isNullOrEmpty(kubeConfig.getOauthToken()))
   kubeConfig.setOauthToken(TokenUtil.getAccountToken());
 }
}
io.fabric8.kubernetes.clientConfiggetOauthToken

Popular methods of Config

  • getMasterUrl
  • getNamespace
  • getPassword
  • getUsername
  • getCaCertData
  • getClientCertData
  • getClientKeyData
  • getClientKeyPassphrase
  • getCaCertFile
  • getClientCertFile
  • getClientKeyAlgo
  • getClientKeyFile
  • getClientKeyAlgo,
  • getClientKeyFile,
  • getRequestTimeout,
  • isTrustCerts,
  • autoConfigure,
  • getApiVersion,
  • getConnectionTimeout,
  • getRollingTimeout,
  • <init>

Popular in Java

  • Making http post requests using okhttp
  • compareTo (BigDecimal)
  • runOnUiThread (Activity)
  • addToBackStack (FragmentTransaction)
  • InputStreamReader (java.io)
    An InputStreamReader is a bridge from byte streams to character streams: It reads bytes and decodes
  • ConnectException (java.net)
    A ConnectException is thrown if a connection cannot be established to a remote host on a specific po
  • GregorianCalendar (java.util)
    GregorianCalendar is a concrete subclass of Calendarand provides the standard calendar used by most
  • TreeSet (java.util)
    A NavigableSet implementation based on a TreeMap. The elements are ordered using their Comparable, o
  • Executor (java.util.concurrent)
    An object that executes submitted Runnable tasks. This interface provides a way of decoupling task s
  • SAXParseException (org.xml.sax)
    Encapsulate an XML parse error or warning.This exception may include information for locating the er
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now