@SuppressWarnings({ "unchecked", "rawtypes" }) public SessionContextImpl(Session session, Set<AdminPrivilege> adminPrivileges, List<Long> lGroups, List<Long> mGroups, List<String> roles, SessionStats stats, Roles _roles, SessionContext previous) { this._roles = _roles; this.stats = stats; this.session = session; if (previous != null) { this.count = previous.count(); this.shareId = previous.getCurrentShareId(); } else { this.count = new SessionContext.Count(session.getUuid()); } this.adminPrivileges = ImmutableSet.copyOf(adminPrivileges); this.leaderOfGroups = Collections.unmodifiableList(new ArrayList( lGroups)); this.memberOfGroups = Collections.unmodifiableList(new ArrayList( mGroups)); this.roles = Collections.unmodifiableList(new ArrayList(roles)); // Force NPE getCurrentGroupPermissions(); }
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 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); }
public int detach(String uuid) { SessionContext ctx = cache.getSessionContext(uuid); return ctx.count().decrement(); }
public int getReferenceCount(String uuid) { SessionContext ctx = cache.getSessionContext(uuid); return ctx.count().get(); }