|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.xpn.xwiki.plugin.ldap.XWikiLDAPUtils
public class XWikiLDAPUtils
LDAP communication tool.
Constructor Summary | |
---|---|
XWikiLDAPUtils(XWikiLDAPConnection connection)
Create an instance of XWikiLDAPUtils . |
Method Summary | |
---|---|
protected void |
addUserToXWikiGroup(String xwikiUserName,
String groupName,
XWikiContext context)
Add user name to provided XWiki group. |
protected void |
createUserFromLDAP(XWikiDocument userProfile,
List<XWikiLDAPSearchAttribute> searchAttributes,
String ldapDN,
String ldapUid,
XWikiContext context)
Create an XWiki user and set all mapped attributes from LDAP to XWiki attributes. |
protected String |
findInGroup(String userName,
Map<String,String> groupMembers,
XWikiContext context)
Locates the user in the Map: either the user is a value or the key starts with the LDAP syntax. |
String[] |
getAttributeNameTable(XWikiContext context)
|
String |
getBaseDN()
|
Cache<Map<String,String>> |
getCache(CacheConfiguration configuration,
XWikiContext context)
Deprecated. use getGroupCache(CacheConfiguration, XWikiContext) instead since 4.1M1 |
XWikiLDAPConnection |
getConnection()
|
Cache<Map<String,String>> |
getGroupCache(CacheConfiguration configuration,
XWikiContext context)
Get the cache with the provided name for a particular LDAP server. |
static CacheConfiguration |
getGroupCacheConfiguration(XWikiContext context)
|
Collection<String> |
getGroupClasses()
|
Collection<String> |
getGroupMemberFields()
|
boolean |
getGroupMembers(Map<String,String> memberMap,
List<String> subgroups,
com.novell.ldap.LDAPEntry ldapEntry,
XWikiContext context)
Get all members of a given group based on the groupDN. |
boolean |
getGroupMembers(String groupDN,
Map<String,String> memberMap,
List<String> subgroups,
List<XWikiLDAPSearchAttribute> searchAttributeList,
XWikiContext context)
Get all members of a given group based on the groupDN. |
boolean |
getGroupMembers(String userOrGroup,
Map<String,String> memberMap,
List<String> subgroups,
XWikiContext context)
Get all members of a given group based on the groupDN. |
Map<String,String> |
getGroupMembers(String groupDN,
XWikiContext context)
Get group members from cache or update it from LDAP if it is not already cached. |
boolean |
getGroupMembersFromDN(String userOrGroupDN,
Map<String,String> memberMap,
List<String> subgroups,
XWikiContext context)
Get all members of a given group based on the groupDN. |
boolean |
getGroupMembersFromFilter(String filter,
Map<String,String> memberMap,
List<String> subgroups,
XWikiContext context)
Get all members of a given group based on the groupDN. |
boolean |
getGroupMembersSearchResult(com.novell.ldap.LDAPSearchResults result,
Map<String,String> memberMap,
List<String> subgroups,
XWikiContext context)
Get all members of a given group based on the the result of a LDAP search. |
String |
getUidAttributeName()
|
XWikiDocument |
getUserProfileByUid(String validXWikiUserName,
String ldapUid,
XWikiContext context)
|
String |
getUserSearchFormatString()
|
boolean |
isMemberOfGroup(String memberDN,
String groupDN,
XWikiContext context)
Check if provided DN is in provided LDAP group. |
boolean |
isMemberOfGroups(String memberDN,
Collection<String> groupDNList,
XWikiContext context)
Check if provided DN is in one of the provided LDAP groups. |
String |
isUidInGroup(String userName,
String groupDN,
XWikiContext context)
Check if user is in provided LDAP group. |
protected void |
removeUserFromXWikiGroup(String xwikiUserName,
String groupName,
XWikiContext context)
Remove user name from provided XWiki group. |
static void |
resetGroupCache()
Force to empty the group cache. |
List<XWikiLDAPSearchAttribute> |
searchUserAttributesByUid(String uid,
String[] attributeNameTable)
|
String |
searchUserDNByUid(String uid)
|
void |
setBaseDN(String baseDN)
|
void |
setGroupClasses(Collection<String> groupClasses)
|
void |
setGroupMemberFields(Collection<String> groupMemberFields)
|
void |
setUidAttributeName(String uidAttributeName)
|
void |
setUserSearchFormatString(String fmt)
|
void |
syncGroupsMembership(String xwikiUserName,
String userDN,
Map<String,Set<String>> groupMappings,
XWikiContext context)
Synchronize user XWiki membership with it's LDAP membership. |
void |
syncUser(XWikiDocument userProfile,
List<XWikiLDAPSearchAttribute> searchAttributeListIn,
String ldapDn,
String ldapUid,
XWikiContext context)
Update or create XWiki user base on LDAP. |
protected void |
updateUserFromLDAP(XWikiDocument userProfile,
List<XWikiLDAPSearchAttribute> searchAttributes,
String ldapDN,
String ldapUid,
XWikiContext context)
Sets attributes on the user object based on attribute values provided by the LDAP. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public XWikiLDAPUtils(XWikiLDAPConnection connection)
XWikiLDAPUtils
.
connection
- the XWiki LDAP connection tool.Method Detail |
---|
public void setUidAttributeName(String uidAttributeName)
uidAttributeName
- the LDAP attribute containing the identifier for a user.public String getUidAttributeName()
public void setBaseDN(String baseDN)
baseDN
- the LDAP base DN from where to executes LDAP queries.public String getBaseDN()
public void setUserSearchFormatString(String fmt)
fmt
- the user search format string.public String getUserSearchFormatString()
public void setGroupClasses(Collection<String> groupClasses)
groupClasses
- the different LDAP implementations groups classes names.public Collection<String> getGroupClasses()
public void setGroupMemberFields(Collection<String> groupMemberFields)
groupMemberFields
- the different LDAP implementations groups member property name.public Collection<String> getGroupMemberFields()
@Deprecated public Cache<Map<String,String>> getCache(CacheConfiguration configuration, XWikiContext context) throws CacheException
getGroupCache(CacheConfiguration, XWikiContext)
instead since 4.1M1
configuration
- the configuration to use to create the cache and to find it if it's already created.context
- the XWiki context.
CacheException
- error when creating the cache.public Cache<Map<String,String>> getGroupCache(CacheConfiguration configuration, XWikiContext context) throws CacheException
configuration
- the configuration to use to create the cache and to find it if it's already created.context
- the XWiki context.
CacheException
- error when creating the cache.public static void resetGroupCache()
public XWikiLDAPConnection getConnection()
XWikiLDAPConnection
.public boolean getGroupMembers(String groupDN, Map<String,String> memberMap, List<String> subgroups, List<XWikiLDAPSearchAttribute> searchAttributeList, XWikiContext context)
groupDN
- the group to retrieve the members of and scan for subgroups.memberMap
- the result: maps DN to member id.subgroups
- all the subgroups identified.searchAttributeList
- the groups members found in LDAP search.context
- the XWiki context.
public boolean getGroupMembers(Map<String,String> memberMap, List<String> subgroups, com.novell.ldap.LDAPEntry ldapEntry, XWikiContext context) throws com.novell.ldap.LDAPException
memberMap
- the result: maps DN to member id.subgroups
- all the subgroups identified.ldapEntry
- the ldap entry returned by a search members found in LDAP search.context
- the XWiki context.
com.novell.ldap.LDAPException
- error when parsing the provided LDAP entrypublic boolean getGroupMembers(String userOrGroup, Map<String,String> memberMap, List<String> subgroups, XWikiContext context)
userOrGroup
- the group to retrieve the members of and scan for subgroups. Can be
memberMap
- the result: maps DN to member id.subgroups
- all the subgroups identified.context
- the XWiki context.
public boolean getGroupMembersFromDN(String userOrGroupDN, Map<String,String> memberMap, List<String> subgroups, XWikiContext context)
userOrGroupDN
- the group DN to retrieve the members from or the user DN to add in the members map.memberMap
- the result: maps DN to member id.subgroups
- all the subgroups identified.context
- the XWiki context.
public boolean getGroupMembersFromFilter(String filter, Map<String,String> memberMap, List<String> subgroups, XWikiContext context)
filter
- the LDAP filter to search with.memberMap
- the result: maps DN to member id.subgroups
- all the subgroups identified.context
- the XWiki context.
public boolean getGroupMembersSearchResult(com.novell.ldap.LDAPSearchResults result, Map<String,String> memberMap, List<String> subgroups, XWikiContext context)
result
- the result of a LDAP search.memberMap
- the result: maps DN to member id.subgroups
- all the subgroups identified.context
- the XWiki context.
public Map<String,String> getGroupMembers(String groupDN, XWikiContext context) throws XWikiException
groupDN
- the name of the group.context
- the XWiki context.
XWikiException
- error when getting the group cache.public boolean isMemberOfGroup(String memberDN, String groupDN, XWikiContext context) throws XWikiException
memberDN
- the DN to find in the provided group.groupDN
- the DN of the group where to search.context
- the XWiki context.
XWikiException
- error when searching for group members.public boolean isMemberOfGroups(String memberDN, Collection<String> groupDNList, XWikiContext context) throws XWikiException
memberDN
- the DN to find in the provided groups.groupDNList
- the list of DN of the groups where to search.context
- the XWiki context.
XWikiException
- error when searching for group members.public static CacheConfiguration getGroupCacheConfiguration(XWikiContext context)
context
- the XWiki context used to get cache configuration.
protected String findInGroup(String userName, Map<String,String> groupMembers, XWikiContext context)
userName
- the name of the user.groupMembers
- the members of LDAP group.context
- the XWiki context.
public String isUidInGroup(String userName, String groupDN, XWikiContext context) throws XWikiException
userName
- the user name.groupDN
- the LDAP group DN.context
- the XWiki context.
XWikiException
- error when getting the group cache.public List<XWikiLDAPSearchAttribute> searchUserAttributesByUid(String uid, String[] attributeNameTable)
uid
- the unique identifier of the user in the LDAP server.attributeNameTable
- the names of the LDAP user attributes to query.
public String searchUserDNByUid(String uid)
uid
- the unique identifier of the user in the LDAP server.
public void syncUser(XWikiDocument userProfile, List<XWikiLDAPSearchAttribute> searchAttributeListIn, String ldapDn, String ldapUid, XWikiContext context) throws XWikiException
userProfile
- the name of the user.ldapDn
- the LDAP user DN.ldapUid
- the UID field.searchAttributeListIn
- the attributes of the LDAP user.context
- the XWiki context.
XWikiException
- error when updating or creating XWiki user.public void syncGroupsMembership(String xwikiUserName, String userDN, Map<String,Set<String>> groupMappings, XWikiContext context) throws XWikiException
xwikiUserName
- the name of the user.userDN
- the LDAP DN of the user.groupMappings
- the mapping between XWiki groups names and LDAP groups names.context
- the XWiki context.
XWikiException
- error when synchronizing user membership.public String[] getAttributeNameTable(XWikiContext context)
context
- the XWiki context.
protected void createUserFromLDAP(XWikiDocument userProfile, List<XWikiLDAPSearchAttribute> searchAttributes, String ldapDN, String ldapUid, XWikiContext context) throws XWikiException
userProfile
- the XWiki user profile.searchAttributes
- the attributes.ldapDN
- the LDAP DN of the user.ldapUid
- the LDAP unique id of the user.context
- the XWiki context.
XWikiException
- error when creating XWiki user.protected void updateUserFromLDAP(XWikiDocument userProfile, List<XWikiLDAPSearchAttribute> searchAttributes, String ldapDN, String ldapUid, XWikiContext context) throws XWikiException
userProfile
- the XWiki user profile document.searchAttributes
- the attributes of the LDAP user to update.ldapDN
- the DN of the LDAP user to updateldapUid
- value of the unique identifier for the user to update.context
- the XWiki context.
XWikiException
- error when updating XWiki user.protected void addUserToXWikiGroup(String xwikiUserName, String groupName, XWikiContext context)
xwikiUserName
- the full name of the user.groupName
- the name of the group.context
- the XWiki context.protected void removeUserFromXWikiGroup(String xwikiUserName, String groupName, XWikiContext context)
xwikiUserName
- the full name of the user.groupName
- the name of the group.context
- the XWiki context.public XWikiDocument getUserProfileByUid(String validXWikiUserName, String ldapUid, XWikiContext context) throws XWikiException
validXWikiUserName
- the valid XWiki name of the user to get the profile for. Used for fast lookup relying
on the document cache before doing a database search.ldapUid
- the UID to get the profile forcontext
- the XWiki context
XWikiException
- when a problem occurs while retrieving the user profile
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |