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

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

public class LdapUserPrincipalDaoImpl
extends LdapPrincipalDaoImpl
implements LdapUserPrincipalDao

Author:
Mike Long , David Le Strat

Field Summary
private  LdapMembershipDao membership
           
 
Fields inherited from class org.apache.jetspeed.security.spi.impl.ldap.AbstractLdapDao
ctx
 
Constructor Summary
LdapUserPrincipalDaoImpl()
           Default constructor.
LdapUserPrincipalDaoImpl(LdapBindingConfig ldapConfig)
           Initializes the dao.
 
Method Summary
 void addGroup(String userPrincipalUid, String groupPrincipalUid)
           Add a user to a group.
 void addRole(String userPrincipalUid, String rolePrincipalUid)
           Add a user to a group.
 void addRoleToGroup(String groupPrincipalUid, String rolePrincipalUid)
           Add a role to a group.
protected  Attributes defineLdapAttributes(String principalUid)
           A template method for defining the attributes for a particular LDAP class.
protected  String[] getAttributes()
           
protected  String getDnSuffix()
           Builds the dn suffix.
protected  String getEntryPrefix()
           A template method that returns the LDAP entry prefix of the concrete DAO.
 String[] getGroupUidsForUser(String userPrincipalUid)
          Return the list of group IDs for a particular user
protected  String[] getObjectClasses()
           
 String[] getRolesForGroup(String groupPrincipalUid)
           Return an array of the roles that belong to a group.
 String[] getRoleUidsForUser(String userPrincipalUid)
          Returns the role IDs for a particular user Looks up the user, and extracts the rolemembership attr (ex : uniquemember)
protected  String getSearchSuffix()
           A template method that returns the LDAP entry prefix of the concrete DAO.
protected  String getUidAttributeForPrincipal()
           Builds the dn suffix.
 String[] getUserUidsForGroup(String groupPrincipalUid)
           Return an array of the user principal UIDS that belong to a group.
 String[] getUserUidsForRole(String rolePrincipalUid)
           Return an array of the user principal UIDS that belong to a group.
protected  Principal makePrincipal(String principalUid)
           Creates a GroupPrincipal object.
private  void modifyRoleGroupByGroup(String groupPrincipalUid, String rolePrincipalUid, int operationType)
           Replace or delete the user group attribute.
private  void modifyRoleGroupByRole(String groupPrincipalUid, String rolePrincipalUid, int operationType)
           Replace or delete the user group attribute.
private  void modifyUserGroupByGroup(String userPrincipalUid, String groupPrincipalUid, int operationType)
           Replace or delete the user group attribute.
private  void modifyUserGroupByUser(String userPrincipalUid, String groupPrincipalUid, int operationType)
           Replace or delete the user group attribute.
private  void modifyUserRoleByRole(String userPrincipalUid, String rolePrincipalUid, int operationType)
           Replace or delete the role attribute.
private  void modifyUserRoleByUser(String userPrincipalUid, String rolePrincipalUid, int operationType)
           Replace or delete the role attribute.
 void removeGroup(String userPrincipalUid, String groupPrincipalUid)
           Remove a user from a group.
 void removeRole(String userPrincipalUid, String rolePrincipalUid)
           Remove a user from a group.
 void removeRoleFromGroup(String groupPrincipalUid, String rolePrincipalUid)
           Remove a role from a group.
 
Methods inherited from class org.apache.jetspeed.security.spi.impl.ldap.LdapPrincipalDaoImpl
convertUidToLdapAcceptableName, create, delete, find, getAttribute, getGroupDN, getGroupDN, getRoleDN, getRoleDN, getSearchDomain, getUserDN, getUserDN, parseAttr
 
Methods inherited from class org.apache.jetspeed.security.spi.impl.ldap.AbstractLdapDao
bindToServer, getGroupAttributes, getGroupFilter, getGroupFilterBase, getGroupIdAttribute, getGroupMembershipAttribute, getGroupMembershipForRoleAttribute, getGroupObjectClasses, getGroupObjectRequiredAttributeClasses, getGroupUidAttribute, getKnownAttributes, getRoleAttributes, getRoleFilter, getRoleFilterBase, getRoleGroupMembershipForRoleAttribute, getRoleIdAttribute, getRoleMembershipAttribute, getRoleObjectClasses, getRoleObjectRequiredAttributeClasses, getRoleUidAttribute, getRootContext, getSearchScope, getSubcontextName, getUidAttribute, getUserAttributes, getUserFilter, getUserFilterBase, getUserGroupMembershipAttribute, getUserIdAttribute, getUserObjectClasses, getUserPasswordAttribute, getUserRoleMembershipAttribute, getUserUidAttribute, lookupByUid, searchByWildcardedUid, searchGroupByWildcardedUid, searchRoleByWildcardedUid, 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
convertUidToLdapAcceptableName, create, delete, find
 
