Package org.olat.basesecurity

Examples of org.olat.basesecurity.Manager


     * groups...................................................... [3] create 2
     * policies, ownerGroup -> PERMISSION_ACCESS -> buddygroup.
     * ....partipiciantGroup -> PERMISSION_READ -> buddygroup ..............
     */
    BusinessGroupImpl businessgroup = null;
    Manager securityManager = ManagerFactory.getManager();
    // groups
    SecurityGroup ownerGroup = securityManager.createAndPersistSecurityGroup();
    SecurityGroup partipiciantGroup = securityManager.createAndPersistSecurityGroup();

    businessgroup = new BusinessGroupImpl(BusinessGroup.TYPE_BUDDYGROUP, name, description, ownerGroup, partipiciantGroup,null/* no waitingGroup*/, null);
    businessgroup.setMinParticipants(minParticipants);
    businessgroup.setMaxParticipants(maxParticipants);

    DBFactory.getInstance().saveObject(businessgroup);
    if(Tracing.isDebugEnabled(BusinessGroupFactory.class)){
      Tracing.logDebug("created Buddy Group named " + name + " for Identity " + identity, BusinessGroupFactory.class);
    }
    /*
     * policies: - ownerGroup can do everything on this businessgroup -> is an
     * admin, can invite people to owner.- & partipiciantgroup -
     * partipiciantGroup can read this businessgroup
     */
    OLATResource businessgroupOlatResource =  OLATResourceManager.getInstance().createOLATResourceInstance(businessgroup);
    OLATResourceManager.getInstance().saveOLATResource(businessgroupOlatResource);

    //    securityManager.createAndPersistPolicy(ownerGroup, Constants.PERMISSION_ACCESS, businessgroup);
    securityManager.createAndPersistPolicyWithResource(ownerGroup, Constants.PERMISSION_ACCESS, businessgroupOlatResource);
    securityManager.createAndPersistPolicyWithResource(partipiciantGroup, Constants.PERMISSION_READ, businessgroupOlatResource);
    // membership: add identity
    securityManager.addIdentityToSecurityGroup(identity, ownerGroup);

    // per default all collaboration-tools are disabled

    // group members visibility
    BusinessGroupPropertyManager bgpm = new BusinessGroupPropertyManager(businessgroup);
View Full Code Here


     * security groups...................................................... [3]
     * create 2 policies, ownerGroup -> PERMISSION_ACCESS ....partipiciantGroup ->
     * PERMISSION_READ
     */
    BusinessGroupImpl businessgroup = null;
    Manager securityManager = ManagerFactory.getManager();

    // check if group does already exist in this learning context
    boolean groupExists = testIfGroupAlreadyExists(name, BusinessGroup.TYPE_LEARNINGROUP, groupContext);
    if (groupExists) {
      // there is already a group with this name, return without
      // creating a new group
      Tracing.logWarn("A group with this name already exists! You will get null instead of a businessGroup returned!", BusinessGroupFactory.class);
      return null;
    }
    Codepoint.codepoint(BusinessGroupFactory.class, "createAndPersistLearningGroup");
    // groups
    SecurityGroup ownerGroup = securityManager.createAndPersistSecurityGroup();
    SecurityGroup partipiciantGroup = securityManager.createAndPersistSecurityGroup();
    SecurityGroup waitingGroup = securityManager.createAndPersistSecurityGroup();
    //
    businessgroup = new BusinessGroupImpl(BusinessGroup.TYPE_LEARNINGROUP, name, description, ownerGroup, partipiciantGroup, waitingGroup, groupContext);
    businessgroup.setMinParticipants(minParticipants);
    businessgroup.setMaxParticipants(maxParticipants);
    businessgroup.setWaitingListEnabled(waitingListEnabled);
    businessgroup.setAutoCloseRanksEnabled(autoCloseRanksEnabled);
   
    DBFactory.getInstance().saveObject(businessgroup);
    if(Tracing.isDebugEnabled(BusinessGroupFactory.class)){
      Tracing.logDebug("created Learning Group named " + name, BusinessGroupFactory.class);
    }
    /*
     * policies: - ownerGroup can do everything on this businessgroup -> is an
     * admin, can invite people to owner.- & partipiciantgroup -
     * partipiciantGroup can read this businessgroup
     */
    OLATResource businessgroupOlatResource = OLATResourceManager.getInstance().createOLATResourceInstance(businessgroup);
    OLATResourceManager.getInstance().saveOLATResource(businessgroupOlatResource);
    OLATResource groupContextOlatResource = OLATResourceManager.getInstance().findResourceable(groupContext);
    if (groupContextOlatResource == null) {
      OLATResourceManager.getInstance().createOLATResourceInstance(groupContext);
      OLATResourceManager.getInstance().saveOLATResource(groupContextOlatResource);
    }
    securityManager.createAndPersistPolicyWithResource(ownerGroup, Constants.PERMISSION_ACCESS, businessgroupOlatResource);
    securityManager.createAndPersistPolicyWithResource(ownerGroup, Constants.PERMISSION_COACH, groupContextOlatResource);
    securityManager.createAndPersistPolicyWithResource(partipiciantGroup, Constants.PERMISSION_READ, businessgroupOlatResource);
    securityManager.createAndPersistPolicyWithResource(partipiciantGroup, Constants.PERMISSION_PARTI, groupContextOlatResource);
    // membership: add identity if available
    if (identity != null) {
      securityManager.addIdentityToSecurityGroup(identity, ownerGroup);
    }

    // per default all collaboration-tools are disabled

    // group members visibility
