Package com.sshtools.j2ssh.authentication

Examples of com.sshtools.j2ssh.authentication.SshAuthenticationClient


        while (it.hasNext()) {
            entry = (Map.Entry) it.next();
            xml += ("   <AuthenticationMethod Name=\"" + entry.getKey() +
            "\">\n");

            SshAuthenticationClient auth = (SshAuthenticationClient) entry.getValue();
            properties = auth.getPersistableProperties();

            Iterator it2 = properties.entrySet().iterator();

            while (it2.hasNext()) {
                entry = (Map.Entry) it2.next();
View Full Code Here


                    currentElement = "SshToolsConnectionProfile";
                } else if (qname.equals("AuthenticationMethod")) {
                    currentElement = "SshToolsConnectionProfile";

                    try {
                        SshAuthenticationClient auth = SshAuthenticationClientFactory.newInstance(currentAuthentication);
                        auth.setPersistableProperties(currentProperties);
                        authMethods.put(currentAuthentication, auth);
                    } catch (AlgorithmNotSupportedException anse) {
                        log.warn(
                            "AuthenticationMethod element ignored because '" +
                            currentAuthentication +
View Full Code Here

            if (!authenticationMethod.equals("")) {
                try {
                    log.debug("Adding authentication method " +
                        authenticationMethod);

                    SshAuthenticationClient authClient = SshAuthenticationClientFactory.newInstance(authenticationMethod);
                    profile.addAuthenticationMethod(authClient);
                } catch (Exception e) {
                    log.error("Could not add authentication method.", e);
                }
            }
View Full Code Here

        //Iterator it2 = null;
        java.util.List selected;

        // Loop until the user either cancels or completes
        boolean completed = false;
        SshAuthenticationClient auth;
        Map.Entry entry;
        String msg = null;

        while (!completed &&
                (ssh.getConnectionState().getValue() != TransportProtocolState.DISCONNECTED)) {
            auth = null;

            // Select an authentication method from the properties file or
            // prompt the user to choose
            if (it.hasNext()) {
                Object obj = it.next();

                if (obj instanceof Map.Entry) {
                    entry = (Map.Entry) obj;
                    auth = (SshAuthenticationClient) entry.getValue();
                } else if (obj instanceof String) {
                    auth = SshAuthenticationClientFactory.newInstance((String) obj);
                    auth.setUsername(getCurrentConnectionProfile().getUsername());
                } else {
                    closeConnection(true);
                    throw new IOException(
                        "Iterator of Map or List of String expected");
                }
            } else {
                selected = AuthenticationDialog.showAuthenticationDialog(this,
                        display, ((msg == null) ? "" : msg));

                if (selected.size() > 0) {
                    it = selected.iterator();
                } else {
                    closeConnection(true);

                    return false;
                }
            }

            if (auth != null) {
                // The password authentication client can act upon requests to change the password

                /* if (auth instanceof PasswordAuthenticationClient) {
PasswordAuthenticationDialog dialog = new PasswordAuthenticationDialog(SshTerminalPanel.this);
((PasswordAuthenticationClient) auth).setAuthenticationPrompt(dialog);
( (PasswordAuthenticationClient) auth)
.setPasswordChangePrompt(PasswordChange.getInstance());
PasswordChange.getInstance().setParentComponent(
SshTerminalPanel.this);
}*/

                // Show the implementations dialog
                // if(auth.showAuthenticationDialog()) {
                // Authentication with the details supplied
                result = showAuthenticationPrompt(auth); //ssh.authenticate(auth);

                if (result == AuthenticationProtocolState.FAILED) {
                    msg = auth.getMethodName() +
                        " authentication failed, try again?";
                }

                // If the result returned partial success then continue
                if (result == AuthenticationProtocolState.PARTIAL) {
                    // We succeeded so add to the connections authenticaiton
                    // list and continue on to the next one
                    getCurrentConnectionProfile().addAuthenticationMethod(auth);
                    msg = auth.getMethodName() +
                        " authentication succeeded but another is required";
                }

                if (result == AuthenticationProtocolState.COMPLETE) {
                    authenticated = true;
View Full Code Here

    /**
*
*/
    public void clearAuthenticationCache() {
        SshAuthenticationClient auth;
        Properties properties;

        for (Iterator it = authMethods.values().iterator(); it.hasNext();) {
            auth = (SshAuthenticationClient) it.next();
            properties = auth.getPersistableProperties();
            auth.reset();
            auth.setPersistableProperties(properties);
        }
    }
View Full Code Here

            while (it.hasNext()) {
                String method = (String) it.next();

                try {
                    SshAuthenticationClient auth = SshAuthenticationClientFactory.newInstance(method);
                } catch (AlgorithmNotSupportedException anse) {
                    JOptionPane.showMessageDialog(this,
                        method + " is not supported!");

                    return false;
View Full Code Here

            while (it.hasNext()) {
                String method = (String) it.next();

                try {
                    SshAuthenticationClient auth = SshAuthenticationClientFactory.newInstance(method);
                    auth.setUsername(jTextUsername.getText());
                    profile.addAuthenticationMethod(auth);
                } catch (AlgorithmNotSupportedException anse) {
                    log.error("This should have been caught by validateTab()?",
                        anse);
                }
View Full Code Here

        //Iterator it2 = null;
        java.util.List selected;

        // Loop until the user either cancels or completes
        boolean completed = false;
        SshAuthenticationClient auth;
        Map.Entry entry;
        String msg = null;

        while (!completed &&
                (ssh.getConnectionState().getValue() != TransportProtocolState.DISCONNECTED)) {
            auth = null;

            // Select an authentication method from the properties file or
            // prompt the user to choose
            if (it.hasNext()) {
                Object obj = it.next();

                if (obj instanceof Map.Entry) {
                    entry = (Map.Entry) obj;
                    auth = (SshAuthenticationClient) entry.getValue();
                } else if (obj instanceof String) {
                    auth = SshAuthenticationClientFactory.newInstance((String) obj);
                    auth.setUsername(getCurrentConnectionProfile().getUsername());
                } else {
                    closeConnection(true);
                    throw new IOException(
                        "Iterator of Map or List of String expected");
                }
            } else {
                selected = AuthenticationDialog.showAuthenticationDialog(this,
                        display, ((msg == null) ? "" : msg));

                if (selected.size() > 0) {
                    it = selected.iterator();
                } else {
                    closeConnection(true);

                    return false;
                }
            }

            if (auth != null) {
                // The password authentication client can act upon requests to change the password

                /* if (auth instanceof PasswordAuthenticationClient) {
PasswordAuthenticationDialog dialog = new PasswordAuthenticationDialog(SshTerminalPanel.this);
((PasswordAuthenticationClient) auth).setAuthenticationPrompt(dialog);
( (PasswordAuthenticationClient) auth)
.setPasswordChangePrompt(PasswordChange.getInstance());
PasswordChange.getInstance().setParentComponent(
SshTerminalPanel.this);
}*/

                // Show the implementations dialog
                // if(auth.showAuthenticationDialog()) {
                // Authentication with the details supplied
                result = showAuthenticationPrompt(auth); //ssh.authenticate(auth);

                if (result == AuthenticationProtocolState.FAILED) {
                    msg = auth.getMethodName() +
                        " authentication failed, try again?";
                }

                // If the result returned partial success then continue
                if (result == AuthenticationProtocolState.PARTIAL) {
                    // We succeeded so add to the connections authenticaiton
                    // list and continue on to the next one
                    getCurrentConnectionProfile().addAuthenticationMethod(auth);
                    msg = auth.getMethodName() +
                        " authentication succeeded but another is required";
                }

                if (result == AuthenticationProtocolState.COMPLETE) {
                    authenticated = true;
View Full Code Here

    /**
*
*/
    public void clearAuthenticationCache() {
        SshAuthenticationClient auth;
        Properties properties;

        for (Iterator it = authMethods.values().iterator(); it.hasNext();) {
            auth = (SshAuthenticationClient) it.next();
            properties = auth.getPersistableProperties();
            auth.reset();
            auth.setPersistableProperties(properties);
        }
    }
View Full Code Here

        while (it.hasNext()) {
            entry = (Map.Entry) it.next();
            xml += ("   <AuthenticationMethod Name=\"" + entry.getKey() +
            "\">\n");

            SshAuthenticationClient auth = (SshAuthenticationClient) entry.getValue();
            properties = auth.getPersistableProperties();

            Iterator it2 = properties.entrySet().iterator();

            while (it2.hasNext()) {
                entry = (Map.Entry) it2.next();
View Full Code Here

TOP

Related Classes of com.sshtools.j2ssh.authentication.SshAuthenticationClient

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.