Jive Forums API (5.5.20.2-oracle) Developer Javadocs

com.jivesoftware.base.ldap
Class LdapUserManager

java.lang.Object
  extended by com.jivesoftware.base.ldap.LdapUserManager
All Implemented Interfaces:
AdvancedUserManager, IntrospectiveUserManager, UserManager

public class LdapUserManager
extends java.lang.Object
implements IntrospectiveUserManager, AdvancedUserManager

LDAP connections are made via JNDI using the Sun LDAP provider.


Field Summary
static Cache userEmailCache
           
 
Constructor Summary
LdapUserManager()
           
 
Method Summary
 User createUser(java.lang.String username, java.lang.String password, java.lang.String email)
          Factory method for creating a new User with all required values: a password, email address, and unique username.
 User createUser(java.lang.String username, java.lang.String password, java.lang.String name, java.lang.String email, boolean nameVisible, boolean emailVisible, java.util.Map properties)
          Factory method for creating a new User with all required AND optional values.
 void deleteUser(User user)
          Deletes a user.
 User getUser(long userID)
          Returns a User specified by their ID.
 User getUser(java.lang.String username)
          Returns the User specified by username.
 int getUserCount()
          Returns the number of users in the system.
 User getUserFromEmailAddress(java.lang.String email)
          Returns a user object corresponding to the email address given.
 long getUserID(java.lang.String username)
          Returns the userID specified by the username.
 java.util.Iterator getUsersFromEmailAddress(java.lang.String email)
          Returns an iterator of user objects corresponding to the email address given.
 boolean isCreateUserSupported()
          Creation of users in ldap implementation is not supported
 boolean isDeleteUserSupported()
          true, however ldap will remain unaffected
 boolean isGetUserCountSupported()
          supported, returns true
 boolean isGetUserFromEmailAddressSupported()
          supported, returns true
 boolean isReadOnly()
          returns false
 boolean isUserListSupported()
          supported, returns true
 java.util.Iterator users()
          Returns an iterator for all users in the system.
 java.util.Iterator users(int startIndex, int numResults)
          Returns an iterator for all users starting at startIndex with the given number of results.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

userEmailCache

public static Cache userEmailCache
Constructor Detail

LdapUserManager

public LdapUserManager()
Method Detail

createUser

public User createUser(java.lang.String username,
                       java.lang.String password,
                       java.lang.String email)
                throws UserAlreadyExistsException
Description copied from interface: UserManager
Factory method for creating a new User with all required values: a password, email address, and unique username.

If your back-end user store does not support this operation, throw an UnsupportedOperationException.

Specified by:
createUser in interface UserManager
Parameters:
username - the new and unique username for the account.
password - the password for the account as plain text.
email - the email address for the account.
Returns:
a new User.
Throws:
UserAlreadyExistsException - if the username already exists in the system.

createUser

public User createUser(java.lang.String username,
                       java.lang.String password,
                       java.lang.String name,
                       java.lang.String email,
                       boolean nameVisible,
                       boolean emailVisible,
                       java.util.Map properties)
                throws UserAlreadyExistsException
Description copied from interface: UserManager
Factory method for creating a new User with all required AND optional values.

If your back-end user store does not support this operation, throw an UnsupportedOperationException.

Specified by:
createUser in interface UserManager
Parameters:
username - the new and unique username for the account.
password - the password for the account as plain text.
name - the name for the account.
email - the email address for the account.
nameVisible - true if the user's name should be visible to others.
emailVisible - true if the user's email address should be visible to others.
properties - the user's extended properties.
Returns:
a new User.
Throws:
UserAlreadyExistsException - if the username already exists in the system.

getUser

public User getUser(long userID)
             throws UserNotFoundException
Description copied from interface: UserManager
Returns a User specified by their ID.

Because this method will be called often by other parts of the API, a cache of User objects should be used. UserManagerFactory.userCache can be used for this purpose. The algorithm should be:

  1. Look for the user object in cache with new Long(userID) as the key.
  2. If the object is found in cache, return it.
  3. If the object is not found in cache, load the object from the back-end store then add it to cache with new Long(userID) as the key. Finally, return the user object.

Specified by:
getUser in interface UserManager
Parameters:
userID - the id of the User to lookup.
Returns:
the User specified by userID.
Throws:
UserNotFoundException - if the user does not exist.

getUser

public User getUser(java.lang.String username)
             throws UserNotFoundException
Description copied from interface: UserManager
Returns the User specified by username.

The method should typically be implemented as:
return getUser(getUserID(username));

Specified by:
getUser in interface UserManager
Parameters:
username - the username of the user.
Returns:
the User that matches username.
Throws:
UserNotFoundException - if the user does not exist.

