Package org.olat.basesecurity

Examples of org.olat.basesecurity.Manager


   *      boolean)
   */
  public BGContext createAndPersistBGContext(String name, String description, String groupType, Identity owner, boolean defaultContext) {
    if (name == null) throw new AssertException("Business group context name must not be null");
    if (groupType == null) throw new AssertException("Business group groupType name must not be null");
    Manager securityManager = ManagerFactory.getManager();
    // 1) create administrative owner security group, add owner if available
    SecurityGroup ownerGroup = securityManager.createAndPersistSecurityGroup();
    if (owner != null) {
      securityManager.addIdentityToSecurityGroup(owner, ownerGroup);
    }
    // 2) create new group context with this security group and save it
    BGContext bgContext = new BGContextImpl(name, description, ownerGroup, groupType, defaultContext);
    DBFactory.getInstance().saveObject(bgContext);
    // 3) save context owner policy to this context and the owner group
    securityManager.createAndPersistPolicy(ownerGroup, Constants.PERMISSION_ACCESS, bgContext);
    // 4) save groupmanager policy on this group - all members are automatically
    // group managers
    securityManager.createAndPersistPolicy(ownerGroup, Constants.PERMISSION_HASROLE, Constants.ORESOURCE_GROUPMANAGER);
    Tracing.logAudit("Created Business Group Context", bgContext.toString(), this.getClass());
    return bgContext;
  }
View Full Code Here


    // 4) Delete group context
    DBFactory.getInstance().deleteObject(bgContext);
    // 5) Delete security group
    SecurityGroup owners = bgContext.getOwnerGroup();
    if (owners != null) {
      Manager secMgr = ManagerFactory.getManager();
      secMgr.deleteSecurityGroup(owners);
    }
    Tracing.logAudit("Deleted Business Group Context", bgContext.toString(), this.getClass());
  }
