Spring / Spring CredHub Interview questions
How do you write a credential using CredHubOperations?
Get the credentials sub-interface from the injected CredHubOperations bean, build a typed request, and call write():
PasswordCredential value = new PasswordCredential("s3cr3t-value"); PasswordCredentialRequest request = PasswordCredentialRequest.builder() .name(new SimpleCredentialName("myapp", "prod", "db-password")) .value(value) .build(); CredentialDetails<PasswordCredential> details = credHubOperations.credentials().write(request);
If a credential already exists at that name, write() overwrites it with the new value and CredHub keeps the previous version in its history, retrievable later with getByNameWithHistory().
The same pattern — build a typed request, call write() — applies to every credential type; only the request and value classes change.
More Related questions...