use of com.venafi.vcert.sdk.connectors.ZoneConfiguration in project vcert-java by Venafi.
the class CloudConnectorCertAT method requestCertificateUnrestricted.
@Test
void requestCertificateUnrestricted() throws VCertException, UnknownHostException {
CloudConnector connector = connectorResource.connector();
ZoneConfiguration zoneConfiguration = connectorResource.zoneConfiguration();
CertificateRequest certificateRequest = connectorResource.certificateRequest().keyType(KeyType.RSA).keyLength(2048);
certificateRequest = connector.generateRequest(zoneConfiguration, certificateRequest);
String certificateId = connector.requestCertificate(certificateRequest, zoneConfiguration);
assertThat(certificateId).isNotNull();
}
use of com.venafi.vcert.sdk.connectors.ZoneConfiguration in project vcert-java by Venafi.
the class ZoneConfigurationTest method validateCertificateRequest.
@Test
@DisplayName("Validate a policy match")
void validateCertificateRequest() throws VCertException {
final ZoneConfiguration zoneConfiguration = getBaseZoneConfiguration();
zoneConfiguration.validateCertificateRequest(getDefaultCertificateRequest());
}
use of com.venafi.vcert.sdk.connectors.ZoneConfiguration in project vcert-java by Venafi.
the class ZoneConfigurationTest method invalidCNMatch.
@Test
@DisplayName("Expect CN not to match with a termination")
void invalidCNMatch() throws VCertException {
final ZoneConfiguration zoneConfiguration = getBaseZoneConfiguration();
final CertificateRequest certificateRequest = getDefaultCertificateRequest();
certificateRequest.subject().commonName("vcert.text.vfidev.com.example");
final Throwable exception = assertThrows(VCertException.class, () -> zoneConfiguration.validateCertificateRequest(certificateRequest));
assertThat(exception.getMessage()).contains("CN does not match any of the allowed CN");
}
use of com.venafi.vcert.sdk.connectors.ZoneConfiguration in project vcert-java by Venafi.
the class TppClient method main.
public static void main(String[] args) throws VCertException, CertificateEncodingException, NoSuchAlgorithmException, KeyManagementException {
String url = System.getenv("TPPURL");
String zone = System.getenv("TPPZONE");
String appInfo = System.getenv("PRODUCT");
String tpp_user = System.getenv("TPPUSER");
String tpp_passwd = System.getenv("TPPPASSWORD");
if (tpp_user == null)
tpp_user = "local:admin";
if (tpp_passwd == null)
tpp_passwd = "password";
if (url == null)
url = "https://tpp.venafi.example/vedsdk";
if (zone == null)
zone = "Certificates\\vcert\\";
if (appInfo == null)
appInfo = "CompanyName AppName";
// Configuration
Config config = Config.builder().connectorType(ConnectorType.TPP).baseUrl(url).appInfo(appInfo).build();
Authentication auth = Authentication.builder().user(tpp_user).password(tpp_passwd).build();
VCertClient client = new VCertClient(config);
client.authenticate(auth);
ZoneConfiguration zoneConfiguration = client.readZoneConfiguration(zone);
// Generate a certificate
CertificateRequest certificateRequest = new CertificateRequest().subject(new CertificateRequest.PKIXName().commonName("vcert-java.venafi.example").organization(Collections.singletonList("Venafi, Inc.")).organizationalUnit(Arrays.asList("Product Management")).country(Collections.singletonList("US")).locality(Collections.singletonList("Salt Lake City")).province(Collections.singletonList("Utah"))).keyType(KeyType.RSA).keyLength(2048);
certificateRequest = client.generateRequest(zoneConfiguration, certificateRequest);
// Submit the certificate request
client.requestCertificate(certificateRequest, zoneConfiguration);
// Retrieve PEM collection from Venafi
PEMCollection pemCollection = client.retrieveCertificate(certificateRequest);
System.out.println(pemCollection.certificate());
}
use of com.venafi.vcert.sdk.connectors.ZoneConfiguration in project vcert-java by Venafi.
the class TppTokenClient method main.
public static void main(String[] args) throws VCertException, CertificateEncodingException, NoSuchAlgorithmException, KeyManagementException {
String url = System.getenv("TPP_TOKEN_URL");
String zone = System.getenv("TPPZONE");
String appInfo = System.getenv("PRODUCT");
String tpp_user = System.getenv("TPPUSER");
String tpp_passwd = System.getenv("TPPPASSWORD");
if (tpp_user == null)
tpp_user = "local:admin";
if (tpp_passwd == null)
tpp_passwd = "password";
if (url == null)
url = "https://tpp.venafi.example/vedsdk";
if (zone == null)
zone = "Certificates\\vcert\\";
if (appInfo == null)
appInfo = "CompanyName AppName";
// Configuration
Config config = Config.builder().connectorType(ConnectorType.TPP_TOKEN).baseUrl(url).appInfo(appInfo).build();
Authentication auth = Authentication.builder().user(tpp_user).password(tpp_passwd).build();
VCertTknClient client = new VCertTknClient(config);
TokenInfo tknInfo = client.getAccessToken(auth);
ZoneConfiguration zoneConfiguration = client.readZoneConfiguration(zone);
// Generate a certificate
CertificateRequest certificateRequest = new CertificateRequest().subject(new CertificateRequest.PKIXName().commonName("vcert-java.venafi.example").organization(Collections.singletonList("Venafi, Inc.")).organizationalUnit(Arrays.asList("Product Management")).country(Collections.singletonList("US")).locality(Collections.singletonList("Salt Lake City")).province(Collections.singletonList("Utah"))).keyType(KeyType.RSA).keyLength(2048);
certificateRequest = client.generateRequest(zoneConfiguration, certificateRequest);
// Submit the certificate request
client.requestCertificate(certificateRequest, zoneConfiguration);
// Retrieve PEM collection from Venafi
PEMCollection pemCollection = client.retrieveCertificate(certificateRequest);
System.out.println(pemCollection.certificate());
}
Aggregations