Package org.olat.basesecurity

Examples of org.olat.basesecurity.Manager


   */
  private void saveFormData(UserRequest ureq, Identity myIdentity, SystemRolesAndRightsForm form) {
    Map configuration = BaseSecurityModule.getConfiguration();
    boolean iAmOlatAdmin = ureq.getUserSession().getRoles().isOLATAdmin();
    boolean iAmUserManager = ureq.getUserSession().getRoles().isUserManager();
    Manager secMgr = ManagerFactory.getManager();
    // 1) general user type - anonymous or user
    // anonymous users
    boolean isAnonymous = false;
    Boolean canGuestsByConfig = (Boolean) configuration.get(BaseSecurityModule.CONFIG_USERMANAGER_CAN_MANAGE_GUESTS)
    if (canGuestsByConfig.booleanValue() || iAmOlatAdmin) {
      SecurityGroup anonymousGroup = secMgr.findSecurityGroupByName(Constants.GROUP_ANONYMOUS);
      boolean hasBeenAnonymous = secMgr.isIdentityInSecurityGroup(myIdentity, anonymousGroup);
      isAnonymous = form.isAnonymous();
      updateSecurityGroup(myIdentity, secMgr, anonymousGroup, hasBeenAnonymous, isAnonymous);
      // system users - oposite of anonymous users
      SecurityGroup usersGroup = secMgr.findSecurityGroupByName(Constants.GROUP_OLATUSERS);
      boolean hasBeenUser = secMgr.isIdentityInSecurityGroup(myIdentity, usersGroup);
      boolean isUser = !form.isAnonymous();
      updateSecurityGroup(myIdentity, secMgr, usersGroup, hasBeenUser, isUser);
    }
    // 2) system roles
    // group manager
    Boolean canGroupmanagerByConfig = (Boolean) configuration.get(BaseSecurityModule.CONFIG_USERMANAGER_CAN_MANAGE_GROUPMANAGERS)
    if (canGroupmanagerByConfig.booleanValue() || iAmOlatAdmin) {
      SecurityGroup groupManagerGroup = secMgr.findSecurityGroupByName(Constants.GROUP_GROUPMANAGERS);
      boolean hasBeenGroupManager = secMgr.isIdentityInSecurityGroup(myIdentity, groupManagerGroup);
      boolean isGroupManager = form.isGroupmanager();
      updateSecurityGroup(myIdentity, secMgr, groupManagerGroup, hasBeenGroupManager, isGroupManager);
    }
    // author
    Boolean canAuthorByConfig = (Boolean) configuration.get(BaseSecurityModule.CONFIG_USERMANAGER_CAN_MANAGE_AUTHORS)
    if (canAuthorByConfig.booleanValue() || iAmOlatAdmin) {
      SecurityGroup authorGroup = secMgr.findSecurityGroupByName(Constants.GROUP_AUTHORS);
      boolean hasBeenAuthor = secMgr.isIdentityInSecurityGroup(myIdentity, authorGroup);
      boolean isAuthor = form.isAuthor() || form.isInstitutionalResourceManager();
      updateSecurityGroup(myIdentity, secMgr, authorGroup, hasBeenAuthor, isAuthor);
    }
    // user manager, only allowed by admin
    if (iAmOlatAdmin) {
      SecurityGroup userManagerGroup = secMgr.findSecurityGroupByName(Constants.GROUP_USERMANAGERS);
      boolean hasBeenUserManager = secMgr.isIdentityInSecurityGroup(myIdentity, userManagerGroup);
      boolean isUserManager = form.isUsermanager();
      updateSecurityGroup(myIdentity, secMgr, userManagerGroup, hasBeenUserManager, isUserManager);
    }
     // institutional resource manager, only allowed by admin
    if (iAmUserManager || iAmOlatAdmin) {
      SecurityGroup institutionalResourceManagerGroup = secMgr.findSecurityGroupByName(Constants.GROUP_INST_ORES_MANAGER);
      boolean hasBeenInstitutionalResourceManager = secMgr.isIdentityInSecurityGroup(myIdentity, institutionalResourceManagerGroup);
      boolean isInstitutionalResourceManager = form.isInstitutionalResourceManager();
      updateSecurityGroup(myIdentity, secMgr, institutionalResourceManagerGroup, hasBeenInstitutionalResourceManager, isInstitutionalResourceManager);
    }
    // system administrator, only allowed by admin
    if (iAmOlatAdmin) {
      SecurityGroup adminGroup = secMgr.findSecurityGroupByName(Constants.GROUP_ADMIN);
      boolean hasBeenAdmin = secMgr.isIdentityInSecurityGroup(myIdentity, adminGroup);
      boolean isAdmin = form.isAdmin();
      updateSecurityGroup(myIdentity, secMgr, adminGroup, hasBeenAdmin, isAdmin);   
    }
    if (iAmOlatAdmin &&  !myIdentity.getStatus().equals(form.getStatus()) ) {
      secMgr.saveIdentityStatus(myIdentity, form.getStatus());
    }
  }
