org.openstreetmap.josm.data.oauth
Class OAuthParameters

java.lang.Object
  extended by org.openstreetmap.josm.data.oauth.OAuthParameters

public class OAuthParameters
extends java.lang.Object

This class manages a set of OAuth parameters.

Since:
2747

Field Summary
private  java.lang.String accessTokenUrl
           
private  java.lang.String authoriseUrl
           
private  java.lang.String consumerKey
           
private  java.lang.String consumerSecret
           
static java.lang.String DEFAULT_ACCESS_TOKEN_URL
          The default OSM OAuth access token URL.
static java.lang.String DEFAULT_AUTHORISE_URL
          The default OSM OAuth authorize URL.
static java.lang.String DEFAULT_JOSM_CONSUMER_KEY
          The default JOSM OAuth consumer key.
static java.lang.String DEFAULT_JOSM_CONSUMER_SECRET
          The default JOSM OAuth consumer secret.
static java.lang.String DEFAULT_REQUEST_TOKEN_URL
          The default OSM OAuth request token URL.
private  java.lang.String requestTokenUrl
           
 
Constructor Summary
OAuthParameters()
          Constructs a new, unitialized, OAuthParameters.
OAuthParameters(OAuthParameters other)
          Creates a clone of the parameters in other.
 
Method Summary
 OAuthConsumer buildConsumer()
          Builds an OAuthConsumer based on these parameters.
 OAuthProvider buildProvider(OAuthConsumer consumer)
          Builds an OAuthProvider based on these parameters and a OAuth consumer consumer.
static void clearPreferences(Preferences pref)
          Clears the preferences for OAuth parameters
static OAuthParameters createDefault()
          Replies a set of default parameters for a consumer accessing the standard OSM server at OsmApi.DEFAULT_API_URL.
static OAuthParameters createDefault(java.lang.String apiUrl)
          Replies a set of default parameters for a consumer accessing an OSM server at the given API url.
static OAuthParameters createFromPreferences(Preferences pref)
          Replies a set of parameters as defined in the preferences.
 boolean equals(java.lang.Object obj)
           
 java.lang.String getAccessTokenUrl()
          Gets the access token URL.
 java.lang.String getAuthoriseUrl()
          Gets the authorise URL.
 java.lang.String getConsumerKey()
          Gets the consumer key.
 java.lang.String getConsumerSecret()
          Gets the consumer secret.
 java.lang.String getRequestTokenUrl()
          Gets the request token URL.
 int hashCode()
           
 void saveToPreferences(Preferences pref)
          Saves these OAuth parameters to the given Preferences.
 void setAccessTokenUrl(java.lang.String accessTokenUrl)
          Sets the access token URL.
 void setAuthoriseUrl(java.lang.String authoriseUrl)
          Sets the authorise URL.
 void setConsumerKey(java.lang.String consumerKey)
          Sets the consumer key.
 void setConsumerSecret(java.lang.String consumerSecret)
          Sets the consumer secret.
 void setRequestTokenUrl(java.lang.String requestTokenUrl)
          Sets the request token URL.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_JOSM_CONSUMER_KEY

public static final java.lang.String DEFAULT_JOSM_CONSUMER_KEY
The default JOSM OAuth consumer key.

See Also:
Constant Field Values

DEFAULT_JOSM_CONSUMER_SECRET

public static final java.lang.String DEFAULT_JOSM_CONSUMER_SECRET
The default JOSM OAuth consumer secret.

See Also:
Constant Field Values

DEFAULT_REQUEST_TOKEN_URL

public static final java.lang.String DEFAULT_REQUEST_TOKEN_URL
The default OSM OAuth request token URL.

See Also:
Constant Field Values

DEFAULT_ACCESS_TOKEN_URL

public static final java.lang.String DEFAULT_ACCESS_TOKEN_URL
The default OSM OAuth access token URL.

See Also:
Constant Field Values

DEFAULT_AUTHORISE_URL

public static final java.lang.String DEFAULT_AUTHORISE_URL
The default OSM OAuth authorize URL.

See Also:
Constant Field Values

