Package org.apache.sshd.common

Examples of org.apache.sshd.common.SshException


    public Boolean doAuth(Buffer buffer, boolean init) throws Exception {
        if (!init) {
            throw new IllegalStateException();
        }
        if (!"ssh-connection".equals(service)) {
            throw new SshException(SshConstants.SSH2_DISCONNECT_PROTOCOL_ERROR, "Unsupported service '" + service + "'");
        }
        boolean newPassword = buffer.getBoolean();
        if (newPassword) {
            throw new IllegalStateException("Password changes are not supported");
        }
View Full Code Here


        if (clientVersion == null) {
            return false;
        }
        log.debug("Client version string: {}", clientVersion);
        if (!clientVersion.startsWith("SSH-2.0-")) {
            throw new SshException(SshConstants.SSH2_DISCONNECT_PROTOCOL_VERSION_NOT_SUPPORTED,
                                   "Unsupported protocol version: " + clientVersion);
        }
        return true;
    }
View Full Code Here

            }
            // Verify all required methods are supported
            for (List<String> l : authMethods) {
                for (String m : l) {
                    if (NamedFactory.Utils.get(userAuthFactories, m) == null) {
                        throw new SshException("Configured method is not supported: " + m);
                    }
                }
            }
            log.debug("Authorized authentication methods: {}", NamedFactory.Utils.getNames(userAuthFactories));
            setState(State.UserAuth);
View Full Code Here

    public Boolean doAuth(Buffer buffer, boolean init) throws Exception {
        if (!init) {
            throw new IllegalStateException();
        }
        if (!"ssh-connection".equals(service)) {
            throw new SshException(SshConstants.SSH2_DISCONNECT_PROTOCOL_ERROR, "Unsupported service '" + service + "'");
        }
        boolean hasSig = buffer.getBoolean();
        String alg = buffer.getString();

        int oldLim = buffer.wpos();
View Full Code Here

        else
        {
            SshConstants.Message msg = buffer.getCommand();
            if (!(msg == SshConstants.Message.SSH_MSG_USERAUTH_INFO_RESPONSE ||
                    msg == SshConstants.Message.SSH_MSG_USERAUTH_GSSAPI_MIC && context.isEstablished())) {
                throw new SshException(SshConstants.SSH2_DISCONNECT_PROTOCOL_ERROR,
                        "Packet not supported by user authentication method");
            }

            log.debug("In krb5.next: msg = " + msg);
View Full Code Here

    }

    @Override
    protected Boolean doAuth(Buffer buffer, boolean init) throws Exception {
        if (!"ssh-connection".equals(service)) {
            throw new SshException(SshConstants.SSH2_DISCONNECT_PROTOCOL_ERROR, "Unsupported service '" + service + "'");
        }
        if (init) {
            // Prompt for password
            buffer = session.createBuffer(SshConstants.Message.SSH_MSG_USERAUTH_INFO_REQUEST, 0);
            buffer.putString("Password authentication");
            buffer.putString("");
            buffer.putString("en-US");
            buffer.putInt(1);
            buffer.putString("Password: ");
            buffer.putBoolean(false);
            session.writePacket(buffer);
            return null;
        } else {
            SshConstants.Message cmd = buffer.getCommand();
            if (cmd != SshConstants.Message.SSH_MSG_USERAUTH_INFO_RESPONSE) {
                throw new SshException("Received unexepected message: " + cmd);
            }
            int num = buffer.getInt();
            if (num != 1) {
                throw new SshException("Expected 1 response from user but received " + num);
            }
            String password = buffer.getString();
            return checkPassword(session, username, password);
        }
    }
View Full Code Here

    }

    public void receive(SshFile path, boolean recursive, boolean shouldBeDir, boolean preserve) throws IOException {
        if (shouldBeDir) {
            if (!path.doesExist()) {
                throw new SshException("Target directory " + path.toString() + " does not exists");
            }
            if (!path.isDirectory()) {
                throw new SshException("Target directory " + path.toString() + " is not a directory");
            }
        }
        ack();
        long[] time = null;
        for (;;)
View Full Code Here

            } else {
                throw new IllegalStateException("Unsupported algorithm: " + keyAlg);
            }
            return key;
        } catch (InvalidKeySpecException e) {
            throw new SshException(e);
        } catch (NoSuchAlgorithmException e) {
            throw new SshException(e);
        } catch (NoSuchProviderException e) {
            throw new SshException(e);
        }
    }
View Full Code Here

            } else {
                throw new IllegalStateException("Unsupported algorithm: " + keyAlg);
            }
            return new KeyPair(pub, prv);
        } catch (InvalidKeySpecException e) {
            throw new SshException(e);
        } catch (NoSuchAlgorithmException e) {
            throw new SshException(e);
        } catch (NoSuchProviderException e) {
            throw new SshException(e);
        }
    }
View Full Code Here

    }

    @Override
    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

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.