use of org.cloudfoundry.credhub.exceptions.InvalidQueryParameterException in project credhub by cloudfoundry-incubator.
the class PermissionedCertificateService method getVersions.
public List<CredentialVersion> getVersions(UUID uuid, boolean current, List<EventAuditRecordParameters> auditRecordParameters) {
List<CredentialVersion> list;
String name;
try {
if (current) {
Credential credential = findCertificateCredential(uuid);
name = credential.getName();
list = certificateVersionDataService.findActiveWithTransitional(name);
} else {
list = certificateVersionDataService.findAllVersions(uuid);
name = !list.isEmpty() ? list.get(0).getName() : null;
}
} catch (IllegalArgumentException e) {
auditRecordParameters.add(new EventAuditRecordParameters(AuditingOperationCode.CREDENTIAL_ACCESS, null));
throw new InvalidQueryParameterException("error.bad_request", "uuid");
}
auditRecordParameters.add(new EventAuditRecordParameters(AuditingOperationCode.CREDENTIAL_ACCESS, name));
if (list.isEmpty() || !permissionCheckingService.hasPermission(userContextHolder.getUserContext().getActor(), name, PermissionOperation.READ)) {
throw new EntryNotFoundException("error.credential.invalid_access");
}
return list;
}
Aggregations