Search in sources :

Example 6 with CertificateDTO

use of com.stnetix.ariaddna.commonutils.dto.CertificateDTO in project ariADDna by StnetixDevTeam.

the class CertificateTransformerTest method certificateEntityToDTOTest.

@Test
public void certificateEntityToDTOTest() throws Exception {
    Certificate certificate = new Certificate();
    UUID uuid = UUID.randomUUID();
    certificate.setId(1L);
    certificate.setUuid(uuid.toString());
    certificate.setActive(true);
    CertificateDTO certificateDTO = transformer.certificateEntityToDTO(certificate);
    assertNotEquals(certificateDTO, certificate);
    assertEquals(certificate.getUuid(), certificateDTO.getUuid());
    assertEquals(certificate.getId(), certificateDTO.getId());
    assertEquals(certificate.getActive(), certificateDTO.getActive());
}
Also used : CertificateDTO(com.stnetix.ariaddna.commonutils.dto.CertificateDTO) UUID(java.util.UUID) Certificate(com.stnetix.ariaddna.persistence.entities.Certificate) Test(org.junit.Test)

Example 7 with CertificateDTO

use of com.stnetix.ariaddna.commonutils.dto.CertificateDTO in project ariADDna by StnetixDevTeam.

the class CertificateTransformerTest method certificateDTOToEntityTest.

@Test
public void certificateDTOToEntityTest() throws Exception {
    CertificateDTO certificateDTO = new CertificateDTO();
    UUID uuid = UUID.randomUUID();
    certificateDTO.setId(1L);
    certificateDTO.setUuid(uuid.toString());
    certificateDTO.setActive(true);
    Certificate certificate = transformer.certificateDTOToEntity(certificateDTO);
    assertNotEquals(certificate, certificateDTO);
    assertEquals(certificate.getUuid(), certificateDTO.getUuid());
    assertEquals(certificate.getId(), certificateDTO.getId());
    assertEquals(certificate.getActive(), certificateDTO.getActive());
}
Also used : CertificateDTO(com.stnetix.ariaddna.commonutils.dto.CertificateDTO) UUID(java.util.UUID) Certificate(com.stnetix.ariaddna.persistence.entities.Certificate) Test(org.junit.Test)

Example 8 with CertificateDTO

use of com.stnetix.ariaddna.commonutils.dto.CertificateDTO in project ariADDna by StnetixDevTeam.

the class PersistHelperImpl method getTargetCert.

private CertificateDTO getTargetCert(String alias) {
    List<CertificateDTO> certList = certificateService.getAllCertificates();
    CertificateDTO target = null;
    for (CertificateDTO cert : certList) {
        if (cert.getUuid().equalsIgnoreCase(alias)) {
            target = cert;
            break;
        }
    }
    return target;
}
Also used : CertificateDTO(com.stnetix.ariaddna.commonutils.dto.CertificateDTO)

Example 9 with CertificateDTO

use of com.stnetix.ariaddna.commonutils.dto.CertificateDTO in project ariADDna by StnetixDevTeam.

the class PersistHelperImpl method setCertificateDisable.

@Override
public void setCertificateDisable(String alias) {
    CertificateDTO target = getTargetCert(alias);
    if (target != null) {
        target.setActive(false);
        certificateService.save(target);
    }
}
Also used : CertificateDTO(com.stnetix.ariaddna.commonutils.dto.CertificateDTO)

Aggregations

CertificateDTO (com.stnetix.ariaddna.commonutils.dto.CertificateDTO)9 UUID (java.util.UUID)6 Test (org.junit.Test)6 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)4 Certificate (com.stnetix.ariaddna.persistence.entities.Certificate)2 KeyStoreException (com.stnetix.ariaddna.keystore.exceptions.KeyStoreException)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 BigInteger (java.math.BigInteger)1 KeyPair (java.security.KeyPair)1 KeyPairGenerator (java.security.KeyPairGenerator)1 PrivateKey (java.security.PrivateKey)1 SecureRandom (java.security.SecureRandom)1 AlgorithmId (sun.security.x509.AlgorithmId)1 CertificateAlgorithmId (sun.security.x509.CertificateAlgorithmId)1 CertificateSerialNumber (sun.security.x509.CertificateSerialNumber)1 CertificateValidity (sun.security.x509.CertificateValidity)1 CertificateVersion (sun.security.x509.CertificateVersion)1 CertificateX509Key (sun.security.x509.CertificateX509Key)1 X500Name (sun.security.x509.X500Name)1