org.javers.spring.auditable.AuthorProvider Java Examples

The following examples show how to use org.javers.spring.auditable.AuthorProvider. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AuditableAspectConfiguration.java    From cia with Apache License 2.0 5 votes vote down vote up
/**
 * Author provider.
 *
 * @return the author provider
 */
@Bean
public AuthorProvider authorProvider() {
	return () -> {
		final SecurityContext context = SecurityContextHolder.getContext();
		if (context != null && context.getAuthentication() != null) {
			return context.getAuthentication().getPrincipal().toString();
		} else {
			return "system";
		}
	};
}
 
Example #2
Source File: HibernateConfig.java    From javers with Apache License 2.0 5 votes vote down vote up
/**
 * Required by Repository auto-audit aspect. <br/><br/>
 * <p>
 * Returns mock implementation for testing.
 * <br/>
 * Provide real implementation,
 * when using Spring Security you can use
 * {@link SpringSecurityAuthorProvider}.
 */
@Bean
public AuthorProvider authorProvider() {
    return new AuthorProvider() {
        @Override
        public String provide() {
            return "unknown";
        }
    };
}
 
Example #3
Source File: JaversAuditableAspectAsync.java    From javers with Apache License 2.0 4 votes vote down vote up
public JaversAuditableAspectAsync(Javers javers, AuthorProvider authorProvider, CommitPropertiesProvider commitPropertiesProvider,Executor executor) {
    this(new JaversCommitAdvice(javers, authorProvider, commitPropertiesProvider, executor));
}
 
Example #4
Source File: JaversAuditableAspect.java    From javers with Apache License 2.0 4 votes vote down vote up
public JaversAuditableAspect(Javers javers, AuthorProvider authorProvider, CommitPropertiesProvider commitPropertiesProvider) {
    this(new JaversCommitAdvice(javers, authorProvider, commitPropertiesProvider) );
}
 
Example #5
Source File: JaversAuditableAspect.java    From javers with Apache License 2.0 4 votes vote down vote up
public JaversAuditableAspect(Javers javers, AuthorProvider authorProvider) {
    this(javers, authorProvider, new EmptyPropertiesProvider());
}
 
Example #6
Source File: AbstractSpringAuditableRepositoryAspect.java    From javers with Apache License 2.0 4 votes vote down vote up
protected AbstractSpringAuditableRepositoryAspect(Javers javers, AuthorProvider authorProvider, CommitPropertiesProvider commitPropertiesProvider) {
    this.javers = javers;
    this.javersCommitAdvice = new JaversCommitAdvice(javers, authorProvider, commitPropertiesProvider);
}
 
Example #7
Source File: JaversSpringDataAuditableRepositoryAspect.java    From javers with Apache License 2.0 4 votes vote down vote up
public JaversSpringDataAuditableRepositoryAspect(Javers javers, AuthorProvider authorProvider, CommitPropertiesProvider commitPropertiesProvider) {
    super(javers, authorProvider, commitPropertiesProvider);
}
 
Example #8
Source File: JaversCommitAdvice.java    From javers with Apache License 2.0 4 votes vote down vote up
public JaversCommitAdvice(Javers javers, AuthorProvider authorProvider, CommitPropertiesProvider commitPropertiesProvider) {
    this.javers = javers;
    this.authorProvider = authorProvider;
    this.commitPropertiesProvider = commitPropertiesProvider;
    this.executor = null;
}
 
Example #9
Source File: JaversCommitAdvice.java    From javers with Apache License 2.0 4 votes vote down vote up
public JaversCommitAdvice(Javers javers, AuthorProvider authorProvider, CommitPropertiesProvider commitPropertiesProvider, Executor executor) {
	this.javers = javers;
	this.authorProvider = authorProvider;
	this.commitPropertiesProvider = commitPropertiesProvider;
   	this.executor = executor;
}
 
Example #10
Source File: JaversSpringDataJpaAuditableRepositoryAspect.java    From javers with Apache License 2.0 4 votes vote down vote up
public JaversSpringDataJpaAuditableRepositoryAspect(Javers javers, AuthorProvider authorProvider, CommitPropertiesProvider commitPropertiesProvider) {
    super(javers, authorProvider, commitPropertiesProvider);
}
 
Example #11
Source File: JaversConfiguration.java    From tutorials with MIT License 4 votes vote down vote up
@Bean
public AuthorProvider provideJaversAuthor() {
    return new SimpleAuthorProvider();
}
 
Example #12
Source File: AuditableAspectConfiguration.java    From cia with Apache License 2.0 2 votes vote down vote up
/**
 * Javers auditable aspect.
 *
 * @param javers                   the javers
 * @param authorProvider           the author provider
 * @param commitPropertiesProvider the commit properties provider
 * @return the javers auditable aspect
 */
@Bean
public JaversAuditableAspect javersAuditableAspect(final Javers javers, final AuthorProvider authorProvider,
		final CommitPropertiesProvider commitPropertiesProvider) {
	return new JaversAuditableAspect(javers, authorProvider, commitPropertiesProvider);
}
 
Example #13
Source File: JaversSpringMongoApplicationConfig.java    From javers with Apache License 2.0 2 votes vote down vote up
/**
 * Required by auto-audit aspect. <br/><br/>
 *
 * Creates {@link SpringSecurityAuthorProvider} instance,
 * suitable when using Spring Security
 */
@Bean
public AuthorProvider authorProvider() {
    return new SpringSecurityAuthorProvider();
}
 
Example #14
Source File: JaversSpringJpaApplicationConfig.java    From javers with Apache License 2.0 2 votes vote down vote up
/**
 * Required by auto-audit aspect. <br/><br/>
 *
 * Creates {@link SpringSecurityAuthorProvider} instance,
 * suitable when using Spring Security
 */
@Bean
public AuthorProvider authorProvider() {
    return new SpringSecurityAuthorProvider();
}