Skip to content

Commit faeb99c

Browse files
authored
Merge pull request #17275 from iterate-ch/bugfix/MD-23962
Save passwords regardless of missing username.
2 parents c600be0 + 85b2a10 commit faeb99c

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

core/src/main/java/ch/cyberduck/core/DefaultHostPasswordStore.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ public String findLoginPassword(final Host bookmark) {
4949
final String password;
5050
try {
5151
password = this.getPassword(bookmark.getProtocol().getScheme(), bookmark.getPort(),
52-
bookmark.getHostname(), credentials.getUsername());
52+
bookmark.getHostname(), StringUtils.isEmpty(credentials.getUsername()) ?
53+
bookmark.getProtocol().getPasswordPlaceholder() :
54+
String.format("%s (%s)", bookmark.getProtocol().getPasswordPlaceholder(), credentials.getUsername()));
5355
}
5456
catch(LocalAccessDeniedException e) {
5557
log.warn("Failure {} searching in keychain", e.getMessage());
@@ -74,7 +76,8 @@ public String findLoginToken(final Host bookmark) {
7476
try {
7577
token = this.getPassword(bookmark.getProtocol().getScheme(), bookmark.getPort(),
7678
bookmark.getHostname(), StringUtils.isEmpty(credentials.getUsername()) ?
77-
bookmark.getProtocol().getTokenPlaceholder() : String.format("%s (%s)", bookmark.getProtocol().getTokenPlaceholder(), credentials.getUsername()));
79+
bookmark.getProtocol().getTokenPlaceholder() :
80+
String.format("%s (%s)", bookmark.getProtocol().getTokenPlaceholder(), credentials.getUsername()));
7881
}
7982
catch(LocalAccessDeniedException e) {
8083
log.warn("Failure {} searching in keychain", e.getMessage());
@@ -218,12 +221,9 @@ public void save(final Host bookmark) throws LocalAccessDeniedException {
218221
log.warn("No username in credentials for bookmark {}", bookmark.getHostname());
219222
return;
220223
}
221-
if(StringUtils.isEmpty(credentials.getPassword())) {
222-
log.warn("No password in credentials for bookmark {}", bookmark.getHostname());
223-
return;
224-
}
225224
this.addPassword(protocol.getScheme(), bookmark.getPort(),
226-
bookmark.getHostname(), credentials.getUsername(), credentials.getPassword());
225+
bookmark.getHostname(), StringUtils.isEmpty(credentials.getUsername()) ?
226+
protocol.getPasswordPlaceholder() : String.format("%s (%s)", protocol.getPasswordPlaceholder(), credentials.getUsername()), credentials.getPassword());
227227
}
228228
if(credentials.isTokenAuthentication()) {
229229
this.addPassword(protocol.getScheme(), bookmark.getPort(),

0 commit comments

Comments
 (0)