Search in sources :

Example 1 with BasicAuthenticationClient

use of co.cask.cdap.security.authentication.client.basic.BasicAuthenticationClient in project cdap by caskdata.

the class CLIConfig method getAuthenticationClient.

private AuthenticationClient getAuthenticationClient(ConnectionConfig connectionInfo) {
    AuthenticationClient authenticationClient = new BasicAuthenticationClient();
    authenticationClient.setConnectionInfo(connectionInfo.getHostname(), connectionInfo.getPort(), connectionInfo.isSSLEnabled());
    return authenticationClient;
}
Also used : BasicAuthenticationClient(co.cask.cdap.security.authentication.client.basic.BasicAuthenticationClient) AuthenticationClient(co.cask.cdap.security.authentication.client.AuthenticationClient) BasicAuthenticationClient(co.cask.cdap.security.authentication.client.basic.BasicAuthenticationClient)

Example 2 with BasicAuthenticationClient

use of co.cask.cdap.security.authentication.client.basic.BasicAuthenticationClient in project cdap by caskdata.

the class IntegrationTestBase method fetchAccessToken.

protected AccessToken fetchAccessToken(String username, String password) throws IOException, TimeoutException, InterruptedException {
    Properties properties = new Properties();
    properties.setProperty("security.auth.client.username", username);
    properties.setProperty("security.auth.client.password", password);
    final AuthenticationClient authClient = new BasicAuthenticationClient();
    authClient.configure(properties);
    ConnectionConfig connectionConfig = getClientConfig().getConnectionConfig();
    authClient.setConnectionInfo(connectionConfig.getHostname(), connectionConfig.getPort(), false);
    checkServicesWithRetry(new Callable<Boolean>() {

        @Override
        public Boolean call() throws Exception {
            return authClient.getAccessToken() != null;
        }
    }, "Unable to connect to Authentication service to obtain access token, Connection info : " + connectionConfig);
    return authClient.getAccessToken();
}
Also used : BasicAuthenticationClient(co.cask.cdap.security.authentication.client.basic.BasicAuthenticationClient) Properties(java.util.Properties) AuthenticationClient(co.cask.cdap.security.authentication.client.AuthenticationClient) BasicAuthenticationClient(co.cask.cdap.security.authentication.client.basic.BasicAuthenticationClient) ConnectionConfig(co.cask.cdap.client.config.ConnectionConfig) TimeoutException(java.util.concurrent.TimeoutException) UnauthorizedException(co.cask.cdap.security.spi.authorization.UnauthorizedException) IOException(java.io.IOException) UnauthenticatedException(co.cask.cdap.common.UnauthenticatedException)

Aggregations

AuthenticationClient (co.cask.cdap.security.authentication.client.AuthenticationClient)2 BasicAuthenticationClient (co.cask.cdap.security.authentication.client.basic.BasicAuthenticationClient)2 ConnectionConfig (co.cask.cdap.client.config.ConnectionConfig)1 UnauthenticatedException (co.cask.cdap.common.UnauthenticatedException)1 UnauthorizedException (co.cask.cdap.security.spi.authorization.UnauthorizedException)1 IOException (java.io.IOException)1 Properties (java.util.Properties)1 TimeoutException (java.util.concurrent.TimeoutException)1