public ExperimenterGroup getGroup() { return current().getGroup(); }
/** * Checks if the current {@link Thread} has non-null {@link Experimenter}, * {@link Event}, and {@link ExperimenterGroup}, required for proper * functioning of the security system. */ public boolean isReady() { BasicEventContext c = current(); if (c.getEvent() != null && c.getGroup() != null && c.getOwner() != null) { return true; } return false; }
public Event newEvent(Session session, EventType type, TokenHolder tokenHolder) { BasicEventContext c = current(); Event e = new Event(); e.setType(type); e.setTime(new Timestamp(System.currentTimeMillis())); tokenHolder.setToken(e.getGraphHolder()); e.getDetails().setPermissions(Permissions.READ_ONLY); // Proxied if necessary e.setExperimenter(c.getOwner()); e.setExperimenterGroup(c.getGroup()); e.setSession(session); c.setEvent(e); return e; }
/** * Creates a {@link Details} object for the current security context. * * The {@link Permissions} on the instance are calculated from the current * group as well as the user's umask. * * @return details for the current security context * @see <a href="https://trac.openmicroscopy.org/ome/ticket/1434">ticket:1434</a> */ public Details createDetails() { final BasicEventContext c = current(); final Details d = Details.create(new Object[]{c, c.getCallContext()}); d.setCreationEvent(c.getEvent()); d.setUpdateEvent(c.getEvent()); d.setOwner(c.getOwner()); d.setGroup(c.getGroup()); // ticket:1434 final Permissions groupPerms = c.getCurrentGroupPermissions(); final Permissions p = new Permissions(groupPerms); d.setPermissions(p); return d; }
public Object doInHibernate(Session session) throws HibernateException, SQLException { BasicEventContext c = cd.current(); boolean wasAdmin = c.isCurrentUserAdmin(); final Set<AdminPrivilege> oldAdminPrivileges = c.getAdminPrivileges(); ExperimenterGroup oldGroup = c.getGroup(); try { c.setAdmin(true); c.setAdminPrivileges(LightAdminPrivileges.getAllPrivileges()); if (group != null) { c.setGroup(group, group.getDetails().getPermissions()); } disable(MergeEventListener.MERGE_EVENT); enableReadFilter(session); action.runAsAdmin(); } finally { c.setAdmin(wasAdmin); c.setAdminPrivileges(oldAdminPrivileges); if (group != null) { c.setGroup(oldGroup, oldGroup.getDetails().getPermissions()); } enable(MergeEventListener.MERGE_EVENT); enableReadFilter(session); // Now as non-admin } return null; } });