1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package no.feide.moria.store;
22
23 import java.util.HashMap;
24
25 /***
26 * This class is a container for userdata that persists across logins (for SSO
27 * Light and Proxy authentication).
28 * @author Bjørn Ola Smievoll <b.o@smievoll.no>
29 * @version $Revision: 1.10 $
30 */
31 public final class CachedUserData
32 implements MoriaStoreData {
33
34 /*** The internal hashmap used to store the attributes. */
35 private final HashMap attributes;
36
37
38 /***
39 * Constructs a new instance encapsulating the userdata given as argument.
40 * @param attributes
41 * A hashmap containing the user attributes.
42 */
43 public CachedUserData(final HashMap attributes) {
44
45 if (attributes == null)
46 throw new IllegalArgumentException("Argument can not be null");
47 this.attributes = attributes;
48 }
49
50
51 /***
52 * Adds an attribute. Needed to add ticket granting tickets to cache.
53 * @param name
54 * Attribute name.
55 * @param data
56 * Attribute data.
57 */
58 public void addAttribute(final String name, final Object data) {
59
60 this.attributes.put(name, data);
61 }
62
63
64 /***
65 * Remove an attribute. Needed to purge non-SSO-enabled attributes.
66 * @param name
67 * Attribute name.
68 */
69 public void removeAttribute(final String name) {
70
71 attributes.remove(name);
72
73 }
74
75
76 /***
77 * Gets a map containing the attributes.
78 * @return A clone of the internal attribute map.
79 */
80 public HashMap getAttributes() {
81
82 return (HashMap) attributes.clone();
83 }
84 }