Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add validation to prevent issuing certificate with disabled RA profile #889

Merged
merged 2 commits into from
Nov 21, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,14 @@ public CertificateDetailDto submitCertificateRequest(ClientCertificateRequestDto
@Transactional(Transactional.TxType.NOT_SUPPORTED)
@ExternalAuthorization(resource = Resource.RA_PROFILE, action = ResourceAction.DETAIL, parentResource = Resource.AUTHORITY, parentAction = ResourceAction.DETAIL)
public ClientCertificateDataResponseDto issueCertificate(final SecuredParentUUID authorityUuid, final SecuredUUID raProfileUuid, final ClientCertificateSignRequestDto request, final CertificateProtocolInfo protocolInfo) throws NotFoundException, CertificateException, NoSuchAlgorithmException, CertificateOperationException, CertificateRequestException {
// validate RA profile
RaProfile raProfile = raProfileRepository.findByUuidAndEnabledIsTrue(raProfileUuid.getValue())
.orElseThrow(() -> new NotFoundException(RaProfile.class, raProfileUuid));

if (Boolean.FALSE.equals(raProfile.getEnabled())) {
throw new ValidationException(String.format("Cannot issue certificate with disabled RA profile. Ra Profile: %s", raProfile.getName()));
}

ClientCertificateRequestDto certificateRequestDto = new ClientCertificateRequestDto();
certificateRequestDto.setRaProfileUuid(raProfileUuid.getValue());
certificateRequestDto.setCsrAttributes(request.getCsrAttributes());
Expand Down
Loading