Package de.elo.ix.client.ldap
Interface LdapUserDirectoryHandler
- All Known Implementing Classes:
LdapUserDirectoryHandlerWrapper
public interface LdapUserDirectoryHandler
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Assign the given groups to UserInfo.groupList.void
assignProperties
(UserInfo ui, Domain domain, String userName, Attributes attributes) Assign LDAP attributes.void
assignSuperior
(UserInfo ui, Domain domain, String userName, Attributes attributes) Assign superior.void
assignUserName
(UserInfo ui, Domain domain, String userName, Attributes attributes) Assign user name, os name and mail address.authenticate
(String loginName, String password, String runAsName) Authenticate a user and optionally return information of a second user.void
closeContext
(Context ctxt) Close Context object.createInitialDirContext
(Domain domain, Map<String, String> environment) Create an javax.naming.directory.InitialDirContext.extractGroupNameFromDN
(Domain domain, String groupDN) Extract group name from Distinguished Name.void
getGroupDNsFromAttributes
(Domain domain, String userDN, Attributes attributes, String attributeName, Set<String> groupNames) Extract the Distinguished Names of groups found in the given attributes.void
getInitialContextEnvironment
(Domain domain, String ldapUrl, String userName, String password, Map<String, String> environment) Get environment properties to create an javax.naming.directory.InitialDirContext.void
getUserAttributeNames
(Domain domain, String userDN, Set<String> attributeNames) Get user attributes to be read.getUserAttributes
(DirContext ctxt, Domain domain, String userDN, Set<String> attributeNames) Get attributes from DirContext.searchGroupsOfMember
(DirContext ctxt, Domain domain, String groupSearchDN, String filterGroups, String memberDN, int timeoutSeconds) Search groups in sub-tree of groupSearchDN that include memberDN as member.searchPerson
(DirContext ctx, Domain domain, String personSearchDN, String filterPerson, String userName, int timeoutSeconds, Set<String> attributeNames) Search person by name or mail.tryReadEloUser
(String userName, boolean mustExist) Read user from ELO.
-
Method Details
-
authenticate
UserInfo authenticate(String loginName, String password, String runAsName) throws byps.RemoteException Authenticate a user and optionally return information of a second user.- Parameters:
loginName
- User to authenticate. If runAsName is null or empty, the implementation can decide to create this user in ELO if it does not exist. If a runAsName is supplied, this user must exist in ELO. This parameter can be empty if the implementation provides a default login account.password
- Password to loginName. Ignored, if loginName is empty.runAsName
- Return information of this user. The implementation can decide to create this user in ELO if it does not exist. If this parameter is null, the returned object refers to loginName.- Returns:
- UserInfo object or null.
UserInfo.getName()
has to return the unique ELO user name.UserInfo.getId()
must return the unique ELO user ID. ReturnUserDirectory.NOT_RESPONSIBLE_FOR_AUTHENTICATION
if authentication should be processed against the ELO user database (and not against LDAP). Return null, if this handler does not process authentication (default behavior). - Throws:
byps.RemoteException
-
tryReadEloUser
Read user from ELO. If user is not found and mustExist=false, return a new UserInfo object with UserInfo.id=-1 and UserInfo.name=userName.- Parameters:
userName
-mustExist
- if true, an exception is thrown if the user does not exist.- Returns:
- UserInfo object.
- Throws:
byps.RemoteException
-
getInitialContextEnvironment
void getInitialContextEnvironment(Domain domain, String ldapUrl, String userName, String password, Map<String, String> environment) Get environment properties to create an javax.naming.directory.InitialDirContext.- Parameters:
domain
- DomainldapUrl
- Server urluserName
- User name to authenticatepassword
- User passwordenvironment
- The properties built by the other parameters have to be added to this map.
-
createInitialDirContext
InitialDirContext createInitialDirContext(Domain domain, Map<String, String> environment) throws ExceptionCreate an javax.naming.directory.InitialDirContext.- Parameters:
domain
- Domainenvironment
- Environment properties, created bygetInitialContextEnvironment(Domain, String, String, String, Map)
.- Returns:
- InitialDirContext object.
- Throws:
Exception
-
closeContext
Close Context object.- Parameters:
ctxt
- Context object.
-
searchPerson
NamingEnumeration<SearchResult> searchPerson(DirContext ctx, Domain domain, String personSearchDN, String filterPerson, String userName, int timeoutSeconds, Set<String> attributeNames) throws Exception Search person by name or mail.- Parameters:
ctx
- DirContextdomain
- DomainpersonSearchDN
- Sub-trees to be searched (Distinguished Name).filterPerson
- Filter expression.userName
- User name.timeoutSeconds
- Timeout value.attributeNames
- Attributes to return.- Returns:
- Attributes.
- Throws:
Exception
-
getUserAttributeNames
Get user attributes to be read.- Parameters:
domain
- DomainuserDN
- User Distinguished name of user.attributeNames
- Attribute names.
-
getUserAttributes
Attributes getUserAttributes(DirContext ctxt, Domain domain, String userDN, Set<String> attributeNames) throws Exception Get attributes from DirContext.- Parameters:
ctxt
- DirContextdomain
- DomainuserDN
- Distinguished name of user.attributeNames
- Attribute names.- Returns:
- Attributes
- Throws:
Exception
-
getGroupDNsFromAttributes
void getGroupDNsFromAttributes(Domain domain, String userDN, Attributes attributes, String attributeName, Set<String> groupNames) throws Exception Extract the Distinguished Names of groups found in the given attributes.- Parameters:
domain
- DomainuserDN
- Distinguished name of user.attributes
- AttributesattributeName
- Attribute name of group membershipgroupNames
- Distinguished Names of groups.- Throws:
Exception
-
extractGroupNameFromDN
Extract group name from Distinguished Name.- Parameters:
domain
- DomaingroupDN
- Group Distinguished Name- Returns:
- Simple group name.
-
searchGroupsOfMember
NamingEnumeration<SearchResult> searchGroupsOfMember(DirContext ctxt, Domain domain, String groupSearchDN, String filterGroups, String memberDN, int timeoutSeconds) throws Exception Search groups in sub-tree of groupSearchDN that include memberDN as member.- Parameters:
ctxt
- DirContextdomain
- DomaingroupSearchDN
- Distinguished Name of sub-treefilterGroups
- Filter expressionmemberDN
- Distinguished Name of group member.timeoutSeconds
- Search timeout in seconds- Returns:
- Enumeration
- Throws:
Exception
-
assignGroups
void assignGroups(UserInfo ui, Domain domain, String userName, Set<String> groupNamesOS) throws Exception Assign the given groups to UserInfo.groupList. The default implementation calls checkoutUsers to read the ELO groups and maps the group names to their IDs. Group UserInfo.ID_EVERYONE should be always assigned.- Parameters:
ui
- UserInfo.groupList is set by this function.domain
- DomainuserName
- User name.groupNamesOS
- Set of group names.- Throws:
Exception
-
assignUserName
void assignUserName(UserInfo ui, Domain domain, String userName, Attributes attributes) throws Exception Assign user name, os name and mail address.- Parameters:
ui
- UserInfo.name, UserInfo.userProps[UserInfoC.PROP_NAME_OS], and UserInfo.userProps[UserInfoC.PROP_NAME_EMAIL] are set.domain
- DomainuserName
- User name.attributes
- Attributes from LDAP server- Throws:
Exception
-
assignSuperior
void assignSuperior(UserInfo ui, Domain domain, String userName, Attributes attributes) throws Exception Assign superior.- Parameters:
ui
- UserInfo.name, UserInfo.userProps[UserInfoC.PROP_NAME_OS], and UserInfo.userProps[UserInfoC.PROP_NAME_EMAIL] are set.domain
- DomainuserName
- User name.attributes
- Attributes from LDAP server- Throws:
Exception
-
assignProperties
void assignProperties(UserInfo ui, Domain domain, String userName, Attributes attributes) throws Exception Assign LDAP attributes.- Parameters:
ui
- UserInfo.ldapProperties are setdomain
- DomainuserName
- User name.attributes
- Attributes from LDAP server- Throws:
Exception
-