Class DefaultLdapRoleMapper
- java.lang.Object
-
- org.apache.archiva.redback.common.ldap.role.DefaultLdapRoleMapper
-
- All Implemented Interfaces:
LdapRoleMapper
@Service("ldapRoleMapper#default") public class DefaultLdapRoleMapper extends Object implements LdapRoleMapper- Since:
- 2.1
- Author:
- Olivier Lamy
-
-
Field Summary
Fields Modifier and Type Field Description static StringDEFAULT_DESCRIPTION_ATTRIBUTEstatic StringDEFAULT_GROUP_NAME_ATTRIBUTEstatic StringDEFAULT_USER_ID_ATTRIBUTEpossible to user cn=beer or uid=beer or sn=beer etc so make it configurable
-
Constructor Summary
Constructors Constructor Description DefaultLdapRoleMapper()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcloseNamingEnumeration(NamingEnumeration namingEnumeration)protected StringfindGroupName(String role)List<LdapGroup>getAllGroupObjects(DirContext context)Read all groups from LDAP and return the list of group objects.List<String>getAllGroups(DirContext context)read all groups from ldapList<String>getAllRoles(DirContext context)read all ldap groups then map to corresponding role (if no mapping found group is ignored)StringgetBaseDn()LdapGroupgetGroupForName(DirContext context, String groupName)List<LdapGroup>getGroupObjects(String username, DirContext context)List<String>getGroups(String username, DirContext context)StringgetGroupsDn()List<String>getGroupsMember(String group, DirContext context)StringgetLdapDnAttribute()StringgetLdapGroupClass()StringgetLdapGroupMemberAttribute()List<String>getRoles(String username, DirContext context, Collection<String> realRoles)StringgetUserIdAttribute()booleanhasRole(DirContext context, String roleName)voidinitialize()booleanisUseDefaultRoleName()voidremoveAllRoles(DirContext context)voidremoveRole(String roleName, DirContext context)booleanremoveUserRole(String roleName, String username, DirContext context)booleansaveRole(String roleName, DirContext context)will save a ldap group corresponding to the mapping.booleansaveUserRole(String roleName, String username, DirContext context)associate role to user in ldapvoidsetBaseDn(String baseDn)voidsetGroupsDn(String groupsDn)voidsetLdapConnectionFactory(LdapConnectionFactory ldapConnectionFactory)voidsetLdapGroupClass(String ldapGroupClass)voidsetLdapGroupMemberAttribute(String ldapGroupMemberAttribute)voidsetUseDefaultRoleName(boolean useDefaultRoleName)voidsetUserConf(UserConfiguration userConf)voidsetUserIdAttribute(String userIdAttribute)
-
-
-
Field Detail
-
DEFAULT_USER_ID_ATTRIBUTE
public static String DEFAULT_USER_ID_ATTRIBUTE
possible to user cn=beer or uid=beer or sn=beer etc so make it configurable
-
DEFAULT_GROUP_NAME_ATTRIBUTE
public static String DEFAULT_GROUP_NAME_ATTRIBUTE
-
DEFAULT_DESCRIPTION_ATTRIBUTE
public static String DEFAULT_DESCRIPTION_ATTRIBUTE
-
-
Constructor Detail
-
DefaultLdapRoleMapper
public DefaultLdapRoleMapper()
-
-
Method Detail
-
initialize
@PostConstruct public void initialize()
-
getAllGroups
public List<String> getAllGroups(DirContext context) throws MappingException
Description copied from interface:LdapRoleMapperread all groups from ldap- Specified by:
getAllGroupsin interfaceLdapRoleMapper- Returns:
- all LDAP groups
- Throws:
MappingException
-
getAllGroupObjects
public List<LdapGroup> getAllGroupObjects(DirContext context) throws MappingException
Description copied from interface:LdapRoleMapperRead all groups from LDAP and return the list of group objects.- Specified by:
getAllGroupObjectsin interfaceLdapRoleMapper- Returns:
- all LDAP groups found in the LDAP directory
- Throws:
MappingException
-
getGroupForName
public LdapGroup getGroupForName(DirContext context, String groupName) throws MappingException
- Specified by:
getGroupForNamein interfaceLdapRoleMapper- Throws:
MappingException
-
closeNamingEnumeration
protected void closeNamingEnumeration(NamingEnumeration namingEnumeration)
-
hasRole
public boolean hasRole(DirContext context, String roleName) throws MappingException
- Specified by:
hasRolein interfaceLdapRoleMapper- Throws:
MappingException
-
getAllRoles
public List<String> getAllRoles(DirContext context) throws MappingException
Description copied from interface:LdapRoleMapperread all ldap groups then map to corresponding role (if no mapping found group is ignored)- Specified by:
getAllRolesin interfaceLdapRoleMapper- Returns:
- all roles
- Throws:
MappingException
-
getGroupsMember
public List<String> getGroupsMember(String group, DirContext context) throws MappingException
- Specified by:
getGroupsMemberin interfaceLdapRoleMapper- Parameters:
group- ldap group- Returns:
- uids of group members
- Throws:
MappingException
-
getGroups
public List<String> getGroups(String username, DirContext context) throws MappingException
- Specified by:
getGroupsin interfaceLdapRoleMapper- Throws:
MappingException
-
getGroupObjects
public List<LdapGroup> getGroupObjects(String username, DirContext context) throws MappingException
- Specified by:
getGroupObjectsin interfaceLdapRoleMapper- Throws:
MappingException
-
getRoles
public List<String> getRoles(String username, DirContext context, Collection<String> realRoles) throws MappingException
- Specified by:
getRolesin interfaceLdapRoleMapper- Throws:
MappingException
-
getGroupsDn
public String getGroupsDn()
- Specified by:
getGroupsDnin interfaceLdapRoleMapper- Returns:
- the base dn which contains all ldap groups
-
getLdapGroupClass
public String getLdapGroupClass()
- Specified by:
getLdapGroupClassin interfaceLdapRoleMapper- Returns:
- the class used for group usually groupOfUniqueNames
-
getLdapDnAttribute
public String getLdapDnAttribute()
-
saveRole
public boolean saveRole(String roleName, DirContext context) throws MappingException
Description copied from interface:LdapRoleMapperwill save a ldap group corresponding to the mapping. will do nothing in group already exists.- Specified by:
saveRolein interfaceLdapRoleMapper- Returns:
trueif role was added,falseif role already exists- Throws:
MappingException
-
saveUserRole
public boolean saveUserRole(String roleName, String username, DirContext context) throws MappingException
Description copied from interface:LdapRoleMapperassociate role to user in ldap- Specified by:
saveUserRolein interfaceLdapRoleMapper- Returns:
trueif role was added to user,falseif role already exists for the user- Throws:
MappingException
-
removeUserRole
public boolean removeUserRole(String roleName, String username, DirContext context) throws MappingException
- Specified by:
removeUserRolein interfaceLdapRoleMapper- Throws:
MappingException
-
removeAllRoles
public void removeAllRoles(DirContext context) throws MappingException
- Specified by:
removeAllRolesin interfaceLdapRoleMapper- Throws:
MappingException
-
removeRole
public void removeRole(String roleName, DirContext context) throws MappingException
- Specified by:
removeRolein interfaceLdapRoleMapper- Throws:
MappingException
-
setGroupsDn
public void setGroupsDn(String groupsDn)
-
setLdapGroupClass
public void setLdapGroupClass(String ldapGroupClass)
-
setUserConf
public void setUserConf(UserConfiguration userConf)
-
setLdapConnectionFactory
public void setLdapConnectionFactory(LdapConnectionFactory ldapConnectionFactory)
-
getLdapGroupMemberAttribute
public String getLdapGroupMemberAttribute()
-
setLdapGroupMemberAttribute
public void setLdapGroupMemberAttribute(String ldapGroupMemberAttribute)
-
findGroupName
protected String findGroupName(String role) throws MappingException
- Throws:
MappingException
-
getUserIdAttribute
public String getUserIdAttribute()
- Specified by:
getUserIdAttributein interfaceLdapRoleMapper
-
setUserIdAttribute
public void setUserIdAttribute(String userIdAttribute)
-
isUseDefaultRoleName
public boolean isUseDefaultRoleName()
- Specified by:
isUseDefaultRoleNamein interfaceLdapRoleMapper
-
setUseDefaultRoleName
public void setUseDefaultRoleName(boolean useDefaultRoleName)
-
-