public class CredHubTemplate extends java.lang.Object implements CredHubOperations
| Constructor and Description |
|---|
CredHubTemplate(java.lang.String apiUriBase,
org.springframework.http.client.ClientHttpRequestFactory clientHttpRequestFactory)
Create a new
CredHubTemplate using the provided base URI and
ClientHttpRequestFactory. |
| Modifier and Type | Method and Description |
|---|---|
java.util.List<CredentialPermission> |
addPermissions(CredentialName name,
CredentialPermission... permissions)
Add permissions to an existing credential.
|
void |
deleteByName(CredentialName name)
Delete a credential by its full name.
|
void |
deletePermission(CredentialName name,
Actor actor)
Delete a permission associated with a credential.
|
<T> T |
doWithRest(RestOperationsCallback<T> callback)
Allow interaction with the configured
RestTemplate not provided
by other methods. |
java.util.List<CredentialSummary> |
findByName(CredentialName name)
Find a credential using a full or partial name.
|
java.util.List<CredentialSummary> |
findByPath(java.lang.String path)
Find a credential using a path.
|
<T,P> CredentialDetails<T> |
generate(ParametersRequest<P> parametersRequest)
Generate a new credential in CredHub, or overwrite an existing credential with a new
generated value.
|
<T> CredentialDetails<T> |
getById(java.lang.String id,
java.lang.Class<T> credentialType)
Retrieve a credential using its ID, as returned in a write request.
|
<T> CredentialDetails<T> |
getByName(CredentialName name,
java.lang.Class<T> credentialType)
Retrieve a credential using its name, as passed to a write request.
|
<T> java.util.List<CredentialDetails<T>> |
getByNameWithHistory(CredentialName name,
java.lang.Class<T> credentialType)
Retrieve a credential using its name, as passed to a write request.
|
java.util.List<CredentialPermission> |
getPermissions(CredentialName name)
Get the permissions associated with a credential.
|
ServicesData |
interpolateServiceData(ServicesData serviceData)
Search the provided data structure of bound service credentials, looking for
references to CredHub credentials.
|
<T> CredentialDetails<T> |
regenerate(CredentialName name)
Regenerate a credential in CredHub.
|
<T> CredentialDetails<T> |
write(CredentialRequest<T> credentialRequest)
Write a new credential to CredHub, or overwrite an existing credential with a new
value.
|
public CredHubTemplate(java.lang.String apiUriBase,
org.springframework.http.client.ClientHttpRequestFactory clientHttpRequestFactory)
CredHubTemplate using the provided base URI and
ClientHttpRequestFactory.apiUriBase - the base URI for the CredHub server (scheme, host, and port);
must not be nullclientHttpRequestFactory - the ClientHttpRequestFactory to use when
creating new connectionspublic <T> CredentialDetails<T> write(CredentialRequest<T> credentialRequest)
CredHubOperationswrite in interface CredHubOperationsT - the credential implementation typecredentialRequest - the credential to write to CredHub; must not be nullpublic <T,P> CredentialDetails<T> generate(ParametersRequest<P> parametersRequest)
CredHubOperationsgenerate in interface CredHubOperationsT - the credential implementation typeP - the credential parameter implementation typeparametersRequest - the parameters of the new credential to generate in CredHub;
must not be nullpublic <T> CredentialDetails<T> regenerate(CredentialName name)
CredHubOperationsregenerate in interface CredHubOperationsT - the credential implementation typename - the name of the credential; must not be nullpublic <T> CredentialDetails<T> getById(java.lang.String id, java.lang.Class<T> credentialType)
CredHubOperationsgetById in interface CredHubOperationsT - the credential implementation typeid - the ID of the credential; must not be nullcredentialType - the type of the credential to be retrieved; must not be nullpublic <T> CredentialDetails<T> getByName(CredentialName name, java.lang.Class<T> credentialType)
CredHubOperationsgetByName in interface CredHubOperationsT - the credential implementation typename - the name of the credential; must not be nullcredentialType - the type of credential expected to be returnedpublic <T> java.util.List<CredentialDetails<T>> getByNameWithHistory(CredentialName name, java.lang.Class<T> credentialType)
CredHubOperationsgetByNameWithHistory in interface CredHubOperationsT - the credential implementation typename - the name of the credential; must not be nullcredentialType - the type of credential expected to be returnedpublic java.util.List<CredentialSummary> findByName(CredentialName name)
CredHubOperationsfindByName in interface CredHubOperationsname - the name of the credential; must not be nullpublic java.util.List<CredentialSummary> findByPath(java.lang.String path)
CredHubOperationsfindByPath in interface CredHubOperationspath - the path to the credential; must not be nullpublic void deleteByName(CredentialName name)
CredHubOperationsdeleteByName in interface CredHubOperationsname - the name of the credential; must not be nullpublic java.util.List<CredentialPermission> getPermissions(CredentialName name)
CredHubOperationsgetPermissions in interface CredHubOperationsname - the name of the credential; must not be nullpublic java.util.List<CredentialPermission> addPermissions(CredentialName name, CredentialPermission... permissions)
CredHubOperationsaddPermissions in interface CredHubOperationsname - the name of the credential; must not be nullpermissions - a collection of permissions to addpublic void deletePermission(CredentialName name, Actor actor)
CredHubOperationsdeletePermission in interface CredHubOperationsname - the name of the credential; must not be nullactor - the actor of the permission; must not be nullpublic ServicesData interpolateServiceData(ServicesData serviceData)
CredHubOperations
{
"service-offering": [{
"credentials": {
"credhub-ref": "((/c/service-broker/service-offering/1111-2222-3333-4444/credentials))"
}
"label": "service-offering",
"name": "service-instance",
"plan": "standard",
"tags": ["
"cloud-service"
]
}]
}
Assuming that CredHub has a credential with the name
/c/service-broker/service-offering/1111-2222-3333-4444/credentials,
passing the data structure above to this method would result in the
credhub-ref field being replaced by the credentials stored in CredHub:
{
"service-offering": [{
"credentials": {
"url": "https://servicehost.example.com/",
"username": "someuser",
"password": "secret"
}
"label": "service-offering",
"name": "service-instance",
"plan": "standard",
"tags": ["
"cloud-service"
]
}]
}
interpolateServiceData in interface CredHubOperationsserviceData - a data structure of bound service credentials, as would be
parsed from the VCAP_SERVICES environment variable provided to
applications running on Cloud Foundrypublic <T> T doWithRest(RestOperationsCallback<T> callback)
CredHubOperationsRestTemplate not provided
by other methods.doWithRest in interface CredHubOperationsT - the credential implementation typecallback - wrapper for the callback method