Package org.olat.core.id

Examples of org.olat.core.id.User


    Identity identity;
    identity = securityManager.findIdentityByName(username);
    if (identity == null) {
      // Create new user and subject
      User newUser = new UserImpl(firstname, lastname, email);
      newUser.getPreferences().setLanguage(language);
      newUser.getPreferences().setInformSessionTimeout(true);

      // Now finally create that user thing on the database with all
      // credentials, person etc. in one transation context!
      identity = ManagerFactory.getManager().createAndPersistIdentityAndUser(username, newUser, OLATAuthenticationController.PROVIDER_OLAT,
          username, Encoder.encrypt(pwd));
View Full Code Here


    try {
      boolean isMailSent = mailer.sendEmail(changedEmail, subject, body);
      if (isMailSent) {
        tk.setMailSent(true);
        // set key
        User user = this.identityToModify.getUser();
        user.setProperty("emchangeKey", tk.getRegistrationKey());
        UserManager.getInstance().updateUser(user);
        getWindowControl().setInfo(this.translator.translate("email.sent"));
      } else {
        tk.setMailSent(false);
        rm.deleteTemporaryKeyWithId(tk.getRegistrationKey());
View Full Code Here

  /**
   * delete registration key, 'change.email.login' entry and set the userproperty emchangeKey to null
   */
  public void deleteRegistrationKey() {
    User user = userRequest.getIdentity().getUser();
    // remove keys
    user.setProperty("emchangeKey", null);
    userRequest.getUserSession().removeEntryFromNonClearedStore(CHANGE_EMAIL_ENTRY);
    userRequest.getUserSession().removeEntryFromNonClearedStore("error.change.email.time");
    // delete registration key
    if (tempKey != null) rm.deleteTemporaryKeyWithId(tempKey.getRegistrationKey());
  }
View Full Code Here

    if (securityManager.findIdentityByName(uid) != null) {
      log.error("Can't create user with username='" + uid + "', does already exist in OLAT database");
      return;
    }
    // Create User (first and lastname is added in next step)
    User user = UserManager.getInstance().createUser(null, null, email);
    // Set User Property's (Iterates over Attributes and gets OLAT Property out
    // of olatexconfig.xml)
    NamingEnumeration<Attribute> neAttr = (NamingEnumeration<Attribute>) userAttributes.getAll();
    try {
      while (neAttr.hasMore()) {
        Attribute attr = neAttr.next();
        String olatProperty = LDAPHelper.mapLdapAttributeToOlatProperty(attr.getID());
        if (attr.get() != uid) {
          String ldapValue = LDAPHelper.getAttributeValue(attr);
          if (olatProperty == null || ldapValue == null) continue;
          user.setProperty(olatProperty, ldapValue);
        }
      }
      // Add static user properties from the configuration
      Map<String, String> staticProperties = LDAPLoginModule.getStaticUserProperties();
      if (staticProperties != null && staticProperties.size() > 0) {
        for (Entry<String, String> staticProperty : staticProperties.entrySet()) {
          user.setProperty(staticProperty.getKey(), staticProperty.getValue());
        }
      }
    } catch (NamingException e) {
      log.error("NamingException when trying to create and persist LDAP user with username::" + uid, e);
      return;
View Full Code Here

   *         property has changed. NULL is returned it no attributes have to be synced
   */
  @SuppressWarnings("unchecked")
  public Map<String, String> prepareUserPropertyForSync(Attributes attributes, Identity identity) {
    Map<String, String> olatPropertyMap = new HashMap<String, String>();
    User user = identity.getUser();
    NamingEnumeration<Attribute> neAttrs = (NamingEnumeration<Attribute>) attributes.getAll();
    try {
      while (neAttrs.hasMore()) {
        Attribute attr = neAttrs.next();
        String olatProperty = LDAPHelper.mapLdapAttributeToOlatProperty(attr.getID());
        if(olatProperty == null) {
          continue;
        }
        String ldapValue = LDAPHelper.getAttributeValue(attr);
        String olatValue = user.getProperty(olatProperty, null);
        if (olatValue == null) {
          // new property or user ID (will always be null, pseudo property)
          olatPropertyMap.put(olatProperty, ldapValue);
        } else {
          if (ldapValue.compareTo(olatValue) != 0) {
View Full Code Here

    // is guaranteed -> see doPreDispose of BasicController
    myContent.put("sampleform", sampleFlexiForm.getInitialComponent());
   
    // lookup the current user info to display a personalized welcome message
    Identity curIdentity = ureq.getIdentity();
    User curUser = curIdentity.getUser();
    String userinfo = (curUser==null? "n/a" :getTranslator().translate("show.entered.data", new String[] { curUser.getProperty(UserConstants.LASTNAME, ureq.getLocale()), curUser.getProperty(UserConstants.FIRSTNAME, ureq.getLocale())}));
    // simple variable that can be referred in the velocity context by
    // "$userinfo"
    myContent.contextPut("userinfo", userinfo);

    putInitialPanel(myContent);
View Full Code Here

    Translator trans = Util.createPackageTranslator(UserManager.class, locale);
    String guestUsername = GUEST_USERNAME_PREFIX + locale.toString();   
    Identity guestIdentity = findIdentityByName(guestUsername);
    if (guestIdentity == null) {
      // Create it lazy on demand
      User guestUser = UserManager.getInstance().createUser(trans.translate("user.guest"), null, null);
      guestUser.getPreferences().setLanguage(locale.toString());
      guestIdentity = createAndPersistIdentityAndUser(guestUsername, guestUser, null, null, null);
      SecurityGroup anonymousGroup = findSecurityGroupByName(Constants.GROUP_ANONYMOUS);
      addIdentityToSecurityGroup(guestIdentity, anonymousGroup);
      return guestIdentity;
    } else {
View Full Code Here

  public void syncUser(Map<String, String> olatPropertyMap, Identity identity) {
    if (identity == null) {
      log.warn("Identiy is null - should not happen");
      return;
    }
    User user = identity.getUser();
    // remove user identifyer - can not be changed later
    olatPropertyMap.remove(LDAPConstants.LDAP_USER_IDENTIFYER);
    // remove attributes that are defined as sync-only-on-create
    Set<String> syncOnlyOnCreateProperties = LDAPLoginModule.getSyncOnlyOnCreateProperties();
    if (syncOnlyOnCreateProperties != null) {
      for (String syncOnlyOnCreateKey : syncOnlyOnCreateProperties) {
        olatPropertyMap.remove(syncOnlyOnCreateKey);
      }     
    }
    Iterator<String> itrSync = olatPropertyMap.keySet().iterator();
    while (itrSync.hasNext()) {
      String key = itrSync.next();
      user.setProperty(key, olatPropertyMap.get(key));
    }
    // Add static user properties from the configuration
    Map<String, String> staticProperties = LDAPLoginModule.getStaticUserProperties();
    if (staticProperties != null && staticProperties.size() > 0) {
      for (Entry<String, String> staticProperty : staticProperties.entrySet()) {
        user.setProperty(staticProperty.getKey(), staticProperty.getValue());
      }
    }

  }
View Full Code Here

      Identity identity = ManagerFactory.getManager().loadIdentityByKey(authorIdentKey);
      if (identity == null) {
        log.warn("Found no idenitiy with key='" + authorIdentKey + "'");
        return "-";
      }
      User user = identity.getUser();
      String formattedName = user.getProperty(UserConstants.FIRSTNAME, null);
      formattedName = formattedName + " " + user.getProperty(UserConstants.LASTNAME, null);
      //TODO: add link to user profile when checking in 4289/4295 and remove reference to loginname
      formattedName = formattedName + " (" + identity.getName() + ")";
      return formattedName;
   
  }
View Full Code Here

            ureq.getUserSession().putEntry(PRESENTED_EMAIL_CHANGE_REMINDER, Boolean.TRUE);
          }
        }
      }
    } else {
      User user = ureq.getIdentity().getUser();
      String value = user.getProperty("emailDisabled", null);
      if (value != null && value.equals("true")) {
        wControl.setWarning(translate("email.disabled"));
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.olat.core.id.User

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.