pt.digitalis.utils.ldap
Interface ILDAPUtils

All Known Implementing Classes:
AbstractLDAPUtils, LDAPUtilsActiveDirectoryImpl, LDAPUtilsOpenLDAPImpl

public interface ILDAPUtils

Defines a set of LDAP operations.

Author:
Rodrigo Gonçalves rgoncalves@digitalis.pt
, Luis Pinto lpinto@digitalis.pt
, Pedro Viegas pviegas@digitalis.pt, Fábio Souto fsouto@digitalis.pt

Method Summary
 void addGroup(LDAPGroup newGroup)
          Adds a new group to the LDAP tree.
 void addGroupAttribute(String commonName, String attributeName, Object value)
          Adds an attribute to a given group.
 void addUser(LDAPUser newUser)
          Adds a new user to the LDAP tree.
 void addUserAttribute(String loginName, String attributeName, Object value)
          Adds an attribute to a given user.
 void addUserToGroup(String groupCN, String userLogin)
          Adds a user from a given group.
 void changePassword(String loginName, String newPassword)
          Changes the password for a given user.
 int countAllfUsers(String groupId)
          Counts all users of a given group.
 int countAllGroups()
          Counts all groups in the LDAP directory
 int countAllGroupsOfUser(String loginName)
          Counts all groups of a user
 int countAllUsers()
          Counts all users in the LDAP directory
 int countUsers(Map<String,String> attributes)
          Count users in the LDAP directory which match the provided attributes
 Set<LDAPGroup> findAllGroups()
          Returns the list of all groups.
 Set<LDAPUser> findAllUsers()
          Returns the list of all users.
 LDAPGroup findGroupByCommonName(String cn)
          Returns the group with a given common name.
 LDAPGroup findGroupByDistinguishedName(String dn)
          Returns the group with a given distinguished name.
 Set<LDAPGroup> findGroups(int rowsPerPage, int pageToReturn)
          Finds a subset of all the groups, according to the parameters
 Set<LDAPGroup> findGroupsOfUser(String loginName)
          Returns the list of a given user's groups.
 Set<LDAPGroup> findGroupsOfUserPagination(String loginName, int rowsPerPage, int pageToReturn)
          Returns the list of a given user's groups, with pagination
 LDAPUser findUserByDistinguishedName(String dn)
          Returns the user with a given distinguished name.
 LDAPUser findUserByLogin(String loginName)
          Returns the user with a given login name.
 Set<LDAPUser> findUsers(int rowsPerPage, int pageToReturn)
          Finds a subset of all the users, according to the parameters
 Set<LDAPUser> findUsersByAttribute(String attribute, String value)
          Returns the list of users with a given attribute value.
 Set<LDAPUser> findUsersByAttributes(Map<String,String> attributes)
          Finds a set of LDAP users that match all of the specified criteria
 Set<LDAPUser> findUsersByAttributes(Map<String,String> attributes, int rowsPerPage, int pageToReturn)
          Finds a set of LDAP users that match all of the specified criteria
 Set<LDAPUser> findUsersByEmail(String value)
          Returns the list of users with a given email attribute value.
 Map<String,LDAPUser> findUsersInGroup(String groupCN)
          Checks if a given user belongs to a given group.
 Set<LDAPGroup> getChildGroupsByCN(String commonName)
          Returns the list of groups that belong to a parent group given its common name.
 Set<LDAPGroup> getChildGroupsByDN(String distinguishedName)
          Returns the list of groups that belong to a parent group given its distinguished name.
 LDAPConfigurations getConfigurations()
          Inspector for the LDAP configurations object.
 Object getGroupAttribute(String attributeName, String commonName)
          Returns a given attribute or null of it doesn't exists.
 String getGroupAttributeName()
          Gets the name attribute name
 Map<String,Object> getGroupAttributes(String commonName)
          Returns the attribute map.
 String getMailAttributeName()
          Gets the mail attribute name
 String getNameAttributeName()
          Gets the name attribute name
 String getNonAvailableValue()
          Get the Non Available Message.
 List<String> getUnchangeableLDAPAttributes()
          Get the list of the LDAP unchangeable attributes
 Object getUserAttribute(String attributeName, String loginName)
          Returns a given attribute or null of it doesn't exists.
 Map<String,Object> getUserAttributes(String loginName)
          Returns the attribute map.
 String getUserLoginAttributeName()
          Gets the user login attribute name
 String getUserParentGroupAttributeName()
          Returns the parent group attribute name.
 boolean groupContainsAttribute(String attributeName, String commonName)
          Checks if a given attribute belongs to the entity.
 boolean groupExists(String groupCN)
          Checks if a given group exists on the LDAP tree.
 boolean isIdentityValid(String loginName, String suppliedPassword)
          Checks if the supplied password matches the one defined for a user with a given ID.
 boolean isReadOnly()
          Get the ldap readOnly configuration value.
 boolean isUserInGroup(String groupCN, String userLogin)
          Checks if a given user belongs to a given group.
 void removeGroup(String groupCN)
          Removes an existing group from the LDAP tree.
 void removeGroupAttribute(String commonName, String attributeName)
          Removes an attribute from a given group.
 void removeUser(String loginName)
          Removes an existing user from the LDAP tree.
 void removeUserAttribute(String loginName, String attributeName)
          Removes an attribute from a given user.
 void removeUserFromGroup(String groupCN, String userLogin)
          Removes a user from a given group.
 void resetConfigurations()
          Resets the LDAP configurations.
 void setGroupAttribute(String loginName, String attributeName, Object value)
          Sets a given attribute value.
 void setLogger(pt.digitalis.log.ILogWrapper logger)
          Set the API logger
 void setUserAttribute(String loginName, String attributeName, Object value)
          Sets the a given attribute value.
 void updateGroup(LDAPGroup groupToUpdate, String groupID)
          Updates an existing group on the LDAP tree.
 void updateUser(LDAPUser userToUpdate, String userLogin)
          Updates an existing user on the LDAP tree.
 boolean userContainsAttribute(String attributeName, String loginName)
          Checks if a given attribute belongs to the entity.
 boolean userExists(String loginName)
          Checks if a user exists on the LDAP tree.
 

