ome.security.basic
Class OmeroInterceptor

java.lang.Object
  extended by ome.security.basic.OmeroInterceptor
All Implemented Interfaces:
org.hibernate.Interceptor

public class OmeroInterceptor
extends Object
implements org.hibernate.Interceptor

implements Interceptor for controlling various aspects of the Hibernate runtime. Where no special requirements exist, methods delegate to EmptyInterceptor Current responsibilities include the proper (re-)setting of Details

Since:
3.0-M3
Version:
$Revision: 7499 $, $Date: 2010-07-08 15:39:15 +0100 (Thu, 08 Jul 2010) $
Author:
Josh Moore, josh.moore at gmx.de
See Also:
EmptyInterceptor, Interceptor

Constructor Summary
OmeroInterceptor(Roles roles, SystemTypes sysTypes, ExtendedMetadata em, CurrentDetails cd, TokenHolder tokenHolder, SessionStats stats)
           
 
Method Summary
 void afterTransactionBegin(org.hibernate.Transaction tx)
           
 void afterTransactionCompletion(org.hibernate.Transaction tx)
           
 void beforeTransactionCompletion(org.hibernate.Transaction tx)
           
 ome.model.internal.Details checkManagedDetails(ome.model.IObject iobj, ome.model.internal.Details previousDetails)
           
 void evaluateLinkages(ome.model.IObject iObject)
          Checks the details of the objects which the given object links to in order to guarantee that linkages are valid.
 int[] findDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState, String[] propertyNames, org.hibernate.type.Type[] types)
          default logic
 Object getEntity(String entityName, Serializable id)
           
 String getEntityName(Object object)
           
 Object instantiate(String entityName, org.hibernate.EntityMode entityMode, Serializable id)
          default logic, but we may want to use them eventually for dependency-injection.
 Boolean isTransient(Object entity)
           
protected  void log(String msg)
           
protected  boolean managedEvent(boolean privileged, ome.model.IObject obj, ome.model.internal.Details previousDetails, ome.model.internal.Details currentDetails, ome.model.internal.Details newDetails)
           
protected  boolean managedExternalInfo(boolean privileged, ome.model.IObject obj, ome.model.internal.Details previousDetails, ome.model.internal.Details currentDetails, ome.model.internal.Details newDetails)
          responsible for guaranteeing that external info is not modified by any users, including rot.
protected  boolean managedGroup(boolean privileged, ome.model.IObject obj, ome.model.internal.Details previousDetails, ome.model.internal.Details currentDetails, ome.model.internal.Details newDetails, ome.security.basic.BasicEventContext bec)
           
protected  boolean managedOwner(boolean privileged, ome.model.IObject obj, ome.model.internal.Details previousDetails, ome.model.internal.Details currentDetails, ome.model.internal.Details newDetails, ome.security.basic.BasicEventContext bec)
           
protected  boolean managedPermissions(boolean privileged, ome.model.IObject obj, ome.model.internal.Details previousDetails, ome.model.internal.Details currentDetails, ome.model.internal.Details newDetails, boolean sysType)
          responsible for properly copying user-requested permissions taking into account the Flag#LOCKED status.
 ome.model.internal.Details newTransientDetails(ome.model.IObject obj)
           
 void onCollectionRecreate(Object collection, Serializable key)
           
 void onCollectionRemove(Object collection, Serializable key)
           
 void onCollectionUpdate(Object collection, Serializable key)
           
 void onDelete(Object entity, Serializable id, Object[] state, String[] propertyNames, org.hibernate.type.Type[] types)
          default logic
 boolean onFlushDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState, String[] propertyNames, org.hibernate.type.Type[] types)
          callsback to BasicSecuritySystem.checkManagedDetails(IObject, Details) for properly setting Details.
 boolean onLoad(Object entity, Serializable id, Object[] state, String[] propertyNames, org.hibernate.type.Type[] types)
          default logic.
 String onPrepareStatement(String sql)
           
 boolean onSave(Object entity, Serializable id, Object[] state, String[] propertyNames, org.hibernate.type.Type[] types)
          callsback to BasicSecuritySystem.newTransientDetails(IObject) for properly setting Details
 void postFlush(Iterator entities)
           
 void preFlush(Iterator entities)
           
