01: /*
02: * SSHTools - Java SSH2 API
03: *
04: * Copyright (C) 2002-2003 Lee David Painter and Contributors.
05: *
06: * Contributions made by:
07: *
08: * Brett Smith
09: * Richard Pernavas
10: * Erwin Bolwidt
11: *
12: * This program is free software; you can redistribute it and/or
13: * modify it under the terms of the GNU General Public License
14: * as published by the Free Software Foundation; either version 2
15: * of the License, or (at your option) any later version.
16: *
17: * This program is distributed in the hope that it will be useful,
18: * but WITHOUT ANY WARRANTY; without even the implied warranty of
19: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20: * GNU General Public License for more details.
21: *
22: * You should have received a copy of the GNU General Public License
23: * along with this program; if not, write to the Free Software
24: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25: */
26: package com.sshtools.daemon.session;
27:
28: import com.sshtools.j2ssh.configuration.*;
29: import com.sshtools.j2ssh.connection.*;
30:
31: /**
32: *
33: *
34: * @author $author$
35: * @version $Revision: 1.12 $
36: */
37: public class SessionChannelFactory implements ChannelFactory {
38: /** */
39: public final static String SESSION_CHANNEL = "session";
40: Class sessionChannelImpl;
41:
42: /**
43: * Creates a new SessionChannelFactory object.
44: *
45: * @throws ConfigurationException
46: */
47: public SessionChannelFactory() throws ConfigurationException {
48: sessionChannelImpl = SessionChannelServer.class;
49:
50: /*ServerConfiguration server = ConfigurationLoader.getServerConfiguration();
51: sessionChannelImpl = ConfigurationLoader.getServerConfiguration().getSessionChannelImpl();*/
52: }
53:
54: /*public List getChannelType() {
55: List list = new ArrayList();
56: list.add(SessionChannelServer.SESSION_CHANNEL_TYPE);
57: return list;
58: }*/
59: public Channel createChannel(String channelType, byte[] requestData)
60: throws InvalidChannelException {
61: try {
62: if (channelType.equals("session")) {
63: return (Channel) sessionChannelImpl.newInstance();
64: } else {
65: throw new InvalidChannelException(
66: "Only session channels can be opened by this factory");
67: }
68: } catch (Exception e) {
69: throw new InvalidChannelException(
70: "Failed to create session channel implemented by "
71: + sessionChannelImpl.getName());
72: }
73: }
74:
75: /*public void setSessionChannelImpl(Class sessionChannelImpl)
76: throws InvalidChannelException {
77: try {
78: Channel channel = (Channel) sessionChannelImpl.newInstance();
79: if (!(channel instanceof AbstractSessionChannelServer)) {
80: throw new InvalidChannelException(
81: "Class does not extend AbstractSessionChannelServer");
82: }
83: } catch (Exception e) {
84: throw new InvalidChannelException(
85: "Cannot set session channel implementation");
86: }
87: }*/
88: }
|