From 0848671c81b5c007d32b7dce259b1c21325dc7e0 Mon Sep 17 00:00:00 2001 From: Andrew Hind Date: Tue, 14 Jul 2009 20:05:58 +0000 Subject: [PATCH] RM capabilities: no op impl for RM_QUERY; First cut of Action security wrappers; Tidy up for new access API and config changes to support it across all public services (except AVM) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@15186 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../public-services-security-context.xml | 30 ++++++------ .../impl/PublicServiceAccessServiceImpl.java | 47 +++++++++++-------- .../permissions/impl/acegi/ACLEntryVoter.java | 2 +- 3 files changed, 44 insertions(+), 35 deletions(-) diff --git a/config/alfresco/public-services-security-context.xml b/config/alfresco/public-services-security-context.xml index de4560b988..4852a1b561 100644 --- a/config/alfresco/public-services-security-context.xml +++ b/config/alfresco/public-services-security-context.xml @@ -196,7 +196,7 @@ - + false @@ -339,7 +339,7 @@ - + @@ -392,7 +392,7 @@ - + @@ -428,7 +428,7 @@ - + @@ -462,7 +462,7 @@ - + @@ -487,7 +487,7 @@ - + @@ -526,7 +526,7 @@ - + @@ -559,7 +559,7 @@ - + @@ -587,7 +587,7 @@ - + @@ -611,7 +611,7 @@ - + @@ -660,7 +660,7 @@ - + @@ -694,7 +694,7 @@ - + @@ -740,7 +740,7 @@ - + @@ -775,7 +775,7 @@ - + @@ -793,7 +793,7 @@ - + diff --git a/source/java/org/alfresco/repo/security/permissions/impl/PublicServiceAccessServiceImpl.java b/source/java/org/alfresco/repo/security/permissions/impl/PublicServiceAccessServiceImpl.java index 656fbe8c8b..99e07d05c6 100644 --- a/source/java/org/alfresco/repo/security/permissions/impl/PublicServiceAccessServiceImpl.java +++ b/source/java/org/alfresco/repo/security/permissions/impl/PublicServiceAccessServiceImpl.java @@ -36,7 +36,6 @@ import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactoryAware; import org.springframework.beans.factory.ListableBeanFactory; - public class PublicServiceAccessServiceImpl implements PublicServiceAccessService, BeanFactoryAware { @@ -44,36 +43,46 @@ public class PublicServiceAccessServiceImpl implements PublicServiceAccessServic public AccessStatus hasAccess(String publicService, String methodName, Object... args) { - MethodSecurityInterceptor msi = (MethodSecurityInterceptor)beanFactory.getBean(publicService+"_security"); - if(msi == null) + Object interceptor = beanFactory.getBean(publicService + "_security"); + if (interceptor == null) { - throw new UnsupportedOperationException("Unknown public service security implementation "+publicService); + throw new UnsupportedOperationException("Unknown public service security implementation " + publicService); } - - MethodInvocation methodInvocation = null; - Object publicServiceImpl = beanFactory.getBean(publicService); - for(Method method : publicServiceImpl.getClass().getMethods()) + if (interceptor instanceof AlwaysProceedMethodInterceptor) { - if(method.getName().equals(methodName)) + return AccessStatus.ALLOWED; + } + + if (interceptor instanceof MethodSecurityInterceptor) + { + MethodSecurityInterceptor msi = (MethodSecurityInterceptor) interceptor; + + MethodInvocation methodInvocation = null; + Object publicServiceImpl = beanFactory.getBean(publicService); + for (Method method : publicServiceImpl.getClass().getMethods()) { - if(method.getParameterTypes().length == args.length) + if (method.getName().equals(methodName)) { - methodInvocation = new ReflectiveMethodInvocation(null, null, method, args, null, null); + if (method.getParameterTypes().length == args.length) + { + methodInvocation = new ReflectiveMethodInvocation(null, null, method, args, null, null); + } } } + + if (methodInvocation == null) + { + throw new UnsupportedOperationException("Unknown public service security implementation " + publicService + "." + methodName); + } + + return msi.pre(methodInvocation); } - - if(methodInvocation == null) - { - throw new UnsupportedOperationException("Unknown public service security implementation "+publicService+"."+methodName); - } - - return msi.pre(methodInvocation); + throw new UnsupportedOperationException("Unknown security interceptor "+interceptor.getClass()); } public void setBeanFactory(BeanFactory beanFactory) throws BeansException { - this.beanFactory = (ListableBeanFactory)beanFactory; + this.beanFactory = (ListableBeanFactory) beanFactory; } } diff --git a/source/java/org/alfresco/repo/security/permissions/impl/acegi/ACLEntryVoter.java b/source/java/org/alfresco/repo/security/permissions/impl/acegi/ACLEntryVoter.java index 9698d472ad..a7b356a548 100644 --- a/source/java/org/alfresco/repo/security/permissions/impl/acegi/ACLEntryVoter.java +++ b/source/java/org/alfresco/repo/security/permissions/impl/acegi/ACLEntryVoter.java @@ -256,7 +256,7 @@ public class ACLEntryVoter implements AccessDecisionVoter, InitializingBean if (supportedDefinitions.size() == 0) { - return AccessDecisionVoter.ACCESS_GRANTED; + return AccessDecisionVoter.ACCESS_ABSTAIN; } MethodInvocation invocation = (MethodInvocation) object;