HttpRequestUtils { public static boolean hasPermission(final UserManager userManager, final User user, final Permission.Type type) { for (final String roleName : user.getRoles()) { final Role role = userManager.getRole(roleName); if (role.getPermission().isPermissionSet(type) || role.getPermission().isPermissionSet(Permission.Type.ADMIN)) { return true; } } return false; }  static ExecutionOptions parseFlowOptions(final HttpServletRequest req,
      final String flowName); static void filterAdminOnlyFlowParams(final UserManager userManager,
      final ExecutionOptions options, final User user); static boolean validateIntegerParam(final Map<String, String> params,
      final String paramName); static boolean hasPermission(final UserManager userManager, final User user,
      final Permission.Type type); static boolean hasParam(final HttpServletRequest request, final String param); static String getParam(final HttpServletRequest request, final String name); static String getParam(final HttpServletRequest request, final String name,
      final String defaultVal); static int getIntParam(final HttpServletRequest request, final String name); static int getIntParam(final HttpServletRequest request, final String name,
      final int defaultVal); static boolean getBooleanParam(final HttpServletRequest request, final String name); static boolean getBooleanParam(final HttpServletRequest request,
      final String name, final boolean defaultVal); static long getLongParam(final HttpServletRequest request, final String name); static long getLongParam(final HttpServletRequest request, final String name,
      final long defaultVal); static Map<String, String> getParamGroup(final HttpServletRequest request,
      final String groupName); static Object getJsonBody(final HttpServletRequest request); static String getBody(final HttpServletRequest request); static final String PARAM_SLA_EMAILS; static final String PARAM_SLA_SETTINGS; }
@Test public void testHasAdminPermission() throws UserManagerException { final UserManager manager = TestUtils.createTestXmlUserManager(); final User adminUser = manager.getUser("testAdmin", "testAdmin"); Assert.assertTrue(HttpRequestUtils.hasPermission(manager, adminUser, Type.ADMIN)); }
@Test public void testHasOrdinaryPermission() throws UserManagerException { final UserManager manager = TestUtils.createTestXmlUserManager(); final User testUser = manager.getUser("testUser", "testUser"); Assert.assertFalse(HttpRequestUtils.hasPermission(manager, testUser, Type.ADMIN)); }