edu.internet2.middleware.grouper
Class GrouperSourceAdapter

java.lang.Object
  extended by edu.internet2.middleware.subject.provider.BaseSourceAdapter
      extended by edu.internet2.middleware.grouper.GrouperSourceAdapter
All Implemented Interfaces:
edu.internet2.middleware.subject.Source
Direct Known Subclasses:
EntitySourceAdapter

public class GrouperSourceAdapter
extends edu.internet2.middleware.subject.provider.BaseSourceAdapter

Source adapter for using Grouper groups as I2MI Subjects.

This is an adapter I2MI Subjects of type group. It allows groups within a Group Groups Registry to be referenced as I2MI Subjects.

To use, add the following to your sources.xml file:

 <source adapterClass="edu.internet2.middleware.grouper.GrouperSourceAdapter">
   <id>g:gsa</id>
   <name>Grouper: Grouper Source Adapter</name>
   <type>group</type>
 </source>
 

Version:
$Id: GrouperSourceAdapter.java,v 1.31 2009-08-12 04:52:21 mchyzer Exp $
Author:
blair christensen.

Field Summary
static boolean failOnSearchForTesting
          for testing if we should fail on testing
 
Constructor Summary
GrouperSourceAdapter()
          Allocates new GrouperSourceAdapter.
GrouperSourceAdapter(String id, String name)
          Allocates new GrouperSourceAdapter.
 
Method Summary
 void checkConfig()
           
static void clearSearchForGroupsWithReadPrivilege()
          put this in a finally block to clear that we are searching for groups with certain privileges
 Integer getMaxPage()
          max Page size
 edu.internet2.middleware.subject.Subject getSubject(String id)
          Deprecated. 
 edu.internet2.middleware.subject.Subject getSubject(String id, boolean exceptionIfNotFound)
          Get a Group subject by UUID.
 edu.internet2.middleware.subject.Subject getSubjectByIdentifier(String name)
          Deprecated. 
 edu.internet2.middleware.subject.Subject getSubjectByIdentifier(String name, boolean exceptionIfNull)
          Gets a Group subject by its name.
 Map<Integer,String> getSubjectIdentifierAttributes()
           
 Map<String,edu.internet2.middleware.subject.Subject> getSubjectsByIdentifiers(Collection<String> identifiers)
           
 Map<String,edu.internet2.middleware.subject.Subject> getSubjectsByIds(Collection<String> ids)
           
 Set getSubjectTypes()
          Gets the SubjectTypes supported by this source.
static String groupSourceId()
          return the group source id
 void init()
          Initializes the Grouper source adapter.
static GrouperSession internal_getSessionOrRootForSubjectFinder()
           
 String printConfig()
           
 Set<edu.internet2.middleware.subject.Subject> search(String searchValue)
          
static boolean searchForGroupsWithReadPrivilege()
          if searching for groups with read privilege
static void searchForGroupsWithReadPrivilege(boolean searchForRead)
          when doing a subject search, search for groups with privileges
 edu.internet2.middleware.subject.SearchPageResult searchPage(String searchValue)
           
 Set<TypeOfGroup> typeOfGroups()
          type of groups to search on
 
Methods inherited from class edu.internet2.middleware.subject.provider.BaseSourceAdapter
addAttribute, addInitParam, addInternalAttribute, addSubjectType, equals, getId, getInitParam, getInternalAttributes, getName, getSearchAttributes, getSortAttributes, getSubject, getSubjectByIdentifier, getSubjectByIdOrIdentifier, getSubjectByIdOrIdentifier, getSubjectsByIdentifiers, getSubjectsByIds, getSubjectsByIdsOrIdentifiers, getSubjectsByIdsOrIdentifiers, getSubjectStatusConfig, getSubjectType, hashCode, initParams, loadSearch, removeInitParam, resultSetLimit, search, searchPage, setId, setName, setSearchAttributes, setSortAttributes, setSubjectIdentifierAttributes
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

failOnSearchForTesting

public static boolean failOnSearchForTesting
for testing if we should fail on testing

Constructor Detail

GrouperSourceAdapter

public GrouperSourceAdapter()
Allocates new GrouperSourceAdapter.


GrouperSourceAdapter

public GrouperSourceAdapter(String id,
                            String name)
Allocates new GrouperSourceAdapter.

Parameters:
id -
name -
Method Detail

searchForGroupsWithReadPrivilege

public static void searchForGroupsWithReadPrivilege(boolean searchForRead)
when doing a subject search, search for groups with privileges

Parameters:
privileges1 -

searchForGroupsWithReadPrivilege

public static boolean searchForGroupsWithReadPrivilege()
if searching for groups with read privilege

Returns:
if searching

clearSearchForGroupsWithReadPrivilege

public static void clearSearchForGroupsWithReadPrivilege()
put this in a finally block to clear that we are searching for groups with certain privileges


getSubject

@Deprecated
public edu.internet2.middleware.subject.Subject getSubject(String id)
                                                    throws edu.internet2.middleware.subject.SubjectNotFoundException
Deprecated. 

Get a Group subject by UUID.

 // Use it within the Grouper API
 try {
   Subject subj = SubjectFinder.getSubject(uuid, "group");
 } 
 catch (SubjectNotFoundException e) {
   // Subject not found
 }

 // Use it directly
 try {
   Subject subj = source.getSubject(uuid, "group");
 } 
 catch (SubjectNotFoundException e) {
   // Subject not found
 }
 

Specified by:
getSubject in interface edu.internet2.middleware.subject.Source
Specified by:
getSubject in class edu.internet2.middleware.subject.provider.BaseSourceAdapter
Parameters:
id - Group UUID
Returns:
A Subject
Throws:
edu.internet2.middleware.subject.SubjectNotFoundException

getSubject

public edu.internet2.middleware.subject.Subject getSubject(String id,
                                                           boolean exceptionIfNotFound)
                                                    throws edu.internet2.middleware.subject.SubjectNotFoundException
Get a Group subject by UUID.

 // Use it within the Grouper API
 try {
   Subject subj = SubjectFinder.getSubject(uuid, "group");
 } 
 catch (SubjectNotFoundException e) {
   // Subject not found
 }

 // Use it directly
 try {
   Subject subj = source.getSubject(uuid, "group");
 } 
 catch (SubjectNotFoundException e) {
   // Subject not found
 }
 

Specified by:
getSubject in interface edu.internet2.middleware.subject.Source
Overrides:
getSubject in class edu.internet2.middleware.subject.provider.BaseSourceAdapter
Parameters:
id - Group UUID
exceptionIfNotFound -
Returns:
A Subject
Throws:
edu.internet2.middleware.subject.SubjectNotFoundException

getSubjectByIdentifier

@Deprecated
public edu.internet2.middleware.subject.Subject getSubjectByIdentifier(String name)
                                                                throws edu.internet2.middleware.subject.SubjectNotFoundException
Deprecated. 

Gets a Group subject by its name.

 // Use it within the Grouper API
 try {
   Subject subj = SubjectFinder.getSubjectByIdentifier(name, "group");
 }
 catch (SubjectNotFoundException e) {
   // Subject not found
 }

 // Use it directly
 try {
   Subject subj = source.getSubjectByIdentifier(name, "group");
 } 
 catch (SubjectNotFoundException e) {
   // Subject not found
 }
 

Specified by:
getSubjectByIdentifier in interface edu.internet2.middleware.subject.Source
Specified by:
getSubjectByIdentifier in class edu.internet2.middleware.subject.provider.BaseSourceAdapter
Parameters:
name - Group name
Returns:
A Subject
Throws:
edu.internet2.middleware.subject.SubjectNotFoundException

getSubjectsByIdentifiers

public Map<String,edu.internet2.middleware.subject.Subject> getSubjectsByIdentifiers(Collection<String> identifiers)
Specified by:
getSubjectsByIdentifiers in interface edu.internet2.middleware.subject.Source
Overrides:
getSubjectsByIdentifiers in class edu.internet2.middleware.subject.provider.BaseSourceAdapter
See Also:
Source.getSubjectsByIdentifiers(Collection)

