use of com.venafi.vcert.sdk.connectors.ZoneConfiguration in project vcert-java by Venafi.
the class ZoneConfigurationTest method invalidProvince.
@Test
@DisplayName("Invalid match in the state province")
void invalidProvince() throws VCertException {
final ZoneConfiguration zoneConfiguration = getBaseZoneConfiguration();
final CertificateRequest certificateRequest = getDefaultCertificateRequest();
certificateRequest.subject().province(Arrays.asList("Test"));
final Throwable exception = assertThrows(VCertException.class, () -> zoneConfiguration.validateCertificateRequest(certificateRequest));
assertThat(exception.getMessage()).contains("does not match any of the allowed State/Province");
}
use of com.venafi.vcert.sdk.connectors.ZoneConfiguration in project vcert-java by Venafi.
the class TppTokenConnectorCertAT method retrieveCertificate.
@Test
void retrieveCertificate() throws VCertException, SocketException, UnknownHostException {
TppTokenConnector connector = connectorResource.connector();
ZoneConfiguration zoneConfiguration = connectorResource.zoneConfiguration();
CertificateRequest certificateRequest = connectorResource.certificateRequest();
certificateRequest = connector.generateRequest(zoneConfiguration, certificateRequest);
String certificateId = connector.requestCertificate(certificateRequest, zoneConfiguration);
assertThat(certificateId).isNotNull();
PEMCollection pemCollection = connector.retrieveCertificate(certificateRequest);
assertThat(pemCollection.certificate()).isNotNull();
assertThat(pemCollection.privateKey()).isNotNull();
}
use of com.venafi.vcert.sdk.connectors.ZoneConfiguration in project vcert-java by Venafi.
the class CertificateIssuingTemplate method toZoneConfig.
public ZoneConfiguration toZoneConfig() {
ZoneConfiguration zoneConfig = new ZoneConfiguration().customAttributeValues(new HashMap<>());
if (recommendedSettings != null) {
zoneConfig.country(recommendedSettings.subjectCValue).organization(recommendedSettings.subjectOValue).organizationalUnit(Collections.singletonList(recommendedSettings.subjectOUValue)).province(recommendedSettings.subjectSTValue).locality(recommendedSettings.subjectLValue);
if (recommendedSettings.key() != null) {
String type = recommendedSettings.key().type != null ? recommendedSettings.key().type : KeyType.defaultKeyType().name();
Integer length = recommendedSettings.key().length != null ? recommendedSettings.key().length : KeyType.defaultRsaLength();
zoneConfig.keyConfig(new AllowedKeyConfiguration(KeyType.from(type), Collections.singletonList(length), null));
}
}
return zoneConfig;
}
use of com.venafi.vcert.sdk.connectors.ZoneConfiguration in project vcert-java by Venafi.
the class TppConnector method readZoneConfiguration.
@Override
public ZoneConfiguration readZoneConfiguration(String zone) throws VCertException {
VCertException.throwIfNull(zone, "empty zone");
ReadZoneConfigurationRequest request = new ReadZoneConfigurationRequest(getPolicyDN(zone));
ReadZoneConfigurationResponse response = tppAPI.readZoneConfiguration(request);
ServerPolicy serverPolicy = response.policy();
Policy policy = serverPolicy.toPolicy();
ZoneConfiguration zoneConfig = serverPolicy.toZoneConfig();
zoneConfig.policy(policy);
zoneConfig.zoneId(zone);
return zoneConfig;
}
use of com.venafi.vcert.sdk.connectors.ZoneConfiguration in project vcert-java by Venafi.
the class CloudConnector method readZoneConfiguration.
@Override
public ZoneConfiguration readZoneConfiguration(String zone) throws VCertException {
String[] valies = StringUtils.split(zone, "\\");
String appName = valies[0];
String citAlias = valies[1];
CertificateIssuingTemplate cit = null;
if ((appName != null && !appName.equals("")) && (citAlias != null && !citAlias.equals(""))) {
cit = cloud.certificateIssuingTemplateByAppNameAndCitAlias(appName, citAlias, auth.apiKey());
} else {
throw new ZoneFormatException("The parameters: appName, citAlias or both are empty");
}
// get application id.
Application app = cloud.applicationByName(appName, auth.apiKey());
String appId = app.id();
ZoneConfiguration zoneConfig = cit.toZoneConfig();
zoneConfig.policy(cit.toPolicy());
zoneConfig.zoneId(zone);
zoneConfig.applicationId(appId);
zoneConfig.certificateIssuingTemplateId(cit.id());
return zoneConfig;
}
Aggregations