Top Description Methods
org.apache.sshd.common.config.keys.writer

public Interface KeyPairResourceWriter<OPTIONS extends PrivateKeyEncryptionContext>

Known Direct Implementers
org.apache.sshd.common.config.keys.writer.openssh.OpenSSHKeyPairResourceWriter
Type Parameters
<OPTIONS>
The type of PrivateKeyEncryptionContext to use with this KeyPairResourceWriter.
Imports
java.io.IOException, .OutputStream, java.security.GeneralSecurityException, .KeyPair, .PublicKey, org.apache.sshd.common.config.keys.loader.PrivateKeyEncryptionContext

A KeyPairResourceWriter can serialize keys to an external representation.

Method Summary

Modifier and TypeMethod and Description
public void
writePrivateKey(KeyPair
to write the private key of
key
,
String
to write with the private key
comment
,
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.
options
,
OutputStream
The OutputStream to write to - recommend using a SecureByteArrayOutputStream in order to reduce sensitive data exposure in memory
out
)

Writes a serialization of a private key from a given KeyPair to a given OutputStream.

public default void
writePublicKey(KeyPair
to write the public key of
key
,
String
to write with the public key
comment
,
OutputStream
The OutputStream to write to - recommend using a SecureByteArrayOutputStream in order to reduce sensitive data exposure in memory
out
)

Writes a serialization of a public key from a given KeyPair to a given OutputStream.

public void
writePublicKey(PublicKey
to write
key
,
String
to write with the key
comment
,
OutputStream
The OutputStream to write to - recommend using a SecureByteArrayOutputStream in order to reduce sensitive data exposure in memory
out
)

Writes a serialization of a PublicKey to a given OutputStream.

Method Detail

writePrivateKeyback to summary
public void writePrivateKey(KeyPair key, String comment, OPTIONS options, OutputStream out) throws IOException, GeneralSecurityException

Writes a serialization of a private key from a given KeyPair to a given OutputStream.

Parameters
key:KeyPair

to write the private key of

comment:String

to write with the private key

options: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:OutputStream

The OutputStream to write to - recommend using a SecureByteArrayOutputStream in order to reduce sensitive data exposure in memory

Exceptions
IOException:
if the key cannot be written
GeneralSecurityException:
if the key is inconsistent or unknown, or the encryption specified cannot be applied
writePublicKeyback to summary
public default void writePublicKey(KeyPair key, String comment, OutputStream out) throws IOException, GeneralSecurityException

Writes a serialization of a public key from a given KeyPair to a given OutputStream.

Parameters
key:KeyPair

to write the public key of

comment:String

to write with the public key

out:OutputStream

The OutputStream to write to - recommend using a SecureByteArrayOutputStream in order to reduce sensitive data exposure in memory

Exceptions
IOException:
if the key cannot be written
GeneralSecurityException:
if the key is unknown
writePublicKeyback to summary
public void writePublicKey(PublicKey key, String comment, OutputStream out) throws IOException, GeneralSecurityException

Writes a serialization of a PublicKey to a given OutputStream.

Parameters
key:PublicKey

to write

comment:String

to write with the key

out:OutputStream

The OutputStream to write to - recommend using a SecureByteArrayOutputStream in order to reduce sensitive data exposure in memory

Exceptions
IOException:
if the key cannot be written
GeneralSecurityException:
if the key is unknown