Package org.apache.sshd.common.util

Examples of org.apache.sshd.common.util.Buffer


                setDataReceiver(recv);
                command.setInputStream(recv.getIn());
            }
        }
        if (tempBuffer != null) {
            Buffer buffer = tempBuffer;
            tempBuffer = null;
            doWriteData(buffer.array(), buffer.rpos(), buffer.available());
        }
        command.setExitCallback(new ExitCallback() {
            public void onExit(int exitValue) {
                try {
                    closeShell(exitValue);
View Full Code Here


        IoHandler handler = new IoHandler() {
            public void messageReceived(IoSession session, Readable message) throws Exception {
                if (state.get() != OPENED) {
                    log.debug("Ignoring write to channel {} in CLOSING state", id);
                } else {
                    Buffer buffer = new Buffer();
                    buffer.putBuffer(message);
                    out.write(buffer.array(), buffer.rpos(), buffer.available());
                    out.flush();
                }
            }
            public void sessionCreated(IoSession session) throws Exception {
            }
View Full Code Here

    }

    private Buffer buffer = new Buffer();

    public int data(ChannelSession channel, byte[] buf, int start, int len) throws IOException {
        Buffer incoming = new Buffer(buf,  start, len);
        // If we already have partial data, we need to append it to the buffer and use it
        if (buffer.available() > 0) {
            buffer.putBuffer(incoming);
            incoming = buffer;
        }
        // Process commands
        int rpos = incoming.rpos();
        while (receive(incoming));
        int read = incoming.rpos() - rpos;
        // Compact and add remaining data
        buffer.compact();
        if (buffer != incoming && incoming.available() > 0) {
            buffer.putBuffer(incoming);
        }
        return read;
    }
View Full Code Here

    protected void doOpen() throws IOException {
        doOpenPty();

        log.debug("Send SSH_MSG_CHANNEL_REQUEST shell");
        Buffer buffer = session.createBuffer(SshConstants.SSH_MSG_CHANNEL_REQUEST);
        buffer.putInt(recipient);
        buffer.putString("shell");
        buffer.putBoolean(false);
        writePacket(buffer);

        super.doOpen();
    }
View Full Code Here

        if (initialServiceRequestSent) {
            return;
        }
        initialServiceRequestSent = true;
        log.debug("Send SSH_MSG_SERVICE_REQUEST for {}", currentServiceFactory.getName());
        Buffer request = createBuffer(SshConstants.SSH_MSG_SERVICE_REQUEST);
        request.putString(currentServiceFactory.getName());
        writePacket(request);
        // Assuming that MINA-SSHD only implements "explicit server authentication" it is permissible
        // for the client's service to start sending data before the service-accept has been received.
        // If "implicit authentication" were to ever be supported, then this would need to be
        // called after service-accept comes back.  See SSH-TRANSPORT.
View Full Code Here

        log.debug("Start authentication");
        this.identities = new ArrayList<Object>(identities);
        this.service = service;

        log.debug("Send SSH_MSG_USERAUTH_REQUEST for none");
        Buffer buffer = session.createBuffer(SshConstants.SSH_MSG_USERAUTH_REQUEST);
        buffer.putString(session.getUsername());
        buffer.putString(service);
        buffer.putString("none");
        session.writePacket(buffer);

        return authFuture;
    }
View Full Code Here

        if (closeFuture.isClosed()) {
            throw new SshException("Session has been closed");
        }
        openFuture = new DefaultOpenFuture(lock);
        log.debug("Send SSH_MSG_CHANNEL_OPEN on channel {}", this);
        Buffer buffer = session.createBuffer(SshConstants.SSH_MSG_CHANNEL_OPEN);
        buffer.putString(type);
        buffer.putInt(id);
        buffer.putInt(localWindow.getSize());
        buffer.putInt(localWindow.getPacketSize());
        writePacket(buffer);
        return openFuture;
    }
View Full Code Here

        // If we're already closing, ignore incoming data
        if (state.get() != CloseableUtils.AbstractCloseable.OPENED) {
            return;
        }
        if (asyncOut != null) {
            asyncOut.write(new Buffer(data, off, len));
        } else if (out != null) {
            out.write(data, off, len);
            out.flush();
            localWindow.consumeAndCheck(len);
        } else {
View Full Code Here

        // If we're already closing, ignore incoming data
        if (state.get() != CloseableUtils.AbstractCloseable.OPENED) {
            return;
        }
        if (asyncErr != null) {
            asyncErr.write(new Buffer(data, off, len));
        } else if (err != null) {
            err.write(data, off, len);
            err.flush();
            localWindow.consumeAndCheck(len);
        } else {
View Full Code Here

    /**
     * Receive binary data
     */
    protected int data(byte[] buf, int start, int len) throws IOException {
        Buffer incoming = new Buffer(buf,  start, len);
        // If we already have partial data, we need to append it to the buffer and use it
        if (receiveBuffer.available() > 0) {
            receiveBuffer.putBuffer(incoming);
            incoming = receiveBuffer;
        }
        // Process commands
        int rpos = incoming.rpos();
        while (receive(incoming));
        int read = incoming.rpos() - rpos;
        // Compact and add remaining data
        receiveBuffer.compact();
        if (receiveBuffer != incoming && incoming.available() > 0) {
            receiveBuffer.putBuffer(incoming);
        }
        return read;
    }
View Full Code Here

TOP

Related Classes of org.apache.sshd.common.util.Buffer

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.