Top Fields Methods
org.apache.sshd.common.config.keys

public Interface PrivateKeyEntryDecoder<PUB extends PublicKey, PRV extends PrivateKey>

extends KeyEntryResolver<PUB extends PublicKey, PRV extends PrivateKey>, PrivateKeyEntryResolver
Known Direct Implementers
org.apache.sshd.common.config.keys.impl.AbstractPrivateKeyEntryDecoder
Type Parameters
<PUB>
Type of PublicKey
<PRV>
Type of PrivateKey
Imports
java.io.ByteArrayInputStream, .IOException, .InputStream, .StreamCorruptedException, java.security.GeneralSecurityException, .PrivateKey, .PublicKey, java.security.spec.InvalidKeySpecException, java.util.Collection, .Objects, org.apache.sshd.common.config.keys.loader.KeyPairResourceLoader, org.apache.sshd.common.session.SessionContext, org.apache.sshd.common.util.GenericUtils, .NumberUtils, .ValidateUtils, org.apache.sshd.common.util.io.output.SecureByteArrayOutputStream

Author
Apache MINA SSHD Project

Field Summary

Inherited from org.apache.sshd.common.config.keys.PrivateKeyEntryResolver:
FAILINGIGNORING

Method Summary

Modifier and TypeMethod and Description
public default PRV

Returns:

The decoded PrivateKey - or null if no data
decodePrivateKey
(SessionContext
The SessionContext for invoking this load command - may be null if not invoked within a session context (e.g., offline tool or session unknown).
session
,
FilePasswordProvider
The FilePasswordProvider to use in case the data is encrypted - may be null if no encrypted data is expected
passwordProvider
,
byte...
The key data bytes in OpenSSH format (after BASE64 decoding) - ignored if null/empty
keyData
)

public default PRV
decodePrivateKey(SessionContext session, FilePasswordProvider passwordProvider, byte[] keyData, int offset, int length)

public default PRV
public PRV

Returns:

The decoded PrivateKey
decodePrivateKey
(SessionContext
The SessionContext for invoking this load command - may be null if not invoked within a session context (e.g., offline tool or session unknown).
session
,
String
The reported / encode key type
keyType
,
FilePasswordProvider
The FilePasswordProvider to use in case the data is encrypted - may be null if no encrypted data is expected
passwordProvider
,
InputStream
The key data bytes stream positioned after the key type decoding and making sure it is one of the supported types
keyData
)

public default String

Returns:

The key type value - one of the getSupportedKeyTypes() or null if encoding not supported
encodePrivateKey
(SecureByteArrayOutputStream
The SecureByteArrayOutputStream to write the data to.
s
,
PRV
The PrivateKey - may not be null
key
,
PUB
The PublicKey belonging to the private key - must be non-null if public key recovery is not supported
pubKey
)

Encodes the PrivateKey using the OpenSSH format - same one used by the decodePublicKey method(s)

public default boolean
public default PUB

Returns:

The recovered PublicKey - null if cannot recover it
recoverPublicKey
(PRV prvKey)

Attempts to recover the public key given the private one

public default PrivateKey
resolve(SessionContext
The SessionContext for invoking this load command - may be null if not invoked within a session context (e.g., offline tool or session unknown).
session
,
String
The OpenSSH reported key type
keyType
,
byte[]
The OpenSSH encoded key data
keyData
)

Implements org.apache.sshd.common.config.keys.PrivateKeyEntryResolver.resolve.

Inherited from org.apache.sshd.common.config.keys.KeyEntryResolver:
cloneKeyPairclonePrivateKeyclonePublicKeydecodeBigIntdecodeIntdecodeIntdecodeIntdecodeStringdecodeStringdecodeStringdecodeStringdecodeStringdecodeStringdecodeStringencodeBigIntencodeIntencodeStringencodeStringencodeStringgenerateKeyPairgetKeyFactoryInstancegetKeyPairGeneratorreadRLEBytesreadRLEBytesreadRLEByteswriteRLEByteswriteRLEBytes

Method Detail

decodePrivateKeyback to summary
public default PRV decodePrivateKey(SessionContext session, FilePasswordProvider passwordProvider, byte... keyData) throws IOException, GeneralSecurityException
Parameters
session:SessionContext

