Package com.sshtools.j2ssh.forwarding

Examples of com.sshtools.j2ssh.forwarding.ForwardingConfiguration


            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;
View Full Code Here


    protected ForwardingConfiguration getLocalForwardingByAddress(
        String orginatingAddress, int originatingPort)
        throws ForwardingConfigurationException {
        try {
            Iterator it = localForwardings.iterator();
            ForwardingConfiguration config;

            while (it.hasNext()) {
                config = (ForwardingConfiguration) it.next();

                if (config.getAddressToBind().equals(orginatingAddress) &&
                        (config.getPortToBind() == originatingPort)) {
                    return config;
                }
            }

            // No configuration is available so create one
            config = new ForwardingConfiguration(orginatingAddress,
                    originatingPort);

            // We must start this configuration in order to use it
            config.start();
            localForwardings.add(config);

            return config;
        } catch (IOException ex) {
            throw new ForwardingConfigurationException(ex.getMessage());
View Full Code Here

*/
    protected ForwardingConfiguration getRemoteForwardingByAddress(
        String addressToBind, int portToBind)
        throws ForwardingConfigurationException {
        Iterator it = remoteForwardings.iterator();
        ForwardingConfiguration config;

        while (it.hasNext()) {
            config = (ForwardingConfiguration) it.next();

            if (config.getAddressToBind().equals(addressToBind) &&
                    (config.getPortToBind() == portToBind)) {
                return config;
            }
        }

        throw new ForwardingConfigurationException(
View Full Code Here

*/
    protected void addRemoteForwardingConfiguration(String addressToBind,
        int portToBind) throws ForwardingConfigurationException {
        // Is the server already listening
        Iterator it = remoteForwardings.iterator();
        ForwardingConfiguration config;

        while (it.hasNext()) {
            config = (ForwardingConfiguration) it.next();

            if (config.getAddressToBind().equals(addressToBind) &&
                    (config.getPortToBind() == portToBind)) {
                throw new ForwardingConfigurationException(
                    "The address and port are already in use!");
            }
        }

        config = new ForwardingConfiguration(addressToBind, portToBind);

        // Check the security mananger
        SecurityManager manager = System.getSecurityManager();

        if (manager != null) {
View Full Code Here

*
* @throws ForwardingConfigurationException
*/
    protected void removeRemoteForwarding(String addressToBind, int portToBind)
        throws ForwardingConfigurationException {
        ForwardingConfiguration config = getRemoteForwardingByAddress(addressToBind,
                portToBind);

        // Stop the forwarding
        config.stop();

        // Remove from the remote forwardings list
        remoteForwardings.remove(config);
    }
View Full Code Here

        it = localForwardings.values().iterator();
        xml += ("   <ForwardingAutoStart value=\"" +
        String.valueOf(forwardingAutoStart) + "\"/>\n");

        while (it.hasNext()) {
            ForwardingConfiguration config = (ForwardingConfiguration) it.next();
            xml += ("   <LocalPortForwarding Name=\"" + config.getName() +
            "\" AddressToBind=\"" + config.getAddressToBind() +
            "\" PortToBind=\"" + String.valueOf(config.getPortToBind()) +
            "\" AddressToConnect=\"" + config.getHostToConnect() +
            "\" PortToConnect=\"" + String.valueOf(config.getPortToConnect()) +
            "\"/>\n");
        }

        it = remoteForwardings.values().iterator();

        while (it.hasNext()) {
            ForwardingConfiguration config = (ForwardingConfiguration) it.next();
            xml += ("   <RemotePortForwarding Name=\"" + config.getName() +
            "\" AddressToBind=\"" + config.getAddressToBind() +
            "\" PortToBind=\"" + String.valueOf(config.getPortToBind()) +
            "\" AddressToConnect=\"" + config.getHostToConnect() +
            "\" PortToConnect=\"" + String.valueOf(config.getPortToConnect()) +
            "\"/>\n");
        }

        xml += "</SshToolsConnectionProfile>";
View Full Code Here

                            throw new SAXException(
                                "Required attribute missing for <" + qname +
                                "> element");
                        }

                        ForwardingConfiguration config = new ForwardingConfiguration(name,
                                addressToBind, Integer.parseInt(portToBind),
                                addressToConnect,
                                Integer.parseInt(portToConnect));

                        if (qname.equals("LocalPortForwarding")) {
View Full Code Here

            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;
View Full Code Here

    protected ForwardingConfiguration getLocalForwardingByAddress(
        String orginatingAddress, int originatingPort)
        throws ForwardingConfigurationException {
        try {
            Iterator it = localForwardings.iterator();
            ForwardingConfiguration config;

            while (it.hasNext()) {
                config = (ForwardingConfiguration) it.next();

                if (config.getAddressToBind().equals(orginatingAddress) &&
                        (config.getPortToBind() == originatingPort)) {
                    return config;
                }
            }

            // No configuration is available so create one
            config = new ForwardingConfiguration(orginatingAddress,
                    originatingPort);

            // We must start this configuration in order to use it
            config.start();
            localForwardings.add(config);

            return config;
        } catch (IOException ex) {
            throw new ForwardingConfigurationException(ex.getMessage());
View Full Code Here

*/
    protected ForwardingConfiguration getRemoteForwardingByAddress(
        String addressToBind, int portToBind)
        throws ForwardingConfigurationException {
        Iterator it = remoteForwardings.iterator();
        ForwardingConfiguration config;

        while (it.hasNext()) {
            config = (ForwardingConfiguration) it.next();

            if (config.getAddressToBind().equals(addressToBind) &&
                    (config.getPortToBind() == portToBind)) {
                return config;
            }
        }

        throw new ForwardingConfigurationException(
View Full Code Here

TOP

Related Classes of com.sshtools.j2ssh.forwarding.ForwardingConfiguration

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.