Search in sources :

Example 6 with Certificate

use of com.github.zhenwei.core.asn1.x509.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 7 with Certificate

use of com.github.zhenwei.core.asn1.x509.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 8 with Certificate

use of com.github.zhenwei.core.asn1.x509.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 9 with Certificate

use of com.github.zhenwei.core.asn1.x509.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)

Example 10 with Certificate

use of com.github.zhenwei.core.asn1.x509.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.v1().certificates().inNamespace(namespace).create(certificate);
        System.out.println("Created: " + certificate.getMetadata().getName());
        // List Certificate
        CertificateList certificateList = certManagerClient.v1().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.v1.CertificateBuilder) CertificateList(io.fabric8.certmanager.api.model.v1.CertificateList) Certificate(io.fabric8.certmanager.api.model.v1.Certificate)

Aggregations

IOException (java.io.IOException)242 X509Certificate (java.security.cert.X509Certificate)216 Date (java.util.Date)133 X500Name (org.bouncycastle.asn1.x500.X500Name)133 BigInteger (java.math.BigInteger)120 ContentSigner (org.bouncycastle.operator.ContentSigner)102 X509CertificateHolder (org.bouncycastle.cert.X509CertificateHolder)101 GeneralName (org.bouncycastle.asn1.x509.GeneralName)100 JcaContentSignerBuilder (org.bouncycastle.operator.jcajce.JcaContentSignerBuilder)96 CertificateException (java.security.cert.CertificateException)95 ArrayList (java.util.ArrayList)90 JcaX509CertificateConverter (org.bouncycastle.cert.jcajce.JcaX509CertificateConverter)85 X509v3CertificateBuilder (org.bouncycastle.cert.X509v3CertificateBuilder)82 SubjectPublicKeyInfo (org.bouncycastle.asn1.x509.SubjectPublicKeyInfo)78 GeneralSecurityException (java.security.GeneralSecurityException)69 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)62 GeneralNames (org.bouncycastle.asn1.x509.GeneralNames)62 Extension (org.bouncycastle.asn1.x509.Extension)61 BasicConstraints (org.bouncycastle.asn1.x509.BasicConstraints)60 AlgorithmIdentifier (org.bouncycastle.asn1.x509.AlgorithmIdentifier)59