View Full Code Here

        probe.reset();
        result.append("\n0\n0\n");
      }
      result.append(instanceId);
    } else if (command.equals("usercount")) { // get number of useraccounts counter
      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();     
      result.append(users-disabled).append("\n"); // number of active users
      result.append(disabled).append("\n"); // number of disabled users
      result.append("0\n");
      result.append(instanceId);
     
    } else if (command.equals("usercountmonthly")) { // get number of different users logged in during last month and last half year
      Manager secMgr = ManagerFactory.getManager();
      Calendar lastLoginLimit = Calendar.getInstance();
      lastLoginLimit.add(Calendar.MONTH, -1);
      result.append(secMgr.countUniqueUserLoginsSince(lastLoginLimit.getTime())).append("\n");
      lastLoginLimit.add(Calendar.MONTH, -5); // -1 -5 = -6 for half a year
      result.append(secMgr.countUniqueUserLoginsSince(lastLoginLimit.getTime())).append("\n");
      result.append("0\n");
      result.append(instanceId);
   
    } else if (command.equals("usercountdaily")) { // get number of different users logged in during last day and last week
      Manager secMgr = ManagerFactory.getManager();
      Calendar lastLoginLimit = Calendar.getInstance();
      lastLoginLimit.add(Calendar.DAY_OF_YEAR, -1);
      result.append(secMgr.countUniqueUserLoginsSince(lastLoginLimit.getTime())).append("\n");
      lastLoginLimit.add(Calendar.DAY_OF_YEAR, -6); // -1 - 6 = -7 for last week
      result.append(secMgr.countUniqueUserLoginsSince(lastLoginLimit.getTime())).append("\n");
      result.append("0\n");
      result.append(instanceId);     
       
    } else if (command.equals("usercountsince")) { // get number of different users logged in since a period which is specified by parameter date
      Manager secMgr = ManagerFactory.getManager();
      String dateParam = request.getParameter("date");
      if (dateParam==null) {
        result.append("date parameter missing. add date=yyyy-MM-dd\n");
      }
      else {
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        try {
          Date mydate = df.parse(dateParam);
          result.append(secMgr.countUniqueUserLoginsSince(mydate)).append("\n");
        } catch (ParseException e) {
          result.append("date parameter format error. expected: yyyy-MM-dd\n");
        }
       
        result.append("0\n0\n");
View Full Code Here

  @Override
  public List<Identity> getNewIdentityCreated(Date from) {
    if(from == null)
      return Collections.emptyList();
   
    Manager manager = ManagerFactory.getManager();
    PermissionOnResourceable[] permissions = {new PermissionOnResourceable(Constants.PERMISSION_HASROLE, Constants.ORESOURCE_GUESTONLY)};
    List<Identity> guests = manager.getIdentitiesByPowerSearch(null, null, true, null, permissions, null, from, null, Identity.STATUS_VISIBLE_LIMIT);
    List<Identity> identities = manager.getIdentitiesByPowerSearch(null, null, true, null, null, null, from, null, Identity.STATUS_VISIBLE_LIMIT);
    if(!identities.isEmpty() && !guests.isEmpty()) {
      identities.removeAll(guests);
    }
   
    for(Iterator<Identity> identityIt=identities.iterator(); identityIt.hasNext(); ) {
View Full Code Here

   * @param RepositoryEntry repositoryEntry
   * @param Identity identity
   */
  public boolean isInstitutionalRessourceManagerFor(RepositoryEntry repositoryEntry, Identity identity) {
    if(repositoryEntry == null || repositoryEntry.getOwnerGroup() == null) return false;
    Manager secMgr = ManagerFactory.getManager();
    // list of owners
    List<Identity> listIdentities = secMgr.getIdentitiesOfSecurityGroup(repositoryEntry.getOwnerGroup());
    String currentUserInstitutionalName = identity.getUser().getProperty("institutionalName", null);
    boolean isInstitutionalResourceManager = ManagerFactory.getManager().isIdentityPermittedOnResourceable(identity, Constants.PERMISSION_HASROLE, Constants.ORESOURCE_INSTORESMANAGER);
    boolean sameInstitutional = false;
    String identInstitutionalName = "";
    for (Identity ident : listIdentities) {
View Full Code Here

   
    int c = 0;
   
    if (userName.getValue().length()>0) {
      c++;
      Manager secMgr = ManagerFactory.getManager();
      identity = secMgr.findIdentityByName(userName.getValue());
       if (identity == null){
             userName.setErrorKey ("error.search.form.nousername", null);
             return false;
       }
    }
View Full Code Here

      log.info("LDAP login is disabled");
      return;
    }
    // Create LDAP Security Group if not existing. Used to identify users that
    // have to be synced with LDAP
    Manager scrManager = ManagerFactory.getManager();
    LDAPLoginManager ldapManager = LDAPLoginManager.getInstance();
    SecurityGroup ldapGroup = scrManager.findSecurityGroupByName(LDAPConstants.SECURITY_GROUP_LDAP);
    if (ldapGroup == null) {
      ldapGroup = scrManager.createAndPersistNamedSecurityGroup(LDAPConstants.SECURITY_GROUP_LDAP);
    }
    // check for valid configuration
    if (!checkConfigParameterIsNotEmpty(ldapUrl)) return;
    if (!checkConfigParameterIsNotEmpty(systemDN)) return;
    if (!checkConfigParameterIsNotEmpty(systemPW)) return;
View Full Code Here

    tblCtr.addColumnDescriptor(new DefaultColumnDescriptor("table.user.role", 2, null, ureq.getLocale()));
    tblCtr.addColumnDescriptor(new DefaultColumnDescriptor("table.user.joindate", 3, null, ureq.getLocale()));
       
    //build data model
    BusinessGroupManager bgm = BusinessGroupManagerImpl.getInstance();
    Manager sm = ManagerFactory.getManager();
    List<Object[]> userGroups = new ArrayList<Object[]>();
      //loop over all kind of groups with all possible memberships
      List<String> bgTypes = new ArrayList<String>();
      bgTypes.add(BusinessGroup.TYPE_BUDDYGROUP);
      bgTypes.add(BusinessGroup.TYPE_LEARNINGROUP);
      bgTypes.add(BusinessGroup.TYPE_RIGHTGROUP);
      for (String bgType : bgTypes) {       
        List<BusinessGroup> ownedGroups = bgm.findBusinessGroupsOwnedBy(bgType, identity, null);
        List<BusinessGroup> attendedGroups = bgm.findBusinessGroupsAttendedBy(bgType, identity, null);
        List<BusinessGroup> waitingGroups = bgm.findBusinessGroupsWithWaitingListAttendedBy(bgType, identity, null);
        //using HashSet to remove duplicate entries
        HashSet<BusinessGroup> allGroups = new HashSet<BusinessGroup>();
        allGroups.addAll(ownedGroups);
        allGroups.addAll(attendedGroups);
        allGroups.addAll(waitingGroups);
       
        Iterator<BusinessGroup> iter = allGroups.iterator();
        while (iter.hasNext()) {
          Object[] groupEntry = new Object[4];
          BusinessGroup group = iter.next();
          groupEntry[0] = translate(group.getType());
          groupEntry[1] = group;
          Date joinDate = null;
          if(attendedGroups.contains(group)&&ownedGroups.contains(group)) {
            groupEntry[2] = translate("attende.and.owner");
            joinDate = sm.getSecurityGroupJoinDateForIdentity(group.getPartipiciantGroup(), identity);
          }
          else if(attendedGroups.contains(group)) {
            groupEntry[2] = translate("attende");
            joinDate = sm.getSecurityGroupJoinDateForIdentity(group.getPartipiciantGroup(), identity);
          }
          else if(ownedGroups.contains(group)) {
            groupEntry[2] = translate("owner");
            joinDate = sm.getSecurityGroupJoinDateForIdentity(group.getOwnerGroup(), identity);
          }
          else if(waitingGroups.contains(group)) {
            int waitingListPosition = bgm.getPositionInWaitingListFor(identity, group);
            groupEntry[2] = translate("waiting", String.valueOf(waitingListPosition));
            joinDate = sm.getSecurityGroupJoinDateForIdentity(group.getWaitingGroup(), identity);
          }
          groupEntry[3] = joinDate;
         
          userGroups.add(groupEntry);
          }     
View Full Code Here

          ldapManager.syncUser(olatProToSync, identity);
        }
      }
      // Add or update an OLAT authentication token for this user if configured in the module
      if (identity != null && LDAPLoginModule.isCacheLDAPPwdAsOLATPwdOnLogin()) {
        Manager secMgr = ManagerFactory.getManager();
        Authentication auth = secMgr.findAuthentication(identity, OLATAuthenticationController.PROVIDER_OLAT);
        if (auth == null) {
          // Reuse exising authentication token
          secMgr.createAndPersistAuthentication(identity, OLATAuthenticationController.PROVIDER_OLAT, username, Encoder.encrypt(pwd));
        } else {
          // Create new authenticaten token
          auth.setCredential(Encoder.encrypt(pwd));
          DBFactory.getInstance().updateObject(auth);
        }       
View Full Code Here

   * Delete all Identities in List and removes them from LDAPSecurityGroup
   *
   * @param identityList List of Identities to delete
   */
  public void deletIdentities(List<Identity> identityList) {
    Manager securityManager = ManagerFactory.getManager();
    Identity identity;
    UserDeletionManager deletionManager = UserDeletionManager.getInstance();
    SecurityGroup secGroup = securityManager.findSecurityGroupByName(LDAPConstants.SECURITY_GROUP_LDAP);
    for (Iterator<Identity> itr = identityList.iterator(); itr.hasNext();) {
      identity = itr.next();
      securityManager.removeIdentityFromSecurityGroup(identity, secGroup);
      deletionManager.deleteIdentity(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.