Beispiel #1
0
 /** Remove this sessions's user node. */
 public void logout() {
   if (userHandle != null) {
     try {
       // Invoke User.onLogout() iff this is a transactor request with a request
       // evaluator already associated (i.e., if this is called from an app/script).
       // Otherwise, we assume being called from the scheduler thread, which takes
       // care of calling User.onLogout().
       RequestEvaluator reval = app.getCurrentRequestEvaluator();
       if (reval != null) {
         Node userNode = userHandle.getNode(app.nmgr.safe);
         if (userNode != null)
           reval.invokeDirectFunction(userNode, "onLogout", new Object[] {sessionId});
       }
     } catch (Exception x) {
       // errors should already be logged by request evaluator, but you never know
       app.logError("Error in onLogout", x);
     } finally {
       // do log out
       userHandle = null;
       uid = null;
       lastModified = System.currentTimeMillis();
       modifiedInRequest = true;
     }
   }
 }
Beispiel #2
0
 /**
  * Try logging in this session given the userName and password.
  *
  * @param userName the user name
  * @param password the password
  * @return true if session was logged in.
  */
 public boolean login(String userName, String password) {
   if (app.loginSession(userName, password, this)) {
     lastModified = System.currentTimeMillis();
     modifiedInRequest = true;
     return true;
   }
   return false;
 }
Beispiel #3
0
  /** Attach the given user node to this session. */
  public void login(INode usernode) {
    if (usernode == null) {
      userHandle = null;
      uid = null;
    } else {
      userHandle = ((Node) usernode).getHandle();
      uid = usernode.getElementName();
    }

    lastModified = System.currentTimeMillis();
    modifiedInRequest = true;
  }
Beispiel #4
0
 /**
  * Creates a new Session object.
  *
  * @param sessionId ...
  * @param app ...
  */
 public Session(String sessionId, Application app) {
   this.sessionId = sessionId;
   this.app = app;
   this.uid = null;
   this.userHandle = null;
   cacheNode = new TransientNode(app, "session");
   cacheLastModified = cacheNode.lastModified();
   // HACK - decrease timestamp by 1 to notice modifications
   // taking place immediately after object creation
   onSince = System.currentTimeMillis() - 1;
   lastTouched = lastModified = onSince;
 }
Beispiel #5
0
 /** Called at the beginning of a request to let the session know it's being used. */
 public void touch() {
   lastTouched = System.currentTimeMillis();
 }