Package org.olat.basesecurity

Examples of org.olat.basesecurity.Manager


        backLinkFin = LinkFactory.createLinkBack(finishedVC, this);
       
        GenericObjectArrayTableDataModel sepValFinModel = new GenericObjectArrayTableDataModel(rowsFourthStep, numOfLines);
         
        UserManager um = UserManager.getInstance();
        Manager secMgr = ManagerFactory.getManager();
       
        BulkActionModule bam = new BulkActionModule();
        BulkAction ba = (BulkAction) bulkActions.get(bulk);
        List identities = new ArrayList(sepValFinModel.getRowCount());
       
        // read values from the column which the user has defined as olat key (e.g. username)
        // and add them to a list.
        for(int i = 0; i < sepValFinModel.getRowCount(); i ++ ){
          String val = (String) sepValFinModel.getValueAt(i, selectedColForOlatKey);
          val = val.trim();
          Identity identity = null;

          if (selectedOlatKey == 0) { // matrikelnumber
            Map<String, String> searchValue = new HashMap<String, String>();
            searchValue.put(UserConstants.INSTITUTIONALUSERIDENTIFIER, val);
            List identitiesFoundByInst = ManagerFactory.getManager().getIdentitiesByPowerSearch(null, searchValue, true, null, null, null, null, null, null);
            //FIXME:as:b error handling if there is more than one identity found by institutionalUserIdentifier
            // see also in BulkAssessmentWizardController
            if (identitiesFoundByInst.size() == 1){
              identity = (Identity) identitiesFoundByInst.get(0);
            }
          }else if (selectedOlatKey == 1){ // username
              identity = secMgr.findIdentityByName(val);
          }else if (selectedOlatKey == 2) { // email
            identity = um.findIdentityByEmail(val);
          }
          identities.add(identity);
        }
