protected AdminLoginManager getAdminLoginManager(HostConfig host) { if (credentialsProvider == null) { logger.info("No admin login manager required because no login credentials were configured"); return null; } else { final LoginCredentials credentials = credentialsProvider.getCredentials(); logger.info("Bootstrapping the admin login manager at [{}] as [{}]", host, credentials.getUsername()); final AdminLoginManager result = new AdminLoginManager(credentials.getUsername(), true); try { final boolean bootstrapped = result.bootstrap(host.getHost(), host.getPort(), credentials); if (!bootstrapped) { throw new OpenMetricsReaderException("Failed to bootstrap the admin login manager at [" + host.toString() + "] as [" + credentials.getUsername() + "]"); } } catch (AuthenticationFailureException e) { throw new OpenMetricsReaderException("Failed to bootstrap the admin login manager due to authentication failure", e); } return result; } }
protected void connectStore() { final LoginCredentials credentials = credentialsProvider.getCredentials(); final Properties securityProps = createSecurityProperties(config.getTrustFile()); final KVStoreConfig kvStoreConfig = new KVStoreConfig(config.getStoreName(), helperHosts); kvStoreConfig.setSecurityProperties(securityProps); logger.info("Connecting to the secured kv store [{}] at {} as [{}]", kvStoreConfig.getStoreName(), helperHosts, credentials.getUsername()); try { final KVStore store = KVStoreFactory.getStore(kvStoreConfig, credentials, KVStoreLogin.makeReauthenticateHandler(credentialsProvider)); IOUtils.closeQuietly(store); } catch (FaultException e) { throw new OpenMetricsReaderException("Failed to connect to store", e); } }