pannonia-expertise/audit-starter:pom.xml
Audit starter module provides mechanism for auditing write operations on database.
Default implementation of type AuditUsernameProvider - PrincipalUsernameProvider will provide current's user name from principal (using spring security) in ThreadLocal manner.
To override it, one just need to provide custom implementation.
After AuditUsernameProvider bean has been provided, auditing system is used by implementing Auditable interface in entity, adding AuditListener entity listener, and embeded Audit class object.
@Getter
@Setter
@Entity
@EntityListeners(AuditListener.class)
public class TheAuditedEntity extends BaseEntity implements Auditable {
@Embedded
Audit audit;
}
If needed a custom username provider can be added as a Spring Bean that implements
UsernameProvider interface. For reference see:
com.pannoniaexpertise.audit.usernameProviders.impl.ClientDetailsUsernameProvider
or
com.pannoniaexpertise.audit.usernameProviders.impl.UserDetailsUsernameProvider