Search in sources :

Example 1 with CertificateAttribute

use of de.trustable.ca3s.core.domain.CertificateAttribute in project ca3sCore by kuehne-trustable-de.

the class CertificateUtilIntTest method testBuildCertificateWithSAN2.

@Test
public void testBuildCertificateWithSAN2() throws GeneralSecurityException, IOException {
    String executionId = "";
    Certificate cert = certificateUtil.createCertificate(testCertWithSAN2, null, executionId);
    assertNotNull(cert);
    assertFalse(cert.getSans().isEmpty());
    assertEquals("info@ramthun.net", cert.getSans());
    boolean sanPresent = false;
    for (CertificateAttribute certAtt : cert.getCertificateAttributes()) {
        if (CertificateAttribute.ATTRIBUTE_SAN.equals(certAtt.getName())) {
            // assertEquals("ca@trustable.de", certAtt.getValue());
            System.out.println("::: " + certAtt.getValue());
            sanPresent = true;
        }
    }
    assertTrue(sanPresent);
}
Also used : X509Certificate(java.security.cert.X509Certificate) Certificate(de.trustable.ca3s.core.domain.Certificate) CertificateAttribute(de.trustable.ca3s.core.domain.CertificateAttribute) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with CertificateAttribute

use of de.trustable.ca3s.core.domain.CertificateAttribute in project ca3sCore by kuehne-trustable-de.

the class CertificateUtilIntTest method testBuildCertificatetestCertWithLongSAN.

@Test
public void testBuildCertificatetestCertWithLongSAN() throws GeneralSecurityException, IOException {
    String executionId = "";
    Certificate cert = certificateUtil.createCertificate(testCertWithLongSAN, null, executionId);
    assertNotNull(cert);
    assertFalse(cert.getSans().isEmpty());
    assertEquals("2.16.724.1.3.5.1.2.1=sede electrónica,2.16.724.1.3.5.1.2.2=ministerio de industria energia y turismo,2.16.724.1.3.5.1.2.3=s2800214e,2.16.724.1.3.5.1.2.4=sede electronica del ministerio de industria energia y turismo,2.16.724.1.3.5.1.2.5=sede.minetur.", cert.getSans());
    int sanCount = 0;
    for (CertificateAttribute certAtt : cert.getCertificateAttributes()) {
        if (CertificateAttribute.ATTRIBUTE_SAN.equals(certAtt.getName())) {
            sanCount++;
        }
        if (CertificateAttribute.ATTRIBUTE_CRL_URL.equals(certAtt.getName())) {
            System.out.println("ATTRIBUTE_CRL_URL" + certAtt.getValue());
        }
    }
    assertEquals(2, sanCount);
    assertEquals("rsa", cert.getKeyAlgorithm());
    assertEquals("rsa", cert.getSigningAlgorithm());
    assertEquals("sha1", cert.getHashingAlgorithm());
    assertEquals("2048", cert.getKeyLength().toString());
    assertEquals("pkcs1", cert.getPaddingAlgorithm());
}
Also used : X509Certificate(java.security.cert.X509Certificate) Certificate(de.trustable.ca3s.core.domain.Certificate) CertificateAttribute(de.trustable.ca3s.core.domain.CertificateAttribute) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 3 with CertificateAttribute

use of de.trustable.ca3s.core.domain.CertificateAttribute in project ca3sCore by kuehne-trustable-de.

the class CertificateUtilIntTest method testBuildCertificatestLocalhost.

@Test
public void testBuildCertificatestLocalhost() throws GeneralSecurityException, IOException {
    String executionId = "";
    Certificate cert = certificateUtil.createCertificate(testLocalhost, null, executionId);
    assertNotNull(cert);
    for (CertificateAttribute certAtt : cert.getCertificateAttributes()) {
        if (CertificateAttribute.ATTRIBUTE_CRL_URL.equals(certAtt.getName())) {
            System.out.println("ATTRIBUTE_CRL_URL" + certAtt.getValue());
        }
    }
    assertEquals("rsa", cert.getKeyAlgorithm());
    assertEquals("rsa", cert.getSigningAlgorithm());
    assertEquals("sha256", cert.getHashingAlgorithm());
    assertEquals("2048", cert.getKeyLength().toString());
    assertEquals("pkcs1", cert.getPaddingAlgorithm());
}
Also used : X509Certificate(java.security.cert.X509Certificate) Certificate(de.trustable.ca3s.core.domain.Certificate) CertificateAttribute(de.trustable.ca3s.core.domain.CertificateAttribute) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 4 with CertificateAttribute

