public final class CredentialStore extends Object
Provider
.Modifier and Type | Class and Description |
---|---|
static class |
CredentialStore.CredentialSourceProtectionParameter
A protection parameter which uses a credential source to acquire a credential to use.
|
static interface |
CredentialStore.ProtectionParameter
The protection parameter to use when accessing a credential store or entry.
|
Modifier and Type | Field and Description |
---|---|
static String |
CREDENTIAL_STORE_TYPE
JCA service type for a credential store.
|
Modifier and Type | Method and Description |
---|---|
<C extends Credential> |
exists(String credentialAlias,
Class<C> credentialType)
Check whether credential store has an entry associated with the given credential alias of specified credential type.
|
void |
flush()
Flush the contents of this credential store to storage.
|
Set<String> |
getAliases()
Returns
Set<String> stored in this store. |
static CredentialStore |
getInstance(String algorithm)
Get a
CredentialStore instance. |
static CredentialStore |
getInstance(String algorithm,
Provider provider)
Get a
CredentialStore instance. |
static CredentialStore |
getInstance(String algorithm,
String providerName)
Get a
CredentialStore instance. |
static CredentialStore |
getInstance(String algorithm,
String providerName,
Supplier<Provider[]> providers)
Get a
CredentialStore instance. |
static CredentialStore |
getInstance(String algorithm,
Supplier<Provider[]> providers)
Get a
CredentialStore instance. |
Provider |
getProvider()
Returns
Provider which provides CredentialStoreSpi for this instance. |
String |
getType()
Returns JCA service type of
CredentialStoreSpi for this instance. |
void |
initialize(Map<String,String> attributes)
Initialize Credential Store service with given attributes.
|
void |
initialize(Map<String,String> attributes,
CredentialStore.ProtectionParameter protectionParameter)
Initialize Credential Store service with given attributes.
|
void |
initialize(Map<String,String> attributes,
CredentialStore.ProtectionParameter protectionParameter,
Provider[] providers)
Initialize Credential Store service with given attributes.
|
boolean |
isInitialized()
Checks whether underlying credential store is initialized.
|
boolean |
isModifiable()
Check if credential store supports modification of actual store
|
void |
remove(String credentialAlias,
Class<? extends Credential> credentialType)
Remove the credentialType with from given alias matching the given criteria from the store.
|
void |
remove(String credentialAlias,
Class<? extends Credential> credentialType,
String credentialAlgorithm)
Remove the credentialType with from given alias matching the given criteria from the store.
|
void |
remove(String credentialAlias,
Class<? extends Credential> credentialType,
String credentialAlgorithm,
AlgorithmParameterSpec parameterSpec)
Remove the credentialType with from given alias matching the given criteria from the store.
|
<C extends Credential> |
retrieve(String credentialAlias,
Class<C> credentialType)
Retrieve credential stored in the store under the key and of the credential type
|
<C extends Credential> |
retrieve(String credentialAlias,
Class<C> credentialType,
String credentialAlgorithm)
Retrieve credential stored in the store under the key and of the credential type.
|
<C extends Credential> |
retrieve(String credentialAlias,
Class<C> credentialType,
String credentialAlgorithm,
AlgorithmParameterSpec parameterSpec)
Retrieve credential stored in the store under the key and of the credential type.
|
<C extends Credential> |
retrieve(String credentialAlias,
Class<C> credentialType,
String credentialAlgorithm,
AlgorithmParameterSpec parameterSpec,
CredentialStore.ProtectionParameter protectionParameter)
Retrieve credential stored in the store under the key and of the credential type.
|
<C extends Credential> |
store(String credentialAlias,
C credential)
Store credential to the store under the given alias.
|
<C extends Credential> |
store(String credentialAlias,
C credential,
CredentialStore.ProtectionParameter protectionParameter)
Store credential to the store under the given alias.
|
public static final String CREDENTIAL_STORE_TYPE
public static CredentialStore getInstance(String algorithm) throws NoSuchAlgorithmException
CredentialStore
instance. The returned CredentialStore object will implement the given algorithm.algorithm
- the name of the algorithmCredentialStore
instanceNoSuchAlgorithmException
- if the given algorithm has no available implementationspublic static CredentialStore getInstance(String algorithm, Supplier<Provider[]> providers) throws NoSuchAlgorithmException
CredentialStore
instance. The returned CredentialStore object will implement the given algorithm.algorithm
- the name of the algorithmproviders
- supplier of provider instances to search.CredentialStore
instanceNoSuchAlgorithmException
- if the given algorithm has no available implementationspublic static CredentialStore getInstance(String algorithm, String providerName) throws NoSuchAlgorithmException, NoSuchProviderException
CredentialStore
instance. The returned CredentialStore object will implement the given algorithm.algorithm
- the name of the algorithmproviderName
- the name of the provider to useCredentialStore
instanceNoSuchAlgorithmException
- if the given algorithm has no available implementationsNoSuchProviderException
- if given provider name cannot match any registered Provider
public static CredentialStore getInstance(String algorithm, String providerName, Supplier<Provider[]> providers) throws NoSuchAlgorithmException, NoSuchProviderException
CredentialStore
instance. The returned CredentialStore object will implement the given algorithm.algorithm
- the name of the algorithmproviderName
- the name of the provider to useproviders
- supplier of provider instances to searchCredentialStore
instanceNoSuchAlgorithmException
- if the given algorithm has no available implementationsNoSuchProviderException
- if given provider name cannot match any registered Provider
public static CredentialStore getInstance(String algorithm, Provider provider) throws NoSuchAlgorithmException
CredentialStore
instance. The returned CredentialStore object will implement the given algorithm.algorithm
- the name of the algorithmprovider
- the provider to useCredentialStore
instanceNoSuchAlgorithmException
- if the given algorithm has no available implementationspublic void initialize(Map<String,String> attributes, CredentialStore.ProtectionParameter protectionParameter, Provider[] providers) throws CredentialStoreException
CredentialStoreSpi.initialized
after successful initialization.attributes
- attributes to used to pass information to Credential Store serviceprotectionParameter
- the protection parameter to use when accessing the storeproviders
- providers to be injected into SPI implementation to get custom object instances of various type fromCredentialStoreException
- if initialization fails due to any reasonpublic void initialize(Map<String,String> attributes, CredentialStore.ProtectionParameter protectionParameter) throws CredentialStoreException
CredentialStoreSpi.initialized
after successful initialization.attributes
- attributes to used to pass information to Credential Store serviceprotectionParameter
- the protection parameter to use when accessing the storeCredentialStoreException
- if initialization fails due to any reasonpublic void initialize(Map<String,String> attributes) throws CredentialStoreException
CredentialStoreSpi.initialized
after successful initialization.attributes
- attributes to used to pass information to Credential Store serviceCredentialStoreException
- if initialization fails due to any reasonpublic boolean isInitialized()
true
in case of initialization passed successfully, false
otherwise.public boolean isModifiable()
public <C extends Credential> boolean exists(String credentialAlias, Class<C> credentialType) throws CredentialStoreException, UnsupportedCredentialTypeException
C
- the class of type to which should be credential castedcredentialAlias
- alias to check existencecredentialType
- to check existence in the credential storeCredentialStoreException
- when there is a problem with credential storeUnsupportedCredentialTypeException
- when the credentialType is not supportedpublic <C extends Credential> void store(String credentialAlias, C credential) throws CredentialStoreException, UnsupportedCredentialTypeException
CredentialStoreSpi
supports storing of multiple entries (credential types) per alias.
Each must be of different credential type.C
- the class of type to which should be credential castedcredentialAlias
- to store the credential to the storecredential
- instance of Credential
to storeCredentialStoreException
- when the credential cannot be storedUnsupportedCredentialTypeException
- when the credentialType is not supportedpublic <C extends Credential> void store(String credentialAlias, C credential, CredentialStore.ProtectionParameter protectionParameter) throws CredentialStoreException, UnsupportedCredentialTypeException
CredentialStoreSpi
supports storing of multiple entries (credential types) per alias.
Each must be of different credential type.C
- the class of type to which should be credential castedcredentialAlias
- to store the credential to the storecredential
- instance of Credential
to storeprotectionParameter
- the protection parameter to use, or null
for noneCredentialStoreException
- when the credential cannot be storedUnsupportedCredentialTypeException
- when the credentialType is not supportedpublic <C extends Credential> C retrieve(String credentialAlias, Class<C> credentialType) throws CredentialStoreException, UnsupportedCredentialTypeException
C
- the class of type to which should be credential castedcredentialAlias
- to find the credential in the storecredentialType
- - credential type to retrieve from under the credentialAlias from the storeCredential
stored in the storeCredentialStoreException
- - if credentialAlias credentialType combination doesn't exist or credentialAlias cannot be retrievedUnsupportedCredentialTypeException
- when the credentialType is not supportedpublic <C extends Credential> C retrieve(String credentialAlias, Class<C> credentialType, String credentialAlgorithm) throws CredentialStoreException
C
- the class of type to which should be credential castedcredentialAlias
- to find the credential in the storecredentialType
- credential type to retrieve from under the credentialAlias from the storecredentialAlgorithm
- the credential algorithm to match, or null
to match anyCredential
stored in the storeCredentialStoreException
- if credentialAlias credentialType combination doesn't exist or credentialAlias cannot be retrievedpublic <C extends Credential> C retrieve(String credentialAlias, Class<C> credentialType, String credentialAlgorithm, AlgorithmParameterSpec parameterSpec) throws CredentialStoreException
C
- the class of type to which should be credential castedcredentialAlias
- to find the credential in the storecredentialType
- credential type to retrieve from under the credentialAlias from the storecredentialAlgorithm
- the credential algorithm to match, or null
to match anyparameterSpec
- the parameter specification to match, or null
to match anyCredential
stored in the storeCredentialStoreException
- if credentialAlias credentialType combination doesn't exist or credentialAlias cannot be retrievedpublic <C extends Credential> C retrieve(String credentialAlias, Class<C> credentialType, String credentialAlgorithm, AlgorithmParameterSpec parameterSpec, CredentialStore.ProtectionParameter protectionParameter) throws CredentialStoreException
C
- the class of type to which should be credential castedcredentialAlias
- to find the credential in the storecredentialType
- credential type to retrieve from under the credentialAlias from the storecredentialAlgorithm
- the credential algorithm to match, or null
to match anyparameterSpec
- the parameter specification to match, or null
to match anyprotectionParameter
- the protection parameter to use, or null
to use noneCredential
stored in the storeCredentialStoreException
- if credentialAlias credentialType combination doesn't exist or credentialAlias cannot be retrievedpublic void remove(String credentialAlias, Class<? extends Credential> credentialType) throws CredentialStoreException
credentialAlias
- alias to remove credential(s) fromcredentialType
- credential type to match (must not be null
)CredentialStoreException
- if credential removal failspublic void remove(String credentialAlias, Class<? extends Credential> credentialType, String credentialAlgorithm) throws CredentialStoreException
credentialAlias
- alias to remove credential(s) fromcredentialType
- credential type to match (must not be null
)credentialAlgorithm
- the algorithm name to match, or null
to match anyCredentialStoreException
- if credential removal failspublic void remove(String credentialAlias, Class<? extends Credential> credentialType, String credentialAlgorithm, AlgorithmParameterSpec parameterSpec) throws CredentialStoreException
credentialAlias
- alias to remove credential(s) fromcredentialType
- credential type to match (must not be null
)credentialAlgorithm
- the algorithm name to match, or null
to match anyparameterSpec
- the parameters to match, or null
to match anyCredentialStoreException
- if credential removal failspublic Set<String> getAliases() throws UnsupportedOperationException, CredentialStoreException
Set<String>
stored in this store.Set<String>
of all keys stored in this storeUnsupportedOperationException
- when this method is not supported by the underlying credential storeCredentialStoreException
- if there is any problem with internal storepublic void flush() throws CredentialStoreException
CredentialStoreException
- if flushing the store fails for some reasonpublic Provider getProvider()
Provider
which provides CredentialStoreSpi
for this instance.Provider
of this CredentialStoreSpi
public String getType()
CredentialStoreSpi
for this instance.CredentialStoreSpi
Copyright © 2020 JBoss by Red Hat. All rights reserved.