org.restlet.ext.oauth
Class OAuthServerResource

java.lang.Object
  extended by org.restlet.resource.Resource
      extended by org.restlet.resource.UniformResource
          extended by org.restlet.resource.ServerResource
              extended by org.restlet.ext.oauth.OAuthServerResource
Direct Known Subclasses:
AccessTokenServerResource, AuthorizationServerResource, AuthPageServerResource, ValidationServerResource

public abstract class OAuthServerResource
extends ServerResource

Base class for common resources used by the OAuth server side.

Author:
Kristoffer Gronowski

Field Summary
static String ACCESS_TOKEN
           
static String ASSERTION
           
static String ASSERTION_TYPE
           
static String AUTONOMOUS_USER
           
static String CLIENT_ID
           
static String CLIENT_SECRET
           
static String ClientCookieID
           
protected  ClientStore<?> clients
           
static String CODE
           
static String ERROR
           
static String ERROR_DESC
           
static String ERROR_URI
           
static String EXPIRES_IN
           
protected  org.restlet.ext.oauth.internal.TokenGenerator generator
           
static String GRANT_TYPE
           
protected static List<CacheDirective> noCache
           
protected static List<CacheDirective> noStore
           
static String OAUTH_TOKEN
           
static String PASSWORD
           
static String REDIR_URI
           
static String REFRESH_TOKEN
           
static String RESPONSE_TYPE
          MandatoryClient Request Authorization parameters.
static String SCOPE
           
static String STATE
           
static String TOKEN_SERVER_MAX_TIME_SEC
           
static String TOKEN_SERVER_TIME_SEC
           
protected  long tokenMaxTimeSec
           
protected  long tokenTimeSec
           
static String USERNAME
           
 
Constructor Summary
OAuthServerResource()
          Default constructor.
 
Method Summary
protected  void doInit()
           
protected  String generateAgentToken(String userId, Client client, String redirURL)
          Returns the agent token for the given user, client and redirection URI.
protected  String generateCode(String userId, Client client, String redirURL)
          Returns the code for the given user, client and redirection URI.
protected  String getParameter(String parameter, String defaultValue)
          Returns the value of the first parameter found with the given name.
protected  String[] parseScope(String scopes)
          Parses a " " separated list of scopes into an array.
 
Methods inherited from class org.restlet.resource.ServerResource
abort, commit, delete, delete, describeVariants, doCatch, doConditionalHandle, doError, doHandle, doHandle, doNegotiatedHandle, get, get, getAttribute, getInfo, getInfo, getOnSent, getPreferredVariant, getVariants, getVariants, handle, hasAnnotations, head, head, isAnnotated, isAutoCommitting, isCommitted, isConditional, isExisting, isInRole, isNegotiated, options, options, post, post, put, put, redirectPermanent, redirectPermanent, redirectSeeOther, redirectSeeOther, redirectTemporary, redirectTemporary, setAllowedMethods, setAnnotated, setAttribute, setAutoCommitting, setChallengeRequests, setCommitted, setConditional, setCookieSettings, setDimensions, setExisting, setLocationRef, setLocationRef, setNegotiated, setOnSent, setProxyChallengeRequests, setServerInfo, setStatus, setStatus, setStatus, setStatus, updateAllowedMethods, updateDimensions
 
Methods inherited from class org.restlet.resource.Resource
doError, doRelease, getAllowedMethods, getApplication, getChallengeRequests, getChallengeResponse, getClientInfo, getConditions, getConnegService, getContext, getConverterService, getCookies, getCookieSettings, getDimensions, getHostRef, getLocationRef, getLogger, getMatrix, getMatrixValue, getMaxForwards, getMetadataService, getMethod, getOriginalRef, getProtocol, getProxyChallengeRequests, getProxyChallengeResponse, getQuery, getQueryValue, getRanges, getReference, getReferrerRef, getRequest, getRequestAttributes, getRequestCacheDirectives, getRequestEntity, getResponse, getResponseAttributes, getResponseCacheDirectives, getResponseEntity, getRootRef, getServerInfo, getStatus, getStatusService, init, isConfidential, isLoggable, release, setApplication, setQueryValue, setRequest, setResponse, toObject, toRepresentation, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ACCESS_TOKEN

public static final String ACCESS_TOKEN
See Also:
Constant Field Values

ASSERTION

public static final String ASSERTION
See Also:
Constant Field Values

ASSERTION_TYPE

public static final String ASSERTION_TYPE
See Also:
Constant Field Values

AUTONOMOUS_USER

public static final String AUTONOMOUS_USER
See Also:
Constant Field Values

CLIENT_ID

public static final String CLIENT_ID
See Also:
Constant Field Values

CLIENT_SECRET

public static final String CLIENT_SECRET
See Also:
Constant Field Values

ClientCookieID

public static final String ClientCookieID
See Also:
Constant Field Values

CODE

public static final String CODE
See Also:
Constant Field Values

ERROR

public static final String ERROR
See Also:
Constant Field Values

ERROR_DESC

public static final String ERROR_DESC
See Also:
Constant Field Values

ERROR_URI

public static final String ERROR_URI
See Also:
Constant Field Values

EXPIRES_IN

public static final String EXPIRES_IN
See Also:
Constant Field Values

GRANT_TYPE

public static final String GRANT_TYPE
See Also:
Constant Field Values

noCache

protected static final List<CacheDirective> noCache

noStore

protected static final List<CacheDirective> noStore

OAUTH_TOKEN

public static final String OAUTH_TOKEN
See Also:
Constant Field Values

PASSWORD

public static final String PASSWORD
See Also:
Constant Field Values

REDIR_URI

public static final String REDIR_URI
See Also:
Constant Field Values

REFRESH_TOKEN

public static final String REFRESH_TOKEN
See Also:
Constant Field Values

RESPONSE_TYPE

public static final String RESPONSE_TYPE
MandatoryClient Request Authorization parameters.

See Also:
Constant Field Values

SCOPE

public static final String SCOPE
See Also:
Constant Field Values

STATE

public static final String STATE
See Also:
Constant Field Values

TOKEN_SERVER_MAX_TIME_SEC

public static final String TOKEN_SERVER_MAX_TIME_SEC
See Also:
Constant Field Values

TOKEN_SERVER_TIME_SEC

public static final String TOKEN_SERVER_TIME_SEC
See Also:
Constant Field Values

USERNAME

public static final String USERNAME
See Also:
Constant Field Values

clients

protected volatile ClientStore<?> clients

generator

protected volatile org.restlet.ext.oauth.internal.TokenGenerator generator

tokenMaxTimeSec

protected volatile long tokenMaxTimeSec

tokenTimeSec

protected volatile long tokenTimeSec
Constructor Detail

OAuthServerResource

public OAuthServerResource()
Default constructor.

Method Detail

doInit

protected void doInit()
               throws ResourceException
Overrides:
doInit in class Resource
Throws:
ResourceException

generateAgentToken

protected String generateAgentToken(String userId,
                                    Client client,
                                    String redirURL)
Returns the agent token for the given user, client and redirection URI.

Parameters:
userId - The identifier of the user.
client - The oAuth client.
redirURL - The redirection URI.
Returns:
The agent token for the given user, client and redirection URI.

generateCode

protected String generateCode(String userId,
                              Client client,
                              String redirURL)
Returns the code for the given user, client and redirection URI.

Parameters:
userId - The identifier of the user.
client - The oAuth client.
redirURL - The redirection URI.
Returns:
The code for the given user, client and redirection URI.

getParameter

protected String getParameter(String parameter,
                              String defaultValue)
Returns the value of the first parameter found with the given name.

Parameters:
parameter - The parameter name.
defaultValue - The default value to return if no matching parameter found or if the parameter has a null value.
Returns:
The value of the first parameter found with the given name or the default value.

parseScope

protected String[] parseScope(String scopes)
Parses a " " separated list of scopes into an array.

Parameters:
scopes - The " " separated list of scopes.
Returns:
The corresponding list of string of characters.


Copyright © 2005-2013 Restlet.