Package com.sshtools.common.auth
Class PublicKeyAuthentication<C extends Context>
java.lang.Object
com.sshtools.common.auth.PublicKeyAuthentication<C>
- All Implemented Interfaces:
AuthenticationMechanism
public class PublicKeyAuthentication<C extends Context>
extends Object
implements AuthenticationMechanism
Provides an
AuthenticationMechanism that enables the public key
authentication. The current implementation will look for an
authorized_keys file in the users home directory which is returned
from the
com.maverick.sshd.platform.NativeAuthenticationProvider#getHomeDirectory(String)
method. The format of this file is identical to that required by OpenSSH.- Author:
- Lee David Painter
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionPublicKeyAuthentication(AbstractServerTransport<C> transport, AbstractAuthenticationProtocol<C> authentication, SshConnection con, PublicKeyAuthenticationProvider[] providers) -
Method Summary
Modifier and TypeMethodDescriptionReturn the SSH method name for this authentication.booleanprocessMessage(byte[] msg) If the SSH protocol authentication method defines additional messages which are sent from the client, they will be passed into your implementation here when received.booleanstartRequest(String username, byte[] msg) Start an authentication transaction.
-
Field Details
-
SSH_MSG_USERAUTH_PK_OK
public static final int SSH_MSG_USERAUTH_PK_OK- See Also:
-
AUTHENTICATION_METHOD
- See Also:
-
-
Constructor Details
-
PublicKeyAuthentication
public PublicKeyAuthentication(AbstractServerTransport<C> transport, AbstractAuthenticationProtocol<C> authentication, SshConnection con, PublicKeyAuthenticationProvider[] providers)
-
-
Method Details
-
getMethod
Description copied from interface:AuthenticationMechanismReturn the SSH method name for this authentication. e.g "password"- Specified by:
getMethodin interfaceAuthenticationMechanism- Returns:
- String
-
startRequest
Description copied from interface:AuthenticationMechanismStart an authentication transaction. If the authentication mechanism is simple and you can determine the result from all information received in the SSH_MSG_USERAUTH_REQUEST message, you should call the approriate completion methods on thecom.maverick.sshd.AuthenticationProtocolinstance that was passed in the initialization process. The request data varies according to the authentication method.if (success) authentication.completedAuthentication(method, username, service); else authentication.failedAuthentication(method);- Specified by:
startRequestin interfaceAuthenticationMechanismmsg- the request data from the SSH_MSG_USERAUTH_REQUEST message- Returns:
- true if the message was processed, otherwise false
- Throws:
IOException
-
processMessage
Description copied from interface:AuthenticationMechanismIf the SSH protocol authentication method defines additional messages which are sent from the client, they will be passed into your implementation here when received.- Specified by:
processMessagein interfaceAuthenticationMechanism- Returns:
- boolean
- Throws:
IOException
-