Method Detail

addGroup

void addGroup(LDAPGroup newGroup)
              throws LDAPOperationException
Adds a new group to the LDAP tree.

Parameters:
newGroup - the group to add
Throws:
LDAPOperationException - if the group can't be created

addGroupAttribute

void addGroupAttribute(String commonName,
                       String attributeName,
                       Object value)
                       throws LDAPOperationException
Adds an attribute to a given group.

Parameters:
commonName - the group's common name
attributeName - the attribute name
value - the attribute value
Throws:
LDAPOperationException

addUser

void addUser(LDAPUser newUser)
             throws LDAPOperationException
Adds a new user to the LDAP tree.

Parameters:
newUser - the new user to add to the LDAP server
Throws:
LDAPOperationException - if the user can't be created

addUserAttribute

void addUserAttribute(String loginName,
                      String attributeName,
                      Object value)
                      throws LDAPOperationException
Adds an attribute to a given user.

Parameters:
loginName - the user login name
attributeName - the attribute name
value - the attribute value
Throws:
LDAPOperationException - if the attribute can't be added

addUserToGroup

void addUserToGroup(String groupCN,
                    String userLogin)
                    throws LDAPOperationException
Adds a user from a given group.

Parameters:
groupCN - the CN of the group
userLogin - the login name of the user to add
Throws:
LDAPOperationException - if the user groups can't be added

changePassword

void changePassword(String loginName,
                    String newPassword)
                    throws LDAPOperationException
Changes the password for a given user.

Parameters:
loginName - the login name of the user to change the password
newPassword - the new password to set
Throws:
LDAPOperationException - if the operation cannot be executed

countAllfUsers

int countAllfUsers(String groupId)
                   throws LDAPOperationException
Counts all users of a given group.

Parameters:
groupId - The group identifier
Returns:
The number of users of this group.
Throws:
LDAPOperationException

countAllGroups

int countAllGroups()
                   throws NamingException,
                          LDAPOperationException
Counts all groups in the LDAP directory

Returns:
the number of groups in the LDAP directory
Throws:
NamingException
LDAPOperationException

countAllGroupsOfUser

int countAllGroupsOfUser(String loginName)
                         throws NamingException,
                                LDAPOperationException
Counts all groups of a user

Parameters:
loginName - The user login name
Returns:
the number of users in the LDAP directory
Throws:
NamingException
LDAPOperationException

countAllUsers

int countAllUsers()
                  throws NamingException,
                         LDAPOperationException
Counts all users in the LDAP directory

Returns:
the number of users in the LDAP directory
Throws:
NamingException
LDAPOperationException

countUsers

int countUsers(Map<String,String> attributes)
               throws LDAPOperationException
Count users in the LDAP directory which match the provided attributes

