mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-2130 (Check classification after method execution, filtering results where appropriate)
+review RM-94 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/DEV/ENFORCE@106552 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -41,7 +41,7 @@ import org.alfresco.util.ParameterCheck;
|
|||||||
* @since 3.0
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
public class SecurityClearanceServiceImpl extends ServiceBaseImpl implements SecurityClearanceService
|
public class SecurityClearanceServiceImpl extends ServiceBaseImpl implements SecurityClearanceService
|
||||||
{
|
{
|
||||||
/** The clearance levels currently configured in this server. */
|
/** The clearance levels currently configured in this server. */
|
||||||
private ClearanceLevelManager clearanceManager;
|
private ClearanceLevelManager clearanceManager;
|
||||||
/** The object containing the {@link ClassificationLevel}s in the system. */
|
/** The object containing the {@link ClassificationLevel}s in the system. */
|
||||||
@@ -88,7 +88,7 @@ public class SecurityClearanceServiceImpl extends ServiceBaseImpl implements Sec
|
|||||||
*/
|
*/
|
||||||
private SecurityClearance getUserSecurityClearance(final String userName)
|
private SecurityClearance getUserSecurityClearance(final String userName)
|
||||||
{
|
{
|
||||||
final NodeRef personNode = personService.getPerson(userName, false);
|
final NodeRef personNode = personService.getPerson(userName, true);
|
||||||
final PersonInfo personInfo = personService.getPerson(personNode);
|
final PersonInfo personInfo = personService.getPerson(personNode);
|
||||||
|
|
||||||
ClearanceLevel clearanceLevel = ClearanceLevelManager.NO_CLEARANCE;
|
ClearanceLevel clearanceLevel = ClearanceLevelManager.NO_CLEARANCE;
|
||||||
|
@@ -68,7 +68,7 @@ public class PostMethodInvocationProcessorRegistry
|
|||||||
|
|
||||||
BasePostMethodInvocationProcessor result = null;
|
BasePostMethodInvocationProcessor result = null;
|
||||||
|
|
||||||
for (Map.Entry<Class<?>, BasePostMethodInvocationProcessor> processor : processors.entrySet())
|
for (Map.Entry<Class<?>, BasePostMethodInvocationProcessor> processor : getProcessors().entrySet())
|
||||||
{
|
{
|
||||||
if (processor.getKey().isAssignableFrom(clazz))
|
if (processor.getKey().isAssignableFrom(clazz))
|
||||||
{
|
{
|
||||||
|
@@ -18,10 +18,15 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor;
|
package org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor;
|
||||||
|
|
||||||
|
import static com.google.common.collect.ImmutableList.copyOf;
|
||||||
|
import static com.google.common.collect.Lists.newArrayList;
|
||||||
|
import static java.util.Collections.unmodifiableCollection;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
import static org.springframework.extensions.webscripts.GUID.generate;
|
import static org.springframework.extensions.webscripts.GUID.generate;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import org.alfresco.module.org_alfresco_module_rm.classification.ContentClassificationService;
|
import org.alfresco.module.org_alfresco_module_rm.classification.ContentClassificationService;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor.ClassificationPostMethodInvocationException.NotSupportedClassTypeException;
|
import org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor.ClassificationPostMethodInvocationException.NotSupportedClassTypeException;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest;
|
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest;
|
||||||
@@ -59,7 +64,6 @@ public class NodeRefPostMethodInvocationProcessorUnitTest extends BaseUnitTest
|
|||||||
{
|
{
|
||||||
NodeRef nodeRef = new NodeRef(generate() + "://" + generate() + "/");
|
NodeRef nodeRef = new NodeRef(generate() + "://" + generate() + "/");
|
||||||
|
|
||||||
when(mockedNodeService.getType(nodeRef)).thenReturn(TYPE_CONTENT);
|
|
||||||
when(mockedDictionaryService.isSubClass(mockedNodeService.getType(nodeRef), TYPE_CONTENT)).thenReturn(true);
|
when(mockedDictionaryService.isSubClass(mockedNodeService.getType(nodeRef), TYPE_CONTENT)).thenReturn(true);
|
||||||
when(mockedContentClassificationService.hasClearance(nodeRef)).thenReturn(true);
|
when(mockedContentClassificationService.hasClearance(nodeRef)).thenReturn(true);
|
||||||
|
|
||||||
@@ -71,7 +75,6 @@ public class NodeRefPostMethodInvocationProcessorUnitTest extends BaseUnitTest
|
|||||||
{
|
{
|
||||||
NodeRef nodeRef = generateNodeRef();
|
NodeRef nodeRef = generateNodeRef();
|
||||||
|
|
||||||
when(mockedNodeService.getType(nodeRef)).thenReturn(TYPE_CONTENT);
|
|
||||||
when(mockedDictionaryService.isSubClass(mockedNodeService.getType(nodeRef), TYPE_CONTENT)).thenReturn(false);
|
when(mockedDictionaryService.isSubClass(mockedNodeService.getType(nodeRef), TYPE_CONTENT)).thenReturn(false);
|
||||||
when(mockedContentClassificationService.hasClearance(nodeRef)).thenReturn(true);
|
when(mockedContentClassificationService.hasClearance(nodeRef)).thenReturn(true);
|
||||||
|
|
||||||
@@ -83,7 +86,6 @@ public class NodeRefPostMethodInvocationProcessorUnitTest extends BaseUnitTest
|
|||||||
{
|
{
|
||||||
NodeRef nodeRef = generateNodeRef();
|
NodeRef nodeRef = generateNodeRef();
|
||||||
|
|
||||||
when(mockedNodeService.getType(nodeRef)).thenReturn(TYPE_CONTENT);
|
|
||||||
when(mockedDictionaryService.isSubClass(mockedNodeService.getType(nodeRef), TYPE_CONTENT)).thenReturn(true);
|
when(mockedDictionaryService.isSubClass(mockedNodeService.getType(nodeRef), TYPE_CONTENT)).thenReturn(true);
|
||||||
when(mockedContentClassificationService.hasClearance(nodeRef)).thenReturn(true);
|
when(mockedContentClassificationService.hasClearance(nodeRef)).thenReturn(true);
|
||||||
|
|
||||||
@@ -95,10 +97,90 @@ public class NodeRefPostMethodInvocationProcessorUnitTest extends BaseUnitTest
|
|||||||
{
|
{
|
||||||
NodeRef nodeRef = generateNodeRef();
|
NodeRef nodeRef = generateNodeRef();
|
||||||
|
|
||||||
when(mockedNodeService.getType(nodeRef)).thenReturn(TYPE_CONTENT);
|
|
||||||
when(mockedDictionaryService.isSubClass(mockedNodeService.getType(nodeRef), TYPE_CONTENT)).thenReturn(true);
|
when(mockedDictionaryService.isSubClass(mockedNodeService.getType(nodeRef), TYPE_CONTENT)).thenReturn(true);
|
||||||
when(mockedContentClassificationService.hasClearance(nodeRef)).thenReturn(false);
|
when(mockedContentClassificationService.hasClearance(nodeRef)).thenReturn(false);
|
||||||
|
|
||||||
assertEquals(null, nodeRefPostMethodInvocationProcessor.process(nodeRef));
|
assertEquals(null, nodeRefPostMethodInvocationProcessor.process(nodeRef));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCollection_bothNodesConent_userClearedForBoth()
|
||||||
|
{
|
||||||
|
NodeRef nodeRef1 = generateNodeRef();
|
||||||
|
NodeRef nodeRef2 = generateNodeRef();
|
||||||
|
ArrayList<NodeRef> nodeRefs = newArrayList(nodeRef1, nodeRef2);
|
||||||
|
|
||||||
|
when(mockedDictionaryService.isSubClass(mockedNodeService.getType(nodeRef1), TYPE_CONTENT)).thenReturn(true);
|
||||||
|
when(mockedContentClassificationService.hasClearance(nodeRef1)).thenReturn(true);
|
||||||
|
|
||||||
|
when(mockedDictionaryService.isSubClass(mockedNodeService.getType(nodeRef2), TYPE_CONTENT)).thenReturn(true);
|
||||||
|
when(mockedContentClassificationService.hasClearance(nodeRef2)).thenReturn(true);
|
||||||
|
|
||||||
|
assertEquals(nodeRefs, nodeRefPostMethodInvocationProcessor.process(nodeRefs));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCollection_bothNodesContent_userClearedForOne()
|
||||||
|
{
|
||||||
|
NodeRef nodeRef1 = generateNodeRef();
|
||||||
|
NodeRef nodeRef2 = generateNodeRef();
|
||||||
|
ArrayList<NodeRef> nodeRefs = newArrayList(nodeRef1, nodeRef2);
|
||||||
|
|
||||||
|
when(mockedDictionaryService.isSubClass(mockedNodeService.getType(nodeRef1), TYPE_CONTENT)).thenReturn(true);
|
||||||
|
when(mockedContentClassificationService.hasClearance(nodeRef1)).thenReturn(true);
|
||||||
|
|
||||||
|
when(mockedDictionaryService.isSubClass(mockedNodeService.getType(nodeRef2), TYPE_CONTENT)).thenReturn(true);
|
||||||
|
when(mockedContentClassificationService.hasClearance(nodeRef2)).thenReturn(false);
|
||||||
|
|
||||||
|
assertEquals(newArrayList(nodeRef1), nodeRefPostMethodInvocationProcessor.process(nodeRefs));
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
@Test
|
||||||
|
public void testCollection_bothNodesContent_userClearedForNone()
|
||||||
|
{
|
||||||
|
NodeRef nodeRef1 = generateNodeRef();
|
||||||
|
NodeRef nodeRef2 = generateNodeRef();
|
||||||
|
ArrayList<NodeRef> nodeRefs = newArrayList(nodeRef1, nodeRef2);
|
||||||
|
|
||||||
|
when(mockedDictionaryService.isSubClass(mockedNodeService.getType(nodeRef1), TYPE_CONTENT)).thenReturn(true);
|
||||||
|
when(mockedContentClassificationService.hasClearance(nodeRef1)).thenReturn(false);
|
||||||
|
|
||||||
|
when(mockedDictionaryService.isSubClass(mockedNodeService.getType(nodeRef2), TYPE_CONTENT)).thenReturn(true);
|
||||||
|
when(mockedContentClassificationService.hasClearance(nodeRef2)).thenReturn(false);
|
||||||
|
|
||||||
|
assertEquals(new ArrayList(), nodeRefPostMethodInvocationProcessor.process(unmodifiableCollection(nodeRefs)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCollection_onlyOneNodeContent_userClearedForBoth()
|
||||||
|
{
|
||||||
|
NodeRef nodeRef1 = generateNodeRef();
|
||||||
|
NodeRef nodeRef2 = generateNodeRef();
|
||||||
|
ArrayList<NodeRef> nodeRefs = newArrayList(nodeRef1, nodeRef2);
|
||||||
|
|
||||||
|
when(mockedDictionaryService.isSubClass(mockedNodeService.getType(nodeRef1), TYPE_CONTENT)).thenReturn(false);
|
||||||
|
when(mockedContentClassificationService.hasClearance(nodeRef1)).thenReturn(true);
|
||||||
|
|
||||||
|
when(mockedDictionaryService.isSubClass(mockedNodeService.getType(nodeRef2), TYPE_CONTENT)).thenReturn(true);
|
||||||
|
when(mockedContentClassificationService.hasClearance(nodeRef2)).thenReturn(true);
|
||||||
|
|
||||||
|
assertEquals(nodeRefs, nodeRefPostMethodInvocationProcessor.process(copyOf(nodeRefs)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCollection_bothNodesNotContent_userClearedForBoth()
|
||||||
|
{
|
||||||
|
NodeRef nodeRef1 = generateNodeRef();
|
||||||
|
NodeRef nodeRef2 = generateNodeRef();
|
||||||
|
ArrayList<NodeRef> nodeRefs = newArrayList(nodeRef1, nodeRef2);
|
||||||
|
|
||||||
|
when(mockedDictionaryService.isSubClass(mockedNodeService.getType(nodeRef1), TYPE_CONTENT)).thenReturn(false);
|
||||||
|
when(mockedContentClassificationService.hasClearance(nodeRef1)).thenReturn(true);
|
||||||
|
|
||||||
|
when(mockedDictionaryService.isSubClass(mockedNodeService.getType(nodeRef2), TYPE_CONTENT)).thenReturn(false);
|
||||||
|
when(mockedContentClassificationService.hasClearance(nodeRef2)).thenReturn(true);
|
||||||
|
|
||||||
|
assertEquals(nodeRefs, nodeRefPostMethodInvocationProcessor.process(copyOf(nodeRefs)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user