audit4j / audit4j-core

An open source auditing framework.
http://audit4j.org
Apache License 2.0
129 stars 75 forks source link

@Audit annotation does not work #78

Open johno1985 opened 6 years ago

johno1985 commented 6 years ago

Version 2.5.0

I have added the @Audit annotation to one of my controller methods and have implemented the MetaData interface but no audit events are triggered

    @Audit
    public void handleRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        logger.info("Received request: " + request.getRequestURI() + "?" + request.getQueryString());
                ...
        }
package com.launchworks.launchbi.audit;

import org.audit4j.core.MetaData;

public class AuditData implements MetaData {

    @Override
    public String getActor() {
        return "blah";
    }

    @Override
    public String getOrigin() {
        return "booh";
    }

}
!Configuration
handlers:
- !org.audit4j.handler.db.DatabaseAuditHandler
    embedded: false
    db_driver: com.mysql.cj.jdbc.Driver
    db_url: jdbc:mysql://localhost:3306/launchbi_audit_local?serverTimezone=UTC
    db_user: ***
    db_password:***
layout: 
  !org.audit4j.core.layout.SimpleLayout
    dateFormat: MM/dd/yyyy HH:mm:ss zzz
metaData: !com.launchworks.launchbi.audit.AuditData {}
franck-benault commented 6 years ago

Hello,

What is your project (is it a spring boot project?) Do you see in the log the starting of audit4j ?

Regards Franck

johno1985 commented 6 years ago

Hi Franck

Our project is a servlet 4 application. That's right, no rest frameworks are currently being used! Horror!

Kind regards

Jonathan

On Sat, 23 Jun 2018, 15:03 Franck Benault, notifications@github.com wrote:

Hello,

What is your project (is it a spring boot project?) Do you see in the log the starting of audit4j ?

Regards Franck

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/audit4j/audit4j-core/issues/78#issuecomment-399680553, or mute the thread https://github.com/notifications/unsubscribe-auth/ABkJAVCVsQirEtRNgf91mqTGA3C97Yzoks5t_kqXgaJpZM4UzvSb .

franck-benault commented 6 years ago

Hello,

I have faced the issue how to integrate the @Audit annotation in environment without spring.

I have put a simple example using Aspectj to integrate @Audit annotation in audit4j-demo (audit-demo-annotation-int) https://github.com/audit4j/audit4j-demo/tree/master/audit4j-demo-annotation-int

But one additionnal point please avoid to audit a method like void handleRequest(HttpServletRequest request, HttpServletResponse response) the input object are quite complexe and I am not so sure that you will have good results

Regards Franck

johno1985 commented 6 years ago

Thanks Franck. Quick question, if I were to use Jersey REST, would this annotation work with their default DI mechanism, HK2?

Kind regards,

Jonathan

On Sun, 24 Jun 2018 at 21:18, Franck Benault notifications@github.com wrote:

Hello,

I have faced the issue how to integrate the @Audit https://github.com/Audit annotation in environment without spring.

I have put a simple example using Aspectj to integrate @Audit https://github.com/Audit annotation in audit4j-demo (audit-demo-annotation-int)

https://github.com/audit4j/audit4j-demo/tree/master/audit4j-demo-annotation-int

But one additionnal point please avoid to audit a method like void handleRequest(HttpServletRequest request, HttpServletResponse response) the input object are quite complexe and I am not so sure that you will have good results

Regards Franck

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/audit4j/audit4j-core/issues/78#issuecomment-399784538, or mute the thread https://github.com/notifications/unsubscribe-auth/ABkJAft04AvuWaXx-JLLbRn_1nhrKfoVks5t__QtgaJpZM4UzvSb .