Search in sources :

Example 6 with AuthenticationException

use of org.netbeans.lib.cvsclient.connection.AuthenticationException in project intellij-community by JetBrains.

the class SshPasswordAuthentication method authenticate.

public void authenticate(final Connection connection) throws AuthenticationException, SolveableAuthenticationException {
    final String password = myPasswordProvider.getPasswordForCvsRoot(myCvsRootAsString);
    if (password == null) {
        throw new SolveableAuthenticationException("Authentication rejected.");
    }
    try {
        final String[] methodsArr = connection.getRemainingAuthMethods(myLogin);
        if ((methodsArr == null) || (methodsArr.length == 0))
            return;
        final List<String> methods = Arrays.asList(methodsArr);
        if (methods.contains(PASSWORD_METHOD)) {
            if (connection.authenticateWithPassword(myLogin, password))
                return;
        }
        if (methods.contains(KEYBOARD_METHOD)) {
            final boolean wasAuthenticated = connection.authenticateWithKeyboardInteractive(myLogin, new InteractiveCallback() {

                public String[] replyToChallenge(String s, String instruction, int numPrompts, String[] strings, boolean[] booleans) throws Exception {
                    final String[] result = new String[numPrompts];
                    if (numPrompts > 0) {
                        Arrays.fill(result, password);
                    }
                    return result;
                }
            });
            if (wasAuthenticated)
                return;
        }
        throw new SolveableAuthenticationException("Authentication rejected.");
    } catch (IOException e) {
        throw new SolveableAuthenticationException(e.getMessage(), e);
    }
}
Also used : InteractiveCallback(com.trilead.ssh2.InteractiveCallback) IOException(java.io.IOException) IOException(java.io.IOException) AuthenticationException(org.netbeans.lib.cvsclient.connection.AuthenticationException)

Aggregations

AuthenticationException (org.netbeans.lib.cvsclient.connection.AuthenticationException)6 IOException (java.io.IOException)3 ReadWriteStatistics (com.intellij.cvsSupport2.javacvsImpl.io.ReadWriteStatistics)2 CvsResultEx (com.intellij.cvsSupport2.CvsResultEx)1 CvsEntriesManager (com.intellij.cvsSupport2.application.CvsEntriesManager)1 IgnoreFileFilterBasedOnCvsEntriesManager (com.intellij.cvsSupport2.cvsIgnore.IgnoreFileFilterBasedOnCvsEntriesManager)1 CvsExecutionEnvironment (com.intellij.cvsSupport2.cvsoperations.common.CvsExecutionEnvironment)1 GetModulesListOperation (com.intellij.cvsSupport2.cvsoperations.cvsContent.GetModulesListOperation)1 ErrorMessagesProcessor (com.intellij.cvsSupport2.cvsoperations.cvsErrors.ErrorMessagesProcessor)1 CvsMessagesListener (com.intellij.cvsSupport2.cvsoperations.cvsMessages.CvsMessagesListener)1 CvsMessagesTranslator (com.intellij.cvsSupport2.cvsoperations.cvsMessages.CvsMessagesTranslator)1 CvsException (com.intellij.cvsSupport2.errorHandling.CvsException)1 InputStreamWrapper (com.intellij.cvsSupport2.javacvsImpl.io.InputStreamWrapper)1 GeneralCommandLine (com.intellij.execution.configurations.GeneralCommandLine)1 Application (com.intellij.openapi.application.Application)1 CvsResult (com.intellij.openapi.cvsIntegration.CvsResult)1 ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)1 VcsException (com.intellij.openapi.vcs.VcsException)1 InteractiveCallback (com.trilead.ssh2.InteractiveCallback)1 ExecutionException (java.util.concurrent.ExecutionException)1