org.restlet.ext.oauth
Class OAuthProxy
java.lang.Object
org.restlet.Restlet
org.restlet.routing.Filter
org.restlet.ext.oauth.OAuthProxy
- All Implemented Interfaces:
- OAuthResourceDefs, Uniform
public class OAuthProxy
- extends Filter
- implements OAuthResourceDefs
A restlet filter for initiating a web server flow or comparable to OAuth 2.0
3-legged authorization.
On successful execution a working OAuth token will be maintained. It is
recommended to put a ServerResource after this filter to display to the end
user on successful service setup.
The following example shows how to gain an access token that will be
available for "DummyResource" to use to access some remote protected resource
{
@code
OAuthProxy proxy = new OauthProxy(getContext(), true);
proxy.setClientId("clientId");
proxy.setClientSecret("clientSecret");
proxy.setRedirectURI("callbackURI");
proxy.setAuthorizationURI("authURI");
proxy.setTokenURI("tokenURI");
proxy.setNext(DummyResource.class);
router.attach("/write", write);
}
- Author:
- Kristoffer Gronowski, Shotaro Uchida
- See Also:
OAuthParameters
Fields inherited from interface org.restlet.ext.oauth.OAuthResourceDefs |
ACCESS_TOKEN, CLIENT_ID, CLIENT_SECRET, CODE, ERROR, ERROR_DESC, ERROR_URI, EXPIRES_IN, GRANT_TYPE, PASSWORD, REDIR_URI, REFRESH_TOKEN, RESPONSE_TYPE, SCOPE, STATE, TOKEN_TYPE, TOKEN_TYPE_BEARER, TOKEN_TYPE_MAC, USERNAME |
Methods inherited from class org.restlet.Restlet |
createFinder, finalize, getApplication, getAuthor, getContext, getDescription, getFinderClass, getLogger, getName, getOwner, handle, handle, handle, isStarted, isStopped, setAuthor, setContext, setDescription, setFinderClass, setName, setOwner |
OAuthProxy
public OAuthProxy(Context ctx)
- Sets up an OauthProxy. Defaults to form based authentication and not http
basic.
- Parameters:
ctx
- The Restlet context.
OAuthProxy
public OAuthProxy(Context ctx,
boolean useBasicSecret)
- Sets up an OAuthProxy.
- Parameters:
useBasicSecret
- If true use http basic authentication otherwise use form
based.ctx
- The Restlet context.
OAuthProxy
public OAuthProxy(Context ctx,
boolean useBasicSecret,
Client requestClient)
- Sets up an OAuthProxy.
- Parameters:
useBasicSecret
- If true use http basic authentication otherwise use form
based.ctx
- The Restlet context.requestClient
- A predefined client that will be used for remote client
request. Useful when you need to set e.g. SSL initialization
parameters
getVersion
public static String getVersion()
- Returns the current proxy's version.
- Returns:
- The current proxy's version.
createAuthorizationRequest
protected OAuthParameters createAuthorizationRequest()
createTokenRequest
protected OAuthParameters createTokenRequest(String code)
getErrorPage
protected Representation getErrorPage(Exception ex)
beforeHandle
protected int beforeHandle(Request request,
Response response)
- Overrides:
beforeHandle
in class Filter
getClientId
public String getClientId()
- Returns:
- the clientId
setClientId
public void setClientId(String clientId)
- Parameters:
clientId
- the clientId to set
getClientSecret
public String getClientSecret()
- Returns:
- the clientSecret
setClientSecret
public void setClientSecret(String clientSecret)
- Parameters:
clientSecret
- the clientSecret to set
getRedirectURI
public String getRedirectURI()
- Returns:
- the redirectURI
setRedirectURI
public void setRedirectURI(String redirectURI)
- Parameters:
redirectURI
- the redirectURI to set
getScope
public String[] getScope()
- Returns:
- the scope
setScope
public void setScope(String[] scope)
- Parameters:
scope
- the scope to set
getAuthorizationURI
public String getAuthorizationURI()
- Returns:
- the authorizationURI
setAuthorizationURI
public void setAuthorizationURI(String authorizationURI)
- Parameters:
authorizationURI
- the authorizationURI to set
getTokenURI
public String getTokenURI()
- Returns:
- the tokenURI
setTokenURI
public void setTokenURI(String tokenURI)
- Parameters:
tokenURI
- the tokenURI to set
Copyright © 2005-2014 Restlet.