Package com.sshtools.j2ssh.connection

Examples of com.sshtools.j2ssh.connection.InvalidChannelException


     */
    public Channel createChannel(String channelType, byte[] requestData)
        throws InvalidChannelException {
        if (channelType.equals(ForwardingSocketChannel.X11_FORWARDING_CHANNEL)) {
            if (xDisplay == null) {
                throw new InvalidChannelException(
                    "Local display has not been set for X11 forwarding.");
            }

            try {
                ByteArrayReader bar = new ByteArrayReader(requestData);
                String originatingHost = bar.readString();
                int originatingPort = (int) bar.readInt();
                log.debug("Creating socket to " +
                    x11ForwardingConfiguration.getHostToConnect() + "/" +
                    x11ForwardingConfiguration.getPortToConnect());

                Socket socket = new Socket(x11ForwardingConfiguration.getHostToConnect(),
                        x11ForwardingConfiguration.getPortToConnect());

                // Create the channel adding it to the active channels
                ForwardingSocketChannel channel = x11ForwardingConfiguration.createForwardingSocketChannel(channelType,
                        x11ForwardingConfiguration.getHostToConnect(),
                        x11ForwardingConfiguration.getPortToConnect(),
                        originatingHost, originatingPort);
                channel.bindSocket(socket);
                channel.addEventListener(x11ForwardingConfiguration.monitor);

                return channel;
            } catch (IOException ioe) {
                throw new InvalidChannelException(ioe.getMessage());
            }
        }

        if (channelType.equals(
                    ForwardingSocketChannel.REMOTE_FORWARDING_CHANNEL)) {
            try {
                ByteArrayReader bar = new ByteArrayReader(requestData);
                String addressBound = bar.readString();
                int portBound = (int) bar.readInt();
                String originatingHost = bar.readString();
                int originatingPort = (int) bar.readInt();
                ForwardingConfiguration config = getRemoteForwardingByAddress(addressBound,
                        portBound);
                Socket socket = new Socket(config.getHostToConnect(),
                        config.getPortToConnect());

                /*Socket socket = new Socket();
                 socket.connect(new InetSocketAddress(
                     config.getHostToConnect(), config.getPortToConnect()));*/

                // Create the channel adding it to the active channels
                ForwardingSocketChannel channel = config.createForwardingSocketChannel(channelType,
                        config.getHostToConnect(), config.getPortToConnect(),
                        originatingHost, originatingPort);
                channel.bindSocket(socket);
                channel.addEventListener(config.monitor);

                return channel;
            } catch (ForwardingConfigurationException fce) {
                throw new InvalidChannelException(
                    "No valid forwarding configuration was available for the request address");
            } catch (IOException ioe) {
                throw new InvalidChannelException(ioe.getMessage());
            }
        }

        throw new InvalidChannelException(
            "The server can only request a remote forwarding channel or an" +
            "X11 forwarding channel");
    }
View Full Code Here


  }*/
    public Channel createChannel(String channelType, byte[] requestData)
        throws InvalidChannelException {
        if (!channelType.equals(
                    ForwardingSocketChannel.LOCAL_FORWARDING_CHANNEL)) {
            throw new InvalidChannelException(
                "The client can only request the " +
                "opening of a local forwarding channel");
        }

        try {
            ByteArrayReader bar = new ByteArrayReader(requestData);
            String hostToConnect = bar.readString();
            int portToConnect = (int) bar.readInt();
            String originatingHost = bar.readString();
            int originatingPort = (int) bar.readInt();

            // Get a configuration item for the forwarding
            ForwardingConfiguration config = getLocalForwardingByAddress(originatingHost,
                    originatingPort);
            Socket socket = new Socket(hostToConnect, portToConnect);

            // Create the channel adding it to the active channels
            ForwardingSocketChannel channel = config.createForwardingSocketChannel(channelType,
                    hostToConnect, portToConnect, originatingHost,
                    originatingPort);
            channel.bindSocket(socket);

            return channel;
        } catch (ForwardingConfigurationException fce) {
            throw new InvalidChannelException(
                "No valid forwarding configuration was available for the request");
        } catch (IOException ioe) {
            throw new InvalidChannelException("The channel request data is " +
                "invalid/or corrupt for channel type " + channelType);
        }
    }
View Full Code Here

            // Now bind the socket to the channel
            //  bindInputStream(socket.getInputStream());
            //  bindOutputStream(socket.getOutputStream());
            //}
        } catch (IOException ex) {
            throw new InvalidChannelException(ex.getMessage());
        }
    }
View Full Code Here

                                        "sshtools.agent") /*, 5*/);
                            channel.bindSocket(socket);

                            return channel;
                        } catch (Exception ex) {
                            throw new InvalidChannelException(ex.getMessage());
                        }
                    }
                });
        }

