PersonDirectory 2.4
PersonDirectory in uPortal 2.4 and Earlier
PersonDirectory as public API
PersonDirectory is a static class and service which includes the following public static API:
/** Obtain an instance of PersonDirectory */
public static synchronized PersonDirectory instance();
Once you've obtained a PersonDirectory, the public API it provides includes:
/**
* For a given user, return a Map from attribute names to Strings or
* vectors of Strings representing values for those attributes.
*/
public Hashtable getUserDirectoryInformation (String username);
/**
* For a given user, obtain attributes for the user and then insert those
* attributes into the given IPerson, which will then be placed into the
* PersonDirectory persons cache.
*/
public void getUserDirectoryInformation(String uid, IPerson m_Person);
/**
* Returns a reference to a restricted IPerson represented by the supplied user ID.
* The restricted IPerson allows access to person attributes, but not the security context.
* If the person is available in the PersonDirectory cache, return that.
* Otherwise, use the PersonFactory to create the person. Obtain the attributes for this
* newly created person using getUserDirectoryInformation(uid, IPerson).
* Side effect: adds person to persons cache.
* @param uid the user ID
* @return the corresponding person, restricted so that its security context is inaccessible
*/
public static RestrictedPerson getRestrictedPerson(String uid);
PersonDirectory implementation
Core to the current PersonDirectory is its implementation. It is not merely a public API – it is also an expected implementation of that API. PersonDirectory parses an XML file to obtain an ordered list of attribute sources. These attribute sources may be either JDBC queries or LDAP queries. It executes these queries in order, accumulating a Map of String attribute names to (String | Vector of Strings) values.
Collision handling
The most recently set value for any entry in the attribute Map is the controlling entry.
Virtues of this approach
PersonDirectory provides declarative configuration of user attribute mapping. You institution exposes user attributes via (authenticated or not) LDAP or JDBC. You map those exposed attributes to eduPerson or other attributes using PersonDirectory. Want to use JDBC in development but LDAP in test? Simply swap PersonDirs.xml configuration files and you're set.