getUserID

public long getUserID(java.lang.String username)
               throws UserNotFoundException
Description copied from interface: UserManager
Returns the userID specified by the username. This method is only useful in specialized cases, as its generally easier to call getUser(username).getID() instead of this method.

Because this method will be called often by other parts of the API, a cache should be used that maps usernames to userIDs. UserManagerFactory.userIDCache can be used for this purpose. The algorithm should be:

  1. Look for the username to userID mapping in cache.
  2. If the mapping is found, return the userID.
  3. If the mapping is not found in cache, load the user object from the back-end store to figure out the correct userID, add the mapping to cache, then return the userID.

Specified by:
getUserID in interface UserManager
Parameters:
username - the username of the usedr.
Returns:
the userID that matches username.
Throws:
UserNotFoundException - if the user does not exist.

deleteUser

public void deleteUser(User user)
                throws UnauthorizedException
Description copied from interface: UserManager
Deletes a user. To maintain data consistency, deleting a user will cause all messages created by the user to switch to being from an anonymous author.

If your back-end user store does not support this operation, throw an UnsupportedOperationException.

Specified by:
deleteUser in interface UserManager
Parameters:
user - the user to delete.
Throws:
UnauthorizedException

getUserCount

public int getUserCount()
Description copied from interface: UserManager
Returns the number of users in the system.

If your back-end user store does not support this operation, throw an UnsupportedOperationException.

Specified by:
getUserCount in interface UserManager
Returns:
the total number of users.

users

public java.util.Iterator users()
Description copied from interface: UserManager
Returns an iterator for all users in the system.

If your back-end user store does not support this operation, throw an UnsupportedOperationException.

Specified by:
users in interface UserManager
Returns:
an Iterator for all users.

users

public java.util.Iterator users(int startIndex,
                                int numResults)
Description copied from interface: UserManager
Returns an iterator for all users starting at startIndex with the given number of results. This is useful to support pagination in a GUI where you may only want to display a certain number of results per page. It is possible that the number of results returned will be less than that specified by numResults if numResults is greater than the number of records left in the system to display.

If your back-end user store does not support this operation, throw an UnsupportedOperationException.

Specified by:
users in interface UserManager
Parameters:
startIndex - the beginning index to start the results at.
numResults - the total number of results to return.
Returns:
an Iterator for all users in the specified range.

getUserFromEmailAddress

public User getUserFromEmailAddress(java.lang.String email)
Description copied from interface: AdvancedUserManager
Returns a user object corresponding to the email address given. If no user is found which corresponds to the given email address null should be returned. If more than one user corresponds to the given email address it is up to the implementation to decide what to do (i.e. return one of the users or return null).

Specified by:
getUserFromEmailAddress in interface AdvancedUserManager
Parameters:
email - the email address to get a user object for.
Returns:
a user object corresponding to the given email address.

getUsersFromEmailAddress

public java.util.Iterator getUsersFromEmailAddress(java.lang.String email)
Description copied from interface: AdvancedUserManager
Returns an iterator of user objects corresponding to the email address given. There is not a uniqueness contraint on the email id ofr a user object, so multiples may be returned. If no users are found which correspond to the given email address, an empty iterator should be returned.

Specified by:
getUsersFromEmailAddress in interface AdvancedUserManager
Parameters:
email - the email address to get a user object for.
Returns:
an iterator of user objects corresponding to the given email address.

isCreateUserSupported

public boolean isCreateUserSupported()
Creation of users in ldap implementation is not supported

Specified by:
isCreateUserSupported in interface IntrospectiveUserManager
Returns:
false

isDeleteUserSupported

public boolean isDeleteUserSupported()
true, however ldap will remain unaffected

Specified by:
isDeleteUserSupported in interface IntrospectiveUserManager
Returns:
true

isGetUserCountSupported

public boolean isGetUserCountSupported()
supported, returns true

Specified by:
isGetUserCountSupported in interface IntrospectiveUserManager
Returns:
true

isUserListSupported

public boolean isUserListSupported()
supported, returns true

Specified by:
isUserListSupported in interface IntrospectiveUserManager
Returns:
true

isGetUserFromEmailAddressSupported

public boolean isGetUserFromEmailAddressSupported()
supported, returns true

Specified by:
isGetUserFromEmailAddressSupported in interface IntrospectiveUserManager
Returns:
returns true;

isReadOnly

public boolean isReadOnly()
returns false

Specified by:
isReadOnly in interface IntrospectiveUserManager
Returns:
false

Jive Forums Project Page

Copyright © 1999-2006 Jive Software.