Interface KeyPairResourceWriter<OPTIONS extends PrivateKeyEncryptionContext>

    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      void writePrivateKey​(java.security.KeyPair key, java.lang.String comment, OPTIONS options, java.io.OutputStream out)
      Writes a serialization of a private key from a given KeyPair to a given OutputStream.
      default void writePublicKey​(java.security.KeyPair key, java.lang.String comment, java.io.OutputStream out)
      Writes a serialization of a public key from a given KeyPair to a given OutputStream.
      void writePublicKey​(java.security.PublicKey key, java.lang.String comment, java.io.OutputStream out)
      Writes a serialization of a PublicKey to a given OutputStream.
    • Method Detail

      • writePrivateKey

        void writePrivateKey​(java.security.KeyPair key,
                             java.lang.String comment,
                             OPTIONS options,
                             java.io.OutputStream out)
                      throws java.io.IOException,
                             java.security.GeneralSecurityException
        Writes a serialization of a private key from a given KeyPair to a given OutputStream.
        Parameters:
        key - to write the private key of
        comment - to write with the private key
        options - for writing the key; may be null if no encryption is wanted. The caller is responsible for clearing the options when no longer needed. If the passphrase obtained from the context is null or an empty/blank string (length zero or containing only whitespace), the key is written unencrypted.
        out - The OutputStream to write to - recommend using a SecureByteArrayOutputStream in order to reduce sensitive data exposure in memory
        Throws:
        java.security.GeneralSecurityException - if the key is inconsistent or unknown, or the encryption specified cannot be applied
        java.io.IOException - if the key cannot be written
      • writePublicKey

        default void writePublicKey​(java.security.KeyPair key,
                                    java.lang.String comment,
                                    java.io.OutputStream out)
                             throws java.io.IOException,
                                    java.security.GeneralSecurityException
        Writes a serialization of a public key from a given KeyPair to a given OutputStream.
        Parameters:
        key - to write the public key of
        comment - to write with the public key
        out - The OutputStream to write to - recommend using a SecureByteArrayOutputStream in order to reduce sensitive data exposure in memory
        Throws:
        java.security.GeneralSecurityException - if the key is unknown
        java.io.IOException - if the key cannot be written
      • writePublicKey

        void writePublicKey​(java.security.PublicKey key,
                            java.lang.String comment,
                            java.io.OutputStream out)
                     throws java.io.IOException,
                            java.security.GeneralSecurityException
        Writes a serialization of a PublicKey to a given OutputStream.
        Parameters:
        key - to write
        comment - to write with the key
        out - The OutputStream to write to - recommend using a SecureByteArrayOutputStream in order to reduce sensitive data exposure in memory
        Throws:
        java.security.GeneralSecurityException - if the key is unknown
        java.io.IOException - if the key cannot be written