|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.sshtools.j2ssh.transport.Service | +--com.sshtools.j2ssh.authentication.AuthenticationProtocol
Implements the SSH Authentication protocol as a Transport layer service. This class can authenticate with any authentication object implementing the SshAuthentication interface and returns the success, partial success or failure result synchronously.
The authentication process is as follows:
The authentication service is started
The server MAY reply with a banner message (which can be retreived using
getBannerMessage
The user MAY request the list of available authorizations by calling getAvailableAuths
The user MUST request authentication by calling authenticate
for each method they wish to try (with the Service instance to start)
The server responds with a success message and the desired service is
started
Constructor Summary | |
AuthenticationProtocol()
Constructor for the AuthenticationProtocol |
Method Summary | |
int |
authenticate(SshAuthentication auth,
Service serviceToStart)
Authenticate a user with the given authentication method. |
java.util.List |
getAvailableAuths(java.lang.String username,
java.lang.String serviceName)
Gets the available authentication methods returned by the server. |
java.lang.String |
getBannerMessage()
Gets the authentication banner message received from the server. |
AuthenticationProtocolState |
getState()
Gets the current state of the authentication protocol. |
void |
onDisconnect(java.lang.String reason)
Called by the framework if the remote computer disconnects. |
protected void |
onMessageReceived(SshMessage msg)
Called by the Service framework when a registered message has been received. |
protected void |
onServiceAccept()
Abstract method implementation called when the service is accepted by the server. |
void |
onServiceInit()
Called by the framework when the service is initialized. |
protected void |
onServiceRequest()
Abstract method implementation called when the service is request by a remote client. |
protected void |
onThreadException(java.lang.Exception e)
Called by the framework when a exception occurs in a child thread |
Methods inherited from class com.sshtools.j2ssh.transport.Service |
getExchangeHash, getMessageStore, getServiceName, getTransportLayer, run, start, stop, waitForSingleMessage |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public AuthenticationProtocol()
Method Detail |
public void onServiceInit() throws ServiceOperationException
Called by the framework when the service is initialized. We do not currently perform any processing here.
onServiceInit
in class Service
ServiceOperationException
public void onDisconnect(java.lang.String reason)
Called by the framework if the remote computer disconnects.
onDisconnect
in class Service
reason
- The reason for disconnectionprotected void onServiceAccept() throws ServiceOperationException
Abstract method implementation called when the service is accepted by the server. We register client side message notifications here.
onServiceAccept
in class Service
ServiceOperationException
- Thrown if a message registration
error occursprotected void onServiceRequest()
Abstract method implementation called when the service is request by a remote client.
NOTE: The Authentication Protocol currently does not implement and processing here; we should register server side messages here.
onServiceRequest
in class Service
protected void onThreadException(java.lang.Exception e)
Called by the framework when a exception occurs in a child thread
onThreadException
in class Service
e
- The excpetion thrownpublic AuthenticationProtocolState getState()
Gets the current state of the authentication protocol.
public java.lang.String getBannerMessage()
Gets the authentication banner message received from the server. This may be null.
protected void onMessageReceived(SshMessage msg) throws ServiceOperationException, TransportProtocolException
Called by the Service framework when a registered message has been received.
onMessageReceived
in class Service
msg
- The message received
ServiceOperationException
TransportProtocolException
public java.util.List getAvailableAuths(java.lang.String username, java.lang.String serviceName) throws TransportProtocolException
Gets the available authentication methods returned by the server.
NOTE: The authentication protocol states that the server may return authentication methods that are not valid for the user.
username
- The username to request
authentication methods forserviceName
- The service name to start
TransportProtocolException
- Description of the Exceptionpublic int authenticate(SshAuthentication auth, Service serviceToStart) throws TransportProtocolException, AuthenticationProtocolException, ServiceOperationException
Authenticate a user with the given authentication method.
auth
- The authentication method
instance to try.serviceToStart
- The service instance to
start.
AuthenticationProtocolException
ServiceOperationException
TransportProtocolException
- Description of the Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |