Implements: ICredentialStore, IReconfigurable
Description
The MemoryCredentialStore class is used to create credential stores that keep their contained credentials in memory.
Configuration parameters
- [credential key 1]:
- … : credential parameters for key 1
- [credential key 2]:
- … : credential parameters for key N
- … :
References
- *:credential-store:*:*:1.0 - (optional) Credential stores to resolve credentials
Constructors
Creates a new instance of the credential store.
public
constructor(config: ConfigParams = null)
- config: ConfigParams - (optional) configuration with credential parameters.
Instance methods
configure
Configures component by passing configuration parameters.
public
configure(config: ConfigParams): void
- config: ConfigParams - configuration parameters to be set.
lookup
Lookups credential parameters by its key.
public
lookup(correlationId: string, key: string): Promise<CredentialParams>
- correlationId: string - (optional) transaction id to trace execution through call chain.
- key: string - a key to uniquely identify the credential.
- returns: Promise<CredentialParams> - found credential parameters or null if nothing was found
readCredentials
Reads credentials from configuration parameters. Each section represents an individual CredentialParams.
public
readCredentials(config: ConfigParams): void
- config: ConfigParams - configuration parameters to be read
store
Stores credential parameters into the store.
public
store(correlationId: string, key: string, credential: CredentialParams): Promise<void>
- correlationId: string - (optional) transaction id to trace execution through call chain.
- key: string - a key to uniquely identify the credential parameters.
- credential: CredentialParams - a credential parameters to be stored.
Examples
let config = ConfigParams.fromTuples(
"key1.user", "jdoe",
"key1.pass", "pass123",
"key2.user", "bsmith",
"key2.pass", "mypass"
);
let credentialStore = new MemoryCredentialStore();
credentialStore.readCredentials(config);
let credential = await credentialStore.lookup("123", "key1");
// Result: user=jdoe;pass=pass123