Package uk.gov.gchq.gaffer.graph.hook
Class OperationAuthoriser
- java.lang.Object
-
- uk.gov.gchq.gaffer.graph.hook.OperationAuthoriser
-
-
Constructor Summary
Constructors Constructor Description OperationAuthoriser()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAuths(Class<? extends Operation> opClass, String... auths)
Add operation authorisations for a given operation class.Set<String>
getAllAuths()
Map<Class<?>,Set<String>>
getAuths()
Map<String,Set<String>>
getAuthsAsStrings()
<T> T
onFailure(T result, OperationChain<?> opChain, Context context, Exception e)
Called fromGraph
if an error occurs whilst executing theOperationChain
.<T> T
postExecute(T result, OperationChain<?> opChain, Context context)
Called fromGraph
after anOperationChain
is executed.void
preExecute(OperationChain<?> opChain, Context context)
Checks theOperation
s in the providedOperationChain
are allowed to be executed by the user.void
setAuths(Map<Class<?>,Set<String>> auths)
void
setAuthsFromStrings(Map<String,Set<String>> auths)
-
-
-
Method Detail
-
preExecute
public void preExecute(OperationChain<?> opChain, Context context)
Checks theOperation
s in the providedOperationChain
are allowed to be executed by the user. This is done by checking the user's auths against the operation auths. If an operation cannot be executed then anIllegalAccessError
is thrown.- Specified by:
preExecute
in interfaceGraphHook
- Parameters:
context
- the user to authorise.opChain
- the operation chain.
-
postExecute
public <T> T postExecute(T result, OperationChain<?> opChain, Context context)
Description copied from interface:GraphHook
Called fromGraph
after anOperationChain
is executed.- Specified by:
postExecute
in interfaceGraphHook
- Type Parameters:
T
- the result type- Parameters:
result
- the result from the operation chainopChain
- theOperationChain
that was executed. This can be modified/optimised in any GraphHook.context
- theContext
in which the operation chain was executed. The context also holds a reference to the original operation chain.- Returns:
- result object
-
onFailure
public <T> T onFailure(T result, OperationChain<?> opChain, Context context, Exception e)
Description copied from interface:GraphHook
Called fromGraph
if an error occurs whilst executing theOperationChain
.- Specified by:
onFailure
in interfaceGraphHook
- Type Parameters:
T
- the result type- Parameters:
result
- the result from the operation chain - likely to be null.opChain
- theOperationChain
that was executed. This can be modified/optimised in any GraphHook.context
- theContext
in which the operation chain was executed. The context also holds a reference to the original operation chain.e
- the exception- Returns:
- result object
-
addAuths
public void addAuths(Class<? extends Operation> opClass, String... auths)
Add operation authorisations for a given operation class. This can be called multiple times for the same operation class and the authorisations will be appended.- Parameters:
opClass
- the operation classauths
- the authorisations
-
setAuthsFromStrings
public void setAuthsFromStrings(Map<String,Set<String>> auths) throws ClassNotFoundException
- Throws:
ClassNotFoundException
-
-