no.feide.moria.directory.backend
Class DummyBackend

java.lang.Object
  extended by no.feide.moria.directory.backend.DummyBackend
All Implemented Interfaces:
DirectoryManagerBackend

public class DummyBackend
extends java.lang.Object
implements DirectoryManagerBackend

Hard-coded dummy backend, for testing. Does not require an actual backend source.


Field Summary
private  java.util.HashMap users
          Maps user names (converted to lowercase) to DummyUser elements.
 
Fields inherited from interface no.feide.moria.directory.backend.DirectoryManagerBackend
ATTRIBUTE_VALUE_CHARSET, VIRTUAL_ATTRIBUTES
 
Constructor Summary
protected DummyBackend(org.jdom.Element config)
          Protected constructor.
 
Method Summary
 java.util.HashMap authenticate(Credentials userCredentials, java.lang.String[] attributeRequest)
          Authenticates a user, if the user exists and the username equals the password.
 void close()
          Does nothing, but needed to fulfill the DirectoryManagerBackend interface.
 void open(IndexedReference[] references)
          Does nothing, but needed to fulfill the DirectoryManagerBackend interface.
 boolean userExists(java.lang.String username)
          Checks whether a user exists.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

users

private java.util.HashMap users
Maps user names (converted to lowercase) to DummyUser elements.

Constructor Detail

DummyBackend

protected DummyBackend(org.jdom.Element config)
Protected constructor. Sets the configuration used by this instance.

Parameters:
config - A Backend configuration element. Must contain a Dummy element (if more than one only the first is considered), which is expected to contain one or more User elements, each with one or more Attribute elements, which again have Value elements with exactly one value child. Allows for easy configuration of test cases, without having to rely on an external backend source. See the supplied dummy configuration for a workable example. Note that attribute and user names are case insensitive, while attribute values are stored as specified in the configuration.
Throws:
DirectoryManagerConfigurationException - If config lacks a mandatory element.
Method Detail

open

public void open(IndexedReference[] references)
Does nothing, but needed to fulfill the DirectoryManagerBackend interface.

Specified by:
open in interface DirectoryManagerBackend
Parameters:
references - Ignored.
See Also:
DirectoryManagerBackend.open(IndexedReference[])

userExists

public final boolean userExists(java.lang.String username)
Checks whether a user exists.

Specified by:
userExists in interface DirectoryManagerBackend
Parameters:
username - The username. Case is ignored.
Returns:
true if the user exists, false otherwise.
See Also:
DirectoryManagerBackend.userExists(String)

authenticate

public final java.util.HashMap authenticate(Credentials userCredentials,
                                            java.lang.String[] attributeRequest)
                                     throws AuthenticationFailedException
Authenticates a user, if the user exists and the username equals the password.

Specified by:
authenticate in interface DirectoryManagerBackend
Parameters:
userCredentials - The user's credentials. Cannot be null.
attributeRequest - A list of requested attributes from the user object. May be null or an empty array. Not case sensitive.
Returns:
User attributes, possibly empty.
Throws:
AuthenticationFailedException - If the authentication fails.
java.lang.IllegalArgumentException - If userCredentials are null.
See Also:
DirectoryManagerBackend.authenticate(Credentials, String[])

close

public void close()
Does nothing, but needed to fulfill the DirectoryManagerBackend interface.

Specified by:
close in interface DirectoryManagerBackend
See Also:
DirectoryManagerBackend.close()


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