public static boolean canAccess(int userId, String roleName, String value) {
    PermissionControl pc = SecurityRepository.get(userId);

    if (pc == null) {
      throw new SecurityLoadException(
          "Failed to load security roles for userId "
              + userId
              + " (null PermissionControl returned). "
              + "roleName="
              + roleName
              + ", roleValue="
              + value);
    }

    return (value != null ? pc.canAccess(roleName, value) : pc.canAccess(roleName));
  }
  /**
   * Load user's roles.
   *
   * @param user The <code>User</code> to load
   * @param force If <code>true</code>, forces a reload. If <code>false</code>, the call will be
   *     ignored if the roles are already loaded.
   * @see SecurityRepository#load(int)
   * @see SecurityRepository#load(int, boolean)
   * @see SecurityRepository#load(User)
   * @return PermissionControl
   */
  public static PermissionControl load(User user, boolean force) {
    String userId = Integer.toString(user.getId());

    if (force || cache.get(FQN, userId) == null) {
      PermissionControl pc = new PermissionControl();

      // load roles
      GroupSecurityDAO dao = DataAccessDriver.getInstance().newGroupSecurityDAO();
      pc.setRoles(dao.loadRolesByUserGroups(user));

      cache.add(FQN, userId, pc);

      return pc;
    }

    return SecurityRepository.get(user.getId());
  }