Restlet Framework 2.2.2
OSGi Environments

org.restlet.ext.oauth
Class OAuthProxy

java.lang.Object
  extended by org.restlet.Restlet
      extended by org.restlet.routing.Filter
          extended by 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

Field Summary
 
Fields inherited from class org.restlet.routing.Filter
CONTINUE, SKIP, STOP
 
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
 
Constructor Summary
OAuthProxy(Context ctx)
          Sets up an OauthProxy.
OAuthProxy(Context ctx, boolean useBasicSecret)
          Sets up an OAuthProxy.
OAuthProxy(Context ctx, boolean useBasicSecret, Client requestClient)
          Sets up an OAuthProxy.
 
Method Summary
protected  int beforeHandle(Request request, Response response)
           
protected  OAuthParameters createAuthorizationRequest()
           
protected  OAuthParameters createTokenRequest(String code)
           
 String getAuthorizationURI()
           
 String getClientId()
           
 String getClientSecret()
           
protected  Representation getErrorPage(Exception ex)
           
 String getRedirectURI()
           
 String[] getScope()
           
 String getTokenURI()
           
static String getVersion()
          Returns the current proxy's version.
 void setAuthorizationURI(String authorizationURI)
           
 void setClientId(String clientId)
           
 void setClientSecret(String clientSecret)
           
 void setRedirectURI(String redirectURI)
           
 void setScope(String[] scope)
           
 void setTokenURI(String tokenURI)
           
 
Methods inherited from class org.restlet.routing.Filter
afterHandle, doHandle, getNext, handle, hasNext, setNext, setNext, start, stop
 
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
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

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
Method Detail

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

Restlet Framework 2.2.2
OSGi Environments

Copyright © 2005-2014 Restlet.