Package ome.security.basic
Class OmeroInterceptor
- java.lang.Object
-
- org.hibernate.EmptyInterceptor
-
- ome.security.basic.SqlQueryInterceptor
-
- ome.security.basic.OmeroInterceptor
-
- All Implemented Interfaces:
java.io.Serializable
,org.hibernate.Interceptor
public class OmeroInterceptor extends SqlQueryInterceptor
implementsInterceptor
for controlling various aspects of the Hibernate runtime. Where no special requirements exist, methods delegate toEmptyInterceptor
Current responsibilities include the proper (re-)setting ofDetails
- Since:
- 3.0-M3
- See Also:
EmptyInterceptor
,SqlQueryInterceptor
,Interceptor
, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description OmeroInterceptor(ome.system.Roles roles, SystemTypes sysTypes, ExtendedMetadata em, CurrentDetails cd, TokenHolder tokenHolder, SessionStats stats, LightAdminPrivileges adminPrivileges, ome.util.SqlAction sqlAction, SqlQueryTransformer sqlQueryTransformer, java.util.Set<java.lang.String> managedRepoUuids, java.util.Set<java.lang.String> scriptRepoUuids)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description 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)
protected ome.model.internal.Details
checkManagedDetails(ome.model.IObject iobj, ome.model.internal.Details previousDetails, ome.model.internal.Details newDetails)
LikecheckManagedDetails(IObject, Details, Details)
but allows passing in a specificDetails
instance.ome.model.internal.Details
evaluateLinkages(ome.model.IObject changedObject)
Checks the details of the objects which the given object links to in order to guarantee that linkages are valid.int[]
findDirty(java.lang.Object entity, java.io.Serializable id, java.lang.Object[] currentState, java.lang.Object[] previousState, java.lang.String[] propertyNames, org.hibernate.type.Type[] types)
default logicjava.lang.Object
getEntity(java.lang.String entityName, java.io.Serializable id)
java.lang.String
getEntityName(java.lang.Object object)
java.lang.Object
instantiate(java.lang.String entityName, org.hibernate.EntityMode entityMode, java.io.Serializable id)
default logic, but we may want to use them eventually for dependency-injection.java.lang.Boolean
isTransient(java.lang.Object entity)
protected void
log(java.lang.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)
Deprecated.protected boolean
managedGroup(boolean privileged, ome.model.IObject obj, ome.model.internal.Details previousDetails, ome.model.internal.Details currentDetails, ome.model.internal.Details newDetails, 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, BasicEventContext bec)
protected ome.model.internal.Permissions.Right
neededRight(java.lang.Class<?> changedClass, java.lang.Class<?> linkedClass)
The default right need for a linkage isPermissions.Right.WRITE
.ome.model.internal.Details
newTransientDetails(ome.model.IObject obj)
protected ome.model.internal.Details
newTransientDetails(ome.model.IObject obj, ome.model.internal.Details newDetails)
LikenewTransientDetails(IObject)
but allows passing in a newDetails object with possibly preset values.void
onCollectionRecreate(java.lang.Object collection, java.io.Serializable key)
void
onCollectionRemove(java.lang.Object collection, java.io.Serializable key)
void
onCollectionUpdate(java.lang.Object collection, java.io.Serializable key)
void
onDelete(java.lang.Object entity, java.io.Serializable id, java.lang.Object[] state, java.lang.String[] propertyNames, org.hibernate.type.Type[] types)
default logicboolean
onFlushDirty(java.lang.Object entity, java.io.Serializable id, java.lang.Object[] currentState, java.lang.Object[] previousState, java.lang.String[] propertyNames, org.hibernate.type.Type[] types)
calls back toBasicSecuritySystem.checkManagedDetails(IObject, Details)
for properly settingDetails
.boolean
onLoad(java.lang.Object entity, java.io.Serializable id, java.lang.Object[] state, java.lang.String[] propertyNames, org.hibernate.type.Type[] types)
default logic.java.lang.String
onPrepareStatement(java.lang.String sql)
boolean
onSave(java.lang.Object entity, java.io.Serializable id, java.lang.Object[] state, java.lang.String[] propertyNames, org.hibernate.type.Type[] types)
calls back toBasicSecuritySystem.newTransientDetails(IObject)
for properly settingDetails
void
postFlush(java.util.Iterator entities)
void
preFlush(java.util.Iterator entities)
protected boolean
resetDetails(ome.model.IObject entity, java.lang.Object[] currentState, java.lang.Object[] previousState, int idx, ome.model.internal.Details newDetails)
asksBasicSecuritySystem
to create a new managedDetails
based on the previous state of this entity.
-
-
-
Constructor Detail
-
OmeroInterceptor
public OmeroInterceptor(ome.system.Roles roles, SystemTypes sysTypes, ExtendedMetadata em, CurrentDetails cd, TokenHolder tokenHolder, SessionStats stats, LightAdminPrivileges adminPrivileges, ome.util.SqlAction sqlAction, SqlQueryTransformer sqlQueryTransformer, java.util.Set<java.lang.String> managedRepoUuids, java.util.Set<java.lang.String> scriptRepoUuids)
-
-
Method Detail
-
instantiate
public java.lang.Object instantiate(java.lang.String entityName, org.hibernate.EntityMode entityMode, java.io.Serializable id) throws org.hibernate.CallbackException
default logic, but we may want to use them eventually for dependency-injection.- Specified by:
instantiate
in interfaceorg.hibernate.Interceptor
- Overrides:
instantiate
in classorg.hibernate.EmptyInterceptor
- Throws:
org.hibernate.CallbackException
-
onLoad
public boolean onLoad(java.lang.Object entity, java.io.Serializable id, java.lang.Object[] state, java.lang.String[] propertyNames, org.hibernate.type.Type[] types) throws org.hibernate.CallbackException
default logic.- Specified by:
onLoad
in interfaceorg.hibernate.Interceptor
- Overrides:
onLoad
in classorg.hibernate.EmptyInterceptor
- Throws:
org.hibernate.CallbackException
-
findDirty
public int[] findDirty(java.lang.Object entity, java.io.Serializable id, java.lang.Object[] currentState, java.lang.Object[] previousState, java.lang.String[] propertyNames, org.hibernate.type.Type[] types)
default logic- Specified by:
findDirty
in interfaceorg.hibernate.Interceptor
- Overrides:
findDirty
in classorg.hibernate.EmptyInterceptor
-
onSave
public boolean onSave(java.lang.Object entity, java.io.Serializable id, java.lang.Object[] state, java.lang.String[] propertyNames, org.hibernate.type.Type[] types)
calls back toBasicSecuritySystem.newTransientDetails(IObject)
for properly settingDetails
- Specified by:
onSave
in interfaceorg.hibernate.Interceptor
- Overrides:
onSave
in classorg.hibernate.EmptyInterceptor
-
onFlushDirty
public boolean onFlushDirty(java.lang.Object entity, java.io.Serializable id, java.lang.Object[] currentState, java.lang.Object[] previousState, java.lang.String[] propertyNames, org.hibernate.type.Type[] types)
calls back toBasicSecuritySystem.checkManagedDetails(IObject, Details)
for properly settingDetails
.- Specified by:
onFlushDirty
in interfaceorg.hibernate.Interceptor
- Overrides:
onFlushDirty
in classorg.hibernate.EmptyInterceptor
-
onDelete
public void onDelete(java.lang.Object entity, java.io.Serializable id, java.lang.Object[] state, java.lang.String[] propertyNames, org.hibernate.type.Type[] types) throws org.hibernate.CallbackException
default logic- Specified by:
onDelete
in interfaceorg.hibernate.Interceptor
- Overrides:
onDelete
in classorg.hibernate.EmptyInterceptor
- Throws:
org.hibernate.CallbackException
-
onCollectionRecreate
public void onCollectionRecreate(java.lang.Object collection, java.io.Serializable key) throws org.hibernate.CallbackException
- Specified by:
onCollectionRecreate
in interfaceorg.hibernate.Interceptor
- Overrides:
onCollectionRecreate
in classorg.hibernate.EmptyInterceptor
- Throws:
org.hibernate.CallbackException
-
onCollectionRemove
public void onCollectionRemove(java.lang.Object collection, java.io.Serializable key) throws org.hibernate.CallbackException
- Specified by:
onCollectionRemove
in interfaceorg.hibernate.Interceptor
- Overrides:
onCollectionRemove
in classorg.hibernate.EmptyInterceptor
- Throws:
org.hibernate.CallbackException
-
onCollectionUpdate
public void onCollectionUpdate(java.lang.Object collection, java.io.Serializable key) throws org.hibernate.CallbackException
- Specified by:
onCollectionUpdate
in interfaceorg.hibernate.Interceptor
- Overrides:
onCollectionUpdate
in classorg.hibernate.EmptyInterceptor
- Throws:
org.hibernate.CallbackException
-
preFlush
public void preFlush(java.util.Iterator entities) throws org.hibernate.CallbackException
- Specified by:
preFlush
in interfaceorg.hibernate.Interceptor
- Overrides:
preFlush
in classorg.hibernate.EmptyInterceptor
- Throws:
org.hibernate.CallbackException
-
postFlush
public void postFlush(java.util.Iterator entities) throws org.hibernate.CallbackException
- Specified by:
postFlush
in interfaceorg.hibernate.Interceptor
- Overrides:
postFlush
in classorg.hibernate.EmptyInterceptor
- Throws:
org.hibernate.CallbackException
-
afterTransactionBegin
public void afterTransactionBegin(org.hibernate.Transaction tx)
- Specified by:
afterTransactionBegin
in interfaceorg.hibernate.Interceptor
- Overrides:
afterTransactionBegin
in classorg.hibernate.EmptyInterceptor
-
afterTransactionCompletion
public void afterTransactionCompletion(org.hibernate.Transaction tx)
- Specified by:
afterTransactionCompletion
in interfaceorg.hibernate.Interceptor
- Overrides:
afterTransactionCompletion
in classorg.hibernate.EmptyInterceptor
-
beforeTransactionCompletion
public void beforeTransactionCompletion(org.hibernate.Transaction tx)
- Specified by:
beforeTransactionCompletion
in interfaceorg.hibernate.Interceptor
- Overrides:
beforeTransactionCompletion
in classorg.hibernate.EmptyInterceptor
-
getEntity
public java.lang.Object getEntity(java.lang.String entityName, java.io.Serializable id) throws org.hibernate.CallbackException
- Specified by:
getEntity
in interfaceorg.hibernate.Interceptor
- Overrides:
getEntity
in classorg.hibernate.EmptyInterceptor
- Throws:
org.hibernate.CallbackException
-
getEntityName
public java.lang.String getEntityName(java.lang.Object object) throws org.hibernate.CallbackException
- Specified by:
getEntityName
in interfaceorg.hibernate.Interceptor
- Overrides:
getEntityName
in classorg.hibernate.EmptyInterceptor
- Throws:
org.hibernate.CallbackException
-
isTransient
public java.lang.Boolean isTransient(java.lang.Object entity)
- Specified by:
isTransient
in interfaceorg.hibernate.Interceptor
- Overrides:
isTransient
in classorg.hibernate.EmptyInterceptor
-
onPrepareStatement
public java.lang.String onPrepareStatement(java.lang.String sql)
- Specified by:
onPrepareStatement
in interfaceorg.hibernate.Interceptor
- Overrides:
onPrepareStatement
in classSqlQueryInterceptor
-
resetDetails
protected boolean resetDetails(ome.model.IObject entity, java.lang.Object[] currentState, java.lang.Object[] previousState, int idx, ome.model.internal.Details newDetails)
asksBasicSecuritySystem
to create a new managedDetails
based on the previous state of this entity. If the previous state is null (see ticket:3929) then throw an exception.- Parameters:
entity
- IObject to be updatedcurrentState
- the possibly changed field data for this entitypreviousState
- the field data as seen in the dbidx
- the index of Details in the state arrays.
-
log
protected void log(java.lang.String msg)
-
evaluateLinkages
public ome.model.internal.Details evaluateLinkages(ome.model.IObject changedObject)
Checks the details of the objects which the given object links to in order to guarantee that linkages are valid. In the case of a non-specific UID or GID, then the Details object returned by this method can be used as the basis for unknown user/group. This method is called duringsave
andupdate
since this is the only time that new entity references can be created.- Parameters:
changedObject
- new or updated entity which may reference other entities which then require locking. Nulls are tolerated but do nothing.
-
neededRight
protected ome.model.internal.Permissions.Right neededRight(java.lang.Class<?> changedClass, java.lang.Class<?> linkedClass)
The default right need for a linkage isPermissions.Right.WRITE
. If however, this is only an annotation or only a viewing, then less permission is needed.- Parameters:
changedClass
- the changed classlinkedClass
- the linked class- Returns:
- the right that is needed
-
newTransientDetails
public ome.model.internal.Details newTransientDetails(ome.model.IObject obj)
-
newTransientDetails
protected ome.model.internal.Details newTransientDetails(ome.model.IObject obj, ome.model.internal.Details newDetails)
LikenewTransientDetails(IObject)
but allows passing in a newDetails object with possibly preset values.- See Also:
evaluateLinkages(IObject)
-
checkManagedDetails
public ome.model.internal.Details checkManagedDetails(ome.model.IObject iobj, ome.model.internal.Details previousDetails)
-
checkManagedDetails
protected ome.model.internal.Details checkManagedDetails(ome.model.IObject iobj, ome.model.internal.Details previousDetails, ome.model.internal.Details newDetails)
LikecheckManagedDetails(IObject, Details, Details)
but allows passing in a specificDetails
instance.
-
managedExternalInfo
@Deprecated protected boolean managedExternalInfo(boolean privileged, ome.model.IObject obj, ome.model.internal.Details previousDetails, ome.model.internal.Details currentDetails, ome.model.internal.Details newDetails)
Deprecated.responsible for guaranteeing that external info is not modified by any users, including root. This does not apply to the "client concern" fields which can be modified after the fact.- Parameters:
privileged
- if the user is privilegedobj
- the model objectpreviousDetails
- details representing the known DB statecurrentDetails
- details representing the user request (UNTRUSTED)newDetails
- details from the current context. Holder for the mergedPermissions
- 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, 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, 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)
-
-