nl.surfnet.coin.api.client
Class OpenConextOAuthClientImpl

java.lang.Object
  extended by nl.surfnet.coin.api.client.OpenConextOAuthClientImpl
All Implemented Interfaces:
OpenConextOAuthClient

public class OpenConextOAuthClientImpl
extends Object
implements OpenConextOAuthClient

Implementation of OpenConextOAuthClient


Constructor Summary
OpenConextOAuthClientImpl(OAuthEnvironment environment, OAuthRepository repository)
           
 
Method Summary
 String getAuthorizationUrl(OAuthVersion version)
          Get the authorization url
 List<Person> getGroupMembers(String groupId, String onBehalfOf)
          Get the group members of the given group.
 List<Group> getGroups(String userId, String onBehalfOf)
          Get Persons' Groups
 List<Group20> getGroups20(String userId, String onBehalfOf)
          Get Persons' Groups
 Person getPerson(String userId, String onBehalfOf)
          Get the OpenSocial Person.
 boolean isAccessTokenGranted(String userId)
          Is it possible to make OpenSocial requests for this user (as onBehalfOf).
 void oauthCallback(OAuthVersion version, javax.servlet.http.HttpServletRequest request)
          Clients who have requested a redirect to the authorization URL will be notified on the registered callback URL.
 void redirectToAuthorizationUrl(OAuthVersion version, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Clients who wants to make three-legged calls, but who do not have an access token yet for an user can redirect to the authorization URL.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OpenConextOAuthClientImpl

public OpenConextOAuthClientImpl(OAuthEnvironment environment,
                                 OAuthRepository repository)
Method Detail

isAccessTokenGranted

public boolean isAccessTokenGranted(String userId)
Description copied from interface: OpenConextOAuthClient
Is it possible to make OpenSocial requests for this user (as onBehalfOf). In principle clients need to make this check every time they want to make a three-legged oauth call.

Specified by:
isAccessTokenGranted in interface OpenConextOAuthClient
Parameters:
userId - the unique identifier
Returns:
true if there is a valid access token for the user

redirectToAuthorizationUrl

public void redirectToAuthorizationUrl(OAuthVersion version,
                                       javax.servlet.http.HttpServletRequest request,
                                       javax.servlet.http.HttpServletResponse response)
Description copied from interface: OpenConextOAuthClient
Clients who wants to make three-legged calls, but who do not have an access token yet for an user can redirect to the authorization URL. Note that the Response will be used to actually redirect to.

Specified by:
redirectToAuthorizationUrl in interface OpenConextOAuthClient
Parameters:
version - the OAuth protocol version to use
request - the HTTP request for obtaining the request token
response - the HTTP response for redirecting to the authorization url

getAuthorizationUrl

public String getAuthorizationUrl(OAuthVersion version)
Description copied from interface: OpenConextOAuthClient
Get the authorization url

Specified by:
getAuthorizationUrl in interface OpenConextOAuthClient
Parameters:
version - the oauth version
Returns:
the authorization url

oauthCallback

public void oauthCallback(OAuthVersion version,
                          javax.servlet.http.HttpServletRequest request)
Description copied from interface: OpenConextOAuthClient
Clients who have requested a redirect to the authorization URL will be notified on the registered callback URL. For extracting the oauth access token they will need to 'forward' the call back request to this method.

Specified by:
oauthCallback in interface OpenConextOAuthClient
Parameters:
version - the OAuth protocol version to use
request - the HTTP request for obtaining the request token

getPerson

public Person getPerson(String userId,
                        String onBehalfOf)
Description copied from interface: OpenConextOAuthClient
Get the OpenSocial Person. Note that the onBehalfOf is only necessary if this is a three-legged call (e.g. there is an access token for the onBehalfOf). For two legged calls the onBehalfOf can be null.

Specified by:
getPerson in interface OpenConextOAuthClient
Parameters:
userId - the unique identifier
onBehalfOf - the unique identifier of the user that is going to make the request
Returns:
the Person

getGroupMembers

public List<Person> getGroupMembers(String groupId,
                                    String onBehalfOf)
Description copied from interface: OpenConextOAuthClient
Get the group members of the given group. Note that the onBehalfOf is only necessary if this is a three-legged call (e.g. there is an access token for the onBehalfOf). For two legged calls the onBehalfOf can be null.

Specified by:
getGroupMembers in interface OpenConextOAuthClient
Parameters:
groupId - String the unique identifier for the group
onBehalfOf - String the unique identifier of the user that is going to make the request
Returns:
an ArrayList containing Person's

getGroups

public List<Group> getGroups(String userId,
                             String onBehalfOf)
Description copied from interface: OpenConextOAuthClient
Get Persons' Groups

Specified by:
getGroups in interface OpenConextOAuthClient
Parameters:
userId - the unique identifier
onBehalfOf - the unique identifier of the user that is going to make the request
Returns:
List containing the Groups

getGroups20

public List<Group20> getGroups20(String userId,
                                 String onBehalfOf)
Description copied from interface: OpenConextOAuthClient
Get Persons' Groups

Specified by:
getGroups20 in interface OpenConextOAuthClient
Parameters:
userId - the unique identifier
onBehalfOf - the unique identifier of the user that is going to make the request
Returns:
List containing the Groups


Copyright © 2009-2012 SURFnet bv, The Netherlands. All Rights Reserved.