View Full Code Here

     */
    public Channel createChannel(String channelType, byte[] requestData)
        throws InvalidChannelException {
        if (channelType.equals(ForwardingSocketChannel.X11_FORWARDING_CHANNEL)) {
            if (xDisplay == null) {
                throw new InvalidChannelException(
                    "Local display has not been set for X11 forwarding.");
            }

            try {
                ByteArrayReader bar = new ByteArrayReader(requestData);
                String originatingHost = bar.readString();
                int originatingPort = (int) bar.readInt();
                log.debug("Creating socket to " +
                    x11ForwardingConfiguration.getHostToConnect() + "/" +
                    x11ForwardingConfiguration.getPortToConnect());

                Socket socket = new Socket(x11ForwardingConfiguration.getHostToConnect(),
                        x11ForwardingConfiguration.getPortToConnect());

                // Create the channel adding it to the active channels
                ForwardingSocketChannel channel = x11ForwardingConfiguration.createForwardingSocketChannel(channelType,
                        x11ForwardingConfiguration.getHostToConnect(),
                        x11ForwardingConfiguration.getPortToConnect(),
                        originatingHost, originatingPort);
                channel.bindSocket(socket);
                channel.addEventListener(x11ForwardingConfiguration.monitor);

                return channel;
            } catch (IOException ioe) {
                throw new InvalidChannelException(ioe.getMessage());
            }
        }

        if (channelType.equals(
                    ForwardingSocketChannel.REMOTE_FORWARDING_CHANNEL)) {
            try {
                ByteArrayReader bar = new ByteArrayReader(requestData);
                String addressBound = bar.readString();
                int portBound = (int) bar.readInt();
                String originatingHost = bar.readString();
                int originatingPort = (int) bar.readInt();
                ForwardingConfiguration config = getRemoteForwardingByAddress(addressBound,
                        portBound);
                Socket socket = new Socket(config.getHostToConnect(),
                        config.getPortToConnect());

                /*Socket socket = new Socket();
                 socket.connect(new InetSocketAddress(
                     config.getHostToConnect(), config.getPortToConnect()));*/

                // Create the channel adding it to the active channels
                ForwardingSocketChannel channel = config.createForwardingSocketChannel(channelType,
                        config.getHostToConnect(), config.getPortToConnect(),
                        originatingHost, originatingPort);
                channel.bindSocket(socket);
                channel.addEventListener(config.monitor);

                return channel;
            } catch (ForwardingConfigurationException fce) {
                throw new InvalidChannelException(
                    "No valid forwarding configuration was available for the request address");
            } catch (IOException ioe) {
                throw new InvalidChannelException(ioe.getMessage());
            }
        }

        throw new InvalidChannelException(
            "The server can only request a remote forwarding channel or an" +
            "X11 forwarding channel");
    }
View Full Code Here

                                        "sshtools.agent") /*, 5*/);
                            channel.bindSocket(socket);

                            return channel;
                        } catch (Exception ex) {
                            throw new InvalidChannelException(ex.getMessage());
                        }
                    }
                });
        }

View Full Code Here

  }*/
    public Channel createChannel(String channelType, byte[] requestData)
        throws InvalidChannelException {
        if (!channelType.equals(
                    ForwardingSocketChannel.LOCAL_FORWARDING_CHANNEL)) {
            throw new InvalidChannelException(
                "The client can only request the " +
                "opening of a local forwarding channel");
        }

        try {
            ByteArrayReader bar = new ByteArrayReader(requestData);
            String hostToConnect = bar.readString();
            int portToConnect = (int) bar.readInt();
            String originatingHost = bar.readString();
            int originatingPort = (int) bar.readInt();

            // Get a configuration item for the forwarding
            ForwardingConfiguration config = getLocalForwardingByAddress(originatingHost,
                    originatingPort);
            Socket socket = new Socket(hostToConnect, portToConnect);

            // Create the channel adding it to the active channels
            ForwardingSocketChannel channel = config.createForwardingSocketChannel(channelType,
                    hostToConnect, portToConnect, originatingHost,
                    originatingPort);
            channel.bindSocket(socket);

            return channel;
        } catch (ForwardingConfigurationException fce) {
            throw new InvalidChannelException(
                "No valid forwarding configuration was available for the request");
        } catch (IOException ioe) {
            throw new InvalidChannelException("The channel request data is " +
                "invalid/or corrupt for channel type " + channelType);
        }
    }
View Full Code Here

            // Now bind the socket to the channel
            //  bindInputStream(socket.getInputStream());
            //  bindOutputStream(socket.getOutputStream());
            //}
        } catch (IOException ex) {
            throw new InvalidChannelException(ex.getMessage());
        }
    }
View Full Code Here

TOP

Related Classes of com.sshtools.j2ssh.connection.InvalidChannelException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.