Package com.uphea.domain

Source Code of com.uphea.domain.UserSession

package com.uphea.domain;

import jodd.datetime.JDateTime;

/**
* Session information for logged user.
* Will be stored in HTTP session of container, by web module.
*/
public class UserSession {

  protected final JDateTime sessionStart;
  protected User user;

  public UserSession(User user) {
    this.user = user;
    sessionStart = new JDateTime();
  }

  /**
   * Returns current user.
   */
  public User getUser() {
    return user;
  }

  /**
   * Replaces current user withing this session.
   * It should be done only when user data changes
   * (on profile edit)
   */
  public void setUser(User user) {
    this.user = user;
  }

  /**
   * Returns session start time. This is time of user login.
   */
  public JDateTime getSessionStart() {
    return sessionStart;
  }

  @Override
  public String toString() {
    return '[' + user.getScreenName() + ']';
  }
}
TOP

Related Classes of com.uphea.domain.UserSession

TOP
Copyright © 2018 www.massapi.com. 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.