public class CredentialStoreServiceImpl extends Object implements CredentialStoreService
Constructor and Description |
---|
CredentialStoreServiceImpl(Configuration configuration,
SecurePasswordHelper securePasswordHelper) |
Modifier and Type | Method and Description |
---|---|
static String |
canonicalizeAlias(String clusterName,
String alias)
Canonicalizes an alias name by making sure that is contains the prefix indicating what cluster it belongs to.
|
boolean |
containsCredential(String clusterName,
String alias)
Tests to see if the requested alias exists in any CredentialStore
|
boolean |
containsCredential(String clusterName,
String alias,
CredentialStoreType credentialStoreType)
Tests to see if the requested alias exists in ether the persistent or the temporary CredentialStore
|
static String |
decanonicalizeAlias(String clusterName,
String canonicaizedAlias)
Removes the prefix (if exists) from the front of a canonicalized alias
|
Credential |
getCredential(String clusterName,
String alias)
Retrieves the specified credential looking in the temporary and then the persistent CredentialStore
|
Credential |
getCredential(String clusterName,
String alias,
CredentialStoreType credentialStoreType)
Retrieves the specified credential looking in ether the persistent or the temporary CredentialStore
|
CredentialStoreType |
getCredentialStoreType(String clusterName,
String alias)
Gets the type of the credential store used to store the requested credential
|
void |
initializePersistedCredentialStore(File credentialStoreLocation,
MasterKeyService masterKeyService) |
void |
initializeTemporaryCredentialStore(long retentionDuration,
TimeUnit units,
boolean activelyPurge) |
boolean |
isInitialized()
Tests this CredentialStoreService to check if it has been properly initialized
|
boolean |
isInitialized(CredentialStoreType credentialStoreType)
Tests this CredentialStoreService to check if ether the persistent or the temporary CredentialStore
has been properly initialized
|
Map<String,CredentialStoreType> |
listCredentials(String clusterName)
Maps the existing alias names to their relevant credential store types.
|
void |
removeCredential(String clusterName,
String alias)
Removes the specified credential from all CredentialStores
|
void |
removeCredential(String clusterName,
String alias,
CredentialStoreType credentialStoreType)
Removes the specified credential from ether the persistent or the temporary CredentialStore
|
void |
setCredential(String clusterName,
String alias,
Credential credential,
CredentialStoreType credentialStoreType)
Adds a new credential to either the persistent or the temporary CredentialStore
The supplied key will be converted into UTF-8 bytes before being stored.
|
@Inject public CredentialStoreServiceImpl(Configuration configuration, SecurePasswordHelper securePasswordHelper)
public void initializeTemporaryCredentialStore(long retentionDuration, TimeUnit units, boolean activelyPurge) throws org.apache.ambari.server.AmbariException
org.apache.ambari.server.AmbariException
public void initializePersistedCredentialStore(File credentialStoreLocation, MasterKeyService masterKeyService) throws org.apache.ambari.server.AmbariException
org.apache.ambari.server.AmbariException
public void setCredential(String clusterName, String alias, Credential credential, CredentialStoreType credentialStoreType) throws org.apache.ambari.server.AmbariException
setCredential
in interface CredentialStoreService
clusterName
- the name of the cluster this credential is related toalias
- a string declaring the alias (or name) of the credentialcredential
- the credential value to storecredentialStoreType
- a CredentialStoreType indicating which credential store facility to useorg.apache.ambari.server.AmbariException
public Credential getCredential(String clusterName, String alias) throws org.apache.ambari.server.AmbariException
CredentialStoreService
getCredential
in interface CredentialStoreService
clusterName
- the name of the cluster the credential is related toalias
- a string declaring the alias (or name) of the credentialorg.apache.ambari.server.AmbariException
- if an error occurs while retrieving the credentialpublic Credential getCredential(String clusterName, String alias, CredentialStoreType credentialStoreType) throws org.apache.ambari.server.AmbariException
CredentialStoreService
getCredential
in interface CredentialStoreService
clusterName
- the name of the cluster this credential is related toalias
- a string declaring the alias (or name) of the credentialcredentialStoreType
- a CredentialStoreType indicating which credential store facility to useorg.apache.ambari.server.AmbariException
- if an error occurs while retrieving the credentialpublic void removeCredential(String clusterName, String alias) throws org.apache.ambari.server.AmbariException
CredentialStoreService
removeCredential
in interface CredentialStoreService
clusterName
- the name of the cluster this credential is related toalias
- a string declaring the alias (or name) of the credentialorg.apache.ambari.server.AmbariException
- if an error occurs while removing the credentialpublic void removeCredential(String clusterName, String alias, CredentialStoreType credentialStoreType) throws org.apache.ambari.server.AmbariException
CredentialStoreService
removeCredential
in interface CredentialStoreService
clusterName
- the name of the cluster this credential is related toalias
- a string declaring the alias (or name) of the credentialcredentialStoreType
- a CredentialStoreType indicating which credential store facility to useorg.apache.ambari.server.AmbariException
- if an error occurs while removing the credentialpublic boolean containsCredential(String clusterName, String alias) throws org.apache.ambari.server.AmbariException
CredentialStoreService
containsCredential
in interface CredentialStoreService
clusterName
- the name of the cluster this credential is related toalias
- a string declaring the alias (or name) of the credentialorg.apache.ambari.server.AmbariException
- if an error occurs while searching for the credentialpublic boolean containsCredential(String clusterName, String alias, CredentialStoreType credentialStoreType) throws org.apache.ambari.server.AmbariException
CredentialStoreService
containsCredential
in interface CredentialStoreService
clusterName
- the name of the cluster this credential is related toalias
- a string declaring the alias (or name) of the credentialcredentialStoreType
- a CredentialStoreType indicating which credential store facility to useorg.apache.ambari.server.AmbariException
- if an error occurs while searching for the credentialpublic CredentialStoreType getCredentialStoreType(String clusterName, String alias) throws org.apache.ambari.server.AmbariException
CredentialStoreService
getCredentialStoreType
in interface CredentialStoreService
clusterName
- the name of the cluster this credential is related toalias
- a string declaring the alias (or name) of the credentialorg.apache.ambari.server.AmbariException
- if an error occurs while searching for the credentialpublic Map<String,CredentialStoreType> listCredentials(String clusterName) throws org.apache.ambari.server.AmbariException
CredentialStoreService
listCredentials
in interface CredentialStoreService
clusterName
- the name of the cluster this credential is related toorg.apache.ambari.server.AmbariException
- if an error occurs while searching for the credentialspublic boolean isInitialized()
CredentialStoreService
isInitialized
in interface CredentialStoreService
public boolean isInitialized(CredentialStoreType credentialStoreType)
CredentialStoreService
isInitialized
in interface CredentialStoreService
credentialStoreType
- a CredentialStoreType indicating which credential store facility to usepublic static String canonicalizeAlias(String clusterName, String alias)
cluster.:clusterName.
, and the
combination is to be converted to have all lowercase characters. For example if the alias was
"external.DB" and the cluster name is "c1", then the canonicalized alias name would be
"cluster.c1.external.db".clusterName
- the name of the clusteralias
- a string declaring the alias (or name) of the credentialpublic static String decanonicalizeAlias(String clusterName, String canonicaizedAlias)
clusterName
- the name the name of the clustercanonicaizedAlias
- the canonicalized alias to processCopyright © 2022 Apache Software Foundation. All rights reserved.