Class Service
- java.lang.Object
-
- com.sshtools.j2ssh.transport.Service
-
- Direct Known Subclasses:
AsyncService,AuthenticationProtocolClient
public abstract class Service extends java.lang.ObjectThis 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.- Since:
- 0.2.0
- Version:
- $Revision: 1.42 $
- Author:
- Lee David Painter
-
-
Field Summary
Fields Modifier and Type Field Description static intACCEPTING_SERVICESerivce start mode passed intoinitmethod when the service is operating in server mode.protected SshMessageStoremessageStoreThe message store registered with the transport protocol to receive the service's message.static intREQUESTING_SERVICEService start mode passed intoinitmethod when the service is operating in client mode.protected java.lang.IntegerstartModeThis instances start modeprotected ServiceStatestateThe current state of the serviceprotected TransportProtocoltransportThe underlying transport protocol
-
Constructor Summary
Constructors Constructor Description Service(java.lang.String serviceName)Constructs the service.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetServiceName()Returns the service name.ServiceStategetState()Returns the state of the service.voidinit(int startMode, TransportProtocol transport)Initialize the service.protected abstract voidonServiceAccept()Called when the service is accepted by the remote server.protected abstract voidonServiceInit(int startMode)Called when the service is intialized.protected abstract voidonServiceRequest()protected abstract voidonStart()Called when the service is started.protected voidsendServiceAccept()Sends the SSH_MSG_SERVICE_ACCEPT message to the client to indicate that the local computer is accepting the remote computers service request.voidstart()Starts the service.voidstop()Stops the service.
-
-
-
Field Detail
-
REQUESTING_SERVICE
public static final int REQUESTING_SERVICE
Service start mode passed intoinitmethod 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.- See Also:
- Constant Field Values
-
ACCEPTING_SERVICE
public static final int ACCEPTING_SERVICE
Serivce start mode passed intoinitmethod 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.- See Also:
- Constant Field Values
-
messageStore
protected SshMessageStore messageStore
The message store registered with the transport protocol to receive the service's message.
-
transport
protected TransportProtocol transport
The underlying transport protocol
-
startMode
protected java.lang.Integer startMode
This instances start mode
-
state
protected ServiceState state
The current state of the service
-
-
Method Detail
-
getServiceName
public final java.lang.String getServiceName()
Returns the service name.
- Returns:
- the serivce name
- Since:
- 0.2.0
-
start
public final void start() throws java.io.IOExceptionStarts the service.
- Throws:
java.io.IOException- if an IO error occurs- Since:
- 0.2.0
-
onStart
protected abstract void onStart() throws java.io.IOExceptionCalled when the service is started.
- Throws:
java.io.IOException- if an IO error occurs- 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 java.io.IOExceptionInitialize the service.
- Parameters:
startMode- the mode of the servicetransport- the underlying transport protocol- Throws:
java.io.IOException- if an IO error occurs- Since:
- 0.2.0
-
stop
public final void stop()
Stops the service.
- Since:
- 0.2.0
-
onServiceAccept
protected abstract void onServiceAccept() throws java.io.IOExceptionCalled when the service is accepted by the remote server.
- Throws:
java.io.IOException- Since:
- 0.2.0
-
onServiceInit
protected abstract void onServiceInit(int startMode) throws java.io.IOExceptionCalled when the service is intialized.
- Parameters:
startMode- the mode of the service- Throws:
java.io.IOException- if an IO error occurs- Since:
- 0.2.0
-
onServiceRequest
protected abstract void onServiceRequest() throws java.io.IOException- Throws:
java.io.IOException
-
sendServiceAccept
protected void sendServiceAccept() throws java.io.IOExceptionSends the SSH_MSG_SERVICE_ACCEPT message to the client to indicate that the local computer is accepting the remote computers service request.
- Throws:
java.io.IOException- if an IO error occurs- Since:
- 0.2.0
-
-