Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
dkocher committed Nov 12, 2010
1 parent 697cb40 commit 6dfbf4f
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 10 deletions.
23 changes: 19 additions & 4 deletions source/ch/cyberduck/core/AbstractLoginController.java
Expand Up @@ -45,6 +45,18 @@ public void warn(String title, String message, String preference) throws LoginCa
public abstract void warn(String title, String message, String continueButton, String disconnectButton, String preference)
throws LoginCanceledException;

/**
* @param host
* @param title The title for the login prompt
* @param message
* @throws LoginCanceledException
*/
public void check(final Host host, String title, String message)
throws LoginCanceledException {
this.check(host, title, message, Preferences.instance().getBoolean("connection.login.useKeychain"),
host.getProtocol().equals(Protocol.SFTP), true);
}

/**
* Check the credentials for validity and prompt the user for the password if not found
* in the login keychain
Expand All @@ -53,7 +65,7 @@ public abstract void warn(String title, String message, String continueButton, S
* @param message Additional message displayed in the password prompt
* @throws LoginCanceledException
*/
public void check(final Host host, String title, String message)
public void check(final Host host, String title, String message, boolean enableKeychain, boolean enablePublicKey, boolean enableAnonymous)
throws LoginCanceledException {

final Credentials credentials = host.getCredentials();
Expand All @@ -74,7 +86,8 @@ public void check(final Host host, String title, String message)
else {
reason.append(Locale.localizedString(
"No login credentials could be found in the Keychain", "Credentials")).append(".");
this.prompt(host.getProtocol(), credentials, title, reason.toString());
this.prompt(host.getProtocol(), credentials, title, reason.toString(),
enableKeychain, enablePublicKey, enableAnonymous);
}
}
else {
Expand All @@ -86,14 +99,16 @@ public void check(final Host host, String title, String message)
else {
reason.append(Locale.localizedString(
"The use of the Keychain is disabled in the Preferences", "Credentials")).append(".");
this.prompt(host.getProtocol(), credentials, title, reason.toString());
this.prompt(host.getProtocol(), credentials, title, reason.toString(),
enableKeychain, enablePublicKey, enableAnonymous);
}
}
else {
reason.append(Locale.localizedString(
"No login credentials could be found in the Keychain", "Credentials")).append(".");
;
this.prompt(host.getProtocol(), credentials, title, reason.toString());
this.prompt(host.getProtocol(), credentials, title, reason.toString(),
enableKeychain, enablePublicKey, enableAnonymous);
}
}
}
Expand Down
24 changes: 18 additions & 6 deletions source/ch/cyberduck/core/LoginController.java
Expand Up @@ -35,11 +35,11 @@ public interface LoginController {
/**
* Display warning sheet. Block connection until decision is made.
*
* @param title Title in alert window
* @param message Message in alert window
* @param continueButton Button title for default button
* @param disconnectButton Button title for other button
* @param preference Where to save preference if dismissed
* @param title Title in alert window
* @param message Message in alert window
* @param continueButton Button title for default button
* @param disconnectButton Button title for other button
* @param preference Where to save preference if dismissed
* @throws LoginCanceledException If the other option has been selected.
*/
void warn(String title, String message, String continueButton, String disconnectButton, String preference) throws LoginCanceledException;
Expand All @@ -55,6 +55,18 @@ public interface LoginController {
*/
void check(Host host, String title, String reason) throws LoginCanceledException;

/**
* Check the credentials for validity and prompt the user for the password if not found
* in the login keychain
*
* @param host
* @param title The title for the login prompt
* @param enableKeychain Enable checkbox to save password in keychain
* @param enablePublicKey Enable public key authentication checkbox
* @param enableAnonymous Enable anynomous login option checkbox
*/
void check(final Host host, String title, String message, boolean enableKeychain, boolean enablePublicKey, boolean enableAnonymous) throws LoginCanceledException;

/**
* Call this to allow the user to reenter the new login credentials.
* A concrete subclass should display a login prompt.
Expand Down Expand Up @@ -103,7 +115,7 @@ public interface LoginController {
* @param reason The detail message for the login prompt. Any additional information why the login failed.
* @param enableKeychain Enable checkbox to save password in keychain
* @param enablePublicKey Enable public key authentication checkbox
* @param enableAnonymous
* @param enableAnonymous Enable anynomous login option checkbox
* @throws LoginCanceledException
*/
void prompt(final Protocol protocol, final Credentials credentials,
Expand Down

0 comments on commit 6dfbf4f

Please sign in to comment.