Search in sources :

Example 1 with CustomField

use of com.venafi.vcert.sdk.certificate.CustomField in project vcert-java by Venafi.

the class TppTokenConnectorCertAT method createCertificateValidateValidityHours.

@Test
@DisplayName("Create a cerfiticate that contais custom fields and validate if certifcate were created correctly")
void createCertificateValidateValidityHours() throws UnknownHostException, VCertException {
    // Custom fields
    List<CustomField> customFields = new ArrayList<CustomField>();
    customFields.add(new CustomField("custom", "java-test"));
    customFields.add(new CustomField("cfList", "item2"));
    customFields.add(new CustomField("cfListMulti", "tier1"));
    customFields.add(new CustomField("cfListMulti", "tier2"));
    TppTokenConnector connector = connectorResource.connector();
    ZoneConfiguration zoneConfiguration = connectorResource.zoneConfiguration();
    CertificateRequest certificateRequest = connectorResource.certificateRequest().customFields(customFields);
    certificateRequest = connector.generateRequest(zoneConfiguration, connectorResource.certificateRequest());
    // Submit the certificate request
    connector.requestCertificate(certificateRequest, zoneConfiguration);
    // Retrieve PEM collection from Venafi
    PEMCollection pemCollection = connector.retrieveCertificate(certificateRequest);
    // At this moment certificate, must be created, it will fail if some custom fields aren't supported or specified on tpp
    // so is enough to validate if certificate is created.
    assertTrue(pemCollection.certificate() != null);
}
Also used : PEMCollection(com.venafi.vcert.sdk.certificate.PEMCollection) CustomField(com.venafi.vcert.sdk.certificate.CustomField) ArrayList(java.util.ArrayList) ZoneConfiguration(com.venafi.vcert.sdk.connectors.ZoneConfiguration) CertificateRequest(com.venafi.vcert.sdk.certificate.CertificateRequest) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Aggregations

CertificateRequest (com.venafi.vcert.sdk.certificate.CertificateRequest)1 CustomField (com.venafi.vcert.sdk.certificate.CustomField)1 PEMCollection (com.venafi.vcert.sdk.certificate.PEMCollection)1 ZoneConfiguration (com.venafi.vcert.sdk.connectors.ZoneConfiguration)1 ArrayList (java.util.ArrayList)1 DisplayName (org.junit.jupiter.api.DisplayName)1 Test (org.junit.jupiter.api.Test)1