Search in sources :

Example 1 with TppManualCSRNotEnabledException

use of com.venafi.vcert.sdk.connectors.ConnectorException.TppManualCSRNotEnabledException in project vcert-java by Venafi.

the class TppConnector method generateRequest.

@Override
public CertificateRequest generateRequest(ZoneConfiguration config, CertificateRequest request) throws VCertException {
    // todo: should one really have to pass a request into a "generate request" method?
    if (config == null) {
        config = readZoneConfiguration(zone);
    }
    String tppMgmtType = config.customAttributeValues().get(TPP_ATTRIBUTE_MANAGEMENT_TYPE);
    if ("Monitoring".equals(tppMgmtType) || "Unassigned".equals(tppMgmtType))
        throw new TppRequestCertificateNotAllowedException();
    config.applyCertificateRequestDefaultSettingsIfNeeded(request);
    switch(request.csrOrigin()) {
        case LocalGeneratedCSR:
            {
                if ("0".equals(config.customAttributeValues().get(TPP_ATTRIBUTE_MANUAL_CSR)))
                    throw new TppManualCSRNotEnabledException(request.csrOrigin());
                request.generatePrivateKey();
                request.generateCSR();
                break;
            }
        case UserProvidedCSR:
            {
                if ("0".equals(config.customAttributeValues().get(TPP_ATTRIBUTE_MANUAL_CSR)))
                    throw new TppManualCSRNotEnabledException(request.csrOrigin());
                if (Is.blank(request.csr()))
                    throw new CSRNotProvidedByUserException();
                break;
            }
        case ServiceGeneratedCSR:
            {
                request.csr(null);
                break;
            }
    }
    // TODO: should we return the request we modified? It's not a copy, it's the one
    return request;
// that was passed in, mutated.
}
Also used : TppManualCSRNotEnabledException(com.venafi.vcert.sdk.connectors.ConnectorException.TppManualCSRNotEnabledException) TppRequestCertificateNotAllowedException(com.venafi.vcert.sdk.connectors.ConnectorException.TppRequestCertificateNotAllowedException) CSRNotProvidedByUserException(com.venafi.vcert.sdk.connectors.ConnectorException.CSRNotProvidedByUserException)

Aggregations

CSRNotProvidedByUserException (com.venafi.vcert.sdk.connectors.ConnectorException.CSRNotProvidedByUserException)1 TppManualCSRNotEnabledException (com.venafi.vcert.sdk.connectors.ConnectorException.TppManualCSRNotEnabledException)1 TppRequestCertificateNotAllowedException (com.venafi.vcert.sdk.connectors.ConnectorException.TppRequestCertificateNotAllowedException)1