Package org.projectforge.user

Examples of org.projectforge.user.UserGroupCache


   */
  @Override
  public boolean hasAccess(final PFUserDO user, final AuftragDO obj, final  AuftragDO oldObj, final OperationType operationType)
  {
    final AccessChecker accessChecker = UserRights.getAccessChecker();
    final UserGroupCache userGroupCache = UserRights.getUserGroupCache();
    if (operationType == OperationType.SELECT) {
      if (accessChecker.isUserMemberOfGroup(user, ProjectForgeGroup.CONTROLLING_GROUP) == true) {
        return true;
      }
      if (accessChecker.hasRight(user, getId(), UserRightValue.READONLY, UserRightValue.PARTLYREADWRITE, UserRightValue.READWRITE) == false) {
        return false;
      }
    } else {
      if (accessChecker.hasRight(user, getId(), UserRightValue.PARTLYREADWRITE, UserRightValue.READWRITE) == false) {
        return false;
      }
    }
    if (obj != null
        && accessChecker.isUserMemberOfGroup(user, ProjectForgeGroup.FINANCE_GROUP) == false
        && CollectionUtils.isNotEmpty(obj.getPositionen()) == true) {
      // Special field check for non finance administrative staff members:
      if (operationType == OperationType.INSERT) {
        for (final AuftragsPositionDO position : obj.getPositionen()) {
          if (position.isVollstaendigFakturiert() == true) {
            throw new AccessException("fibu.auftrag.error.vollstaendigFakturiertProtection");
          }
        }
      } else if (oldObj != null) {
        for (short number = 1; number <= obj.getPositionen().size(); number++) {
          final AuftragsPositionDO position = obj.getPosition(number);
          final AuftragsPositionDO dbPosition = oldObj.getPosition(number);
          if (dbPosition == null) {
            if (position.isVollstaendigFakturiert() == true) {
              throw new AccessException("fibu.auftrag.error.vollstaendigFakturiertProtection");
            }
          } else if (position.isVollstaendigFakturiert() != dbPosition.isVollstaendigFakturiert()) {
            throw new AccessException("fibu.auftrag.error.vollstaendigFakturiertProtection");
          }
        }
      }
    }
    if (accessChecker.isUserMemberOfGroup(user, UserRights.FIBU_ORGA_GROUPS) == true
        && accessChecker.hasRight(user, getId(), UserRightValue.READONLY, UserRightValue.READWRITE)) {
      // No further access checking (but not for users with right PARTLY_READWRITE.
    } else if (obj != null) {
      // User should be a PROJECT_MANAGER or PROJECT_ASSISTANT or user has PARTLYREADWRITE access:
      boolean hasAccess = false;
      if (accessChecker.userEquals(user, obj.getContactPerson()) == true) {
        hasAccess = true;
      }
      if (obj.getProjekt() != null && userGroupCache.isUserMemberOfGroup(user.getId(), obj.getProjekt().getProjektManagerGroupId())) {
        hasAccess = true;
      }
      if (hasAccess == true) {
        if (obj.isVollstaendigFakturiert() == false) {
          return true;
View Full Code Here


    final ProjektFilter filter = new ProjektFilter();
    final List<ProjektDO> projects = projektDao.getList(filter);
    if (CollectionUtils.isEmpty(projects) == true) {
      return result;
    }
    final UserGroupCache userGroupCache = Registry.instance().getUserGroupCache();
    for (final ProjektDO project : projects) {
      final Integer groupId = project.getProjektManagerGroupId();
      if (groupId == null) {
        // No manager group defined.
        continue;
      }
      if (userGroupCache.isUserMemberOfGroup(user, groupId) == false) {
        continue;
      }
      result.add(project);
    }
    return result;
View Full Code Here

   * Get all given gid numbers of all ProjectForge groups including any deleted group and get the next highest and free number. The number is
   * 1000 if no gid number (with a value greater than 999) is found.
   */
  public static int getNextFreeGidNumber()
  {
    final UserGroupCache userGroupCache = Registry.instance().getUserGroupCache();
    final Collection<GroupDO> allGroups = userGroupCache.getAllGroups();
    int currentMaxNumber = 999;
    for (final GroupDO group : allGroups) {
      final LdapGroupValues ldapGroupValues = GroupDOConverter.readLdapGroupValues(group.getLdapValues());
      if (ldapGroupValues == null) {
        continue;
View Full Code Here

   * @param gidNumber
   * @return Returns true if any group (also deleted group) other than the given group has the given gidNumber, otherwise false.
   */
  public static boolean isGivenNumberFree(final GroupDO currentGroup, final int gidNumber)
  {
    final UserGroupCache userGroupCache = Registry.instance().getUserGroupCache();
    final Collection<GroupDO> allGroups = userGroupCache.getAllGroups();
    for (final GroupDO group : allGroups) {
      final LdapGroupValues ldapGroupValues = GroupDOConverter.readLdapGroupValues(group.getLdapValues());
      if (ObjectUtils.equals(group.getId(), currentGroup.getId()) == true) {
        // The current group may have the given gidNumber already, so ignore this entry.
        continue;
View Full Code Here

   * Get all given uid numbers of all ProjectForge users including any deleted user and get the next highest and free number. The number is
   * 1000 if no uid number (with an value greater than 999) is found.
   */
  public static int getNextFreeUidNumber()
  {
    final UserGroupCache userGroupCache = Registry.instance().getUserGroupCache();
    final Collection<PFUserDO> allUsers = userGroupCache.getAllUsers();
    int currentMaxNumber = 999;
    for (final PFUserDO user : allUsers) {
      final LdapUserValues ldapUserValues = PFUserDOConverter.readLdapUserValues(user.getLdapValues());
      if (ldapUserValues == null) {
        continue;
View Full Code Here

   * @param uidNumber
   * @return Returns true if any user (also deleted user) other than the given user has the given uidNumber, otherwise false.
   */
  public static boolean isGivenNumberFree(final PFUserDO currentUser, final int uidNumber)
  {
    final UserGroupCache userGroupCache = Registry.instance().getUserGroupCache();
    final Collection<PFUserDO> allUsers = userGroupCache.getAllUsers();
    for (final PFUserDO user : allUsers) {
      final LdapUserValues ldapUserValues = PFUserDOConverter.readLdapUserValues(user.getLdapValues());
      if (ObjectUtils.equals(user.getId(), currentUser.getId()) == true) {
        // The current user may have the given uidNumber already, so ignore this entry.
        continue;
View Full Code Here

   * Get all given uid numbers of all ProjectForge users including any deleted user and get the next highest and free number. The number is
   * 1000 if no uid number (with a value greater than 999) is found.
   */
  public static int getNextFreeSambaSIDNumber()
  {
    final UserGroupCache userGroupCache = Registry.instance().getUserGroupCache();
    final Collection<PFUserDO> allUsers = userGroupCache.getAllUsers();
    int currentMaxNumber = 999;
    for (final PFUserDO user : allUsers) {
      final LdapUserValues ldapUserValues = PFUserDOConverter.readLdapUserValues(user.getLdapValues());
      if (ldapUserValues == null) {
        continue;
View Full Code Here

  {
    if (sambaSIDNumber == null) {
      // Nothing to check.
      return true;
    }
    final UserGroupCache userGroupCache = Registry.instance().getUserGroupCache();
    final Collection<PFUserDO> allUsers = userGroupCache.getAllUsers();
    for (final PFUserDO user : allUsers) {
      final LdapUserValues ldapUserValues = PFUserDOConverter.readLdapUserValues(user.getLdapValues());
      if (ObjectUtils.equals(user.getId(), currentUser.getId()) == true) {
        // The current user may have the given sambaSIDNumber already, so ignore this entry.
        continue;
View Full Code Here

    final HttpServletResponse response = mock(HttpServletResponse.class);
    final UserDao userDao = mock(UserDao.class);
    when(userDao.authenticateUser(Mockito.eq("successUser"), Mockito.eq("successPassword"))).thenReturn(
        new PFUserDO().setUsername("successUser"));
    when(userDao.getCachedAuthenticationToken(Mockito.eq(2))).thenReturn("token");
    final UserGroupCache userGroupCache = mock(UserGroupCache.class);
    when(userDao.getUserGroupCache()).thenReturn(userGroupCache);
    when(userGroupCache.getUser(Mockito.eq(2))).thenReturn(new PFUserDO().setUsername("testuser"));
    final RestUserFilter filter = new RestUserFilter();
    filter.userDao = userDao;

    // Wrong password
    HttpServletRequest request = mockRequest("successUser", "failed", null, null);
View Full Code Here

  {
    if (ids == null || ids.length == 0) {
      return "";
    }
    String s = "";
    final UserGroupCache userGroupCache = Registry.instance().getUserGroupCache();
    for (final Integer id : ids) {
      s += userGroupCache.getGroupname(id) + ", ";
    }
    return s.substring(0, s.lastIndexOf(", "));
  }
View Full Code Here

TOP

Related Classes of org.projectforge.user.UserGroupCache

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.