View Full Code Here

     * learningGroup with name, description, introMsg and the security
     * group...................................................... [3] create 2
     * policies, partipiciantGroup -> PERMISSION_READ
     */
    BusinessGroupImpl businessgroup = null;
    Manager securityManager = ManagerFactory.getManager();

    // check if group does already exist in this learning context
    boolean groupExists = testIfGroupAlreadyExists(name, BusinessGroup.TYPE_RIGHTGROUP, groupContext);
    if (groupExists) {
      // there is already a group with this name, return without
      // creating a new group
      return null;
    }

    // group
    SecurityGroup partipiciantGroup = securityManager.createAndPersistSecurityGroup();
    //
    businessgroup = new BusinessGroupImpl(BusinessGroup.TYPE_RIGHTGROUP, name, description, null, partipiciantGroup,null/* no waitingGroup */, groupContext);
    businessgroup.setMinParticipants(minParticipants);
    businessgroup.setMaxParticipants(maxParticipants);
    //
    DBFactory.getInstance().saveObject(businessgroup);
    if(Tracing.isDebugEnabled(BusinessGroupFactory.class)){
      Tracing.logDebug("Created Right Group named " + name, BusinessGroupFactory.class);
    }
    /*
     * policies: - partipiciantGroup can read this businessgroup
     */
    OLATResource businessgroupOlatResource = OLATResourceManager.getInstance().createOLATResourceInstance(businessgroup);
    OLATResourceManager.getInstance().saveOLATResource(businessgroupOlatResource);
    securityManager.createAndPersistPolicyWithResource(partipiciantGroup, Constants.PERMISSION_READ, businessgroupOlatResource);
    // membership: add identity if available
    if (identity != null) {
      securityManager.addIdentityToSecurityGroup(identity, partipiciantGroup);
    }

    // per default all collaboration-tools are disabled

    // group members visibility
View Full Code Here

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

