@Override public Session findSessionById(long id, org.hibernate.Session session) { return findSessionById(id, (ServiceFactory) null); }
@Override public Long findSessionIdByUuid(String uuid, ServiceFactory sf) { return findSessionIdByUuid(uuid); }
@Override public Session executeInternalSession(final String uuid, Session session) { Node node = (Node) executor.executeSql(new Executor.SimpleSqlWork(this, "executeInternalSession") { @Transactional(readOnly = true) public Object doWork(SqlAction sql) { final Long nodeId = nodeProvider.getManagerIdByUuid(uuid, sql); return nodeId == null ? null : new Node(nodeId, false); } }); session.setId(executeNextSessionId()); log.debug("Created session: {}", session); log.debug("Setting node: {}", node); session.setNode(node); session.setOwner(new Experimenter(roles.getRootId(), false)); openSessions.put(session.getUuid(), session); return session; }
/** * Simplified factory method which generates all the security primitives * internally. Primarily useful for generated testing instances. * @param sm the session manager * @param sf the session factory * @param cache the session cache * @return a configured security system */ public static BasicSecuritySystem selfConfigure(SessionManager sm, ServiceFactory sf, SessionCache cache) { CurrentDetails cd = new CurrentDetails(cache); SystemTypes st = new SystemTypes(); TokenHolder th = new TokenHolder(); Roles roles = new Roles(); final SessionProvider sessionProvider = new SessionProviderInMemory(roles, new NodeProviderInMemory(""), null); final OmeroInterceptor oi = new OmeroInterceptor(roles, st, new ExtendedMetadata.Impl(), cd, th, new PerSessionStats(cd), new LightAdminPrivileges(roles), null, new HashSet<String>(), new HashSet<String>()); SecurityFilterHolder holder = new SecurityFilterHolder( cd, new OneGroupSecurityFilter(roles), new AllGroupsSecurityFilter(null, roles), new SharingSecurityFilter(roles, null)); BasicSecuritySystem sec = new BasicSecuritySystem(oi, st, cd, sm, sessionProvider, new EventProviderInMemory(), roles, sf, new TokenHolder(), Collections.<SecurityFilter>singletonList(holder), new DefaultPolicyService(), new BasicACLVoter(cd, st, th, holder, sessionProvider, new ReadOnlyStatus(false, false))); return sec; }
@Override public Session executeUpdate(ServiceFactory sf, Session session, String uuid, long userId, Long sudoerId) { Node node = nodeProvider.getManagerByUuid(uuid, sf); if (node == null) { node = new Node(0L, false); // Using default node. } if (session.getId() == null) { session.setId(executeNextSessionId()); } session.setNode(node); session.setOwner(new Experimenter(userId, false)); if (sudoerId == null) { session.setSudoer(null); } else { session.setSudoer(new Experimenter(sudoerId, false)); } /* put before remove so that the session is never missing altogether */ if (session.getClosed() == null) { openSessions.put(session.getUuid(), session); closedSessions.remove(session.getUuid()); } else { closedSessions.put(session.getUuid(), session); openSessions.remove(session.getUuid()); } log.debug("Registered Session:{} ({})", session.getId(), session.getUuid()); return session; }