use of de.trustable.ca3s.core.domain.CertificateAttribute in project ca3sCore by kuehne-trustable-de.

the class CertificateAttributeResourceIT method createCertificateAttribute.

@Test
@Transactional
public void createCertificateAttribute() throws Exception {
    int databaseSizeBeforeCreate = certificateAttributeRepository.findAll().size();
    // Create the CertificateAttribute
    restCertificateAttributeMockMvc.perform(post("/api/certificate-attributes").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(certificateAttribute))).andExpect(status().isCreated());
    // Validate the CertificateAttribute in the database
    List<CertificateAttribute> certificateAttributeList = certificateAttributeRepository.findAll();
    assertThat(certificateAttributeList).hasSize(databaseSizeBeforeCreate + 1);
    CertificateAttribute testCertificateAttribute = certificateAttributeList.get(certificateAttributeList.size() - 1);
    assertThat(testCertificateAttribute.getName()).isEqualTo(DEFAULT_NAME);
    assertThat(testCertificateAttribute.getValue()).isEqualTo(DEFAULT_VALUE);
}
Also used : CertificateAttribute(de.trustable.ca3s.core.domain.CertificateAttribute) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with CertificateAttribute

use of de.trustable.ca3s.core.domain.CertificateAttribute in project ca3sCore by kuehne-trustable-de.

the class CertificateAttributeResource method updateCertificateAttribute.

/**
 * {@code PUT  /certificate-attributes} : Updates an existing certificateAttribute.
 *
 * @param certificateAttribute the certificateAttribute to update.
 * @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the updated certificateAttribute,
 * or with status {@code 400 (Bad Request)} if the certificateAttribute is not valid,
 * or with status {@code 500 (Internal Server Error)} if the certificateAttribute couldn't be updated.
 * @throws URISyntaxException if the Location URI syntax is incorrect.
 */
@PutMapping("/certificate-attributes")
public ResponseEntity<CertificateAttribute> updateCertificateAttribute(@Valid @RequestBody CertificateAttribute certificateAttribute) throws URISyntaxException {
    log.debug("REST request to update CertificateAttribute : {}", certificateAttribute);
    if (certificateAttribute.getId() == null) {
        throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull");
    }
    CertificateAttribute result = certificateAttributeRepository.save(certificateAttribute);
    return ResponseEntity.ok().headers(HeaderUtil.createEntityUpdateAlert(applicationName, true, ENTITY_NAME, certificateAttribute.getId().toString())).body(result);
}
Also used : BadRequestAlertException(de.trustable.ca3s.core.web.rest.errors.BadRequestAlertException) CertificateAttribute(de.trustable.ca3s.core.domain.CertificateAttribute)

Aggregations

CertificateAttribute (de.trustable.ca3s.core.domain.CertificateAttribute)11 Test (org.junit.jupiter.api.Test)8 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)8 Certificate (de.trustable.ca3s.core.domain.Certificate)6 X509Certificate (java.security.cert.X509Certificate)6 BadRequestAlertException (de.trustable.ca3s.core.web.rest.errors.BadRequestAlertException)2 Transactional (org.springframework.transaction.annotation.Transactional)2 IOException (java.io.IOException)1 BigInteger (java.math.BigInteger)1 URI (java.net.URI)1 CRLException (java.security.cert.CRLException)1 CertificateException (java.security.cert.CertificateException)1 X509CRL (java.security.cert.X509CRL)1 X509CRLEntry (java.security.cert.X509CRLEntry)1 NamingException (javax.naming.NamingException)1