|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectno.feide.moria.directory.backend.JNDIBackend
public class JNDIBackend
Java Naming and Directory Interface (JNDI) backend. Used to authenticate users and retrieve the associated attributes.
| Field Summary | |
|---|---|
private java.util.Hashtable |
defaultEnv
Default initial LDAP context environment. |
private java.lang.String |
guessedAttribute
The name of the attribute used to guess a user's (R)DN. |
private no.feide.moria.log.MessageLogger |
log
The message logger. |
private IndexedReference[] |
myReferences
The external reference of this backend. |
private java.lang.String |
mySessionTicket
The session ticket used when logging from this instance. |
private int |
myTimeout
The connection timeout used. |
private java.lang.String |
usernameAttribute
The name of the attribute holding the username. |
| Fields inherited from interface no.feide.moria.directory.backend.DirectoryManagerBackend |
|---|
ATTRIBUTE_VALUE_CHARSET, VIRTUAL_ATTRIBUTES |
| Constructor Summary | |
|---|---|
protected |
JNDIBackend(java.lang.String sessionTicket,
int timeout,
boolean ssl,
java.lang.String usernameAttributeName,
java.lang.String guessedAttributeName)
Protected constructor. |
| Method Summary | |
|---|---|
java.util.HashMap |
authenticate(Credentials userCredentials,
java.lang.String[] attributeRequest)
Authenticates the user using the supplied credentials and retrieves the requested attributes. |
void |
close()
Does nothing, but needed to fulfill the DirectoryManagerBackend interface. |
private javax.naming.ldap.InitialLdapContext |
connect(java.lang.String url)
Creates a new connection to a given backend provider URL. |
private java.util.HashMap |
getAttributes(javax.naming.ldap.InitialLdapContext ldap,
java.lang.String rdn,
java.lang.String[] attributes)
Retrieves a list of attributes from an element. |
private java.lang.String |
ldapSearch(javax.naming.ldap.InitialLdapContext ldap,
java.lang.String pattern)
Does a subtree search for an element given a pattern. |
void |
open(IndexedReference[] references)
Opens this backend. |
boolean |
userExists(java.lang.String username)
Checks whether a user element exists, based on its username value. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private final no.feide.moria.log.MessageLogger log
private IndexedReference[] myReferences
private final int myTimeout
private java.util.Hashtable defaultEnv
private java.lang.String usernameAttribute
private java.lang.String guessedAttribute
private java.lang.String mySessionTicket
| Constructor Detail |
|---|
protected JNDIBackend(java.lang.String sessionTicket,
int timeout,
boolean ssl,
java.lang.String usernameAttributeName,
java.lang.String guessedAttributeName)
throws java.lang.IllegalArgumentException,
java.lang.NullPointerException
sessionTicket - The session ticket for this instance, used when logging. May
be null (which is treated as an empty string)
or an empty string.timeout - The number of seconds before a connection attempt through this
backend times out.ssl - true if SSL is to be used, otherwise
false.usernameAttributeName - The name of the attribute holding the username. Cannot be
null.guessedAttributeName - If we search but cannot find a user element (for example, if
it is not searchable), we will guess that the (R)DN starts
with the substring
guessedAttributeName=usernamePrefix,
where usernamePrefix is the part of the
username preceding the 'at' character. Cannot be
null.
java.lang.IllegalArgumentException - If timeout is less than zero.
java.lang.NullPointerException - If guessedAttributeName or
usernameAttribute is null.| Method Detail |
|---|
public final void open(IndexedReference[] references)
open in interface DirectoryManagerBackendreferences - The external reference to the LDAP server. Cannot be
null, and must contain at least one reference.
java.lang.IllegalArgumentException - If reference is null, or an
empty array.
public final boolean userExists(java.lang.String username)
throws BackendException
userExists in interface DirectoryManagerBackendusername - User name.
true if the user can be looked up through JNDI,
otherwise false.
BackendException - If there is a problem accessing the backend.
public final java.util.HashMap authenticate(Credentials userCredentials,
java.lang.String[] attributeRequest)
throws AuthenticationFailedException,
BackendException
authenticate in interface DirectoryManagerBackenduserCredentials - User's credentials. Cannot be null.attributeRequest - Requested attributes.
String names and
String[] values), if they did exist in the
external backend. Otherwise returns those attributes that could
actually be read, this may be an empty HashMap.
Returns an empty HashMap if
attributeRequest is null or an
empty array.
AuthenticationFailedException - If the authentication fails.
BackendException - If there is a problem accessing the backend.
java.lang.IllegalArgumentException - If userCredentials is null.
private java.util.HashMap getAttributes(javax.naming.ldap.InitialLdapContext ldap,
java.lang.String rdn,
java.lang.String[] attributes)
throws BackendException
ldap - A prepared LDAP context. Cannot be null.rdn - The relative DN (to the DN in the LDAP context
ldap). Cannot be null.attributes - The requested attribute's names.
String names and
String[] values), if they did exist in the
external backend. Otherwise returns those attributes that could
actually be read, this may be an empty HashMap.
Returns an empty HashMap if
attributes is null or an empty
array. Note that attribute values are mapped to
String using ISO-8859-1.
BackendException - If unable to read the attributes from the backend.
java.lang.NullPointerException - If ldap or rdn is
null.InitialDirContext.getAttributes(java.lang.String,
java.lang.String[])public void close()
DirectoryManagerBackend interface. Actual backend
connections are closed after each use.
close in interface DirectoryManagerBackendDirectoryManagerBackend.close()
private java.lang.String ldapSearch(javax.naming.ldap.InitialLdapContext ldap,
java.lang.String pattern)
throws BackendException
ldap - A prepared LDAP context.pattern - The search pattern. Must not include the character '*' or the
substring '\2a' to prevent possible LDAP exploits.
null if none was
found. null is also returned if the search pattern
contains an illegal character or substring.
BackendException - If there was a problem accessing the backend. Typical causes
include timeouts.
private javax.naming.ldap.InitialLdapContext connect(java.lang.String url)
throws javax.naming.NamingException
url - The backend provider URL.
javax.naming.NamingException - If unable to connect to the provider given by
url.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||