Example usage for org.springframework.data.domain AuditorAware AuditorAware

List of usage examples for org.springframework.data.domain AuditorAware AuditorAware

Introduction

In this page you can find the example usage for org.springframework.data.domain AuditorAware AuditorAware.

Prototype

AuditorAware

Source Link

Usage

From source file:com.jiwhiz.domain.JiwhizBlogRepositoryTestApplication.java

@Bean
public AuditorAware<String> auditorAware() {
    return new AuditorAware<String>() {
        public String getCurrentAuditor() {
            return TEST_AUDITOR;
        }//www .ja  va  2 s.  c o m
    };
}

From source file:net.kenblair.scheduler.jpa.TestConfig.java

@Bean
public AuditorAware auditorAware() {
    return new AuditorAware() {
        @Override//from   ww  w. ja  v  a  2  s .c  o m
        public Object getCurrentAuditor() {
            return null;
        }
    };
}

From source file:com.jiwhiz.JiwhizBlogRestApiTestApplication.java

@Bean
public AuditorAware<String> auditorAware() {
    return new AuditorAware<String>() {
        public String getCurrentAuditor() {
            Authentication authentication = SecurityContextHolder.getContext().getAuthentication();

            if (authentication == null || !authentication.isAuthenticated()) {
                return null;
            }/*from  ww  w .j  a v a 2  s  . c  o  m*/

            return authentication.getName();
        }
    };
}