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.j2ssh.forwarding;
027:
028: import com.sshtools.j2ssh.connection.IOChannel;
029:
030: import org.apache.commons.logging.Log;
031: import org.apache.commons.logging.LogFactory;
032:
033: //import java.net.InetSocketAddress;
034: import java.io.IOException;
035:
036: /**
037: *
038: *
039: * @author $author$
040: * @version $Revision: 1.13 $
041: */
042: public class ForwardingIOChannel extends IOChannel implements
043: ForwardingChannel {
044: private static Log log = LogFactory
045: .getLog(ForwardingIOChannel.class);
046: private ForwardingChannelImpl channel;
047:
048: /**
049: * Creates a new ForwardingIOChannel object.
050: *
051: * @param forwardType
052: * @param hostToConnectOrBind
053: * @param portToConnectOrBind
054: * @param originatingHost
055: * @param originatingPort
056: *
057: * @throws ForwardingConfigurationException
058: */
059: public ForwardingIOChannel(String forwardType, String name, /*ForwardingConfiguration config,*/
060: String hostToConnectOrBind, int portToConnectOrBind,
061: String originatingHost, int originatingPort)
062: throws ForwardingConfigurationException {
063: if (!forwardType.equals(LOCAL_FORWARDING_CHANNEL)
064: && !forwardType.equals(REMOTE_FORWARDING_CHANNEL)
065: && !forwardType.equals(X11_FORWARDING_CHANNEL)) {
066: throw new ForwardingConfigurationException(
067: "The forwarding type is invalid");
068: }
069:
070: channel = new ForwardingChannelImpl(forwardType, name,
071: hostToConnectOrBind, portToConnectOrBind,
072: originatingHost, originatingPort);
073: }
074:
075: /**
076: *
077: *
078: * @return
079: */
080: public byte[] getChannelOpenData() {
081: return channel.getChannelOpenData();
082: }
083:
084: /**
085: *
086: *
087: * @return
088: */
089: public byte[] getChannelConfirmationData() {
090: return channel.getChannelConfirmationData();
091: }
092:
093: public String getName() {
094: return channel.getName();
095: }
096:
097: /**
098: *
099: *
100: * @return
101: */
102: public String getChannelType() {
103: return channel.getChannelType();
104: }
105:
106: /**
107: *
108: *
109: * @return
110: */
111: protected int getMinimumWindowSpace() {
112: return 32768;
113: }
114:
115: /**
116: *
117: *
118: * @return
119: */
120: protected int getMaximumWindowSpace() {
121: return 131072;
122: }
123:
124: /**
125: *
126: *
127: * @return
128: */
129: protected int getMaximumPacketSize() {
130: return 32768;
131: }
132:
133: /**
134: *
135: *
136: * @return
137: */
138: public String getOriginatingHost() {
139: return channel.getOriginatingHost();
140: }
141:
142: /**
143: *
144: *
145: * @return
146: */
147: public int getOriginatingPort() {
148: return channel.getOriginatingPort();
149: }
150:
151: /**
152: *
153: *
154: * @return
155: */
156: public String getHostToConnectOrBind() {
157: return channel.getHostToConnectOrBind();
158: }
159:
160: /**
161: *
162: *
163: * @return
164: */
165: public int getPortToConnectOrBind() {
166: return channel.getPortToConnectOrBind();
167: }
168:
169: /**
170: *
171: *
172: * @param request
173: * @param wantReply
174: * @param requestData
175: *
176: * @throws IOException
177: */
178: protected void onChannelRequest(String request, boolean wantReply,
179: byte[] requestData) throws IOException {
180: connection.sendChannelRequestFailure(this );
181: }
182:
183: /**
184: *
185: *
186: * @throws IOException
187: */
188: protected void onChannelOpen() throws IOException {
189: }
190: }
|