View Full Code Here


              CourseRights.RIGHT_ASSESSMENT));
          final List<Identity> coachedUsers = new ArrayList<Identity>();
          if (!hasFullAccess) {
            // initialize list of users, only when user has not full access
            List<BusinessGroup> coachedGroups = cgm.getOwnedLearningGroupsFromAllContexts(identity);
            Manager securityManager = ManagerFactory.getManager();
            for (Iterator<BusinessGroup> iter = coachedGroups.iterator(); iter.hasNext();) {
              BusinessGroup group = iter.next();
              coachedUsers.addAll(securityManager.getIdentitiesOfSecurityGroup(group.getPartipiciantGroup()));
            }
          }

          List<IQTESTCourseNode> testNodes = getCourseTestNodes(course);
          Translator translator = Util.createPackageTranslator(AssessmentNotificationsHandler.class, locale);
View Full Code Here

   *
   * @param ureq
   * @return a contact form controller for this group
   */
  private ContactFormController createContactFormController(UserRequest ureq) {
    Manager scrtMngr = ManagerFactory.getManager();

    ContactMessage cmsg = new ContactMessage(ureq.getIdentity());
    // two named ContactLists, the new way using the contact form
    // the same name as in the checkboxes are taken as contactlist names
    ContactList ownerCntctLst;// = new ContactList(translate("sendtochooser.form.chckbx.owners"));
    ContactList partipCntctLst;// = new ContactList(translate("sendtochooser.form.chckbx.partip"));
    ContactList waitingListContactList;// = new ContactList(translate("sendtochooser.form.chckbx.waitingList"));
    if (flags.isEnabled(BGConfigFlags.GROUP_OWNERS)) {
      if (sendToChooserForm.ownerChecked().equals(BusinessGroupSendToChooserForm.NLS_RADIO_ALL)) {
        ownerCntctLst = new ContactList(translate("sendtochooser.form.radio.owners.all"));
        SecurityGroup owners = businessGroup.getOwnerGroup();
        List<Identity> ownerList = scrtMngr.getIdentitiesOfSecurityGroup(owners);
        ownerCntctLst.addAllIdentites(ownerList);
        cmsg.addEmailTo(ownerCntctLst);
      } else {
        if (sendToChooserForm.ownerChecked().equals(BusinessGroupSendToChooserForm.NLS_RADIO_CHOOSE)) {
          ownerCntctLst = new ContactList(translate("sendtochooser.form.radio.owners.choose"));
          SecurityGroup owners = businessGroup.getOwnerGroup();
          List<Identity> ownerList = scrtMngr.getIdentitiesOfSecurityGroup(owners);
          List<Identity> changeableOwnerList = scrtMngr.getIdentitiesOfSecurityGroup(owners);
          for (Identity identity : ownerList) {
            boolean keyIsSelected = false;
            for (Long key : sendToChooserForm.getSelectedOwnerKeys()) {
              if (key.equals(identity.getKey())) {
                keyIsSelected = true;
                break;
              }
            }
            if (!keyIsSelected) {
              changeableOwnerList.remove(changeableOwnerList.indexOf(identity));
            }
          }
          ownerCntctLst.addAllIdentites(changeableOwnerList);
          cmsg.addEmailTo(ownerCntctLst);
        }
      }
    }
    if (sendToChooserForm != null) {
      if  (sendToChooserForm.participantChecked().equals(BusinessGroupSendToChooserForm.NLS_RADIO_ALL)) {
        partipCntctLst  = new ContactList(translate("sendtochooser.form.radio.partip.all"));
        SecurityGroup participants = businessGroup.getPartipiciantGroup();
        List<Identity> participantsList = scrtMngr.getIdentitiesOfSecurityGroup(participants);
        partipCntctLst.addAllIdentites(participantsList);
        cmsg.addEmailTo(partipCntctLst);
      } else {
        if (sendToChooserForm.participantChecked().equals(BusinessGroupSendToChooserForm.NLS_RADIO_CHOOSE)) {
          partipCntctLst  = new ContactList(translate("sendtochooser.form.radio.partip.choose"));
          SecurityGroup participants = businessGroup.getPartipiciantGroup();
          List<Identity> participantsList = scrtMngr.getIdentitiesOfSecurityGroup(participants);
          List<Identity> changeableParticipantsList = scrtMngr.getIdentitiesOfSecurityGroup(participants);
          for (Identity identity : participantsList) {
            boolean keyIsSelected = false;
            for (Long key : sendToChooserForm.getSelectedPartipKeys()) {
              if (key.equals(identity.getKey())) {
                keyIsSelected = true;
                break;
              }
            }
            if (!keyIsSelected) {
              changeableParticipantsList.remove(changeableParticipantsList.indexOf(identity));
            }
          }
          partipCntctLst.addAllIdentites(changeableParticipantsList);
          cmsg.addEmailTo(partipCntctLst);
        }
      }
     
    }
    if (sendToChooserForm != null && isAdmin && businessGroup.getWaitingListEnabled().booleanValue()) {
      if (sendToChooserForm.waitingListChecked().equals(BusinessGroupSendToChooserForm.NLS_RADIO_ALL)) {
        waitingListContactList = new ContactList(translate("sendtochooser.form.radio.waitings.all"));
        SecurityGroup waitingList = businessGroup.getWaitingGroup();
        List<Identity> waitingListIdentities = scrtMngr.getIdentitiesOfSecurityGroup(waitingList);
        waitingListContactList.addAllIdentites(waitingListIdentities);
        cmsg.addEmailTo(waitingListContactList);
      } else {
        if (sendToChooserForm.waitingListChecked().equals(BusinessGroupSendToChooserForm.NLS_RADIO_CHOOSE)) {
          waitingListContactList = new ContactList(translate("sendtochooser.form.radio.waitings.choose"));
          SecurityGroup waitingList = businessGroup.getWaitingGroup();
          List<Identity> waitingListIdentities = scrtMngr.getIdentitiesOfSecurityGroup(waitingList);
          List<Identity> changeableWaitingListIdentities = scrtMngr.getIdentitiesOfSecurityGroup(waitingList);
          for (Identity indentity : waitingListIdentities) {
            boolean keyIsSelected = false;
            for (Long key : sendToChooserForm.getSelectedWaitingKeys()) {
              if (key.equals(indentity.getKey())) {
                keyIsSelected = true;
View Full Code Here

   */
  public BusinessGroupModifiedEvent(String command, BusinessGroup group, Identity identity) {
    super(command);
    this.groupKey = group.getKey();
    this.identityKey = (identity == null ? null : identity.getKey());
    Manager securityManager = ManagerFactory.getManager();
    if (identity != null) {
      if (command.equals(MYSELF_ASOWNER_REMOVED_EVENT)) {
        isTutor = true; // Removed myself as tutor/owner from group
      } else {
        isTutor = securityManager.isIdentityInSecurityGroup(identity, group.getOwnerGroup());
      }
    }
  }
View Full Code Here

    this.course = course;
    this.allIdentities = new ArrayList<Identity>();
    this.notInGroupIdentities = new ArrayList<Identity>();
    this.lstGroups = new ArrayList<BusinessGroup>();
   
    Manager secMgr = ManagerFactory.getManager();
    loadData();
   
   
    cgm = course.getCourseEnvironment().getCourseGroupManager();
    Identity identity = ureq.getIdentity();
    boolean isAdmin = ureq.getUserSession().getRoles().isOLATAdmin() || cgm.isIdentityCourseAdministrator(identity);
    if(cgm.isIdentityCourseAdministrator(identity)) {
      // collect all identities with results
      HashSet<Identity> identitiesWithResult = new HashSet<Identity>();
      for( Checkpoint checkpoint : this.checklist.getCheckpoints() ) {
        for( CheckpointResult result : checkpoint.getResults() ) {
          identitiesWithResult.add(secMgr.loadIdentityByKey(result.getIdentityId()));
        }
      }
     
      // collect all identities in learning groups
      HashSet<Identity> identitiesInGroups = new HashSet<Identity>();
View Full Code Here

   * @param wControl
   * @param identity
   */
  public UserAdminController(UserRequest ureq, WindowControl wControl, Identity identity) {
    super(ureq, wControl);
    Manager mgr = ManagerFactory.getManager();
    if (!mgr.isIdentityPermittedOnResourceable(
        ureq.getIdentity(),
        Constants.PERMISSION_ACCESS,
        OresHelper.lookupType(this.getClass())))
      throw new OLATSecurityException("Insufficient permissions to access UserAdminController");
   
View Full Code Here

  private boolean allowedToManageUser(UserRequest ureq, Identity identity) {
    boolean isOlatAdmin = ureq.getUserSession().getRoles().isOLATAdmin();
    if (isOlatAdmin) return true;

    Map configuration = BaseSecurityModule.getConfiguration();
    Manager secmgr = ManagerFactory.getManager();
    // only admins can administrate admin and usermanager users
    boolean isAdmin = secmgr.isIdentityPermittedOnResourceable(identity, Constants.PERMISSION_HASROLE, Constants.ORESOURCE_ADMIN);
    boolean isUserManager = secmgr.isIdentityPermittedOnResourceable(identity, Constants.PERMISSION_HASROLE, Constants.ORESOURCE_USERMANAGER);
    if (isAdmin || isUserManager) return false;
    // if user is author ony allowed to edit if configured
    boolean isAuthor = secmgr.isIdentityPermittedOnResourceable(identity, Constants.PERMISSION_HASROLE, Constants.ORESOURCE_AUTHOR);
    Boolean canManageAuthor = (Boolean) configuration.get(BaseSecurityModule.CONFIG_USERMANAGER_CAN_MANAGE_AUTHORS);
    if (isAuthor && !canManageAuthor.booleanValue()) return false;
    // if user is groupmanager ony allowed to edit if configured
    boolean isGroupManager = secmgr.isIdentityPermittedOnResourceable(identity, Constants.PERMISSION_HASROLE, Constants.ORESOURCE_GROUPMANAGER);
    Boolean canManageGroupmanager = (Boolean) configuration.get(BaseSecurityModule.CONFIG_USERMANAGER_CAN_MANAGE_GROUPMANAGERS);
    if (isGroupManager && !canManageGroupmanager.booleanValue()) return false;
    // if user is guest ony allowed to edit if configured
    boolean isGuestOnly = secmgr.isIdentityPermittedOnResourceable(identity, Constants.PERMISSION_HASROLE, Constants.ORESOURCE_GUESTONLY);
    Boolean canManageGuest = (Boolean) configuration.get(BaseSecurityModule.CONFIG_USERMANAGER_CAN_MANAGE_GUESTS);
    if (isGuestOnly && !canManageGuest.booleanValue()) return false;
    // passed all tests, current user is allowed to edit given identity
    return true;
  }
View Full Code Here

   * @param ureq
   * @param wControl
   */
  public UserCreateController (UserRequest ureq, WindowControl wControl, boolean canCreateOLATPassword) {
    super(ureq,wControl);
    Manager mgr = ManagerFactory.getManager();
    if (!mgr.isIdentityPermittedOnResourceable(
        ureq.getIdentity(),
        Constants.PERMISSION_ACCESS,
        OresHelper.lookupType(this.getClass())))
      throw new OLATSecurityException("Insufficient permissions to access UserCreateController");
       
View Full Code Here

        int allCourses = repoMgr.countByTypeLimitAccess(CourseModule.ORES_TYPE_COURSE, RepositoryEntry.ACC_OWNERS);
        int publishedCourses = repoMgr.countByTypeLimitAccess(CourseModule.ORES_TYPE_COURSE, RepositoryEntry.ACC_USERS);
        msgProperties.setProperty("courseCountAll", String.valueOf(allCourses));
        msgProperties.setProperty("courseCountPublished", String.valueOf(publishedCourses));
        // User counts
        Manager secMgr = ManagerFactory.getManager();
        SecurityGroup olatuserGroup = secMgr.findSecurityGroupByName(Constants.GROUP_OLATUSERS);
        int users = secMgr.countIdentitiesOfSecurityGroup(olatuserGroup);
        int disabled = secMgr.getIdentitiesByPowerSearch(null, null, true, null, null, null, null, null, Identity.STATUS_LOGIN_DENIED)
            .size();
        msgProperties.setProperty("usersEnabled", String.valueOf(users - disabled));
       
        PermissionOnResourceable[] permissions = { new PermissionOnResourceable(Constants.PERMISSION_HASROLE, Constants.ORESOURCE_AUTHOR) };
        List<Identity> authorsList = secMgr.getIdentitiesByPowerSearch(null, null, true, null, permissions, null, null, null, null);
        int authors = authorsList.size();
        msgProperties.setProperty("usersAuthors", String.valueOf(authors));
        // Activity
        Calendar lastLoginLimit = Calendar.getInstance();
        lastLoginLimit.add(Calendar.DAY_OF_YEAR, -6); // -1 - 6 = -7 for last
                                                      // week
        msgProperties.setProperty("activeUsersLastWeek", String.valueOf(secMgr.countUniqueUserLoginsSince(lastLoginLimit.getTime())));
        lastLoginLimit.add(Calendar.MONTH, -1);
        msgProperties.setProperty("activeUsersLastMonth", String.valueOf(secMgr.countUniqueUserLoginsSince(lastLoginLimit.getTime())));
        // Groups
        BGContextManager groupMgr = BGContextManagerImpl.getInstance();
        int buddyGroups = groupMgr.countGroupsOfType(BusinessGroup.TYPE_BUDDYGROUP);
        msgProperties.setProperty("groupCountBuddyGroups", String.valueOf(buddyGroups));
        int learningGroups = groupMgr.countGroupsOfType(BusinessGroup.TYPE_LEARNINGROUP);
View Full Code Here

  /**
   * @return List of all course participants
   */
  List<Identity> getAllIdentitisFromGroupmanagement() {
    List<Identity> allUsersList = new ArrayList<Identity>();
    Manager secMgr = ManagerFactory.getManager();
    Iterator<BusinessGroup> iter = this.coachedGroups.iterator();
    while (iter.hasNext()) {
      BusinessGroup group = iter.next();
      SecurityGroup secGroup = group.getPartipiciantGroup();
      List<Identity> identities = secMgr.getIdentitiesOfSecurityGroup(secGroup);
      for (Iterator<Identity> identitiyIter = identities.iterator(); identitiyIter.hasNext();) {
        Identity identity = identitiyIter.next();
        if (!PersistenceHelper.listContainsObjectByKey(allUsersList, identity)) {
          // only add if not already in list
          allUsersList.add(identity);
View Full Code Here

TOP

Related Classes of org.olat.basesecurity.Manager

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.