All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.javers.spring.auditable.SpringSecurityAuthorProvider Maven / Gradle / Ivy

There is a newer version: 7.7.0
Show newest version
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