Skip to content

Commit

Permalink
Fix default password pattern.
Browse files Browse the repository at this point in the history
  • Loading branch information
dkocher committed May 10, 2018
1 parent adde2d0 commit 7b8262f
Showing 1 changed file with 18 additions and 16 deletions.
@@ -1,19 +1,19 @@
package ch.cyberduck.core.sftp.auth;

/*
* Copyright (c) 2002-2017 iterate GmbH. All rights reserved.
* https://cyberduck.io/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
/*
* Copyright (c) 2002-2017 iterate GmbH. All rights reserved.
* https://cyberduck.io/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/

import ch.cyberduck.core.AuthenticationProvider;
import ch.cyberduck.core.BookmarkNameProvider;
Expand All @@ -38,15 +38,17 @@
import java.util.Collections;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.regex.Pattern;

import net.schmizz.sshj.userauth.method.AuthKeyboardInteractive;
import net.schmizz.sshj.userauth.method.ChallengeResponseProvider;
import net.schmizz.sshj.userauth.method.PasswordResponseProvider;
import net.schmizz.sshj.userauth.password.Resource;

public class SFTPChallengeResponseAuthentication implements AuthenticationProvider<Boolean> {
private static final Logger log = Logger.getLogger(SFTPChallengeResponseAuthentication.class);

private static final Pattern DEFAULT_PROMPT_PATTERN = Pattern.compile(".*[pP]assword\\s?\\z", Pattern.DOTALL);

private final SFTPSession session;

public SFTPChallengeResponseAuthentication(final SFTPSession session) {
Expand Down Expand Up @@ -86,7 +88,7 @@ public char[] getResponse(final String prompt, final boolean echo) {
if(log.isDebugEnabled()) {
log.debug(String.format("Reply to challenge name %s with instruction %s", name, instruction));
}
if(PasswordResponseProvider.DEFAULT_PROMPT_PATTERN.matcher(prompt).matches()) {
if(DEFAULT_PROMPT_PATTERN.matcher(prompt).matches()) {
if(StringUtils.isBlank(credentials.getPassword())) {
try {
final Credentials input = callback.prompt(bookmark, credentials.getUsername(),
Expand Down

0 comments on commit 7b8262f

Please sign in to comment.