%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
org.apache.jetspeed.security.activeauthentication.ActiveAuthenticationIdentityProviderImpl |
|
|
1 | /* |
|
2 | * Licensed to the Apache Software Foundation (ASF) under one or more |
|
3 | * contributor license agreements. See the NOTICE file distributed with |
|
4 | * this work for additional information regarding copyright ownership. |
|
5 | * The ASF licenses this file to You under the Apache License, Version 2.0 |
|
6 | * (the "License"); you may not use this file except in compliance with |
|
7 | * the License. You may obtain a copy of the License at |
|
8 | * |
|
9 | * http://www.apache.org/licenses/LICENSE-2.0 |
|
10 | * |
|
11 | * Unless required by applicable law or agreed to in writing, software |
|
12 | * distributed under the License is distributed on an "AS IS" BASIS, |
|
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
14 | * See the License for the specific language governing permissions and |
|
15 | * limitations under the License. |
|
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 | 0 | { |
44 | 0 | this.cache = cache; |
45 | 0 | this.sessionAttributes = sessionAttributes; |
46 | 0 | } |
47 | ||
48 | public IdentityToken createIdentityToken(String seed) |
|
49 | { |
|
50 | 0 | String token = seed + "-" + String.valueOf(System.currentTimeMillis()); |
51 | 0 | return createToken(token); |
52 | } |
|
53 | ||
54 | public IdentityToken createIdentityToken() |
|
55 | { |
|
56 | 0 | String token = String.valueOf(System.currentTimeMillis()); |
57 | 0 | return createToken(token); |
58 | } |
|
59 | ||
60 | private IdentityToken createToken(String token) |
|
61 | { |
|
62 | 0 | IdentityToken identityToken = new IdentityTokenImpl(token); |
63 | 0 | CacheElement element = cache.createElement(token, identityToken); |
64 | 0 | cache.put(element); |
65 | 0 | return identityToken; |
66 | } |
|
67 | ||
68 | public void completeAuthenticationEvent(String token) |
|
69 | { |
|
70 | 0 | cache.remove(token); |
71 | 0 | } |
72 | ||
73 | public List getSessionAttributeNames() |
|
74 | { |
|
75 | 0 | return this.sessionAttributes; |
76 | } |
|
77 | ||
78 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |