List of usage examples for org.apache.hadoop.security.alias CredentialProviderFactory CREDENTIAL_PROVIDER_PATH
String CREDENTIAL_PROVIDER_PATH
To view the source code for org.apache.hadoop.security.alias CredentialProviderFactory CREDENTIAL_PROVIDER_PATH.
Click Source Link
From source file:org.apache.zeppelin.realm.LdapRealm.java
License:Apache License
static String getSystemPassword(String hadoopSecurityCredentialPath, String keystorePass) { String password = ""; try {// w ww . j av a 2 s. c o m Configuration configuration = new Configuration(); configuration.set(CredentialProviderFactory.CREDENTIAL_PROVIDER_PATH, hadoopSecurityCredentialPath); CredentialProvider provider = CredentialProviderFactory.getProviders(configuration).get(0); CredentialProvider.CredentialEntry credEntry = provider.getCredentialEntry(keystorePass); if (credEntry != null) { password = new String(credEntry.getCredential()); } } catch (IOException e) { throw new ShiroException("Error from getting credential entry from keystore", e); } if (org.apache.commons.lang.StringUtils.isEmpty(password)) { throw new ShiroException("Error getting SystemPassword from the provided keystore:" + keystorePass + ", in path:" + hadoopSecurityCredentialPath); } return password; }
From source file:uk.gov.gchq.gaffer.slider.util.AccumuloSliderUtils.java
License:Apache License
/** * Retrieves the Accumulo root password from the credential keystores used by an Accumulo instance * * @param appConfig The Slider application configuration for an Accumulo instance * @return The root password/* w w w . j a v a2 s . com*/ * @throws IOException if IOException * @throws URISyntaxException if URISyntaxException */ public static String getRootPassword(final ConfTree appConfig) throws IOException, URISyntaxException { Map<String, List<String>> keystores = SliderKeystoreUtils.getCredentialKeyStores(appConfig); String passwordKeystore = null; // Identify the keystore that is being used to store the Accumulo root user's password for (final Map.Entry<String, List<String>> keystore : keystores.entrySet()) { if (keystore.getValue().contains(CustomAuthenticator.ROOT_INITIAL_PASSWORD_PROPERTY)) { passwordKeystore = keystore.getKey(); } } if (passwordKeystore == null) { throw new IOException("Unable to identify a keystore that contains: " + CustomAuthenticator.ROOT_INITIAL_PASSWORD_PROPERTY); } // Load keystore CommandTestBase.SLIDER_CONFIG.set(CredentialProviderFactory.CREDENTIAL_PROVIDER_PATH, passwordKeystore); CredentialProvider provider = CredentialProviderFactory.getProviders(CommandTestBase.SLIDER_CONFIG).get(0); // Access root password CredentialProvider.CredentialEntry rootPasswordEntry = provider .getCredentialEntry(CustomAuthenticator.ROOT_INITIAL_PASSWORD_PROPERTY); return new String(rootPasswordEntry.getCredential()); }