|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.openstreetmap.josm.gui.oauth.OsmOAuthAuthorizationClient
public class OsmOAuthAuthorizationClient
An OAuth 1.0 authorization client.
Nested Class Summary | |
---|---|
private static class |
OsmOAuthAuthorizationClient.SessionId
|
Field Summary | |
---|---|
private boolean |
canceled
|
private java.net.HttpURLConnection |
connection
|
private OAuthConsumer |
consumer
|
private OAuthParameters |
oauthProviderParameters
|
private OAuthProvider |
provider
|
Constructor Summary | |
---|---|
OsmOAuthAuthorizationClient()
Creates a new authorisation client with default OAuth parameters |
|
OsmOAuthAuthorizationClient(OAuthParameters parameters)
Creates a new authorisation client with the parameters parameters . |
|
OsmOAuthAuthorizationClient(OAuthParameters parameters,
OAuthToken requestToken)
Creates a new authorisation client with the parameters parameters
and an already known Request Token. |
Method Summary | |
---|---|
protected void |
authenticateOsmSession(OsmOAuthAuthorizationClient.SessionId sessionId,
java.lang.String userName,
java.lang.String password)
|
void |
authorise(OAuthToken requestToken,
java.lang.String osmUserName,
java.lang.String osmPassword,
OsmPrivileges privileges,
ProgressMonitor monitor)
Automatically authorises a request token for a set of privileges. |
java.lang.String |
buildOsmLoginUrl()
Derives the OSM login URL from the OAuth Authorization Website URL |
protected java.lang.String |
buildOsmLogoutUrl()
Derives the OSM logout URL from the OAuth Authorization Website URL |
protected java.lang.String |
buildPostRequest(java.util.Map<java.lang.String,java.lang.String> parameters)
|
void |
cancel()
Cancels the current OAuth operation. |
protected OsmOAuthAuthorizationClient.SessionId |
extractOsmSession(java.net.HttpURLConnection connection)
|
protected java.lang.String |
extractToken(java.net.HttpURLConnection connection)
|
protected void |
fetchOAuthToken(OsmOAuthAuthorizationClient.SessionId sessionId,
OAuthToken requestToken)
Submits a request to the OSM website for a OAuth form. |
protected OsmOAuthAuthorizationClient.SessionId |
fetchOsmWebsiteSessionId()
Submits a request to the OSM website for a login form. |
OAuthToken |
getAccessToken(ProgressMonitor monitor)
Submits a request for an Access Token to the Access Token Endpoint Url of the OAuth Service Provider and replies the request token. |
java.lang.String |
getAuthoriseUrl(OAuthToken requestToken)
Builds the authorise URL for a given Request Token. |
OAuthToken |
getRequestToken(ProgressMonitor monitor)
Submits a request for a Request Token to the Request Token Endpoint Url of the OAuth Service Provider and replies the request token. |
protected void |
logoutOsmSession(OsmOAuthAuthorizationClient.SessionId sessionId)
|
protected void |
sendAuthorisationRequest(OsmOAuthAuthorizationClient.SessionId sessionId,
OAuthToken requestToken,
OsmPrivileges privileges)
|
protected void |
setHttpRequestParameters(java.net.HttpURLConnection connection)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private final OAuthParameters oauthProviderParameters
private final OAuthConsumer consumer
private final OAuthProvider provider
private boolean canceled
private java.net.HttpURLConnection connection
Constructor Detail |
---|
public OsmOAuthAuthorizationClient()
public OsmOAuthAuthorizationClient(OAuthParameters parameters) throws java.lang.IllegalArgumentException
parameters
.
parameters
- the OAuth parameters. Must not be null.
java.lang.IllegalArgumentException
- if parameters is nullpublic OsmOAuthAuthorizationClient(OAuthParameters parameters, OAuthToken requestToken) throws java.lang.IllegalArgumentException
parameters
and an already known Request Token.
parameters
- the OAuth parameters. Must not be null.requestToken
- the request token. Must not be null.
java.lang.IllegalArgumentException
- if parameters is null
java.lang.IllegalArgumentException
- if requestToken is nullMethod Detail |
---|
public void cancel()
public OAuthToken getRequestToken(ProgressMonitor monitor) throws OsmOAuthAuthorizationException, OsmTransferCanceledException
monitor
- a progress monitor. Defaults to NullProgressMonitor.INSTANCE
if null
OsmOAuthAuthorizationException
- if something goes wrong when retrieving the request token
OsmTransferCanceledException
- if the user canceled the requestpublic OAuthToken getAccessToken(ProgressMonitor monitor) throws OsmOAuthAuthorizationException, OsmTransferCanceledException
getRequestToken(ProgressMonitor)
first.
monitor
- a progress monitor. Defaults to NullProgressMonitor.INSTANCE
if null
OsmOAuthAuthorizationException
- if something goes wrong when retrieving the request token
OsmTransferCanceledException
- if the user canceled the requestgetRequestToken(ProgressMonitor)
public java.lang.String getAuthoriseUrl(OAuthToken requestToken)
requestToken
- the request token
protected java.lang.String extractToken(java.net.HttpURLConnection connection)
protected OsmOAuthAuthorizationClient.SessionId extractOsmSession(java.net.HttpURLConnection connection)
protected java.lang.String buildPostRequest(java.util.Map<java.lang.String,java.lang.String> parameters) throws OsmOAuthAuthorizationException
OsmOAuthAuthorizationException
public java.lang.String buildOsmLoginUrl() throws OsmOAuthAuthorizationException
OsmOAuthAuthorizationException
- if something went wrong, in particular if the
URLs are malformedprotected java.lang.String buildOsmLogoutUrl() throws OsmOAuthAuthorizationException
OsmOAuthAuthorizationException
- if something went wrong, in particular if the
URLs are malformedprotected OsmOAuthAuthorizationClient.SessionId fetchOsmWebsiteSessionId() throws OsmOAuthAuthorizationException
OsmOAuthAuthorizationException
- if something went wrongprotected void fetchOAuthToken(OsmOAuthAuthorizationClient.SessionId sessionId, OAuthToken requestToken) throws OsmOAuthAuthorizationException
OsmOAuthAuthorizationException
- if something went wrongprotected void authenticateOsmSession(OsmOAuthAuthorizationClient.SessionId sessionId, java.lang.String userName, java.lang.String password) throws OsmLoginFailedException
OsmLoginFailedException
protected void logoutOsmSession(OsmOAuthAuthorizationClient.SessionId sessionId) throws OsmOAuthAuthorizationException
OsmOAuthAuthorizationException
protected void sendAuthorisationRequest(OsmOAuthAuthorizationClient.SessionId sessionId, OAuthToken requestToken, OsmPrivileges privileges) throws OsmOAuthAuthorizationException
OsmOAuthAuthorizationException
protected void setHttpRequestParameters(java.net.HttpURLConnection connection)
public void authorise(OAuthToken requestToken, java.lang.String osmUserName, java.lang.String osmPassword, OsmPrivileges privileges, ProgressMonitor monitor) throws java.lang.IllegalArgumentException, OsmOAuthAuthorizationException, OsmTransferCanceledException
requestToken
- the request token. Must not be null.osmUserName
- the OSM user name. Must not be null.osmPassword
- the OSM password. Must not be null.privileges
- the set of privileges. Must not be null.monitor
- a progress monitor. Defaults to NullProgressMonitor.INSTANCE
if null
java.lang.IllegalArgumentException
- if requestToken is null
java.lang.IllegalArgumentException
- if osmUserName is null
java.lang.IllegalArgumentException
- if osmPassword is null
java.lang.IllegalArgumentException
- if privileges is null
OsmOAuthAuthorizationException
- if the authorisation fails
OsmTransferCanceledException
- if the task is canceled by the user
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |