us.openinternet.luge.service
Class PersonFacade

java.lang.Object
  |
  +--us.openinternet.luge.service.LugeFacade
        |
        +--us.openinternet.luge.service.PersonFacade

public class PersonFacade
extends LugeFacade


Field Summary
 
Fields inherited from class us.openinternet.luge.service.LugeFacade
grpTransformer, lugeTransformer, personTransformer
 
Constructor Summary
PersonFacade(LugeFacade lf)
           
PersonFacade(LugeTransformer lt)
           
PersonFacade(java.lang.String cn, java.lang.String key)
          Use this constructor to establish your connection to the ldap server.
 
Method Summary
 boolean addAttributeToPerson(java.lang.String uid, java.lang.String attr, java.util.ArrayList values)
          This method will add an attribute with mutliple values to the user.
 boolean addAttributeToPerson(java.lang.String uid, java.lang.String attr, java.lang.String value)
          This method will add an attribute with single value to the user.
 boolean addPerson(PersonVO pvo)
          This method adds a user to the directory.
 boolean deleteAttributeFromPerson(java.lang.String uid, java.lang.String attr)
          This method allows all values of an attribute to be deleted.
 boolean deleteAttributeValueFromPerson(java.lang.String uid, java.lang.String attr, java.lang.String val)
          This method allows a particular value to be deleted from an attribute.
 boolean deletePerson(java.lang.String uid)
          This method removes the specified user from the directory.
protected  void finalize()
           
 java.util.ArrayList getUserAttributeMultiValue(java.lang.String uid, java.lang.String attr)
          This method is intended to be used as a quick method for retrieving a multi-valued attribute.
 java.util.Hashtable getUserAttributes(java.lang.String uid, java.lang.String[] attrs)
          This method returns specific attributes of a user in a Hashtable with the actual ldap attribute names as keys and the values returned as String arrays to accomodate multi-valued attributes.
 java.lang.String getUserAttributeSingleValue(java.lang.String uid, java.lang.String attr)
          This method returns the first value of an attribute.
 boolean modifyPerson(java.lang.String uid, PersonVO pvo, boolean AppendAttributes)
          This method allows the attributes of a person to be modified.
 boolean personExists(java.lang.String uid)
          This method verifies that a user exists in the directory.
 PersonVO personLookup(java.lang.String uid)
          Use this method to return all the values for the specified person.
 java.util.ArrayList quickUserSearch(java.lang.String attrName, java.lang.String value)
          This method returns an ArrayList of user names that match a simple attribute value search (ie cn=foo*).
 GroupVO removeAttributeValueFromAllPeople(java.lang.String attrName, java.lang.String attrValue)
          Remove a specified attribute value from all People that possess it.
 boolean replaceAttributeForPerson(java.lang.String uid, java.lang.String attr, java.util.ArrayList values)
          This method is the same as replaceAttributeForPerson except it accepts an ArrayList of values to accomodate multi-valued attributes.
 boolean replaceAttributeForPerson(java.lang.String uid, java.lang.String attr, java.lang.String value)
          This method replaces an attribute.
 boolean replaceAttributeForPerson(java.lang.String uid, java.lang.String attr, java.lang.String oldValue, java.lang.String newValue)
          This method allows a single value of a multi-vauled attribute to be replaced
 SearchVO searchUsers(SearchVO svo)
          The preferred method to search the directory, see SearchVO documentation for sample code on setting serach criteria, using this method and extracting the results.
 boolean userHasAttribute(java.lang.String uid, java.lang.String attr)
          This method verifies if a user has a specific attribute.
 boolean userHasAttributeValue(java.lang.String uid, java.lang.String attr, java.lang.String value)
          This method verifies if a user has an attribute with a specific value.
 boolean validateUserPassword(java.lang.String user, java.lang.String passwd)
          This method tests whether a given username/password set is valid.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PersonFacade

public PersonFacade(java.lang.String cn,
                    java.lang.String key)
             throws LugeException
Use this constructor to establish your connection to the ldap server.

Parameters:
cn - - This is an id assigned to your application
key - - Each id is also assigned a key for authentication purposes. The key is not the LDAP server password.
Throws:
LugeException

PersonFacade

public PersonFacade(LugeTransformer lt)
             throws LugeException

PersonFacade

public PersonFacade(LugeFacade lf)
             throws LugeException
Method Detail

addPerson

public boolean addPerson(PersonVO pvo)
                  throws LugeException
This method adds a user to the directory. Note: it does not enable the user in PD. For example:

PersonVO pvo = new PersonVO();
pvo.setName("foo_bar");
pvo.setLastName("Bar");
pvo.setEmail("foo_bar@spam.com");
ArrayList categories = new ArrayList();
categories.add("Marketing");
categories.add("Sales");
categories.add("Finance");
pvo.setAttributeValues("businessCategory", categories);
pvo.addValueToAttribute("businessCategory", "One_More_Category");
try{
          AdminFacade af = new AdminFacade("myApp", "myKey");
          af.addPerson(pvo);
} catch (LugeException lugeEx) {
          lugeEx.printStackTrace();
}

LugeException

deletePerson

public boolean deletePerson(java.lang.String uid)
                     throws LugeException
This method removes the specified user from the directory. If the user is pdEnabled, you must be authorized as a PdAdmin to delete the user or a LugeException will be thrown.

Parameters:
uid - - the Person's name
LugeException

addAttributeToPerson

public boolean addAttributeToPerson(java.lang.String uid,
                                    java.lang.String attr,
                                    java.lang.String value)
                             throws LugeException
This method will add an attribute with single value to the user.

Parameters:
uid - The userID (cn) of the person.
attr - The valid LDAP attribute name.
value - The value to be added to the attribute.
LugeException

addAttributeToPerson

public boolean addAttributeToPerson(java.lang.String uid,
                                    java.lang.String attr,
                                    java.util.ArrayList values)
                             throws LugeException
This method will add an attribute with mutliple values to the user.

Parameters:
uid - The userID (cn) of the person
attr - The valid LDAP attribute name.
values - An ArrayList of values to be added to the attribute.
LugeException

replaceAttributeForPerson

public boolean replaceAttributeForPerson(java.lang.String uid,
                                         java.lang.String attr,
                                         java.lang.String value)
                                  throws LugeException
This method replaces an attribute. If the attribute does not exist, it will create a new attribute. If the attribute already exists, the old value will be deleted and replaced with the new value.

Parameters:
uid - The userID (cn) of the person
attr - The valid LDAP attribute name.
value - The value of the attribute.
LugeException

replaceAttributeForPerson

public boolean replaceAttributeForPerson(java.lang.String uid,
                                         java.lang.String attr,
                                         java.util.ArrayList values)
                                  throws LugeException
This method is the same as replaceAttributeForPerson except it accepts an ArrayList of values to accomodate multi-valued attributes.

Parameters:
uid - The userID (cn) of the person
attr - The valid LDAP attribute name.
values - An ArrayList of values of the attribute.
LugeException

replaceAttributeForPerson

public boolean replaceAttributeForPerson(java.lang.String uid,
                                         java.lang.String attr,
                                         java.lang.String oldValue,
                                         java.lang.String newValue)
                                  throws LugeException
This method allows a single value of a multi-vauled attribute to be replaced

Parameters:
uid - The userID (cn) of the person
attr - The valid LDAP attribute name.
oldValue - The current value of the attribute.
newValue - The new value of the attribute.
LugeException

deleteAttributeFromPerson

public boolean deleteAttributeFromPerson(java.lang.String uid,
                                         java.lang.String attr)
                                  throws LugeException
This method allows all values of an attribute to be deleted.

Parameters:
uid - The userID (cn) of the person
attr - The valid LDAP attribute name.
LugeException

deleteAttributeValueFromPerson

public boolean deleteAttributeValueFromPerson(java.lang.String uid,
                                              java.lang.String attr,
                                              java.lang.String val)
                                       throws LugeException
This method allows a particular value to be deleted from an attribute.

Parameters:
uid - The userID (cn) of the person.
attr - The valid LDAP attribute name.
val - The value of the attribute to be deleted.
LugeException

modifyPerson

public boolean modifyPerson(java.lang.String uid,
                            PersonVO pvo,
                            boolean AppendAttributes)
                     throws LugeException
This method allows the attributes of a person to be modified. Use the ValueObject PersonVO to set single and multi-vaule attributes, and then post the person VO to this method.

Parameters:
uid - The userID (cn) of the person.
LugeException

removeAttributeValueFromAllPeople

