Added configurability for domain and expiration to cookie cache
[java-idp.git] / src / edu / internet2 / middleware / shibboleth / wayf / WayfCacheFactory.java
1 package edu.internet2.middleware.shibboleth.wayf;
2
3 import org.apache.log4j.Logger;
4
5 /**
6  * Factory for creating instances of <code>WayfCache</code> based on 
7  * the state of the <code>WayfConfig</code>.
8  * 
9  * @author Walter Hoehn wassa&#064;columbia.edu
10  */
11 public class WayfCacheFactory {
12
13         private static Logger log =
14                 Logger.getLogger(WayfCacheFactory.class.getName());
15
16         public static WayfCache getInstance(String cacheType, WayfCacheOptions options) {
17
18                 if (cacheType.equals("NONE")) {
19                         return new NullWayfCache();
20                 } else if (cacheType.equals("SESSION")) {
21                         return new SessionWayfCache(options.getExpiration());
22                 } else if (cacheType.equals("COOKIES")) {
23                         return new CookieWayfCache(options.getExpiration(), options.getDomain());
24                 } else {
25                         log.warn(
26                                 "Invalid Cache type specified: running with cache type NONE.");
27                         return new NullWayfCache();
28                 }
29         }
30         
31         public static WayfCache getInstance(String cacheType) {
32                 
33                 return getInstance(cacheType, new WayfCacheOptions());
34                 }
35
36 }