nl.surfnet.coin.api.service
Class MockServiceImpl

java.lang.Object
  extended by nl.surfnet.coin.api.service.MockServiceImpl
All Implemented Interfaces:
GroupProviderConfiguration, ConfigurableGroupProvider, GroupService, PersonService

@Component(value="mockService")
public class MockServiceImpl
extends Object
implements PersonService, GroupService, ConfigurableGroupProvider, GroupProviderConfiguration


Nested Class Summary
 
Nested classes/interfaces inherited from interface nl.surfnet.coin.api.GroupProviderConfiguration
GroupProviderConfiguration.Service
 
Field Summary
 
Fields inherited from interface nl.surfnet.coin.api.GroupProviderConfiguration
INTERNAL_GROUP_PATTERN
 
Constructor Summary
MockServiceImpl()
           
 
Method Summary
 void addGroup(Group20 group)
           
 void addPerson(Person person)
           
 void addPersonToGroup(String personId, String groupId)
           
 Group20Entry addUrnPartForGrouper(List<GroupProvider> groupProviders, Group20Entry group20Entry)
          Add to all the groups the conext urn part for grouper
 String cutOffUrnPartForGrouper(List<GroupProvider> groupProviders, String groupId)
          Strip the urn part off the groupId
 List<Person> enforceArp(String spEntityId, List<Person> persons)
          A no-op implementation that simply returns the same list (a new one actually, by contract)
 List<GroupProvider> getAllGroupProviders()
          Get all group providers
 List<GroupProvider> getAllowedGroupProviders(GroupProviderConfiguration.Service service, String spEntityId, List<GroupProvider> allGroupProviders)
          Get all GroupProviders that have the correct ACL configured based on the Service.
 GroupEntry getGroup(String userId, String groupId, String onBehalfOf)
          Get specific Group
 Group20 getGroup20(GroupProvider groupProvider, String userId, String groupId)
          Get a single group
 Group20Entry getGroup20(String userId, String groupId, String onBehalfOf)
          Get specific Group
 Group20Entry getGroup20Entry(GroupProvider groupProvider, String userId, int limit, int offset)
           
 GroupMembersEntry getGroupMembers(String groupId, String onBehalfOf, String spEntityId, Integer count, Integer startIndex, String sortBy)
          Get the group members of the given group.
 GroupMembersEntry getGroupMembersEntry(GroupProvider groupProvider, String onBehalfOf, String groupId, int limit, int offset)
          Gets group members with paginating information for the user's oauth configuration
 GroupEntry getGroups(String userId, String onBehalfOf, Integer count, Integer startIndex, String sortBy)
          Get Persons' Groups
 Group20Entry getGroups20(String userId, String onBehalfOf, Integer count, Integer startIndex, String sortBy)
          Get Persons' Groups
 Group20Entry getGroups20ByIds(String personId, String[] ids, Integer count, Integer startIndex)
          Get a list of Group20's by the given list of group ids
 PersonEntry getPerson(String userId, String loggedInUser, String spEntityId)
          Get the OpenSocial Person.
 boolean isActive()
           
 boolean isCallAllowed(GroupProviderConfiguration.Service service, String spEntityId, GroupProvider groupProvider)
          Is the call allowed? e.g.
 boolean isInternalGroup(String groupId)
          Verify if the given groupId is from an internal e.g.
protected  List<? extends Object> processQueryOptions(AbstractEntry parent, Integer count, Integer startIndex, String sortBy, List<? extends Object> entry)
          Filter/mangle a result set based on query parameters
 void reset()
           
 void setActive(boolean isActive)
           
 void sleep(long millSeconds)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MockServiceImpl

public MockServiceImpl()
Method Detail

getPerson

public PersonEntry getPerson(String userId,
                             String loggedInUser,
                             String spEntityId)
Description copied from interface: PersonService
Get the OpenSocial Person. Note that the onBehalfOf can be null.

Specified by:
getPerson in interface PersonService
Parameters:
userId - the unique identifier
loggedInUser - the unique identifier of the user on behalf of whom the request is made.
spEntityId - the entity that performs the request
Returns:
the PersonEntry

getGroupMembers

public GroupMembersEntry getGroupMembers(String groupId,
                                         String onBehalfOf,
                                         String spEntityId,
                                         Integer count,
                                         Integer startIndex,
                                         String sortBy)
Description copied from interface: PersonService
Get the group members of the given group. Note that the onBehalfOf can be null.

Specified by:
getGroupMembers in interface PersonService
Parameters:
groupId - String the unique identifier for the group
onBehalfOf - the unique identifier of the user on behalf of whom the request is made.
spEntityId - the entity that performs the request
count - nr of records to fetch
startIndex - first record nr.
sortBy - field to sort by.
Returns:
an ArrayList containing Person's

enforceArp

public List<Person> enforceArp(String spEntityId,
                               List<Person> persons)
A no-op implementation that simply returns the same list (a new one actually, by contract)

Specified by:
enforceArp in interface PersonService
Parameters:
spEntityId - the SP to use the ARP for
persons - the persons to enforce
Returns:
List of persons with the ARP applied.

getGroups

public GroupEntry getGroups(String userId,
                            String onBehalfOf,
                            Integer count,
                            Integer startIndex,
                            String sortBy)
Description copied from interface: GroupService
Get Persons' Groups

Specified by:
getGroups in interface GroupService
Parameters:
userId - the unique identifier
onBehalfOf - the unique identifier of the user that is going to make the request
count - nr of records to return
startIndex - first record of result set
sortBy - field to sort by
Returns:
List containing the Groups

getGroups20

public Group20Entry getGroups20(String userId,
                                String onBehalfOf,
                                Integer count,
                                Integer startIndex,
                                String sortBy)
Description copied from interface: GroupService
Get Persons' Groups

Specified by:
getGroups20 in interface GroupService
Parameters:
userId - the unique identifier
onBehalfOf - the unique identifier of the user that is going to make the request
count - nr of records to return
startIndex - first record of result set
sortBy - field to sort by
Returns:
List containing the Groups

getGroup

public GroupEntry getGroup(String userId,
                           String groupId,
                           String onBehalfOf)
Description copied from interface: GroupService
Get specific Group

Specified by:
getGroup in interface GroupService
Parameters:
userId - the unique identifier
groupId - the unique identifier
onBehalfOf - the unique identifier of the user that is going to make the request

getGroup20

public Group20Entry getGroup20(String userId,
                               String groupId,
                               String onBehalfOf)
Description copied from interface: GroupService
Get specific Group

Specified by:
getGroup20 in interface GroupService
Parameters:
userId - the unique identifier
groupId - the unique identifier
onBehalfOf - the unique identifier of the user that is going to make the request

getGroups20ByIds

public Group20Entry getGroups20ByIds(String personId,
                                     String[] ids,
                                     Integer count,
                                     Integer startIndex)
Description copied from interface: GroupService
Get a list of Group20's by the given list of group ids

Specified by:
getGroups20ByIds in interface GroupService
Parameters:
personId - the personId
ids - the array of ids
count - nr of records to return
startIndex - first record of result set
Returns:
the list of groups.

isActive

public boolean isActive()

setActive

public void setActive(boolean isActive)

reset

public void reset()
Specified by:
reset in interface ConfigurableGroupProvider

addPerson

public void addPerson(Person person)
Specified by:
addPerson in interface ConfigurableGroupProvider

addGroup

public void addGroup(Group20 group)
Specified by:
addGroup in interface ConfigurableGroupProvider

addPersonToGroup

public void addPersonToGroup(String personId,
                             String groupId)
Specified by:
addPersonToGroup in interface ConfigurableGroupProvider

processQueryOptions

protected List<? extends Object> processQueryOptions(AbstractEntry parent,
                                                     Integer count,
                                                     Integer startIndex,
                                                     String sortBy,
                                                     List<? extends Object> entry)
Filter/mangle a result set based on query parameters

Parameters:
parent - the root object; effectively this parameter is altered by setting the totalResults property
count - nr of records to fetch
startIndex - the start index
sortBy - field to sort by
entry - the result list of entries
Returns:

sleep

public void sleep(long millSeconds)
Specified by:
sleep in interface ConfigurableGroupProvider

isInternalGroup

public boolean isInternalGroup(String groupId)
Description copied from interface: GroupProviderConfiguration
Verify if the given groupId is from an internal e.g. grouper group

