Changeset 13173 in josm for trunk/src/org/openstreetmap/josm/data/oauth/OAuthAccessTokenHolder.java
- Timestamp:
- 2017-11-28T00:56:29+01:00 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/oauth/OAuthAccessTokenHolder.java
r12928 r13173 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import org.openstreetmap.josm.data.Preferences;7 6 import org.openstreetmap.josm.io.auth.CredentialsAgent; 8 7 import org.openstreetmap.josm.io.auth.CredentialsAgentException; … … 165 164 166 165 /** 167 * Initializes the content of this holder from the Access Token managed by the168 * 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 null173 * @deprecated (since 12928) replaced by {@link #init(org.openstreetmap.josm.io.auth.CredentialsAgent)}174 */175 @Deprecated176 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 /**195 166 * Saves the content of this holder to the preferences and a credential store managed 196 167 * by a credential manager. … … 216 187 217 188 /** 218 * Saves the content of this holder to the preferences and a credential store managed219 * 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 null224 * @throws IllegalArgumentException if cm is null225 * @deprecated (since 12928) replaced by {@link #save(org.openstreetmap.josm.io.auth.CredentialsAgent)}226 */227 @Deprecated228 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 /**246 189 * Clears the content of this holder 247 190 */
Note:
See TracChangeset
for help on using the changeset viewer.