org.restlet.ext.oauth
Class OAuthUser

java.lang.Object
  extended by org.restlet.security.User
      extended by org.restlet.ext.oauth.OAuthUser
All Implemented Interfaces:
Principal

public class OAuthUser
extends User

Used for storing the OAuth access token in the OAuth security framework.

Author:
Kristoffer Gronowski

Constructor Summary
OAuthUser(String user, String accessToken)
          Constructor used for unlimited tokens.
OAuthUser(String user, String accessToken, String refreshToken, long expiresIn)
          Constructor used for tokens with a expiration time.
OAuthUser(User user, String accessToken)
          Constructor used for unlimited tokens.
OAuthUser(User user, String accessToken, String refreshToken, long expiresIn)
          Constructor used for tokens with a expiration time.
 
Method Summary
static OAuthUser createJson(Representation body)
          Converts successful JSON token body responses to OAuthUser.
static OAuthUser createJson(User toCopy, Representation body)
          Converts successful JSON token body responses to OAuthUser.
 String getAccessToken()
          Returns the access token.
 long getExpiresIn()
          The expiration delay.
 String getRefreshToken()
          Returns the refresh token.
 String getState()
          Returns the current state.
 boolean isExpireToken()
          Indicates if the current user has a refresh token, or not.
 void setState(String state)
          Sets the current state.
 
Methods inherited from class org.restlet.security.User
getEmail, getFirstName, getIdentifier, getLastName, getName, getSecret, setEmail, setFirstName, setIdentifier, setLastName, setSecret, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.security.Principal
equals, hashCode
 

Constructor Detail

OAuthUser

public OAuthUser(String user,
                 String accessToken)
Constructor used for unlimited tokens.

Parameters:
user - The user identifier.
accessToken - The access token.

OAuthUser

public OAuthUser(String user,
                 String accessToken,
                 String refreshToken,
                 long expiresIn)
Constructor used for tokens with a expiration time.

Parameters:
user - The user identifier.
accessToken - The access token.
refreshToken - The refresh token.
expiresIn - The expiration time.

OAuthUser

public OAuthUser(User user,
                 String accessToken)
Constructor used for unlimited tokens.

Parameters:
user - The User object, all fields will be copied (email, lastName, firstName, identifier).
accessToken - The access token.

OAuthUser

public OAuthUser(User user,
                 String accessToken,
                 String refreshToken,
                 long expiresIn)
Constructor used for tokens with a expiration time.

Parameters:
user - The User object, all fields will be copied (email, lastName, firstName, identifier).
accessToken - The access token.
refreshToken - The refresh token.
expiresIn - The expiration time.
Method Detail

createJson

public static OAuthUser createJson(Representation body)
Converts successful JSON token body responses to OAuthUser.

Parameters:
body - Representation containing a successful JSON body element.
Returns:
OAuthUser object containing accessToken, refreshToken and expiration time.

createJson

public static OAuthUser createJson(User toCopy,
                                   Representation body)
Converts successful JSON token body responses to OAuthUser.

Parameters:
toCopy - Copy user data from. Can be null
body - Representation containing a successful JSON body element.
Returns:
OAuthUser object containing accessToken, refreshToken and expiration time.

getAccessToken

public String getAccessToken()
Returns the access token.

Returns:
The access token.

getExpiresIn

public long getExpiresIn()
The expiration delay.

Returns:
The expiration delay.

getRefreshToken

public String getRefreshToken()
Returns the refresh token.

Returns:
The refresh token.

getState

public String getState()
Returns the current state.

Returns:
The current state.

isExpireToken

public boolean isExpireToken()
Indicates if the current user has a refresh token, or not.

Returns:
True if there is a refresh token.

setState

public void setState(String state)
Sets the current state.

Parameters:
state - The current state.


Copyright © 2005-2013 Restlet.