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

public Interface FilePasswordProvider

Annotations
@FunctionalInterface
Imports
java.io.IOException, java.net.ProtocolException, java.security.GeneralSecurityException, java.util.Collections, .EnumSet, .Set, javax.security.auth.login.FailedLoginException, org.apache.sshd.common.NamedResource, org.apache.sshd.common.session.SessionContext, org.apache.sshd.common.util.GenericUtils

Author
Apache MINA SSHD Project

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
FilePasswordProvider.Decoder<
type of the result
T
>

Something that can produce a result given a password.

public static enum

Field Summary

Modifier and TypeField and Description
public static final FilePasswordProvider
EMPTY

An "empty" provider that returns null - i.e., unprotected key file

Method Summary

Modifier and TypeMethod and Description
public default <
Result type of the decoder
T
>
T

Returns:

the decoder's result, or null if none
decode
(SessionContext
SessionContext, may be null
session
,
NamedResource
NamedResource used for error reporting
resourceKey
,
FilePasswordProvider.Decoder<? extends T>
Decoder to produce the result given a password
decoder
)

Obtains the password through getPassword(SessionContext, NamedResource, int), invokes the Decoder and then handleDecodeAttemptResult(SessionContext, NamedResource, int, String, Exception) and then returns the decoded result.

public String

Returns:

The password - if null/empty then no password is required
getPassword
(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
,
NamedResource
The resource key representing the private file
resourceKey
,
int
The zero-based index of the invocation for the specific resource (in case invoked several times for the same resource)
retryIndex
)

public default FilePasswordProvider.ResourceDecodeResult

Returns:

How to proceed in case of error - ignored if invoked in order to report success

Note

null is same as ResourceDecodeResult#TERMINATE.

handleDecodeAttemptResult
(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
,
NamedResource
The resource key representing the private file
resourceKey
,
int
The zero-based index of the invocation for the specific resource (in case invoked several times for the same resource). If success report, it indicates the number of retries it took to succeed
retryIndex
,
String
The password that was attempted
password
,
Exception
The attempt result - null for success
err
)

Invoked to inform the password provide about the decoding result

Note

any exception thrown from this method (including if called to inform about success) will be propagated instead of the original (if any was reported)

public static FilePasswordProvider
of(String password)

Field Detail

EMPTYback to summary
public static final FilePasswordProvider EMPTY

An "empty" provider that returns null - i.e., unprotected key file

Method Detail

decodeback to summary
public default <T> T decode(SessionContext session, NamedResource resourceKey, FilePasswordProvider.Decoder<? extends T> decoder) throws IOException, GeneralSecurityException

Obtains the password through getPassword(SessionContext, NamedResource, int), invokes the Decoder and then handleDecodeAttemptResult(SessionContext, NamedResource, int, String, Exception) and then returns the decoded result. If the decoder fails and the ResourceDecodeResult is ResourceDecodeResult#RETRY, the whole process is re-tried.

Parameters
<T>
Result type of the decoder
session:SessionContext

SessionContext, may be null

resourceKey:NamedResource

NamedResource used for error reporting

decoder:FilePasswordProvider.Decoder<? extends T>

Decoder to produce the result given a password

Returns:T

the decoder's result, or null if none

Exceptions
IOException:
if an I/O problem occurs
GeneralSecurityException:
if the decoder throws it
getPasswordback to summary
public String getPassword(SessionContext session, NamedResource resourceKey, int retryIndex) throws IOException
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).

resourceKey:NamedResource

The resource key representing the private file

retryIndex:int

The zero-based index of the invocation for the specific resource (in case invoked several times for the same resource)

Returns:String

The password - if null/empty then no password is required

Exceptions
IOException:
if cannot resolve password
See Also
handleDecodeAttemptResult(SessionContext, NamedResource, int, String, Exception)
handleDecodeAttemptResultback to summary
public default FilePasswordProvider.ResourceDecodeResult handleDecodeAttemptResult(SessionContext session, NamedResource resourceKey, int retryIndex, String password, Exception err) throws IOException, GeneralSecurityException

Invoked to inform the password provide about the decoding result

Note

any exception thrown from this method (including if called to inform about success) will be propagated instead of the original (if any was reported)

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).

resourceKey:NamedResource

The resource key representing the private file

retryIndex:int

The zero-based index of the invocation for the specific resource (in case invoked several times for the same resource). If success report, it indicates the number of retries it took to succeed

password:String

The password that was attempted

err:Exception

The attempt result - null for success

Returns:FilePasswordProvider.ResourceDecodeResult

How to proceed in case of error - ignored if invoked in order to report success

Note

null is same as ResourceDecodeResult#TERMINATE.

Exceptions
IOException:
If cannot resolve a new password
GeneralSecurityException:
If not attempting to resolve a new password
ofback to summary
public static FilePasswordProvider of(String password)
org.apache.sshd.common.config.keys back to summary

public Interface FilePasswordProvider.Decoder<T>

Type Parameters
<T>
type of the result

Something that can produce a result given a password.

Method Summary

Modifier and TypeMethod and Description
public T
decode(String password)

Method Detail

decodeback to summary
public T decode(String password) throws IOException, GeneralSecurityException
org.apache.sshd.common.config.keys back to summary

public final Enum FilePasswordProvider.ResourceDecodeResult

extends Enum<FilePasswordProvider.ResourceDecodeResult>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final FilePasswordProvider.ResourceDecodeResult
IGNORE

Skip attempt and see if can proceed without the key

public static final FilePasswordProvider.ResourceDecodeResult
RETRY

Try again the decoding process - including password prompt

public static final FilePasswordProvider.ResourceDecodeResult
TERMINATE

Re-throw the decoding exception

public static final Set<FilePasswordProvider.ResourceDecodeResult>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static FilePasswordProvider.ResourceDecodeResult
public static FilePasswordProvider.ResourceDecodeResult[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

IGNOREback to summary
public static final FilePasswordProvider.ResourceDecodeResult IGNORE

Skip attempt and see if can proceed without the key

RETRYback to summary
public static final FilePasswordProvider.ResourceDecodeResult RETRY

Try again the decoding process - including password prompt

TERMINATEback to summary
public static final FilePasswordProvider.ResourceDecodeResult TERMINATE

Re-throw the decoding exception

VALUESback to summary
public static final Set<FilePasswordProvider.ResourceDecodeResult> VALUES

Constructor Detail

ResourceDecodeResultback to summary
private ResourceDecodeResult()

Method Detail

valueOfback to summary
public static FilePasswordProvider.ResourceDecodeResult valueOf(String name)
valuesback to summary
public static FilePasswordProvider.ResourceDecodeResult[] values()