Changeset 8510 in josm for trunk/src/org/openstreetmap/josm/gui/oauth
- Timestamp:
- 2015-06-20T23:42:21+02:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/oauth
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/oauth/AccessTokenInfoPanel.java
r6890 r8510 34 34 gc.fill = GridBagConstraints.HORIZONTAL; 35 35 gc.weightx = 0.0; 36 gc.insets = new Insets(0, 0,3,3);36 gc.insets = new Insets(0, 0, 3, 3); 37 37 add(new JLabel(tr("Access Token Key:")), gc); 38 38 … … 46 46 gc.gridy = 1; 47 47 gc.weightx = 0.0; 48 gc.insets = new Insets(0, 0,3,3);48 gc.insets = new Insets(0, 0, 3, 3); 49 49 add(new JLabel(tr("Access Token Secret:")), gc); 50 50 -
trunk/src/org/openstreetmap/josm/gui/oauth/AdvancedOAuthPropertiesPanel.java
r8444 r8510 53 53 protected final void build() { 54 54 setLayout(new GridBagLayout()); 55 setBorder(BorderFactory.createEmptyBorder(3, 3,3,3));55 setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3)); 56 56 GridBagConstraints gc = new GridBagConstraints(); 57 57 … … 59 59 gc.fill = GridBagConstraints.HORIZONTAL; 60 60 gc.weightx = 1.0; 61 gc.insets = new Insets(0, 0, 3, 3);61 gc.insets = new Insets(0, 0, 3, 3); 62 62 gc.gridwidth = 2; 63 63 cbUseDefaults = new JCheckBox(tr("Use default settings")); … … 177 177 } 178 178 179 protected void setChildComponentsEnabled(boolean enabled) {179 protected void setChildComponentsEnabled(boolean enabled) { 180 180 for (Component c: getComponents()) { 181 181 if (c instanceof JosmTextField || c instanceof JLabel) { -
trunk/src/org/openstreetmap/josm/gui/oauth/FullyAutomaticAuthorizationUI.java
r8509 r8510 86 86 VerticallyScrollablePanel pnl = new VerticallyScrollablePanel(new GridBagLayout()); 87 87 GridBagConstraints gc = new GridBagConstraints(); 88 pnl.setBorder(BorderFactory.createEmptyBorder(5, 5,5,5));88 pnl.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); 89 89 90 90 gc.anchor = GridBagConstraints.NORTHWEST; … … 93 93 gc.gridwidth = 2; 94 94 HtmlPanel pnlMessage = new HtmlPanel(); 95 HTMLEditorKit kit = (HTMLEditorKit) pnlMessage.getEditorPane().getEditorKit();95 HTMLEditorKit kit = (HTMLEditorKit) pnlMessage.getEditorPane().getEditorKit(); 96 96 kit.getStyleSheet().addRule( 97 ".warning-body {background-color:rgb(253,255,221);padding: 10pt; border-color:rgb(128,128,128);border-style: solid;border-width: 1px;}"); 97 ".warning-body {background-color:rgb(253,255,221);padding: 10pt; " + 98 "border-color:rgb(128,128,128);border-style: solid;border-width: 1px;}"); 98 99 kit.getStyleSheet().addRule("ol {margin-left: 1cm}"); 99 100 pnlMessage.setText("<html><body><p class=\"warning-body\">" … … 111 112 gc.fill = GridBagConstraints.HORIZONTAL; 112 113 gc.weightx = 0.0; 113 gc.insets = new Insets(0, 0,3,3);114 gc.insets = new Insets(0, 0, 3, 3); 114 115 pnl.add(new JLabel(tr("Username: ")), gc); 115 116 … … 143 144 gc.gridwidth = 2; 144 145 pnlMessage = new HtmlPanel(); 145 kit = (HTMLEditorKit) pnlMessage.getEditorPane().getEditorKit();146 kit = (HTMLEditorKit) pnlMessage.getEditorPane().getEditorKit(); 146 147 kit.getStyleSheet().addRule( 147 ".warning-body {background-color:rgb(253,255,221);padding: 10pt; border-color:rgb(128,128,128);border-style: solid;border-width: 1px;}"); 148 ".warning-body {background-color:rgb(253,255,221);padding: 10pt; " + 149 "border-color:rgb(128,128,128);border-style: solid;border-width: 1px;}"); 148 150 kit.getStyleSheet().addRule("ol {margin-left: 1cm}"); 149 151 pnlMessage.setText("<html><body>" … … 197 199 tfPassword.setText(pa.getPassword() == null ? "" : String.valueOf(pa.getPassword())); 198 200 } 199 } catch (CredentialsAgentException e) {201 } catch (CredentialsAgentException e) { 200 202 Main.error(e); 201 203 tfUserName.setText(""); … … 212 214 JPanel pnl = new JPanel(new FlowLayout(FlowLayout.LEFT)); 213 215 214 RunAuthorisationAction runAuthorisationAction = new RunAuthorisationAction();216 RunAuthorisationAction runAuthorisationAction = new RunAuthorisationAction(); 215 217 tfPassword.getDocument().addDocumentListener(runAuthorisationAction); 216 218 tfUserName.getDocument().addDocumentListener(runAuthorisationAction); … … 227 229 JPanel pnl = new JPanel(new GridBagLayout()); 228 230 GridBagConstraints gc = new GridBagConstraints(); 229 pnl.setBorder(BorderFactory.createEmptyBorder(5, 5,5,5));231 pnl.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); 230 232 231 233 // the message panel … … 240 242 + "Click on <strong>{0}</strong> to accept the token. JOSM will use it in " 241 243 + "subsequent requests to gain access to the OSM API." 242 + "</html>", lbl));244 + "</html>", lbl)); 243 245 pnl.add(msg, gc); 244 246 245 247 // infos about the access token 246 248 gc.gridy = 1; 247 gc.insets = new Insets(5, 0,0,0);249 gc.insets = new Insets(5, 0, 0, 0); 248 250 pnl.add(pnlAccessTokenInfo = new AccessTokenInfoPanel(), gc); 249 251 … … 495 497 try { 496 498 loginUrl = authClient.buildOsmLoginUrl(); 497 } catch (OsmOAuthAuthorizationException e1) {499 } catch (OsmOAuthAuthorizationException e1) { 498 500 alertInvalidLoginUrl(); 499 501 return; … … 520 522 public void run() { 521 523 if (e instanceof OsmLoginFailedException) { 522 alertLoginFailed((OsmLoginFailedException) e);524 alertLoginFailed((OsmLoginFailedException) e); 523 525 } else { 524 526 alertAuthorisationFailed(e); … … 541 543 ); 542 544 getProgressMonitor().worked(1); 543 if (canceled) return;545 if (canceled) return; 544 546 authClient.authorise( 545 547 requestToken, … … 550 552 ); 551 553 getProgressMonitor().worked(1); 552 if (canceled) return;554 if (canceled) return; 553 555 final OAuthToken accessToken = authClient.getAccessToken( 554 getProgressMonitor().createSubTaskMonitor(1, false)556 getProgressMonitor().createSubTaskMonitor(1, false) 555 557 ); 556 558 getProgressMonitor().worked(1); 557 if (canceled) return;559 if (canceled) return; 558 560 GuiHelper.runInEDT(new Runnable() { 559 561 @Override … … 563 565 } 564 566 }); 565 } catch (final OsmOAuthAuthorizationException e) {567 } catch (final OsmOAuthAuthorizationException e) { 566 568 handleException(e); 567 569 } -
trunk/src/org/openstreetmap/josm/gui/oauth/FullyAutomaticPropertiesPanel.java
r8461 r8510 30 30 gc.fill = GridBagConstraints.HORIZONTAL; 31 31 gc.weightx = 0.0; 32 gc.insets = new Insets(0, 0,3,3);32 gc.insets = new Insets(0, 0, 3, 3); 33 33 pnl.add(new JLabel(tr("Username: ")), gc); 34 34 … … 61 61 setLayout(new GridBagLayout()); 62 62 GridBagConstraints gc = new GridBagConstraints(); 63 setBorder(BorderFactory.createEmptyBorder(3, 3,3,3));63 setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3)); 64 64 65 65 gc.anchor = GridBagConstraints.NORTHWEST; -
trunk/src/org/openstreetmap/josm/gui/oauth/ManualAuthorizationUI.java
r8444 r8510 50 50 protected JPanel buildAccessTokenPanel() { 51 51 JPanel pnl = new JPanel(new GridBagLayout()); 52 pnl.setBorder(BorderFactory.createEmptyBorder(5, 5,5,5));52 pnl.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); 53 53 GridBagConstraints gc = new GridBagConstraints(); 54 54 AccessTokenBuilder accessTokenBuilder = new AccessTokenBuilder(); … … 59 59 gc.weightx = 0.0; 60 60 gc.gridwidth = 2; 61 gc.insets = new Insets(0, 0,5,0);61 gc.insets = new Insets(0, 0, 5, 0); 62 62 pnlMessage = new HtmlPanel(); 63 63 pnlMessage.setText("<html><body>" … … 71 71 gc.weightx = 0.0; 72 72 gc.gridwidth = 1; 73 gc.insets = new Insets(0, 0,0,3);73 gc.insets = new Insets(0, 0, 0, 3); 74 74 pnl.add(new JLabel(tr("Access Token Key:")), gc); 75 75 … … 99 99 gc.gridy = 3; 100 100 gc.gridx = 0; 101 gc.gridwidth = 2;101 gc.gridwidth = 2; 102 102 gc.weightx = 1.0; 103 103 pnl.add(cbSaveToPreferences = new JCheckBox(tr("Save Access Token in preferences")), gc); … … 107 107 gc.gridy = 3; 108 108 gc.gridx = 0; 109 gc.gridwidth = 2;109 gc.gridwidth = 2; 110 110 gc.weightx = 1.0; 111 111 gc.weighty = 1.0; … … 155 155 protected final void build() { 156 156 setLayout(new BorderLayout()); 157 setBorder(BorderFactory.createEmptyBorder(5, 5,5,5));157 setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); 158 158 add(buildTabbedPreferencesPanel(), BorderLayout.CENTER); 159 159 add(buildActionsPanel(), BorderLayout.SOUTH); … … 225 225 } 226 226 } 227 227 228 @Override 228 229 public void changedUpdate(DocumentEvent e) { -
trunk/src/org/openstreetmap/josm/gui/oauth/OAuthAuthorizationWizard.java
r8468 r8510 71 71 * @return panel with buttons 72 72 */ 73 protected JPanel buildButtonRow() {73 protected JPanel buildButtonRow() { 74 74 JPanel pnl = new JPanel(new FlowLayout(FlowLayout.CENTER)); 75 75 … … 93 93 protected JPanel buildHeaderInfoPanel() { 94 94 JPanel pnl = new JPanel(new GridBagLayout()); 95 pnl.setBorder(BorderFactory.createEmptyBorder(5, 5,5,5));95 pnl.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); 96 96 GridBagConstraints gc = new GridBagConstraints(); 97 97 … … 109 109 // OAuth in a nutshell ... 110 110 gc.gridy = 1; 111 gc.insets = new Insets(5, 0,0,5);111 gc.insets = new Insets(5, 0, 0, 5); 112 112 HtmlPanel pnlMessage = new HtmlPanel(); 113 113 pnlMessage.setText("<html><body>" … … 125 125 lbl = new JLabel(tr("Please select an authorization procedure: ")); 126 126 lbl.setFont(lbl.getFont().deriveFont(Font.PLAIN)); 127 pnl.add(lbl, gc);127 pnl.add(lbl, gc); 128 128 129 129 gc.gridx = 1; 130 130 gc.gridwidth = 1; 131 131 gc.weightx = 1.0; 132 pnl.add(cbAuthorisationProcedure = new AuthorizationProcedureComboBox(), gc);132 pnl.add(cbAuthorisationProcedure = new AuthorizationProcedureComboBox(), gc); 133 133 cbAuthorisationProcedure.addItemListener(new AuthorisationProcedureChangeListener()); 134 134 lbl.setLabelFor(cbAuthorisationProcedure); … … 141 141 */ 142 142 protected void refreshAuthorisationProcedurePanel() { 143 AuthorizationProcedure procedure = (AuthorizationProcedure) cbAuthorisationProcedure.getSelectedItem();143 AuthorizationProcedure procedure = (AuthorizationProcedure) cbAuthorisationProcedure.getSelectedItem(); 144 144 switch(procedure) { 145 145 case FULLY_AUTOMATIC: … … 189 189 @Override 190 190 public void componentResized(ComponentEvent e) {} 191 191 192 @Override 192 193 public void componentMoved(ComponentEvent e) {} … … 239 240 240 241 protected AbstractAuthorizationUI getCurrentAuthorisationUI() { 241 switch((AuthorizationProcedure) cbAuthorisationProcedure.getSelectedItem()) {242 switch((AuthorizationProcedure) cbAuthorisationProcedure.getSelectedItem()) { 242 243 case FULLY_AUTOMATIC: return pnlFullyAutomaticAuthorisationUI; 243 244 case MANUALLY: return pnlManualAuthorisationUI; … … 296 297 WindowGeometry.centerInWindow( 297 298 Main.parent, 298 new Dimension(450, 540)299 new Dimension(450, 540) 299 300 ) 300 301 ).applySafe(this); … … 365 366 if (!evt.getPropertyName().equals(AbstractAuthorizationUI.ACCESS_TOKEN_PROP)) 366 367 return; 367 updateEnabledState((OAuthToken) evt.getNewValue());368 updateEnabledState((OAuthToken) evt.getNewValue()); 368 369 } 369 370 } -
trunk/src/org/openstreetmap/josm/gui/oauth/OsmLoginFailedException.java
r3408 r8510 2 2 package org.openstreetmap.josm.gui.oauth; 3 3 4 public class OsmLoginFailedException extends OsmOAuthAuthorizationException {4 public class OsmLoginFailedException extends OsmOAuthAuthorizationException { 5 5 6 6 public OsmLoginFailedException() { -
trunk/src/org/openstreetmap/josm/gui/oauth/OsmOAuthAuthorizationClient.java
r8509 r8510 99 99 */ 100 100 public void cancel() { 101 DefaultOAuthProvider p = (DefaultOAuthProvider) provider;101 DefaultOAuthProvider p = (DefaultOAuthProvider) provider; 102 102 canceled = true; 103 103 if (p != null) { … … 105 105 Field f = p.getClass().getDeclaredField("connection"); 106 106 f.setAccessible(true); 107 HttpURLConnection con = (HttpURLConnection) f.get(p);107 HttpURLConnection con = (HttpURLConnection) f.get(p); 108 108 if (con != null) { 109 109 con.disconnect(); … … 114 114 } 115 115 } 116 synchronized (this) {116 synchronized (this) { 117 117 if (connection != null) { 118 118 connection.disconnect(); … … 139 139 provider.retrieveRequestToken(consumer, ""); 140 140 return OAuthToken.createToken(consumer); 141 } catch (OAuthException e){141 } catch (OAuthException e) { 142 142 if (canceled) 143 143 throw new OsmTransferCanceledException(e); … … 169 169 provider.retrieveAccessToken(consumer, null); 170 170 return OAuthToken.createToken(consumer); 171 } catch (OAuthException e){171 } catch (OAuthException e) { 172 172 if (canceled) 173 173 throw new OsmTransferCanceledException(e); … … 235 235 // osm session cookie found 236 236 String token = extractToken(connection); 237 if (token == null)237 if (token == null) 238 238 return null; 239 239 SessionId si = new SessionId(); … … 247 247 } 248 248 249 protected String buildPostRequest(Map<String, String> parameters) throws OsmOAuthAuthorizationException {249 protected String buildPostRequest(Map<String, String> parameters) throws OsmOAuthAuthorizationException { 250 250 StringBuilder sb = new StringBuilder(32); 251 251 252 for (Iterator<Entry<String,String>> it = parameters.entrySet().iterator(); it.hasNext();) {253 Entry<String, String> entry = it.next();252 for (Iterator<Entry<String, String>> it = parameters.entrySet().iterator(); it.hasNext();) { 253 Entry<String, String> entry = it.next(); 254 254 String value = entry.getValue(); 255 255 value = (value == null) ? "" : value; … … 269 269 * URLs are malformed 270 270 */ 271 public String buildOsmLoginUrl() throws OsmOAuthAuthorizationException {271 public String buildOsmLoginUrl() throws OsmOAuthAuthorizationException { 272 272 try { 273 273 URL autUrl = new URL(oauthProviderParameters.getAuthoriseUrl()); 274 274 URL url = new URL(Main.pref.get("oauth.protocol", "https"), autUrl.getHost(), autUrl.getPort(), "/login"); 275 275 return url.toString(); 276 } catch (MalformedURLException e) {276 } catch (MalformedURLException e) { 277 277 throw new OsmOAuthAuthorizationException(e); 278 278 } … … 286 286 * URLs are malformed 287 287 */ 288 protected String buildOsmLogoutUrl() throws OsmOAuthAuthorizationException {288 protected String buildOsmLogoutUrl() throws OsmOAuthAuthorizationException { 289 289 try { 290 290 URL autUrl = new URL(oauthProviderParameters.getAuthoriseUrl()); 291 291 URL url = new URL("http", autUrl.getHost(), autUrl.getPort(), "/logout"); 292 292 return url.toString(); 293 } catch (MalformedURLException e) {293 } catch (MalformedURLException e) { 294 294 throw new OsmOAuthAuthorizationException(e); 295 295 } … … 308 308 sb.append(buildOsmLoginUrl()).append("?cookie_test=true"); 309 309 URL url = new URL(sb.toString()); 310 synchronized (this) {310 synchronized (this) { 311 311 connection = Utils.openHttpConnection(url); 312 312 } … … 319 319 throw new OsmOAuthAuthorizationException(tr("OSM website did not return a session cookie in response to ''{0}'',", url.toString())); 320 320 return sessionId; 321 } catch (IOException e) {322 throw new OsmOAuthAuthorizationException(e); 323 } finally { 324 synchronized (this) {321 } catch (IOException e) { 322 throw new OsmOAuthAuthorizationException(e); 323 } finally { 324 synchronized (this) { 325 325 connection = null; 326 326 } … … 337 337 try { 338 338 URL url = new URL(getAuthoriseUrl(requestToken)); 339 synchronized (this) {339 synchronized (this) { 340 340 connection = Utils.openHttpConnection(url); 341 341 } … … 348 348 if (sessionId.token == null) 349 349 throw new OsmOAuthAuthorizationException(tr("OSM website did not return a session cookie in response to ''{0}'',", url.toString())); 350 } catch (IOException e) {351 throw new OsmOAuthAuthorizationException(e); 352 } finally { 353 synchronized (this) {350 } catch (IOException e) { 351 throw new OsmOAuthAuthorizationException(e); 352 } finally { 353 synchronized (this) { 354 354 connection = null; 355 355 } … … 360 360 try { 361 361 URL url = new URL(buildOsmLoginUrl()); 362 synchronized (this) {362 synchronized (this) { 363 363 connection = Utils.openHttpConnection(url); 364 364 } … … 368 368 connection.setUseCaches(false); 369 369 370 Map<String, String> parameters = new HashMap<>();370 Map<String, String> parameters = new HashMap<>(); 371 371 parameters.put("username", userName); 372 372 parameters.put("password", password); … … 397 397 if (retCode != HttpURLConnection.HTTP_MOVED_TEMP) 398 398 throw new OsmOAuthAuthorizationException(tr("Failed to authenticate user ''{0}'' with password ''***'' as OAuth user", userName)); 399 } catch (OsmOAuthAuthorizationException e) {399 } catch (OsmOAuthAuthorizationException e) { 400 400 throw new OsmLoginFailedException(e.getCause()); 401 } catch (IOException e) {401 } catch (IOException e) { 402 402 throw new OsmLoginFailedException(e); 403 403 } finally { 404 synchronized (this) {404 synchronized (this) { 405 405 connection = null; 406 406 } … … 411 411 try { 412 412 URL url = new URL(buildOsmLogoutUrl()); 413 synchronized (this) {413 synchronized (this) { 414 414 connection = Utils.openHttpConnection(url); 415 415 } … … 418 418 connection.setDoOutput(false); 419 419 connection.connect(); 420 } catch (IOException e) {420 } catch (IOException e) { 421 421 throw new OsmOAuthAuthorizationException(e); 422 422 } finally { 423 synchronized (this) {423 synchronized (this) { 424 424 connection = null; 425 425 } … … 458 458 try { 459 459 URL url = new URL(oauthProviderParameters.getAuthoriseUrl()); 460 synchronized (this) {460 synchronized (this) { 461 461 connection = Utils.openHttpConnection(url); 462 462 } … … 483 483 throw new OsmOAuthAuthorizationException(e); 484 484 } finally { 485 synchronized (this) {485 synchronized (this) { 486 486 connection = null; 487 487 } … … 541 541 throw new OsmTransferCanceledException("Authorization canceled"); 542 542 monitor.worked(1); 543 } catch (OsmOAuthAuthorizationException e) {543 } catch (OsmOAuthAuthorizationException e) { 544 544 if (canceled) 545 545 throw new OsmTransferCanceledException(e); -
trunk/src/org/openstreetmap/josm/gui/oauth/OsmPrivilegesPanel.java
r6890 r8510 27 27 setLayout(new GridBagLayout()); 28 28 GridBagConstraints gc = new GridBagConstraints(); 29 setBorder(BorderFactory.createEmptyBorder(5, 5,5,5));29 setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); 30 30 31 31 // checkbox for "allow to upload map data" … … 34 34 gc.fill = GridBagConstraints.HORIZONTAL; 35 35 gc.weightx = 1.0; 36 gc.insets = new Insets(0, 0,3,3);36 gc.insets = new Insets(0, 0, 3, 3); 37 37 add(cbWriteApi = new JCheckBox(), gc); 38 38 cbWriteApi.setText(tr("Allow to upload map data")); -
trunk/src/org/openstreetmap/josm/gui/oauth/RetrieveAccessTokenTask.java
r8291 r8510 55 55 protected void cancel() { 56 56 canceled = true; 57 synchronized (this) {57 synchronized (this) { 58 58 if (client != null) { 59 59 client.cancel(); … … 81 81 protected void realRun() throws SAXException, IOException, OsmTransferException { 82 82 try { 83 synchronized (this) {83 synchronized (this) { 84 84 client = new OsmOAuthAuthorizationClient(parameters, requestToken); 85 85 } 86 86 accessToken = client.getAccessToken(getProgressMonitor().createSubTaskMonitor(0, false)); 87 } catch (OsmTransferCanceledException e) {87 } catch (OsmTransferCanceledException e) { 88 88 return; 89 89 } catch (OsmOAuthAuthorizationException e) { … … 92 92 accessToken = null; 93 93 } finally { 94 synchronized (this) {94 synchronized (this) { 95 95 client = null; 96 96 } -
trunk/src/org/openstreetmap/josm/gui/oauth/RetrieveRequestTokenTask.java
r8444 r8510 49 49 protected void cancel() { 50 50 canceled = true; 51 synchronized (this) {51 synchronized (this) { 52 52 if (client != null) { 53 53 client.cancel(); … … 75 75 protected void realRun() throws SAXException, IOException, OsmTransferException { 76 76 try { 77 synchronized (this) {77 synchronized (this) { 78 78 client = new OsmOAuthAuthorizationClient(parameters); 79 79 } 80 80 requestToken = client.getRequestToken(getProgressMonitor().createSubTaskMonitor(0, false)); 81 } catch (OsmTransferCanceledException e) {81 } catch (OsmTransferCanceledException e) { 82 82 return; 83 83 } catch (OsmOAuthAuthorizationException e) { … … 86 86 requestToken = null; 87 87 } finally { 88 synchronized (this) {88 synchronized (this) { 89 89 client = null; 90 90 } -
trunk/src/org/openstreetmap/josm/gui/oauth/SemiAutomaticAuthorizationUI.java
r8468 r8510 53 53 protected final void build() { 54 54 setLayout(new BorderLayout()); 55 setBorder(BorderFactory.createEmptyBorder(5, 5,5,5));55 setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); 56 56 pnlRetrieveRequestToken = new RetrieveRequestTokenPanel(); 57 57 pnlRetrieveAccessToken = new RetrieveAccessTokenPanel(); … … 123 123 protected JPanel buildAdvancedParametersPanel() { 124 124 JPanel pnl = new JPanel(new GridBagLayout()); 125 GridBagConstraints gc = new GridBagConstraints();125 GridBagConstraints gc = new GridBagConstraints(); 126 126 127 127 gc.anchor = GridBagConstraints.NORTHWEST; 128 128 gc.fill = GridBagConstraints.HORIZONTAL; 129 129 gc.weightx = 0.0; 130 gc.insets = new Insets(0, 0,0,3);130 gc.insets = new Insets(0, 0, 0, 3); 131 131 JCheckBox cbShowAdvancedParameters = new JCheckBox(); 132 132 pnl.add(cbShowAdvancedParameters, gc); … … 149 149 gc.gridy = 1; 150 150 gc.gridx = 1; 151 gc.insets = new Insets(3, 0,3,0);151 gc.insets = new Insets(3, 0, 3, 0); 152 152 gc.fill = GridBagConstraints.BOTH; 153 153 gc.weightx = 1.0; … … 157 157 BorderFactory.createCompoundBorder( 158 158 BorderFactory.createLineBorder(Color.GRAY, 1), 159 BorderFactory.createEmptyBorder(3, 3,3,3)159 BorderFactory.createEmptyBorder(3, 3, 3, 3) 160 160 ) 161 161 ); … … 166 166 protected JPanel buildCommandPanel() { 167 167 JPanel pnl = new JPanel(new GridBagLayout()); 168 GridBagConstraints gc = new GridBagConstraints();168 GridBagConstraints gc = new GridBagConstraints(); 169 169 170 170 gc.anchor = GridBagConstraints.NORTHWEST; … … 172 172 gc.weightx = 1.0; 173 173 gc.weighty = 1.0; 174 gc.insets = new Insets(0, 0,0,3);174 gc.insets = new Insets(0, 0, 0, 3); 175 175 176 176 … … 193 193 194 194 } 195 195 196 protected final void build() { 196 setLayout(new BorderLayout(0, 5));197 setLayout(new BorderLayout(0, 5)); 197 198 JLabel lbl = new JLabel(tr("<html>Step 1/3: Retrieve an OAuth Request Token</html>")); 198 199 lbl.setFont(lbl.getFont().deriveFont(16f)); … … 229 230 GridBagConstraints gc = new GridBagConstraints(); 230 231 231 gc.anchor = GridBagConstraints.NORTHWEST;232 gc.anchor = GridBagConstraints.NORTHWEST; 232 233 gc.fill = GridBagConstraints.HORIZONTAL; 233 234 gc.weightx = 1.0; … … 320 321 GridBagConstraints gc = new GridBagConstraints(); 321 322 322 gc.anchor = GridBagConstraints.NORTHWEST;323 gc.anchor = GridBagConstraints.NORTHWEST; 323 324 gc.fill = GridBagConstraints.HORIZONTAL; 324 325 gc.weightx = 1.0; -
trunk/src/org/openstreetmap/josm/gui/oauth/TestAccessTokenTask.java
r8509 r8510 70 70 protected void cancel() { 71 71 canceled = true; 72 synchronized (this) {72 synchronized (this) { 73 73 if (connection != null) { 74 74 connection.disconnect(); … … 80 80 protected void finish() {} 81 81 82 protected void sign(HttpURLConnection con) throws OAuthException {82 protected void sign(HttpURLConnection con) throws OAuthException { 83 83 OAuthConsumer consumer = oauthParameters.buildConsumer(); 84 84 consumer.setTokenWithSecret(token.getKey(), token.getSecret()); … … 91 91 92 92 // remove trailing slashes 93 while (url.endsWith("/")) {93 while (url.endsWith("/")) { 94 94 url = url.substring(0, url.lastIndexOf('/')); 95 95 } … … 103 103 authenticatorEnabled = DefaultAuthenticator.getInstance().isEnabled(); 104 104 DefaultAuthenticator.getInstance().setEnabled(false); 105 synchronized (this) {105 synchronized (this) { 106 106 connection = Utils.openHttpConnection(url); 107 107 } … … 121 121 122 122 if (connection.getResponseCode() != HttpURLConnection.HTTP_OK) 123 throw new OsmApiException(connection.getResponseCode(), connection.getHeaderField("Error"), null);123 throw new OsmApiException(connection.getResponseCode(), connection.getHeaderField("Error"), null); 124 124 Document d = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(connection.getInputStream()); 125 125 return OsmServerUserInfoReader.buildFromXML(d); 126 } catch (SAXException | ParserConfigurationException e) {126 } catch (SAXException | ParserConfigurationException e) { 127 127 throw new XmlParsingException(e); 128 } catch (IOException e) {128 } catch (IOException e) { 129 129 throw new OsmTransferException(e); 130 } catch (OAuthException e) {130 } catch (OAuthException e) { 131 131 throw new OsmOAuthAuthorizationException(e); 132 132 } finally { … … 249 249 if (canceled) return; 250 250 notifySuccess(userInfo); 251 } catch(OsmOAuthAuthorizationException e) {251 } catch (OsmOAuthAuthorizationException e) { 252 252 if (canceled) return; 253 253 Main.error(e); 254 254 alertFailedSigning(); 255 } catch (OsmApiException e) {255 } catch (OsmApiException e) { 256 256 if (canceled) return; 257 257 Main.error(e); … … 267 267 } 268 268 alertFailedConnection(); 269 } catch (OsmTransferException e) {269 } catch (OsmTransferException e) { 270 270 if (canceled) return; 271 271 Main.error(e);
Note:
See TracChangeset
for help on using the changeset viewer.