org.apache.jetspeed.security.spi.impl.ldap
Class LdapUserPrincipalDaoImpl

java.lang.Object
  extended byorg.apache.jetspeed.security.spi.impl.ldap.AbstractLdapDao
      extended byorg.apache.jetspeed.security.spi.impl.ldap.LdapPrincipalDaoImpl
          extended byorg.apache.jetspeed.security.spi.impl.ldap.LdapUserPrincipalDaoImpl
All Implemented Interfaces:
LdapPrincipalDao, LdapReadOnlyPrincipalDao, LdapUserPrincipalDao

public class LdapUserPrincipalDaoImpl
extends LdapPrincipalDaoImpl
implements LdapUserPrincipalDao

Author:
Mike Long

Field Summary
private static String GROUP_ATTR_NAME
          The group attribute name.
private static org.apache.commons.logging.Log LOG
          The logger.
 
Fields inherited from class org.apache.jetspeed.security.spi.impl.ldap.LdapPrincipalDaoImpl
UID_ATTR_NAME
 
Fields inherited from class org.apache.jetspeed.security.spi.impl.ldap.AbstractLdapDao
ctx, defaultDnSuffix, rootContext, rootDn, rootPassword
 
Constructor Summary
LdapUserPrincipalDaoImpl()
           Default constructor.
LdapUserPrincipalDaoImpl(String ldapServerName, String rootDn, String rootPassword, String rootContext, String defaultDnSuffix)
           Initializes the dao.
 
Method Summary
 void addGroup(String userPrincipalUid, String groupPrincipalUid)
           Add a user to a group.
protected  Attributes defineLdapAttributes(String principalUid)
           A template method for defining the attributes for a particular LDAP class.
private  List getAttributes(Attribute attr)
           
private  Attributes getFirstUser(NamingEnumeration results)
           
private  String[] getGroups(NamingEnumeration results, String uid)
           Get the groups.
 String[] getGroupUidsForUser(String userPrincipalUid)
           Return an array of the group principal UIDS that belong to a specific user.
protected  String getObjectClass()
           A template method that returns the LDAP object class of the concrete DAO.
 String[] getUserUidsForGroup(String groupPrincipalUid)
           Return an array of the user principal UIDS that belong to a group.
protected  Principal makePrincipal(String principalUid)
           Creates a GroupPrincipal object.
private  void modifyUserGroup(String userPrincipalUid, String groupPrincipalUid, int operationType)
           Replace or delete the user group attribute.
 void removeGroup(String userPrincipalUid, String groupPrincipalUid)
           Remove a user from a group.
private  NamingEnumeration searchUserByGroup(String groupPrincipalUid, SearchControls cons)
           Search user by group.
 
Methods inherited from class org.apache.jetspeed.security.spi.impl.ldap.LdapPrincipalDaoImpl
convertUidFromLdapAcceptableName, convertUidToLdapAcceptableName, create, delete, find, getAttribute
 
Methods inherited from class org.apache.jetspeed.security.spi.impl.ldap.AbstractLdapDao
bindToServer, getSubcontextName, lookupByUid, searchByWildcardedUid, setSearchControls, validateDn, validatePassword, validateUid
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.jetspeed.security.spi.impl.ldap.LdapPrincipalDao
create, delete, find
 
Methods inherited from interface org.apache.jetspeed.security.spi.impl.ldap.LdapReadOnlyPrincipalDao
lookupByUid
 

Field Detail

LOG

private static final org.apache.commons.logging.Log LOG
The logger.


GROUP_ATTR_NAME

private static final String GROUP_ATTR_NAME
The group attribute name.

See Also:
Constant Field Values
Constructor Detail

LdapUserPrincipalDaoImpl

public LdapUserPrincipalDaoImpl()
                         throws NamingException,
                                org.apache.jetspeed.security.SecurityException

Default constructor.

Throws:
NamingException - A NamingException.
org.apache.jetspeed.security.SecurityException - A SecurityException.

LdapUserPrincipalDaoImpl

public LdapUserPrincipalDaoImpl(String ldapServerName,
                                String rootDn,
                                String rootPassword,
                                String rootContext,
                                String defaultDnSuffix)
                         throws NamingException,
                                org.apache.jetspeed.security.SecurityException

Initializes the dao.

