public class OsmOAuthAuthorizationClient extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
private static class |
OsmOAuthAuthorizationClient.SessionId |
| Modifier and Type | Field and Description |
|---|---|
private boolean |
canceled |
private HttpClient |
connection |
private oauth.signpost.OAuthConsumer |
consumer |
private OAuthParameters |
oauthProviderParameters |
private oauth.signpost.OAuthProvider |
provider |
| Constructor and Description |
|---|
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. |
| Modifier and Type | Method and Description |
|---|---|
protected void |
authenticateOsmSession(OsmOAuthAuthorizationClient.SessionId sessionId,
java.lang.String userName,
java.lang.String password) |
void |
authorise(OAuthToken requestToken,
java.lang.String userName,
java.lang.String password,
OsmPrivileges privileges,
ProgressMonitor monitor)
Automatically authorises a request token for a set of privileges.
|
protected static 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() |
protected java.lang.String |
extractToken() |
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) |
private final OAuthParameters oauthProviderParameters
private final oauth.signpost.OAuthConsumer consumer
private final oauth.signpost.OAuthProvider provider
private boolean canceled
private HttpClient connection
public OsmOAuthAuthorizationClient(OAuthParameters parameters)
parameters.parameters - the OAuth parameters. Must not be null.java.lang.IllegalArgumentException - if parameters is nullpublic OsmOAuthAuthorizationClient(OAuthParameters parameters, OAuthToken requestToken)
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 nulljava.lang.IllegalArgumentException - if requestToken is nullpublic void cancel()
public OAuthToken getRequestToken(ProgressMonitor monitor) throws OsmOAuthAuthorizationException, OsmTransferCanceledException
monitor - a progress monitor. Defaults to NullProgressMonitor.INSTANCE if nullOsmOAuthAuthorizationException - if something goes wrong when retrieving the request tokenOsmTransferCanceledException - 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 nullOsmOAuthAuthorizationException - if something goes wrong when retrieving the request tokenOsmTransferCanceledException - if the user canceled the requestgetRequestToken(ProgressMonitor)public java.lang.String getAuthoriseUrl(OAuthToken requestToken)
requestToken - the request tokenprotected java.lang.String extractToken()
protected OsmOAuthAuthorizationClient.SessionId extractOsmSession() throws java.io.IOException, java.net.URISyntaxException
java.io.IOExceptionjava.net.URISyntaxExceptionprotected static java.lang.String buildPostRequest(java.util.Map<java.lang.String,java.lang.String> parameters)
protected OsmOAuthAuthorizationClient.SessionId fetchOsmWebsiteSessionId() throws OsmOAuthAuthorizationException
OsmOAuthAuthorizationException - if something went wrongprotected void fetchOAuthToken(OsmOAuthAuthorizationClient.SessionId sessionId, OAuthToken requestToken) throws OsmOAuthAuthorizationException
sessionId - session idrequestToken - request tokenOsmOAuthAuthorizationException - if something went wrongprotected void authenticateOsmSession(OsmOAuthAuthorizationClient.SessionId sessionId, java.lang.String userName, java.lang.String password) throws OsmLoginFailedException
OsmLoginFailedExceptionprotected void logoutOsmSession(OsmOAuthAuthorizationClient.SessionId sessionId) throws OsmOAuthAuthorizationException
OsmOAuthAuthorizationExceptionprotected void sendAuthorisationRequest(OsmOAuthAuthorizationClient.SessionId sessionId, OAuthToken requestToken, OsmPrivileges privileges) throws OsmOAuthAuthorizationException
OsmOAuthAuthorizationExceptionpublic void authorise(OAuthToken requestToken, java.lang.String userName, java.lang.String password, OsmPrivileges privileges, ProgressMonitor monitor) throws OsmOAuthAuthorizationException, OsmTransferCanceledException
requestToken - the request token. Must not be null.userName - the OSM user name. Must not be null.password - 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 nulljava.lang.IllegalArgumentException - if requestToken is nulljava.lang.IllegalArgumentException - if osmUserName is nulljava.lang.IllegalArgumentException - if osmPassword is nulljava.lang.IllegalArgumentException - if privileges is nullOsmOAuthAuthorizationException - if the authorisation failsOsmTransferCanceledException - if the task is canceled by the user