Parameters:
attributes - The attributes to be considered in the search
Returns:
The number of users that match the provided attributes
Throws:
LDAPOperationException - if the operation can't be executed

findAllGroups

Set<LDAPGroup> findAllGroups()
                             throws LDAPOperationException
Returns the list of all groups.

Returns:
the list of all the groups
Throws:
LDAPOperationException - if the operation can't be executed

findAllUsers

Set<LDAPUser> findAllUsers()
                           throws LDAPOperationException
Returns the list of all users.

Returns:
the list of all the users
Throws:
LDAPOperationException - if the operation can't be executed

findGroupByCommonName

LDAPGroup findGroupByCommonName(String cn)
                                throws LDAPOperationException
Returns the group with a given common name.

Parameters:
cn - the group's common name
Returns:
the LDAPGroup with the given common name
Throws:
LDAPOperationException - if the operation cannot be executed

findGroupByDistinguishedName

LDAPGroup findGroupByDistinguishedName(String dn)
                                       throws LDAPOperationException
Returns the group with a given distinguished name.

Parameters:
dn - the group's distinguished name
Returns:
the LDAPGroup with the given distinguished name
Throws:
LDAPOperationException - if the operation cannot be executed

findGroups

Set<LDAPGroup> findGroups(int rowsPerPage,
                          int pageToReturn)
                          throws LDAPOperationException
Finds a subset of all the groups, according to the parameters

Parameters:
rowsPerPage - The number of rows per page
pageToReturn - The page number to return
Returns:
The list containing the specified subset of groups
Throws:
LDAPOperationException - if the operation cannot be executed.

findGroupsOfUser

Set<LDAPGroup> findGroupsOfUser(String loginName)
                                throws LDAPOperationException
Returns the list of a given user's groups.

Parameters:
loginName - the user's login name
Returns:
the list of all the groups that the user belongs to
Throws:
LDAPOperationException - if the operation can't be executed

findGroupsOfUserPagination

Set<LDAPGroup> findGroupsOfUserPagination(String loginName,
                                          int rowsPerPage,
                                          int pageToReturn)
                                          throws LDAPOperationException
Returns the list of a given user's groups, with pagination

Parameters:
loginName - the user's login name
rowsPerPage - The number of results per page
pageToReturn - The page number to return
Returns:
the list of all the groups that the user belongs to
Throws:
LDAPOperationException - if the operation can't be executed

findUserByDistinguishedName

LDAPUser findUserByDistinguishedName(String dn)
                                     throws LDAPOperationException
Returns the user with a given distinguished name.

Parameters:
dn - the user's login name
Returns:
the LDAPUser with the given login name
Throws:
LDAPOperationException - if the operation cannot be executed

findUserByLogin

LDAPUser findUserByLogin(String loginName)
                         throws LDAPOperationException
Returns the user with a given login name.

Parameters:
loginName - the user's login name
Returns:
the LDAPUser with the given login name
Throws:
LDAPOperationException - if the operation cannot be executed

findUsers

Set<LDAPUser> findUsers(int rowsPerPage,
                        int pageToReturn)
                        throws LDAPOperationException
Finds a subset of all the users, according to the parameters

Parameters:
rowsPerPage - The number of rows per page
pageToReturn - The page number to return
Returns:
The list containing the specified subset of groups
Throws:
LDAPOperationException - if the operation cannot be executed

findUsersByAttribute

Set<LDAPUser> findUsersByAttribute(String attribute,
                                   String value)
                                   throws LDAPOperationException
Returns the list of users with a given attribute value.

Parameters:
attribute - the attribute to search
value - the value for the attribute
Returns:
the LDAPUser with the given login name
Throws:
LDAPOperationException - if the operation cannot be executed

findUsersByAttributes

Set<LDAPUser> findUsersByAttributes(Map<String,String> attributes)
                                    throws LDAPOperationException
Finds a set of LDAP users that match all of the specified criteria

Parameters:
attributes - A map of (attribute, attribute value) pairs
Returns:
A set of LDAP users that match all of the specified criteria
Throws:
LDAPOperationException - if the operation cannot be executed

findUsersByAttributes

Set<LDAPUser> findUsersByAttributes(Map<String,String> attributes,
                                    int rowsPerPage,
                                    int pageToReturn)
                                    throws LDAPOperationException
Finds a set of LDAP users that match all of the specified criteria

Parameters:
attributes - A map of (attribute, attribute value) pairs
rowsPerPage - The number of results per page
pageToReturn - The number of the page to return
Returns:
A set of LDAP users that match all of the specified criteria
Throws:
LDAPOperationException - if the operation cannot be executed

