Cyberduck Mountain Duck CLI

Changeset 43470


Ignore:
Timestamp:
Nov 27, 2017 8:46:26 AM (7 months ago)
Author:
dkocher
Message:

Fix #10148. SFTP agent auth requires no password and no private key selection

Location:
shelves/11.2017
Files:
3 edited
1 copied

Legend:

Unmodified
Added
Removed
  • shelves/11.2017/core/src/main/java/ch/cyberduck/core/Protocol.java

    r43460 r43470  
    8080                    case ftp:
    8181                        return Objects.nonNull(credentials.getPassword());
     82                    case sftp:
     83                        // SFTP agent auth requires no password and no private key selection
     84                        return true;
    8285                    default:
    8386                        return StringUtils.isNotBlank(credentials.getPassword());
  • shelves/11.2017/ssh/src/main/java/ch/cyberduck/core/sftp/auth/SFTPChallengeResponseAuthentication.java

    r43439 r43470  
    1717
    1818import ch.cyberduck.core.AuthenticationProvider;
     19import ch.cyberduck.core.BookmarkNameProvider;
    1920import ch.cyberduck.core.Credentials;
    2021import ch.cyberduck.core.Host;
     
    3435
    3536import java.io.IOException;
     37import java.text.MessageFormat;
    3638import java.util.Collections;
    3739import java.util.List;
     
    8587                    if(!StringUtils.isBlank(bookmark.getCredentials().getPassword())
    8688                        && PasswordResponseProvider.DEFAULT_PROMPT_PATTERN.matcher(prompt).matches()) {
     89                        if(StringUtils.isBlank(bookmark.getCredentials().getPassword())) {
     90                            try {
     91                                bookmark.getCredentials().setPassword(callback.prompt(bookmark, bookmark.getCredentials().getUsername(),
     92                                    String.format("%s %s", LocaleFactory.localizedString("Login", "Login"), bookmark.getHostname()),
     93                                    MessageFormat.format(LocaleFactory.localizedString(
     94                                        "Login {0} with username and password", "Credentials"), BookmarkNameProvider.toString(bookmark)),
     95                                    new LoginOptions(bookmark.getProtocol()).publickey(false)
     96                                        .usernamePlaceholder(bookmark.getCredentials().getUsername())).getPassword());
     97                            }
     98                            catch(LoginCanceledException e) {
     99                                canceled.set(true);
     100                                // Return null if user cancels
     101                                return null;
     102                            }
     103                        }
    87104                        return bookmark.getCredentials().getPassword().toCharArray();
    88105                    }
  • shelves/11.2017/ssh/src/main/java/ch/cyberduck/core/sftp/auth/SFTPPasswordAuthentication.java

    r43439 r43470  
    1717
    1818import ch.cyberduck.core.AuthenticationProvider;
     19import ch.cyberduck.core.BookmarkNameProvider;
    1920import ch.cyberduck.core.Credentials;
    2021import ch.cyberduck.core.Host;
     
    3132import ch.cyberduck.core.threading.CancelCallback;
    3233
     34import org.apache.commons.lang3.StringUtils;
    3335import org.apache.log4j.Logger;
    3436
    3537import java.io.IOException;
     38import java.text.MessageFormat;
    3639
    3740import net.schmizz.sshj.userauth.method.AuthPassword;
     
    5255    public Boolean authenticate(final Host bookmark, final HostPasswordStore keychain, final LoginCallback callback, final CancelCallback cancel)
    5356        throws BackgroundException {
    54         if(bookmark.getCredentials().isPasswordAuthentication()) {
    55             return this.authenticate(bookmark, bookmark.getCredentials(), callback, cancel);
     57        if(StringUtils.isBlank(bookmark.getCredentials().getPassword())) {
     58            bookmark.getCredentials().setPassword(callback.prompt(bookmark, bookmark.getCredentials().getUsername(),
     59                String.format("%s %s", LocaleFactory.localizedString("Login", "Login"), bookmark.getHostname()),
     60                MessageFormat.format(LocaleFactory.localizedString(
     61                    "Login {0} with username and password", "Credentials"), BookmarkNameProvider.toString(bookmark)),
     62                new LoginOptions(bookmark.getProtocol()).publickey(false)
     63                    .usernamePlaceholder(bookmark.getCredentials().getUsername())).getPassword());
    5664        }
    57         return false;
     65        return this.authenticate(bookmark, bookmark.getCredentials(), callback, cancel);
    5866    }
    5967
Note: See TracChangeset for help on using the changeset viewer.
swiss made software