Changeset 6076 in josm


Ignore:
Timestamp:
2013-07-19T21:52:17+02:00 (11 years ago)
Author:
stoecker
Message:

fix #8875 - update JOSM key for OAuth, smooth transition for old key.

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

Legend:

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

    r6069 r6076  
    16321632     */
    16331633    public void removeObsolete() {
     1634        /* update the data with old consumer key*/
     1635        if(getInteger("josm.version", Version.getInstance().getVersion()) < 6076) {
     1636            if(!get("oauth.access-token.key").isEmpty() && get("oauth.settings.consumer-key").isEmpty()) {
     1637                put("oauth.settings.consumer-key", "AdCRxTpvnbmfV8aPqrTLyA");
     1638                put("oauth.settings.consumer-secret", "XmYOiGY9hApytcBC3xCec3e28QBqOWz5g6DSb5UpE");
     1639            }
     1640        }
     1641
    16341642        String[] obsolete = {
    16351643                "downloadAlong.downloadAlongTrack.distance",   // 07/2013 - can be removed mid-2014. Replaced by downloadAlongWay.distance
  • trunk/src/org/openstreetmap/josm/data/oauth/OAuthParameters.java

    r6069 r6076  
    2929    static public final String DEFAULT_JOSM_CONSUMER_SECRET = "rIkjpPcBNkMQxrqzcOvOC4RRuYupYr7k8mfP13H5";
    3030    /**
    31      * The old default JOSM OAuth consumer key.
    32      */
    33     static public final String OLD_JOSM_CONSUMER_KEY = "AdCRxTpvnbmfV8aPqrTLyA";
    34     /**
    35      * The old default JOSM OAuth consumer secret.
    36      */
    37     static public final String OLD_JOSM_CONSUMER_SECRET = "XmYOiGY9hApytcBC3xCec3e28QBqOWz5g6DSb5UpE";
    38     /**
    3931     * The default OSM OAuth request token URL.
    4032     */
     
    7163    static public OAuthParameters createDefault(String apiUrl) {
    7264        OAuthParameters parameters = new OAuthParameters();
    73         parameters.setConsumerKey(OLD_JOSM_CONSUMER_KEY);
    74         parameters.setConsumerSecret(OLD_JOSM_CONSUMER_SECRET);
    75         if (apiUrl == null || apiUrl.isEmpty() || apiUrl.equals(OsmApi.DEFAULT_API_URL)) {
    76             parameters.setRequestTokenUrl(DEFAULT_REQUEST_TOKEN_URL);
    77             parameters.setAccessTokenUrl(DEFAULT_ACCESS_TOKEN_URL);
    78             parameters.setAuthoriseUrl(DEFAULT_AUTHORISE_URL);
    79         } else {
     65        parameters.setConsumerKey(DEFAULT_JOSM_CONSUMER_KEY);
     66        parameters.setConsumerSecret(DEFAULT_JOSM_CONSUMER_SECRET);
     67        parameters.setRequestTokenUrl(DEFAULT_REQUEST_TOKEN_URL);
     68        parameters.setAccessTokenUrl(DEFAULT_ACCESS_TOKEN_URL);
     69        parameters.setAuthoriseUrl(DEFAULT_AUTHORISE_URL);
     70        if(!apiUrl.equals(OsmApi.DEFAULT_API_URL)) {
    8071            try {
    8172                String host = new URL(apiUrl).getHost();
     
    9990     */
    10091    static public OAuthParameters createFromPreferences(Preferences pref) {
    101         boolean useDefault = pref.getBoolean("oauth.settings.use-default", true );
    102         if (useDefault)
    103             return createDefault(pref.get("osm-server.url"));
    104         OAuthParameters parameters = new OAuthParameters();
    105         parameters.setConsumerKey(pref.get("oauth.settings.consumer-key", ""));
    106         parameters.setConsumerSecret(pref.get("oauth.settings.consumer-secret", ""));
    107         parameters.setRequestTokenUrl(pref.get("oauth.settings.request-token-url", ""));
    108         parameters.setAccessTokenUrl(pref.get("oauth.settings.access-token-url", ""));
    109         parameters.setAuthoriseUrl(pref.get("oauth.settings.authorise-url", ""));
     92        OAuthParameters parameters = createDefault(pref.get("osm-server.url"));
     93        parameters.setConsumerKey(pref.get("oauth.settings.consumer-key", DEFAULT_JOSM_CONSUMER_KEY));
     94        parameters.setConsumerSecret(pref.get("oauth.settings.consumer-secret", DEFAULT_JOSM_CONSUMER_SECRET));
     95        parameters.setRequestTokenUrl(pref.get("oauth.settings.request-token-url", parameters.getRequestTokenUrl()));
     96        parameters.setAccessTokenUrl(pref.get("oauth.settings.access-token-url", parameters.getAccessTokenUrl()));
     97        parameters.setAuthoriseUrl(pref.get("oauth.settings.authorise-url", parameters.getAuthoriseUrl()));
    11098        return parameters;
    111     }
    112 
    113     /**
    114      * Clears the preferences for OAuth parameters
    115      *
    116      * @param pref the preferences in which keys related to OAuth parameters are
    117      * removed
    118      */
    119     static public void clearPreferences(Preferences pref) {
    120         pref.put("oauth.settings.consumer-key", null);
    121         pref.put("oauth.settings.consumer-secret", null);
    122         pref.put("oauth.settings.request-token-url", null);
    123         pref.put("oauth.settings.access-token-url", null);
    124         pref.put("oauth.settings.authorise-url", null);
    12599    }
    126100
     
    265239     */
    266240    public void saveToPreferences(Preferences pref) {
    267         if (this.equals(createDefault(pref.get("osm-server.url")))) {
    268             pref.put("oauth.settings.use-default", true );
    269             clearPreferences(pref);
    270             return;
    271         }
    272         pref.put("oauth.settings.use-default", false);
    273241        pref.put("oauth.settings.consumer-key", consumerKey);
    274242        pref.put("oauth.settings.consumer-secret", consumerSecret);
Note: See TracChangeset for help on using the changeset viewer.