mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
ALF-9321 (RINF 11): CQ permissions
- AbstractCannedQuery.applyPostQueryPermissions (put back "List<R>" return type) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@28646 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -35,7 +35,6 @@ import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.query.CannedQueryParameters;
|
||||
import org.alfresco.query.CannedQuerySortDetails;
|
||||
import org.alfresco.query.PagingResults;
|
||||
import org.alfresco.query.CannedQuerySortDetails.SortOrder;
|
||||
import org.alfresco.repo.domain.node.AuditablePropertiesEntity;
|
||||
import org.alfresco.repo.domain.node.Node;
|
||||
@@ -482,7 +481,7 @@ public class GetChildrenCannedQuery extends AbstractCannedQueryPermissions<NodeR
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PagingResults<NodeRef> applyPostQueryPermissions(List<NodeRef> results, String authenticationToken, int requestedCount)
|
||||
protected List<NodeRef> applyPostQueryPermissions(List<NodeRef> results, String authenticationToken, int requestedCount)
|
||||
{
|
||||
Long start = (logger.isDebugEnabled() ? System.currentTimeMillis() : null);
|
||||
|
||||
@@ -495,11 +494,11 @@ public class GetChildrenCannedQuery extends AbstractCannedQueryPermissions<NodeR
|
||||
// note: assume user has read access to most/majority of the items hence pre-load up to max checks
|
||||
preload(results.subList(0, toIdx));
|
||||
|
||||
PagingResults<NodeRef> ret = super.applyPostQueryPermissions(results, authenticationToken, requestedCount);
|
||||
List<NodeRef> ret = super.applyPostQueryPermissions(results, authenticationToken, requestedCount);
|
||||
|
||||
if (start != null)
|
||||
{
|
||||
logger.debug("Post-query perms: "+ret.getPage().size()+" in "+(System.currentTimeMillis()-start)+" msecs");
|
||||
logger.debug("Post-query perms: "+ret.size()+" in "+(System.currentTimeMillis()-start)+" msecs");
|
||||
}
|
||||
|
||||
return ret;
|
||||
@@ -699,9 +698,9 @@ public class GetChildrenCannedQuery extends AbstractCannedQueryPermissions<NodeR
|
||||
preload(nodeRefs);
|
||||
|
||||
// TODO track total time for incremental permission checks ... and cutoff (eg. based on some config)
|
||||
PagingResults<NodeRef> results = applyPermissions(nodeRefs, authenticationToken, nodeRefs.size());
|
||||
List<NodeRef> results = applyPermissions(nodeRefs, authenticationToken, nodeRefs.size());
|
||||
|
||||
for (NodeRef nodeRef : results.getPage())
|
||||
for (NodeRef nodeRef : results)
|
||||
{
|
||||
// Call back
|
||||
boolean more = resultsCallback.handle(nodeRef);
|
||||
|
@@ -18,7 +18,6 @@
|
||||
*/
|
||||
package org.alfresco.repo.security.authority;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@@ -76,7 +76,7 @@ public abstract class AbstractCannedQueryPermissions<R> extends AbstractCannedQu
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
protected PagingResults<R> applyPostQueryPermissions(List<R> results, String authenticationToken, int requestedCount)
|
||||
protected List<R> applyPostQueryPermissions(List<R> results, String authenticationToken, int requestedCount)
|
||||
{
|
||||
int requestTotalCountMax = getParameters().requestTotalResultCountMax();
|
||||
int maxChecks = (((requestTotalCountMax > 0) && (requestTotalCountMax > requestedCount)) ? requestTotalCountMax : requestedCount);
|
||||
@@ -85,43 +85,10 @@ public abstract class AbstractCannedQueryPermissions<R> extends AbstractCannedQu
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected PagingResults<R> applyPermissions(List<R> results, String authenticationToken, int maxChecks)
|
||||
protected List<R> applyPermissions(List<R> results, String authenticationToken, int maxChecks)
|
||||
{
|
||||
long start = System.currentTimeMillis();
|
||||
|
||||
// empty result
|
||||
PagingResults<R> ret = new PagingResults<R>()
|
||||
{
|
||||
@Override
|
||||
public String getQueryExecutionId()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<Integer, Integer> getTotalResultCount()
|
||||
{
|
||||
return new Pair<Integer, Integer>(0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<R> getPage()
|
||||
{
|
||||
return new ArrayList<R>(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMoreItems()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean permissionsApplied()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
Context context = ContextHolder.getContext();
|
||||
if ((context == null) || (! (context instanceof AlfrescoSecureContext)))
|
||||
{
|
||||
@@ -129,54 +96,18 @@ public abstract class AbstractCannedQueryPermissions<R> extends AbstractCannedQu
|
||||
{
|
||||
logger.debug("Unexpected context: "+(context == null ? "null" : context.getClass())+" - "+Thread.currentThread().getId());
|
||||
}
|
||||
System.out.println("Unexpected context: "+(context == null ? "null" : context.getClass())+" - "+Thread.currentThread().getId());
|
||||
|
||||
return ret; // empty result
|
||||
return new WrappedList<R>(new ArrayList<R>(0), true, false); // empty result
|
||||
}
|
||||
|
||||
Authentication authentication = (((SecureContext) context).getAuthentication());
|
||||
|
||||
ConfigAttributeDefinition cad = methodSecurityInterceptor.getObjectDefinitionSource().getAttributes(new InternalMethodInvocation(method));
|
||||
final WrappedList<R> wl = (WrappedList<R>)methodSecurityInterceptor.getAfterInvocationManager().decide(authentication, null, cad, new WrappedList<R>(results, maxChecks));
|
||||
|
||||
// final result
|
||||
ret = new PagingResults<R>()
|
||||
{
|
||||
@Override
|
||||
public String getQueryExecutionId()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<Integer, Integer> getTotalResultCount()
|
||||
{
|
||||
int count = wl.size();
|
||||
return new Pair<Integer, Integer>(count, ((! wl.hasMoreItems()) ? count : null));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<R> getPage()
|
||||
{
|
||||
return wl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMoreItems()
|
||||
{
|
||||
return wl.hasMoreItems(); // if hasMoreItems then implies cutoff
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean permissionsApplied()
|
||||
{
|
||||
return wl.permissionsApplied();
|
||||
}
|
||||
};
|
||||
List<R> ret = (WrappedList<R>)methodSecurityInterceptor.getAfterInvocationManager().decide(authentication, null, cad, new WrappedList<R>(results, maxChecks));
|
||||
|
||||
if (logger.isTraceEnabled())
|
||||
{
|
||||
logger.trace("applyPermissions: "+wl.size()+" items in "+(System.currentTimeMillis()-start)+" msecs");
|
||||
logger.trace("applyPermissions: "+ret.size()+" items in "+(System.currentTimeMillis()-start)+" msecs");
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
Reference in New Issue
Block a user