Interface PublicKeyAuthenticationProvider
- All Superinterfaces:
Authenticator
- All Known Implementing Classes:
AbstractPublicKeyAuthenticationProvider,AuthorizedKeysPublicKeyAuthenticationProvider,OpenSshCertificateAuthenticationProvider,PublicKeyAuthenticationAdapter,UniversalAuthenticationProvider
This interface allows you to define a custom public key store for the publickey authentication mechanism. The actual key verification is performed by the mechanism itself and your only requirement is to return a value which indicates whether the key has been authorized by the user for public key access.
The implementation may optionally support addition, removal and listing of
keys. When supported, PublicKeySubsystemServer may be used. If not required
the methods should thrown UnsupportedOperationException.
- Author:
- Lee David Painter
-
Method Summary
Modifier and TypeMethodDescriptionvoidadd(SshPublicKey key, String comment, SshConnection con) booleancheckKey(SshPublicKey key, SshConnection con) getKeys(SshConnection con) booleanisAuthorizedKey(SshPublicKey key, SshConnection con) Check the supplied public key against the users authorized keys.voidremove(SshPublicKey key, SshConnection con)
-
Method Details
-
isAuthorizedKey
Check the supplied public key against the users authorized keys. The actual verification of the key is performed by the server, you only need to return a value to indicate whether the key is authorized or not. You can obtain the username, home directory, group or remote socket address from the
com.sshtools.common.auth.server.PasswordAuthenticationProviderinstance.If your authorized key database is kept on the native file system you can obtain and initialize an instance as follows:
Don't forget to close any file handles and the file system once you've done accessing files.NativeFileSystemProvider nfs = (NativeFileSystemProvider) authenticationProvider .getContext().getFileSystemProvider().newInstance(); nfs.init(sessionid, null, authenticationProvider.getContext());- Parameters:
key- SshPublicKeycon- connectionauthenticationProvider- AuthenticationProvider- Returns:
- boolean true if the key is an authorized key, otherwise false
- Throws:
IOException
-
checkKey
- Throws:
IOException
-
getKeys
- Throws:
PermissionDeniedExceptionIOException
-
remove
void remove(SshPublicKey key, SshConnection con) throws IOException, PermissionDeniedException, SshException -
add
void add(SshPublicKey key, String comment, SshConnection con) throws IOException, PermissionDeniedException, SshException
-