1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.jetspeed.security.activeauthentication;
18
19 import java.util.List;
20
21 import org.apache.jetspeed.cache.CacheElement;
22 import org.apache.jetspeed.cache.JetspeedCache;
23
24 /***
25 * <p>
26 * AuthenticationCacheBeanImpl
27 * </p>
28 * <p>
29 * Short-lived cache implementation to bridge deficiencies in Java Login Modules and general Active Authentication patterns
30 * based on Java login modules. Caches Authentication information across redirects, requests, and threads. The life-time
31 * of this cached authentication information is meant to be very short lived.
32 * </p>
33 * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
34 * @version $Id: $
35 *
36 */
37 public class ActiveAuthenticationIdentityProviderImpl implements ActiveAuthenticationIdentityProvider
38 {
39 JetspeedCache cache;
40 List sessionAttributes;
41
42 public ActiveAuthenticationIdentityProviderImpl(JetspeedCache cache, List sessionAttributes)
43 {
44 this.cache = cache;
45 this.sessionAttributes = sessionAttributes;
46 }
47
48 public IdentityToken createIdentityToken(String seed)
49 {
50 String token = seed + "-" + String.valueOf(System.currentTimeMillis());
51 return createToken(token);
52 }
53
54 public IdentityToken createIdentityToken()
55 {
56 String token = String.valueOf(System.currentTimeMillis());
57 return createToken(token);
58 }
59
60 private IdentityToken createToken(String token)
61 {
62 IdentityToken identityToken = new IdentityTokenImpl(token);
63 CacheElement element = cache.createElement(token, identityToken);
64 cache.put(element);
65 return identityToken;
66 }
67
68 public void completeAuthenticationEvent(String token)
69 {
70 cache.remove(token);
71 }
72
73 public List getSessionAttributeNames()
74 {
75 return this.sessionAttributes;
76 }
77
78 }