001: /*
002: * SSHTools - Java SSH2 API
003: *
004: * Copyright (C) 2002-2003 Lee David Painter and Contributors.
005: *
006: * Contributions made by:
007: *
008: * Brett Smith
009: * Richard Pernavas
010: * Erwin Bolwidt
011: *
012: * This program is free software; you can redistribute it and/or
013: * modify it under the terms of the GNU General Public License
014: * as published by the Free Software Foundation; either version 2
015: * of the License, or (at your option) any later version.
016: *
017: * This program is distributed in the hope that it will be useful,
018: * but WITHOUT ANY WARRANTY; without even the implied warranty of
019: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
020: * GNU General Public License for more details.
021: *
022: * You should have received a copy of the GNU General Public License
023: * along with this program; if not, write to the Free Software
024: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
025: */
026: package com.sshtools.common.ui;
027:
028: import com.sshtools.common.configuration.SshToolsConnectionProfile;
029:
030: import com.sshtools.j2ssh.SftpClient;
031: import com.sshtools.j2ssh.SshEventAdapter;
032: import com.sshtools.j2ssh.connection.Channel;
033: import com.sshtools.j2ssh.connection.ChannelFactory;
034: import com.sshtools.j2ssh.forwarding.ForwardingClient;
035: import com.sshtools.j2ssh.session.SessionChannelClient;
036:
037: import java.io.IOException;
038:
039: /**
040: * <p>This interface is used by the Session Provider framework to abstract
041: * the SshClient connection away from the session provider. This restricts
042: * the session to performing operations that are allowed by the controlling
043: * application. For instance, the provider cannot simply diconnect the
044: * connection, since the SshClient's disconnect method is not exposed, instead
045: * a <code>requestDisconnect</code> method is provided allowing the controlling
046: * application to simply ignore a disconnect since it may have other sessions
047: * open.
048: * </p>
049: *
050: * <p>
051: * Most of the methods of this interface will simply be required to call the
052: * identical method on SshClient.
053: * </p>
054: *
055: * @author Lee David Painter
056: * @version $Revision: 1.11 $
057: */
058: public interface SessionManager {
059: /**
060: * Opens a session on the managed connection.
061: *
062: * @return
063: *
064: * @throws IOException
065: */
066: public SessionChannelClient openSession() throws IOException;
067:
068: /**
069: * The session can call this method to apply any changes to the profile it
070: * may have made.
071: *
072: * @param profile
073: */
074: public void applyProfileChanges(SshToolsConnectionProfile profile);
075:
076: /**
077: * Opens an SftpClient on the managed connection.
078: *
079: * @return
080: *
081: * @throws IOException
082: */
083: public SftpClient openSftpClient() throws IOException;
084:
085: /**
086: * Opens a channel on the managed connection.
087: *
088: * @param channel
089: *
090: * @return
091: *
092: * @throws IOException
093: */
094: public boolean openChannel(Channel channel) throws IOException;
095:
096: /**
097: * Determine if the managed connection is still connected.
098: *
099: * @return
100: */
101: public boolean isConnected();
102:
103: /**
104: * Called when a session wants to disconnect the connection. The manager
105: * implementation should ideally not diconnect unless no other sessions
106: * are open.
107: *
108: * @return
109: */
110: public boolean requestDisconnect();
111:
112: /**
113: * Gets the managed connections port forwarding client.
114: *
115: * @return
116: */
117: public ForwardingClient getForwardingClient();
118:
119: /**
120: * Send a global request
121: *
122: * @param requestname
123: * @param wantreply
124: * @param requestdata
125: *
126: * @return
127: *
128: * @throws IOException
129: */
130: public byte[] sendGlobalRequest(String requestname,
131: boolean wantreply, byte[] requestdata) throws IOException;
132:
133: /**
134: * Add an event handler to the managed connection
135: *
136: * @param eventHandler
137: */
138: public void addEventHandler(SshEventAdapter eventHandler);
139:
140: /**
141: * Gets the identification string supplied by the server.
142: *
143: * @return
144: */
145: public String getServerId();
146:
147: /**
148: * Returns the guessed EOL setting of the remote computer
149: * @return
150: */
151: public int getRemoteEOL();
152:
153: /**
154: * Adds a channel factory to the managed connection.
155: *
156: * @param channelType
157: * @param cf
158: *
159: * @throws IOException
160: */
161: public void allowChannelOpen(String channelType, ChannelFactory cf)
162: throws IOException;
163:
164: /**
165: * Get the current profile attached to the session.
166: *
167: * @return
168: */
169: public SshToolsConnectionProfile getProfile();
170: }
|