class AbstractRestletAccessAuditFilter extends Filter {

    @Override
    protected int beforeHandle(Request request, Response response) {
        try {
            Representation representation = request.getEntity();
            // If the representation is transient we can only read its entity once, so we have to wrap it in a
            // buffer in order to read from it during the event logging and later during authentication
            if (representation.isTransient()) {
                request.setEntity(new BufferingRepresentation(request.getEntity()));
            }
            auditAccessAttempt(request);
        } catch (AuditException e) {
            debug.error("Unable to publish {} audit event '{}' due to error: {} [{}]",
                    ACCESS_TOPIC, EventName.AM_ACCESS_ATTEMPT, e.getMessage(), e);
        }
        return CONTINUE;
    }

    public  AbstractRestletAccessAuditFilter(Component component, Restlet restlet,
            AuditEventPublisher auditEventPublisher, AuditEventFactory auditEventFactory,
            RestletBodyAuditor<?> requestDetailCreator, RestletBodyAuditor<?> responseDetailCreator);

}