Search in sources :

Example 1 with UserGenerateRequest

use of org.cloudfoundry.credhub.request.UserGenerateRequest in project credhub by cloudfoundry-incubator.

the class UserCredentialRegeneratable method createGenerateRequest.

@Override
public BaseCredentialGenerateRequest createGenerateRequest(CredentialVersion credentialVersion, List<EventAuditRecordParameters> auditRecordParameters) {
    UserCredentialVersion userCredential = (UserCredentialVersion) credentialVersion;
    UserGenerateRequest generateRequest = new UserGenerateRequest();
    generateRequest.setName(userCredential.getName());
    generateRequest.setType(userCredential.getCredentialType());
    generateRequest.setOverwrite(true);
    StringGenerationParameters generationParameters;
    generationParameters = userCredential.getGenerationParameters();
    if (generationParameters == null) {
        auditRecordParameters.add(new EventAuditRecordParameters(CREDENTIAL_UPDATE, credentialVersion.getName()));
        throw new ParameterizedValidationException("error.cannot_regenerate_non_generated_user");
    }
    generationParameters.setUsername(userCredential.getUsername());
    generateRequest.setGenerationParameters(generationParameters);
    return generateRequest;
}
Also used : UserGenerateRequest(org.cloudfoundry.credhub.request.UserGenerateRequest) EventAuditRecordParameters(org.cloudfoundry.credhub.audit.EventAuditRecordParameters) UserCredentialVersion(org.cloudfoundry.credhub.domain.UserCredentialVersion) ParameterizedValidationException(org.cloudfoundry.credhub.exceptions.ParameterizedValidationException) StringGenerationParameters(org.cloudfoundry.credhub.request.StringGenerationParameters)

Aggregations

EventAuditRecordParameters (org.cloudfoundry.credhub.audit.EventAuditRecordParameters)1 UserCredentialVersion (org.cloudfoundry.credhub.domain.UserCredentialVersion)1 ParameterizedValidationException (org.cloudfoundry.credhub.exceptions.ParameterizedValidationException)1 StringGenerationParameters (org.cloudfoundry.credhub.request.StringGenerationParameters)1 UserGenerateRequest (org.cloudfoundry.credhub.request.UserGenerateRequest)1