Search in sources :

Example 1 with Certificate

use of com.google.cloud.security.privateca.v1.Certificate in project kubernetes-client by fabric8io.

the class V1CertificateCrudTest method shouldListAndGetCertificate.

@Test
void shouldListAndGetCertificate() {
    Certificate certificate2 = new CertificateBuilder().withNewMetadata().withName("cert2").endMetadata().build();
    client.v1().certificates().inNamespace("ns2").create(certificate2);
    CertificateList certificateList = client.v1().certificates().inNamespace("ns2").list();
    assertNotNull(certificateList);
    assertEquals(1, certificateList.getItems().size());
}
Also used : CertificateBuilder(io.fabric8.certmanager.api.model.v1.CertificateBuilder) CertificateList(io.fabric8.certmanager.api.model.v1.CertificateList) Certificate(io.fabric8.certmanager.api.model.v1.Certificate) Test(org.junit.jupiter.api.Test)

Example 2 with Certificate

use of com.google.cloud.security.privateca.v1.Certificate in project kubernetes-client by fabric8io.

the class V1alpha2CertificateCrudTest method shouldDeleteACertificate.

@Test
void shouldDeleteACertificate() {
    Certificate certificate3 = new CertificateBuilder().withNewMetadata().withName("cert3").endMetadata().build();
    client.v1alpha2().certificates().inNamespace("ns3").create(certificate3);
    Boolean deleted = client.v1alpha2().certificates().inNamespace("ns3").withName("cert3").delete();
    assertTrue(deleted);
}
Also used : CertificateBuilder(io.fabric8.certmanager.api.model.v1alpha2.CertificateBuilder) Certificate(io.fabric8.certmanager.api.model.v1alpha2.Certificate) Test(org.junit.jupiter.api.Test)

Example 3 with Certificate

use of com.google.cloud.security.privateca.v1.Certificate in project kubernetes-client by fabric8io.

the class V1beta1CertificateCrudTest method shouldDeleteACertificate.

@Test
void shouldDeleteACertificate() {
    Certificate certificate3 = new CertificateBuilder().withNewMetadata().withName("cert3").endMetadata().build();
    client.v1beta1().certificates().inNamespace("ns3").create(certificate3);
    Boolean deleted = client.v1beta1().certificates().inNamespace("ns3").withName("cert3").delete();
    assertTrue(deleted);
}
Also used : CertificateBuilder(io.fabric8.certmanager.api.model.v1beta1.CertificateBuilder) Certificate(io.fabric8.certmanager.api.model.v1beta1.Certificate) Test(org.junit.jupiter.api.Test)

Example 4 with Certificate

use of com.google.cloud.security.privateca.v1.Certificate in project kubernetes-client by fabric8io.

the class V1beta1CertificateCrudTest method shouldLoadCertificate.

@Test
void shouldLoadCertificate() {
    String certificateDefinition = String.join("\n", Arrays.asList("apiVersion: cert-manager.io/v1beta1", "kind: Certificate", "metadata:", "  name: ca-issuer", "spec:", "  isCA: true", "  secretName: ca-key-pair", "  commonName: my-csi-app", "  issuerRef:", "    name: selfsigned-issuer", "    kind: Issuer", "    group: cert-manager.io"));
    Certificate certificate = client.v1beta1().certificates().inNamespace("ns4").load(new ByteArrayInputStream(certificateDefinition.getBytes())).createOrReplace();
    assertEquals("ca-issuer", certificate.getMetadata().getName());
    assertEquals("ca-key-pair", certificate.getSpec().getSecretName());
    assertEquals("my-csi-app", certificate.getSpec().getCommonName());
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) Certificate(io.fabric8.certmanager.api.model.v1beta1.Certificate) Test(org.junit.jupiter.api.Test)

Example 5 with Certificate

use of com.google.cloud.security.privateca.v1.Certificate in project kubernetes-client by fabric8io.

the class CertificateCreate method main.

public static void main(String[] args) {
    try (NamespacedCertManagerClient certManagerClient = new DefaultCertManagerClient()) {
        String namespace = "default";
        Certificate certificate = new CertificateBuilder().build();
        // Create Certificate
        certManagerClient.v1beta1().certificates().inNamespace(namespace).create(certificate);
        System.out.println("Created: " + certificate.getMetadata().getName());
        // List Certificate
        CertificateList certificateList = certManagerClient.v1beta1().certificates().inNamespace(namespace).list();
        System.out.println("There are " + certificateList.getItems().size() + " TaskRun objects in " + namespace);
    }
}
Also used : NamespacedCertManagerClient(io.fabric8.certmanager.client.NamespacedCertManagerClient) DefaultCertManagerClient(io.fabric8.certmanager.client.DefaultCertManagerClient) CertificateBuilder(io.fabric8.certmanager.api.model.v1beta1.CertificateBuilder) CertificateList(io.fabric8.certmanager.api.model.v1beta1.CertificateList) Certificate(io.fabric8.certmanager.api.model.v1beta1.Certificate)

Aggregations

Certificate (org.bouncycastle.asn1.x509.Certificate)53 IOException (java.io.IOException)40 X509Certificate (java.security.cert.X509Certificate)37 CertificateException (java.security.cert.CertificateException)27 CertificateAuthorityServiceClient (com.google.cloud.security.privateca.v1.CertificateAuthorityServiceClient)24 Test (org.junit.Test)14 Operation (com.google.longrunning.Operation)13 File (java.io.File)11 BigInteger (java.math.BigInteger)9 CertificateEncodingException (java.security.cert.CertificateEncodingException)9 TBSCertificate (org.bouncycastle.asn1.x509.TBSCertificate)9 Test (org.junit.jupiter.api.Test)9 Certificate (com.google.cloud.security.privateca.v1.Certificate)8 SQLException (java.sql.SQLException)8 X500Name (org.bouncycastle.asn1.x500.X500Name)8 ASN1Sequence (org.bouncycastle.asn1.ASN1Sequence)7 Certificate (com.beanit.asn1bean.compiler.pkix1explicit88.Certificate)6 Extension (org.bouncycastle.asn1.x509.Extension)6 OperatorCreationException (org.bouncycastle.operator.OperatorCreationException)6 Date (java.util.Date)5