Browse Source

Expand logging.

Ben Alex 21 years ago
parent
commit
d639e5c02f

+ 10 - 4
core/src/main/java/org/acegisecurity/acl/AclProviderManager.java

@@ -78,12 +78,13 @@ public class AclProviderManager implements AclManager, InitializingBean {
         return null;
     }
 
-	public AclEntry[] getAcls(Object domainInstance,
-			Authentication authentication) {
+    public AclEntry[] getAcls(Object domainInstance,
+        Authentication authentication) {
         if (domainInstance == null) {
             throw new IllegalArgumentException(
                 "domainInstance is null - violating interface contract");
         }
+
         if (authentication == null) {
             throw new IllegalArgumentException(
                 "authentication is null - violating interface contract");
@@ -101,6 +102,11 @@ public class AclProviderManager implements AclManager, InitializingBean {
                 }
 
                 return provider.getAcls(domainInstance, authentication);
+            } else {
+                if (logger.isDebugEnabled()) {
+                    logger.debug("Provider " + provider.toString()
+                        + " does not support " + domainInstance);
+                }
             }
         }
 
@@ -110,8 +116,8 @@ public class AclProviderManager implements AclManager, InitializingBean {
         }
 
         return null;
-	}
-	
+    }
+
     /**
      * Sets the {@link AclProvider} objects to be used for ACL determinations.
      *

+ 38 - 0
core/src/main/java/org/acegisecurity/acl/basic/BasicAclProvider.java

@@ -299,18 +299,36 @@ public class BasicAclProvider implements AclProvider, InitializingBean {
      */
     public boolean supports(Object domainInstance) {
         if (domainInstance == null) {
+            if (logger.isDebugEnabled()) {
+                logger.debug("domainInstance is null");
+            }
+
             return false;
         }
 
         if ((restrictSupportToClass != null)
             && !restrictSupportToClass.isAssignableFrom(
                 domainInstance.getClass())) {
+            if (logger.isDebugEnabled()) {
+                logger.debug("domainInstance not instance of "
+                    + restrictSupportToClass);
+            }
+
             return false;
         }
 
         if (obtainIdentity(domainInstance) == null) {
+            if (logger.isDebugEnabled()) {
+                logger.debug("obtainIdentity returned null");
+            }
+
             return false;
         } else {
+            if (logger.isDebugEnabled()) {
+                logger.debug("obtainIdentity returned "
+                    + obtainIdentity(domainInstance));
+            }
+
             return true;
         }
     }
@@ -338,6 +356,11 @@ public class BasicAclProvider implements AclProvider, InitializingBean {
         if (domainInstance instanceof AclObjectIdentityAware) {
             AclObjectIdentityAware aclObjectIdentityAware = (AclObjectIdentityAware) domainInstance;
 
+            if (logger.isDebugEnabled()) {
+                logger.debug("domainInstance: " + domainInstance
+                    + " cast to AclObjectIdentityAware");
+            }
+
             return aclObjectIdentityAware.getAclObjectIdentity();
         }
 
@@ -345,8 +368,23 @@ public class BasicAclProvider implements AclProvider, InitializingBean {
             Constructor constructor = defaultAclObjectIdentityClass
                 .getConstructor(new Class[] {Object.class});
 
+            if (logger.isDebugEnabled()) {
+                logger.debug("domainInstance: " + domainInstance
+                    + " attempting to pass to constructor: " + constructor);
+            }
+
             return (AclObjectIdentity) constructor.newInstance(new Object[] {domainInstance});
         } catch (Exception ex) {
+            if (logger.isDebugEnabled()) {
+                logger.debug("Error attempting construction of "
+                    + defaultAclObjectIdentityClass + ": " + ex.getMessage(), ex);
+
+                if (ex.getCause() != null) {
+                    logger.debug("Cause: " + ex.getCause().getMessage(),
+                        ex.getCause());
+                }
+            }
+
             return null;
         }
     }