public GroupVO removeAttributeValueFromAllPeople(java.lang.String attrName,
                                                 java.lang.String attrValue)
                                          throws LugeException
Remove a specified attribute value from all People that possess it. This is a handy cleanup function that should be used with care! It may also be rather slow, deleting attributes may involve re-indexing, so don't count on speed here.

Parameters:
attrName - - the attribute name you want to modify
attrValue - - the attribute value you are looking to eradicate
Returns:
GroupVO - check the getOkPeople and getProblemPeople values for people whose attributes were successfully and unsuccessfully updated.
LugeException

finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class LugeFacade
java.lang.Throwable

searchUsers

public SearchVO searchUsers(SearchVO svo)
                     throws LugeException
The preferred method to search the directory, see SearchVO documentation for sample code on setting serach criteria, using this method and extracting the results.

LugeException

personLookup

public PersonVO personLookup(java.lang.String uid)
                      throws LugeException
Use this method to return all the values for the specified person. See the PersonVO and ValueObject documenation for info on extracting the values.

Parameters:
uid - - the unique identifier for the Person
LugeException

getUserAttributeSingleValue

public java.lang.String getUserAttributeSingleValue(java.lang.String uid,
                                                    java.lang.String attr)
                                             throws LugeException
This method returns the first value of an attribute. It is intended to be used for attributes that are String and single valued. If the attribute is multi-valued this method will return only one value (chosen at random), so it is recommended that you use the getUserAttributes method instead. If the value is not String, or if there is no value for this attribute, this method returns an empty String.

Parameters:
uid - - The uid of the user you want to lookup
attr - Name of the actual ldap attribute that you want returned
Returns:
The value or an empty String.
LugeException

getUserAttributeMultiValue

public java.util.ArrayList getUserAttributeMultiValue(java.lang.String uid,
                                                      java.lang.String attr)
                                               throws LugeException
This method is intended to be used as a quick method for retrieving a multi-valued attribute.

Parameters:
uid - - The cn or uid of the user you want to lookup
LugeException

getUserAttributes

public java.util.Hashtable getUserAttributes(java.lang.String uid,
                                             java.lang.String[] attrs)
                                      throws LugeException
This method returns specific attributes of a user in a Hashtable with the actual ldap attribute names as keys and the values returned as String arrays to accomodate multi-valued attributes.

Parameters:
uid - - The uid of the user you want to lookup
LugeException

quickUserSearch

public java.util.ArrayList quickUserSearch(java.lang.String attrName,
                                           java.lang.String value)
                                    throws LugeException
This method returns an ArrayList of user names that match a simple attribute value search (ie cn=foo*). You can then call SimpleFacade.getUserAttributes to retrieve a user's info. Also, consider using SimpleFacade.searchUsers for better performance if you know you'll need attributes for all the users returned.

Parameters:
attrName - The actual ldap attribute name you want to search on
value - The String value you want to search on, wildcards ok.
Returns:
ArrayList of the Usernames that matched the search attrName=value
LugeException

validateUserPassword

public boolean validateUserPassword(java.lang.String user,
                                    java.lang.String passwd)
                             throws LugeException
This method tests whether a given username/password set is valid. The purpose

Returns:
true if a test bind to the directory is successful using the supplied credentials.
Throws:
LugeExceptions - that specify if the user doesn't exist or if the password is wrong.
LugeException

personExists

public boolean personExists(java.lang.String uid)
This method verifies that a user exists in the directory.

Parameters:
uid - - The userName of the person
Returns:
TRUE if user exists, FALSE otherwise.

userHasAttributeValue

public boolean userHasAttributeValue(java.lang.String uid,
                                     java.lang.String attr,
                                     java.lang.String value)
                              throws LugeException
This method verifies if a user has an attribute with a specific value.

Parameters:
uid - - The userName of the person
attr - A valid ldap attribute name
value - The value you are checking for
Returns:
TRUE if user has the center, FALSE otherwise.
LugeException

userHasAttribute

public boolean userHasAttribute(java.lang.String uid,
                                java.lang.String attr)
                         throws LugeException
This method verifies if a user has a specific attribute.

Parameters:
uid - - The userName of the person
attr - A valid ldap attribute name you are checking for
Returns:
TRUE if user has the center, FALSE otherwise.
LugeException

Copyright 2003, Michael Schwartz All Rights Reserved.