Package org.apache.hadoop.security.alias
Class AbstractJavaKeyStoreProvider
java.lang.Object
org.apache.hadoop.security.alias.CredentialProvider
org.apache.hadoop.security.alias.AbstractJavaKeyStoreProvider
- Direct Known Subclasses:
KeyStoreProvider,LocalKeyStoreProvider
Abstract class for implementing credential providers that are based on
Java Keystores as the underlying credential store.
The password for the keystore is taken from the HADOOP_CREDSTORE_PASSWORD
environment variable with a default of 'none'.
It is expected that for access to credential protected resource to copy the
creds from the original provider into the job's Credentials object, which is
accessed via the UserProvider. Therefore, these providers won't be directly
used by MapReduce tasks.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.hadoop.security.alias.CredentialProvider
CredentialProvider.CredentialEntry -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final org.slf4j.LoggerFields inherited from class org.apache.hadoop.security.alias.CredentialProvider
CLEAR_TEXT_FALLBACK -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractJavaKeyStoreProvider(URI uri, Configuration conf) -
Method Summary
Modifier and TypeMethodDescriptionstatic char[]bytesToChars(byte[] bytes) createCredentialEntry(String alias, char[] credential) Create a new credential.protected abstract voidcreatePermissions(String perms) voiddeleteCredentialEntry(String name) Delete the given credential.voidflush()Ensures that any changes to the credentials are written to persistent store.protected abstract StringGet the aliases for all credentials.protected ConfigurationgetConf()getCredentialEntry(String alias) Get the credential entry for a specific alias.protected abstract InputStreamprotected abstract Stringprotected abstract OutputStreamchar[]getPath()protected final Stringprotected abstract StringgetUri()protected voidinitFileSystem(URI keystoreUri) booleanprotected abstract booleanbooleanDoes this provider require a password?If a password for the provider is needed, but is not provided, this will return an error message and instructions for supplying said password to the provider.If a password for the provider is needed, but is not provided, this will return a warning and instructions for supplying said password to the provider.voidsetChanged(boolean chg) voidsetPassword(char[] pass) voidvoidsetReadLock(Lock rl) voidsetWriteLock(Lock wl) protected abstract voidtoString()Methods inherited from class org.apache.hadoop.security.alias.CredentialProvider
isTransient
-
Field Details
-
LOG
public static final org.slf4j.Logger LOG -
CREDENTIAL_PASSWORD_ENV_VAR
- See Also:
-
CREDENTIAL_PASSWORD_FILE_KEY
- See Also:
-
CREDENTIAL_PASSWORD_DEFAULT
- See Also:
-
-
Constructor Details
-
AbstractJavaKeyStoreProvider
- Throws:
IOException
-
-
Method Details
-
getConf
-
getPath
-
setPath
-
getPassword
public char[] getPassword() -
setPassword
public void setPassword(char[] pass) -
isChanged
public boolean isChanged() -
setChanged
public void setChanged(boolean chg) -
getReadLock
-
setReadLock
-
getWriteLock
-
setWriteLock
-
getUri
-
getKeyStore
-
getPathAsString
-
getSchemeName
-
getKeyStoreType
-
getAlgorithm
-
getOutputStreamForKeystore
- Throws:
IOException
-
keystoreExists
- Throws:
IOException
-
getInputStreamForFile
- Throws:
IOException
-
createPermissions
- Throws:
IOException
-
stashOriginalFilePermissions
- Throws:
IOException
-
initFileSystem
- Throws:
IOException
-
getCredentialEntry
Description copied from class:CredentialProviderGet the credential entry for a specific alias.- Specified by:
getCredentialEntryin classCredentialProvider- Parameters:
alias- the name of a specific credential- Returns:
- the credentialEntry
- Throws:
IOException- raised on errors performing I/O.
-
bytesToChars
- Throws:
IOException
-
getAliases
Description copied from class:CredentialProviderGet the aliases for all credentials.- Specified by:
getAliasesin classCredentialProvider- Returns:
- the list of alias names
- Throws:
IOException- raised on errors performing I/O.
-
createCredentialEntry
public CredentialProvider.CredentialEntry createCredentialEntry(String alias, char[] credential) throws IOException Description copied from class:CredentialProviderCreate a new credential. The given alias must not already exist.- Specified by:
createCredentialEntryin classCredentialProvider- Parameters:
alias- the alias of the credentialcredential- the credential value for the alias.- Returns:
- CredentialEntry.
- Throws:
IOException- raised on errors performing I/O.
-
deleteCredentialEntry
Description copied from class:CredentialProviderDelete the given credential.- Specified by:
deleteCredentialEntryin classCredentialProvider- Parameters:
name- the alias of the credential to delete- Throws:
IOException- raised on errors performing I/O.
-
flush
Description copied from class:CredentialProviderEnsures that any changes to the credentials are written to persistent store.- Specified by:
flushin classCredentialProvider- Throws:
IOException- raised on errors performing I/O.
-
needsPassword
Description copied from class:CredentialProviderDoes this provider require a password? This means that a password is required for normal operation, and it has not been found through normal means. If true, the password should be provided by the caller using setPassword().- Overrides:
needsPasswordin classCredentialProvider- Returns:
- Whether or not the provider requires a password
- Throws:
IOException- raised on errors performing I/O.
-
noPasswordWarning
Description copied from class:CredentialProviderIf a password for the provider is needed, but is not provided, this will return a warning and instructions for supplying said password to the provider.- Overrides:
noPasswordWarningin classCredentialProvider- Returns:
- A warning and instructions for supplying the password
-
noPasswordError
Description copied from class:CredentialProviderIf a password for the provider is needed, but is not provided, this will return an error message and instructions for supplying said password to the provider.- Overrides:
noPasswordErrorin classCredentialProvider- Returns:
- An error message and instructions for supplying the password
-
toString
-