{
// classify policy query for local test case; this implementation
// is not optimized: multiple protection domains exist on the
// call stack, so this method will be invoked 2-3 times for each
// access check with the identical principals and permission
JetspeedPermission j2p = permission instanceof JetspeedPermission ? (JetspeedPermission)permission : null;
boolean testPermission = j2p != null && (j2p.getType().equals("folder")||j2p.getType().equals("page")||j2p.getType().equals("fragment"));
Principal[] principals = domain.getPrincipals();
if ((principals != null) && (principals.length > 0) && (testPermission))
{
// check permission using principals if available
Permissions permissions = new Permissions();