Package org.apache.sshd.client

Examples of org.apache.sshd.client.UserInteraction


                    if (num == 0) {
                        rep = new String[0];
                    } else if (num == 1 && password != null && !echo[0] && prompt[0].toLowerCase().startsWith("password:")) {
                        rep = new String[] { password };
                    } else {
                        UserInteraction ui = session.getClientFactoryManager().getUserInteraction();
                        if (ui != null) {
                            String dest = username + "@" + session.getIoSession().getRemoteAddress().toString();
                            rep = ui.interactive(dest, name, instruction, prompt, echo);
                        }
                    }
                    if (rep == null) {
                        return Result.Failure;
                    }
View Full Code Here


                        }
                        if (cmd == SshConstants.Message.SSH_MSG_USERAUTH_BANNER) {
                            String welcome = buffer.getString();
                            String lang = buffer.getString();
                            log.debug("Welcome banner: " + welcome);
                            UserInteraction ui = getClientFactoryManager().getUserInteraction();
                            if (ui != null) {
                                ui.welcome(welcome);
                            }
                        } else {
                            buffer.rpos(buffer.rpos() - 1);
                            processUserAuth(buffer);
                        }
View Full Code Here

        }

        SshClient client = SshClient.setUpDefaultClient();
        client.start();
        client.setKeyPairProvider(provider);
        client.setUserInteraction(new UserInteraction() {
            public void welcome(String banner) {
                System.out.println(banner);
            }
            public String[] interactive(String destination, String name, String instruction, String[] prompt, boolean[] echo) {
                String[] answers = new String[prompt.length];
View Full Code Here

    @Test
    public void testBanner() throws Exception {
        final AtomicReference<String> welcome = new AtomicReference<String>();
        SshClient client = SshClient.setUpDefaultClient();
        client.setUserInteraction(new UserInteraction() {
            public void welcome(String banner) {
                welcome.set(banner);
            }
            public String[] interactive(String destination, String name, String instruction, String[] prompt, boolean[] echo) {
                return null;
View Full Code Here

            // ignore for now; TODO: random packets
        } else if (cmd == SshConstants.SSH_MSG_USERAUTH_BANNER) {
            String welcome = buffer.getString();
            String lang = buffer.getString();
            log.debug("Welcome banner: {}", welcome);
            UserInteraction ui = session.getFactoryManager().getUserInteraction();
            if (ui != null) {
                ui.welcome(welcome);
            }
        } else {
            buffer.rpos(buffer.rpos() - 1);
            processUserAuth(buffer);
        }
View Full Code Here

            // ignore for now; TODO: random packets
        } else if (cmd == SshConstants.SSH_MSG_USERAUTH_BANNER) {
            String welcome = buffer.getString();
            String lang = buffer.getString();
            log.debug("Welcome banner: {}", welcome);
            UserInteraction ui = session.getFactoryManager().getUserInteraction();
            if (ui != null) {
                ui.welcome(welcome);
            }
        } else {
            buffer.rpos(buffer.rpos() - 1);
            processUserAuth(buffer);
        }
View Full Code Here

    public void testKeyboardInteractiveWithFailures() throws Exception {
        final AtomicInteger count = new AtomicInteger();
        SshClient client = SshClient.setUpDefaultClient();
        client.getProperties().put(ClientFactoryManager.PASSWORD_PROMPTS, "3");
        client.setUserAuthFactories(Arrays.<NamedFactory<UserAuth>>asList(new UserAuthKeyboardInteractive.Factory()));
        client.setUserInteraction(new UserInteraction() {
            public void welcome(String banner) {
            }
            public String[] interactive(String destination, String name, String instruction, String[] prompt, boolean[] echo) {
                count.incrementAndGet();
                return new String[] { "bad" };
View Full Code Here

            if (num == 0) {
                rep = new String[0];
            } else if (num == 1 && current != null && !echo[0] && prompt[0].toLowerCase().startsWith("password:")) {
                rep = new String[] { current };
            } else {
                UserInteraction ui = session.getFactoryManager().getUserInteraction();
                if (ui != null) {
                    String dest = session.getUsername() + "@" + ((AbstractSession) session).getIoSession().getRemoteAddress().toString();
                    rep = ui.interactive(dest, name, instruction, prompt, echo);
                }
            }
            if (rep == null) {
                return false;
            }
View Full Code Here

            // ignore for now; TODO: random packets
        } else if (cmd == SshConstants.SSH_MSG_USERAUTH_BANNER) {
            String welcome = buffer.getString();
            String lang = buffer.getString();
            log.debug("Welcome banner: {}", welcome);
            UserInteraction ui = session.getFactoryManager().getUserInteraction();
            if (ui != null) {
                ui.welcome(welcome);
            }
        } else {
            buffer.rpos(buffer.rpos() - 1);
            processUserAuth(buffer);
        }
View Full Code Here

            // ignore for now; TODO: random packets
        } else if (cmd == SshConstants.SSH_MSG_USERAUTH_BANNER) {
            String welcome = buffer.getString();
            String lang = buffer.getString();
            log.debug("Welcome banner: {}", welcome);
            UserInteraction ui = session.getFactoryManager().getUserInteraction();
            if (ui != null) {
                ui.welcome(welcome);
            }
        } else {
            buffer.rpos(buffer.rpos() - 1);
            processUserAuth(buffer);
        }
View Full Code Here

TOP

Related Classes of org.apache.sshd.client.UserInteraction

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.