Changeset 4690 in josm for trunk/src/org/openstreetmap/josm/io/auth/CredentialsManager.java
- Timestamp:
- 2011-12-21T23:12:59+01:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/auth/CredentialsManager.java
r4264 r4690 8 8 import org.openstreetmap.josm.data.oauth.OAuthToken; 9 9 import org.openstreetmap.josm.gui.JosmUserIdentityManager; 10 import org.openstreetmap.josm.io.OsmApi; 10 11 import org.openstreetmap.josm.tools.Utils; 11 12 … … 66 67 67 68 public String getUsername() { 69 return getUsername(OsmApi.getOsmApi().getHost()); 70 } 71 72 public String getUsername(String host) { 68 73 String username = null; 69 74 try { 70 PasswordAuthentication auth = lookup(RequestorType.SERVER );75 PasswordAuthentication auth = lookup(RequestorType.SERVER, host); 71 76 if (auth != null) { 72 77 username = auth.getUserName(); … … 81 86 82 87 @Override 83 public PasswordAuthentication lookup(RequestorType requestorType ) throws CredentialsAgentException {84 return delegate.lookup(requestorType );88 public PasswordAuthentication lookup(RequestorType requestorType, String host) throws CredentialsAgentException { 89 return delegate.lookup(requestorType, host); 85 90 } 86 91 87 92 @Override 88 public void store(RequestorType requestorType, PasswordAuthentication credentials) throws CredentialsAgentException { 89 if (requestorType == RequestorType.SERVER && credentials.getUserName() != null && !credentials.getUserName().trim().isEmpty()) { 90 JosmUserIdentityManager.getInstance().setPartiallyIdentified(credentials.getUserName()); 93 public void store(RequestorType requestorType, String host, PasswordAuthentication credentials) throws CredentialsAgentException { 94 if (requestorType == RequestorType.SERVER && OsmApi.getOsmApi().getHost().equals(host)) { 95 String username = credentials.getUserName(); 96 if(username != null && !username.trim().isEmpty()) { 97 JosmUserIdentityManager.getInstance().setPartiallyIdentified(username); 98 } 91 99 } 92 delegate.store(requestorType, credentials);100 delegate.store(requestorType, host, credentials); 93 101 } 94 102 95 103 @Override 96 public CredentialsAgentResponse getCredentials(RequestorType requestorType, boolean noSuccessWithLastResponse) throws CredentialsAgentException {97 return delegate.getCredentials(requestorType, noSuccessWithLastResponse);104 public CredentialsAgentResponse getCredentials(RequestorType requestorType, String host, boolean noSuccessWithLastResponse) throws CredentialsAgentException { 105 return delegate.getCredentials(requestorType, host, noSuccessWithLastResponse); 98 106 } 99 107
Note:
See TracChangeset
for help on using the changeset viewer.