@Test public void multiLevelAdminPermissionTesting() { List<String> adminPermissions = Arrays.asList("PARTYMGR", "EXAMPLE", "ACCTG_PREF"); assertTrue(SecurityUtil.checkMultiLevelAdminPermissionValidity(adminPermissions, "PARTYMGR_CME_CREATE")); assertTrue(SecurityUtil.checkMultiLevelAdminPermissionValidity( adminPermissions, "EXAMPLE_WITH_MULTI_LEVEL_ADMIN")); assertFalse(SecurityUtil.checkMultiLevelAdminPermissionValidity(adminPermissions, "ACCTG_ADMIN")); }
static boolean checkMultiLevelAdminPermissionValidity(List<String> permissionIds, String permission) { while (permission.contains("_")) { permission = permission.substring(0, permission.lastIndexOf("_")); if (permissionIds.contains(permission)) return true; } return false; }
SecurityUtil { static boolean checkMultiLevelAdminPermissionValidity(List<String> permissionIds, String permission) { while (permission.contains("_")) { permission = permission.substring(0, permission.lastIndexOf("_")); if (permissionIds.contains(permission)) return true; } return false; } }
SecurityUtil { static boolean checkMultiLevelAdminPermissionValidity(List<String> permissionIds, String permission) { while (permission.contains("_")) { permission = permission.substring(0, permission.lastIndexOf("_")); if (permissionIds.contains(permission)) return true; } return false; }  }
SecurityUtil { static boolean checkMultiLevelAdminPermissionValidity(List<String> permissionIds, String permission) { while (permission.contains("_")) { permission = permission.substring(0, permission.lastIndexOf("_")); if (permissionIds.contains(permission)) return true; } return false; }  static boolean hasUserLoginAdminPermission(Delegator delegator, String userLoginId); static List<String> hasUserLoginMorePermissionThan(Delegator delegator, String userLoginId, String toUserLoginId); static String generateJwtToAuthenticateUserLogin(Delegator delegator, String userLoginId); static boolean authenticateUserLoginByJWT(Delegator delegator, String userLoginId, String jwtToken); }
SecurityUtil { static boolean checkMultiLevelAdminPermissionValidity(List<String> permissionIds, String permission) { while (permission.contains("_")) { permission = permission.substring(0, permission.lastIndexOf("_")); if (permissionIds.contains(permission)) return true; } return false; }  static boolean hasUserLoginAdminPermission(Delegator delegator, String userLoginId); static List<String> hasUserLoginMorePermissionThan(Delegator delegator, String userLoginId, String toUserLoginId); static String generateJwtToAuthenticateUserLogin(Delegator delegator, String userLoginId); static boolean authenticateUserLoginByJWT(Delegator delegator, String userLoginId, String jwtToken);  }