Parameters:
ldapServerName - The server name.
rootDn - The root domain.
rootPassword - The root password.
rootContext - The root context.
defaultDnSuffix - The default suffix.
Throws:
NamingException - A NamingException.
org.apache.jetspeed.security.SecurityException - A SecurityException.
Method Detail

addGroup

public void addGroup(String userPrincipalUid,
                     String groupPrincipalUid)
              throws org.apache.jetspeed.security.SecurityException
Description copied from interface: LdapUserPrincipalDao

Add a user to a group.

Specified by:
addGroup in interface LdapUserPrincipalDao
Parameters:
userPrincipalUid - The user principal.
groupPrincipalUid - The group principal.
Throws:
org.apache.jetspeed.security.SecurityException - A SecurityException.
See Also:
LdapUserPrincipalDao.addGroup(java.lang.String, java.lang.String)

modifyUserGroup

private void modifyUserGroup(String userPrincipalUid,
                             String groupPrincipalUid,
                             int operationType)
                      throws org.apache.jetspeed.security.SecurityException

Replace or delete the user group attribute.

Parameters:
userPrincipalUid -
groupPrincipalUid -
operationType - whether to replace or remove the specified user group from the user
Throws:
org.apache.jetspeed.security.SecurityException - A SecurityException.

removeGroup

public void removeGroup(String userPrincipalUid,
                        String groupPrincipalUid)
                 throws org.apache.jetspeed.security.SecurityException
Description copied from interface: LdapUserPrincipalDao

Remove a user from a group.

Specified by:
removeGroup in interface LdapUserPrincipalDao
Parameters:
userPrincipalUid - The user principal.
groupPrincipalUid - The group principal.
Throws:
org.apache.jetspeed.security.SecurityException - A SecurityException.
See Also:
LdapUserPrincipalDao.removeGroup(java.lang.String, java.lang.String)

defineLdapAttributes

protected Attributes defineLdapAttributes(String principalUid)

A template method for defining the attributes for a particular LDAP class.

Specified by:
defineLdapAttributes in class LdapPrincipalDaoImpl
Parameters:
principalUid - The principal uid.
Returns:
the LDAP attributes object for the particular class.

makePrincipal

protected Principal makePrincipal(String principalUid)

Creates a GroupPrincipal object.

Specified by:
makePrincipal in class LdapPrincipalDaoImpl
Parameters:
principalUid - The principal uid.
Returns:
A group principal object.

getObjectClass

protected String getObjectClass()

A template method that returns the LDAP object class of the concrete DAO.

Specified by:
getObjectClass in class AbstractLdapDao
Returns:
a String containing the LDAP object class name.

getUserUidsForGroup

public String[] getUserUidsForGroup(String groupPrincipalUid)
                             throws org.apache.jetspeed.security.SecurityException

Return an array of the user principal UIDS that belong to a group.

Specified by:
getUserUidsForGroup in interface LdapUserPrincipalDao
Parameters:
groupPrincipalUid - The group principal uid.
Returns:
The array of user uids asociated with this group
Throws:
org.apache.jetspeed.security.SecurityException - A SecurityException.

searchUserByGroup

private NamingEnumeration searchUserByGroup(String groupPrincipalUid,
                                            SearchControls cons)
                                     throws NamingException

Search user by group.

Parameters:
groupPrincipalUid -
cons -
Returns:
Throws:
NamingException - A NamingException.

getGroupUidsForUser

public String[] getGroupUidsForUser(String userPrincipalUid)
                             throws org.apache.jetspeed.security.SecurityException
Description copied from interface: LdapUserPrincipalDao

Return an array of the group principal UIDS that belong to a specific user.

Specified by:
getGroupUidsForUser in interface LdapUserPrincipalDao
Parameters:
userPrincipalUid -
Returns:
the array of group uids asociated with this user
Throws:
org.apache.jetspeed.security.SecurityException

getGroups

private String[] getGroups(NamingEnumeration results,
                           String uid)
                    throws NamingException

Get the groups.

Parameters:
results -
uid -
Returns:
Throws:
NamingException

getFirstUser

private Attributes getFirstUser(NamingEnumeration results)
                         throws NamingException
Parameters:
results -
Returns:
Throws:
NamingException

getAttributes

private List getAttributes(Attribute attr)
                    throws NamingException
Parameters:
attr -
Returns:
Throws:
NamingException


Copyright © 1999-2005 Apache Software Foundation. All Rights Reserved.