Package org.apache.sshd.common

Examples of org.apache.sshd.common.SshException


        int length = buffer.getInt();
        int type = buffer.getByte();
        int id = buffer.getInt();
        if (type == SSH_FXP_VERSION) {
            if (id != 3) {
                throw new SshException("Unable to use SFTP v3, server replied with version " + id);
            }
        } else if (type == SSH_FXP_STATUS) {
            int substatus = buffer.getInt();
            String msg = buffer.getString();
            String lang = buffer.getString();
            throw new SshException("SFTP error (" + substatus + "): " + msg);
        } else {
            throw new SshException("Unexpected SFTP packet received: " + type);
        }
    }
View Full Code Here


        if (type == SSH_FXP_STATUS) {
            int substatus = buffer.getInt();
            String msg = buffer.getString();
            String lang = buffer.getString();
            if (substatus != SSH_FX_OK) {
                throw new SshException("SFTP error (" + substatus + "): " + msg);
            }
        } else {
            throw new SshException("Unexpected SFTP packet received: " + type);
        }
    }
View Full Code Here

        int id = buffer.getInt();
        if (type == SSH_FXP_STATUS) {
            int substatus = buffer.getInt();
            String msg = buffer.getString();
            String lang = buffer.getString();
            throw new SshException("SFTP error (" + substatus + "): " + msg);
        } else if (type == SSH_FXP_HANDLE) {
            String handle = buffer.getString();
            return new Handle(handle);
        } else {
            throw new SshException("Unexpected SFTP packet received: " + type);
        }
    }
View Full Code Here

        int id = buffer.getInt();
        if (type == SSH_FXP_STATUS) {
            int substatus = buffer.getInt();
            String msg = buffer.getString();
            String lang = buffer.getString();
            throw new SshException("SFTP error (" + substatus + "): " + msg);
        } else if (type == SSH_FXP_ATTRS) {
            return readAttributes(buffer);
        } else {
            throw new SshException("Unexpected SFTP packet received: " + type);
        }
    }
View Full Code Here

        int id = buffer.getInt();
        if (type == SSH_FXP_STATUS) {
            int substatus = buffer.getInt();
            String msg = buffer.getString();
            String lang = buffer.getString();
            throw new SshException("SFTP error (" + substatus + "): " + msg);
        } else if (type == SSH_FXP_NAME) {
            int len = buffer.getInt();
            if (len != 1) {
                throw new SshException("SFTP error: received " + len + " names instead of 1");
            }
            String name = buffer.getString();
            String longName = buffer.getString();
            Attributes attrs = readAttributes(buffer);
            return name;
        } else {
            throw new SshException("Unexpected SFTP packet received: " + type);
        }
    }
View Full Code Here

            String msg = buffer.getString();
            String lang = buffer.getString();
            if (substatus == SSH_FX_EOF) {
                return -1;
            }
            throw new SshException("SFTP error (" + substatus + "): " + msg);
        } else if (type == SSH_FXP_DATA) {
            len = buffer.getInt();
            buffer.getRawBytes(dst, dstoff, len);
            return len;
        } else {
            throw new SshException("Unexpected SFTP packet received: " + type);
        }
    }
View Full Code Here

            String msg = buffer.getString();
            String lang = buffer.getString();
            if (substatus == SSH_FX_EOF) {
                return null;
            }
            throw new SshException("SFTP error (" + substatus + "): " + msg);
        } else if (type == SSH_FXP_NAME) {
            int len = buffer.getInt();
            DirEntry[] entries = new DirEntry[len];
            for (int i = 0; i < len; i++) {
                String name = buffer.getString();
                String longName = buffer.getString();
                Attributes attrs = readAttributes(buffer);
                entries[i] = new DirEntry(name, longName, attrs);
            }
            return entries;
        } else {
            throw new SshException("Unexpected SFTP packet received: " + type);
        }
    }
View Full Code Here

        if (!closeFuture.isDone()) {
            if (opened) {
                super.close(immediately);
            } else if (openFuture != null) {
                if (immediately) {
                    openFuture.setException(new SshException("Channel closed"));
                    super.close(immediately);
                } else {
                    openFuture.addListener(new SshFutureListener<OpenFuture>() {
                        public void operationComplete(OpenFuture future) {
                            if (future.isOpened()) {
View Full Code Here

        }
    }

    protected OpenFuture internalOpen() throws IOException {
        if (closeFuture.isClosed()) {
            throw new SshException("Session has been closed");
        }
        openFuture = new DefaultOpenFuture(lock);
        log.info("Send SSH_MSG_CHANNEL_OPEN on channel {}", id);
        Buffer buffer = session.createBuffer(SshConstants.Message.SSH_MSG_CHANNEL_OPEN, 0);
        buffer.putString(type);
View Full Code Here

    public void handleOpenFailure(Buffer buffer) {
        int reason = buffer.getInt();
        String msg = buffer.getString();
        this.openFailureReason = reason;
        this.openFailureMsg = msg;
        this.openFuture.setException(new SshException(msg));
        this.closeFuture.setClosed();
        this.postClose();
        notifyStateChanged();
    }
View Full Code Here

TOP

Related Classes of org.apache.sshd.common.SshException

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.