protected  boolean resetDetails(ome.model.IObject entity, Object[] currentState, Object[] previousState, int idx)
          asks BasicSecuritySystem to create a new managed Details based on the previous state of this entity.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OmeroInterceptor

public OmeroInterceptor(Roles roles,
                        SystemTypes sysTypes,
                        ExtendedMetadata em,
                        CurrentDetails cd,
                        TokenHolder tokenHolder,
                        SessionStats stats)
Method Detail

instantiate

public Object instantiate(String entityName,
                          org.hibernate.EntityMode entityMode,
                          Serializable id)
                   throws org.hibernate.CallbackException
default logic, but we may want to use them eventually for dependency-injection.

Specified by:
instantiate in interface org.hibernate.Interceptor
Throws:
org.hibernate.CallbackException

onLoad

public boolean onLoad(Object entity,
                      Serializable id,
                      Object[] state,
                      String[] propertyNames,
                      org.hibernate.type.Type[] types)
               throws org.hibernate.CallbackException
default logic.

Specified by:
onLoad in interface org.hibernate.Interceptor
Throws:
org.hibernate.CallbackException

findDirty

public int[] findDirty(Object entity,
                       Serializable id,
                       Object[] currentState,
                       Object[] previousState,
                       String[] propertyNames,
                       org.hibernate.type.Type[] types)
default logic

Specified by:
findDirty in interface org.hibernate.Interceptor

onSave

public boolean onSave(Object entity,
                      Serializable id,
                      Object[] state,
                      String[] propertyNames,
                      org.hibernate.type.Type[] types)
callsback to BasicSecuritySystem.newTransientDetails(IObject) for properly setting Details

Specified by:
onSave in interface org.hibernate.Interceptor

onFlushDirty

public boolean onFlushDirty(Object entity,
                            Serializable id,
                            Object[] currentState,
                            Object[] previousState,
                            String[] propertyNames,
                            org.hibernate.type.Type[] types)
callsback to BasicSecuritySystem.checkManagedDetails(IObject, Details) for properly setting Details.

Specified by:
onFlushDirty in interface org.hibernate.Interceptor

onDelete

public void onDelete(Object entity,
                     Serializable id,
                     Object[] state,
                     String[] propertyNames,
                     org.hibernate.type.Type[] types)
              throws org.hibernate.CallbackException
default logic

Specified by:
onDelete in interface org.hibernate.Interceptor
Throws:
org.hibernate.CallbackException

onCollectionRecreate

public void onCollectionRecreate(Object collection,
                                 Serializable key)
                          throws org.hibernate.CallbackException
Specified by:
onCollectionRecreate in interface org.hibernate.Interceptor
Throws:
org.hibernate.CallbackException

onCollectionRemove

public void onCollectionRemove(Object collection,
                               Serializable key)
                        throws org.hibernate.CallbackException
Specified by:
onCollectionRemove in interface org.hibernate.Interceptor
Throws:
org.hibernate.CallbackException

onCollectionUpdate

public void onCollectionUpdate(Object collection,
                               Serializable key)
                        throws org.hibernate.CallbackException
Specified by:
onCollectionUpdate in interface org.hibernate.Interceptor
Throws:
org.hibernate.CallbackException

preFlush

public void preFlush(Iterator entities)
              throws org.hibernate.CallbackException
Specified by:
preFlush in interface org.hibernate.Interceptor
Throws:
org.hibernate.CallbackException

postFlush

public void postFlush(Iterator entities)
               throws org.hibernate.CallbackException
Specified by:
postFlush in interface org.hibernate.Interceptor
Throws:
org.hibernate.CallbackException

afterTransactionBegin

public void afterTransactionBegin(org.hibernate.Transaction tx)
Specified by:
afterTransactionBegin in interface org.hibernate.Interceptor

afterTransactionCompletion

public void afterTransactionCompletion(org.hibernate.Transaction tx)
Specified by:
afterTransactionCompletion in interface org.hibernate.Interceptor

beforeTransactionCompletion

public void beforeTransactionCompletion(org.hibernate.Transaction tx)
Specified by:
beforeTransactionCompletion in interface org.hibernate.Interceptor

getEntity

