Package org.apache.sshd.client.future

Examples of org.apache.sshd.client.future.AuthFuture


        ClientChannel channel = null;
        ClientSession session = null;
       
        try {
            AuthFuture authResult;
            session = connectFuture.getSession();
   
            KeyPairProvider keyPairProvider;
            final String certResource = getCertResource();
            if (certResource != null) {
                log.debug("Attempting to authenticate using ResourceKey '{}'...", certResource);
                keyPairProvider = new ResourceHelperKeyPairProvider(new String[]{certResource}, getCamelContext().getClassResolver());
            } else {
                keyPairProvider = getKeyPairProvider();
            }
   
            if (keyPairProvider != null) {
                log.debug("Attempting to authenticate username '{}' using Key...", getUsername());
                KeyPair pair = keyPairProvider.loadKey(getKeyType());
                authResult = session.authPublicKey(getUsername(), pair);
            } else {
                log.debug("Attempting to authenticate username '{}' using Password...", getUsername());
                authResult = session.authPassword(getUsername(), getPassword());
            }
   
            authResult.await(getTimeout());
   
            if (!authResult.isDone() || authResult.isFailure()) {
                log.debug("Failed to authenticate");
                throw new RuntimeCamelException("Failed to authenticate username " + getUsername());
            }
       
            channel = session.createChannel(ClientChannel.CHANNEL_EXEC, command);
View Full Code Here


            */

            ClientSession session = client.connect(host, port).await().getSession();
            int ret = ClientSession.WAIT_AUTH;

            AuthFuture authFuture;
            do {
                if (hasKeys) {
                    authFuture = session.authAgent(login);
                } else {
                    System.out.print("Password:");
                    BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
                    String password = r.readLine();
                    authFuture = session.authPassword(login, password);
                }
                authFuture.await();
            } while (authFuture.isFailure());
            if (!authFuture.isSuccess()) {
                System.err.println("error");
                System.exit(-1);
            }
            ClientChannel channel;
            if (command == null) {
View Full Code Here

        client = SshClient.setUpDefaultClient();
        client.start();
        ClientSession s = client.connect("localhost", port).await().getSession();
        int nbTrials = 0;
        AuthFuture authFuture;
        do {
            nbTrials++;
            assertTrue(nbTrials < 100);
            authFuture = s.authPassword("smx", "buggy");
            assertTrue(authFuture.await(5000));
            assertTrue(authFuture.isDone());
            assertFalse(authFuture.isSuccess());
        }
        while (authFuture.isFailure());
        assertNotNull(authFuture.getException());
        assertTrue(nbTrials > 10);
    }
View Full Code Here

    public void testCloseBeforeAuthSucceed() throws Exception {
        authLatch = new CountDownLatch(1);
        SshClient client = SshClient.setUpDefaultClient();
        client.start();
        ClientSession session = client.connect("localhost", port).await().getSession();
        AuthFuture authFuture = session.authPassword("smx", "smx");
        CloseFuture closeFuture = session.close(false);
        authLatch.countDown();
        authFuture.await();
        closeFuture.await();
        assertNotNull(authFuture.getException());
        assertTrue(closeFuture.isClosed());
    }
View Full Code Here

                return new String[] { "bad" };
            }
        });
        client.start();
        ClientSession session = client.connect("smx", "localhost", port).await().getSession();
        AuthFuture future = session.auth();
        future.await();
        assertTrue(future.isFailure());
        assertEquals(3, count.get());
    }
View Full Code Here

        client.start();
        ConnectFuture sessionFuture = client.connect("localhost", sshPort);
        sessionFuture.await();
        ClientSession session = sessionFuture.getSession();

        AuthFuture authPassword = session.authPassword("sshd", "sshd");
        authPassword.await();

        return session;
    }
View Full Code Here

    @Test
    public void testCloseBeforeAuthSucceed() throws Exception {
        SshClient client = SshClient.setUpDefaultClient();
        client.start();
        ClientSession session = client.connect("localhost", port).await().getSession();
        AuthFuture authFuture = session.authPassword("smx", "smx");
        CloseFuture closeFuture = session.close(false);
        authFuture.await();
        closeFuture.await();
        assertNotNull(authFuture.getException());
        assertTrue(closeFuture.isClosed());
    }
View Full Code Here

        client = SshClient.setUpDefaultClient();
        client.start();
        ClientSession s = client.connect("localhost", port).await().getSession();
        int nbTrials = 0;
        AuthFuture authFuture;
        do {
            nbTrials++;
            assertTrue(nbTrials < 100);
            authFuture = s.authPassword("smx", "buggy");
            assertTrue(authFuture.await(5000));
            assertTrue(authFuture.isDone());
            assertFalse(authFuture.isSuccess());
        }
        while (authFuture.isFailure());
        assertNotNull(authFuture.getException());
        assertTrue(nbTrials > 10);
    }
View Full Code Here

    public void testCloseBeforeAuthSucceed() throws Exception {
        authLatch = new CountDownLatch(1);
        SshClient client = SshClient.setUpDefaultClient();
        client.start();
        ClientSession session = client.connect("localhost", port).await().getSession();
        AuthFuture authFuture = session.authPassword("smx", "smx");
        CloseFuture closeFuture = session.close(false);
        authLatch.countDown();
        authFuture.await();
        closeFuture.await();
        assertNotNull(authFuture.getException());
        assertTrue(closeFuture.isClosed());
    }
View Full Code Here

        client.start();
        ConnectFuture sessionFuture = client.connect("localhost", sshPort);
        sessionFuture.await();
        ClientSession session = sessionFuture.getSession();

        AuthFuture authPassword = session.authPassword("sshd", "sshd");
        authPassword.await();

        return session;
    }
View Full Code Here

TOP

Related Classes of org.apache.sshd.client.future.AuthFuture

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.