org.javers.spring.auditable.SpringSecurityAuthorProvider Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of javers-spring Show documentation
Show all versions of javers-spring Show documentation
JaVers object auditing and diff framework
package org.javers.spring.auditable;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
/**
* Returns a current user name from Spring Security context
*/
public class SpringSecurityAuthorProvider implements AuthorProvider {
@Override
public String provide() {
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
if (auth == null) {
return "unauthenticated";
}
return auth.getName();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy