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 classFilePasswordProvider.ResourceDecodeResult
-
Field Summary
Fields Modifier and Type Field Description static FilePasswordProviderEMPTYAn "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 StringgetPassword(SessionContext session, NamedResource resourceKey, int retryIndex)default FilePasswordProvider.ResourceDecodeResulthandleDecodeAttemptResult(SessionContext session, NamedResource resourceKey, int retryIndex, String password, Exception err)Invoked to inform the password provide about the decoding result.static FilePasswordProviderof(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- TheSessionContextfor invoking this load command - may benullif 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- TheSessionContextfor invoking this load command - may benullif 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 -nullfor success- Returns:
- How to proceed in case of error - ignored if invoked in order to report
success. Note:
nullis 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)
-
-