@Test public final void testDenyPermissionAuthorityArray() { SecurityContextImpl context = SecurityContextImpl.fromXml(denyConfig, path); context.addAccessRule(new DenyAccessRule(EDITOR, WRITE)); if (SecurityUtils.checkAuthorization(context, WRITE, EDITOR)) { fail("Check for Action " + WRITE + " and role " + EDITOR + " passed while it shouldn't"); } }
public static boolean checkAuthorization(Securable securable, Action action, Authority authority) { if (securable == null) throw new IllegalArgumentException("Securable cannot be null"); if (action == null) throw new IllegalArgumentException("Action cannot be null"); if (authority == null) throw new IllegalArgumentException("Authority cannot be null"); logger.trace("Request to check action '{}' for authority '{}' on {}", new Object[] { action, authority, securable }); switch (securable.getAllowDenyOrder()) { case AllowDeny: if (securable.isAllowed(action, authority)) return true; if (securable.isDenied(action, authority)) return false; return false; case DenyAllow: if (securable.isDenied(action, authority)) return false; if (securable.isAllowed(action, authority)) return true; return false; default: throw new IllegalStateException("Allow/deny order " + securable.getAllowDenyOrder() + " unsupported"); } }
SecurityUtils { public static boolean checkAuthorization(Securable securable, Action action, Authority authority) { if (securable == null) throw new IllegalArgumentException("Securable cannot be null"); if (action == null) throw new IllegalArgumentException("Action cannot be null"); if (authority == null) throw new IllegalArgumentException("Authority cannot be null"); logger.trace("Request to check action '{}' for authority '{}' on {}", new Object[] { action, authority, securable }); switch (securable.getAllowDenyOrder()) { case AllowDeny: if (securable.isAllowed(action, authority)) return true; if (securable.isDenied(action, authority)) return false; return false; case DenyAllow: if (securable.isDenied(action, authority)) return false; if (securable.isAllowed(action, authority)) return true; return false; default: throw new IllegalStateException("Allow/deny order " + securable.getAllowDenyOrder() + " unsupported"); } } }
SecurityUtils { public static boolean checkAuthorization(Securable securable, Action action, Authority authority) { if (securable == null) throw new IllegalArgumentException("Securable cannot be null"); if (action == null) throw new IllegalArgumentException("Action cannot be null"); if (authority == null) throw new IllegalArgumentException("Authority cannot be null"); logger.trace("Request to check action '{}' for authority '{}' on {}", new Object[] { action, authority, securable }); switch (securable.getAllowDenyOrder()) { case AllowDeny: if (securable.isAllowed(action, authority)) return true; if (securable.isDenied(action, authority)) return false; return false; case DenyAllow: if (securable.isDenied(action, authority)) return false; if (securable.isAllowed(action, authority)) return true; return false; default: throw new IllegalStateException("Allow/deny order " + securable.getAllowDenyOrder() + " unsupported"); } } private  SecurityUtils(); }
SecurityUtils { public static boolean checkAuthorization(Securable securable, Action action, Authority authority) { if (securable == null) throw new IllegalArgumentException("Securable cannot be null"); if (action == null) throw new IllegalArgumentException("Action cannot be null"); if (authority == null) throw new IllegalArgumentException("Authority cannot be null"); logger.trace("Request to check action '{}' for authority '{}' on {}", new Object[] { action, authority, securable }); switch (securable.getAllowDenyOrder()) { case AllowDeny: if (securable.isAllowed(action, authority)) return true; if (securable.isDenied(action, authority)) return false; return false; case DenyAllow: if (securable.isDenied(action, authority)) return false; if (securable.isAllowed(action, authority)) return true; return false; default: throw new IllegalStateException("Allow/deny order " + securable.getAllowDenyOrder() + " unsupported"); } } private  SecurityUtils(); static void setConfigured(boolean configured); static boolean isConfigured(); static void setEnabled(boolean enabled); static boolean isEnabled(); static void setUser(User user); static User getUser(); static void setSite(Site site); static Site getSite(); static boolean isAuthenticated(User user); static boolean userHasRole(User user, Role role); static boolean userHasRole(User user, String roleId); static boolean userHasPermission(User user, Securable securable,
      Action action); static Role[] getRoles(User user); static boolean checkAuthorization(Securable securable, Action action,
      Authority authority); static boolean checkAuthorizationForSome(Securable securable,
      Set<Action> actions, Authority authorization); static boolean checkAuthorizationForAll(Securable securable,
      Set<Action> actions, Authority authorization); }
SecurityUtils { public static boolean checkAuthorization(Securable securable, Action action, Authority authority) { if (securable == null) throw new IllegalArgumentException("Securable cannot be null"); if (action == null) throw new IllegalArgumentException("Action cannot be null"); if (authority == null) throw new IllegalArgumentException("Authority cannot be null"); logger.trace("Request to check action '{}' for authority '{}' on {}", new Object[] { action, authority, securable }); switch (securable.getAllowDenyOrder()) { case AllowDeny: if (securable.isAllowed(action, authority)) return true; if (securable.isDenied(action, authority)) return false; return false; case DenyAllow: if (securable.isDenied(action, authority)) return false; if (securable.isAllowed(action, authority)) return true; return false; default: throw new IllegalStateException("Allow/deny order " + securable.getAllowDenyOrder() + " unsupported"); } } private  SecurityUtils(); static void setConfigured(boolean configured); static boolean isConfigured(); static void setEnabled(boolean enabled); static boolean isEnabled(); static void setUser(User user); static User getUser(); static void setSite(Site site); static Site getSite(); static boolean isAuthenticated(User user); static boolean userHasRole(User user, Role role); static boolean userHasRole(User user, String roleId); static boolean userHasPermission(User user, Securable securable,
      Action action); static Role[] getRoles(User user); static boolean checkAuthorization(Securable securable, Action action,
      Authority authority); static boolean checkAuthorizationForSome(Securable securable,
      Set<Action> actions, Authority authorization); static boolean checkAuthorizationForAll(Securable securable,
      Set<Action> actions, Authority authorization);  }