Changeset 36051 in osm for applications/editors/josm


Ignore:
Timestamp:
2023-02-09T14:37:12+01:00 (20 months ago)
Author:
taylor.smock
Message:

See #20768: OpenStreetMap OAuth2 support

The SdsCredentialAgent extends AbstractCredentialsAgent, which means it needed
to be updated.

The agent is used in one place, and does not call any of the new methods. As
such, the new methods will just throw an exception.

Location:
applications/editors/josm/plugins/sds
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/sds/build.xml

    r35039 r36051  
    55    <property name="commit.message" value=""/>
    66    <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
    7     <property name="plugin.main.version" value="14153"/>
     7    <property name="plugin.main.version" value="18650"/>
    88
    99    <property name="plugin.author" value="Frederik Ramm"/>
  • applications/editors/josm/plugins/sds/src/org/openstreetmap/hot/sds/SdsCredentialAgent.java

    r34470 r36051  
    77import java.net.Authenticator.RequestorType;
    88import java.net.PasswordAuthentication;
    9 import java.util.HashMap;
     9import java.util.EnumMap;
    1010import java.util.Map;
    1111
    1212import javax.swing.text.html.HTMLEditorKit;
    1313
     14import org.openstreetmap.josm.data.oauth.IOAuthToken;
    1415import org.openstreetmap.josm.data.oauth.OAuthToken;
    1516import org.openstreetmap.josm.gui.io.CredentialDialog;
     
    2728public class SdsCredentialAgent extends AbstractCredentialsAgent {
    2829
    29     Map<RequestorType, PasswordAuthentication> sdsMemoryCredentialsCache = new HashMap<>();
     30    private final Map<RequestorType, PasswordAuthentication> sdsMemoryCredentialsCache = new EnumMap<>(RequestorType.class);
    3031
    3132    /**
    32      * @see CredentialsAgent#lookup(RequestorType)
     33     * @see CredentialsAgent#lookup(RequestorType, String)
    3334     */
    3435    @Override
    35     public PasswordAuthentication lookup(RequestorType requestorType, String host) throws CredentialsAgentException {
     36    public PasswordAuthentication lookup(RequestorType requestorType, String host) {
    3637        if (requestorType == null)
    3738            return null;
     
    5657
    5758    /**
    58      * @see CredentialsAgent#store(RequestorType, PasswordAuthentication)
     59     * @see CredentialsAgent#store(RequestorType, String, PasswordAuthentication)
    5960     */
    6061    @Override
     
    8788     *
    8889     * @return the current OAuth Access Token to access the OSM server.
    89      * @throws CredentialsAgentException thrown if something goes wrong
    9090     */
    9191    @Override
    92     public OAuthToken lookupOAuthAccessToken() throws CredentialsAgentException {
     92    public OAuthToken lookupOAuthAccessToken() {
    9393        String accessTokenKey = Config.getPref().get("oauth.access-token.key", null);
    9494        String accessTokenSecret = Config.getPref().get("oauth.access-token.secret", null);
     
    9696            return null;
    9797        return new OAuthToken(accessTokenKey, accessTokenSecret);
     98    }
     99
     100    @Override
     101    public IOAuthToken lookupOAuthAccessToken(String host) {
     102        throw new UnsupportedOperationException("SDS does not support OAuth tokens");
    98103    }
    99104
     
    123128
    124129    @Override
    125     public void storeOAuthAccessToken(OAuthToken accessToken)
    126             throws CredentialsAgentException {
     130    public void storeOAuthAccessToken(OAuthToken accessToken) {
    127131        // no-op
    128 
     132    }
     133
     134    @Override
     135    public void storeOAuthAccessToken(String host, IOAuthToken accessToken) {
     136        throw new UnsupportedOperationException("SDS does not support OAuth tokens");
    129137    }
    130138
     
    158166         * (noSuccessWithLastResponse == true).
    159167         */
    160         } else if (noSuccessWithLastResponse || username.equals("") || password.equals("")) {
    161             CredentialDialog dialog = null;
     168        } else if (noSuccessWithLastResponse || "".equals(username) || "".equals(password)) {
     169            CredentialDialog dialog;
    162170            switch(requestorType) {
    163171            case SERVER:
     
    167175                dialog = CredentialDialog.getHttpProxyCredentialDialog(username, password, host, getSaveUsernameAndPasswordCheckboxText());
    168176                break;
     177            default:
     178                return null;
    169179            }
    170180            dialog.setVisible(true);
Note: See TracChangeset for help on using the changeset viewer.