added support to the hs for option of in memory cache or sql cache
[java-idp.git] / src / edu / internet2 / middleware / shibboleth / hs / HandleRepositoryFactory.java
1 package edu.internet2.middleware.shibboleth.hs;
2
3 import javax.servlet.http.*;
4 import edu.internet2.middleware.shibboleth.*;
5 import edu.internet2.middleware.shibboleth.common.*;
6
7 /**
8  *  Used by Shibboleth Handle Service and Attribute Authority to build a repository object
9  */
10 public abstract class HandleRepositoryFactory
11 {
12     /**  Array of policy URI(s) (HS and SHIRE) */
13     protected String[] policies;
14     protected String SQL = "SQL";
15     protected String MEMORY = "MEMORY";
16
17     public HandleRepositoryFactory()
18     {
19     }
20
21     public static HandleRepositoryFactory getInstance(String policy, 
22                                                       String repository,
23                                                       HttpServlet HS)
24         throws HandleException {
25
26         if (policy.equalsIgnoreCase( Constants.POLICY_CLUBSHIB )) {
27             if (repository.equalsIgnoreCase( "SQL" )) {
28                 return new ClubShibSQLHandleRepository(HS);
29             } else if (repository.equalsIgnoreCase( "MEMORY" )) {
30                 return new ClubShibInMemoryHandleRepository(HS);
31             } else {
32                 throw new HandleException("Unspecified repository type.");
33             }
34         }else{
35             throw new HandleException("Unsupported policy found.");
36         }
37     }
38
39     public abstract HandleEntry getHandleEntry(String handle)
40         throws HandleException;
41
42     public abstract  void insertHandleEntry(HandleEntry he)
43         throws HandleException;
44     
45     /* for debugging purposes only */
46     public abstract String toHTMLString()
47         throws HandleException;
48
49 }
50