class FunctionAuthoriser implements GraphHook {

    @Override
    public void preExecute(final OperationChain<?> opChain, final Context context) {
        if (unauthorisedFunctions == null || unauthorisedFunctions.isEmpty()) {
            return;
        }

        Object input = null;
        // Null the input to avoid serialising potentially large inputs
        if (opChain.getOperations().size() > 0 && opChain.getOperations().get(0) instanceof Input) {
            input = ((Input) opChain.getOperations().get(0)).getInput();
            ((Input) opChain.getOperations().get(0)).setInput(null);
        }

        SimpleClassNameCache.setUseFullNameForSerialisation(true);
        String chainString;
        try {
            chainString = new String(JSONSerialiser.serialise(opChain));
        } catch (final SerialisationException e) {
            // This should never happen in real life as operation chains should
            // always be json serialisable. However this could happen if using a
            // mock in testing. To account for this, it will be logged.
            LOGGER.warn("Failed to serialise operation chain: " + opChain + " due to " + e.getMessage());
            return;
        } finally {
            if (input != null) {
                // The only way input could have been set to non null value would
                // be if the first operation was an Input operation.
                ((Input) opChain.getOperations().get(0)).setInput(input);
            }
        }

        checkNoUnauthorisedFunctionsArePresent(chainString);
    }

    public  FunctionAuthoriser();
    public  FunctionAuthoriser(final List<Class<? extends Function>> unauthorisedFunctions);

}