public class SecuritySystemHolder extends Object implements SecuritySystem
SecuritySystem
 instance and allowing dispatching between them.BasicSecuritySystem, 
SharingSecuritySystem| Modifier and Type | Field and Description | 
|---|---|
| protected BasicSecuritySystem | basic | 
| protected ThreadLocal<SecuritySystem> | current | 
| protected SharingSecuritySystem | sharing | 
| Constructor and Description | 
|---|
| SecuritySystemHolder(BasicSecuritySystem basic,
                    SharingSecuritySystem sharing) | 
| Modifier and Type | Method and Description | 
|---|---|
| Details | checkManagedDetails(IObject object,
                   Details trustedDetails)checks that a non-privileged user has not attempted to edit the entity's
  security details. | 
| void | checkRestriction(String name,
                IObject obj)Checks whether or not a  Policyinstance of matching
 name has been registered, considers itself active, and
 considers the passed context object to be restricted. | 
| SecuritySystem | choose() | 
| void | disable(String... ids)disables components of the backend for the current Thread. | 
| <T extends IObject> | doAction(SecureAction action,
        T... objs) | 
| void | enable(String... ids)enables components of the backend for the current Thread. | 
| Long | getEffectiveUID()Returns UID based on whether a share is active, etc. | 
| EventContext | getEventContext()Calls  SecuritySystem.getEventContext(boolean)with a false as "refresh". | 
| EventContext | getEventContext(boolean refresh)If refresh is false, returns the current  EventContextstored
 in the session. | 
| Roles | getSecurityRoles() | 
| boolean | hasPrivilegedToken(IObject obj) | 
| void | invalidateEventContext()Clears the content of the  EventContextso that theSecuritySystemwill no longer return true forSecuritySystem.isReady(). | 
| boolean | isDisabled(String id)checks if the listed id is disabled for the current Thread. | 
| boolean | isGraphCritical(Details details)Determines if the current security context has the possibility of
 corrupting consistent graphs. | 
| boolean | isReady()checks if this  SecuritySysteminstance is in a valid state. | 
| boolean | isSystemType(Class<? extends IObject> klass)checks if instances of the given type are "System-Types". | 
| void | loadEventContext(boolean isReadOnly)Prepares the current  EventContextinstance with the currentPrincipal. | 
| void | login(Principal principal)stores this  Principalinstance in the current thread context for
 authenticating and authorizing all actions. | 
| int | logout()clears the top  Principalinstance from the current thread
 context. | 
| Details | newTransientDetails(IObject object)creates a new secure  detailsfor transient
 entities. | 
| void | runAsAdmin(AdminAction action)Calls  SecuritySystem.runAsAdmin(ExperimenterGroup, AdminAction)with a
 null group. | 
| void | runAsAdmin(ExperimenterGroup group,
          AdminAction action)Allows actions to be performed with the
  EventContext.isCurrentUserAdmin()flag enabled but
 without changing the value ofEventContext.getCurrentUserId(), so that ownerships are properly
 handled. | 
protected final BasicSecuritySystem basic
protected final SharingSecuritySystem sharing
protected ThreadLocal<SecuritySystem> current
public SecuritySystemHolder(BasicSecuritySystem basic, SharingSecuritySystem sharing)
public SecuritySystem choose()
public Details checkManagedDetails(IObject object, Details trustedDetails) throws ApiUsageException, SecurityViolation
SecuritySystemsecurity details. Privileged users can set
 fields on Details as a single-step chmod and
 chgrp.
 
 managedDetails may create
 a new Details instance and return that if needed. If the returned Details
 is not equivalent (==) to the argument Details, then values have been
 changed.checkManagedDetails in interface SecuritySystemobject - non-null IObject instance. Details for that
            instance can be null.trustedDetails - possibly null Details instance. These Details
            are trusted in the sense that they have already once passed
            through the SecuritySystem.ApiUsageException - if SecuritySystem is not readySecurityViolation - if Details instance contains illegal values.public void invalidateEventContext()
SecuritySystemEventContextso that the
 SecuritySystem will no longer return true for SecuritySystem.isReady().
 The Principal set during SecuritySystem.login(Principal) is retained.invalidateEventContext in interface SecuritySystempublic void disable(String... ids)
SecuritySystemSecuritySystem.isDisabled(String) will return false. It is the
 responsibility of various security system components to then throw
 exceptions.disable in interface SecuritySystemids - Non-null, non-empty array of String ids to disable.public <T extends IObject> T doAction(SecureAction action, T... objs)
doAction in interface SecuritySystempublic void enable(String... ids)
SecuritySystemSecuritySystem.isDisabled(String) will return true.enable in interface SecuritySystemids - possibly null array of String ids. A null array specifies that
            all subsystems are to be enabled. Otherwise, only those
            subsystems specified by the ids.public EventContext getEventContext()
SecuritySystemSecuritySystem.getEventContext(boolean) with a false as "refresh".
 This is the previous, safer logic of the method since consumers
 are not expecting a long method run.getEventContext in interface SecuritySystempublic EventContext getEventContext(boolean refresh)
