OPTIONS - The type of PrivateKeyEncryptionContext to use with this KeyPairResourceWriter.public interface KeyPairResourceWriter<OPTIONS extends PrivateKeyEncryptionContext>
KeyPairResourceWriter can serialize keys to an external representation.| Modifier and Type | Method and Description |
|---|---|
void |
writePrivateKey(KeyPair key,
String comment,
OPTIONS options,
OutputStream out)
Writes a serialization of a private key from a given
KeyPair to a given OutputStream. |
default void |
writePublicKey(KeyPair key,
String comment,
OutputStream out)
Writes a serialization of a public key from a given
KeyPair to a given OutputStream. |
void |
writePublicKey(PublicKey key,
String comment,
OutputStream out)
Writes a serialization of a
PublicKey to a given OutputStream. |
void writePrivateKey(KeyPair key, String comment, OPTIONS options, OutputStream out) throws IOException, GeneralSecurityException
KeyPair to a given OutputStream.key - to write the private key ofcomment - to write with the private keyoptions - 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 memoryGeneralSecurityException - if the key is inconsistent or unknown, or the encryption specified cannot be
appliedIOException - if the key cannot be writtendefault void writePublicKey(KeyPair key, String comment, OutputStream out) throws IOException, GeneralSecurityException
KeyPair to a given OutputStream.key - to write the public key ofcomment - to write with the public keyout - The OutputStream to write to - recommend using a
SecureByteArrayOutputStream in order to reduce sensitive data exposure
in memoryGeneralSecurityException - if the key is unknownIOException - if the key cannot be writtenvoid writePublicKey(PublicKey key, String comment, OutputStream out) throws IOException, GeneralSecurityException
PublicKey to a given OutputStream.key - to writecomment - to write with the keyout - The OutputStream to write to - recommend using a
SecureByteArrayOutputStream in order to reduce sensitive data exposure
in memoryGeneralSecurityException - if the key is unknownIOException - if the key cannot be writtenCopyright © 2018–2024 The Apache Software Foundation. All rights reserved.