Fixes to classification enforcement:

* only process services that start with an upper case character.  We were being over zealous in our checking which was causing problems, we only care about public services.
 * add enable/disable/isenabled methods to pre-processor
 * switch off pre-processing when post-processing
 * remove method black list
 * unit tests, integration tests and UI tests run locally

+review RM @taksoy



git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@108613 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Roy Wetherall
2015-07-21 05:30:53 +00:00
parent 8d16bbf699
commit 9a9560fa6c
7 changed files with 51 additions and 120 deletions

View File

@@ -60,7 +60,8 @@ public class ClassificationMethodInterceptorPostProcessor implements BeanFactory
// only modify proxy factory beans that follow the public service naming postfix convention
if (beanDefinition.getBeanClassName() != null &&
beanDefinition.getBeanClassName().endsWith(TYPE_PROXY_FACTORY_BEAN) &&
bean.endsWith(POSTFIX_SERVICE))
bean.endsWith(POSTFIX_SERVICE) &&
Character.isUpperCase(bean.charAt(0)))
{
// get the property values for the bean definition
MutablePropertyValues propertyValues = beanDefinition.getPropertyValues();

View File

@@ -56,6 +56,10 @@ public abstract class BasePostMethodInvocationProcessor
/** Post method invocation processor */
@Autowired
private PostMethodInvocationProcessor postMethodInvocationProcessor;
/** Pre method invocation processor */
@Autowired
private PreMethodInvocationProcessor preMethodInvocationProcessor;
/**
* @return the nodeService
@@ -133,11 +137,21 @@ public abstract class BasePostMethodInvocationProcessor
{
NodeRef filter = nodeRef;
if (getNodeService().exists(nodeRef) &&
// disable pre-method invocation processor
preMethodInvocationProcessor.disable();
try
{
if (getNodeService().exists(nodeRef) &&
getDictionaryService().isSubClass(getNodeService().getType(nodeRef), TYPE_CONTENT) &&
!getContentClassificationService().hasClearance(nodeRef))
{
filter = null;
}
}
finally
{
filter = null;
// re-enable pre-method invocation processor
preMethodInvocationProcessor.enable();
}
return filter;

View File

@@ -137,17 +137,33 @@ public class PreMethodInvocationProcessor implements ApplicationContextAware
{
return this.methodNames;
}
/**
* Init method to populate the list of method names which will be checked before invocation
* is pre-processing enabled?
*
* @return boolean true if enabled, false otherwise
*/
public void init()
public boolean isEnabled()
{
getMethodNames().add("NodeService.exists");
getMethodNames().add("NodeService.getType");
getMethodNames().add("NodeService.hasAspect");
getMethodNames().add("NodeService.getAspects");
getMethodNames().add("NodeService.getProperties");
return (getAlfrescoTransactionSupport().getResource(KEY_PROCESSING) == null);
}
/**
* disable pre-processing for this transaction
*/
public void disable()
{
// mark the transaction as processing a classification check
getAlfrescoTransactionSupport().bindResource(KEY_PROCESSING, TRUE);
}
/**
* enable pre-processing for this transaction
*/
public void enable()
{
// clear the transaction as processed a classification check
getAlfrescoTransactionSupport().unbindResource(KEY_PROCESSING);
}
/**
@@ -169,9 +185,8 @@ public class PreMethodInvocationProcessor implements ApplicationContextAware
// ensure classification service has been bootstrapped
if (getClassificationServiceBootstrap().isInitialised())
{
// check that we are not already processing a classification check
Object value = getAlfrescoTransactionSupport().getResource(KEY_PROCESSING);
if (value == null)
// if pre-processing is enabled
if (isEnabled())
{
Method method = invocation.getMethod();
Class[] params = method.getParameterTypes();
@@ -188,8 +203,8 @@ public class PreMethodInvocationProcessor implements ApplicationContextAware
if (!getMethodNames().contains(name))
{
// mark the transaction as processing a classification check
getAlfrescoTransactionSupport().bindResource(KEY_PROCESSING, TRUE);
// disable pre-processing
disable();
try
{
// get the value of the parameter
@@ -200,8 +215,8 @@ public class PreMethodInvocationProcessor implements ApplicationContextAware
}
finally
{
// clear the transaction as processed a classification check
getAlfrescoTransactionSupport().unbindResource(KEY_PROCESSING);
// re-enable pre-processing
enable();
}
}
}