Inherits: IConfigurable, IReferenceable
Description
The CredentialResolver class is used to retrieve component credentials.
Important points
- If credentials are configured to be retrieved from ICredentialStore, it will automatically locate ICredentialStore in component references and retrieve the credentials from there using the store_key parameter.
Configuration parameters
credential:
- store_key: (optional) key to retrieve the credentials from ICredentialStore
- …: other credential parameters
credentials: alternative to credential
- [credential params 1]: first credential parameters
- … : credential parameters for key 1
- …
- [credential params N]: Nth credential parameters
- … : credential parameters for key N
References
- *:credential-store:*:*:1.0 - (optional) Credential stores to resolve credentials
Constructors
Creates a new instance of credentials resolver.
public
CredentialResolver(ConfigParams config = null, IReferences references = null)
- config: ConfigParams - (optional) component configuration parameters
- references: IReferences - (optional) component references
Instance methods
Add
Adds a new credential to component credentials
public
void Add(CredentialParams connection)
- connection: CredentialParams - new credential parameters to be added
Configure
Configures component by passing configuration parameters.
public
void Configure(ConfigParams config, bool configAsDefault = true)
- config: ConfigParams - configuration parameters to be set.
- configAsDefault: bool - boolean parameter for default configuration. If “true” the default value will be added to the result.
GetAll
Gets all credentials configured in component configuration.
Redirect to CredentialStores is not done at this point. If you need fully fleshed credential use the lookup method instead.
public
List<CredentialParams> GetAll()
- returns: List<CredentialParams> - list with credential parameters
LookupAsync
Looks up component credential parameters. If credentials are configured to be retrieved from Credential store it finds a ICredentialStore` and lookups credentials there.
public
Task<CredentialParams> LookupAsync(string correlationId)
- correlationId: string - (optional) transaction id used to trace execution through the call chain.
- returns: Task<CredentialParams> - resolved credential parameters or null if nothing was found.
SetReferences
Sets references to dependent components.
public
void SetReferences(IReferences references)
- references: IReferences - references to locate the component’s dependencies.
Examples
var config = ConfigParams.FromTuples(
"credential.user", "jdoe",
"credential.pass", "pass123"
);
var credentialResolver = new CredentialResolver();
credentialResolver.Configure(config);
credentialResolver.SetReferences(references);
credentialResolver.LookupAsync("123");