|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.numdata.ssh.SshTools
public class SshTools
Some tools for using SSH connections.
| Nested Class Summary | |
|---|---|
static class |
SshTools.PortForwardingProperties
Defines local or remote port forwarding properties. |
| Method Summary | |
|---|---|
static ch.ethz.ssh2.Connection |
connect(String server)
Connect to SSH server. |
static ch.ethz.ssh2.Connection |
connect(String host,
int port,
String username,
String password)
Connect to SSH server. |
static JdbcDataSource |
createJdbcDataSource(String sshServer,
String dbServer,
int dbPort,
String jdbcDriver,
String jdbcUrl,
String jdbcUser,
String jdbcPassword)
Create JdbcDataSource. |
static int |
createLocalPortForwarder(ch.ethz.ssh2.Connection connection,
SshTools.PortForwardingProperties properties)
Create local port forwarding based on the specified SshTools.PortForwardingProperties. |
static int |
createLocalPortForwarder(ch.ethz.ssh2.Connection connection,
String targetHost,
int targetPort)
Create port forwarding tunnel to the specified target host and port and return the local TCP port through which it can be accessed. |
static int |
getFreeLocalPort()
Get any free local TCP port (typically used for local port forwarding). |
static Quartet<String,Integer,String,String> |
parseOptions(String server)
Parse SSH server specification. |
static int |
requestRemotePortForwarding(ch.ethz.ssh2.Connection connection,
SshTools.PortForwardingProperties properties)
Request remote port forwarding based on the specified SshTools.PortForwardingProperties. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static ch.ethz.ssh2.Connection connect(@Nullable
String server)
throws IOException
server - SSH server specification (<user>:<pass>@<host>[':'<port>]).
IOException - if the connection could not be established.
IllegalArgumentException - if the specification is badly
formatted.
@Nullable
public static Quartet<String,Integer,String,String> parseOptions(@Nullable
String server)
<user>:<pass>@<host>[':'<port>].
server - SSH server specification.
Quartet with SSH server host, server port, user name, and
password; null if server is empty.
IllegalArgumentException - if the specification is badly
formatted.
@NotNull
public static ch.ethz.ssh2.Connection connect(@NotNull
String host,
int port,
@NotNull
String username,
@NotNull
String password)
throws IOException
host - SSH server host.port - SSH server port.username - User name for authentication.password - Password for authentication.
IOException - if the connection could not be established.
public static JdbcDataSource createJdbcDataSource(@Nullable
String sshServer,
@NotNull
String dbServer,
int dbPort,
String jdbcDriver,
@NotNull
String jdbcUrl,
String jdbcUser,
String jdbcPassword)
throws IOException,
SQLException
JdbcDataSource.
sshServer - Optional SSH server specification (<user>:<pass>@<host>[':'<port>]).dbServer - Database server host.dbPort - TCP port of database server.jdbcDriver - JDBC driver name.jdbcUrl - JDBC URL format ({0}=host, {1}=port).jdbcUser - JDBC user name.jdbcPassword - JDBC password.
JdbcDataSource.
IllegalArgumentException - if the specification is badly
formatted.
IOException - if the SSH connection could not be established.
SQLException - if an error occurs while accessing the database.
public static int createLocalPortForwarder(@NotNull
ch.ethz.ssh2.Connection connection,
String targetHost,
int targetPort)
throws IOException
connection - Connection to create port forwarding on.targetHost - Target host to connect to.targetPort - TCP port to connect to.
IOException - if the tunnel could not be created.
public static int createLocalPortForwarder(@NotNull
ch.ethz.ssh2.Connection connection,
@NotNull
SshTools.PortForwardingProperties properties)
throws IOException
SshTools.PortForwardingProperties.
connection - Connection to create port forwardings on.properties - Port forwarding properties.
IOException - port forwarding failed.
public static int requestRemotePortForwarding(@NotNull
ch.ethz.ssh2.Connection connection,
@NotNull
SshTools.PortForwardingProperties properties)
throws IOException
SshTools.PortForwardingProperties.
connection - Connection to request port forwardings on.properties - Port forwarding properties.
IOException - port forwarding failed.
public static int getFreeLocalPort()
throws IOException
IOException - if no free local TCP port is available.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||