|
Lines 30-35
Link Here
|
| 30 |
* in a store, if none is provided the user is optionally prompted for the information. |
30 |
* in a store, if none is provided the user is optionally prompted for the information. |
| 31 |
*/ |
31 |
*/ |
| 32 |
public class Credentials { |
32 |
public class Credentials { |
|
|
33 |
public static class LoginCanceledException extends Exception { |
| 34 |
private static final long serialVersionUID = 1L; |
| 35 |
|
| 36 |
} |
| 37 |
|
| 33 |
private static final Map savedAuthInfo = Collections.synchronizedMap(new HashMap()); |
38 |
private static final Map savedAuthInfo = Collections.synchronizedMap(new HashMap()); |
| 34 |
|
39 |
|
| 35 |
/** |
40 |
/** |
|
Lines 48-54
Link Here
|
| 48 |
* @throws CoreException if the password cannot be read or saved |
53 |
* @throws CoreException if the password cannot be read or saved |
| 49 |
* @return The authentication info. |
54 |
* @return The authentication info. |
| 50 |
*/ |
55 |
*/ |
| 51 |
public static AuthenticationInfo forLocation(URI location, boolean prompt) throws UserCancelledException, CoreException { |
56 |
public static AuthenticationInfo forLocation(URI location, boolean prompt) throws LoginCanceledException, CoreException { |
| 52 |
return forLocation(location, prompt, null); |
57 |
return forLocation(location, prompt, null); |
| 53 |
} |
58 |
} |
| 54 |
|
59 |
|
|
Lines 70-76
Link Here
|
| 70 |
* @throws UserCancelledException - user canceled the prompt for name/password |
75 |
* @throws UserCancelledException - user canceled the prompt for name/password |
| 71 |
* @throws CoreException if there is an error |
76 |
* @throws CoreException if there is an error |
| 72 |
*/ |
77 |
*/ |
| 73 |
public static AuthenticationInfo forLocation(URI location, boolean prompt, AuthenticationInfo lastUsed) throws UserCancelledException, CoreException { |
78 |
public static AuthenticationInfo forLocation(URI location, boolean prompt, AuthenticationInfo lastUsed) throws LoginCanceledException, CoreException { |
| 74 |
ISecurePreferences securePreferences = SecurePreferencesFactory.getDefault(); |
79 |
ISecurePreferences securePreferences = SecurePreferencesFactory.getDefault(); |
| 75 |
|
80 |
|
| 76 |
// if URI is not opaque, just getting the host may be enough |
81 |
// if URI is not opaque, just getting the host may be enough |
|
Lines 137-143
Link Here
|
| 137 |
loginDetails = lastUsed != null ? adminUIService.getUsernamePassword(host, lastUsed) : adminUIService.getUsernamePassword(host); |
142 |
loginDetails = lastUsed != null ? adminUIService.getUsernamePassword(host, lastUsed) : adminUIService.getUsernamePassword(host); |
| 138 |
//null result means user canceled password dialog |
143 |
//null result means user canceled password dialog |
| 139 |
if (loginDetails == null) |
144 |
if (loginDetails == null) |
| 140 |
throw new UserCancelledException(); |
145 |
throw new LoginCanceledException(); |
| 141 |
//save user name and password if requested by user |
146 |
//save user name and password if requested by user |
| 142 |
if (loginDetails.saveResult()) { |
147 |
if (loginDetails.saveResult()) { |
| 143 |
if (prefNode == null) |
148 |
if (prefNode == null) |