public Object getEntity(String entityName,
                        Serializable id)
                 throws org.hibernate.CallbackException
Specified by:
getEntity in interface org.hibernate.Interceptor
Throws:
org.hibernate.CallbackException

getEntityName

public String getEntityName(Object object)
                     throws org.hibernate.CallbackException
Specified by:
getEntityName in interface org.hibernate.Interceptor
Throws:
org.hibernate.CallbackException

isTransient

public Boolean isTransient(Object entity)
Specified by:
isTransient in interface org.hibernate.Interceptor

onPrepareStatement

public String onPrepareStatement(String sql)
Specified by:
onPrepareStatement in interface org.hibernate.Interceptor

resetDetails

protected boolean resetDetails(ome.model.IObject entity,
                               Object[] currentState,
                               Object[] previousState,
                               int idx)
asks BasicSecuritySystem to create a new managed Details based on the previous state of this entity.

Parameters:
entity - IObject to be updated
currentState - the possibly changed field data for this entity
previousState - the field data as seen in the db
idx - the index of Details in the state arrays.

log

protected void log(String msg)

evaluateLinkages

public void evaluateLinkages(ome.model.IObject iObject)
Checks the details of the objects which the given object links to in order to guarantee that linkages are valid. This method is called during save and update since this is the only time that new entity references can be created.

Parameters:
iObject - new or updated entity which may reference other entities which then require locking. Nulls are tolerated but do nothing.
ownerId - the id of the current owner. May be null in which case, the current owner id will most likely be replaced. (If not, then a security exception will be raised later)

newTransientDetails

public ome.model.internal.Details newTransientDetails(ome.model.IObject obj)
See Also:
SecuritySystem.newTransientDetails(IObject)

checkManagedDetails

public ome.model.internal.Details checkManagedDetails(ome.model.IObject iobj,
                                                      ome.model.internal.Details previousDetails)
See Also:
SecuritySystem.checkManagedDetails(IObject, Details)

managedExternalInfo

protected boolean managedExternalInfo(boolean privileged,
                                      ome.model.IObject obj,
                                      ome.model.internal.Details previousDetails,
                                      ome.model.internal.Details currentDetails,
                                      ome.model.internal.Details newDetails)
responsible for guaranteeing that external info is not modified by any users, including rot.

Parameters:
locked -
privileged -
obj -
previousDetails - details representing the known DB state
currentDetails - details representing the user request (UNTRUSTED)
newDetails - details from the current context. Holder for the merged Permissions
Returns:
true if the Permissions of newDetails are changed.

managedPermissions

protected boolean managedPermissions(boolean privileged,
                                     ome.model.IObject obj,
                                     ome.model.internal.Details previousDetails,
                                     ome.model.internal.Details currentDetails,
                                     ome.model.internal.Details newDetails,
                                     boolean sysType)
responsible for properly copying user-requested permissions taking into account the Flag#LOCKED status. This method does not need to (like newTransientDetails(IObject) take into account the session umask available from CurrentDetails.createDetails()

Parameters:
locked -
privileged -
obj -
previousDetails - details representing the known DB state
currentDetails - details representing the user request (UNTRUSTED)
newDetails - details from the current context. Holder for the merged Permissions
Returns:
true if the Permissions of newDetails are changed.

managedOwner

protected boolean managedOwner(boolean privileged,
                               ome.model.IObject obj,
                               ome.model.internal.Details previousDetails,
                               ome.model.internal.Details currentDetails,
                               ome.model.internal.Details newDetails,
                               ome.security.basic.BasicEventContext bec)

managedGroup

protected boolean managedGroup(boolean privileged,
                               ome.model.IObject obj,
                               ome.model.internal.Details previousDetails,
                               ome.model.internal.Details currentDetails,
                               ome.model.internal.Details newDetails,
                               ome.security.basic.BasicEventContext bec)

managedEvent

protected boolean managedEvent(boolean privileged,
                               ome.model.IObject obj,
                               ome.model.internal.Details previousDetails,
                               ome.model.internal.Details currentDetails,
                               ome.model.internal.Details newDetails)


OmeroJava Api

Version: Beta4.2.1-r8614-Beta4.2-b41

Copyright © 2009 The University of Dundee. All Rights Reserved.