Class SSHController
- java.lang.Object
-
- org.teichert.databaseexplorer.controllers.SSHController
-
public final class SSHController extends Object
Provides all methods to handle SSH-Connections and SSHPortForwardings.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addConnection(SSHConnection... connections)
void
connect(SSHConnection... connections)
Establishes an SSH-Connection via its user+password.
Make sure all environment settings like for example a "VPN-Tunnel" are ready to use.
You can see if a session is established in the log-files.void
connectAll()
Establishes a connection to all configured SSH-Connections.void
delForwarding(boolean removeFromMap, SSHPortForwarding... sshPortForwardings)
Deletes all Port-Forwardings from the internal database.void
disconnect(boolean removeFromMap, SSHConnection... connections)
Dissconects all given SSH-Connections if possible.void
disconnectAll(boolean removeFromMap)
Dissconects all SSH-Connections if possible.void
forward(SSHConnection... sshConnections)
Establishes a Port-Forwarding to all SSH-Connections which are configured in the database-explorer.void
forward(SSHPortForwarding... sshPortForwardings)
Establishes all Port-Forwardings which are configured in the database-explorer.void
forwardAll()
Establishes all Port-Forwardings to of all configured SSH-Connections.List<SSHPortForwarding>
getAllForwardings()
Returns a list of all established Port-Forwardings.SSHConnection
getConnectionByHost(String host)
SSHConnection
getConnectionById(String sshId)
static SSHController
getInstance()
LinkedList<SSHConnection>
getListOfConnections()
HashMap<SSHConnection,List<SSHPortForwarding>>
getMapOfPortForwardings()
HashMap<SSHConnection,Session>
getMapOfSessions()
List<SSHConnection>
loadFromSSHConnectionsConfigs()
Loads all SSH-Connections from the internal database.List<SSHPortForwarding>
loadFromSSHForwardingsConfigs()
Loads all Port-Forwardings from the internal database.void
removeConnection(SSHConnection... connections)
void
saveForwardings()
Save all Port-Forwardings persistently.
-
-
-
Method Detail
-
getInstance
public static SSHController getInstance()
-
delForwarding
public void delForwarding(boolean removeFromMap, SSHPortForwarding... sshPortForwardings)
Deletes all Port-Forwardings from the internal database.- Parameters:
removeFromMap
- should all disconnected connections be cleared from the internal cache?sshPortForwardings
- Port-Forwardings to be deleted
-
loadFromSSHConnectionsConfigs
public List<SSHConnection> loadFromSSHConnectionsConfigs()
Loads all SSH-Connections from the internal database.- Returns:
-
loadFromSSHForwardingsConfigs
public List<SSHPortForwarding> loadFromSSHForwardingsConfigs()
Loads all Port-Forwardings from the internal database.- Returns:
-
addConnection
public void addConnection(SSHConnection... connections)
-
removeConnection
public void removeConnection(SSHConnection... connections)
-
getConnectionById
public SSHConnection getConnectionById(String sshId)
-
getConnectionByHost
public SSHConnection getConnectionByHost(String host)
-
getListOfConnections
public LinkedList<SSHConnection> getListOfConnections()
-
getMapOfSessions
public HashMap<SSHConnection,Session> getMapOfSessions()
-
getMapOfPortForwardings
public HashMap<SSHConnection,List<SSHPortForwarding>> getMapOfPortForwardings()
-
disconnectAll
public void disconnectAll(boolean removeFromMap)
Dissconects all SSH-Connections if possible.- Parameters:
removeFromMap
- should all disconnected connections be cleared from the internal cache?
-
disconnect
public void disconnect(boolean removeFromMap, SSHConnection... connections)
Dissconects all given SSH-Connections if possible.- Parameters:
removeFromMap
- should all disconnected connections be cleared from the internal cache?connections
- connections to be discconected
-
connectAll
public void connectAll()
Establishes a connection to all configured SSH-Connections.
-
forwardAll
public void forwardAll()
Establishes all Port-Forwardings to of all configured SSH-Connections.
-
connect
public void connect(SSHConnection... connections) throws Exception
Establishes an SSH-Connection via its user+password.
Make sure all environment settings like for example a "VPN-Tunnel" are ready to use.
You can see if a session is established in the log-files.- Parameters:
connections
-- Throws:
Exception
-
forward
public void forward(SSHPortForwarding... sshPortForwardings)
Establishes all Port-Forwardings which are configured in the database-explorer.- Parameters:
sshPortForwardings
-
-
forward
public void forward(SSHConnection... sshConnections)
Establishes a Port-Forwarding to all SSH-Connections which are configured in the database-explorer.- Parameters:
sshConnections
-
-
getAllForwardings
public List<SSHPortForwarding> getAllForwardings()
Returns a list of all established Port-Forwardings.- Returns:
-
saveForwardings
public void saveForwardings()
Save all Port-Forwardings persistently.
-
-