com.sshtools.j2ssh.transport

Class Service

Known Direct Subclasses:
AsyncService, AuthenticationProtocolClient

public abstract class Service
extends java.lang.Object

This class implements the transport protocol service.

After the transport protocol negotiates the protocol version and performs server authentication via key exchange, the client requests a service. The service is identified by a name and currently there are 2 services defined.

ssh-userauth
ssh-connection

These 2 services are implemented by the SSH authentication protocol and SSH connection protocol respectivley. Further services can be defined and a similar local naming policy is applied to the service names, as is applied to the algorithm names; a local service should use the "servicename(at)domain" syntax.

Version:
$Revision: 1.42 $
Author:
Lee David Painter
Since:
0.2.0

Field Summary

static int
ACCEPTING_SERVICE
Serivce start mode passed into init method when the service is operating in server mode.
static int
REQUESTING_SERVICE
Service start mode passed into init method when the service is operating in client mode.
protected SshMessageStore
messageStore
The message store registered with the transport protocol to receive the service's message.
protected Integer
startMode
This instances start mode
protected ServiceState
state
The current state of the service
protected TransportProtocol
transport
The underlying transport protocol

Constructor Summary

Service(String serviceName)
Constructs the service.

Method Summary

String
getServiceName()
Returns the service name.
ServiceState
getState()
Returns the state of the service.
void
init(int startMode, TransportProtocol transport)
Initialize the service.
protected abstract void
onServiceAccept()
Called when the service is accepted by the remote server.
protected abstract void
onServiceInit(int startMode)
Called when the service is intialized.
protected abstract void
onServiceRequest()
protected abstract void
onStart()
Called when the service is started.
protected void
sendServiceAccept()
Sends the SSH_MSG_SERVICE_ACCEPT message to the client to indicate that the local computer is accepting the remote computers service request.
void
start()
Starts the service.
void
stop()
Stops the service.

Field Details

ACCEPTING_SERVICE

public static final int ACCEPTING_SERVICE
Serivce start mode passed into init method when the service is operating in server mode. i.e a client is requesting a service to be started on the local computer and requires the SSH_MSG_SERVICE_ACCEPT message to be sent.
Field Value:
2

REQUESTING_SERVICE

public static final int REQUESTING_SERVICE
Service start mode passed into init method when the service is operating in client mode. i.e its requesting a service to be started on the remote server and requires a SSH_MSG_SERVICE_ACCEPT message.
Field Value:
1

messageStore

protected SshMessageStore messageStore
The message store registered with the transport protocol to receive the service's message.

startMode

protected Integer startMode
This instances start mode

state

protected ServiceState state
The current state of the service

transport

protected TransportProtocol transport
The underlying transport protocol

Constructor Details

Service

public Service(String serviceName)
Constructs the service.
Parameters:
serviceName - the name of the service
Since:
0.2.0

Method Details

getServiceName

public final String getServiceName()
Returns the service name.
Returns:
the serivce name
Since:
0.2.0

getState

public ServiceState getState()
Returns the state of the service.
Returns:
the state of the service
Since:
0.2.0
See Also:
ServiceState

init

public void init(int startMode,
                 TransportProtocol transport)
            throws IOException
Initialize the service.
Parameters:
startMode - the mode of the service
transport - the underlying transport protocol
Since:
0.2.0

onServiceAccept

protected abstract void onServiceAccept()
            throws IOException
Called when the service is accepted by the remote server.
Since:
0.2.0

onServiceInit

protected abstract void onServiceInit(int startMode)
            throws IOException
Called when the service is intialized.
Parameters:
startMode - the mode of the service
Since:
0.2.0

onServiceRequest

protected abstract void onServiceRequest()
            throws IOException

onStart

protected abstract void onStart()
            throws IOException
Called when the service is started.
Since:
0.2.0

sendServiceAccept

protected void sendServiceAccept()
            throws IOException
Sends the SSH_MSG_SERVICE_ACCEPT message to the client to indicate that the local computer is accepting the remote computers service request.
Since:
0.2.0

start

public final void start()
            throws IOException
Starts the service.
Since:
0.2.0

stop

public final void stop()
Stops the service.
Since:
0.2.0

Copyright © 2002-2003 Lee David Painter & Contributors. All Rights Reserved.