Package org.pipservices3.components.auth
Class MemoryCredentialStore
java.lang.Object
org.pipservices3.components.auth.MemoryCredentialStore
- All Implemented Interfaces:
org.pipservices3.commons.config.IConfigurable
,org.pipservices3.commons.config.IReconfigurable
,ICredentialStore
public class MemoryCredentialStore extends Object implements ICredentialStore, org.pipservices3.commons.config.IReconfigurable
Credential store that keeps credentials in memory.
### Configuration parameters ###
- [credential key 1]:
- ... credential parameters for key 1
- [credential key 2]:
- ... credential parameters for key N
### Example ###
ConfigParams config = ConfigParams.fromTuples(
"key1.user", "jdoe",
"key1.pass", "pass123",
"key2.user", "bsmith",
"key2.pass", "mypass"
);
MemoryCredentialStore credentialStore = new MemoryCredentialStore();
credentialStore.readCredentials(config);
credentialStore.lookup("123", "key1");
- See Also:
ICredentialStore
,CredentialParams
-
Constructor Summary
Constructors Constructor Description MemoryCredentialStore()
Creates a new instance of the credential store.MemoryCredentialStore(org.pipservices3.commons.config.ConfigParams credentials)
Creates a new instance of the credential store. -
Method Summary
Modifier and Type Method Description void
configure(org.pipservices3.commons.config.ConfigParams config)
Configures component by passing configuration parameters.CredentialParams
lookup(String correlationId, String key)
Lookups credential parameters by its key.void
readCredentials(org.pipservices3.commons.config.ConfigParams credentials)
Reads credentials from configuration parameters.void
store(String correlationId, String key, CredentialParams credential)
Stores credential parameters into the store.
-
Constructor Details
-
MemoryCredentialStore
public MemoryCredentialStore()Creates a new instance of the credential store. -
MemoryCredentialStore
public MemoryCredentialStore(org.pipservices3.commons.config.ConfigParams credentials)Creates a new instance of the credential store.- Parameters:
credentials
- (optional) configuration with credential parameters.
-
-
Method Details
-
configure
public void configure(org.pipservices3.commons.config.ConfigParams config)Configures component by passing configuration parameters.- Specified by:
configure
in interfaceorg.pipservices3.commons.config.IConfigurable
- Parameters:
config
- configuration parameters to be set.
-
readCredentials
public void readCredentials(org.pipservices3.commons.config.ConfigParams credentials)Reads credentials from configuration parameters. Each section represents an individual CredentialParams- Parameters:
credentials
- configuration parameters to be read
-
store
Stores credential parameters into the store.- Specified by:
store
in interfaceICredentialStore
- Parameters:
correlationId
- (optional) transaction id to trace execution through call chain.key
- a key to uniquely identify the credential parameters.credential
- a credential parameters to be stored.
-
lookup
Lookups credential parameters by its key.- Specified by:
lookup
in interfaceICredentialStore
- Parameters:
correlationId
- (optional) transaction id to trace execution through call chain.key
- a key to uniquely identify the credential parameters.- Returns:
- resolved credential parameters or null if nothing was found.
-