Package com.sshtools.server
Class NoneAuthentication
java.lang.Object
com.sshtools.server.NoneAuthentication
- All Implemented Interfaces:
com.sshtools.common.auth.AuthenticationMechanism
public class NoneAuthentication
extends Object
implements com.sshtools.common.auth.AuthenticationMechanism
This authentication mechanism can be used to send custom banner messages to the client. When an SSH client connects it sends a 'none' authentication request with the username of the connecting user, normally the Maverick SSHD will send the default banner message configured in the ConfigurationContext.
However you can extend this class and override the getBannerForUser method to return a banner message for a specific user. To configure the SSHD to use your class instead of the default behaviour add it to the supported authentication mechanisms in your SshDaemon.configure method. Also make sure that no banner is configured in the SshContext.
context.supportedAuthenticationMechanisms().add("none", MyNoneAuthentication.class);
-
Constructor Summary
ConstructorsConstructorDescriptionNoneAuthentication
(com.sshtools.synergy.ssh.TransportProtocol<SshServerContext> transport, AuthenticationProtocolServer auth) -
Method Summary
Modifier and TypeMethodDescriptiongetBannerForUser
(String username) Override this method to send user customized banners, if this method is overridden then com.maverick.sshd.SshContext.setBannerMessage(null) should be set to null.final String
Return the SSH method name for this authentication.final void
init
(com.sshtools.synergy.ssh.TransportProtocol<SshServerContext> transport, AuthenticationProtocolServer authentication) Initializes the mechanism with variables.final boolean
processMessage
(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.final boolean
startRequest
(String username, byte[] msg) Start an authentication transaction.
-
Constructor Details
-
NoneAuthentication
public NoneAuthentication() -
NoneAuthentication
public NoneAuthentication(com.sshtools.synergy.ssh.TransportProtocol<SshServerContext> transport, AuthenticationProtocolServer auth)
-
-
Method Details
-
getMethod
Return the SSH method name for this authentication.- Specified by:
getMethod
in interfacecom.sshtools.common.auth.AuthenticationMechanism
- Returns:
- String
-
init
public final void init(com.sshtools.synergy.ssh.TransportProtocol<SshServerContext> transport, AuthenticationProtocolServer authentication) throws IOException Initializes the mechanism with variables.- Parameters:
transport
- the transport protocolauthentication
- the authentication protocolsessionid
- the id of the current session.- Throws:
IOException
-
processMessage
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.- Specified by:
processMessage
in interfacecom.sshtools.common.auth.AuthenticationMechanism
- Parameters:
msg
- byte[]- Returns:
- boolean
- Throws:
IOException
-
getBannerForUser
Override this method to send user customized banners, if this method is overridden then com.maverick.sshd.SshContext.setBannerMessage(null) should be set to null.- Parameters:
username
-- Returns:
-
startRequest
Start an authentication transaction.- Specified by:
startRequest
in interfacecom.sshtools.common.auth.AuthenticationMechanism
- Parameters:
username
- Stringmsg
- the request data from the SSH_MSG_USERAUTH_REQUEST message- Returns:
- true if the message was processed, otherwise false
- Throws:
IOException
-