|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.james.user.ldap.ReadOnlyUsersLDAPRepository
public class ReadOnlyUsersLDAPRepository
This repository implementation serves as a bridge between Apache James and LDAP. It allows James to authenticate users against an LDAP compliant server such as Apache DS or Microsoft AD. It also enables role/group based access restriction based on LDAP groups.
It is intended for organisations that already have a user-authentication and authorisation mechanism in place, and want to leverage this when deploying James. The assumption inherent here is that such organisations would not want to manage user details via James, but will do so externally using whatever mechanism provided by, or built on top off, their LDAP implementation.
Based on this assumption, this repository is strictly read-only. As a consequence, user modification, deletion and creation requests will be ignored when using this repository.
The following fragment of XML provides an example configuration to enable this repository:
<users-store>
<repository name="LDAPUsers"
class="org.apache.james.userrepository.ReadOnlyUsersLDAPRepository"
ldapHost="ldap://myldapserver:389"
principal="uid=ldapUser,ou=system"
credentials="password"
userBase="ou=People,o=myorg.com,ou=system"
userIdAttribute="uid"
userObjectClass="inetOrgPerson"
maxRetries="20"
retryStartInterval="0"
retryMaxInterval="30"
retryIntervalScale="1000"
</users-store>
Its constituent attributes are defined as follows:
Example Schedules
Exception
causing the fault is thrown:
Exception causing the fault is thrown:
In order to enable group/role based access restrictions, you can use the
"<restriction>" configuration element. An example of this is
shown below:
<restriction
memberAttribute="uniqueMember">
<group>cn=PermanentStaff,ou=Groups,o=myorg.co.uk,ou=system</group>
<group>cn=TemporaryStaff,ou=Groups,o=myorg.co.uk,ou=system</group>
</restriction>
Its constituent attributes and elements are defined as follows:
The following parameters may be used to adjust the underlying
com.sun.jndi.ldap.LdapCtxFactory. See LDAP Naming Service Provider for the Java Naming and Directory InterfaceTM
(JNDI) : Provider-specific Properties for details.
com.sun.jndi.ldap.connect.pool to the specified boolean value
com.sun.jndi.ldap.connect.timeout to the specified integer value
com.sun.jndi.ldap.read.timeout to the specified integer value.
Applicable to Java 6 and above.
ReadOnlyLDAPUser,
ReadOnlyLDAPGroupRestriction| Constructor Summary | |
|---|---|
ReadOnlyUsersLDAPRepository()
Creates a new instance of ReadOnlyUsersLDAPRepository. |
|
| Method Summary | |
|---|---|
void |
addUser(String username,
String password)
|
protected LdapContext |
computeLdapContext()
Answers a new LDAP/JNDI context using the specified user credentials. |
void |
configure(org.apache.commons.configuration.HierarchicalConfiguration configuration)
Extracts the parameters required by the repository instance from the James server configuration data. |
boolean |
contains(String name)
|
boolean |
containsCaseInsensitive(String name)
|
int |
countUsers()
|
protected Properties |
getContextEnvironment()
|
protected LdapContext |
getLdapContext()
Answer the LDAP context used to connect with the LDAP server. |
String |
getRealName(String name)
|
User |
getUserByName(String name)
|
User |
getUserByNameCaseInsensitive(String name)
|
void |
init()
Initialises the user-repository instance. |
Iterator<String> |
list()
|
void |
removeUser(String name)
|
void |
setLog(org.slf4j.Logger log)
|
boolean |
supportVirtualHosting()
VirtualHosting not supported |
boolean |
test(String name,
String password)
|
protected void |
updateLdapContext()
|
void |
updateUser(User user)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ReadOnlyUsersLDAPRepository()
| Method Detail |
|---|
public void configure(org.apache.commons.configuration.HierarchicalConfiguration configuration)
throws org.apache.commons.configuration.ConfigurationException
ldapHost, userIdAttribute, userBase,
principal, credentials and restriction.
configure in interface Configurableconfiguration - An encapsulation of the James server configuration data.
org.apache.commons.configuration.ConfigurationException
@PostConstruct
public void init()
throws Exception
Exception - If an error occurs authenticating or connecting to the
specified LDAP host.
protected LdapContext getLdapContext()
throws NamingException
LdapContext
NamingException
protected void updateLdapContext()
throws NamingException
NamingException
protected LdapContext computeLdapContext()
throws NamingException
NamingException - Propagated from underlying LDAP communication API.protected Properties getContextEnvironment()
public boolean contains(String name)
throws UsersRepositoryException
contains in interface UsersRepositoryUsersRepositoryExceptionUsersRepository.contains(java.lang.String)
public boolean containsCaseInsensitive(String name)
throws UsersRepositoryException
UsersRepositoryException
public int countUsers()
throws UsersRepositoryException
countUsers in interface UsersRepositoryUsersRepositoryExceptionUsersRepository.countUsers()
public String getRealName(String name)
throws UsersRepositoryException
UsersRepositoryException
public User getUserByName(String name)
throws UsersRepositoryException
getUserByName in interface UsersRepositoryUsersRepositoryExceptionUsersRepository.getUserByName(java.lang.String)
public User getUserByNameCaseInsensitive(String name)
throws UsersRepositoryException
UsersRepositoryException
public Iterator<String> list()
throws UsersRepositoryException
list in interface UsersRepositoryUsersRepositoryExceptionUsersRepository.list()
public void removeUser(String name)
throws UsersRepositoryException
removeUser in interface UsersRepositoryUsersRepositoryExceptionUsersRepository.removeUser(java.lang.String)
public boolean test(String name,
String password)
throws UsersRepositoryException
test in interface UsersRepositoryUsersRepositoryExceptionUsersRepository.test(java.lang.String, java.lang.String)
public void addUser(String username,
String password)
throws UsersRepositoryException
addUser in interface UsersRepositoryUsersRepositoryExceptionUsersRepository.addUser(java.lang.String, java.lang.String)
public void updateUser(User user)
throws UsersRepositoryException
updateUser in interface UsersRepositoryUsersRepositoryExceptionUsersRepository#updateUser(org.apache.james.api.user.User)public void setLog(org.slf4j.Logger log)
setLog in interface LogEnabledLogEnabled.setLog(org.slf4j.Logger)
public boolean supportVirtualHosting()
throws UsersRepositoryException
supportVirtualHosting in interface UsersRepositoryUsersRepositoryException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||