@Override public void configure(Properties properties) { if (StringUtils.isNotEmpty(username) || StringUtils.isNotEmpty(password)) { throw new IllegalStateException("Client is already configured!"); } username = properties.getProperty(USERNAME_PROP_NAME); Preconditions.checkArgument(StringUtils.isNotEmpty(username), "The username property cannot be empty."); password = properties.getProperty(PASSWORD_PROP_NAME); Preconditions.checkArgument(StringUtils.isNotEmpty(password), "The password property cannot be empty."); boolean verifySSLCert = Boolean.valueOf(properties.getProperty(VERIFY_SSL_CERT_PROP_NAME, "true")); setVerifySSLCert(verifySSLCert); if (!verifySSLCert) { LOG.info("Disabling SSL certificate check."); } LOG.debug("Basic authentication client is configured successfully."); }
private AuthenticationClient getAuthenticationClient(ConnectionConfig connectionInfo) { AuthenticationClient authenticationClient = new BasicAuthenticationClient(); authenticationClient.setConnectionInfo(connectionInfo.getHostname(), connectionInfo.getPort(), connectionInfo.isSSLEnabled()); return authenticationClient; }
private AuthenticationClient getAuthenticationClient(ConnectionConfig connectionInfo) { AuthenticationClient authenticationClient = new BasicAuthenticationClient(); authenticationClient.setConnectionInfo(connectionInfo.getHostname(), connectionInfo.getPort(), connectionInfo.isSSLEnabled()); return authenticationClient; }
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); properties.setProperty("security.auth.client.verify.ssl.cert", Boolean.toString(getClientConfig().isVerifySSLCert())); final AuthenticationClient authClient = new BasicAuthenticationClient(); authClient.configure(properties); ConnectionConfig connectionConfig = getClientConfig().getConnectionConfig(); authClient.setConnectionInfo(connectionConfig.getHostname(), connectionConfig.getPort(), connectionConfig.isSSLEnabled()); 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(); }