Changeset 5434 in josm
- Timestamp:
- 2012-08-12T04:03:42+02:00 (12 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/JosmUserIdentityManager.java
r5266 r5434 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.awt.Component; 6 7 import java.text.MessageFormat; 7 8 … … 11 12 import org.openstreetmap.josm.data.Preferences.StringSetting; 12 13 import org.openstreetmap.josm.data.osm.UserInfo; 14 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; 15 import org.openstreetmap.josm.io.OsmServerUserInfoReader; 16 import org.openstreetmap.josm.io.OsmTransferException; 13 17 import org.openstreetmap.josm.io.auth.CredentialsManager; 14 18 import org.openstreetmap.josm.tools.CheckParameterUtil; … … 34 38 * of what the current JOSM instance knows about the current user. Other subsystems can 35 39 * let the global JosmUserStateManager know in case they fully identify the current user, see 36 * {@link #setFullyIdentified (String, long)}.40 * {@link #setFullyIdentified}. 37 41 * 38 42 * The information kept by the JosmUserStateManager can be used to 39 43 * <ul> 40 44 * <li>safely query changesets owned by the current user based on its user id, not on its user name</li> 41 * <li>safely search for objects last touched by the current user 45 * <li>safely search for objects last touched by the current user based on its user id, not on its user name</li> 42 46 * </ul> 43 47 * … … 166 170 return userInfo; 167 171 } 168 /** 169 * Initializes the user identity manager from values in the {@link org.openstreetmap.josm.data.Preferences} 172 173 /** 174 * Initializes the user identity manager from Basic Authentication values in the {@link org.openstreetmap.josm.data.Preferences} 175 * This method should be called if {@code osm-server.auth-method} is set to {@code basic}. 176 * @see #initFromOAuth 170 177 */ 171 178 public void initFromPreferences() { … … 182 189 // keep the state, be it partially or fully identified 183 190 } 191 } 192 } 193 194 /** 195 * Initializes the user identity manager from OAuth request of user details. 196 * This method should be called if {@code osm-server.auth-method} is set to {@code oauth}. 197 * @param parent component relative to which the {@link PleaseWaitDialog} is displayed. 198 * @see #initFromPreferences 199 * @since 5434 200 */ 201 public void initFromOAuth(Component parent) { 202 try { 203 UserInfo info = new OsmServerUserInfoReader().fetchUserInfo(NullProgressMonitor.INSTANCE); 204 setFullyIdentified(info.getDisplayName(), info); 205 } catch (IllegalArgumentException e) { 206 e.printStackTrace(); 207 } catch (OsmTransferException e) { 208 e.printStackTrace(); 184 209 } 185 210 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetCacheManager.java
r4864 r5434 532 532 public void actionPerformed(ActionEvent arg0) { 533 533 JosmUserIdentityManager im = JosmUserIdentityManager.getInstance(); 534 im.initFromPreferences(); 535 if (im.isAnonymous()) { 536 alertAnonymousUser(); 537 return; 534 if (Main.pref.get("osm-server.auth-method").equals("oauth")) { 535 im.initFromOAuth(ChangesetCacheManager.this); 536 } else { 537 im.initFromPreferences(); 538 if (im.isAnonymous()) { 539 alertAnonymousUser(); 540 return; 541 } 538 542 } 539 543 ChangesetQuery query = new ChangesetQuery(); -
trunk/src/org/openstreetmap/josm/io/OsmServerUserInfoReader.java
r3083 r5434 97 97 98 98 // -- language list 99 NodeList xmlNodeList = (NodeList)xpath.compile("/osm/user[1]/languages[1]/lang ").evaluate(document, XPathConstants.NODESET);99 NodeList xmlNodeList = (NodeList)xpath.compile("/osm/user[1]/languages[1]/lang/text()").evaluate(document, XPathConstants.NODESET); 100 100 if (xmlNodeList != null) { 101 101 List<String> languages = new LinkedList<String>();
Note:
See TracChangeset
for help on using the changeset viewer.