Package com.sshtools.j2ssh.io

Examples of com.sshtools.j2ssh.io.ByteArrayWriter


     */
    public boolean executeCommand(String command) throws IOException {
        log.info("Requesting command execution");
        log.info("Command is " + command);

        ByteArrayWriter baw = new ByteArrayWriter();
        baw.writeString(command);

        if( connection.sendChannelRequest(this, "exec", true, baw.toByteArray()) )
        {
          if (sessionType.equals("Uninitialized")) {
            sessionType = command;
          }
         
View Full Code Here


            log.debug("Width=" + String.valueOf(width));
            log.debug("Height=" + String.valueOf(height));
        }

        // This requests a pseudo terminal
        ByteArrayWriter baw = new ByteArrayWriter();
        baw.writeString(term);
        baw.writeInt(cols);
        baw.writeInt(rows);
        baw.writeInt(width);
        baw.writeInt(height);
        baw.writeString(terminalModes);

        return connection.sendChannelRequest(this, "pty-req", true,
            baw.toByteArray());
    }
View Full Code Here

     * @throws IOException
     */
    public boolean startSubsystem(String subsystem) throws IOException {
        log.info("Starting " + subsystem + " subsystem");

        ByteArrayWriter baw = new ByteArrayWriter();
        baw.writeString(subsystem);

        if (connection.sendChannelRequest(this, "subsystem", true,
                    baw.toByteArray())) {
            if (sessionType.equals("Uninitialized")) {
                sessionType = subsystem;
            }

            return true;
View Full Code Here

        if (x11ForwardingConfiguration == null) {
            throw new ForwardingConfigurationException(
                "X11 forwarding hasn't been enabled.");
        }

        ByteArrayWriter baw = new ByteArrayWriter();
        baw.writeString(x11ForwardingConfiguration.getAddressToBind());
        baw.writeInt(x11ForwardingConfiguration.getPortToBind());
        x11ForwardingConfiguration.getState().setValue(StartStopState.STARTED);

        if (log.isDebugEnabled()) {
            log.info("X11 forwarding started");
            log.debug("Address to bind: " +
View Full Code Here

            throw new ForwardingConfigurationException(
                "The name is not a valid forwarding configuration");
        }

        ForwardingConfiguration config = (ForwardingConfiguration) remoteForwardings.get(name);
        ByteArrayWriter baw = new ByteArrayWriter();
        baw.writeString(config.getAddressToBind());
        baw.writeInt(config.getPortToBind());
        connection.sendGlobalRequest(REMOTE_FORWARD_REQUEST, true,
            baw.toByteArray());
        remoteForwardings.put(name, config);
        config.getState().setValue(StartStopState.STARTED);
        log.info("Remote forwarding configuration '" + name + "' started");

        if (log.isDebugEnabled()) {
View Full Code Here

            throw new ForwardingConfigurationException(
                "The remote forwarding configuration does not exist");
        }

        ForwardingConfiguration config = (ForwardingConfiguration) remoteForwardings.get(name);
        ByteArrayWriter baw = new ByteArrayWriter();
        baw.writeString(config.getAddressToBind());
        baw.writeInt(config.getPortToBind());
        connection.sendGlobalRequest(REMOTE_FORWARD_CANCEL_REQUEST, true,
            baw.toByteArray());
        config.getState().setValue(StartStopState.STOPPED);
        log.info("Remote forwarding configuration '" + name + "' stopped");
    }
View Full Code Here

     *
     * @return
     */
    public byte[] getEncoded() {
        try {
            ByteArrayWriter baw = new ByteArrayWriter();

            // The private key consists of the public key blob
            baw.write(getPublicKey().getEncoded());

            // And the private data
            baw.writeBigInteger(prvKey.getPrivateExponent());

            return baw.toByteArray();
        } catch (IOException ioe) {
            return null;
        }
    }
View Full Code Here

        try {
            Signature sig = Signature.getInstance("SHA1withRSA");
            sig.initSign(prvKey);
            sig.update(data);

            ByteArrayWriter baw = new ByteArrayWriter();
            baw.writeString(getAlgorithmName());
            baw.writeBinaryString(sig.sign());

            return baw.toByteArray();
        } catch (Exception e) {
            return null;
        }
    }
View Full Code Here

                    break;
                }
            }

            // This is now the public key blob Base64 encoded
            ByteArrayWriter baw = new ByteArrayWriter();

            while (true) {
                blob += line;
                line = reader.readLine();
View Full Code Here

     *
     * @return
     */
    public byte[] getChannelOpenData() {
        try {
            ByteArrayWriter baw = new ByteArrayWriter();
            baw.writeString(hostToConnectOrBind);
            baw.writeInt(portToConnectOrBind);
            baw.writeString(originatingHost);
            baw.writeInt(originatingPort);

            return baw.toByteArray();
        } catch (IOException ioe) {
            return null;
        }
    }
View Full Code Here

TOP

Related Classes of com.sshtools.j2ssh.io.ByteArrayWriter

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.