View Full Code Here

  /** rights tests */
  public void testHasRightIsInMethods() {
      BGContextManager cm = BGContextManagerImpl.getInstance();
      BusinessGroupManager bgm = BusinessGroupManagerImpl.getInstance();
      Manager secm = ManagerFactory.getManager();
      BGRightManager rm = BGRightManagerImpl.getInstance();
      BGAreaManager am = BGAreaManagerImpl.getInstance();
     
      // 1) context one: learning groups
      BGContext c1 = cm.createAndAddBGContextToResource("c1name", course1, BusinessGroup.TYPE_LEARNINGROUP, id1, true);
      // create groups without waitinglist
      BusinessGroup g1 = bgm.createAndPersistBusinessGroup(BusinessGroup.TYPE_LEARNINGROUP, null, "g1", null, new Integer(0), new Integer(10), false, false, c1);
      BusinessGroup g2 = bgm.createAndPersistBusinessGroup(BusinessGroup.TYPE_LEARNINGROUP, null, "g2", null, new Integer(0), new Integer(10), false, false, c1);
      // members
      secm.addIdentityToSecurityGroup(id1, g2.getOwnerGroup());
      secm.addIdentityToSecurityGroup(id1, g1.getPartipiciantGroup());
      secm.addIdentityToSecurityGroup(id2, g1.getPartipiciantGroup());
      secm.addIdentityToSecurityGroup(id2, g2.getPartipiciantGroup());
      secm.addIdentityToSecurityGroup(id3, g1.getOwnerGroup());
      // areas
      BGArea a1 = am.createAndPersistBGAreaIfNotExists("a1", "desca1",c1);
      BGArea a2 = am.createAndPersistBGAreaIfNotExists("a2", null, c1);
      BGArea a3 = am.createAndPersistBGAreaIfNotExists("a3", null, c1);
      am.addBGToBGArea(g1, a1);   
      am.addBGToBGArea(g2, a1);
      am.addBGToBGArea(g1, a2)
      am.addBGToBGArea(g2, a3);
     
      // 2) context two: right groups
      BGContext c2 = cm.createAndAddBGContextToResource("c2name", course1, BusinessGroup.TYPE_RIGHTGROUP, id2, true);
      // groups
      BusinessGroup g3 = bgm.createAndPersistBusinessGroup(BusinessGroup.TYPE_RIGHTGROUP, null, "g3", null, null, null, null/* enableWaitinglist */, null/* enableAutoCloseRanks */, c2);
      BusinessGroup g4 = bgm.createAndPersistBusinessGroup(BusinessGroup.TYPE_RIGHTGROUP, null, "g4", null, null, null, null/* enableWaitinglist */, null/* enableAutoCloseRanks */, c2);
      // members
      secm.addIdentityToSecurityGroup(id1, g3.getPartipiciantGroup());
      secm.addIdentityToSecurityGroup(id1, g4.getPartipiciantGroup());
      secm.addIdentityToSecurityGroup(id3, g4.getPartipiciantGroup());
      // rights
      rm.addBGRight(CourseRights.RIGHT_ARCHIVING, g3);
      rm.addBGRight(CourseRights.RIGHT_COURSEEDITOR, g3);
      rm.addBGRight(CourseRights.RIGHT_ARCHIVING, g4);
      rm.addBGRight(CourseRights.RIGHT_GROUPMANAGEMENT, g4);
View Full Code Here

    this.showEmailButton = showEmailButton;

    userListVC.contextPut("showBackButton", Boolean.FALSE);
    userListVC.contextPut("showTitle", Boolean.TRUE);

    Manager secMgr = ManagerFactory.getManager();
    identitiesList = secMgr.getIdentitiesByPowerSearch(null, null, true, searchGroups, searchPermissionOnResources, searchAuthProviders,
        searchCreatedAfter, searchCreatedBefore, status);

    initUserListCtr(ureq, identitiesList, status);
    userListVC.put("userlist", tableCtr.getInitialComponent());
    userListVC.contextPut("emptyList", (identitiesList.size() == 0 ? Boolean.TRUE : Boolean.FALSE));
View Full Code Here

   *
   * @param ureq
   */
  private void doBuddyGroupDelete(UserRequest ureq) {
    // 1) send notification mails to users
    Manager securityManager = ManagerFactory.getManager();
    ContactList owners = new ContactList(translate("userlist.owners.title"));
    List ow = securityManager.getIdentitiesOfSecurityGroup(currBusinessGroup.getOwnerGroup());
    owners.addAllIdentites(ow);
    ContactList participants = new ContactList(translate("userlist.participants.title"));
    participants.addAllIdentites(securityManager.getIdentitiesOfSecurityGroup(currBusinessGroup.getPartipiciantGroup()));
    // check if user is in owner group (could fake link in table)
    if (!PersistenceHelper.listContainsObjectByKey(ow, ureq.getIdentity())) {
      Tracing.logWarn("User tried to delete a group but he was not owner of the group", null, BGMainController.class);
      return;
    }
View Full Code Here

  /**
   * @return List of identities that match the criterias from the search form
   */
  private List<Identity> findIdentitiesFromSearchForm() {
    Manager secMgr = ManagerFactory.getManager();
    // get user attributes from form
    String login = searchform.getTextElement("login").getValue();
    Integer status = null;

    // get user fields from form
    // build user fields search map
    Map<String, String> userPropertiesSearch = new HashMap<String, String>();
    for (UserPropertyHandler userPropertyHandler : searchform.userPropertyHandlers) {
      if (userPropertyHandler == null) continue;
      FormElement ui = searchform.getFormElement(userPropertyHandler.getName());
      String uiValue = userPropertyHandler.getStringValue(ui);
      if (StringHelper.containsNonWhitespace(uiValue)) {
        userPropertiesSearch.put(userPropertyHandler.getName(), uiValue);
      }
    }
    if (userPropertiesSearch.isEmpty()) userPropertiesSearch = null;

    // get group memberships from form
    List<SecurityGroup> groupsList = new ArrayList<SecurityGroup>();
    if (searchform.getCheckBoxElement("admin") != null && searchform.getCheckBoxElement("admin").isChecked()) {
      SecurityGroup group = secMgr.findSecurityGroupByName(org.olat.basesecurity.Constants.GROUP_ADMIN);
      groupsList.add(group);
    }
    if (searchform.getCheckBoxElement("author") != null && searchform.getCheckBoxElement("author").isChecked()) {
      SecurityGroup group = secMgr.findSecurityGroupByName(org.olat.basesecurity.Constants.GROUP_AUTHORS);
      groupsList.add(group);
    }
    if (searchform.getCheckBoxElement("groupmanager") != null && searchform.getCheckBoxElement("groupmanager").isChecked()) {
      SecurityGroup group = secMgr.findSecurityGroupByName(org.olat.basesecurity.Constants.GROUP_GROUPMANAGERS);
      groupsList.add(group);
    }
    if (searchform.getCheckBoxElement("usermanager") != null && searchform.getCheckBoxElement("usermanager").isChecked()) {
      SecurityGroup group = secMgr.findSecurityGroupByName(org.olat.basesecurity.Constants.GROUP_USERMANAGERS);
      groupsList.add(group);
    }
    if (searchform.getCheckBoxElement("oresmanager") != null && searchform.getCheckBoxElement("oresmanager").isChecked()) {
      SecurityGroup group = secMgr.findSecurityGroupByName(org.olat.basesecurity.Constants.GROUP_INST_ORES_MANAGER);
      groupsList.add(group);
    }
    if (searchform.getSingleSelectionElement("status") != null) {
      status = new Integer(searchform.getSingleSelectionElement("status").getSelectedKey());
    }
    SecurityGroup[] groups = groupsList.toArray(new SecurityGroup[groupsList.size()]);

    // no permissions in this form so far
    PermissionOnResourceable[] permissionOnResources = null;

    // get selected authentication providers from list
    List<String> authProvidersList = new ArrayList<String>();
    // get all authentication provider from configuration
    Collection providers = LoginModule.getAuthenticationProviders();
    Iterator iter = providers.iterator();
    while (iter.hasNext()) {
      AuthenticationProvider provider = (AuthenticationProvider) iter.next();
      if (provider.isEnabled()) {
        String providerName = provider.getName();
        CheckBoxElement authElem = searchform.getCheckBoxElement("auth." + providerName);
        if (authElem != null && authElem.isChecked()) {
          authProvidersList.add(providerName);
        }
      }
    }
   
    if(WebDAVManager.getInstance().isEnabled()) {
      CheckBoxElement authElem = searchform.getCheckBoxElement("auth." + WebDAVAuthManager.PROVIDER_WEBDAV);
      if (authElem != null && authElem.isChecked()) {
        authProvidersList.add(WebDAVAuthManager.PROVIDER_WEBDAV);
      }
    }
   
    // add null provider as special case
    if (searchform.getCheckBoxElement("admin") != null && searchform.getCheckBoxElement("noAuth").isChecked()) {
      authProvidersList.add(null);
    }
    String[] authProviders = (String[]) authProvidersList.toArray(new String[authProvidersList.size()]);

    // get date constraints from form
    Date createdBefore = searchform.getDateElement("beforeDate").getDate();
    Date createdAfter = searchform.getDateElement("afterDate").getDate();

    // now perform power search
    List<Identity> myIdentities = secMgr.getIdentitiesByPowerSearch((login.equals("") ? null : login), userPropertiesSearch, true, groups,
        permissionOnResources, authProviders, createdAfter, createdBefore, status);

    return myIdentities;
  }
View Full Code Here

   * no other owner are found the user won't be removed from the owner group
   *
   * @param ureq
   */
  private void doBuddyGroupLeave(UserRequest ureq) {
    Manager securityManager = ManagerFactory.getManager();
    BGConfigFlags flags = BGConfigFlags.createBuddyGroupDefaultFlags();
    // 1) remove as owner
    SecurityGroup owners = currBusinessGroup.getOwnerGroup();
    if (securityManager.isIdentityInSecurityGroup(identity, owners)) {
      List ownerList = securityManager.getIdentitiesOfSecurityGroup(owners);
      if (ownerList.size() > 1) {
        bgm.removeOwnerAndFireEvent(ureq.getIdentity(), ureq.getIdentity(), currBusinessGroup, flags, false);
        // update model
        updateGroupListModelAll();
      } else {
View Full Code Here

   *
   * @param ureq
   */
  private void reloadDataModel(UserRequest ureq) {
    if (identitiesList == null) return;
    Manager secMgr = ManagerFactory.getManager();
    for (int i = 0; i < identitiesList.size(); i++) {
      Identity ident = identitiesList.get(i);
      Identity refrshed = secMgr.loadIdentityByKey(ident.getKey());
      identitiesList.set(i, refrshed);
    }
    initUserListCtr(ureq, identitiesList, null);
    userListVC.put("userlist", tableCtr.getInitialComponent());
  }
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.