Fixed MemoryHandleRepository Handle Expiration.
authorwassa <wassa@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Tue, 4 Feb 2003 21:14:16 +0000 (21:14 +0000)
committerwassa <wassa@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Tue, 4 Feb 2003 21:14:16 +0000 (21:14 +0000)
git-svn-id: https://subversion.switch.ch/svn/shibboleth/java-idp/trunk@447 ab3bd59b-922f-494d-bb5f-6f0a3c29deca

src/edu/internet2/middleware/shibboleth/hs/provider/BaseHandleRepository.java
src/edu/internet2/middleware/shibboleth/hs/provider/MemoryHandleRepository.java

index 6b60dae..847747e 100644 (file)
@@ -69,13 +69,12 @@ public abstract class BaseHandleRepository implements HandleRepository {
 
        protected BaseHandleRepository(Properties properties) throws HandleRepositoryException {
                try {
-                       if (properties.getProperty("edu.internet2.middleware.shibboleth.hs.HandleRepository.handleTTL", null)
+                       if (properties.getProperty("edu.internet2.middleware.shibboleth.hs.BaseHandleRepository.handleTTL")
                                != null) {
-
                                handleTTL =
                                        Long.parseLong(
                                                properties.getProperty(
-                                                       "edu.internet2.middleware.shibboleth.hs.HandleRepository.handleTTL",
+                                                       "edu.internet2.middleware.shibboleth.hs.BaseHandleRepository.handleTTL",
                                                        null));
                                if (handleTTL < 30000) {
                                        log.warn(
@@ -83,10 +82,12 @@ public abstract class BaseHandleRepository implements HandleRepository {
                                                        + "value.  It is recommended that you increase it.");
                                }
                        }
+                       log.debug("Attribute Query Handle TTL set to (" + handleTTL + ") milliseconds.");
+                       
                } catch (NumberFormatException nfe) {
                        log.error(
-                               "Value for (edu.internet2.middleware.shibboleth.hs.HandleRepository.handleTTL) must be a long integer.");
-                       throw new HandleRepositoryException("Value for (edu.internet2.middleware.shibboleth.hs.HandleRepository.handleTTL) must be a long integer.");
+                               "Value for (edu.internet2.middleware.shibboleth.hs.BaseHandleRepository.handleTTL) must be a long integer.");
+                       throw new HandleRepositoryException("Value for (edu.internet2.middleware.shibboleth.hs.BaseHandleRepository.handleTTL) must be a long integer.");
                }
 
        }
index 9e0f2c8..70a5ede 100644 (file)
@@ -54,10 +54,12 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.Properties;
 
+import org.apache.log4j.Logger;
 import org.doomdark.uuid.UUIDGenerator;
 
 import edu.internet2.middleware.shibboleth.hs.HandleRepository;
 import edu.internet2.middleware.shibboleth.hs.HandleRepositoryException;
+import edu.internet2.middleware.shibboleth.hs.HandleServlet;
 
 /**
  * <code>HandleRepository</code> implementation that uses a static cache.  This requires
@@ -68,6 +70,9 @@ import edu.internet2.middleware.shibboleth.hs.HandleRepositoryException;
 public class MemoryHandleRepository extends BaseHandleRepository implements HandleRepository {
 
        protected static Map handleEntries = new HashMap();
+               private static Logger log = Logger.getLogger(MemoryHandleRepository.class.getName());
+
+
 
        public MemoryHandleRepository(Properties properties) throws HandleRepositoryException {
                super(properties);
@@ -78,6 +83,7 @@ public class MemoryHandleRepository extends BaseHandleRepository implements Hand
         */
        public String getHandle(Principal principal) {
                String handle = UUIDGenerator.getInstance().generateRandomBasedUUID().toString();
+               log.debug("Assigning handle (" + handle + ") to principal (" + principal.getName() + ").");
                synchronized (handleEntries) {
                        handleEntries.put(handle, new HandleEntry(principal));
                }
@@ -90,6 +96,7 @@ public class MemoryHandleRepository extends BaseHandleRepository implements Hand
        public Principal getPrincipal(String handle) {
                synchronized (handleEntries) {
                        if (!handleEntries.containsKey(handle)) {
+                               log.debug("Repository does not contain an entry for this Attribute Query Handle.");
                                return null;
                        }
                }
@@ -98,11 +105,13 @@ public class MemoryHandleRepository extends BaseHandleRepository implements Hand
                        handleEntry = (HandleEntry) handleEntries.get(handle);
                }
                if (handleEntry.isExpired()) {
+                       log.debug("Attribute Query Handle is expired.");
                        synchronized (handleEntries) {
                                handleEntries.remove(handle);
                        }
                        return null;
                } else {
+                       log.debug("Attribute Query Handle recognized.");
                        return handleEntry.principal;
                }
        }