no.feide.moria.directory.index
Class SerializableIndex

java.lang.Object
  extended by no.feide.moria.directory.index.SerializableIndex
All Implemented Interfaces:
java.io.Serializable, DirectoryManagerIndex

public class SerializableIndex
extends java.lang.Object
implements java.io.Serializable, DirectoryManagerIndex

A serializable index implementation, used for offline generation of a new index.

See Also:
Serialized Form

Field Summary
private  java.util.HashMap associations
          Internal list of associations; that is, the mapping between logical ID realms (as Strings) - following the 'at' character - and search base references (as String arrays).
private  java.util.HashMap exceptions
          Internal list of exceptions to the associations; that is, explicitly indexed logical IDs (as Strings) to full external references (as String s).
private  java.util.HashMap passwords
          Internal list of passwords for each association/exception.
private  java.util.HashMap realms
          Internal list of realms for each exception.
(package private) static long serialVersionUID
          Serial version identifier.
private  java.util.HashMap usernames
          Internal list of usernames for each association/exception.
 
Constructor Summary
SerializableIndex()
           
 
Method Summary
 void addAssociation(java.lang.String realm, java.lang.String base, java.lang.String username, java.lang.String password)
          Adds a new realm-to-base association to the index.
 void addException(java.lang.String id, java.lang.String reference, java.lang.String realm)
          Add a new search exception (exception to the basic rule of realm-to-base associations) to this index.
 boolean equals(java.lang.Object obj)
          Checks whether two index instances are equal.
 java.lang.String getPassword(java.lang.String base)
          Return the password associated with a given base.
 java.lang.String getRealm(java.lang.String id)
          Looks up which realm a given identifier belongs to.
 IndexedReference[] getReferences(java.lang.String id)
          Looks up an element reference from the index based on its logical ID (typically username).
 java.lang.String getUsername(java.lang.String base)
          Return the username associated with a given base.
 int hashCode()
          Generates a hashCode.
 java.lang.String toString()
          Gives a string representation of the object, for visual debugging.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

static final long serialVersionUID
Serial version identifier.

See Also:
Constant Field Values

associations

private java.util.HashMap associations
Internal list of associations; that is, the mapping between logical ID realms (as Strings) - following the 'at' character - and search base references (as String arrays).


exceptions

private java.util.HashMap exceptions
Internal list of exceptions to the associations; that is, explicitly indexed logical IDs (as Strings) to full external references (as String s).


realms

private java.util.HashMap realms
Internal list of realms for each exception. The list should have the same keys as exceptions, but the elements of this list give the explicit realm (as Strings) for each exception.


usernames

private java.util.HashMap usernames
Internal list of usernames for each association/exception.


passwords

private java.util.HashMap passwords
Internal list of passwords for each association/exception.

Constructor Detail

SerializableIndex

public SerializableIndex()
Method Detail

equals

public final boolean equals(java.lang.Object obj)
Checks whether two index instances are equal.

Note that for convenience (and/or laziness) this method relies on the String representation as given by toString().

Overrides:
equals in class java.lang.Object
Parameters:
obj - The other SerializableIndex object to compare to.
Returns:
true if two SerializableIndex objects are equal, otherwise false. Two instances are equal if and only if their lists of associations, exceptions and realms are equal.
See Also:
Object.equals(java.lang.Object), toString()

hashCode

public final int hashCode()
Generates a hashCode. Dummy implementation.

Overrides:
hashCode in class java.lang.Object
Returns:
The hashcode.
Throws:
java.lang.UnsupportedOperationException - Always.

getReferences

public final IndexedReference[] getReferences(java.lang.String id)
Looks up an element reference from the index based on its logical ID (typically username).

Note that looking up in the association list requires the logical ID to be on the form identifier-at-realm, similar to an email address. This is not a requirement for looking up references in the exception list, and therefore the 'at' character is not required in the logical ID.

Specified by:
getReferences in interface DirectoryManagerIndex
Parameters:
id - The logical identifier to look up.
Returns:
One or more references matching the given identifier, or null if no such reference was found.
See Also:
DirectoryManagerIndex.getReferences(String)

getRealm

public final java.lang.String getRealm(java.lang.String id)
Looks up which realm a given identifier belongs to.

Specified by:
getRealm in interface DirectoryManagerIndex
Parameters:
id - The logical identifier to get realm for.
Returns:
The resolved realm for this identifier, or null if no such realm could be found.
See Also:
DirectoryManagerIndex.getRealm(String)

addAssociation

public final void addAssociation(java.lang.String realm,
                                 java.lang.String base,
                                 java.lang.String username,
                                 java.lang.String password)
Adds a new realm-to-base association to the index. Any modification of the index will result in any existing association with the same realm to be appended with the new realm.

Note that this method does not check for duplicate associations (associations between one realm and two identical bases).

Parameters:
realm - The realm (typically user realm) related to this base. Cannot be null.
base - The association. In practical use this will be an LDAP search base similar to ldap://some.ldap.server:636/dc=search,dc=base. Cannot be null.
username - The username to be used when performing searches on this association's base. May not be null.
password - The password to be used when performing searches on this association's base. May not be null.
Throws:
java.lang.IllegalArgumentException - If either realm,base, username, or password is null.

addException

public final void addException(java.lang.String id,
                               java.lang.String reference,
                               java.lang.String realm)
Add a new search exception (exception to the basic rule of realm-to-base associations) to this index. Any modifications to an already existing exception will result in the old references being replaced.

Parameters:
id - The identifier for this exception, typically a user ID. Cannot be null.
reference - The reference. In practical use this will be an LDAP element reference similar to ldap://some.ldap.server:636/uid=id,dc=search,dc=base. Cannot be null.
realm - The actual realm of the reference, which may not be given by the identifier (on the form user@realm , for example). Since moving between realms while keeping an unchanged identifier is possible, this must be taken into account.
Throws:
java.lang.IllegalArgumentException - If either id or reference is null.

toString

public final java.lang.String toString()
Gives a string representation of the object, for visual debugging.

Overrides:
toString in class java.lang.Object
Returns:
The object represented as a String, includes separate lists of associations and exceptions.

getUsername

public final java.lang.String getUsername(java.lang.String base)
                                   throws java.lang.IllegalArgumentException
Return the username associated with a given base.

Specified by:
getUsername in interface DirectoryManagerIndex
Parameters:
base - The search base. May not be null or an empty string.
Returns:
The username associated with base. May be an empty string, but will never be null even though the base does not exist.
Throws:
java.lang.IllegalArgumentException - If base is null or an empty string.

getPassword

public final java.lang.String getPassword(java.lang.String base)
                                   throws java.lang.IllegalArgumentException
Return the password associated with a given base.

Specified by:
getPassword in interface DirectoryManagerIndex
Parameters:
base - The search base. May not be null or an empty string.
Returns:
The password associated with base. May be an empty string, but will never be null even though the base does not exist.
Throws:
java.lang.IllegalArgumentException - If base is null or an empty string.


Copyright © 2001-2006 UNINETT FAS. All Rights Reserved.