Package org.projectforge.access

Examples of org.projectforge.access.AccessException


  private void securityChecks(final String script)
  {
    final String[] forbiddenKeyWords = { "__baseDao", "__baseObject", "System.ex"};
    for (final String forbiddenKeyWord : forbiddenKeyWords) {
      if (StringUtils.contains(script, forbiddenKeyWord) == true) {
        throw new AccessException("access.exception.violation", forbiddenKeyWord);
      }
    }
  }
View Full Code Here


    if (result == false && obj.isDeleted() == false) {
      Validate.notNull(user);
      result = userGroupCache.isUserMemberOfGroup(user.getId(), obj.getId());
    }
    if (throwException == true && result == false) {
      throw new AccessException(AccessType.GROUP, OperationType.SELECT);
    }
    return result;
  }
View Full Code Here

    if (PFUserContext.getUser() == SYSTEM_ADMIN_PSEUDO_USER) {
      // No access check for the system admin pseudo user.
      return;
    }
    if (Login.getInstance().isAdminUser(PFUserContext.getUser()) == false) {
      throw new AccessException(AccessChecker.I18N_KEY_VIOLATION_USER_NOT_MEMBER_OF, ProjectForgeGroup.ADMIN_GROUP.getKey());
    }
    accessChecker.checkRestrictedOrDemoUser();
  }
View Full Code Here

  protected void checkInsertAccess(final PFUserDO user, final TaskDO obj) throws AccessException
  {
    super.checkInsertAccess(user, obj);
    if (accessChecker.isUserMemberOfGroup(user, ProjectForgeGroup.FINANCE_GROUP) == false) {
      if (obj.getProtectTimesheetsUntil() != null) {
        throw new AccessException("task.error.protectTimesheetsUntilReadonly");
      }
      if (obj.isProtectionOfPrivacy() == true) {
        throw new AccessException("task.error.protectionOfPrivacyReadonly");
      }
    }
    if (hasAccessForKost2AndTimesheetBookingStatus(user, obj) == false) {
      // Non project managers are not able to manipulate the following fields:
      if (StringUtils.isNotBlank(obj.getKost2BlackWhiteList()) == true || obj.isKost2IsBlackList() == true) {
        throw new AccessException("task.error.kost2Readonly");
      }
      if (obj.getTimesheetBookingStatus() != TimesheetBookingStatus.DEFAULT) {
        throw new AccessException("task.error.timesheetBookingStatus2Readonly");
      }
    }
  }
View Full Code Here

      }
      if (dbObj.getProtectTimesheetsUntil() != null) {
        ts2 = dbObj.getProtectTimesheetsUntil().getTime();
      }
      if (ObjectUtils.equals(ts1, ts2) == false) {
        throw new AccessException("task.error.protectTimesheetsUntilReadonly");
      }
      if (ObjectUtils.equals(obj.isProtectionOfPrivacy(), dbObj.isProtectionOfPrivacy()) == false) {
        throw new AccessException("task.error.protectionOfPrivacyReadonly");
      }
    }
    if (hasAccessForKost2AndTimesheetBookingStatus(user, obj) == false) {
      // Non project managers are not able to manipulate the following fields:
      if (ObjectUtils.equals(obj.getKost2BlackWhiteList(), dbObj.getKost2BlackWhiteList()) == false
          || obj.isKost2IsBlackList() != dbObj.isKost2IsBlackList()) {
        throw new AccessException("task.error.kost2Readonly");
      }
      if (obj.getTimesheetBookingStatus() != dbObj.getTimesheetBookingStatus()) {
        throw new AccessException("task.error.timesheetBookingStatus2Readonly");
      }
    }
  }
View Full Code Here

  private void databaseNotEmpty()
  {
    final String msg = "Database seems to be not empty. Initialization of database aborted.";
    log.error(msg);
    throw new AccessException(msg);
  }
