1/*2* Licensed to the Apache Software Foundation (ASF) under one or more3* contributor license agreements. See the NOTICE file distributed with4* this work for additional information regarding copyright ownership.5* The ASF licenses this file to You under the Apache License, Version 2.06* (the "License"); you may not use this file except in compliance with7* the License. You may obtain a copy of the License at8*9* http://www.apache.org/licenses/LICENSE-2.010*11* Unless required by applicable law or agreed to in writing, software12* 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 and15* limitations under the License.16*/17packageorg.apache.jetspeed.security.activeauthentication;
1819import java.util.List;
2021import org.apache.jetspeed.cache.CacheElement;
22import org.apache.jetspeed.cache.JetspeedCache;
2324/***25 * <p>26 * AuthenticationCacheBeanImpl27 * </p>28 * <p>29 * Short-lived cache implementation to bridge deficiencies in Java Login Modules and general Active Authentication patterns30 * based on Java login modules. Caches Authentication information across redirects, requests, and threads. The life-time31 * 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 */37publicclassActiveAuthenticationIdentityProviderImpl implements ActiveAuthenticationIdentityProvider
38 {
39 JetspeedCache cache;
40 List sessionAttributes;
4142publicActiveAuthenticationIdentityProviderImpl(JetspeedCache cache, List sessionAttributes)
43 {
44this.cache = cache;
45this.sessionAttributes = sessionAttributes;
46 }
4748public IdentityToken createIdentityToken(String seed)
49 {
50 String token = seed + "-" + String.valueOf(System.currentTimeMillis());
51return createToken(token);
52 }
5354public IdentityToken createIdentityToken()
55 {
56 String token = String.valueOf(System.currentTimeMillis());
57return createToken(token);
58 }
5960private IdentityToken createToken(String token)
61 {
62 IdentityToken identityToken = newIdentityTokenImpl(token);
63 CacheElement element = cache.createElement(token, identityToken);
64 cache.put(element);
65return identityToken;
66 }
6768publicvoid completeAuthenticationEvent(String token)
69 {
70 cache.remove(token);
71 }
7273public List getSessionAttributeNames()
74 {
75returnthis.sessionAttributes;
76 }
7778 }