/**
  * delete registration key, 'change.email.login' entry and set the userproperty emchangeKey to
  * null
  */
 public void deleteRegistrationKey() {
   final 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());
   }
 }
示例#2
0
  private UserSession afterAuthorization(Identity identity, HttpServletRequest request) {
    UserSession usess = sessionManager.getUserSession(request);
    synchronized (usess) {
      // double check to prevent severals concurrent login
      if (usess.isAuthenticated()) {
        return usess;
      }

      sessionManager.signOffAndClear(usess);
      usess.setIdentity(identity);
      UserDeletionManager.getInstance().setIdentityAsActiv(identity);
      // set the roles (admin, author, guest)
      Roles roles = BaseSecurityManager.getInstance().getRoles(identity);
      usess.setRoles(roles);
      // set session info
      SessionInfo sinfo =
          new SessionInfo(identity.getKey(), identity.getName(), request.getSession());
      User usr = identity.getUser();
      sinfo.setFirstname(usr.getProperty(UserConstants.FIRSTNAME, null));
      sinfo.setLastname(usr.getProperty(UserConstants.LASTNAME, null));

      String remoteAddr = request.getRemoteAddr();
      sinfo.setFromIP(remoteAddr);
      sinfo.setFromFQN(remoteAddr);
      try {
        InetAddress[] iaddr = InetAddress.getAllByName(request.getRemoteAddr());
        if (iaddr.length > 0) sinfo.setFromFQN(iaddr[0].getHostName());
      } catch (UnknownHostException e) {
        // ok, already set IP as FQDN
      }
      sinfo.setAuthProvider(BaseSecurityModule.getDefaultAuthProviderIdentifier());
      sinfo.setUserAgent(request.getHeader("User-Agent"));
      sinfo.setSecure(request.isSecure());
      sinfo.setWebDAV(true);
      sinfo.setWebModeFromUreq(null);
      // set session info for this session
      usess.setSessionInfo(sinfo);
      //
      sessionManager.signOn(usess);
      return usess;
    }
  }
示例#3
0
 /** @return The name of the author */
 public String getAuthor() {
   String authorName = null;
   if (authorKey > 0) {
     Identity identity = BaseSecurityManager.getInstance().loadIdentityByKey(authorKey, false);
     if (identity != null) {
       User user = identity.getUser();
       if (user == null) {
         authorName = author = identity.getName();
       } else {
         authorName =
             author =
                 user.getProperty(UserConstants.FIRSTNAME, null)
                     + " "
                     + user.getProperty(UserConstants.LASTNAME, null);
       }
     }
   }
   if (authorName == null && StringHelper.containsNonWhitespace(author)) {
     authorName = author;
   }
   return authorName;
 }