Record Class CertifiedKey

java.lang.Object
java.lang.Record
io.github.mahmoudimus.quic.tls.CertifiedKey
Record Components:
chain - the certificates, end-entity first; never empty
privateKey - the end-entity certificate's private key: EC (P-256 or P-384), RSA or Ed25519

public record CertifiedKey(List<X509Certificate> chain, PrivateKey privateKey) extends Record
A certificate chain, end-entity certificate first, and the private key for that certificate: what a server, or a client asked for a certificate, presents and signs with.
  • Constructor Details

    • CertifiedKey

      public CertifiedKey(List<X509Certificate> chain, PrivateKey privateKey)
      Validates and copies the chain.
      Parameters:
      chain - the certificates, end-entity first; never empty
      privateKey - the end-entity certificate's private key
  • Method Details

    • of

      public static CertifiedKey of(PrivateKey privateKey, X509Certificate... chain)
      A certified key from a chain given as varargs.
      Parameters:
      privateKey - the end-entity certificate's private key
      chain - the certificates, end-entity first
      Returns:
      the certified key
    • fromKeyManager

      public static CertifiedKey fromKeyManager(X509KeyManager keyManager, String alias)
      The chain and key a key manager holds under an alias.
      Parameters:
      keyManager - the key manager, such as one from a KeyManagerFactory
      alias - the alias of the key entry
      Returns:
      the certified key
      Throws:
      IllegalArgumentException - if the key manager has no chain or key for the alias
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • chain

      public List<X509Certificate> chain()
      Returns the value of the chain record component.
      Returns:
      the value of the chain record component
    • privateKey

      public PrivateKey privateKey()
      Returns the value of the privateKey record component.
      Returns:
      the value of the privateKey record component