Skip to content

Commit

Permalink
Merge pull request #2 from 3KeyCompany/release/2.0.1
Browse files Browse the repository at this point in the history
Release/2.0.1
  • Loading branch information
3keyroman authored Nov 30, 2021
2 parents 63a47c5 + a4e85b1 commit 580f2f1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 22 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<groupId>com.czertainly</groupId>
<artifactId>core</artifactId>
<version>2.0.0</version>
<version>2.0.1</version>
<name>CZERTAINLY-Core</name>

<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import javax.transaction.Transactional;

import com.czertainly.api.core.modal.*;
import com.czertainly.core.aop.AuditLogged;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
Expand All @@ -15,11 +16,6 @@
import org.springframework.security.access.annotation.Secured;
import org.springframework.stereotype.Service;

import com.czertainly.api.core.modal.AddClientRequestDto;
import com.czertainly.api.core.modal.ClientDto;
import com.czertainly.api.core.modal.EditClientRequestDto;
import com.czertainly.api.core.modal.ObjectType;
import com.czertainly.api.core.modal.OperationType;
import com.czertainly.core.dao.entity.Certificate;
import com.czertainly.core.dao.entity.Client;
import com.czertainly.core.dao.entity.RaProfile;
Expand Down Expand Up @@ -246,17 +242,14 @@ private Client createClient(AddClientRequestDto requestDTO) throws CertificateEx
Client client = new Client();
Certificate certificate;
if((requestDTO.getClientCertificate() != null && !requestDTO.getClientCertificate().isEmpty()) || (requestDTO.getCertificateUuid() != null && !requestDTO.getCertificateUuid().isEmpty())) {
if (requestDTO.getCertificateUuid() != null) {
if (!requestDTO.getCertificateUuid().isEmpty()) {
certificate = certificateService.getCertificateEntity(requestDTO.getCertificateUuid());
client.setCertificate(certificate);

} else {
X509Certificate x509Cert = CertificateUtil.parseCertificate(requestDTO.getClientCertificate());
if (certificateRepository.findBySerialNumberIgnoreCase(x509Cert.getSerialNumber().toString(16)).isPresent()) {
throw new AlreadyExistException(Certificate.class, x509Cert.getSerialNumber().toString(16));
}
certificate = certificateService.createCertificateEntity(x509Cert);
certificateRepository.save(certificate);
UploadCertificateRequestDto request = new UploadCertificateRequestDto();
request.setCertificate(requestDTO.getClientCertificate());
certificate = certificateService.getCertificateEntity(certificateService.upload(request).getUuid());
client.setCertificate(certificate);
}
client.setSerialNumber(certificate.getSerialNumber());
Expand All @@ -271,19 +264,15 @@ private Client createClient(AddClientRequestDto requestDTO) throws CertificateEx
private Client updateClient(Client client, EditClientRequestDto requestDTO) throws CertificateException, NotFoundException, AlreadyExistException {
client.setDescription(requestDTO.getDescription());
Certificate certificate;
if(requestDTO.getCertificateUuid() != null) {
if(!requestDTO.getCertificateUuid().isEmpty()) {
certificate = certificateService.getCertificateEntity(requestDTO.getCertificateUuid());
client.setCertificate(certificate);

}else {
X509Certificate x509Cert = CertificateUtil.parseCertificate(requestDTO.getClientCertificate());
if (certificateRepository.findBySerialNumberIgnoreCase(x509Cert.getSerialNumber().toString(16)).isPresent()) {
throw new AlreadyExistException(Certificate.class, x509Cert.getSerialNumber().toString(16));
}

certificate = certificateService.createCertificateEntity(x509Cert);
certificateRepository.save(certificate);
client.setCertificate(certificate);
UploadCertificateRequestDto request = new UploadCertificateRequestDto();
request.setCertificate(requestDTO.getClientCertificate());
certificate = certificateService.getCertificateEntity(certificateService.upload(request).getUuid());
client.setCertificate(certificate);
}
client.setSerialNumber(certificate.getSerialNumber());
return client;
Expand Down

0 comments on commit 580f2f1

Please sign in to comment.