findUsersByEmail

Set<LDAPUser> findUsersByEmail(String value)
                               throws LDAPOperationException
Returns the list of users with a given email attribute value.

Parameters:
value - the value for the attribute email
Returns:
the LDAPUser with the given login name
Throws:
LDAPOperationException - if the operation cannot be executed

findUsersInGroup

Map<String,LDAPUser> findUsersInGroup(String groupCN)
                                      throws LDAPOperationException
Checks if a given user belongs to a given group.

Parameters:
groupCN - the group's CN
Returns:
a map of the group's users ()
Throws:
LDAPOperationException - if the operation can't be executed

getChildGroupsByCN

Set<LDAPGroup> getChildGroupsByCN(String commonName)
                                  throws LDAPOperationException
Returns the list of groups that belong to a parent group given its common name.

Parameters:
commonName - the parent group's common name
Returns:
the list of all the groups that the user belongs to the parent group
Throws:
LDAPOperationException - if the operation can't be executed

getChildGroupsByDN

Set<LDAPGroup> getChildGroupsByDN(String distinguishedName)
                                  throws LDAPOperationException
Returns the list of groups that belong to a parent group given its distinguished name.

Parameters:
distinguishedName - the parent group's distinguished name
Returns:
the list of all the groups that the user belongs to the parent group
Throws:
LDAPOperationException - if the operation can't be executed

getConfigurations

LDAPConfigurations getConfigurations()
Inspector for the LDAP configurations object.

Returns:
the LDAP configurations object

getGroupAttribute

Object getGroupAttribute(String attributeName,
                         String commonName)
                         throws LDAPOperationException
Returns a given attribute or null of it doesn't exists.

Parameters:
attributeName - the attribute name
commonName - the group common name
Returns:
the attribute with the given id
Throws:
LDAPOperationException - if the user attribute can't be fetched

getGroupAttributeName

String getGroupAttributeName()
Gets the name attribute name

Returns:
The string containing the attribute name.

getGroupAttributes

Map<String,Object> getGroupAttributes(String commonName)
                                      throws LDAPOperationException
Returns the attribute map.

Parameters:
commonName - the group common name
Returns:
the attribute map
Throws:
LDAPOperationException - if the user attributes can't be fetched

getMailAttributeName

String getMailAttributeName()
Gets the mail attribute name

Returns:
The string containing the attribute name.

getNameAttributeName

String getNameAttributeName()
Gets the name attribute name

Returns:
The string containing the attribute name.

getNonAvailableValue

String getNonAvailableValue()
Get the Non Available Message.

Returns:
the Non Available message.

getUnchangeableLDAPAttributes

List<String> getUnchangeableLDAPAttributes()
Get the list of the LDAP unchangeable attributes

Returns:
the list of attributes

getUserAttribute

Object getUserAttribute(String attributeName,
                        String loginName)
                        throws LDAPOperationException
Returns a given attribute or null of it doesn't exists.

Parameters:
attributeName - the attribute name
loginName - the user login name
Returns:
the attribute with the given id
Throws:
LDAPOperationException - if the user attribute can't be fetched

getUserAttributes

Map<String,Object> getUserAttributes(String loginName)
                                     throws LDAPOperationException
Returns the attribute map.

Parameters:
loginName - the user login name
Returns:
the attribute map
Throws:
LDAPOperationException - if the user attributes can't be fetched

getUserLoginAttributeName

String getUserLoginAttributeName()
Gets the user login attribute name

Returns:
The string containing the attribute name.

getUserParentGroupAttributeName

String getUserParentGroupAttributeName()
Returns the parent group attribute name.

Returns:
A string containing the parent group attribute name

groupContainsAttribute

boolean groupContainsAttribute(String attributeName,
                               String commonName)
                               throws LDAPOperationException
Checks if a given attribute belongs to the entity.

Parameters:
attributeName - the attribute name
commonName - the group common name
Returns:
T if the entity has the attribute, F otherwise
Throws:
LDAPOperationException - if the user attribute can't be fetched

groupExists

boolean groupExists(String groupCN)
                    throws LDAPOperationException
Checks if a given group exists on the LDAP tree.

Parameters:
groupCN - the group's CN
Returns:
T if the group is found on the LDAP tree, F otherwise
Throws:
LDAPOperationException - if the operation can't be executed

isIdentityValid

boolean isIdentityValid(String loginName,
                        String suppliedPassword)
                        throws LDAPOperationException
