From d639e5c02f241139880e048708f54fec5f693856 Mon Sep 17 00:00:00 2001 From: Ben Alex Date: Mon, 15 Nov 2004 01:41:45 +0000 Subject: [PATCH] Expand logging. --- .../acegisecurity/acl/AclProviderManager.java | 14 +++++-- .../acl/basic/BasicAclProvider.java | 38 +++++++++++++++++++ 2 files changed, 48 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/org/acegisecurity/acl/AclProviderManager.java b/core/src/main/java/org/acegisecurity/acl/AclProviderManager.java index 97c9de8290..1cc047edcc 100644 --- a/core/src/main/java/org/acegisecurity/acl/AclProviderManager.java +++ b/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. * diff --git a/core/src/main/java/org/acegisecurity/acl/basic/BasicAclProvider.java b/core/src/main/java/org/acegisecurity/acl/basic/BasicAclProvider.java index 4833436dd1..b89d3afc66 100644 --- a/core/src/main/java/org/acegisecurity/acl/basic/BasicAclProvider.java +++ b/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; } }