Package org.apache.sshd.common

Examples of org.apache.sshd.common.SshException


        }

        public synchronized OpenFuture open() throws IOException {
            InetSocketAddress remote = (InetSocketAddress) serverSession.getRemoteAddress();
            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


        int recipient = buffer.getInt();
        Channel channel = channels.get(recipient);
        if (channel == null) {
            buffer.rpos(buffer.rpos() - 5);
            byte cmd = buffer.getByte();
            throw new SshException("Received " + cmd + " on unknown channel " + recipient);
        }
        return channel;
    }
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
        {
            byte msg = buffer.getByte();
            if (!(msg == SshConstants.SSH_MSG_USERAUTH_INFO_RESPONSE ||
                    msg == SshConstants.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

        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

        if (!(s instanceof ServerSession)) {
            throw new IllegalStateException("Server side service used on client side");
        }
        ServerSession session = (ServerSession) s;
        if (!session.isAuthenticated()) {
            throw new SshException("Session is not authenticated");
        }
    }
View Full Code Here

        if (!(s instanceof ServerSession)) {
            throw new IllegalStateException("Server side service used on client side");
        }
        this.session = (ServerSession) s;
        if (session.isAuthenticated()) {
            throw new SshException("Session already authenticated");
        }
        maxAuthRequests = session.getIntProperty(ServerFactoryManager.MAX_AUTH_REQUESTS, maxAuthRequests);

        userAuthFactories = new ArrayList<NamedFactory<UserAuth>>(getFactoryManager().getUserAuthFactories());
        // Get authentication methods
        authMethods = new ArrayList<List<String>>();
        String mths = getFactoryManager().getProperties().get(SshServer.AUTH_METHODS);
        if (mths == null) {
            for (NamedFactory<UserAuth> uaf : getFactoryManager().getUserAuthFactories()) {
                authMethods.add(new ArrayList<String>(Collections.singletonList(uaf.getName())));
            }
        } else {
            for (String mthl : mths.split("\\s")) {
                authMethods.add(new ArrayList<String>(Arrays.asList(mthl.split(","))));
            }
        }
        // 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));
    }
View Full Code Here

    private final List<Pair<KeyPair, String>> keys = new ArrayList<Pair<KeyPair, String>>();
    private boolean closed;

    public List<Pair<PublicKey, String>> getIdentities() throws IOException {
        if (closed) {
            throw new SshException("Agent closed");
        }
        List<Pair<PublicKey, String>> pks = new ArrayList<Pair<PublicKey, String>>();
        for (Pair<KeyPair, String> kp : keys) {
            pks.add(new Pair<PublicKey, String>(kp.getFirst().getPublic(), kp.getSecond()));
        }
View Full Code Here

        return pks;
    }

    public byte[] sign(PublicKey key, byte[] data) throws IOException {
        if (closed) {
            throw new SshException("Agent closed");
        }
        Pair<KeyPair, String> kp = getKeyPair(keys, key);
        if (kp == null) {
            throw new SshException("Key not found");
        }
        try {
            Signature verif;
            if (kp.getFirst().getPublic() instanceof DSAPublicKey) {
                verif = new SignatureDSA();
            } else if (kp.getFirst().getPublic() instanceof ECPublicKey) {
                ECPublicKey pubKey = (ECPublicKey) kp.getFirst().getPublic();
                verif = SignatureECDSA.getByCurveSize(pubKey.getParams());
            } else if (kp.getFirst().getPublic() instanceof RSAPublicKey) {
                verif = new SignatureRSA();
            } else {
                throw new SshException("Unsupported key type");
            }
            verif.init(kp.getFirst().getPublic(), kp.getFirst().getPrivate());
            verif.update(data, 0, data.length);
            return verif.sign();
        } catch (IOException e) {
            throw e;
        } catch (Exception e) {
            throw new SshException(e);
        }
    }
View Full Code Here

        }
    }

    public void addIdentity(KeyPair key, String comment) throws IOException {
        if (closed) {
            throw new SshException("Agent closed");
        }
        keys.add(new Pair<KeyPair, String>(key, comment));
    }
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.