Package com.sshtools.common.auth
Class UniversalAuthenticationProvider
java.lang.Object
com.sshtools.common.auth.UniversalAuthenticationProvider
- All Implemented Interfaces:
Authenticator,PublicKeyAuthenticationProvider
public class UniversalAuthenticationProvider
extends Object
implements PublicKeyAuthenticationProvider
-
Constructor Summary
ConstructorsConstructorDescriptionUniversalAuthenticationProvider(UniversalAuthenticatorAccountDatabase accountDatabase) UniversalAuthenticationProvider(UniversalAuthenticatorAccountDatabase accountDatabase, String hostname) UniversalAuthenticationProvider(UniversalAuthenticatorAccountDatabase accountDatabase, String hostname, int port) -
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)
-
Constructor Details
-
UniversalAuthenticationProvider
-
UniversalAuthenticationProvider
public UniversalAuthenticationProvider(UniversalAuthenticatorAccountDatabase accountDatabase, String hostname) -
UniversalAuthenticationProvider
public UniversalAuthenticationProvider(UniversalAuthenticatorAccountDatabase accountDatabase, String hostname, int port)
-
-
Method Details
-
isAuthorizedKey
Description copied from interface:PublicKeyAuthenticationProviderCheck 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());- Specified by:
isAuthorizedKeyin interfacePublicKeyAuthenticationProvider- Parameters:
key- SshPublicKeycon- connection- Returns:
- boolean true if the key is an authorized key, otherwise false
- Throws:
IOException
-
getKeys
public Iterator<SshPublicKeyFile> getKeys(SshConnection con) throws PermissionDeniedException, IOException - Specified by:
getKeysin interfacePublicKeyAuthenticationProvider- Throws:
PermissionDeniedExceptionIOException
-
remove
public void remove(SshPublicKey key, SshConnection con) throws IOException, PermissionDeniedException, SshException - Specified by:
removein interfacePublicKeyAuthenticationProvider- Throws:
IOExceptionPermissionDeniedExceptionSshException
-
add
public void add(SshPublicKey key, String comment, SshConnection con) throws IOException, PermissionDeniedException, SshException - Specified by:
addin interfacePublicKeyAuthenticationProvider- Throws:
IOExceptionPermissionDeniedExceptionSshException
-
checkKey
- Specified by:
checkKeyin interfacePublicKeyAuthenticationProvider- Throws:
IOException
-