SecurityService extends DefaultComponent { public static String[] getPrincipalsToCheck(Principal principal) { List<String> userGroups = null; if (principal instanceof NuxeoPrincipal) { userGroups = ((NuxeoPrincipal) principal).getAllGroups(); } if (userGroups == null) { return new String[] { principal.getName(), SecurityConstants.EVERYONE }; } else { int size = userGroups.size(); String[] groups = new String[size + 2]; userGroups.toArray(groups); groups[size] = principal.getName(); groups[size + 1] = SecurityConstants.EVERYONE; return groups; } }  @Override void activate(ComponentContext context); @Override void deactivate(ComponentContext context); @Override void registerContribution(Object contribution,
            String extensionPoint, ComponentInstance contributor); @Override void unregisterContribution(Object contribution,
            String extensionPoint, ComponentInstance contributor); PermissionProvider getPermissionProvider(); boolean arePoliciesRestrictingPermission(String permission); boolean arePoliciesExpressibleInQuery(String repositoryName); Collection<SQLQuery.Transformer> getPoliciesQueryTransformers(
            String repositoryName); boolean checkPermission(Document doc, Principal principal,
            String permission); String[] getPermissionsToCheck(String permission); static String[] getPrincipalsToCheck(Principal principal); @SuppressWarnings("unchecked") @Override T getAdapter(Class<T> adapter); static final ComponentName NAME; static final String PERMISSIONS_EXTENSION_POINT; }
@Test public void testGetPrincipalsToCheck() { NuxeoPrincipal principal = new UserPrincipal("bob", Arrays.asList( "vps", "males"), false, false); String[] principals = SecurityService.getPrincipalsToCheck(principal); assertEquals(4, principals.length); assertTrue(Arrays.asList(principals).contains("bob")); assertTrue(Arrays.asList(principals).contains("vps")); assertTrue(Arrays.asList(principals).contains("males")); assertTrue(Arrays.asList(principals).contains( SecurityConstants.EVERYONE)); }