Changeset 5692 in josm for trunk/src/org/openstreetmap/josm/io/auth/AbstractCredentialsAgent.java
- Timestamp:
- 2013-01-30T02:25:13+01:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/auth/AbstractCredentialsAgent.java
r4826 r5692 8 8 9 9 import org.openstreetmap.josm.gui.io.CredentialDialog; 10 import org.openstreetmap.josm.gui.util.GuiHelper; 10 11 11 12 abstract public class AbstractCredentialsAgent implements CredentialsAgent { … … 14 15 15 16 /** 16 * @see CredentialsAgent#getCredentials(RequestorType, boolean)17 * @see CredentialsAgent#getCredentials(RequestorType, String, boolean) 17 18 */ 18 19 @Override 19 public CredentialsAgentResponse getCredentials( RequestorType requestorType,String host, boolean noSuccessWithLastResponse) throws CredentialsAgentException{20 public CredentialsAgentResponse getCredentials(final RequestorType requestorType, final String host, boolean noSuccessWithLastResponse) throws CredentialsAgentException{ 20 21 if (requestorType == null) 21 22 return null; 22 23 PasswordAuthentication credentials = lookup(requestorType, host); 23 String username = (credentials == null || credentials.getUserName() == null) ? "" : credentials.getUserName();24 String password = (credentials == null || credentials.getPassword() == null) ? "" : String.valueOf(credentials.getPassword());24 final String username = (credentials == null || credentials.getUserName() == null) ? "" : credentials.getUserName(); 25 final String password = (credentials == null || credentials.getPassword() == null) ? "" : String.valueOf(credentials.getPassword()); 25 26 26 CredentialsAgentResponse response = new CredentialsAgentResponse();27 final CredentialsAgentResponse response = new CredentialsAgentResponse(); 27 28 28 29 /* … … 45 46 */ 46 47 } else if (noSuccessWithLastResponse || username.equals("") || password.equals("")) { 47 CredentialDialog dialog = null; 48 switch(requestorType) { 49 case SERVER: dialog = CredentialDialog.getOsmApiCredentialDialog(username, password, host, getSaveUsernameAndPasswordCheckboxText()); break; 50 case PROXY: dialog = CredentialDialog.getHttpProxyCredentialDialog(username, password, host, getSaveUsernameAndPasswordCheckboxText()); break; 48 GuiHelper.runInEDTAndWait(new Runnable() { 49 @Override 50 public void run() { 51 CredentialDialog dialog = null; 52 switch(requestorType) { 53 case SERVER: dialog = CredentialDialog.getOsmApiCredentialDialog(username, password, host, getSaveUsernameAndPasswordCheckboxText()); break; 54 case PROXY: dialog = CredentialDialog.getHttpProxyCredentialDialog(username, password, host, getSaveUsernameAndPasswordCheckboxText()); break; 55 } 56 dialog.setVisible(true); 57 response.setCanceled(dialog.isCanceled()); 58 if (dialog.isCanceled()) 59 return; 60 response.setUsername(dialog.getUsername()); 61 response.setPassword(dialog.getPassword()); 62 response.setSaveCredentials(dialog.isSaveCredentials()); 63 } 64 }); 65 if (response.isCanceled()) { 66 return response; 51 67 } 52 dialog.setVisible(true); 53 response.setCanceled(dialog.isCanceled()); 54 if (dialog.isCanceled()) 55 return response; 56 response.setUsername(dialog.getUsername()); 57 response.setPassword(dialog.getPassword()); 58 if (dialog.isSaveCredentials()) { 68 if (response.isSaveCredentials()) { 59 69 store(requestorType, host, new PasswordAuthentication( 60 70 response.getUsername(), … … 66 76 */ 67 77 } else { 68 PasswordAuthentication pa = new PasswordAuthentication( dialog.getUsername(), dialog.getPassword());78 PasswordAuthentication pa = new PasswordAuthentication(response.getUsername(), response.getPassword()); 69 79 memoryCredentialsCache.put(requestorType, pa); 70 80 }
Note:
See TracChangeset
for help on using the changeset viewer.