Utils implements Constants { public static boolean canHandle(@NotNull Principal principal, @NotNull Filter filter, int importBehavior) throws AccessControlException { String name = principal.getName(); if (Strings.isNullOrEmpty(name)) { throw new AccessControlException("Invalid principal " + name); } boolean canHandle = filter.canHandle(Collections.singleton(principal)); switch (importBehavior) { case ImportBehavior.ABORT: if (!canHandle) { throw new AccessControlException("Unsupported principal " + name); } break; case ImportBehavior.IGNORE: case ImportBehavior.BESTEFFORT: log.debug("Ignoring unsupported principal {}", name); break; default: throw new IllegalArgumentException("Unsupported import behavior " + importBehavior); } return canHandle; } private  Utils(); static boolean isPrincipalPolicyTree(@NotNull Tree tree); static boolean isPrincipalEntry(@NotNull Tree tree); static boolean canHandle(@NotNull Principal principal, @NotNull Filter filter, int importBehavior); static Privilege[] privilegesFromOakNames(@NotNull Set<String> privilegeNames, @NotNull PrivilegeManager privilegeManager, @NotNull NamePathMapper namePathMapper); static boolean hasModAcPermission(@NotNull PermissionProvider permissionProvider, @NotNull String effectivePath);  }
@Test(expected = AccessControlException.class) public void testCanHandleNullName() throws Exception { Utils.canHandle(Mockito.mock(Principal.class), mockFilter(true), ImportBehavior.ABORT); }
@Test(expected = AccessControlException.class) public void testCanHandleEmptyName() throws Exception { Utils.canHandle(new PrincipalImpl(""), mockFilter(true), ImportBehavior.ABORT); }
@Test(expected = AccessControlException.class) public void testCanHandleUnsupportedPrincipalAbort() throws Exception { Utils.canHandle(PRINCIPAL, mockFilter(false), ImportBehavior.ABORT); }
@Test public void testCanHandleUnsupportedPrincipalIgnore() throws Exception { assertFalse(Utils.canHandle(PRINCIPAL, mockFilter(false), ImportBehavior.IGNORE)); }
@Test public void testCanHandleUnsupportedPrincipalBestEffort() throws Exception { assertFalse(Utils.canHandle(PRINCIPAL, mockFilter(false), ImportBehavior.BESTEFFORT)); }
@Test(expected = IllegalArgumentException.class) public void testCanHandleIllegalImportBehavior() throws Exception { assertFalse(Utils.canHandle(PRINCIPAL, mockFilter(true), -1)); }
@Test public void testCanHandle() throws Exception { for (int behavior : new int[] {ImportBehavior.ABORT, ImportBehavior.BESTEFFORT, ImportBehavior.IGNORE}) { assertTrue(Utils.canHandle(PRINCIPAL, mockFilter(true), behavior)); } }