Changeset 17972 in josm for trunk/src/org


Ignore:
Timestamp:
2021-07-09T22:33:03+02:00 (3 years ago)
Author:
Don-vip
Message:

fix #21065 - update fully automatic OAuth authentication to adapt to recent OSM server changes

Location:
trunk/src/org/openstreetmap/josm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/oauth/OsmPrivileges.java

    r9201 r17972  
    1313    private boolean allowWritePrefs;
    1414    private boolean allowModifyNotes;
     15    private boolean allowWriteDiary;
    1516
    1617    /**
     
    109110        this.allowModifyNotes = allowModifyNotes;
    110111    }
     112
     113    /**
     114     * Determines if the client is allowed to write diary.
     115     * @return {@code true} if the client is allowed to write diary, {@code false} otherwise
     116     * @since 17972
     117     */
     118    public boolean isAllowWriteDiary() {
     119        return allowWriteDiary;
     120    }
     121
     122    /**
     123     * Sets whether the client is allowed to write diary.
     124     * @param allowWriteDiary {@code true} if the client is allowed to write diary, {@code false} otherwise
     125     * @since 17972
     126     */
     127    public void setAllowWriteDiary(boolean allowWriteDiary) {
     128        this.allowWriteDiary = allowWriteDiary;
     129    }
    111130}
  • trunk/src/org/openstreetmap/josm/gui/oauth/OsmOAuthAuthorizationClient.java

    r17196 r17972  
    360360        parameters.put("oauth_callback", "");
    361361        parameters.put("authenticity_token", sessionId.token);
    362         if (privileges.isAllowWriteApi()) {
    363             parameters.put("allow_write_api", "yes");
    364         }
    365         if (privileges.isAllowWriteGpx()) {
    366             parameters.put("allow_write_gpx", "yes");
    367         }
    368         if (privileges.isAllowReadGpx()) {
    369             parameters.put("allow_read_gpx", "yes");
    370         }
    371         if (privileges.isAllowWritePrefs()) {
    372             parameters.put("allow_write_prefs", "yes");
    373         }
    374         if (privileges.isAllowReadPrefs()) {
    375             parameters.put("allow_read_prefs", "yes");
    376         }
    377         if (privileges.isAllowModifyNotes()) {
    378             parameters.put("allow_write_notes", "yes");
    379         }
    380 
    381         parameters.put("commit", "Save changes");
     362        parameters.put("allow_write_api", booleanParam(privileges.isAllowWriteApi()));
     363        parameters.put("allow_write_gpx", booleanParam(privileges.isAllowWriteGpx()));
     364        parameters.put("allow_read_gpx", booleanParam(privileges.isAllowReadGpx()));
     365        parameters.put("allow_write_prefs", booleanParam(privileges.isAllowWritePrefs()));
     366        parameters.put("allow_read_prefs", booleanParam(privileges.isAllowReadPrefs()));
     367        parameters.put("allow_write_notes", booleanParam(privileges.isAllowModifyNotes()));
     368        parameters.put("allow_write_diary", booleanParam(privileges.isAllowWriteDiary()));
    382369
    383370        String request = buildPostRequest(parameters);
     
    405392            }
    406393        }
     394    }
     395
     396    private static String booleanParam(boolean param) {
     397        return param ? "1" : "0";
    407398    }
    408399
Note: See TracChangeset for help on using the changeset viewer.