Changeset 19660 in josm
- Timestamp:
- 2026-10-23T23:18:23+02:00 (5 hours ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/oauth/TestAccessTokenTask.java
r19651 r19660 7 7 import java.io.IOException; 8 8 import java.net.HttpURLConnection; 9 import java.net.URI; 9 10 import java.net.URL; 10 11 … … 86 87 boolean authenticatorEnabled = true; 87 88 try { 88 URL url = new URL(apiUrl + "/0.6/user/details");89 final URL url = URI.create(apiUrl + "/0.6/user/details").toURL(); 89 90 authenticatorEnabled = DefaultAuthenticator.getInstance().isEnabled(); 90 91 DefaultAuthenticator.getInstance().setEnabled(false); … … 98 99 99 100 final String oauthKey = getAuthKey(); 100 if (connection.getResponse().getResponseCode() == HttpURLConnection.HTTP_UNAUTHORIZED) 101 if (connection.getResponse().getResponseCode() == HttpURLConnection.HTTP_UNAUTHORIZED) { 101 102 throw new OsmApiException(HttpURLConnection.HTTP_UNAUTHORIZED, 102 103 tr("Retrieving user details with Access Token Key ''{0}'' was rejected.", 103 104 oauthKey), null); 104 105 if (connection.getResponse().getResponseCode() == HttpURLConnection.HTTP_FORBIDDEN) 105 } 106 107 if (connection.getResponse().getResponseCode() == HttpURLConnection.HTTP_FORBIDDEN) { 106 108 throw new OsmApiException(HttpURLConnection.HTTP_FORBIDDEN, 107 109 tr("Retrieving user details with Access Token Key ''{0}'' was forbidden.", oauthKey), null); 108 109 if (connection.getResponse().getResponseCode() != HttpURLConnection.HTTP_OK) 110 } 111 112 if (connection.getResponse().getResponseCode() != HttpURLConnection.HTTP_OK) { 110 113 throw new OsmApiException(connection.getResponse().getResponseCode(), 111 114 connection.getResponse().getHeaderField("Error"), null); 112 Document d = XmlUtils.parseSafeDOM(connection.getResponse().getContent()); 115 } 116 final Document d = XmlUtils.parseSafeDOM(connection.getResponse().getContent()); 113 117 return OsmServerUserInfoReader.buildFromXML(d); 114 118 } catch (SAXException | ParserConfigurationException e) { … … 234 238 try { 235 239 getProgressMonitor().indeterminateSubTask(tr("Retrieving user info...")); 236 UserInfo userInfo = getUserDetails(); 237 if (canceled) return; 240 final UserInfo userInfo = getUserDetails(); 241 if (canceled) { 242 return; 243 } 238 244 notifySuccess(userInfo); 239 245 } catch (OsmOAuthAuthorizationException e) { 240 if (canceled) return; 246 if (canceled) { 247 return; 248 } 241 249 Logging.error(e); 242 250 alertFailedSigning(); 243 251 } catch (OsmApiException e) { 244 if (canceled) return; 252 if (canceled) { 253 return; 254 } 245 255 Logging.error(e); 246 256 if (e.getResponseCode() == HttpURLConnection.HTTP_INTERNAL_ERROR) { … … 256 266 alertFailedConnection(); 257 267 } catch (OsmTransferException e) { 258 if (canceled) return; 268 if (canceled) { 269 return; 270 } 259 271 Logging.error(e); 260 272 alertFailedConnection();
Note:
See TracChangeset
for help on using the changeset viewer.
