public class SshServer extends AbstractFactoryManager implements ServerFactoryManager
setUpDefaultServer()
method, which will known ciphers, macs, channels, etc...
Besides this basic setup, a few things have to be manually configured such as the
port number, Factory
, the KeyPairProvider
and the PasswordAuthenticator
.
Some properties can also be configured using the AbstractFactoryManager.setProperties(java.util.Map)
method.
Once the SshServer instance has been configured, it can be started using the
start()
method and stopped using the stop()
method.ServerFactoryManager
,
FactoryManager
Modifier and Type | Field and Description |
---|---|
protected org.apache.mina.core.service.IoAcceptor |
acceptor |
protected int |
backlog |
protected CommandFactory |
commandFactory |
protected ScheduledExecutorService |
executor |
protected FileSystemFactory |
fileSystemFactory |
protected ForwardingFilter |
forwardingFilter |
protected GSSAuthenticator |
gssAuthenticator |
protected String |
host |
protected PasswordAuthenticator |
passwordAuthenticator |
protected int |
port |
protected PublickeyAuthenticator |
publickeyAuthenticator |
protected boolean |
reuseAddress |
protected org.apache.mina.core.session.IoSessionConfig |
sessionConfig |
protected SessionFactory |
sessionFactory |
protected Factory<Command> |
shellFactory |
protected boolean |
shutdownExecutor |
protected List<NamedFactory<Command>> |
subsystemFactories |
protected ForwardingAcceptorFactory |
tcpipForwardingAcceptorFactory |
protected List<NamedFactory<UserAuth>> |
userAuthFactories |
protected ForwardingAcceptorFactory |
x11ForwardingAcceptorFactory |
agentFactory, channelFactories, cipherFactories, compressionFactories, keyExchangeFactories, keyPairProvider, macFactories, properties, randomFactory, signatureFactories, version
AUTH_TIMEOUT, IDLE_TIMEOUT, MAX_AUTH_REQUESTS, MAX_CONCURRENT_SESSIONS, SERVER_IDENTIFICATION
DEFAULT_NIO_WORKERS, MAX_PACKET_SIZE, NIO_WORKERS, WINDOW_SIZE
Constructor and Description |
---|
SshServer() |
Modifier and Type | Method and Description |
---|---|
protected void |
checkConfig() |
protected void |
configure(org.apache.mina.core.service.IoAcceptor acceptor) |
protected org.apache.mina.core.service.IoAcceptor |
createAcceptor() |
protected SessionFactory |
createSessionFactory() |
List<AbstractSession> |
getActiveSessions()
Obtain the list of active sessions.
|
int |
getBacklog() |
CommandFactory |
getCommandFactory()
Retrieve the
CommandFactory to be used to process commands requests. |
FileSystemFactory |
getFileSystemFactory()
Retrieve the
FileSystemFactory to be used to traverse the file system. |
ForwardingFilter |
getForwardingFilter()
Retrieve the
ForwardingFilter to be used by the SSH server. |
GSSAuthenticator |
getGSSAuthenticator()
Retrieve the
GSSAuthenticator to be used by the SSH server. |
String |
getHost() |
PasswordAuthenticator |
getPasswordAuthenticator()
Retrieve the
PasswordAuthenticator to be used by the SSH server. |
int |
getPort() |
PublickeyAuthenticator |
getPublickeyAuthenticator()
Retrieve the
PublickeyAuthenticator to be used by SSH server. |
boolean |
getReuseAddress() |
ScheduledExecutorService |
getScheduledExecutorService()
Retrieve the
ScheduledExecutorService to be used. |
org.apache.mina.core.session.IoSessionConfig |
getSessionConfig() |
SessionFactory |
getSessionFactory() |
Factory<Command> |
getShellFactory()
Retrieve the
ShellFactory object to be used to create shells. |
List<NamedFactory<Command>> |
getSubsystemFactories()
Retrieve the list of named factories for
CommandFactory.Command to
be used to create subsystems. |
ForwardingAcceptorFactory |
getTcpipForwardingAcceptorFactory()
Retrieve the IoAcceptor factory to be used to accept incoming connections
to port forwards.
|
List<NamedFactory<UserAuth>> |
getUserAuthFactories()
Retrieve the list of named factories for
UserAuth |
ForwardingAcceptorFactory |
getX11ForwardingAcceptorFactory()
Retrieve the IoAcceptor factory to be used to accept incoming connections
for X11 Forwards.
|
static void |
main(String[] args) |
void |
setBacklog(int backlog) |
void |
setCommandFactory(CommandFactory commandFactory) |
void |
setFileSystemFactory(FileSystemFactory fileSystemFactory) |
void |
setForwardingFilter(ForwardingFilter forwardingFilter) |
void |
setGSSAuthenticator(GSSAuthenticator gssAuthenticator) |
void |
setHost(String host) |
void |
setPasswordAuthenticator(PasswordAuthenticator passwordAuthenticator) |
void |
setPort(int port)
Configure the port number to use for this SSH server.
|
void |
setPublickeyAuthenticator(PublickeyAuthenticator publickeyAuthenticator) |
void |
setReuseAddress(boolean reuseAddress) |
void |
setScheduledExecutorService(ScheduledExecutorService executor) |
void |
setScheduledExecutorService(ScheduledExecutorService executor,
boolean shutdownExecutor) |
void |
setSessionConfig(org.apache.mina.core.session.IoSessionConfig sessionConfig) |
void |
setSessionFactory(SessionFactory sessionFactory) |
void |
setShellFactory(Factory<Command> shellFactory) |
void |
setSubsystemFactories(List<NamedFactory<Command>> subsystemFactories) |
void |
setTcpipForwardNioSocketAcceptorFactory(ForwardingAcceptorFactory f) |
static SshServer |
setUpDefaultServer() |
void |
setUserAuthFactories(List<NamedFactory<UserAuth>> userAuthFactories) |
void |
setX11ForwardNioSocketAcceptorFactory(ForwardingAcceptorFactory f) |
void |
start()
Start the SSH server and accept incoming exceptions on the configured port.
|
void |
stop()
Stop the SSH server.
|
void |
stop(boolean immediately) |
getAgentFactory, getChannelFactories, getCipherFactories, getCompressionFactories, getKeyExchangeFactories, getKeyPairProvider, getMacFactories, getNioWorkers, getProperties, getRandomFactory, getSignatureFactories, getVersion, loadVersion, setAgentFactory, setChannelFactories, setCipherFactories, setCompressionFactories, setKeyExchangeFactories, setKeyPairProvider, setMacFactories, setNioWorkers, setProperties, setRandomFactory, setSignatureFactories
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getAgentFactory, getChannelFactories, getCipherFactories, getCompressionFactories, getKeyExchangeFactories, getKeyPairProvider, getMacFactories, getProperties, getRandomFactory, getSignatureFactories, getVersion
protected org.apache.mina.core.service.IoAcceptor acceptor
protected String host
protected int port
protected int backlog
protected boolean reuseAddress
protected org.apache.mina.core.session.IoSessionConfig sessionConfig
protected List<NamedFactory<UserAuth>> userAuthFactories
protected SessionFactory sessionFactory
protected CommandFactory commandFactory
protected FileSystemFactory fileSystemFactory
protected List<NamedFactory<Command>> subsystemFactories
protected PasswordAuthenticator passwordAuthenticator
protected PublickeyAuthenticator publickeyAuthenticator
protected GSSAuthenticator gssAuthenticator
protected ForwardingFilter forwardingFilter
protected ForwardingAcceptorFactory x11ForwardingAcceptorFactory
protected ForwardingAcceptorFactory tcpipForwardingAcceptorFactory
protected ScheduledExecutorService executor
protected boolean shutdownExecutor
public String getHost()
public void setHost(String host)
public int getPort()
public void setPort(int port)
port
- the port number for this SSH serverpublic boolean getReuseAddress()
public void setReuseAddress(boolean reuseAddress)
public int getBacklog()
public void setBacklog(int backlog)
public org.apache.mina.core.session.IoSessionConfig getSessionConfig()
public void setSessionConfig(org.apache.mina.core.session.IoSessionConfig sessionConfig)
public List<NamedFactory<UserAuth>> getUserAuthFactories()
ServerFactoryManager
UserAuth objects.
getUserAuthFactories
in interface ServerFactoryManager
UserAuth
factories, never null
public void setUserAuthFactories(List<NamedFactory<UserAuth>> userAuthFactories)
public Factory<Command> getShellFactory()
ServerFactoryManager
ShellFactory
object to be used to create shells.getShellFactory
in interface ServerFactoryManager
ShellFactory
object or null
if shells
are not supported on this serverpublic SessionFactory getSessionFactory()
public void setSessionFactory(SessionFactory sessionFactory)
public CommandFactory getCommandFactory()
ServerFactoryManager
CommandFactory
to be used to process commands requests.getCommandFactory
in interface ServerFactoryManager
CommandFactory
object or null
if commands
are not supported on this serverpublic void setCommandFactory(CommandFactory commandFactory)
public FileSystemFactory getFileSystemFactory()
ServerFactoryManager
FileSystemFactory
to be used to traverse the file system.getFileSystemFactory
in interface ServerFactoryManager
FileSystemFactory
object or null
if commands
are not supported on this serverpublic void setFileSystemFactory(FileSystemFactory fileSystemFactory)
public List<NamedFactory<Command>> getSubsystemFactories()
ServerFactoryManager
CommandFactory.Command
to
be used to create subsystems.getSubsystemFactories
in interface ServerFactoryManager
CommandFactory.Command
factories
or null
if subsystems are not supported on this serverpublic void setSubsystemFactories(List<NamedFactory<Command>> subsystemFactories)
public PasswordAuthenticator getPasswordAuthenticator()
ServerFactoryManager
PasswordAuthenticator
to be used by the SSH server.
If no authenticator has been configured (i.e. this method returns
null
), then client authentication requests based on passwords
will be rejected.getPasswordAuthenticator
in interface ServerFactoryManager
PasswordAuthenticator
or null
public void setPasswordAuthenticator(PasswordAuthenticator passwordAuthenticator)
public PublickeyAuthenticator getPublickeyAuthenticator()
ServerFactoryManager
PublickeyAuthenticator
to be used by SSH server.
If no authenticator has been configured (i.e. this method returns
null
), then client authentication requests based on keys will be
rejected.getPublickeyAuthenticator
in interface ServerFactoryManager
PublickeyAuthenticato
or null
public void setPublickeyAuthenticator(PublickeyAuthenticator publickeyAuthenticator)
public GSSAuthenticator getGSSAuthenticator()
ServerFactoryManager
GSSAuthenticator
to be used by the SSH server.
If no authenticator has been configured (i.e. this method returns
null
), then client authentication requests based on gssapi
will be rejected.getGSSAuthenticator
in interface ServerFactoryManager
GSSAuthenticator
or null
public void setGSSAuthenticator(GSSAuthenticator gssAuthenticator)
public ForwardingFilter getForwardingFilter()
ServerFactoryManager
ForwardingFilter
to be used by the SSH server.
If no filter has been configured (i.e. this method returns
null
), then all forwarding requests will be rejected.getForwardingFilter
in interface ServerFactoryManager
ForwardingFilter
or null
public ForwardingAcceptorFactory getTcpipForwardingAcceptorFactory()
ServerFactoryManager
getTcpipForwardingAcceptorFactory
in interface ServerFactoryManager
ForwardNioAcceptorFactory
public void setX11ForwardNioSocketAcceptorFactory(ForwardingAcceptorFactory f)
public ForwardingAcceptorFactory getX11ForwardingAcceptorFactory()
ServerFactoryManager
getX11ForwardingAcceptorFactory
in interface ServerFactoryManager
ForwardNioAcceptorFactory
public void setTcpipForwardNioSocketAcceptorFactory(ForwardingAcceptorFactory f)
public void setForwardingFilter(ForwardingFilter forwardingFilter)
public ScheduledExecutorService getScheduledExecutorService()
ServerFactoryManager
ScheduledExecutorService
to be used.getScheduledExecutorService
in interface ServerFactoryManager
ScheduledExecutorService
, never null
public void setScheduledExecutorService(ScheduledExecutorService executor)
public void setScheduledExecutorService(ScheduledExecutorService executor, boolean shutdownExecutor)
protected void checkConfig()
public void start() throws IOException
IOException
public void stop() throws InterruptedException
InterruptedException
public void stop(boolean immediately) throws InterruptedException
InterruptedException
public List<AbstractSession> getActiveSessions()
protected org.apache.mina.core.service.IoAcceptor createAcceptor()
protected void configure(org.apache.mina.core.service.IoAcceptor acceptor)
protected SessionFactory createSessionFactory()
public static SshServer setUpDefaultServer()
Copyright © 2008-2013 The Apache Software Foundation. All Rights Reserved.