The SessionContext for invoking this load command - may be null if not invoked within a session context (e.g., offline tool or session unknown).

passwordProvider:FilePasswordProvider

The FilePasswordProvider to use in case the data is encrypted - may be null if no encrypted data is expected

keyData:byte[]

The key data bytes in OpenSSH format (after BASE64 decoding) - ignored if null/empty

Returns:PRV

The decoded PrivateKey - or null if no data

Exceptions
IOException:
If failed to decode the key
GeneralSecurityException:
If failed to generate the key
decodePrivateKeyback to summary
public default PRV decodePrivateKey(SessionContext session, FilePasswordProvider passwordProvider, byte[] keyData, int offset, int length) throws IOException, GeneralSecurityException
decodePrivateKeyback to summary
public default PRV decodePrivateKey(SessionContext session, FilePasswordProvider passwordProvider, InputStream keyData) throws IOException, GeneralSecurityException
decodePrivateKeyback to summary
public PRV decodePrivateKey(SessionContext session, String keyType, FilePasswordProvider passwordProvider, InputStream keyData) throws IOException, GeneralSecurityException
Parameters
session:SessionContext

The SessionContext for invoking this load command - may be null if not invoked within a session context (e.g., offline tool or session unknown).

keyType:String

The reported / encode key type

passwordProvider:FilePasswordProvider

The FilePasswordProvider to use in case the data is encrypted - may be null if no encrypted data is expected

keyData:InputStream

The key data bytes stream positioned after the key type decoding and making sure it is one of the supported types

Returns:PRV

The decoded PrivateKey

Exceptions
IOException:
If failed to read from the data stream
GeneralSecurityException:
If failed to generate the key
encodePrivateKeyback to summary
public default String encodePrivateKey(SecureByteArrayOutputStream s, PRV key, PUB pubKey) throws IOException

Encodes the PrivateKey using the OpenSSH format - same one used by the decodePublicKey method(s)

Parameters
s:SecureByteArrayOutputStream

The SecureByteArrayOutputStream to write the data to.

key:PRV

The PrivateKey - may not be null

pubKey:PUB

The PublicKey belonging to the private key - must be non-null if public key recovery is not supported

Returns:String

The key type value - one of the getSupportedKeyTypes() or null if encoding not supported

Exceptions
IOException:
If failed to generate the encoding
isPublicKeyRecoverySupportedback to summary
public default boolean isPublicKeyRecoverySupported()
recoverPublicKeyback to summary
public default PUB recoverPublicKey(PRV prvKey) throws GeneralSecurityException

Attempts to recover the public key given the private one

Parameters
prvKey:PRV

The PrivateKey

Returns:PUB

The recovered PublicKey - null if cannot recover it

Exceptions
GeneralSecurityException:
If failed to generate the public key
resolveback to summary
public default PrivateKey resolve(SessionContext session, String keyType, byte[] keyData) throws IOException, GeneralSecurityException

Implements org.apache.sshd.common.config.keys.PrivateKeyEntryResolver.resolve.

Parameters
session:SessionContext

Doc from org.apache.sshd.common.config.keys.PrivateKeyEntryResolver.resolve.

The SessionContext for invoking this load command - may be null if not invoked within a session context (e.g., offline tool or session unknown).

keyType:String

Doc from org.apache.sshd.common.config.keys.PrivateKeyEntryResolver.resolve.

The OpenSSH reported key type

keyData:byte[]

Doc from org.apache.sshd.common.config.keys.PrivateKeyEntryResolver.resolve.

The OpenSSH encoded key data

Returns:PrivateKey

Doc from org.apache.sshd.common.config.keys.PrivateKeyEntryResolver.resolve.

The extracted PrivateKey - ignored if null

Annotations
@Override
Exceptions
IOException:

Doc from org.apache.sshd.common.config.keys.PrivateKeyEntryResolver.resolve.

If failed to parse the key data

GeneralSecurityException:

Doc from org.apache.sshd.common.config.keys.PrivateKeyEntryResolver.resolve.

If failed to generate the key