Package org.olat.basesecurity

Examples of org.olat.basesecurity.Manager


   * Create an identity with admin permissions
   * @param login
   * @return
   */
  public static final Identity createAndPersistIdentityAsAdmin(String login) {
    Manager securityManager = ManagerFactory.getManager();
    SecurityGroup group = securityManager.findSecurityGroupByName(Constants.GROUP_ADMIN);
    if (group == null) group = securityManager.createAndPersistNamedSecurityGroup(Constants.GROUP_ADMIN);
    User user = UserManager.getInstance().createUser("first" + login, "last" + login, login + "@" + maildomain);
    Identity identity = securityManager.createAndPersistIdentityAndUser(login, user, OLATAuthenticationController.PROVIDER_OLAT, login,
        Encoder.encrypt("A6B7C8"));
    securityManager.addIdentityToSecurityGroup(identity, group);
    return identity;
  }
View Full Code Here


  public Component getTransactionComponent() {
    return getInitialComponent();
  }

  public void repositoryEntryCreated(RepositoryEntry re) {
    Manager secMgr = ManagerFactory.getManager();
    secMgr.createAndPersistPolicy(re.getOwnerGroup(), Constants.PERMISSION_ADMIN, re.getOlatResource());
  }
View Full Code Here

      BusinessGroupManager groupManager = BusinessGroupManagerImpl.getInstance();
      BusinessGroup group = groupManager.loadBusinessGroup(groupKey, false);
      // check if the group still exists and the user is really in this group
      // (security, changed group)
      if (group != null && groupManager.isIdentityInBusinessGroup(ureq.getIdentity(), group)) {
        Manager securityManager = ManagerFactory.getManager();
        boolean isCoach = securityManager.isIdentityInSecurityGroup(ureq.getIdentity(), group.getOwnerGroup());
        // create group without admin flag enabled eventhough the user might be
        // coach. the flag is not needed here
        // since the groups knows itself if the user is coach and the user sees
        // only his own groups.
        BGControllerFactory.getInstance().createRunControllerAsTopNavTab(group, ureq, getWindowControl(), /*ual, */false, null);
View Full Code Here

   * @return The list of identities from this course
   */
  public static List loadUsers(CourseEnvironment courseEnv) {
    List identites = new ArrayList();
    CourseGroupManager gm = courseEnv.getCourseGroupManager();
    Manager securityManager = ManagerFactory.getManager();
    List groups = gm.getAllLearningGroupsFromAllContexts();

    Iterator iter = groups.iterator();
    while (iter.hasNext()) {
      BusinessGroup group = (BusinessGroup) iter.next();
      SecurityGroup participants = group.getPartipiciantGroup();
      List ids = securityManager.getIdentitiesOfSecurityGroup(participants);
      identites.addAll(ids);
    }
    return identites;
  }
View Full Code Here

   */
  public List<Identity> getIdentitiesWithQtiSerEntry(Long resourceableId, String ident) {   
    List<Identity> identities = new ArrayList<Identity>();
    LocalFolderImpl item = new LocalFolderImpl(new File(FilePersister.getFullPathToCourseNodeDirectory(Long.toString(resourceableId), ident)));
    if (VFSManager.exists(item)) {
      Manager secMgr = ManagerFactory.getManager();
      for (VFSItem identityFolder : item.getItems()) {
        Identity identity = secMgr.findIdentityByName(identityFolder.getName());
        if (identity != null) identities.add(identity);
      }
    }
   
    return identities;
View Full Code Here

   /**
   * @see org.olat.instantMessaging.InstantMessaging#synchonizeBuddyRoster(org.olat.group.BusinessGroup)
   */
  public boolean synchonizeBuddyRoster(BusinessGroup group) {
    Manager securityManager = ManagerFactory.getManager();
    SecurityGroup owners = group.getOwnerGroup();
    SecurityGroup participants = group.getPartipiciantGroup();
    List<Identity> users = securityManager.getIdentitiesOfSecurityGroup(owners);
    users.addAll(securityManager.getIdentitiesOfSecurityGroup(participants));
   
    int counter = 0;
    List<String> usernames = new ArrayList<String>();
    for (Iterator<Identity> iter = users.iterator(); iter.hasNext();) {
      Identity ident = iter.next();
View Full Code Here

  public void doIndex(SearchResourceContext parentResourceContext, Object parentObject, OlatFullIndexer indexWriter) throws IOException,
      InterruptedException {
   
    int counter = 0;
    Manager secMgr = ManagerFactory.getManager();
    List<Identity> identities = secMgr.getIdentitiesByPowerSearch(null, null, true, null, null, null, null, null, Identity.STATUS_ACTIV);
    if (log.isDebug()) log.debug("Found " + identities.size() + " active identities to index");
    for (Identity identity : identities) {
      try {
        if (log.isDebug()) log.debug("Indexing identity::" + identity.getName() + " and counter::" + counter);
        // Create a search context for this identity. The search context will open the users visiting card in a new tab
View Full Code Here

   */
  public void event(UserRequest ureq, Component source, Event event) {
    if (source == regForm) {
      if (event == Form.EVNT_VALIDATION_OK) {
        String choosenLogin = regForm.getLogin();
        Manager secMgr = ManagerFactory.getManager();
        Identity identity = secMgr.findIdentityByName(choosenLogin);

       
        if (identity == null) { // ok, create new user
          if (!hasEmailInShibAttr){
            regWithEmailForm = new ShibbolethRegistrationWithEmailForm("regWithEmailForm", translator, choosenLogin);
            regWithEmailForm.addListener(this);
            mainContainer.put("regWithEmailForm", regWithEmailForm);
            mainContainer.setPage(VELOCITY_ROOT + "/registerwithemail.html");
          } else { // there is an emailaddress
            state = STATE_NEW_SHIB_USER;
            mainContainer.setPage(VELOCITY_ROOT + "/disclaimer.html");
          }
        } else { // offer identity migration, if OLAT provider exists
          Authentication auth = secMgr.findAuthentication(identity, OLATAuthenticationController.PROVIDER_OLAT);         
          if (auth == null) { // no OLAT provider, migration not possible...
            getWindowControl().setError(translator.translate("sr.error.loginexists", new String[] {WebappHelper.getMailConfig("mailSupport")}));
          else { // OLAT provider exists, offer migration...
            migrationForm = new ShibbolethMigrationForm("migrationForm", translator, auth);
            migrationForm.addListener(this);
View Full Code Here

        dclController.changeLocale(lcev.getNewLocale());
      }
    } else if (source == dclController) {
      if (event == Event.DONE_EVENT) { // disclaimer accepted...
        if (state == STATE_NEW_SHIB_USER) { // ...proceed and create user
          Manager secMgr = ManagerFactory.getManager();
          String choosenLogin = regForm.getLogin();
          // check if login has been taken by another user in the meantime...
          Identity identity = secMgr.findIdentityByName(choosenLogin);
          if (identity != null) {
            getWindowControl().setError(translator.translate("sr.login.meantimetaken"));
            mainContainer.setPage(VELOCITY_ROOT + "/register.html");
            state = STATE_UNDEFINED;
            return;
          }

          String email;
          if(!hasEmailInShibAttr) email = regWithEmailForm.getEmail();
          else email = userMapping.getEMail();
          User user = UserManager.getInstance().findUserByEmail(email);
         
          if (user != null) {
            // error, email already exists. should actually not happen if OLAT Authenticator has
            // been set after removing shibboleth authenticator
            getWindowControl().setError(translator.translate("sr.error.emailexists", new String[] {WebappHelper.getMailConfig("mailSupport")}));
            mainContainer.setPage(VELOCITY_ROOT + "/register.html");
            state = STATE_UNDEFINED;
            return;
          }

          String firstName = userMapping.getFirstName();
          String lastName = userMapping.getLastName();
          user = UserManager.getInstance().createUser(firstName, lastName, email);
          user.setProperty(UserConstants.INSTITUTIONALNAME, userMapping.getInstitutionalName());
          if(hasEmailInShibAttr){
            user.setProperty(UserConstants.INSTITUTIONALEMAIL, userMapping.getInstitutionalEMail());
          }
          user.setProperty(UserConstants.INSTITUTIONALUSERIDENTIFIER, userMapping.getInstitutionalUserIdentifier());
          identity = secMgr.createAndPersistIdentityAndUser(choosenLogin, user, ShibbolethDispatcher.PROVIDER_SHIB, shibbolethUniqueID, null);
          SecurityGroup olatUserGroup = secMgr.findSecurityGroupByName(Constants.GROUP_OLATUSERS);
          secMgr.addIdentityToSecurityGroup(identity, olatUserGroup);
          // tell system that this user did accept the disclaimer
          RegistrationManager.getInstance().setHasConfirmedDislaimer(identity);
          doLogin(identity, ureq);
          return;
        } else if (state == STATE_MIGRATED_SHIB_USER) { // ...proceed and migrate user
          // create additional authentication
          Authentication auth = migrationForm.getAuthentication();
          Identity authenticationedIdentity = auth.getIdentity();
          Manager secMgr = ManagerFactory.getManager();
          secMgr.createAndPersistAuthentication(authenticationedIdentity, ShibbolethDispatcher.PROVIDER_SHIB, shibbolethUniqueID, null);
         
          // update user profile
          User user = authenticationedIdentity.getUser();
          String s = userMapping.getFirstName();
          if (s != null) user.setProperty(UserConstants.FIRSTNAME, s);
View Full Code Here

    this.currBusinessGroup.setMaxParticipants(bgMax);
    this.currBusinessGroup.setMinParticipants(bgMin);
    this.currBusinessGroup.setWaitingListEnabled(waitingListEnabled);
    if (waitingListEnabled.booleanValue() && (this.currBusinessGroup.getWaitingGroup() == null) ) {
      // Waitinglist is enabled but not created => Create waitingGroup
      Manager securityManager = ManagerFactory.getManager();
      SecurityGroup waitingGroup = securityManager.createAndPersistSecurityGroup();
      currBusinessGroup.setWaitingGroup(waitingGroup);
    }
    currBusinessGroup.setAutoCloseRanksEnabled(autoCloseRanksEnabled);
    currBusinessGroup.setLastUsage(new Date(System.currentTimeMillis()));
    LifeCycleManager.createInstanceFor(currBusinessGroup).deleteTimestampFor(GroupDeletionManager.SEND_DELETE_EMAIL_ACTION);
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.