MemoryCredentialStore

Credential store that keeps credentials in memory.

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

NewMemoryCredentialStore

Creates a new instance of the credential store.

NewMemoryCredentialStore(ctx context.Context, config *config.ConfigParams) *MemoryCredentialStore

  • ctx: context.Context - operation context.
  • config: *config.ConfigParams - (optional) configuration with credential parameters.

NewEmptyMemoryCredentialStore

Creates a new instance of the credential store.

NewEmptyMemoryCredentialStore() *MemoryCredentialScotore

Methods

Configure

Configures component by passing configuration parameters.

(c *MemoryCredentialStore) Configure(ctx context.Context, config *config.ConfigParams)

  • ctx: context.Context - operation context.
  • config: *config.ConfigParams - configuration parameters to be set.

Lookup

Looks up credential parameters by its key.

(c *MemoryCredentialStore) Lookup(ctx context.Context, context IContext, key string) (result *CredentialParams, err error)

  • ctx: context.Context - operation context.
  • context: IContext - (optional) a context to trace execution through a call chain.
  • key: string - key used to uniquely identify the credential.
  • returns: (result *CredentialParams, err error) - found credential parameters or nil if nothing was found

ReadCredentials

Reads credentials from configuration parameters. Each section represents an individual CredentialParams.

(c *MemoryCredentialStore) ReadCredentials(config *config.ConfigParams)

Store

Stores credential parameters into the store.

(c *MemoryCredentialStore) Store(ctx context.Context, context IContext, key string, credential *CredentialParams) error

  • ctx: context.Context - operation context.
  • context: IContext - (optional) a context to trace execution through a call chain.
  • key: string - key to uniquely identify the credential parameters.
  • credential: *CredentialParams - credential parameters to be stored.
  • returns: error - return error if not stored.

Examples

config := NewConfigParamsFromTuples(
	"key1.user", "jdoe",
	"key1.pass", "pass123",
	"key2.user", "bsmith",
	"key2.pass", "mypass"
)
credentialStore := NewEmptyMemoryCredentialStore()
credentialStore.ReadCredentials(config)
res, err := credentialStore.Lookup(context.Backgroudn(), "123", "key1")

See also