Interface FilePasswordProvider
-
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface FilePasswordProvider
- Author:
- Apache MINA SSHD Project
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
FilePasswordProvider.ResourceDecodeResult
-
Field Summary
Fields Modifier and Type Field Description static FilePasswordProvider
EMPTY
An "empty" provider that returnsnull
- i.e., unprotected key file
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description String
getPassword(SessionContext session, NamedResource resourceKey, int retryIndex)
default FilePasswordProvider.ResourceDecodeResult
handleDecodeAttemptResult(SessionContext session, NamedResource resourceKey, int retryIndex, String password, Exception err)
Invoked to inform the password provide about the decoding result.static FilePasswordProvider
of(String password)
-
-
-
Field Detail
-
EMPTY
static final FilePasswordProvider EMPTY
An "empty" provider that returnsnull
- i.e., unprotected key file
-
-
Method Detail
-
getPassword
String getPassword(SessionContext session, NamedResource resourceKey, int retryIndex) throws IOException
- Parameters:
session
- TheSessionContext
for invoking this load command - may benull
if not invoked within a session context (e.g., offline tool or session unknown).resourceKey
- The resource key representing the private fileretryIndex
- The zero-based index of the invocation for the specific resource (in case invoked several times for the same resource)- Returns:
- The password - if
null
/empty then no password is required - Throws:
IOException
- if cannot resolve password- See Also:
handleDecodeAttemptResult(SessionContext, NamedResource, int, String, Exception)
-
handleDecodeAttemptResult
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
- TheSessionContext
for invoking this load command - may benull
if not invoked within a session context (e.g., offline tool or session unknown).resourceKey
- The resource key representing the private fileretryIndex
- 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 succeedpassword
- The password that was attemptederr
- The attempt result -null
for success- Returns:
- How to proceed in case of error - ignored if invoked in order to report
success. Note:
null
is same asFilePasswordProvider.ResourceDecodeResult.TERMINATE
. - Throws:
IOException
- If cannot resolve a new passwordGeneralSecurityException
- If not attempting to resolve a new password
-
of
static FilePasswordProvider of(String password)
-
-