Changeset 5584 in josm for trunk/src/org/openstreetmap/josm/gui/ExceptionDialogUtil.java
- Timestamp:
- 2012-11-17T14:08:43+01:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/ExceptionDialogUtil.java
r5275 r5584 10 10 import java.net.SocketException; 11 11 import java.net.UnknownHostException; 12 import java.util.regex.Matcher; 13 import java.util.regex.Pattern; 12 14 13 15 import javax.swing.JOptionPane; … … 242 244 } 243 245 246 private static boolean isOAuth() { 247 return Main.pref.get("osm-server.auth-method", "basic").equals("oauth"); 248 } 249 244 250 /** 245 251 * Explains a {@link OsmApiException} which was thrown because the authentication at … … 249 255 */ 250 256 public static void explainAuthenticationFailed(OsmApiException e) { 251 String authMethod = Main.pref.get("osm-server.auth-method", "basic");252 257 String msg; 253 if ( authMethod.equals("oauth")) {258 if (isOAuth()) { 254 259 msg = ExceptionUtil.explainFailedOAuthAuthentication(e); 255 260 } else { … … 268 273 /** 269 274 * Explains a {@link OsmApiException} which was thrown because accessing a protected 270 * resource was forbidden .275 * resource was forbidden (HTTP 403). 271 276 * 272 277 * @param e the exception 273 278 */ 274 279 public static void explainAuthorizationFailed(OsmApiException e) { 275 // Fixme: add special handling that calls ExceptionUtil.explainFailedOAuthAuthorisation(e) 276 HelpAwareOptionPane.showOptionDialog( 277 Main.parent, 278 ExceptionUtil.explainFailedAuthorisation(e), 280 281 Matcher m; 282 String msg; 283 String url = e.getAccessedUrl(); 284 Pattern p = Pattern.compile("http://.*/api/0.6/(node|way|relation)/(\\d+)/(\\d+)"); 285 286 // Special case for individual access to redacted versions 287 // See http://wiki.openstreetmap.org/wiki/Open_Database_License/Changes_in_the_API 288 if (url != null && (m = p.matcher(url)).matches()) { 289 String type = m.group(1); 290 String id = m.group(2); 291 String version = m.group(3); 292 // {1} is the translation of "node", "way" or "relation" 293 msg = tr("Access to redacted version ''{0}'' of {1} {2} is forbidden.", 294 version, tr(type), id); 295 } else if (isOAuth()) { 296 msg = ExceptionUtil.explainFailedOAuthAuthorisation(e); 297 } else { 298 msg = ExceptionUtil.explainFailedAuthorisation(e); 299 } 300 301 HelpAwareOptionPane.showOptionDialog( 302 Main.parent, 303 msg, 279 304 tr("Authorisation Failed"), 280 305 JOptionPane.ERROR_MESSAGE, 281 ht("/ErrorMessages#Auth enticationFailed")306 ht("/ErrorMessages#AuthorizationFailed") 282 307 ); 283 308 }
Note:
See TracChangeset
for help on using the changeset viewer.