Ignore:
Timestamp:
2017-11-28T00:56:29+01:00 (2 years ago)
Author:
Don-vip
Message:

see #15310 - remove most of deprecated APIs

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

Legend:

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

    r12928 r13173  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
    6 import org.openstreetmap.josm.data.Preferences;
    76import org.openstreetmap.josm.io.auth.CredentialsAgent;
    87import org.openstreetmap.josm.io.auth.CredentialsAgentException;
     
    165164
    166165    /**
    167      * Initializes the content of this holder from the Access Token managed by the
    168      * credential manager.
    169      *
    170      * @param pref the preferences. Must not be null.
    171      * @param cm the credential manager. Must not be null.
    172      * @throws IllegalArgumentException if cm is null
    173      * @deprecated (since 12928) replaced by {@link #init(org.openstreetmap.josm.io.auth.CredentialsAgent)}
    174      */
    175     @Deprecated
    176     public void init(Preferences pref, CredentialsAgent cm) {
    177         CheckParameterUtil.ensureParameterNotNull(pref, "pref");
    178         CheckParameterUtil.ensureParameterNotNull(cm, "cm");
    179         OAuthToken token = null;
    180         try {
    181             token = cm.lookupOAuthAccessToken();
    182         } catch (CredentialsAgentException e) {
    183             Logging.error(e);
    184             Logging.warn(tr("Failed to retrieve OAuth Access Token from credential manager"));
    185             Logging.warn(tr("Current credential manager is of type ''{0}''", cm.getClass().getName()));
    186         }
    187         saveToPreferences = pref.getBoolean("oauth.access-token.save-to-preferences", true);
    188         if (token != null) {
    189             accessTokenKey = token.getKey();
    190             accessTokenSecret = token.getSecret();
    191         }
    192     }
    193 
    194     /**
    195166     * Saves the content of this holder to the preferences and a credential store managed
    196167     * by a credential manager.
     
    216187
    217188    /**
    218      * Saves the content of this holder to the preferences and a credential store managed
    219      * by a credential manager.
    220      *
    221      * @param preferences the preferences. Must not be null.
    222      * @param cm the credentials manager. Must not be null.
    223      * @throws IllegalArgumentException if preferences is null
    224      * @throws IllegalArgumentException if cm is null
    225      * @deprecated (since 12928) replaced by {@link #save(org.openstreetmap.josm.io.auth.CredentialsAgent)}
    226      */
    227     @Deprecated
    228     public void save(Preferences preferences, CredentialsAgent cm) {
    229         CheckParameterUtil.ensureParameterNotNull(preferences, "preferences");
    230         CheckParameterUtil.ensureParameterNotNull(cm, "cm");
    231         preferences.putBoolean("oauth.access-token.save-to-preferences", saveToPreferences);
    232         try {
    233             if (!saveToPreferences) {
    234                 cm.storeOAuthAccessToken(null);
    235             } else {
    236                 cm.storeOAuthAccessToken(new OAuthToken(accessTokenKey, accessTokenSecret));
    237             }
    238         } catch (CredentialsAgentException e) {
    239             Logging.error(e);
    240             Logging.warn(tr("Failed to store OAuth Access Token to credentials manager"));
    241             Logging.warn(tr("Current credential manager is of type ''{0}''", cm.getClass().getName()));
    242         }
    243     }
    244 
    245     /**
    246189     * Clears the content of this holder
    247190     */
  • trunk/src/org/openstreetmap/josm/data/oauth/OAuthParameters.java

    r12928 r13173  
    55
    66import org.openstreetmap.josm.Main;
    7 import org.openstreetmap.josm.data.Preferences;
    87import org.openstreetmap.josm.io.OsmApi;
    98import org.openstreetmap.josm.spi.preferences.Config;
     
    9695
    9796    /**
    98      * Replies a set of parameters as defined in the preferences.
    99      *
    100      * @param pref the preferences
    101      * @return the parameters
    102      * @deprecated (since 12928) replaced by {@link #createFromApiUrl(java.lang.String)}
    103      */
    104     @Deprecated
    105     public static OAuthParameters createFromPreferences(Preferences pref) {
    106         OAuthParameters parameters = createDefault(pref.get("osm-server.url"));
    107         return new OAuthParameters(
    108                 pref.get("oauth.settings.consumer-key", parameters.getConsumerKey()),
    109                 pref.get("oauth.settings.consumer-secret", parameters.getConsumerSecret()),
    110                 pref.get("oauth.settings.request-token-url", parameters.getRequestTokenUrl()),
    111                 pref.get("oauth.settings.access-token-url", parameters.getAccessTokenUrl()),
    112                 pref.get("oauth.settings.authorise-url", parameters.getAuthoriseUrl()),
    113                 pref.get("oauth.settings.osm-login-url", parameters.getOsmLoginUrl()),
    114                 pref.get("oauth.settings.osm-logout-url", parameters.getOsmLogoutUrl()));
    115     }
    116 
    117     /**
    11897     * Remembers the current values in the preferences.
    11998     */
     
    126105        Config.getPref().put("oauth.settings.osm-login-url", getOsmLoginUrl());
    127106        Config.getPref().put("oauth.settings.osm-logout-url", getOsmLogoutUrl());
    128     }
    129 
    130     /**
    131      * Remembers the current values in the preferences <code>pref</code>.
    132      *
    133      * @param pref the preferences. Must not be null.
    134      * @throws IllegalArgumentException if pref is null.
    135      * @deprecated (since 12928) replaced by {@link #rememberPreferences()}
    136      */
    137     @Deprecated
    138     public void rememberPreferences(Preferences pref) {
    139         CheckParameterUtil.ensureParameterNotNull(pref, "pref");
    140         pref.put("oauth.settings.consumer-key", getConsumerKey());
    141         pref.put("oauth.settings.consumer-secret", getConsumerSecret());
    142         pref.put("oauth.settings.request-token-url", getRequestTokenUrl());
    143         pref.put("oauth.settings.access-token-url", getAccessTokenUrl());
    144         pref.put("oauth.settings.authorise-url", getAuthoriseUrl());
    145         pref.put("oauth.settings.osm-login-url", getOsmLoginUrl());
    146         pref.put("oauth.settings.osm-logout-url", getOsmLogoutUrl());
    147107    }
    148108
Note: See TracChangeset for help on using the changeset viewer.