Ignore:
Timestamp:
2009-12-16T18:58:04+01:00 (14 years ago)
Author:
Gubaer
Message:

new: supports system defined proxies if JOSM is started with -Djava.net.useSystemProxies=true
fixed #1641: JOSM doesn't allow for setting HTTP proxy user/password distrinct from OSM server user/password
fixed #2865: SOCKS Proxy Support
fixed #4182: Proxy Authentication

Location:
trunk/src/org/openstreetmap/josm/io/auth
Files:
1 added
1 moved

Legend:

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

    r2628 r2641  
    11// License: GPL. For details, see LICENSE file.
    2 package org.openstreetmap.josm.io;
     2package org.openstreetmap.josm.io.auth;
    33
    4 import org.openstreetmap.josm.io.OsmConnection.OsmAuth;
     4import java.net.PasswordAuthentication;
     5import java.net.Authenticator.RequestorType;
    56
    67/**
    7  * Manages how username and password are stored. In addition all
    8  * username/password-related user interaction is encapsulated here.
     8 * A CredentialManager manages two credentials:
     9 * <ul>
     10 *   <li>the credential for {@see RequestorType#SERVER} which is equal to the OSM API credentials
     11 *   in JOSM</li>
     12 *   <li>the credential for {@see RequestorType#PROXY} which is equal to the credentials for an
     13 *   optional HTTP proxy server a user may use</li>
     14 *  </ul>
    915 */
    1016public interface CredentialsManager {
    11     enum Key {
    12         OSM_SERVER_URL("url"),
    13         USERNAME("username"),
    14         PASSWORD("password");
    15         final private String pname;
    16         private Key(String name) {
    17             pname = name;
    18         }
    19         @Override public String toString() {
    20             return pname;
    21         }
    22     };
    2317
    2418    /**
    25      * Should throw or return non-null, possibly empty String.
     19     * Looks up the credentials for a given type.
     20     *
     21     * @param the type of service. {@see RequestorType#SERVER} for the OSM API server, {@see RequestorType#PROXY}
     22     * for a proxy server
     23     * @return the credentials
     24     * @throws CredentialsManagerException thrown if a problem occurs in a implementation of this interface
    2625     */
    27     public String lookup(Key key) throws CMException;
     26    public PasswordAuthentication lookup(RequestorType requestorType) throws CredentialsManagerException;
    2827
    2928    /**
    30      * May silently fail to store.
     29     * Saves the credentials in <code>credentials</code> for the given service type.
     30     *
     31     * @param the type of service. {@see RequestorType#SERVER} for the OSM API server, {@see RequestorType#PROXY}
     32     * for a proxy server
     33     * @param credentials the credentials
     34     * @throws CredentialsManagerException thrown if a problem occurs in a implementation of this interface
    3135     */
    32     public void store(Key key, String secret) throws CMException;
     36    public void store(RequestorType requestorType, PasswordAuthentication credentials) throws CredentialsManagerException;
    3337
    3438    /**
    35      * If authentication using the stored credentials fails, this method is
    36      * called to promt for new username/password.
     39     *
     40     * @param requestorType  the type of service. {@see RequestorType#SERVER} for the OSM API server, {@see RequestorType#PROXY}
     41     * for a proxy server
     42     * @param noSuccessWithLastResponse true, if the last request with the supplied credentials failed; false otherwise.
     43     * If true, implementations of this interface are adviced prompt user for new credentials.
     44     * @throws CredentialsManagerException thrown if a problem occurs in a implementation of this interface
     45
    3746     */
    38     public java.net.PasswordAuthentication getPasswordAuthentication(OsmAuth caller);
    39 
    40     /**
    41      * Credentials-related preference gui.
    42      */
    43     public interface PreferenceAdditions {
    44         public void addPreferenceOptions(javax.swing.JPanel panel);
    45         public void preferencesChanged();
    46     }
    47     public PreferenceAdditions newPreferenceAdditions();
    48 
    49     public class CMException extends Exception {
    50         public CMException() {super();}
    51         public CMException(String message, Throwable cause) {super(message, cause);}
    52         public CMException(String message) {super(message);}
    53         public CMException(Throwable cause) {super(cause);}
    54     }
    55     public class NoContentException extends CMException {
    56         public NoContentException() {super();}
    57         public NoContentException(String message, Throwable cause) {super(message, cause);}
    58         public NoContentException(String message) {super(message);}
    59         public NoContentException(Throwable cause) {super(cause);}
    60     }
     47    public CredentialsManagerResponse getCredentials(RequestorType requestorType, boolean noSuccessWithLastResponse) throws CredentialsManagerException;
    6148}
Note: See TracChangeset for help on using the changeset viewer.