Specified by:
isInternalGroup in interface GroupProviderConfiguration
Parameters:
groupId - the group identifier
Returns:
boolean true id the group is external

getAllowedGroupProviders

public List<GroupProvider> getAllowedGroupProviders(GroupProviderConfiguration.Service service,
                                                    String spEntityId,
                                                    List<GroupProvider> allGroupProviders)
Description copied from interface: GroupProviderConfiguration
Get all GroupProviders that have the correct ACL configured based on the Service. Note that the SP entityId that is used to check against is retrieved from the SecurityContextHolder.getContext().getAuthentication().getPrincipal() context

Specified by:
getAllowedGroupProviders in interface GroupProviderConfiguration
Parameters:
service - the ACL to check for
spEntityId - the entity of the Service provider
allGroupProviders - all of the Group Providers
Returns:
All GroupProviders who are configured to

getAllGroupProviders

public List<GroupProvider> getAllGroupProviders()
Description copied from interface: GroupProviderConfiguration
Get all group providers

Specified by:
getAllGroupProviders in interface GroupProviderConfiguration
Returns:
all group providers

isCallAllowed

public boolean isCallAllowed(GroupProviderConfiguration.Service service,
                             String spEntityId,
                             GroupProvider groupProvider)
Description copied from interface: GroupProviderConfiguration
Is the call allowed? e.g. is there an ServiceProviderGroupAcl for the given GroupProviderConfiguration.Service and GroupProvider

Specified by:
isCallAllowed in interface GroupProviderConfiguration
Parameters:
service - the ACL to check for
spEntityId - the entity of the Service provider
groupProvider - the Group Provider
Returns:
true if Grouper is present

getGroupMembersEntry

public GroupMembersEntry getGroupMembersEntry(GroupProvider groupProvider,
                                              String onBehalfOf,
                                              String groupId,
                                              int limit,
                                              int offset)
Description copied from interface: GroupProviderConfiguration
Gets group members with paginating information for the user's oauth configuration

Specified by:
getGroupMembersEntry in interface GroupProviderConfiguration
Parameters:
groupProvider - GroupProvider for the settings
groupId - the groupId as we know it in SURFconext context (e.g. urn:collab:group:myuniversity.nl:testgroup)
limit - maximum number of items
offset - starting point for paging
Returns:
GroupMembersEntry, can be null

getGroup20Entry

public Group20Entry getGroup20Entry(GroupProvider groupProvider,
                                    String userId,
                                    int limit,
                                    int offset)
Specified by:
getGroup20Entry in interface GroupProviderConfiguration
Parameters:
groupProvider - GroupProvider for the settings
userId - the userId as we know it in SURFconext context (e.g. urn:collab:person:myuniversity.nl:testuser)
limit - maximum number of items
offset - starting point for paging
Returns:
Group20Entry, can be null

cutOffUrnPartForGrouper

public String cutOffUrnPartForGrouper(List<GroupProvider> groupProviders,
                                      String groupId)
Description copied from interface: GroupProviderConfiguration
Strip the urn part off the groupId

Specified by:
cutOffUrnPartForGrouper in interface GroupProviderConfiguration
Parameters:
groupProviders - all groupPrviders
groupId - the long version with the urn part of the Group
Returns:
a GroupId that Grouper understands

getGroup20

public Group20 getGroup20(GroupProvider groupProvider,
                          String userId,
                          String groupId)
Description copied from interface: GroupProviderConfiguration
Get a single group

Specified by:
getGroup20 in interface GroupProviderConfiguration
Parameters:
groupProvider - the GroupProvider
userId - the userId
groupId - the groupId
Returns:
Group20 can be null

addUrnPartForGrouper

public Group20Entry addUrnPartForGrouper(List<GroupProvider> groupProviders,
                                         Group20Entry group20Entry)
Description copied from interface: GroupProviderConfiguration
Add to all the groups the conext urn part for grouper

Specified by:
addUrnPartForGrouper in interface GroupProviderConfiguration
Parameters:
groupProviders - all groupProvider
group20Entry - the group20Entry with Grouper id's
Returns:
group20Entry the same group20Entry but now with long conext urn's


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