public Session createWithAgent(final Principal _principal, final String credentials, String agent, String ip) { final CreationRequest req = new CreationRequest(); req.principal = _principal; req.credentials = credentials; req.agent = agent; req.ip = ip; return createFromRequest(req); }
public Map<String, Object> outputEnvironment(String session) { return environment(session, OUTPUT_ENVIRONMENT); }
private boolean executeCheckPassword(final Principal _principal, final String credentials) { Boolean ok = executeCheckPasswordRO(_principal, credentials); if (ok == null) { ok = executeCheckPasswordRW(_principal, credentials); } return ok; }
public Share createShare(Principal principal, boolean enabled, long timeToLive, String eventType, String description, long groupId) { Share share = newShare(); define(share, UUID.randomUUID().toString(), description, System .currentTimeMillis(), defaultTimeToIdle, timeToLive, eventType, "Share", null); share.setGroup(new ExperimenterGroup(groupId, false)); share.setActive(enabled); share.setData(new byte[] {}); share.setItemCount(0L); CreationRequest req = new CreationRequest(); req.principal = principal; return (Share) createSession(req, share); }
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); }
final SessionContext newctx = createSessionContext(list, ctx); final Session copy = copy(orig); executor.execute(asroot, new Executor.SimpleWork(this, "update") { @Transactional(readOnly = false) return copy(orig);
protected void define(Session s, String uuid, String message, long started, CreationRequest req) { Long idle = req.timeToIdle == null ? defaultTimeToIdle : req.timeToIdle; Long live = req.timeToLive == null ? defaultTimeToLive : req.timeToLive; if (req.groupsLed != null) { CommentAnnotation ca = new CommentAnnotation(); ca.setNs(GROUP_SUDO_NS); StringBuilder sb = new StringBuilder(); for (int i = 0; i < req.groupsLed.size(); i++) { if (i > 0) { sb.append(","); } sb.append(req.groupsLed.get(i)); } ca.setTextValue(sb.toString()); s.linkAnnotation(ca); } define(s, uuid, message, started, idle, live, req.principal.getEventType(), req.agent, req.ip); }
/** * Will be called in a synchronized block by {@link SessionCache} in order * to allow for an update. */ @SuppressWarnings({"rawtypes" }) public SessionContext reload(final SessionContext ctx) { List list = (List) executor.execute(asroot, new Executor.SimpleWork( this, "reload", ctx.getSession().getUuid()) { @Transactional(readOnly = true) public Object doWork(org.hibernate.Session session, ServiceFactory sf) { /* user and group names may change while the session is open */ final LocalAdmin admin = (LocalAdmin) sf.getAdminService(); final Experimenter exp = admin.userProxy(ctx.getCurrentUserId()); final ExperimenterGroup grp = admin.groupProxy(ctx.getCurrentGroupId()); final Principal p = new Principal(exp.getOmeName(), grp.getName(), ctx.getCurrentEventType()); return executeSessionContextLookup(sf, p, exp, grp, ctx.getSession()); } }); if (list == null) { return null; } return createSessionContext(list, ctx); }
public boolean executePasswordCheck(final String name, final String credentials) { if (cache.getIds().contains(credentials)) { return true; } return executeCheckPassword(new Principal(name), credentials); }
public Session find(String uuid) { SessionContext sessionContext = cache.getSessionContext(uuid); checkIfShare(sessionContext); return (sessionContext == null) ? null : sessionContext.getSession(); }
ExperimenterGroup g = _getDefaultGroup(sf, p.getName()); if (g == null) { throw new ApiUsageException("Can't find default group for "
/** * Initialization method called by the Spring run-time to acquire an initial * {@link Session}. */ public void init() { try { asroot = new Principal(internal_uuid, "system", "Sessions"); // Create a basic session Session session = new Session(); define(session, internal_uuid, "Session Manager internal", System.currentTimeMillis(), Long.MAX_VALUE, 0L, "Sessions", "Internal", null); session = sessionProvider.executeInternalSession(internal_uuid, session); internalSession = new InternalSessionContext(session, LightAdminPrivileges.getAllPrivileges(), roles); cache.putSession(internal_uuid, internalSession); } catch (UncategorizedSQLException uncat) { log.warn("Assuming that this is read-only"); } catch (DataAccessException dataAccess) { throw new RuntimeException( " " + "=====================================================\n" + "Data access exception: Did you create your database? \n" + "=====================================================\n", dataAccess); } }
+ principal); SessionContext newctx = createSessionContext(rv, null);
public Session createWithAgent(Principal principal, String agent, String ip) { final CreationRequest req = new CreationRequest(); req.principal = principal; req.agent = agent; req.ip = ip; return createFromRequest(req); }
public Map<String, Object> inputEnvironment(String session) { return environment(session, INPUT_ENVIRONMENT); }