public interface AuditorAware<T>
Interface for components that are aware of the application's current auditor. This will be used to populate
Implementations should be registered as Spring beans. The type parameter should match the type of the auditor field in your domain classes (e.g., User, Long, String, etc.).
Example implementation:
@Component
public class SpringSecurityAuditorAware implements AuditorAware<String> {
@Override
public Optional<String> getCurrentAuditor() {
return Optional.ofNullable(SecurityContextHolder.getContext())
.map(SecurityContext::getAuthentication)
.filter(Authentication::isAuthenticated)
.map(Authentication::getName);
}
}T - the type of the auditor (e.g., User, Long, String)| Type Params | Return Type | Name and description |
|---|---|---|
|
public java.util.Optional<T> |
getCurrentAuditor()Returns the current auditor of the application. |