Package org.olat.core.id

Examples of org.olat.core.id.Identity


  /**
   * if enabled in the configuration some testusers for IM are created in the
   * database. It has nothing to do with accounts on the jabber server itself.
   */
  private void checkAndCreateTestUsers() {
    Identity identity;
    Authentication auth;
    Manager securityManager = ManagerFactory.getManager();
    identity = securityManager.findIdentityByName("author");
    auth = ManagerFactory.getManager().findAuthentication(identity, ClientManager.PROVIDER_INSTANT_MESSAGING);
    if (auth == null) { // create new authentication for provider
      ManagerFactory.getManager().createAndPersistAuthentication(identity, ClientManager.PROVIDER_INSTANT_MESSAGING, identity.getName(),
          "test");
      InstantMessagingModule.getAdapter().createAccount("author", "test", "Aurich Throw", "author@olat-newinstallation.org");
    }

    identity = securityManager.findIdentityByName("administrator");
    auth = ManagerFactory.getManager().findAuthentication(identity, ClientManager.PROVIDER_INSTANT_MESSAGING);
    if (auth == null) { // create new authentication for provider
      ManagerFactory.getManager().createAndPersistAuthentication(identity, ClientManager.PROVIDER_INSTANT_MESSAGING, identity.getName(),
          "olat");
      InstantMessagingModule.getAdapter().createAccount("administrator", "olat", "Administrator", "administrator@olat-newinstallation.org");
    }

    identity = securityManager.findIdentityByName("learner");
    auth = ManagerFactory.getManager().findAuthentication(identity, ClientManager.PROVIDER_INSTANT_MESSAGING);
    if (auth == null) { // create new authentication for provider
      ManagerFactory.getManager().createAndPersistAuthentication(identity, ClientManager.PROVIDER_INSTANT_MESSAGING, identity.getName(),
          "test");
      InstantMessagingModule.getAdapter().createAccount("learner", "test", "Leise Arnerich", "learner@olat-newinstallation.org");
    }

    identity = securityManager.findIdentityByName("test");
    auth = ManagerFactory.getManager().findAuthentication(identity, ClientManager.PROVIDER_INSTANT_MESSAGING);
    if (auth == null) { // create new authentication for provider
      ManagerFactory.getManager().createAndPersistAuthentication(identity, ClientManager.PROVIDER_INSTANT_MESSAGING, identity.getName(),
          "test");
      InstantMessagingModule.getAdapter().createAccount("test", "test", "Thomas Est", "test@olat-newinstallation.org");
    }
  }
View Full Code Here


  /**
   * @param identName the name of the identity to release all locks for (only the non-persistent locks in cluster mode, -not- the persistent locks!)
   */
  public void releaseAllLocksFor(String identName) {
    Tracing.logInfo("releaseAllLocksFor: "+identName+" START", getClass());
    Identity ident = ManagerFactory.getManager().findIdentityByName(identName);
       
    DBFactory.getInstance().delete("from org.olat.commons.coordinate.cluster.lock.LockImpl as alock inner join fetch " +
        "alock.owner as owner where owner.key = ?", ident.getKey(), Hibernate.LONG);
    // cluster:: can we save a query (and is it appropriate considering encapsulation)
    // here by saying: alock.owner as owner where owner.name = ? (using identName parameter)
    Tracing.logInfo("releaseAllLocksFor: "+identName+" END", getClass());
  }
View Full Code Here

      return;
    }
    LockEntry le = ((LockResultImpl) lockResult).getLockEntry();
   
    String asset = le.getKey();
    Identity releaseRequestor = le.getOwner();
   
    final ClusterLockManager cm = ClusterLockManager.getInstance();
   
    // cluster:: change to useage with syncer, but we don't have the olatresourceable yet
    PessimisticLockManager.getInstance().findOrPersistPLock(asset);

    LockImpl li = cm.findLock(asset);
    if (li == null) {
      // do nothing - since this lock may have been one that was cleared when restarting the vm
    } else {
      // check that entry was previously locked by the same user that now wants to release the lock.
      Identity ownwer = li.getOwner();
      if (releaseRequestor.getName().equals(ownwer.getName())) {
        // delete the lock
        cm.deleteLock(li);
      } else {
        throw new AssertException("cannot release lock since the requestor of the release ("+
            releaseRequestor.getName()+") is not the owner ("+ownwer.getName()+") of the lock ("+asset+")");
      }
    }
  }
