/** * Explains a {@link OsmApiException} which was thrown because accessing a protected resource was * forbidden (HTTP 403). * * @param e the exception */ public static void explainAuthorizationFailed(OsmApiException e) { Matcher m; String msg; String url = e.getAccessedUrl(); Pattern p = Pattern.compile("https?://.*/api/0.6/(node|way|relation)/(\\d+)/(\\d+)"); // Special case for individual access to redacted versions // See http://wiki.openstreetmap.org/wiki/Open_Database_License/Changes_in_the_API if (url != null && (m = p.matcher(url)).matches()) { String type = m.group(1); String id = m.group(2); String version = m.group(3); // {1} is the translation of "node", "way" or "relation" msg = tr("Access to redacted version ''{0}'' of {1} {2} is forbidden.", version, tr(type), id); } else if (OsmApi.isUsingOAuth()) { msg = ExceptionUtil.explainFailedOAuthAuthorisation(e); } else { msg = ExceptionUtil.explainFailedAuthorisation(e); } HelpAwareOptionPane.showOptionDialog( Main.parent, msg, tr("Authorisation Failed"), JOptionPane.ERROR_MESSAGE, ht("/ErrorMessages#AuthorizationFailed")); }
/** * Explains a {@link OsmApiException} which was thrown because the authentication at the OSM * server failed * * @param e the exception */ public static void explainAuthenticationFailed(OsmApiException e) { String msg; if (OsmApi.isUsingOAuth()) { msg = ExceptionUtil.explainFailedOAuthAuthentication(e); } else { msg = ExceptionUtil.explainFailedBasicAuthentication(e); } HelpAwareOptionPane.showOptionDialog( Main.parent, msg, tr("Authentication Failed"), JOptionPane.ERROR_MESSAGE, ht("/ErrorMessages#AuthenticationFailed")); }