Checks if the supplied password matches the one defined for a user with a given ID.

Parameters:
loginName - the user ID
suppliedPassword - the supplied user password
Returns:
T if user if its identity is valid, F otherwise
Throws:
LDAPOperationException - if the operation cannot be executed

isReadOnly

boolean isReadOnly()
Get the ldap readOnly configuration value.

Returns:
true or false

isUserInGroup

boolean isUserInGroup(String groupCN,
                      String userLogin)
                      throws LDAPOperationException
Checks if a given user belongs to a given group.

Parameters:
groupCN - the group's CN
userLogin - the user's login name
Returns:
T if the user belongs to the given group, F otherwise
Throws:
LDAPOperationException - if the operation can't be executed

removeGroup

void removeGroup(String groupCN)
                 throws LDAPOperationException
Removes an existing group from the LDAP tree.

Parameters:
groupCN - the group to add
Throws:
LDAPOperationException - if the group can't be removed

removeGroupAttribute

void removeGroupAttribute(String commonName,
                          String attributeName)
                          throws LDAPOperationException
Removes an attribute from a given group.

Parameters:
commonName - the group's common name
attributeName - the attribute name
Throws:
LDAPOperationException

removeUser

void removeUser(String loginName)
                throws LDAPOperationException
Removes an existing user from the LDAP tree.

Parameters:
loginName - the id of the user to remove
Throws:
LDAPOperationException - if the user can't be removed

removeUserAttribute

void removeUserAttribute(String loginName,
                         String attributeName)
                         throws LDAPOperationException
Removes an attribute from a given user.

Parameters:
loginName - the user login name
attributeName - the attribute name
Throws:
LDAPOperationException - if the attribute can't be added

removeUserFromGroup

void removeUserFromGroup(String groupCN,
                         String userLogin)
                         throws LDAPOperationException
Removes a user from a given group.

Parameters:
groupCN - the CN of the group
userLogin - the login name of the user to remove
Throws:
LDAPOperationException - if the user groups can't be removed

resetConfigurations

void resetConfigurations()
Resets the LDAP configurations. Forces the configurations to be re-read. VALIDATE: Viegas: This method is helpful to change the configurations in runtime. For example, a management interface user might choose to change the root username or password. The changes must be reflected immediately so the user can keep it's privileges. The management interface should call this method to reinitialize the configurations.


setGroupAttribute

void setGroupAttribute(String loginName,
                       String attributeName,
                       Object value)
                       throws LDAPOperationException
Sets a given attribute value.

Parameters:
loginName - the user login name
attributeName - the attribute name
value - the attribute value
Throws:
LDAPOperationException - if the attribute can't be set

setLogger

void setLogger(pt.digitalis.log.ILogWrapper logger)
Set the API logger

Parameters:
logger - the new logger value to set

setUserAttribute

void setUserAttribute(String loginName,
                      String attributeName,
                      Object value)
                      throws LDAPOperationException
Sets the a given attribute value.

Parameters:
loginName - the user login name
attributeName - the attribute name
value - the attribute value
Throws:
LDAPOperationException - if the attribute can't be set

updateGroup

void updateGroup(LDAPGroup groupToUpdate,
                 String groupID)
                 throws LDAPOperationException
Updates an existing group on the LDAP tree. Does nothing if the user doesn't exist.

Parameters:
groupToUpdate - the user to update
groupID - the group ID
Throws:
LDAPOperationException - if the group cannot be updated

updateUser

void updateUser(LDAPUser userToUpdate,
                String userLogin)
                throws LDAPOperationException
Updates an existing user on the LDAP tree. Does nothing if the user doesn't exist.

Parameters:
userToUpdate - the user to update
userLogin - the user's original login
Throws:
LDAPOperationException - if the operation cannot be executed

userContainsAttribute

boolean userContainsAttribute(String attributeName,
                              String loginName)
                              throws LDAPOperationException
Checks if a given attribute belongs to the entity.

Parameters:
attributeName - the attribute name
loginName - the user login name
Returns:
T if the entity has the attribute, F otherwise
Throws:
LDAPOperationException - if the user attribute can't be fetched

userExists

boolean userExists(String loginName)
                   throws LDAPOperationException
Checks if a user exists on the LDAP tree.

Parameters:
loginName - the ID of the user
Returns:
T if the user exists, F otherwise
Throws:
LDAPOperationException - if the operation cannot be executed


Copyright © 2012 Digitalis Informática Lda. All Rights Reserved.