View Full Code Here

   * @return full user name and username of user like Guido Schnider (guidosch)
   * or the username if not found
   *
   */
  private String getFullUserName(String username) {
    Identity ident = ManagerFactory.getManager().findIdentityByName(username);
    if (ident != null) {
      StringBuilder sb = new StringBuilder();
      sb.append(ident.getUser().getProperty(UserConstants.FIRSTNAME, locale)).append(" ");
      sb.append(ident.getUser().getProperty(UserConstants.LASTNAME, locale)).append(" ");
      sb.append("(").append(ident.getName()).append(")");
      return sb.toString();
    }
    return username;
  }
View Full Code Here

    message.setProperty("receiveTime", new Long(new Date().getTime()));
    return message;
  }
 
  private String getFullUserName(String userName) {
    Identity ident = ManagerFactory.getManager().findIdentityByName(userName);
    if (ident != null) {
      StringBuilder sb = new StringBuilder();
      sb.append(ident.getUser().getProperty(UserConstants.FIRSTNAME, locale));
      sb.append(" ");
      sb.append(ident.getUser().getProperty(UserConstants.LASTNAME, locale));
      sb.append(" (");
      sb.append(ident.getName());
      sb.append(")");
      if (sb.length() > 35) {
        return sb.substring(0, 35)+"...";
      }
      return sb.toString();
View Full Code Here

        entries.add(entry);
        if (log.isDebug()) log.debug("loading item from cache: "+olatusername);
     
      } else {
        //item not in cache
        Identity identity = UserSession.getSignedOnIdentity(olatusername);
        if (identity != null) {
          identity = (Identity) DBFactory.getInstance().loadObject(identity);
          try {
            ImPrefsManager ipm = ImPrefsManager.getInstance();
            ImPreferences imPrefs = ipm.loadOrCreatePropertiesFor(identity);
            if ( (imPrefs != null) ) {
              ClientHelper clientHelper = new ClientHelper(olatusername, null, null, null);
              entry = new ConnectedUsersListEntry(olatusername, identity.getUser().getPreferences().getLanguage());
              entry.setName(identity.getUser().getProperty(UserConstants.LASTNAME, null));
              entry.setPrename(identity.getUser().getProperty(UserConstants.FIRSTNAME, null));
              entry.setShowAwarenessMessage(imPrefs.isAwarenessVisible());
              entry.setShowOnlineTime(imPrefs.isOnlineTimeVisible());
              entry.setAwarenessMessage(clientHelper.getStatusMsg());
              entry.setInstantMessagingStatus(clientHelper.getStatus());
              entry.setLastActivity(lastActivity.get(olatusername));
View Full Code Here

    if (source == usc) {
      getWindowControl().pop();
      if (event != Event.CANCELLED_EVENT) {
        // we configured usc to either cancel or to only accept single user selection.
        SingleIdentityChosenEvent sce = (SingleIdentityChosenEvent)event;
        Identity ident = sce.getChosenIdentity();
        ClusterLockManager.getInstance().releaseAllLocksFor(ident.getName());
        showInfo("locks.released", ident.getName());
      }
    }
  }
View Full Code Here

          .getPackageVelocityRoot(this.getClass())
          + "/msg-preview.html");
      uifactory.addSpacerElement("spacer1", formLayout, false);
      formLayout.add(replyMsgLayout);
      replyMsgLayout.setLabel("label.replytomsg", new String[] { replyMessage.getTitle() });
      Identity identity = replyMessage.getCreator();
      replyMsgLayout.contextPut("identity", identity);
      replyMsgLayout.contextPut("messageBody", replyMessage.getBody());
      replyMsgLayout.contextPut("message", replyMessage);
      portraitCtr = new DisplayPortraitController(ureq, getWindowControl(), identity, true, true);
      replyMsgLayout.put("portrait", portraitCtr.getInitialComponent());
View Full Code Here

    if (eMail.notEmpty("srf.error.email.empty")
        && eMail.matches(".+@.+\\..+", "srf.error.email.valid")
        && eMail.matches("^[^<>\"' \t\n\r]*$", "srf.error.email.badcharacters")) {
   
        // check if email is already used by another useraccount
        Identity foundIdentity = UserManager.getInstance().findIdentityByEmail(eMail.getValue());
        if (foundIdentity != null) {
          eMail.setErrorKey("srf.error.email.usedByOtherUser");
          valid = false;
       }
    } else valid = false;
View Full Code Here

   *
   */
  @SuppressWarnings("unused")
  public static void main(String[] args) throws Exception {
   
    Identity ident = new Identity() {

      @SuppressWarnings("unused")
      public Date getDeleteEmailDate() {
        return null;
      }
View Full Code Here

TOP

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

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.