1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package no.feide.moria.directory.backend;
21
22 import java.util.HashMap;
23
24 import no.feide.moria.directory.Credentials;
25 import no.feide.moria.directory.index.IndexedReference;
26
27 /***
28 *
29 */
30 public interface DirectoryManagerBackend {
31
32 /***
33 * The character set used when encoding attribute values.<br>
34 * <br>
35 * Current value is <code>"ISO-8859-1"</code>.
36 */
37 public static final String ATTRIBUTE_VALUE_CHARSET = "ISO-8859-1";
38
39 /***
40 * The list of "virtual" attributes, that is, attributes that are generated
41 * by Moria itself, and not read from any physical attribute through the
42 * backend.<br>
43 * <br>
44 * Current value is <code>{"tgt"}</code>.
45 */
46
47 public static final String[] VIRTUAL_ATTRIBUTES = {"tgt"};
48
49
50 /***
51 * Opens a new backend connection.
52 * @param references
53 * The backend references in question. Cannot be
54 * <code>null</code>, and must contain at least one reference.
55 */
56 void open(IndexedReference[] references);
57
58
59 /***
60 * Checks whether a given user actually exists.
61 * @param username
62 * The username to check for.
63 * @return <code>true</code> if we can find a user element with the given
64 * username, otherwise <code>false</code>.
65 * @throws BackendException
66 * If there was a problem accessing the backend.
67 */
68 boolean userExists(final String username) throws BackendException;
69
70
71 /***
72 * Attempts to authenticate a user and retrieve a set of user attributes.
73 * @param userCredentials
74 * The user's credentials. Cannot be <code>null</code>.
75 * @param attributeRequest
76 * A list of requested attributes from the user object. May be
77 * <code>null</code> or an empty array. Not case sensitive.
78 * @return The requested user attributes, if any are requested and if they
79 * can be retrieved from the backend following a successful
80 * authentication. Otherwise, an empty <code>HashMap</code>.
81 * Attribute values should be encoded using ISO-8859-1.
82 * @throws AuthenticationFailedException
83 * If the authentication fails.
84 * @throws BackendException
85 * If there was a problem accessing the backend.
86 */
87 HashMap authenticate(final Credentials userCredentials,
88 final String[] attributeRequest) throws AuthenticationFailedException,
89 BackendException;
90
91
92 /***
93 * Closes the current backend and releases any resources.
94 */
95 void close();
96
97 }