Changeset 5587 in josm for trunk/src/org/openstreetmap/josm/gui/oauth
- Timestamp:
- 2012-11-18T00:44:10+01:00 (12 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/oauth
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/oauth/OsmOAuthAuthorizationClient.java
r5422 r5587 30 30 31 31 import org.openstreetmap.josm.Main; 32 import org.openstreetmap.josm.data.Version;33 32 import org.openstreetmap.josm.data.oauth.OAuthParameters; 34 33 import org.openstreetmap.josm.data.oauth.OAuthToken; … … 38 37 import org.openstreetmap.josm.io.OsmTransferCanceledException; 39 38 import org.openstreetmap.josm.tools.CheckParameterUtil; 39 import org.openstreetmap.josm.tools.Utils; 40 40 41 41 /** … … 325 325 URL url = new URL(sb.toString()); 326 326 synchronized(this) { 327 connection = (HttpURLConnection)url.openConnection();327 connection = Utils.openHttpConnection(url); 328 328 } 329 329 connection.setRequestMethod("GET"); 330 330 connection.setDoInput(true); 331 331 connection.setDoOutput(false); 332 setHttpRequestParameters(connection);333 332 connection.connect(); 334 333 SessionId sessionId = extractOsmSession(connection); … … 355 354 URL url = new URL(getAuthoriseUrl(requestToken)); 356 355 synchronized(this) { 357 connection = (HttpURLConnection)url.openConnection();356 connection = Utils.openHttpConnection(url); 358 357 } 359 358 connection.setRequestMethod("GET"); … … 361 360 connection.setDoOutput(false); 362 361 connection.setRequestProperty("Cookie", "_osm_session=" + sessionId.id + "; _osm_username=" + sessionId.userName); 363 setHttpRequestParameters(connection);364 362 connection.connect(); 365 363 sessionId.token = extractToken(connection); … … 380 378 URL url = new URL(buildOsmLoginUrl()); 381 379 synchronized(this) { 382 connection = (HttpURLConnection)url.openConnection();380 connection = Utils.openHttpConnection(url); 383 381 } 384 382 connection.setRequestMethod("POST"); … … 401 399 // make sure we can catch 302 Moved Temporarily below 402 400 connection.setInstanceFollowRedirects(false); 403 setHttpRequestParameters(connection);404 401 405 402 connection.connect(); … … 437 434 URL url = new URL(buildOsmLogoutUrl()); 438 435 synchronized(this) { 439 connection = (HttpURLConnection)url.openConnection();436 connection = Utils.openHttpConnection(url); 440 437 } 441 438 connection.setRequestMethod("GET"); 442 439 connection.setDoInput(true); 443 440 connection.setDoOutput(false); 444 setHttpRequestParameters(connection);445 441 connection.connect(); 446 } catch(MalformedURLException e) {442 } catch(MalformedURLException e) { 447 443 throw new OsmOAuthAuthorizationException(e); 448 444 } catch(IOException e) { … … 484 480 URL url = new URL(oauthProviderParameters.getAuthoriseUrl()); 485 481 synchronized(this) { 486 connection = (HttpURLConnection)url.openConnection();482 connection = Utils.openHttpConnection(url); 487 483 } 488 484 connection.setRequestMethod("POST"); … … 494 490 connection.setRequestProperty("Cookie", "_osm_session=" + sessionId.id + "; _osm_username=" + sessionId.userName); 495 491 connection.setInstanceFollowRedirects(false); 496 setHttpRequestParameters(connection);497 492 498 493 connection.connect(); … … 520 515 } 521 516 } 522 }523 524 protected void setHttpRequestParameters(HttpURLConnection connection) {525 connection.setRequestProperty("User-Agent", Version.getInstance().getAgentString());526 connection.setRequestProperty("Host", connection.getURL().getHost());527 517 } 528 518 -
trunk/src/org/openstreetmap/josm/gui/oauth/TestAccessTokenTask.java
r5411 r5587 17 17 import oauth.signpost.exception.OAuthException; 18 18 19 import org.openstreetmap.josm.data.Version;20 19 import org.openstreetmap.josm.data.oauth.OAuthParameters; 21 20 import org.openstreetmap.josm.data.oauth.OAuthToken; … … 30 29 import org.openstreetmap.josm.io.auth.DefaultAuthenticator; 31 30 import org.openstreetmap.josm.tools.CheckParameterUtil; 31 import org.openstreetmap.josm.tools.Utils; 32 32 import org.w3c.dom.Document; 33 33 import org.xml.sax.SAXException; … … 104 104 DefaultAuthenticator.getInstance().setEnabled(false); 105 105 synchronized(this) { 106 connection = (HttpURLConnection)url.openConnection();106 connection = Utils.openHttpConnection(url); 107 107 } 108 108 109 109 connection.setDoOutput(true); 110 110 connection.setRequestMethod("GET"); 111 connection.setRequestProperty("User-Agent", Version.getInstance().getAgentString());112 connection.setRequestProperty("Host", connection.getURL().getHost());113 111 sign(connection); 114 112 connection.connect();
Note:
See TracChangeset
for help on using the changeset viewer.