added support to the hs for option of in memory cache or sql cache
authorblk <blk@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Fri, 14 Jun 2002 19:32:48 +0000 (19:32 +0000)
committerblk <blk@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Fri, 14 Jun 2002 19:32:48 +0000 (19:32 +0000)
git-svn-id: https://subversion.switch.ch/svn/shibboleth/java-idp/trunk@121 ab3bd59b-922f-494d-bb5f-6f0a3c29deca

src/edu/internet2/middleware/shibboleth/hs/HandleRepositoryFactory.java
src/edu/internet2/middleware/shibboleth/hs/HandleServlet.java

index fb17fed..6288672 100644 (file)
@@ -11,17 +11,26 @@ public abstract class HandleRepositoryFactory
 {
     /**  Array of policy URI(s) (HS and SHIRE) */
     protected String[] policies;
+    protected String SQL = "SQL";
+    protected String MEMORY = "MEMORY";
 
     public HandleRepositoryFactory()
     {
     }
 
     public static HandleRepositoryFactory getInstance(String policy, 
+                                                     String repository,
                                                      HttpServlet HS)
         throws HandleException {
 
-       if(policy.equalsIgnoreCase( Constants.POLICY_CLUBSHIB )){
-           return new ClubShibSQLHandleRepository(HS);
+       if (policy.equalsIgnoreCase( Constants.POLICY_CLUBSHIB )) {
+           if (repository.equalsIgnoreCase( "SQL" )) {
+               return new ClubShibSQLHandleRepository(HS);
+           } else if (repository.equalsIgnoreCase( "MEMORY" )) {
+               return new ClubShibInMemoryHandleRepository(HS);
+           } else {
+               throw new HandleException("Unspecified repository type.");
+           }
        }else{
            throw new HandleException("Unsupported policy found.");
        }
@@ -33,6 +42,7 @@ public abstract class HandleRepositoryFactory
     public abstract  void insertHandleEntry(HandleEntry he)
        throws HandleException;
     
+    /* for debugging purposes only */
     public abstract String toHTMLString()
         throws HandleException;
 
index b6a68a7..222cd3a 100644 (file)
@@ -34,7 +34,9 @@ public class HandleServlet extends HttpServlet {
                                            is );
            
            hrf = HandleRepositoryFactory.getInstance
-               ( Constants.POLICY_CLUBSHIB, this );
+               ( Constants.POLICY_CLUBSHIB, 
+                 getInitParameter("repository"),
+                 this );
        }
        catch (SAMLException ex) {
            throw new ServletException( "Error initializing SAML libraries: " + ex );
@@ -61,6 +63,7 @@ public class HandleServlet extends HttpServlet {
            ticket = "1400000";
        }
        ticketExp = Long.parseLong(ticket);
+
        if ( getInitParameter("domain") == null || 
             getInitParameter("domain").equals("")) {
            throw new ServletException("Cannot find host domain in init parameters");
@@ -93,10 +96,13 @@ public class HandleServlet extends HttpServlet {
             getInitParameter("certalias").equals("")) {
            throw new ServletException("Cannot find certificate alias in init parameters");
        }
-
-
+       if ( getInitParameter("repository") == null ||
+            getInitParameter("repository").equals("")) {
+           throw new ServletException("Cannot find repository specification in init parameters.");
+       }
     }
 
+
     public void doGet(HttpServletRequest req, 
                      HttpServletResponse res)
        throws ServletException, IOException