colin-lee / ganymed-ssh-2

Automatically exported from code.google.com/p/ganymed-ssh-2
Other
0 stars 0 forks source link

Can Connection use a SessionFactory to create Session instances? #47

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Ganymed release: 2.6.2

This issue is not a bug, but rather an improvement to consider.

In Sun_SSH server version 1.0.1 it appears that closing a Session obtained from 
Connection.openSession() can cause the entire connection to go down. Trying to 
re-use the Connection object will cause a failure. Therefore we would like to 
handle the Session.close() function a bit differently. 

It would be nice to subclass the Session object, and then perform extra 
functionality for the close() function if such a server version is encountered. 
Unfortunately the ability to do this isn't possible because the 
Connection.openSession() uses internal private members (namely the 
ChannelManager) to construct a Session object, so subclassing the Connection 
object is not helpful.

Connection.java
----
public synchronized Session openSession() throws IOException {
    this.checkConnection();

    return new Session(cm, getOrCreateSecureRND());
}
----

Therefore, would it be possible to have the Connection object use a 
SessionFactory instead that can be set on the Connection object to create 
Session instances when openSession() is called? 

This would be general enough to allow various tweaks to be done to the Session 
objects, through subclassing, that are returned from Connection.openSession().

Attached is a proposed implementation to allow this functionality.

Original issue reported on code.google.com by derek.pi...@gmail.com on 29 Jul 2014 at 9:09

Attachments: