Package co.cask.cdap.security.authentication.client.basic

Examples of co.cask.cdap.security.authentication.client.basic.BasicAuthenticationClient


    this.verifySSLCert = Boolean.valueOf(System.getProperty(PROP_VERIFY_SSL_CERT, "true"));
    this.hostname = Objects.firstNonNull(hostname, "localhost");
    this.port = DEFAULT_PORT;
    this.uri = URI.create(String.format("http://%s:%d", hostname, port));
    this.sslPort = DEFAULT_SSL_PORT;
    AuthenticationClient authenticationClient = new BasicAuthenticationClient();
    authenticationClient.setConnectionInfo(hostname, port, DEFAULT_SSL);
    this.clientConfig = new ClientConfig(hostname, port,
                                         new HttpRequestConfig(15000, 15000, verifySSLCert),
                                         new HttpRequestConfig(0, 0, verifySSLCert),
                                         authenticationClient);
    this.version = tryGetVersion();
View Full Code Here


    if (!SocketUtil.isAvailable(hostname, port)) {
      throw new IOException(String.format("Host %s on port %d could not be reached", hostname, port));
    }

    AuthenticationClient authenticationClient = new BasicAuthenticationClient();
    authenticationClient.setConnectionInfo(hostname, port, ssl);
    Properties properties = new Properties();
    properties.put(BasicAuthenticationClient.VERIFY_SSL_CERT_PROP_NAME, String.valueOf(cliConfig.isVerifySSLCert()));

    if (authenticationClient.isAuthEnabled()) {
      output.printf("Authentication is enabled in the gateway server: %s.\n", hostname);
      ConsoleReader reader = new ConsoleReader();
      for (Credential credential : authenticationClient.getRequiredCredentials()) {
        String prompt = "Please, specify " + credential.getDescription() + "> ";
        String credentialValue;
        if (credential.isSecret()) {
          credentialValue = reader.readLine(prompt, '*');
        } else {
          credentialValue = reader.readLine(prompt);
        }
        properties.put(credential.getName(), credentialValue);
      }
      authenticationClient.configure(properties);
      cliConfig.getClientConfig().setAuthenticationClient(authenticationClient);
      authenticationClient.getAccessToken();
    }

    cliConfig.setConnection(hostname, port, ssl);
    output.printf("Successfully connected CDAP instance at %s:%d\n", hostname, port);
  }
View Full Code Here

TOP

Related Classes of co.cask.cdap.security.authentication.client.basic.BasicAuthenticationClient

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.