use of com.android.apksig.internal.x509.Certificate in project java-security-private-ca by googleapis.
the class FilterCertificates method filterCertificates.
// Filter certificates based on a condition and list them.
public static void filterCertificates(String project, String location, String pool_Id) throws IOException {
// clean up any remaining background resources.
try (CertificateAuthorityServiceClient certificateAuthorityServiceClient = CertificateAuthorityServiceClient.create()) {
CaPoolName caPool = CaPoolName.newBuilder().setProject(project).setLocation(location).setCaPool(pool_Id).build();
// Create the certificate request and set the filter condition.
ListCertificatesRequest listCertificatesRequest = ListCertificatesRequest.newBuilder().setParent(caPool.toString()).setFilter("certificate_description.subject_description.subject.organization=csr-org-name").build();
// Retrieve and print the certificate names.
System.out.println("Available certificates: ");
for (Certificate certificate : certificateAuthorityServiceClient.listCertificates(listCertificatesRequest).iterateAll()) {
System.out.println(certificate.getName());
}
}
}
use of com.android.apksig.internal.x509.Certificate in project java-security-private-ca by googleapis.
the class ListCertificates method listCertificates.
// List Certificates present in the given CA pool.
public static void listCertificates(String project, String location, String pool_Id) throws IOException {
// clean up any remaining background resources.
try (CertificateAuthorityServiceClient certificateAuthorityServiceClient = CertificateAuthorityServiceClient.create()) {
CaPoolName caPool = CaPoolName.newBuilder().setProject(project).setLocation(location).setCaPool(pool_Id).build();
// Retrieve and print the certificate names.
System.out.println("Available certificates: ");
for (Certificate certificate : certificateAuthorityServiceClient.listCertificates(caPool).iterateAll()) {
System.out.println(certificate.getName());
}
}
}
use of com.android.apksig.internal.x509.Certificate in project java-security-private-ca by googleapis.
the class SnippetsIT method testCreateCertificate.
@Test
public void testCreateCertificate() throws IOException {
// Check if the certificate created during setup is successful.
try (CertificateAuthorityServiceClient certificateAuthorityServiceClient = CertificateAuthorityServiceClient.create()) {
CertificateName certificateName = CertificateName.of(PROJECT_ID, LOCATION, CA_POOL_ID, CERTIFICATE_NAME);
Certificate certificate = certificateAuthorityServiceClient.getCertificate(certificateName);
assertThat(certificate.getName()).contains(CERTIFICATE_NAME);
}
}
use of com.android.apksig.internal.x509.Certificate in project java-security-private-ca by googleapis.
the class SnippetsIT method testCreateCertificateWithCSR.
@Test
public void testCreateCertificateWithCSR() throws IOException {
try (CertificateAuthorityServiceClient certificateAuthorityServiceClient = CertificateAuthorityServiceClient.create()) {
Certificate response = certificateAuthorityServiceClient.getCertificate(CertificateName.of(PROJECT_ID, LOCATION, CA_POOL_ID, CSR_CERTIFICATE_NAME).toString());
Assert.assertTrue(response.hasCreateTime());
}
}
Aggregations