View Full Code Here

      if (doLog == true) {
        log.info(ex.toString() + ExceptionHelper.getFilteredStackTrace(ex, ONLY4NAMESPACE));
      }
      return securedPage.translateParams(ex.getI18nKey(), ex.getMsgParams(), ex.getParams());
    } else if (exception instanceof AccessException) {
      final AccessException ex = (AccessException) exception;
      if (doLog == true) {
        log.info(ex.toString() + ExceptionHelper.getFilteredStackTrace(ex, ONLY4NAMESPACE));
      }
      if (ex.getParams() != null) {
        return securedPage.getLocalizedMessage(ex.getI18nKey(), ex.getParams());
      } else {
        return securedPage.translateParams(ex.getI18nKey(), ex.getMessageArgs(), ex.getParams());
      }
    }
    throw new UnsupportedOperationException("For developer: Please add unknown ProjectForgeException here!", exception);
  }
View Full Code Here

        || accessChecker.isUserMemberOfGroup(user, ProjectForgeGroup.FINANCE_GROUP, ProjectForgeGroup.CONTROLLING_GROUP);
    if (result == false && obj.hasSystemAccess() == true) {
      result = accessChecker.areUsersInSameGroup(user, obj);
    }
    if (throwException == true && result == false) {
      throw new AccessException(user, AccessType.GROUP, OperationType.SELECT);
    }
    return result;
  }
View Full Code Here

      } else if (task.getTimesheetBookingStatus() == TimesheetBookingStatus.TREE_CLOSED) {
        errorMessage = "timesheet.error.taskNotBookable.treeClosedForBooking";
      }
      if (errorMessage != null) {
        if (throwException == true) {
          throw new AccessException(errorMessage, task.getTitle() + " (#" + task.getId() + ")");
        }
        return false;
      }
      node = node.getParent();
    } while (node != null);
    // 2. Has the task the booking status NO_BOOKING?
    TimesheetBookingStatus bookingStatus = taskNode.getTask().getTimesheetBookingStatus();
    node = taskNode;
    while (bookingStatus == TimesheetBookingStatus.INHERIT && node.getParent() != null) {
      node = node.getParent();
      bookingStatus = node.getTask().getTimesheetBookingStatus();
    }
    if (bookingStatus == TimesheetBookingStatus.NO_BOOKING) {
      if (throwException == true) {
        throw new AccessException("timesheet.error.taskNotBookable.taskClosedForBooking", taskNode.getTask().getTitle()
            + " (#"
            + taskNode.getId()
            + ")");
      }
      return false;
    }
    if (taskNode.hasChilds() == true) {
      // 3. Is the task not a leaf node and has this task or ancestor task the booking status ONLY_LEAFS?
      node = taskNode;
      do {
        final TaskDO task = node.getTask();
        if (task.getTimesheetBookingStatus() == TimesheetBookingStatus.ONLY_LEAFS) {
          if (throwException == true) {
            throw new AccessException("timesheet.error.taskNotBookable.onlyLeafsAllowedForBooking", taskNode.getTask().getTitle()
                + " (#"
                + taskNode.getId()
                + ")");
          }
          return false;
        }
        node = node.getParent();
      } while (node != null);
      // 4. Does any of the descendant task node has an assigned order position?
      for (final TaskNode child : taskNode.getChilds()) {
        if (taskTree.hasOrderPositions(child.getId(), true) == true) {
          if (throwException == true) {
            throw new AccessException("timesheet.error.taskNotBookable.orderPositionsFoundInSubTasks", taskNode.getTask().getTitle()
                + " (#"
                + taskNode.getId()
                + ")");
          }
          return false;
View Full Code Here

      }
      final DateHolder dh = new DateHolder(date);
      dh.setEndOfDay();
      if (timesheet.getStartTime().before(dh.getDate()) == true) {
        if (throwException == true) {
          throw new AccessException("timesheet.error.timesheetProtectionVioloation", node.getTask().getTitle()
              + " (#"
              + node.getTaskId()
              + ")", DateHelper.formatIsoDate(dh.getDate()));
        }
        return false;
View Full Code Here

TOP

Related Classes of org.projectforge.access.AccessException

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.