View Full Code Here


    List<Identity> changedIdentities = new ArrayList<Identity>();
    List<UserPropertyHandler> userPropertyHandlers = UserManager.getInstance().getUserPropertyHandlersFor(usageIdentifyer,
        isAdministrativeUser);
    String[] securityGroups = { Constants.GROUP_USERMANAGERS, Constants.GROUP_GROUPMANAGERS, Constants.GROUP_AUTHORS, Constants.GROUP_ADMIN };
    UserManager um = UserManager.getInstance();
    Manager secMgr = ManagerFactory.getManager();


    // loop over users to be edited:
    for (Identity identity : selIdentities) {
      DB db = DBFactory.getInstance();
      //reload identity from cache, to prevent stale object
      identity = (Identity) db.loadObject(identity);
      User user = identity.getUser();
      String errorDesc = "";
      boolean updateError = false;
      // change pwd
      if (attributeChangeMap.containsKey(PWD_IDENTIFYER)) {
        String newPwd = attributeChangeMap.get(PWD_IDENTIFYER);
        if (StringHelper.containsNonWhitespace(newPwd)) {
          if (!UserManager.getInstance().syntaxCheckOlatPassword(newPwd)) {
            errorDesc = transWithFallback.translate("error.password");
            updateError = true;
          }
        } else newPwd = null;
        OLATAuthManager.changePasswordAsAdmin(identity, newPwd);
      }

      // set language
      String userLanguage = user.getPreferences().getLanguage();
      if (attributeChangeMap.containsKey(LANG_IDENTIFYER)) {
        String inputLanguage = attributeChangeMap.get(LANG_IDENTIFYER);
        if (!userLanguage.equals(inputLanguage)) {
          Preferences preferences = user.getPreferences();
          preferences.setLanguage(inputLanguage);
          user.setPreferences(preferences);
        }
      }

      Context vcContext = new VelocityContext();
      // set all properties as context
      setUserContext(identity, vcContext, isAdministrativeUser);
      // loop for each property configured in
      // src/serviceconfig/org/olat/_spring/olat_userconfig.xml -> Key:
      // org.olat.admin.user.bulkChange.UserBulkChangeStep00
      for (int k = 0; k < userPropertyHandlers.size(); k++) {
        UserPropertyHandler propHandler = userPropertyHandlers.get(k);
        String propertyName = propHandler.getName();
        String userValue = identity.getUser().getProperty(propertyName, null);
        String inputFieldValue = "";
        if (attributeChangeMap.containsKey(propertyName)) {
          inputFieldValue = attributeChangeMap.get(propertyName);
          inputFieldValue = inputFieldValue.replace("$", "$!");
          String evaluatedInputFieldValue = evaluateValueWithUserContext(inputFieldValue, vcContext)
         
          // validate evaluated property-value
          ValidationError validationError = new ValidationError();
          // do validation checks with users current locale!
          Locale locale = transWithFallback.getLocale();
          if (!propHandler.isValidValue(evaluatedInputFieldValue, validationError, locale)) {
            errorDesc = transWithFallback.translate(validationError.getErrorKey()) + " (" + evaluatedInputFieldValue + ")";
            updateError = true;
            break;
          }

          if (!evaluatedInputFieldValue.equals(userValue)) {
            String stringValue = propHandler.getStringValue(evaluatedInputFieldValue, locale);
              propHandler.setUserProperty(user, stringValue);
          }
        }

      } // for (propertyHandlers)

      // set roles for identity
      // loop over securityGroups defined above
      for (String securityGroup : securityGroups) {
        SecurityGroup secGroup = secMgr.findSecurityGroupByName(securityGroup);
        Boolean isInGroup = secMgr.isIdentityInSecurityGroup(identity, secGroup);
        String thisRoleAction = "";
        if (roleChangeMap.containsKey(securityGroup)) {
          thisRoleAction = roleChangeMap.get(securityGroup);
          // user not anymore in security group, remove him
          if (isInGroup && thisRoleAction.equals("remove")) secMgr.removeIdentityFromSecurityGroup(identity, secGroup);
          // user not yet in security group, add him
          if (!isInGroup && thisRoleAction.equals("add")) secMgr.addIdentityToSecurityGroup(identity, secGroup);
        }
      }
     
      // set status
      if (roleChangeMap.containsKey("Status")) {
        Integer status = Integer.parseInt(roleChangeMap.get("Status"));
        secMgr.saveIdentityStatus(identity, status);
        identity = (Identity) db.loadObject(identity);
      }

      // persist changes:
      if (updateError) {
View Full Code Here

  public void event(UserRequest ureq, Controller source, Event event) {
    if (source == mailNotificationCtr && event == Event.DONE_EVENT) {
      if (mailNotificationCtr.getMailTemplate() != null) {
        List<Identity> ownerList = new ArrayList<Identity>();
        // owners
        Manager securityManager = ManagerFactory.getManager();
        SecurityGroup owners = repositoryEntry.getOwnerGroup();
        if (securityManager.isIdentityInSecurityGroup(ureq.getIdentity(), owners)) {
          ownerList = securityManager.getIdentitiesOfSecurityGroup(owners);
        }
        List<Identity> ccIdentities = new ArrayList<Identity>();
        if (mailNotificationCtr.getMailTemplate().getCpfrom()) {
          ccIdentities.add(ureq.getIdentity());
        } else {
View Full Code Here

   * @param wControl
   */
  public SysinfoController(UserRequest ureq, WindowControl wControl) {
    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 SysinfoController");

View Full Code Here

   */
  public void addBGRight(String bgRight, BusinessGroup rightGroup) {
    if (bgRight.indexOf(BG_RIGHT_PREFIX) == -1) throw new AssertException("Groups rights must start with prefix '" + BG_RIGHT_PREFIX
        + "', but given right is ::" + bgRight);
    if (BusinessGroup.TYPE_RIGHTGROUP.equals(rightGroup.getType())) {
      Manager secm = ManagerFactory.getManager();
      BGContext context = rightGroup.getGroupContext();
      secm.createAndPersistPolicy(rightGroup.getPartipiciantGroup(), bgRight, context);
    } else {
      throw new AssertException("Only right groups can have bg rights, but type was ::" + rightGroup.getType());
    }
  }
View Full Code Here

      activatePaneInDetailView = "edit.uroles";
      // special case: use user search controller and search for all users that have author rights
      PermissionOnResourceable[] permissions = {new PermissionOnResourceable(Constants.PERMISSION_HASROLE, Constants.ORESOURCE_AUTHOR)};
      UsermanagerUserSearchController myCtr = new UsermanagerUserSearchController(ureq, getWindowControl(),null, permissions, null, null, null, Identity.STATUS_VISIBLE_LIMIT, true);
      // now subtract users that are in the author group to get the co-authors
      Manager secMgr = ManagerFactory.getManager();
      SecurityGroup[] secGroup = {ManagerFactory.getManager().findSecurityGroupByName(Constants.GROUP_AUTHORS)};
      List identitiesFromAuthorGroup = secMgr.getVisibleIdentitiesByPowerSearch(null, null, true, secGroup , null, null, null, null);
      myCtr.removeIdentitiesFromSearchResult(ureq, identitiesFromAuthorGroup);
      contentCtr = myCtr;
      listenTo(contentCtr);
      return contentCtr.getInitialComponent();
    }
View Full Code Here

   * @see org.olat.group.right.BGRightManager#removeBGRight(java.lang.String,
   *      org.olat.group.BusinessGroup)
   */
  public void removeBGRight(String bgRight, BusinessGroup rightGroup) {
    if (BusinessGroup.TYPE_RIGHTGROUP.equals(rightGroup.getType())) {
      Manager secm = ManagerFactory.getManager();
      BGContext context = rightGroup.getGroupContext();
      secm.deletePolicy(rightGroup.getPartipiciantGroup(), bgRight, context);
    } else {
      throw new AssertException("Only right groups can have bg rights, but type was ::" + rightGroup.getType());
    }
  }
View Full Code Here

   * @see org.olat.group.right.BGRightManager#hasBGRight(java.lang.String,
   *      org.olat.core.id.Identity, org.olat.group.context.BGContext)
   */
  public boolean hasBGRight(String bgRight, Identity identity, BGContext bgContext) {
    if (BusinessGroup.TYPE_RIGHTGROUP.equals(bgContext.getGroupType())) {
      Manager secm = ManagerFactory.getManager();
      return secm.isIdentityPermittedOnResourceable(identity, bgRight, bgContext);
    }
    throw new AssertException("Only right groups can have bg rights, but type was ::" + bgContext.getGroupType());
  }
View Full Code Here

  /**
   * @see org.olat.group.right.BGRightManager#findBGRights(org.olat.group.BusinessGroup)
   */
  public List findBGRights(BusinessGroup rightGroup) {
    Manager secm = ManagerFactory.getManager();
    List results = secm.getPoliciesOfSecurityGroup(rightGroup.getPartipiciantGroup());
    // filter all business group rights permissions. group right permissions
    // start with bgr.
    List rights = new ArrayList();
    for (int i = 0; i < results.size(); i++) {
      Policy rightPolicy = (Policy) results.get(i);
View Full Code Here

  public void deleteBusinessGroupWithMail(BusinessGroup businessGroupTodelete, WindowControl wControl, UserRequest ureq, Translator trans,
      List contactLists) {
    Codepoint.codepoint(this.getClass(), "deleteBusinessGroupWithMail");
   
    // collect data for mail
    Manager secMgr = ManagerFactory.getManager();
    List users = new ArrayList();
    SecurityGroup ownerGroup = businessGroupTodelete.getOwnerGroup();
    if (ownerGroup != null) {
      List owner = secMgr.getIdentitiesOfSecurityGroup(ownerGroup);
      users.addAll(owner);
    }
    SecurityGroup partGroup = businessGroupTodelete.getPartipiciantGroup();
    if (partGroup != null) {
      List participants = secMgr.getIdentitiesOfSecurityGroup(partGroup);
      users.addAll(participants);
    }
    SecurityGroup watiGroup = businessGroupTodelete.getWaitingGroup();
    if (watiGroup != null) {
      List waiting = secMgr.getIdentitiesOfSecurityGroup(watiGroup);
      users.addAll(waiting);
    }
    // now delete the group first
    deleteBusinessGroup(businessGroupTodelete);
    // finally send email
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.