use of org.cloudfoundry.credhub.audit.EventAuditRecordParameters in project credhub by cloudfoundry-incubator.
the class PermissionedCertificateService method getByName.
public List<Credential> getByName(String name, List<EventAuditRecordParameters> auditRecordParameters) {
auditRecordParameters.add(new EventAuditRecordParameters(AuditingOperationCode.CREDENTIAL_FIND, name));
final Credential certificate = certificateDataService.findByName(name);
if (certificate == null || !permissionCheckingService.hasPermission(userContextHolder.getUserContext().getActor(), certificate.getName(), PermissionOperation.READ)) {
throw new EntryNotFoundException("error.credential.invalid_access");
}
return Collections.singletonList(certificate);
}
use of org.cloudfoundry.credhub.audit.EventAuditRecordParameters in project credhub by cloudfoundry-incubator.
the class PermissionedCertificateService method updateTransitionalVersion.
public List<CredentialVersion> updateTransitionalVersion(UUID certificateUuid, UUID newTransitionalVersionUuid, List<EventAuditRecordParameters> auditRecordParameters) {
EventAuditRecordParameters eventAuditRecordParameters = new EventAuditRecordParameters(AuditingOperationCode.CREDENTIAL_UPDATE, null);
auditRecordParameters.add(eventAuditRecordParameters);
Credential credential = findCertificateCredential(certificateUuid);
String name = credential.getName();
eventAuditRecordParameters.setCredentialName(name);
if (!permissionCheckingService.hasPermission(userContextHolder.getUserContext().getActor(), name, PermissionOperation.WRITE)) {
throw new EntryNotFoundException("error.credential.invalid_access");
}
certificateVersionDataService.unsetTransitionalVerison(certificateUuid);
if (newTransitionalVersionUuid != null) {
CertificateCredentialVersion version = certificateVersionDataService.findVersion(newTransitionalVersionUuid);
if (versionDoesNotBelongToCertificate(credential, version)) {
throw new ParameterizedValidationException("error.credential.mismatched_credential_and_version");
}
certificateVersionDataService.setTransitionalVersion(newTransitionalVersionUuid);
}
return certificateVersionDataService.findActiveWithTransitional(name);
}
use of org.cloudfoundry.credhub.audit.EventAuditRecordParameters in project credhub by cloudfoundry-incubator.
the class PermissionedCredentialService method findVersionByUuid.
public CredentialVersion findVersionByUuid(String credentialUUID, List<EventAuditRecordParameters> auditRecordParameters) {
EventAuditRecordParameters eventAuditRecordParameters = new EventAuditRecordParameters(AuditingOperationCode.CREDENTIAL_ACCESS);
auditRecordParameters.add(eventAuditRecordParameters);
CredentialVersion credentialVersion = credentialVersionDataService.findByUuid(credentialUUID);
if (credentialVersion == null) {
throw new EntryNotFoundException("error.credential.invalid_access");
}
String credentialName = credentialVersion.getName();
eventAuditRecordParameters.setCredentialName(credentialName);
if (!permissionCheckingService.hasPermission(userContextHolder.getUserContext().getActor(), credentialName, READ)) {
throw new EntryNotFoundException("error.credential.invalid_access");
}
return credentialVersionDataService.findByUuid(credentialUUID);
}
use of org.cloudfoundry.credhub.audit.EventAuditRecordParameters in project credhub by cloudfoundry-incubator.
the class CertificateCredentialRegeneratable method createGenerateRequest.
@Override
public BaseCredentialGenerateRequest createGenerateRequest(CredentialVersion credentialVersion, List<EventAuditRecordParameters> auditRecordParameters) {
CertificateCredentialVersion certificateCredential = (CertificateCredentialVersion) credentialVersion;
CertificateReader reader = certificateCredential.getParsedCertificate();
if (!reader.isValid() || (isEmpty(certificateCredential.getCaName()) && !reader.isSelfSigned())) {
auditRecordParameters.add(new EventAuditRecordParameters(CREDENTIAL_UPDATE, credentialVersion.getName()));
throw new ParameterizedValidationException("error.cannot_regenerate_non_generated_certificate");
}
CertificateGenerationParameters certificateGenerationParameters = new CertificateGenerationParameters(reader, certificateCredential.getCaName());
CertificateGenerateRequest generateRequest = new CertificateGenerateRequest();
generateRequest.setName(certificateCredential.getName());
generateRequest.setType(certificateCredential.getCredentialType());
generateRequest.setCertificateGenerationParameters(certificateGenerationParameters);
generateRequest.setOverwrite(true);
return generateRequest;
}
use of org.cloudfoundry.credhub.audit.EventAuditRecordParameters in project credhub by cloudfoundry-incubator.
the class PasswordCredentialRegeneratable method createGenerateRequest.
@Override
public BaseCredentialGenerateRequest createGenerateRequest(CredentialVersion credentialVersion, List<EventAuditRecordParameters> auditRecordParameters) {
PasswordCredentialVersion passwordCredential = (PasswordCredentialVersion) credentialVersion;
PasswordGenerateRequest generateRequest = new PasswordGenerateRequest();
generateRequest.setName(passwordCredential.getName());
generateRequest.setType(passwordCredential.getCredentialType());
generateRequest.setOverwrite(true);
StringGenerationParameters generationParameters;
generationParameters = passwordCredential.getGenerationParameters();
if (generationParameters == null) {
auditRecordParameters.add(new EventAuditRecordParameters(CREDENTIAL_UPDATE, credentialVersion.getName()));
throw new ParameterizedValidationException("error.cannot_regenerate_non_generated_password");
}
generateRequest.setGenerationParameters(generationParameters);
return generateRequest;
}
Aggregations