/** * Retrieve a session possibly raising either * {@link RemovedSessionException} or {@link SessionTimeoutException}. */ public SessionContext getSessionContext(String uuid) { return getSessionContext(uuid, false); }
public SessionStats getSessionStats(String uuid) { SessionContext ctx = cache.getSessionContext(uuid); return ctx.stats(); }
private List<Session> findByQuery(String query, Parameters p) { List<Object[]> ids_uuids = executeProjection(query, p); List<Session> rv = new ArrayList<Session>(); for (Object[] arr : ids_uuids) { String uuid = (String) arr[1]; try { SessionContext sc = cache.getSessionContext(uuid); rv.add(sc.getSession()); } catch (Exception e) { // skip } } return rv; }
public List<String> getUserRoles(String uuid) { SessionContext ctx = cache.getSessionContext(uuid); if (ctx == null) { throw new RemovedSessionException("No session with uuid: " + uuid); } return ctx.getUserRoles(); }
public EventContext reload(final String uuid) { final SessionContext ctx = cache.getSessionContext(uuid); if (ctx == null) { throw new RemovedSessionException("No session with uuid:" + uuid); } Future<Object> future = executor.submit(Priority.SYSTEM, new Callable<Object>(){ public Object call() throws Exception { cache.reload(uuid); return null; }}); // A freshly loaded session should now have been saved // as if it had been reloaded during synchronization. executor.get(future); return cache.getSessionContext(uuid); }
public int getReferenceCount(String uuid) { SessionContext ctx = cache.getSessionContext(uuid); return ctx.count().get(); }
public Session find(String uuid) { SessionContext sessionContext = cache.getSessionContext(uuid); checkIfShare(sessionContext); return (sessionContext == null) ? null : sessionContext.getSession(); }
public int detach(String uuid) { SessionContext ctx = cache.getSessionContext(uuid); return ctx.count().decrement(); }
public int close(String uuid) { SessionContext ctx; try { ctx = cache.getSessionContext(uuid); } catch (SessionException se) { log.info("closeSession called but doesn't exist: " + uuid); return -1; // EARLY EXIT! } int refCount = ctx.count().decrement(); if (refCount < 1) { log.info("closeSession called and no more references: " + uuid); cache.removeSession(uuid); return -2; } else { log.info("closeSession called but " + refCount + " more references: " + uuid); return refCount; } }
public EventContext getEventContext(Principal principal) { final SessionContext ctx = cache.getSessionContext(principal.getName()); if (ctx == null) { throw new RemovedSessionException("No session with uuid:" + principal.getName()); } return ctx; }
public void login(Principal principal) { // Can't use the method in SessionManager since that leads to a // circular reference in Spring. final String uuid = principal.getName(); final SessionContext ctx = cache.getSessionContext(uuid); final SessionStats stats = ctx.stats(); final BasicEventContext c = new BasicEventContext(principal, stats); login(c); }
public Session createFromRequest(CreationRequest request) { // If credentials exist as session, then return that if (request.credentials != null) { try { SessionContext context = cache .getSessionContext(request.credentials); if (context != null) { context.count().increment(); return context.getSession(); // EARLY EXIT! } } catch (SessionException se) { // oh well. } // Though trusted values, if we receive a null principal, not ok; boolean ok = request.principal == null ? false : executeCheckPassword( request.principal, request.credentials); if (!ok) { log.warn("Failed to authenticate: " + request.principal); throw new AuthenticationException("Authentication exception."); } } // authentication checked. Now delegating to the admin method (no pass) Session session = new Session(); define(session, UUID.randomUUID().toString(), "Initial message.", System.currentTimeMillis(), request); return createSession(request, session); }
@Transactional(readOnly = true) public Object doWork(org.hibernate.Session session, ServiceFactory sf) { if (ec.getCurrentShareId() != null) { sf.getShareService().deactivate(); } SessionContext sc = cache.getSessionContext(principal.getName()); Session s = sc.getSession(); // Store old value for rollback if (!sc.isCurrentUserAdmin() && id >= 0 && !sc.getMemberOfGroupsList().contains(id)) { StringBuilder sb = new StringBuilder(); sb.append("User "); sb.append(sc.getCurrentUserId()); sb.append(" is not a member of group "); sb.append(id); throw new SecurityViolation(sb.toString()); } group[0] = s.getDetails().getGroup(); s.getDetails().setGroup(sf.getAdminService().getGroup(id)); return s; } });
public TransactionAttribute getTransactionAttribute(Method method, Class targetClass) { try { Principal principal = current.getLast(); String uuid = principal.getName(); EventContext ec = cache.getSessionContext(uuid); Long shareId = ec.getCurrentShareId(); if (ec.getCurrentShareId() != null) { log.debug("Returning readOnly tx for shared " + shareId); DefaultTransactionAttribute ta = new DefaultTransactionAttribute(); ta.setReadOnly(true); return ta; } } catch (SessionException se) { // No worries. It's not our job to enforce anything. return null; } catch (NoSuchElementException nse) { // No one is logged in so there can't be a share active! return null; } return null; } }
SessionContext context = cache.getSessionContext(principal.getName()); if (context != null) { context.count().increment();
final SessionContext ctx = cache.getSessionContext(uuid); if (ctx == null) { throw new RemovedSessionException(
final SessionContext sc = cache.getSessionContext(principal.getName());