net.netheos.pcsapi.oauth
Class OAuth2SessionManager

java.lang.Object
  extended by net.netheos.pcsapi.oauth.SessionManager<OAuth2Credentials>
      extended by net.netheos.pcsapi.oauth.OAuth2SessionManager
All Implemented Interfaces:
HttpExecutor

public class OAuth2SessionManager
extends SessionManager<OAuth2Credentials>

OAuth2 session manager (used by most providers).


Field Summary
 
Fields inherited from class net.netheos.pcsapi.oauth.SessionManager
userCredentials
 
Constructor Summary
OAuth2SessionManager(String authorizeUrl, String accessTokenUrl, String refreshTokenUrl, boolean scopeInAuthorization, Character scopePermsSeparator, StorageBuilder builder)
           
 
Method Summary
 CResponse execute(org.apache.http.client.methods.HttpUriRequest request)
          Execute the request
 void refreshToken()
          Refreshes access token after expiration (before sending request) thanks to the refresh token.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OAuth2SessionManager

public OAuth2SessionManager(String authorizeUrl,
                            String accessTokenUrl,
                            String refreshTokenUrl,
                            boolean scopeInAuthorization,
                            Character scopePermsSeparator,
                            StorageBuilder builder)
Method Detail

execute

public CResponse execute(org.apache.http.client.methods.HttpUriRequest request)
Description copied from interface: HttpExecutor
Execute the request

Parameters:
request - The http request
Returns:
The http response

refreshToken

public void refreshToken()
                  throws CStorageException
Refreshes access token after expiration (before sending request) thanks to the refresh token. The bew access token is then stored in this manager.

Method is synchronized so that no two threads will attempt to refresh at the same time. If a locked thread sees that token has already been refreshed, no refresh is attempted either.

Not all providers support tokens refresh (ex : CloudMe).

Throws:
CStorageException


Copyright © 2014. All Rights Reserved.