Home / Class/ X509Bundle Class — netty Architecture

X509Bundle Class — netty Architecture

Architecture documentation for the X509Bundle class in X509Bundle.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  52390b39_f5c1_cc6d_e53c_96e2c2ffa126["X509Bundle"]
  4e80273e_50c9_c9fa_57e2_8ef7479632c1["X509Bundle.java"]
  52390b39_f5c1_cc6d_e53c_96e2c2ffa126 -->|defined in| 4e80273e_50c9_c9fa_57e2_8ef7479632c1
  ab9ec1fd_2f73_2cf5_a583_8e6ea7f0728f["X509Bundle()"]
  52390b39_f5c1_cc6d_e53c_96e2c2ffa126 -->|method| ab9ec1fd_2f73_2cf5_a583_8e6ea7f0728f
  da74f4fe_d010_1676_e61b_8affc34d39bb["X509Certificate()"]
  52390b39_f5c1_cc6d_e53c_96e2c2ffa126 -->|method| da74f4fe_d010_1676_e61b_8affc34d39bb
  c1483e21_97c0_ac5a_b042_ce0a2f042aef["String()"]
  52390b39_f5c1_cc6d_e53c_96e2c2ffa126 -->|method| c1483e21_97c0_ac5a_b042_ce0a2f042aef
  3572d95b_5768_64aa_cdfe_912af895ea27["getCertificatePath()"]
  52390b39_f5c1_cc6d_e53c_96e2c2ffa126 -->|method| 3572d95b_5768_64aa_cdfe_912af895ea27
  973dad2d_9ea5_8d9b_f47b_e196a655007c["getCertificatePathWithRoot()"]
  52390b39_f5c1_cc6d_e53c_96e2c2ffa126 -->|method| 973dad2d_9ea5_8d9b_f47b_e196a655007c
  0168cdc6_c3d1_7fb2_2d76_ecbac48a1482["getCertificatePathList()"]
  52390b39_f5c1_cc6d_e53c_96e2c2ffa126 -->|method| 0168cdc6_c3d1_7fb2_2d76_ecbac48a1482
  d1b5cd22_191f_ad84_7f53_a1eca45154f7["KeyPair()"]
  52390b39_f5c1_cc6d_e53c_96e2c2ffa126 -->|method| d1b5cd22_191f_ad84_7f53_a1eca45154f7
  7e94000b_653a_89d4_d929_9df417048bde["getMimeEncoder()"]
  52390b39_f5c1_cc6d_e53c_96e2c2ffa126 -->|method| 7e94000b_653a_89d4_d929_9df417048bde
  0c63e378_73fe_b654_1e34_be4d46432d09["TrustAnchor()"]
  52390b39_f5c1_cc6d_e53c_96e2c2ffa126 -->|method| 0c63e378_73fe_b654_1e34_be4d46432d09
  fb9f9d8a_dd4a_938c_8e46_e26b841fd26e["isCertificateAuthority()"]
  52390b39_f5c1_cc6d_e53c_96e2c2ffa126 -->|method| fb9f9d8a_dd4a_938c_8e46_e26b841fd26e
  cdebcf8a_a27e_aee3_4be4_5e910ce566f3["isSelfSigned()"]
  52390b39_f5c1_cc6d_e53c_96e2c2ffa126 -->|method| cdebcf8a_a27e_aee3_4be4_5e910ce566f3
  3a098f27_9c5c_a8f5_bf34_769702624694["TrustManager()"]
  52390b39_f5c1_cc6d_e53c_96e2c2ffa126 -->|method| 3a098f27_9c5c_a8f5_bf34_769702624694
  8b2d6ca5_6548_a430_5702_15daea528337["TrustManagerFactory()"]
  52390b39_f5c1_cc6d_e53c_96e2c2ffa126 -->|method| 8b2d6ca5_6548_a430_5702_15daea528337

Relationship Graph

Source Code

pkitesting/src/main/java/io/netty/pkitesting/X509Bundle.java lines 51–455

public final class X509Bundle {
    private final X509Certificate[] certPath;
    private final X509Certificate root;
    private final KeyPair keyPair;

    /**
     * Construct a bundle from a given certificate path, root certificate, and {@link KeyPair}.
     * @param certPath The certificate path, starting with the leaf certificate.The path can end either with the
     * root certificate, or the intermediate certificate signed by the root certificate.
     * @param root The self-signed root certificate.
     * @param keyPair The key pair.
     */
    private X509Bundle(X509Certificate[] certPath, X509Certificate root, KeyPair keyPair) {
        requireNonNull(root, "root");
        requireNonNull(keyPair, "keyPair");
        if (certPath.length > 1 && certPath[certPath.length - 1].equals(root)) {
            this.certPath = Arrays.copyOf(certPath, certPath.length - 1);
        } else {
            this.certPath = certPath.clone();
        }
        this.root = root;
        this.keyPair = keyPair;
    }

    /**
     * Construct a bundle for a certificate authority.
     * @param root The self-signed root certificate.
     * @param keyPair The key pair.
     * @return The new bundle.
     */
    public static X509Bundle fromRootCertificateAuthority(X509Certificate root, KeyPair keyPair) {
        requireNonNull(root, "root");
        requireNonNull(keyPair, "keyPair");
        X509Bundle bundle = new X509Bundle(new X509Certificate[]{root}, root, keyPair);
        if (!bundle.isCertificateAuthority() || !bundle.isSelfSigned()) {
            throw new IllegalArgumentException("Given certificate is not a root CA certificate: " +
                    root.getSubjectX500Principal() + ", issued by " + root.getIssuerX500Principal());
        }
        return bundle;
    }

    /**
     * Construct a bundle from a given certificate path, root certificate, and {@link KeyPair}.
     * @param certPath The certificate path, starting with the leaf certificate.The path can end either with the
     * root certificate, or the intermediate certificate signed by the root certificate.
     * @param root The self-signed root certificate.
     * @param keyPair The key pair.
     */
    public static X509Bundle fromCertificatePath(
            X509Certificate[] certPath, X509Certificate root, KeyPair keyPair) {
        return new X509Bundle(certPath, root, keyPair);
    }

    /**
     * Get the leaf certificate of the bundle.
     * If this bundle is for a certificate authority, then this return the same as {@link #getRootCertificate()}.
     * @return The leaf certificate.
     */
    public X509Certificate getCertificate() {
        return certPath[0];
    }

    /**
     * Get the PEM encoded string of the {@linkplain #getCertificate() leaf certificate}.
     * @return The certificate PEM string.
     */
    public String getCertificatePEM() {
        return toCertPem(certPath[0]);
    }

    /**
     * Get the certificate path, starting with the leaf certificate up to but excluding the root certificate.
     * @return The certificate path.
     */
    public X509Certificate[] getCertificatePath() {
        return certPath.clone();
    }

    /**
     * Get the certificate path, starting with the leaf certificate up to and including the root certificate.
     * @return The certificate path, including the root certificate.

Frequently Asked Questions

What is the X509Bundle class?
X509Bundle is a class in the netty codebase, defined in pkitesting/src/main/java/io/netty/pkitesting/X509Bundle.java.
Where is X509Bundle defined?
X509Bundle is defined in pkitesting/src/main/java/io/netty/pkitesting/X509Bundle.java at line 51.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free