Changeset 5422 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2012-08-11T17:37:00+02:00 (12 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/AbstractInfoAction.java
r5360 r5422 18 18 import org.openstreetmap.josm.gui.HelpAwareOptionPane.ButtonSpec; 19 19 import org.openstreetmap.josm.gui.help.HelpUtil; 20 import org.openstreetmap.josm.io.OsmApi; 20 21 import org.openstreetmap.josm.tools.ImageProvider; 21 22 import org.openstreetmap.josm.tools.OpenBrowser; … … 38 39 */ 39 40 static public String getBaseBrowseUrl() { 40 String baseUrl = Main.pref.get("osm-server.url", "http://api.openstreetmap.org/api");41 String baseUrl = Main.pref.get("osm-server.url", OsmApi.DEFAULT_API_URL); 41 42 Pattern pattern = Pattern.compile("/api/?$"); 42 43 String ret = pattern.matcher(baseUrl).replaceAll("/browse"); … … 57 58 */ 58 59 static public String getBaseUserUrl() { 59 String baseUrl = Main.pref.get("osm-server.url", "http://api.openstreetmap.org/api");60 String baseUrl = Main.pref.get("osm-server.url", OsmApi.DEFAULT_API_URL); 60 61 Pattern pattern = Pattern.compile("/api/?$"); 61 62 String ret = pattern.matcher(baseUrl).replaceAll("/user"); -
trunk/src/org/openstreetmap/josm/data/oauth/OAuthParameters.java
r5266 r5422 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.data.oauth; 3 4 import java.net.MalformedURLException; 5 import java.net.URL; 3 6 4 7 import oauth.signpost.OAuthConsumer; … … 8 11 9 12 import org.openstreetmap.josm.data.Preferences; 13 import org.openstreetmap.josm.io.OsmApi; 10 14 import org.openstreetmap.josm.tools.CheckParameterUtil; 11 15 12 16 /** 13 17 * This class manages a set of OAuth parameters. 14 * 18 * @since 2747 15 19 */ 16 20 public class OAuthParameters { 17 21 22 /** 23 * The default JOSM OAuth consumer key. 24 */ 18 25 static public final String DEFAULT_JOSM_CONSUMER_KEY = "AdCRxTpvnbmfV8aPqrTLyA"; 26 /** 27 * The default JOSM OAuth consumer secret. 28 */ 19 29 static public final String DEFAULT_JOSM_CONSUMER_SECRET = "XmYOiGY9hApytcBC3xCec3e28QBqOWz5g6DSb5UpE"; 30 /** 31 * The default OSM OAuth request token URL. 32 */ 20 33 static public final String DEFAULT_REQUEST_TOKEN_URL = "http://www.openstreetmap.org/oauth/request_token"; 34 /** 35 * The default OSM OAuth access token URL. 36 */ 21 37 static public final String DEFAULT_ACCESS_TOKEN_URL = "http://www.openstreetmap.org/oauth/access_token"; 38 /** 39 * The default OSM OAuth authorize URL. 40 */ 22 41 static public final String DEFAULT_AUTHORISE_URL = "http://www.openstreetmap.org/oauth/authorize"; 23 42 … … 25 44 /** 26 45 * Replies a set of default parameters for a consumer accessing the standard OSM server 27 * at http://api.openstreetmap.org/api46 * at {@link OsmApi#DEFAULT_API_URL}. 28 47 * 29 48 * @return a set of default parameters 30 49 */ 31 50 static public OAuthParameters createDefault() { 51 return createDefault(null); 52 } 53 54 /** 55 * Replies a set of default parameters for a consumer accessing an OSM server 56 * at the given API url. URL parameters are only set if the URL equals {@link OsmApi#DEFAULT_API_URL} 57 * or references the domain "dev.openstreetmap.org", otherwise they may be <code>null</code>. 58 * 59 * @param apiUrl The API URL for which the OAuth default parameters are created. If null or empty, the default OSM API url is used. 60 * @return a set of default parameters for the given {@code apiUrl} 61 * @since 5422 62 */ 63 static public OAuthParameters createDefault(String apiUrl) { 32 64 OAuthParameters parameters = new OAuthParameters(); 33 65 parameters.setConsumerKey(DEFAULT_JOSM_CONSUMER_KEY); 34 66 parameters.setConsumerSecret(DEFAULT_JOSM_CONSUMER_SECRET); 35 parameters.setRequestTokenUrl(DEFAULT_REQUEST_TOKEN_URL); 36 parameters.setAccessTokenUrl(DEFAULT_ACCESS_TOKEN_URL); 37 parameters.setAuthoriseUrl(DEFAULT_AUTHORISE_URL); 67 if (apiUrl == null || apiUrl.isEmpty() || apiUrl.equals(OsmApi.DEFAULT_API_URL)) { 68 parameters.setRequestTokenUrl(DEFAULT_REQUEST_TOKEN_URL); 69 parameters.setAccessTokenUrl(DEFAULT_ACCESS_TOKEN_URL); 70 parameters.setAuthoriseUrl(DEFAULT_AUTHORISE_URL); 71 } else { 72 try { 73 String host = new URL(apiUrl).getHost(); 74 if (host.endsWith("dev.openstreetmap.org")) { 75 parameters.setRequestTokenUrl(DEFAULT_REQUEST_TOKEN_URL.replace("www.openstreetmap.org", host)); 76 parameters.setAccessTokenUrl(DEFAULT_ACCESS_TOKEN_URL.replace("www.openstreetmap.org", host)); 77 parameters.setAuthoriseUrl(DEFAULT_AUTHORISE_URL.replace("www.openstreetmap.org", host)); 78 } 79 } catch (MalformedURLException e) { 80 // Ignored 81 } 82 } 38 83 return parameters; 39 84 } … … 48 93 boolean useDefault = pref.getBoolean("oauth.settings.use-default", true ); 49 94 if (useDefault) 50 return createDefault( );95 return createDefault(pref.get("osm-server.url")); 51 96 OAuthParameters parameters = new OAuthParameters(); 52 97 parameters.setConsumerKey(pref.get("oauth.settings.consumer-key", "")); … … 78 123 private String authoriseUrl; 79 124 125 /** 126 * Constructs a new, unitialized, {@code OAuthParameters}. 127 * 128 * @see #createDefault 129 * @see #createFromPreferences 130 */ 80 131 public OAuthParameters() { 81 132 } … … 96 147 } 97 148 149 /** 150 * Gets the consumer key. 151 * @return The consumer key 152 */ 98 153 public String getConsumerKey() { 99 154 return consumerKey; 100 155 } 156 157 /** 158 * Sets the consumer key. 159 * @param consumerKey The consumer key 160 */ 101 161 public void setConsumerKey(String consumerKey) { 102 162 this.consumerKey = consumerKey; 103 163 } 164 165 /** 166 * Gets the consumer secret. 167 * @return The consumer secret 168 */ 104 169 public String getConsumerSecret() { 105 170 return consumerSecret; 106 171 } 172 173 /** 174 * Sets the consumer secret. 175 * @param consumerSecret The consumer secret 176 */ 107 177 public void setConsumerSecret(String consumerSecret) { 108 178 this.consumerSecret = consumerSecret; 109 179 } 180 181 /** 182 * Gets the request token URL. 183 * @return The request token URL 184 */ 110 185 public String getRequestTokenUrl() { 111 186 return requestTokenUrl; 112 187 } 188 189 /** 190 * Sets the request token URL. 191 * @param requestTokenUrl the request token URL 192 */ 113 193 public void setRequestTokenUrl(String requestTokenUrl) { 114 194 this.requestTokenUrl = requestTokenUrl; 115 195 } 196 197 /** 198 * Gets the access token URL. 199 * @return The access token URL 200 */ 116 201 public String getAccessTokenUrl() { 117 202 return accessTokenUrl; 118 203 } 204 205 /** 206 * Sets the access token URL. 207 * @param accessTokenUrl The access token URL 208 */ 119 209 public void setAccessTokenUrl(String accessTokenUrl) { 120 210 this.accessTokenUrl = accessTokenUrl; 121 211 } 212 213 /** 214 * Gets the authorise URL. 215 * @return The authorise URL 216 */ 122 217 public String getAuthoriseUrl() { 123 218 return authoriseUrl; 124 219 } 220 221 /** 222 * Sets the authorise URL. 223 * @param authoriseUrl The authorise URL 224 */ 125 225 public void setAuthoriseUrl(String authoriseUrl) { 126 226 this.authoriseUrl = authoriseUrl; … … 128 228 129 229 /** 130 * Builds an {@link OAuthConsumer} based on these parameters 230 * Builds an {@link OAuthConsumer} based on these parameters. 131 231 * 132 232 * @return the consumer 133 233 */ 134 234 public OAuthConsumer buildConsumer() { 135 OAuthConsumer consumer = new DefaultOAuthConsumer(consumerKey, consumerSecret); 136 return consumer; 235 return new DefaultOAuthConsumer(consumerKey, consumerSecret); 137 236 } 138 237 … … 142 241 * @param consumer the consumer. Must not be null. 143 242 * @return the provider 144 * @throws IllegalArgumentException thrownif consumer is null243 * @throws IllegalArgumentException if consumer is null 145 244 */ 146 245 public OAuthProvider buildProvider(OAuthConsumer consumer) throws IllegalArgumentException { … … 153 252 } 154 253 254 /** 255 * Saves these OAuth parameters to the given {@code Preferences}. 256 * @param pref The Preferences into which are saved these OAuth parameters with the prefix "oauth.settings" 257 */ 155 258 public void saveToPreferences(Preferences pref) { 156 if (this.equals(createDefault( ))) {259 if (this.equals(createDefault(pref.get("osm-server.url")))) { 157 260 pref.put("oauth.settings.use-default", true ); 158 261 clearPreferences(pref); -
trunk/src/org/openstreetmap/josm/gui/oauth/AbstractAuthorizationUI.java
r5266 r5422 11 11 * This is the abstract base class for the three authorisation UIs. 12 12 * 13 * 13 * @since 2746 14 14 */ 15 public abstract class AbstractAuthorizationUI extends VerticallyScrollablePanel {15 public abstract class AbstractAuthorizationUI extends VerticallyScrollablePanel { 16 16 /** 17 17 * The property name for the Access Token property … … 20 20 21 21 private String apiUrl; 22 private AdvancedOAuthPropertiesPanel pnlAdvancedProperties;22 private final AdvancedOAuthPropertiesPanel pnlAdvancedProperties; 23 23 private OAuthToken accessToken; 24 24 … … 27 27 } 28 28 29 public AbstractAuthorizationUI() { 29 /** 30 * Constructs a new {@code AbstractAuthorizationUI} for the given API URL. 31 * @param apiUrl The OSM API URL 32 * @since 5422 33 */ 34 public AbstractAuthorizationUI(String apiUrl) { 30 35 pnlAdvancedProperties = new AdvancedOAuthPropertiesPanel(); 36 setApiUrl(apiUrl); 31 37 } 32 38 … … 49 55 public void setApiUrl(String apiUrl) { 50 56 this.apiUrl = apiUrl; 57 this.pnlAdvancedProperties.setApiUrl(apiUrl); 51 58 } 52 59 -
trunk/src/org/openstreetmap/josm/gui/oauth/AdvancedOAuthPropertiesPanel.java
r3530 r5422 27 27 import org.openstreetmap.josm.tools.ImageProvider; 28 28 29 /** 30 * Panel allowing the user to setup advanced OAuth parameters: 31 * <li>Consumer key</li> 32 * <li>Consumer secret</li> 33 * <li>Request token URL</li> 34 * <li>Access token URL</li> 35 * <li>Authorize URL</li> 36 * 37 * @see OAuthParameters 38 * @since 2746 39 */ 29 40 public class AdvancedOAuthPropertiesPanel extends VerticallyScrollablePanel { 30 41 … … 36 47 private JTextField tfAuthoriseURL; 37 48 private UseDefaultItemListener ilUseDefault; 49 private String apiUrl; 38 50 39 51 protected void build() { … … 110 122 111 123 protected boolean hasCustomSettings() { 124 OAuthParameters params = OAuthParameters.createDefault(apiUrl); 112 125 return 113 ! tfConsumerKey.getText().equals( OAuthParameters.DEFAULT_JOSM_CONSUMER_KEY)114 || ! tfConsumerSecret.getText().equals( OAuthParameters.DEFAULT_JOSM_CONSUMER_SECRET)115 || ! tfRequestTokenURL.getText().equals( OAuthParameters.DEFAULT_REQUEST_TOKEN_URL)116 || ! tfAccessTokenURL.getText().equals( OAuthParameters.DEFAULT_ACCESS_TOKEN_URL)117 || ! tfAuthoriseURL.getText().equals( OAuthParameters.DEFAULT_AUTHORISE_URL);126 ! tfConsumerKey.getText().equals(params.getConsumerKey()) 127 || ! tfConsumerSecret.getText().equals(params.getConsumerSecret()) 128 || ! tfRequestTokenURL.getText().equals(params.getRequestTokenUrl()) 129 || ! tfAccessTokenURL.getText().equals(params.getAccessTokenUrl()) 130 || ! tfAuthoriseURL.getText().equals(params.getAuthoriseUrl()); 118 131 } 119 132 … … 152 165 protected void resetToDefaultSettings() { 153 166 cbUseDefaults.setSelected(true); 154 tfConsumerKey.setText( OAuthParameters.DEFAULT_JOSM_CONSUMER_KEY); 155 tfConsumerSecret.setText( OAuthParameters.DEFAULT_JOSM_CONSUMER_SECRET); 156 tfRequestTokenURL.setText(OAuthParameters.DEFAULT_REQUEST_TOKEN_URL); 157 tfAccessTokenURL.setText(OAuthParameters.DEFAULT_ACCESS_TOKEN_URL); 158 tfAuthoriseURL.setText(OAuthParameters.DEFAULT_AUTHORISE_URL); 167 OAuthParameters params = OAuthParameters.createDefault(apiUrl); 168 tfConsumerKey.setText(params.getConsumerKey()); 169 tfConsumerSecret.setText(params.getConsumerSecret()); 170 tfRequestTokenURL.setText(params.getRequestTokenUrl()); 171 tfAccessTokenURL.setText(params.getAccessTokenUrl()); 172 tfAuthoriseURL.setText(params.getAuthoriseUrl()); 159 173 160 174 setChildComponentsEnabled(false); … … 176 190 public OAuthParameters getAdvancedParameters() { 177 191 if (cbUseDefaults.isSelected()) 178 return OAuthParameters.createDefault( );192 return OAuthParameters.createDefault(apiUrl); 179 193 OAuthParameters parameters = new OAuthParameters(); 180 194 parameters.setConsumerKey(tfConsumerKey.getText()); … … 194 208 public void setAdvancedParameters(OAuthParameters parameters) throws IllegalArgumentException{ 195 209 CheckParameterUtil.ensureParameterNotNull(parameters, "parameters"); 196 if (parameters.equals(OAuthParameters.createDefault( ))) {210 if (parameters.equals(OAuthParameters.createDefault(apiUrl))) { 197 211 cbUseDefaults.setSelected(true); 198 212 setChildComponentsEnabled(false); … … 208 222 } 209 223 224 /** 225 * Constructs a new {@code AdvancedOAuthPropertiesPanel}. 226 */ 210 227 public AdvancedOAuthPropertiesPanel() { 211 228 build(); … … 218 235 * @throws IllegalArgumentException thrown if pref is null 219 236 */ 220 public void initFromPreferences(Preferences pref) throws IllegalArgumentException {237 public void initFromPreferences(Preferences pref) throws IllegalArgumentException { 221 238 CheckParameterUtil.ensureParameterNotNull(pref, "pref"); 239 setApiUrl(pref.get("osm-server-url")); 222 240 boolean useDefault = pref.getBoolean("oauth.settings.use-default", true); 223 241 ilUseDefault.setEnabled(false); … … 265 283 public void itemStateChanged(ItemEvent e) { 266 284 if (!enabled) return; 267 switch (e.getStateChange()) {285 switch (e.getStateChange()) { 268 286 case ItemEvent.SELECTED: 269 287 if (hasCustomSettings()) { … … 285 303 } 286 304 } 305 306 /** 307 * Sets the URL of the OSM API for which this panel is currently displaying OAuth properties. 308 * 309 * @param apiUrl the api URL 310 * @since 5422 311 */ 312 public void setApiUrl(String apiUrl) { 313 this.apiUrl = apiUrl; 314 if (cbUseDefaults.isSelected()) { 315 resetToDefaultSettings(); 316 } 317 } 287 318 } -
trunk/src/org/openstreetmap/josm/gui/oauth/FullyAutomaticAuthorizationUI.java
r4690 r5422 54 54 * automatic process. 55 55 * 56 * @since 2746 56 57 */ 57 58 public class FullyAutomaticAuthorizationUI extends AbstractAuthorizationUI { … … 306 307 } 307 308 308 public FullyAutomaticAuthorizationUI() { 309 /** 310 * Constructs a new {@code FullyAutomaticAuthorizationUI} for the given API URL. 311 * @param apiUrl The OSM API URL 312 * @since 5422 313 */ 314 public FullyAutomaticAuthorizationUI(String apiUrl) { 315 super(apiUrl); 309 316 build(); 310 317 } -
trunk/src/org/openstreetmap/josm/gui/oauth/ManualAuthorizationUI.java
r4457 r5422 33 33 import org.openstreetmap.josm.tools.ImageProvider; 34 34 35 /** 36 * This is an UI which supports a JOSM user to get an OAuth Access Token in a fully 37 * manual process. 38 * 39 * @since 2746 40 */ 35 41 public class ManualAuthorizationUI extends AbstractAuthorizationUI{ 36 42 … … 54 60 gc.gridwidth = 2; 55 61 gc.insets = new Insets(0,0,5,0); 56 pnlMessage = new HtmlPanel();62 pnlMessage = new HtmlPanel(); 57 63 pnlMessage.setText("<html><body>" 58 64 + tr("Please enter an OAuth Access Token which is authorized to access the OSM server " … … 137 143 public void setApiUrl(String apiUrl) { 138 144 super.setApiUrl(apiUrl); 139 pnlMessage.setText(tr("<html><body>" 140 + "Please enter an OAuth Access Token which is authorized to access the OSM server " 141 + "''{0}''." 142 + "</body></html>", 143 getApiUrl() 144 )); 145 if (pnlMessage != null) { 146 pnlMessage.setText(tr("<html><body>" 147 + "Please enter an OAuth Access Token which is authorized to access the OSM server " 148 + "''{0}''." 149 + "</body></html>", 150 getApiUrl() 151 )); 152 } 145 153 } 146 154 … … 152 160 } 153 161 154 public ManualAuthorizationUI() { 162 /** 163 * Constructs a new {@code ManualAuthorizationUI} for the given API URL. 164 * @param apiUrl The OSM API URL 165 * @since 5422 166 */ 167 public ManualAuthorizationUI(String apiUrl) { 168 super(apiUrl); 155 169 build(); 156 170 } -
trunk/src/org/openstreetmap/josm/gui/oauth/OAuthAuthorizationWizard.java
r4310 r5422 37 37 38 38 import org.openstreetmap.josm.Main; 39 import org.openstreetmap.josm.data.CustomConfigurator; 40 import org.openstreetmap.josm.data.Preferences; 39 41 import org.openstreetmap.josm.data.oauth.OAuthParameters; 40 42 import org.openstreetmap.josm.data.oauth.OAuthToken; … … 56 58 private HtmlPanel pnlMessage; 57 59 private boolean canceled; 58 private String apiUrl;60 private final String apiUrl; 59 61 60 62 private AuthorizationProcedureComboBox cbAuthorisationProcedure; … … 163 165 getContentPane().add(buildHeaderInfoPanel(), BorderLayout.NORTH); 164 166 165 pnlFullyAutomaticAuthorisationUI = new FullyAutomaticAuthorizationUI(); 166 pnlFullyAutomaticAuthorisationUI.setApiUrl(apiUrl); 167 168 pnlSemiAutomaticAuthorisationUI = new SemiAutomaticAuthorizationUI(); 169 pnlSemiAutomaticAuthorisationUI.setApiUrl(apiUrl); 170 171 pnlManualAuthorisationUI = new ManualAuthorizationUI(); 172 pnlManualAuthorisationUI.setApiUrl(apiUrl); 167 setTitle(tr("Get an Access Token for ''{0}''", apiUrl)); 168 169 pnlFullyAutomaticAuthorisationUI = new FullyAutomaticAuthorizationUI(apiUrl); 170 pnlSemiAutomaticAuthorisationUI = new SemiAutomaticAuthorizationUI(apiUrl); 171 pnlManualAuthorisationUI = new ManualAuthorizationUI(apiUrl); 173 172 174 173 spAuthorisationProcedureUI = new JScrollPane(new JPanel()); … … 208 207 */ 209 208 public OAuthAuthorizationWizard(String apiUrl) throws IllegalArgumentException { 210 super(JOptionPane.getFrameForComponent(Main.parent), ModalityType.DOCUMENT_MODAL); 211 CheckParameterUtil.ensureParameterNotNull(apiUrl, "apiUrl"); 212 build(); 213 setApiUrl(apiUrl); 209 this(Main.parent, apiUrl); 214 210 } 215 211 … … 224 220 super(JOptionPane.getFrameForComponent(parent), ModalityType.DOCUMENT_MODAL); 225 221 CheckParameterUtil.ensureParameterNotNull(apiUrl, "apiUrl"); 222 this.apiUrl = apiUrl; 226 223 build(); 227 setApiUrl(apiUrl);228 }229 230 /**231 * Sets the API URL for the API for which this wizard is generating232 * an Access Token.233 *234 * @param apiUrl the API URL. Must not be null.235 * @throws IllegalArgumentException thrown if apiUrl is null236 */237 public void setApiUrl(String apiUrl) throws IllegalArgumentException{238 CheckParameterUtil.ensureParameterNotNull(apiUrl, "apiUrl");239 this.apiUrl = apiUrl;240 setTitle(tr("Get an Access Token for ''{0}''", apiUrl));241 if (pnlFullyAutomaticAuthorisationUI != null) {242 pnlFullyAutomaticAuthorisationUI.setApiUrl(apiUrl);243 }244 if (pnlSemiAutomaticAuthorisationUI != null) {245 pnlSemiAutomaticAuthorisationUI.setApiUrl(apiUrl);246 }247 if (pnlManualAuthorisationUI != null) {248 pnlManualAuthorisationUI.setApiUrl(apiUrl);249 }250 224 } 251 225 … … 302 276 */ 303 277 public void initFromPreferences() { 304 pnlFullyAutomaticAuthorisationUI.initFromPreferences(Main.pref); 305 pnlSemiAutomaticAuthorisationUI.initFromPreferences(Main.pref); 306 pnlManualAuthorisationUI.initFromPreferences(Main.pref); 278 // Copy current JOSM preferences to update API url with the one used in this wizard 279 Preferences copyPref = CustomConfigurator.clonePreferences(Main.pref); 280 copyPref.put("osm-server-url", apiUrl); 281 pnlFullyAutomaticAuthorisationUI.initFromPreferences(copyPref); 282 pnlSemiAutomaticAuthorisationUI.initFromPreferences(copyPref); 283 pnlManualAuthorisationUI.initFromPreferences(copyPref); 307 284 } 308 285 … … 388 365 public void hyperlinkUpdate(HyperlinkEvent e) { 389 366 if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) { 390 String url = e.getDescription(); 391 OpenBrowser.displayUrl(url); 367 OpenBrowser.displayUrl(e.getDescription()); 392 368 } 393 369 } -
trunk/src/org/openstreetmap/josm/gui/oauth/OsmOAuthAuthorizationClient.java
r5266 r5422 39 39 import org.openstreetmap.josm.tools.CheckParameterUtil; 40 40 41 /** 42 * An OAuth 1.0 authorization client. 43 * @since 2746 44 */ 41 45 public class OsmOAuthAuthorizationClient { 42 private OAuthParameters oauthProviderParameters;43 private OAuthConsumer consumer;44 private OAuthProvider provider;46 private final OAuthParameters oauthProviderParameters; 47 private final OAuthConsumer consumer; 48 private final OAuthProvider provider; 45 49 private boolean canceled; 46 50 private HttpURLConnection connection; … … 57 61 */ 58 62 public OsmOAuthAuthorizationClient() { 59 oauthProviderParameters = OAuthParameters.createDefault( );63 oauthProviderParameters = OAuthParameters.createDefault(Main.pref.get("osm-server.url")); 60 64 consumer = oauthProviderParameters.buildConsumer(); 61 65 provider = oauthProviderParameters.buildProvider(consumer); … … 66 70 * 67 71 * @param parameters the OAuth parameters. Must not be null. 68 * @throws IllegalArgumentException thrownif parameters is null72 * @throws IllegalArgumentException if parameters is null 69 73 */ 70 74 public OsmOAuthAuthorizationClient(OAuthParameters parameters) throws IllegalArgumentException { … … 81 85 * @param parameters the OAuth parameters. Must not be null. 82 86 * @param requestToken the request token. Must not be null. 83 * @throws IllegalArgumentException thrownif parameters is null84 * @throws IllegalArgumentException thrownif requestToken is null87 * @throws IllegalArgumentException if parameters is null 88 * @throws IllegalArgumentException if requestToken is null 85 89 */ 86 90 public OsmOAuthAuthorizationClient(OAuthParameters parameters, OAuthToken requestToken) throws IllegalArgumentException { … … 92 96 } 93 97 98 /** 99 * Cancels the current OAuth operation. 100 */ 94 101 public void cancel() { 95 102 DefaultOAuthProvider p = (DefaultOAuthProvider)provider; … … 127 134 * @param monitor a progress monitor. Defaults to {@link NullProgressMonitor#INSTANCE} if null 128 135 * @return the OAuth Request Token 129 * @throws OsmOAuthAuthorizationException thrown if something goes wrong when retrieving the request token 136 * @throws OsmOAuthAuthorizationException if something goes wrong when retrieving the request token 137 * @throws OsmTransferCanceledException if the user canceled the request 130 138 */ 131 139 public OAuthToken getRequestToken(ProgressMonitor monitor) throws OsmOAuthAuthorizationException, OsmTransferCanceledException { … … 159 167 * @param monitor a progress monitor. Defaults to {@link NullProgressMonitor#INSTANCE} if null 160 168 * @return the OAuth Access Token 161 * @throws OsmOAuthAuthorizationException thrown if something goes wrong when retrieving the request token 169 * @throws OsmOAuthAuthorizationException if something goes wrong when retrieving the request token 170 * @throws OsmTransferCanceledException if the user canceled the request 162 171 * @see #getRequestToken(ProgressMonitor) 163 172 */ … … 273 282 * 274 283 * @return the OSM login URL 275 * @throws OsmOAuthAuthorizationException thrownif something went wrong, in particular if the284 * @throws OsmOAuthAuthorizationException if something went wrong, in particular if the 276 285 * URLs are malformed 277 286 */ … … 290 299 * 291 300 * @return the OSM logout URL 292 * @throws OsmOAuthAuthorizationException thrownif something went wrong, in particular if the301 * @throws OsmOAuthAuthorizationException if something went wrong, in particular if the 293 302 * URLs are malformed 294 303 */ … … 308 317 * 309 318 * @return the session ID structure 310 * @throws OsmOAuthAuthorizationException thrownif something went wrong319 * @throws OsmOAuthAuthorizationException if something went wrong 311 320 */ 312 321 protected SessionId fetchOsmWebsiteSessionId() throws OsmOAuthAuthorizationException { … … 340 349 * a hidden parameter. 341 350 * 342 * @throws OsmOAuthAuthorizationException thrownif something went wrong351 * @throws OsmOAuthAuthorizationException if something went wrong 343 352 */ 344 353 protected void fetchOAuthToken(SessionId sessionId, OAuthToken requestToken) throws OsmOAuthAuthorizationException { … … 526 535 * @param privileges the set of privileges. Must not be null. 527 536 * @param monitor a progress monitor. Defaults to {@link NullProgressMonitor#INSTANCE} if null 528 * @throws IllegalArgumentException thrownif requestToken is null529 * @throws IllegalArgumentException thrownif osmUserName is null530 * @throws IllegalArgumentException thrownif osmPassword is null531 * @throws IllegalArgumentException thrownif privileges is null532 * @throws OsmOAuthAuthorizationException thrownif the authorisation fails533 * @throws OsmTransferCanceledException thrownif the task is canceled by the user537 * @throws IllegalArgumentException if requestToken is null 538 * @throws IllegalArgumentException if osmUserName is null 539 * @throws IllegalArgumentException if osmPassword is null 540 * @throws IllegalArgumentException if privileges is null 541 * @throws OsmOAuthAuthorizationException if the authorisation fails 542 * @throws OsmTransferCanceledException if the task is canceled by the user 534 543 */ 535 544 public void authorise(OAuthToken requestToken, String osmUserName, String osmPassword, OsmPrivileges privileges, ProgressMonitor monitor) throws IllegalArgumentException, OsmOAuthAuthorizationException, OsmTransferCanceledException{ -
trunk/src/org/openstreetmap/josm/gui/oauth/SemiAutomaticAuthorizationUI.java
r3530 r5422 37 37 * In contrast to the fully-automatic procedure the user is dispatched to an 38 38 * external browser for login and authorisation. 39 * 40 * @since 2746 39 41 */ 40 42 public class SemiAutomaticAuthorizationUI extends AbstractAuthorizationUI { … … 58 60 } 59 61 60 public SemiAutomaticAuthorizationUI() { 62 /** 63 * Constructs a new {@code SemiAutomaticAuthorizationUI} for the given API URL. 64 * @param apiUrl The OSM API URL 65 * @since 5422 66 */ 67 public SemiAutomaticAuthorizationUI(String apiUrl) { 68 super(apiUrl); 61 69 build(); 62 70 } -
trunk/src/org/openstreetmap/josm/gui/preferences/server/OAuthAuthenticationPreferencesPanel.java
r5266 r5422 40 40 * user already has an Access Token. 41 41 * 42 * For initial authorisation see {@link OAuthAuthori sationWizard}.42 * For initial authorisation see {@link OAuthAuthorizationWizard}. 43 43 * 44 44 */ … … 145 145 } 146 146 147 /** 148 * Sets the URL of the OSM API for which this panel is currently displaying OAuth properties. 149 * 150 * @param apiUrl the api URL 151 */ 147 152 public void setApiUrl(String apiUrl) { 148 153 this.apiUrl = apiUrl; 154 pnlAdvancedProperties.setApiUrl(apiUrl); 149 155 } 150 156 … … 372 378 if (! evt.getPropertyName().equals(OsmApiUrlInputPanel.API_URL_PROP)) 373 379 return; 374 apiUrl = (String)evt.getNewValue();380 setApiUrl((String)evt.getNewValue()); 375 381 } 376 382 } -
trunk/src/org/openstreetmap/josm/gui/preferences/server/OsmApiUrlInputPanel.java
r4246 r5422 38 38 static public final String API_URL_PROP = OsmApiUrlInputPanel.class.getName() + ".apiUrl"; 39 39 40 static public final String defaulturl = "http://api.openstreetmap.org/api";41 40 private JLabel lblValid; 42 41 private JLabel lblApiUrl; … … 61 60 gc.gridx = 1; 62 61 gc.weightx = 1.0; 63 JLabel lbl = new JLabel(tr("<html>Use the default OSM server URL (<strong>{0}</strong>)</html>", defaulturl));62 JLabel lbl = new JLabel(tr("<html>Use the default OSM server URL (<strong>{0}</strong>)</html>", OsmApi.DEFAULT_API_URL)); 64 63 lbl.setFont(lbl.getFont().deriveFont(Font.PLAIN)); 65 64 pnl.add(lbl, gc); … … 122 121 if (url == null) { 123 122 cbUseDefaultServerUrl.setSelected(true); 124 firePropertyChange(API_URL_PROP, null, defaulturl);125 } else if (url.trim().equals( defaulturl)) {123 firePropertyChange(API_URL_PROP, null, OsmApi.DEFAULT_API_URL); 124 } else if (url.trim().equals(OsmApi.DEFAULT_API_URL)) { 126 125 cbUseDefaultServerUrl.setSelected(true); 127 firePropertyChange(API_URL_PROP, null, defaulturl);126 firePropertyChange(API_URL_PROP, null, OsmApi.DEFAULT_API_URL); 128 127 } else { 129 128 cbUseDefaultServerUrl.setSelected(false); … … 140 139 if (cbUseDefaultServerUrl.isSelected()) { 141 140 Main.pref.put("osm-server.url", null); 142 } else if (tfOsmServerUrl.getText().trim().equals( defaulturl)) {141 } else if (tfOsmServerUrl.getText().trim().equals(OsmApi.DEFAULT_API_URL)) { 143 142 Main.pref.put("osm-server.url", null); 144 143 } else { … … 264 263 case ItemEvent.SELECTED: 265 264 setApiUrlInputEnabled(false); 266 firePropertyChange(API_URL_PROP, null, defaulturl);265 firePropertyChange(API_URL_PROP, null, OsmApi.DEFAULT_API_URL); 267 266 break; 268 267 case ItemEvent.DESELECTED: -
trunk/src/org/openstreetmap/josm/io/OsmApi.java
r5386 r5422 61 61 * <a href="http://wiki.openstreetmap.org/wiki/API_usage_policy#Technical_Usage_Requirements"> 62 62 * OSM API usage policy.</a> 63 * @since 5386 63 64 */ 64 65 static public final int MAX_DOWNLOAD_THREADS = 2; 66 67 /** 68 * Default URL of the standard OSM API. 69 * @since 5422 70 */ 71 static public final String DEFAULT_API_URL = "http://api.openstreetmap.org/api"; 65 72 66 73 // The collection of instantiated OSM APIs … … 92 99 */ 93 100 static public OsmApi getOsmApi() { 94 String serverUrl = Main.pref.get("osm-server.url", "http://api.openstreetmap.org/api");101 String serverUrl = Main.pref.get("osm-server.url", DEFAULT_API_URL); 95 102 if (serverUrl == null) 96 103 throw new IllegalStateException(tr("Preference ''{0}'' missing. Cannot initialize OsmApi.", "osm-server.url")); -
trunk/src/org/openstreetmap/josm/tools/ExceptionUtil.java
r5321 r5422 52 52 "<html>Failed to initialize communication with the OSM server {0}.<br>" 53 53 + "Check the server URL in your preferences and your internet connection.", Main.pref.get( 54 "osm-server.url", "http://api.openstreetmap.org/api"));54 "osm-server.url", OsmApi.DEFAULT_API_URL)); 55 55 return msg; 56 56 } … … 70 70 + "Please open the Preferences Dialog and generate or enter an Access Token." 71 71 + "</html>", 72 Main.pref.get("osm-server.url", "http://api.openstreetmap.org/api")72 Main.pref.get("osm-server.url", OsmApi.DEFAULT_API_URL) 73 73 ); 74 74 return msg;
Note:
See TracChangeset
for help on using the changeset viewer.