consumerKey

private java.lang.String consumerKey

consumerSecret

private java.lang.String consumerSecret

requestTokenUrl

private java.lang.String requestTokenUrl

accessTokenUrl

private java.lang.String accessTokenUrl

authoriseUrl

private java.lang.String authoriseUrl
Constructor Detail

OAuthParameters

public OAuthParameters()
Constructs a new, unitialized, OAuthParameters.

See Also:
createDefault(), createFromPreferences(org.openstreetmap.josm.data.Preferences)

OAuthParameters

public OAuthParameters(OAuthParameters other)
                throws java.lang.IllegalArgumentException
Creates a clone of the parameters in other.

Parameters:
other - the other parameters. Must not be null.
Throws:
java.lang.IllegalArgumentException - thrown if other is null
Method Detail

createDefault

public static OAuthParameters createDefault()
Replies a set of default parameters for a consumer accessing the standard OSM server at OsmApi.DEFAULT_API_URL.

Returns:
a set of default parameters

createDefault

public static OAuthParameters createDefault(java.lang.String apiUrl)
Replies a set of default parameters for a consumer accessing an OSM server at the given API url. URL parameters are only set if the URL equals OsmApi.DEFAULT_API_URL or references the domain "dev.openstreetmap.org", otherwise they may be null.

Parameters:
apiUrl - The API URL for which the OAuth default parameters are created. If null or empty, the default OSM API url is used.
Returns:
a set of default parameters for the given apiUrl
Since:
5422

createFromPreferences

public static OAuthParameters createFromPreferences(Preferences pref)
Replies a set of parameters as defined in the preferences.

Parameters:
pref - the preferences
Returns:
the parameters

clearPreferences

public static void clearPreferences(Preferences pref)
Clears the preferences for OAuth parameters

Parameters:
pref - the preferences in which keys related to OAuth parameters are removed

getConsumerKey

public java.lang.String getConsumerKey()
Gets the consumer key.

Returns:
The consumer key

setConsumerKey

public void setConsumerKey(java.lang.String consumerKey)
Sets the consumer key.

Parameters:
consumerKey - The consumer key

getConsumerSecret

public java.lang.String getConsumerSecret()
Gets the consumer secret.

Returns:
The consumer secret

setConsumerSecret

public void setConsumerSecret(java.lang.String consumerSecret)
Sets the consumer secret.

Parameters:
consumerSecret - The consumer secret

getRequestTokenUrl

public java.lang.String getRequestTokenUrl()
Gets the request token URL.

Returns:
The request token URL

setRequestTokenUrl

public void setRequestTokenUrl(java.lang.String requestTokenUrl)
Sets the request token URL.

Parameters:
requestTokenUrl - the request token URL

getAccessTokenUrl

public java.lang.String getAccessTokenUrl()
Gets the access token URL.

Returns:
The access token URL

setAccessTokenUrl

public void setAccessTokenUrl(java.lang.String accessTokenUrl)
Sets the access token URL.

Parameters:
accessTokenUrl - The access token URL

getAuthoriseUrl

public java.lang.String getAuthoriseUrl()
Gets the authorise URL.

Returns:
The authorise URL

setAuthoriseUrl

public void setAuthoriseUrl(java.lang.String authoriseUrl)
Sets the authorise URL.

Parameters:
authoriseUrl - The authorise URL

buildConsumer

public OAuthConsumer buildConsumer()
Builds an OAuthConsumer based on these parameters.

Returns:
the consumer

buildProvider

public OAuthProvider buildProvider(OAuthConsumer consumer)
                            throws java.lang.IllegalArgumentException
Builds an OAuthProvider based on these parameters and a OAuth consumer consumer.

Parameters:
consumer - the consumer. Must not be null.
Returns:
the provider
Throws:
java.lang.IllegalArgumentException - if consumer is null

saveToPreferences

public void saveToPreferences(Preferences pref)
Saves these OAuth parameters to the given Preferences.

Parameters:
pref - The Preferences into which are saved these OAuth parameters with the prefix "oauth.settings"

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object


JOSM