getSubjectsByIds

public Map<String,edu.internet2.middleware.subject.Subject> getSubjectsByIds(Collection<String> ids)
Specified by:
getSubjectsByIds in interface edu.internet2.middleware.subject.Source
Overrides:
getSubjectsByIds in class edu.internet2.middleware.subject.provider.BaseSourceAdapter
See Also:
Source.getSubjectsByIds(Collection)

getSubjectByIdentifier

public edu.internet2.middleware.subject.Subject getSubjectByIdentifier(String name,
                                                                       boolean exceptionIfNull)
                                                                throws edu.internet2.middleware.subject.SubjectNotFoundException
Gets a Group subject by its name.

 // Use it within the Grouper API
 try {
   Subject subj = SubjectFinder.getSubjectByIdentifier(name, "group");
 }
 catch (SubjectNotFoundException e) {
   // Subject not found
 }

 // Use it directly
 try {
   Subject subj = source.getSubjectByIdentifier(name, "group");
 } 
 catch (SubjectNotFoundException e) {
   // Subject not found
 }
 

Specified by:
getSubjectByIdentifier in interface edu.internet2.middleware.subject.Source
Overrides:
getSubjectByIdentifier in class edu.internet2.middleware.subject.provider.BaseSourceAdapter
Parameters:
name - Group name
exceptionIfNull -
Returns:
A Subject
Throws:
edu.internet2.middleware.subject.SubjectNotFoundException

getSubjectTypes

public Set getSubjectTypes()
Gets the SubjectTypes supported by this source.
 SourceAdapter  sa    = new GrouperSourceAdapter();
 Set            types = sa.getSubjectTypes();
 

Specified by:
getSubjectTypes in interface edu.internet2.middleware.subject.Source
Overrides:
getSubjectTypes in class edu.internet2.middleware.subject.provider.BaseSourceAdapter
Returns:
Subject types supported by this source.

init

public void init()
          throws edu.internet2.middleware.subject.SourceUnavailableException
Initializes the Grouper source adapter.

No initialization is currently performed by this adapter.

Specified by:
init in interface edu.internet2.middleware.subject.Source
Specified by:
init in class edu.internet2.middleware.subject.provider.BaseSourceAdapter
Throws:
edu.internet2.middleware.subject.SourceUnavailableException

groupSourceId

public static String groupSourceId()
return the group source id

Returns:
the source id for the group source

typeOfGroups

public Set<TypeOfGroup> typeOfGroups()
type of groups to search on

Returns:
type of groups

internal_getSessionOrRootForSubjectFinder

public static GrouperSession internal_getSessionOrRootForSubjectFinder()
Returns:
session

checkConfig

public void checkConfig()
See Also:
Source.checkConfig()

printConfig

public String printConfig()
See Also:
Source.printConfig()

getMaxPage

public Integer getMaxPage()
max Page size

Returns:
the maxPage

search

public Set<edu.internet2.middleware.subject.Subject> search(String searchValue)

Specified by:
search in interface edu.internet2.middleware.subject.Source
Specified by:
search in class edu.internet2.middleware.subject.provider.BaseSourceAdapter

searchPage

public edu.internet2.middleware.subject.SearchPageResult searchPage(String searchValue)
Specified by:
searchPage in interface edu.internet2.middleware.subject.Source
Overrides:
searchPage in class edu.internet2.middleware.subject.provider.BaseSourceAdapter
See Also:
BaseSourceAdapter.searchPage(java.lang.String)

getSubjectIdentifierAttributes

public Map<Integer,String> getSubjectIdentifierAttributes()
Specified by:
getSubjectIdentifierAttributes in interface edu.internet2.middleware.subject.Source
Overrides:
getSubjectIdentifierAttributes in class edu.internet2.middleware.subject.provider.BaseSourceAdapter
See Also:
Source.getSubjectIdentifierAttributes()