Methods inherited from interface org.apache.jetspeed.security.spi.impl.ldap.LdapReadOnlyPrincipalDao
lookupByUid
 

Field Detail

membership

private LdapMembershipDao membership
Constructor Detail

LdapUserPrincipalDaoImpl

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

Default constructor.

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

LdapUserPrincipalDaoImpl

public LdapUserPrincipalDaoImpl(LdapBindingConfig ldapConfig)
                         throws org.apache.jetspeed.security.SecurityException

Initializes the dao.

Parameters:
ldapConfig - Holds the ldap binding configuration.
Throws:
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)

modifyUserGroupByGroup

private void modifyUserGroupByGroup(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.

modifyUserGroupByUser

private void modifyUserGroupByUser(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)

addRole

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

Add a user to a group.

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

modifyUserRoleByUser

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

Replace or delete the role attribute.

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

modifyUserRoleByRole

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

Replace or delete the role attribute.

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

removeRole

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

Remove a user from a group.

Specified by:
removeRole in interface LdapUserPrincipalDao
Parameters:
userPrincipalUid - The user principal.
rolePrincipalUid - The role 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.

addRoleToGroup

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

Add a role to a group.

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

modifyRoleGroupByRole

private void modifyRoleGroupByRole(String groupPrincipalUid,
                                   String rolePrincipalUid,
                                   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.

modifyRoleGroupByGroup

private void modifyRoleGroupByGroup(String groupPrincipalUid,
                                    String rolePrincipalUid,
                                    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.

removeRoleFromGroup

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

Remove a role from a group.

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

getGroupUidsForUser

public String[] getGroupUidsForUser(String userPrincipalUid)
                             throws org.apache.jetspeed.security.SecurityException
Return the list of group IDs for a particular 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

getRolesForGroup

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

Return an array of the roles that belong to a group.

Specified by:
getRolesForGroup 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.

getRoleUidsForUser

public String[] getRoleUidsForUser(String userPrincipalUid)
                            throws org.apache.jetspeed.security.SecurityException
Returns the role IDs for a particular user Looks up the user, and extracts the rolemembership attr (ex : uniquemember)

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

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.

getUserUidsForRole

public String[] getUserUidsForRole(String rolePrincipalUid)
                            throws org.apache.jetspeed.security.SecurityException

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

Specified by:
getUserUidsForRole 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.

getObjectClasses

protected String[] getObjectClasses()
Specified by:
getObjectClasses in class AbstractLdapDao

getAttributes

protected String[] getAttributes()
Specified by:
getAttributes in class AbstractLdapDao

getUidAttributeForPrincipal

protected String getUidAttributeForPrincipal()
Description copied from class: LdapPrincipalDaoImpl

Builds the dn suffix.

Specified by:
getUidAttributeForPrincipal in class LdapPrincipalDaoImpl
Returns:
The dn suffix.

getEntryPrefix

protected String getEntryPrefix()
Description copied from class: AbstractLdapDao

A template method that returns the LDAP entry prefix of the concrete DAO.

TODO : this should be in spring config

Specified by:
getEntryPrefix in class AbstractLdapDao
Returns:
a String containing the LDAP entry prefix name.

getSearchSuffix

protected String getSearchSuffix()
Description copied from class: AbstractLdapDao

A template method that returns the LDAP entry prefix of the concrete DAO.

TODO : this should be in spring config

Specified by:
getSearchSuffix in class AbstractLdapDao
Returns:
a String containing the LDAP entry prefix name.

getDnSuffix

protected String getDnSuffix()
Description copied from class: LdapPrincipalDaoImpl

Builds the dn suffix.

Specified by:
getDnSuffix in class LdapPrincipalDaoImpl
Returns:
The dn suffix.


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