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


            throw new RuntimeCamelException(msg);
        }

        log.debug("Connected to {}:{}", getHost(), getPort());

        AuthFuture authResult;
        ClientSession 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());
        }

        ClientChannel channel = session.createChannel(ClientChannel.CHANNEL_EXEC, command);
View Full Code Here

            final ConnectFuture connectFuture = sshClient.connect(connectionUrl.getHost(), connectionUrl.getPort());
            connectFuture.await(15 * 1000);

            clientSession = connectFuture.getSession();

            final AuthFuture authFuture = clientSession.authPassword(credentials.getUsername(), credentials.getPassword());
            authFuture.await(15 * 1000);

            if (!authFuture.isSuccess()) {
                exception = authFuture.getException();

                try {
                    disconnect();
                } catch (final IOException e) {
                    KarafCorePluginActivator.getLogger().warn("Error while disconnecting after authenticate failure", e);
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

        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

    @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

            throw new RuntimeCamelException(msg);
        }

        log.debug("Connected to {}:{}", getHost(), getPort());

        AuthFuture authResult;
        ClientSession 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());
        }

        ClientChannel channel = session.createChannel(ClientChannel.CHANNEL_EXEC, command);
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.