Package com.sshtools.common.auth
Class AuthorizedKeysPublicKeyAuthenticationProvider
java.lang.Object
com.sshtools.common.auth.AbstractPublicKeyAuthenticationProvider
com.sshtools.common.auth.AuthorizedKeysPublicKeyAuthenticationProvider
- All Implemented Interfaces:
Authenticator,PublicKeyAuthenticationProvider
public class AuthorizedKeysPublicKeyAuthenticationProvider
extends AbstractPublicKeyAuthenticationProvider
This class implements the OpenSSH style authorized_keys public key store.
- Author:
- Lee David Painter
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected StringThe path relative to the users home directory from which to load authorized keys -
Constructor Summary
ConstructorsConstructorDescriptionCreate a default authorized_keys store that reads keys from .ssh/authorized_keys.AuthorizedKeysPublicKeyAuthenticationProvider(String authorizedKeysFile) Create an authorized keys stores that reads keys from a custom location. -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(SshPublicKey key, String comment, SshConnection con) booleancheckKey(SshPublicKey key, SshConnection con) protected InputStreamprotected OutputStreamprotected AbstractFilegetFile(SshConnection con) getKeys(SshConnection con) booleanisAuthorizedKey(SshPublicKey key, SshConnection con) Checks the given public key by comparing it against the public keys stored in the users authorized_keys file.voidremove(SshPublicKey key, SshConnection con) Methods inherited from class com.sshtools.common.auth.AbstractPublicKeyAuthenticationProvider
getName
-
Field Details
-
authorizedKeysFile
The path relative to the users home directory from which to load authorized keys
-
-
Constructor Details
-
AuthorizedKeysPublicKeyAuthenticationProvider
public AuthorizedKeysPublicKeyAuthenticationProvider()Create a default authorized_keys store that reads keys from .ssh/authorized_keys. -
AuthorizedKeysPublicKeyAuthenticationProvider
Create an authorized keys stores that reads keys from a custom location.- Parameters:
authorizedKeysFile- String
-
-
Method Details
-
isAuthorizedKey
Checks the given public key by comparing it against the public keys stored in the users authorized_keys file.- Parameters:
key- SshPublicKeysessionid- byte[]authenticationProvider- AuthenticationProvider- Returns:
- boolean
-
getAuthorizedKeysInputStream
protected InputStream getAuthorizedKeysInputStream(SshConnection con) throws PermissionDeniedException, IOException - Throws:
PermissionDeniedExceptionIOException
-
getAuthorizedKeysOutputStream
protected OutputStream getAuthorizedKeysOutputStream(SshConnection con) throws PermissionDeniedException, IOException - Throws:
PermissionDeniedExceptionIOException
-
add
public void add(SshPublicKey key, String comment, SshConnection con) throws IOException, PermissionDeniedException, SshException - Specified by:
addin interfacePublicKeyAuthenticationProvider- Overrides:
addin classAbstractPublicKeyAuthenticationProvider- Throws:
IOExceptionPermissionDeniedExceptionSshException
-
remove
public void remove(SshPublicKey key, SshConnection con) throws IOException, PermissionDeniedException, SshException - Specified by:
removein interfacePublicKeyAuthenticationProvider- Overrides:
removein classAbstractPublicKeyAuthenticationProvider- Throws:
IOExceptionPermissionDeniedExceptionSshException
-
getKeys
public Iterator<SshPublicKeyFile> getKeys(SshConnection con) throws PermissionDeniedException, IOException - Specified by:
getKeysin interfacePublicKeyAuthenticationProvider- Overrides:
getKeysin classAbstractPublicKeyAuthenticationProvider- Throws:
PermissionDeniedExceptionIOException
-
getFile
- Throws:
PermissionDeniedExceptionIOException
-
checkKey
- Specified by:
checkKeyin interfacePublicKeyAuthenticationProvider- Overrides:
checkKeyin classAbstractPublicKeyAuthenticationProvider- Throws:
IOException
-