Table of Contents

Class CredHubClient

Namespace
Steeltoe.Security.DataProtection.CredHub
Assembly
Steeltoe.Security.DataProtection.CredHubBase.dll
[Obsolete("This feature will be removed in the next major version. See https://steeltoe.io/docs/v3/obsolete for details.")]
public class CredHubClient : ICredHubClient
Inheritance
CredHubClient
Implements
Inherited Members

Constructors

CredHubClient(bool)

public CredHubClient(bool validateCertificates = true)

Parameters

validateCertificates bool

Methods

AddPermissionsAsync(string, List<CredentialPermission>)

Add permissions to an existing credential.

public Task<List<CredentialPermission>> AddPermissionsAsync(string name, List<CredentialPermission> permissions)

Parameters

name string
permissions List<CredentialPermission>

A collection of permissions to add

Returns

Task<List<CredentialPermission>>

List of permissions

BulkRegenerateAsync(string)

Regenerate all certificates generated by a given certificate authority

public Task<RegeneratedCertificates> BulkRegenerateAsync(string certificateAuthority)

Parameters

certificateAuthority string

Name of certificate authority used to generate certificates that should be regenerated

Returns

Task<RegeneratedCertificates>

List of regenerated certificates

CreateUAAClientAsync(CredHubOptions, ILogger, HttpClient)

Initialize a CredHub Client with user credentials for the appropriate UAA server

public static Task<CredHubClient> CreateUAAClientAsync(CredHubOptions credHubOptions, ILogger logger = null, HttpClient httpClient = null)

Parameters

credHubOptions CredHubOptions

CredHub client configuration values

logger ILogger

Pass in a logger if you want logs

httpClient HttpClient

Primarily for tests, optionally provide your own http client

Returns

Task<CredHubClient>

An initialized CredHub client (using UAA OAuth)

DeleteByNameAsync(string)

Delete a credential by its full name.

public Task<bool> DeleteByNameAsync(string name)

Parameters

name string

the name of the credential; must not be null

Returns

Task<bool>

Boolean indicating success/failure

DeleteByNameInternalAsync(string)

public Task<bool> DeleteByNameInternalAsync(string name)

Parameters

name string

Returns

Task<bool>

DeletePermissionAsync(string, string)

Delete a permission associated with a credential.

public Task<bool> DeletePermissionAsync(string name, string actor)

Parameters

name string
actor string

the actor of the permission; must not be null

Returns

Task<bool>

Returns true if deleted, false if failed

FindByNameAsync(string)

Search for credentials with a full or partial name.

public Task<List<FoundCredential>> FindByNameAsync(string name)

Parameters

name string

The name of the credential; must not be null

Returns

Task<List<FoundCredential>>

A summary of the credential search results

FindByPathAsync(string)

Find a credential using a path.

public Task<List<FoundCredential>> FindByPathAsync(string path)

Parameters

path string

The path to the credential; must not be null

Returns

Task<List<FoundCredential>>

A summary of the credential search results

GenerateAsync<T>(CredHubGenerateRequest)

Generate a new credential in CredHub, or overwrite an existing credential with a new generated value.

public Task<CredHubCredential<T>> GenerateAsync<T>(CredHubGenerateRequest requestParameters)

Parameters

requestParameters CredHubGenerateRequest

Parameters for the new credential to be generated in CredHub

Returns

Task<CredHubCredential<T>>

The details of the generated credential

Type Parameters

T

Type of CredHub credential to be generated

GetByIdAsync<T>(Guid)

Retrieve a credential using its ID, as returned in a write request.

public Task<CredHubCredential<T>> GetByIdAsync<T>(Guid id)

Parameters

id Guid

ID of the credential; must not be null

Returns

Task<CredHubCredential<T>>

The details of the retrieved credential

Type Parameters

T

Type of CredHub credential to be retrieved

GetByNameAsync<T>(string)

Retrieve a credential using its name, as passed to a write request. Only the current credential value will be returned.

public Task<CredHubCredential<T>> GetByNameAsync<T>(string name)

Parameters

name string

Name of the credential; must not be null

Returns

Task<CredHubCredential<T>>

The details of the retrieved credential

Type Parameters

T

Type of CredHub credential to be retrieved

GetByNameWithHistoryAsync<T>(string, int)

Retrieve a credential using its name, as passed to a write request. A collection of all stored values for the named credential will be returned, including historical values.

public Task<List<CredHubCredential<T>>> GetByNameWithHistoryAsync<T>(string name, int entries = 10)

Parameters

name string

Name of the credential; must not be null

entries int

Maximum number of entries to retrieve

Returns

Task<List<CredHubCredential<T>>>

The details of the retrieved credential

Type Parameters

T

Type of CredHub credential to be retrieved

GetPermissionsAsync(string)

Get the permissions associated with a credential.

public Task<List<CredentialPermission>> GetPermissionsAsync(string name)

Parameters

name string

Returns

Task<List<CredentialPermission>>

List of permssions

InterpolateServiceDataAsync(string)

Search the provided data structure of bound service credentials, looking for references to CredHub credentials.

public Task<string> InterpolateServiceDataAsync(string serviceData)

Parameters

serviceData string

a data structure of bound service credentials, as would be parsed from the {@literal VCAP_SERVICES} environment variable provided to applications running on Cloud Foundry

Returns

Task<string>

the serviceData structure with CredHub references replaced by stored credential values

RegenerateAsync<T>(string)

Regenerate a credential in CredHub. Only credentials that were previously generated can be re-generated.

public Task<CredHubCredential<T>> RegenerateAsync<T>(string name)

Parameters

name string

Name of the credential to regenerate

Returns

Task<CredHubCredential<T>>

Regenerated credential details

Type Parameters

T

Type of CredHub credential to be regenerated

WriteAsync<T>(CredentialSetRequest)

Write a new credential to CredHub, or overwrite an existing credential with a new value.

public Task<CredHubCredential<T>> WriteAsync<T>(CredentialSetRequest credentialRequest)

Parameters

credentialRequest CredentialSetRequest

The credential to write to CredHub; must not be null

Returns

Task<CredHubCredential<T>>

Newly written credential

Type Parameters

T

Type of CredHub credential to be written