Example #1
0
 private void checkAuth(HttpServletRequest req, HttpServletResponse resp, PersistenceManager pm)
     throws IOException {
   String idString = req.getRequestURI().substring("/check-auth/".length());
   if (idString.isEmpty()) {
     LOGGER.warning("empty session id");
     setResponse(resp, 418, "FAIL");
   } else {
     long id = Long.parseLong(idString);
     SqlCloudSession sqlCloudSession = lookupCloudSessionById(id, pm);
     if (sqlCloudSession == null) {
       setResponse(resp, 418, "FAIL");
     } else {
       DbUser user =
           persistenceHelper.getObjectById(
               pm, persistenceHelper.getDbUserClass(), sqlCloudSession.getUser());
       setResponse(resp, 200, "OK\n" + sqlCloudSession.getRandomID() + "\n" + user.getEmail());
     }
   }
   resp.flushBuffer();
 }
Example #2
0
 private void recordSession(
     PersistenceManager pm, SqlCloudSession session, DbInvocation invocation) {
   Transaction tx;
   session.setInvocation(invocation);
   tx = pm.currentTransaction();
   tx.begin();
   try {
     pm.makePersistent(session);
     tx.commit();
   } finally {
     if (tx.isActive()) {
       tx.rollback();
     }
   }
 }
Example #3
0
  private DbInvocation recordInvocation(
      PersistenceManager pm, LogIn loginMsg, SqlCloudSession session) {
    DbInvocation invocation = persistenceHelper.createDbInvocation();
    invocation.setWho(session.getUser());
    invocation.setStartTime(loginMsg.getAnalysisTimestamp());

    Transaction tx = pm.currentTransaction();
    tx.begin();
    try {
      invocation = pm.makePersistent(invocation);
      tx.commit();
    } finally {
      if (tx.isActive()) {
        tx.rollback();
      }
    }
    return invocation;
  }