SecuritySystemEventContext stored
 in the session. Otherwise, reloads the context to have the most
 up-to-date information.getEventContext in interface SecuritySystemrefresh - if the event context should first be reloadedpublic Long getEffectiveUID()
SecuritySystem
 Annotation toSave = ...;
 if (toSave.getDetails().getOwner() == null) // No owner need to find one.
 {
     Long uid = sec.getEffectiveUID();
     if (uid != null)
     {
         toSave.getDetails().setOwner(new Experimenter(uid, false));
     }
     else
     {
         toSave.getDetails().setOwner(
            image.getDetails().getOwner()); // may be null.
     }
 }
 image.linkAnnotation(toSave);
 etc.
 getEffectiveUID in interface SecuritySystempublic Roles getSecurityRoles()
getSecurityRoles in interface SecuritySystempublic boolean hasPrivilegedToken(IObject obj)
SecuritySystemhasPrivilegedToken in interface SecuritySystempublic void checkRestriction(String name, IObject obj)
SecuritySystemPolicy instance of matching
 name has been registered, considers itself active, and
 considers the passed context object to be restricted.checkRestriction in interface SecuritySystemname - A non-null unique name for a class of policies.obj - An instance which is to be checked against matching policies.public boolean isDisabled(String id)
SecuritySystemisDisabled in interface SecuritySystemid - non-null String representing a backend subsystem.SecuritySystem.disable(String[])public boolean isReady()
SecuritySystemSecuritySystem instance is in a valid state. This
 includes that a user is properly logged in and that a connection is
 available to all necessary resources, e.g. database handle and mapping
 session.
 
 Not all methods require that the instance is ready.isReady in interface SecuritySystempublic boolean isSystemType(Class<? extends IObject> klass)
SecuritySystemisSystemType in interface SecuritySystemklass - A class which extends from IObjectpublic void loadEventContext(boolean isReadOnly)
SecuritySystemEventContext instance with the current
 Principal. An exception is thrown if there is none.loadEventContext in interface SecuritySystempublic void login(Principal principal)
SecuritySystemPrincipal instance in the current thread context for
 authenticating and authorizing all actions. This method does not
 make any queries and is only a conduit for login information from the
 outermost levels. Session bean implementations and other in-JVM clients
 can fill the Principal. Note, however, a call must first be made
 to SecuritySystem.loadEventContext(boolean) for some calls to be made to the
 SecuritySystem. In general, this means that execution must pass
 through the EventHandlerlogin in interface SecuritySystemprincipal - the new current principalpublic int logout()
SecuritySystemPrincipal instance from the current thread
 context.logout in interface SecuritySystempublic Details newTransientDetails(IObject object) throws ApiUsageException, SecurityViolation
SecuritySystemdetails for transient
 entities. Non-privileged users can only edit the
 Permissions field. Privileged users can
 use the Details object as a single-step chmod and
 chgrp.
 
 newTransientDetails always returns
 a non-null Details that is not equivalent (==) to the Details argument.
 
 This method can be used from anywhere in the codebase to obtain a valid
 Details, but passing in an IObject instance with a null
 Details. However, if the Details is non-null, there is
 the possibility that this method will throw an exception.newTransientDetails in interface SecuritySystemApiUsageException - if SecuritySystem is not readySecurityViolation - if Details instance contains illegal values.public void runAsAdmin(AdminAction action)
SecuritySystemSecuritySystem.runAsAdmin(ExperimenterGroup, AdminAction) with a
 null group.runAsAdmin in interface SecuritySystemaction - the action to runpublic void runAsAdmin(ExperimenterGroup group, AdminAction action)
SecuritySystemEventContext.isCurrentUserAdmin() flag enabled but
 without changing the value of
 EventContext.getCurrentUserId(), so that ownerships are properly
 handled. The merging of detached entity graphs should be disabled for the
 extent of the execution.
 
 Due to the addition of the group permission system, we also permit
 setting the group on the call so that the administrator can work within
 all groups. A value of null will not change the current group.
 Note: the IUpdate save methods should not be used, since
 they also accept detached entities, which could pose security risks.
 Instead load an entity from the database via IQuery,
 make changes, and save the changes with IUpdate.runAsAdmin in interface SecuritySystemgroup - the group to run the action asaction - the action to runpublic boolean isGraphCritical(Details details)
SecuritySystem
  The current group is non-negative, then use the previous logic;
  else the current group is negative,
     and the object is in a non-"user" group: USE THAT GROUP;
     else the object is in the "user" group: UNCLEAR
     (for the moment we're throwing an exception)
 
 If no Details instance is passed or a Details without
 a ExperimenterGroup value, then throw as well.isGraphCritical in interface SecuritySystemdetails - the details
                
                
Version: 5.3.3-ice35-b63
Copyright © 2017 The University of Dundee & Open Microscopy Environment. All Rights Reserved.