use of com.venafi.vcert.sdk.connectors.ConnectorException.CSRNotProvidedByUserException 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.
}
Aggregations