org.restlet.ext.oauth
Enum Flow

java.lang.Object
  extended by java.lang.Enum<Flow>
      extended by org.restlet.ext.oauth.Flow
All Implemented Interfaces:
Serializable, Comparable<Flow>

public enum Flow
extends Enum<Flow>

Enum that lets clients retrieve tokens using different OAuth2 flows. Currently this class enables use of the NONE (Autonomous) flow and the PASSWORD flow. It also supports a client to refresh a token. The class defines one function doFlow that wraps the above specified ways of retrieving a token from an authorization server. Example:

 {
     @code
     OAuthParameters params = new OAuthParameters("clientId", "clientSecret");
     Flow f = Flow.NONE;
     User u = f.execute(params, null, null, null, null, null);
 
     f = Flow.PASSWORD;
     u = f.execute(params, null, null, "username", "password", null);
 
 }
 

Author:
Martin Svensson, Kristoffer Gronowski
See Also:
User Agent Flow, Autonomous Flow, Password Flow (Native Application)

Enum Constant Summary
NONE
           
PASSWORD
           
REFRESH
           
 
Method Summary
 OAuthUser execute(OAuthParameters params, String callbackUri, String state, String username, String password, String refreshToken)
          Executes a specific OAuth Flow (including token refresh).
 OAuthUser execute(OAuthParameters params, String callbackUri, String state, String username, String password, String refreshToken, Client client)
          Executes a specific OAuth Flow (including token refresh).
static Flow valueOf(String name)
          Returns the enum constant of this type with the specified name.
static Flow[] values()
          Returns an array containing the constants of this enum type, in the order they are declared.
 
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

NONE

public static final Flow NONE

PASSWORD

public static final Flow PASSWORD

REFRESH

public static final Flow REFRESH
Method Detail

values

public static Flow[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
for (Flow c : Flow.values())
    System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are declared

valueOf

public static Flow valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
IllegalArgumentException - if this enum type has no constant with the specified name
NullPointerException - if the argument is null

execute

public OAuthUser execute(OAuthParameters params,
                         String callbackUri,
                         String state,
                         String username,
                         String password,
                         String refreshToken)
Executes a specific OAuth Flow (including token refresh). Based on the chosen flow some of the parameters need to be set (see description). Upon successful authorization returns a new OAuthUser containing an access token that can be used for getting protected resources.

Parameters:
params - parameters specifying (clientId, clientSecret, scope etc). Used for all flows
callbackUri - callbackUri used for the userAgent flow. The server
state - used in the userAgent flow
username - used in the password flow
password - used in the password flow
refreshToken - the token to refresh, used in the refresh flow
Returns:
OAuthUser containing a token that can be used for access

execute

public OAuthUser execute(OAuthParameters params,
                         String callbackUri,
                         String state,
                         String username,
                         String password,
                         String refreshToken,
                         Client client)
Executes a specific OAuth Flow (including token refresh). Based on the chosen flow some of the parameters need to be set (see description). Upon successful authorization returns a new OAuthUser containing an access token that can be used for getting protected resources.

Parameters:
params - parameters specifying OAuth end point. Used for all flows.
callbackUri - callbackUri used for the userAgent flow.
state - state that should be returned by the Authorization server. Used in UserAgent flow.
username - used in the password flow.
password - used in the password flow.
refreshToken - the token to refresh, used in the refresh flow
client - provided client
Returns:
OAuthUser containing a token that can be used for access.


Copyright © 2005-2013 Restlet.