Ignore:
Timestamp:
2017-10-14T00:09:56+02:00 (8 years ago)
Author:
Don-vip
Message:

fix #15435 - do not cache incorrect login credentials when using basic auth

Location:
trunk/src/org/openstreetmap/josm/io/auth
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/io/auth/AbstractCredentialsAgent.java

    r12869 r12992  
    6262
    6363        /*
    64          * Last request was successful and there was no credentials stored
    65          * in file (or only the username is stored).
    66          * -> Try to recall credentials that have been entered
    67          * manually in this session.
     64         * Last request was successful and there was no credentials stored in file (or only the username is stored).
     65         * -> Try to recall credentials that have been entered manually in this session.
    6866         */
    6967        if (!noSuccessWithLastResponse && memoryCredentialsCache.containsKey(requestorType) &&
     
    8987                        response.getPassword()
    9088                ));
    91             /*
    92              * User decides not to save credentials to file. Keep it
    93              * in memory so we don't have to ask over and over again.
    94              */
    9589            } else {
    96                 PasswordAuthentication pa = new PasswordAuthentication(response.getUsername(), response.getPassword());
    97                 memoryCredentialsCache.put(requestorType, pa);
     90                // User decides not to save credentials to file. Keep it in memory so we don't have to ask over and over again.
     91                memoryCredentialsCache.put(requestorType, new PasswordAuthentication(response.getUsername(), response.getPassword()));
    9892            }
    99         /*
    100          * We got it from file.
    101          */
    10293        } else {
     94            // We got it from file.
    10395            response.setUsername(username);
    10496            response.setPassword(password.toCharArray());
     
    10698        }
    10799        return response;
     100    }
     101
     102    @Override
     103    public final void purgeCredentialsCache(RequestorType requestorType) {
     104        memoryCredentialsCache.remove(requestorType);
    108105    }
    109106
  • trunk/src/org/openstreetmap/josm/io/auth/CredentialsAgent.java

    r8929 r12992  
    7474
    7575    /**
     76     * Purges the internal credentials cache for the given requestor type.
     77     * @param requestorType the type of service.
     78     * {@link RequestorType#SERVER} for the OSM API server, {@link RequestorType#PROXY} for a proxy server
     79     * @since 12992
     80     */
     81    void purgeCredentialsCache(RequestorType requestorType);
     82
     83    /**
    7684     * Provide a Panel that is shown below the API password / username fields
    7785     * in the JOSM Preferences. (E.g. a warning that password is saved unencrypted.)
  • trunk/src/org/openstreetmap/josm/io/auth/CredentialsManager.java

    r12743 r12992  
    4343    private static CredentialsAgentFactory agentFactory;
    4444
     45    /**
     46     * Credentials agent factory.
     47     */
    4548    @FunctionalInterface
    4649    public interface CredentialsAgentFactory {
     50        /**
     51         * Returns the credentials agent instance.
     52         * @return the credentials agent instance
     53         */
    4754        CredentialsAgent getCredentialsAgent();
    4855    }
     
    148155        return delegate.getPreferencesDecorationPanel();
    149156    }
     157
     158    @Override
     159    public void purgeCredentialsCache(RequestorType requestorType) {
     160        delegate.purgeCredentialsCache(requestorType);
     161    }
    150162}
Note: See TracChangeset for help on using the changeset viewer.