Java 类org.springframework.boot.actuate.security.AuthenticationAuditListener 实例源码

项目:onboarding-service    文件:AuditApplicationEventLogger.java   
@EventListener
public void onAuditEvent(AuditApplicationEvent event) {
    AuditEvent auditEvent = event.getAuditEvent();

    if (auditEvent.getType() == AuthenticationAuditListener.AUTHENTICATION_SUCCESS) {
        return;
    }

    log.info("Logging audit application event: timestamp: {}, principal: {}, type: {}, data: {}",
            auditEvent.getTimestamp(),
            auditEvent.getPrincipal(),
            auditEvent.getType(),
            auditEvent.getData()
    );

    auditLogRepository.save(
        AuditLog.builder()
                .type(auditEvent.getType())
                .principal(auditEvent.getPrincipal())
                .timestamp(auditEvent.getTimestamp().toInstant())
                .data(auditEvent.getData())
                .build()
    );

}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:AuditAutoConfigurationTests.java   
@Test
public void defaultConfiguration() throws Exception {
    registerAndRefresh(AuditAutoConfiguration.class);
    assertThat(this.context.getBean(AuditEventRepository.class)).isNotNull();
    assertThat(this.context.getBean(AuthenticationAuditListener.class)).isNotNull();
    assertThat(this.context.getBean(AuthorizationAuditListener.class)).isNotNull();
}
项目:spring-boot-concourse    文件:AuditAutoConfigurationTests.java   
@Test
public void defaultConfiguration() throws Exception {
    registerAndRefresh(AuditAutoConfiguration.class);
    assertThat(this.context.getBean(AuditEventRepository.class)).isNotNull();
    assertThat(this.context.getBean(AuthenticationAuditListener.class)).isNotNull();
    assertThat(this.context.getBean(AuthorizationAuditListener.class)).isNotNull();
}
项目:contestparser    文件:AuditAutoConfigurationTests.java   
@Test
public void testTraceConfiguration() throws Exception {
    this.context = new AnnotationConfigApplicationContext();
    this.context.register(AuditAutoConfiguration.class);
    this.context.refresh();
    assertNotNull(this.context.getBean(AuditEventRepository.class));
    assertNotNull(this.context.getBean(AuthenticationAuditListener.class));
    assertNotNull(this.context.getBean(AuthorizationAuditListener.class));
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:AuditAutoConfiguration.java   
@Bean
@ConditionalOnClass(name = "org.springframework.security.authentication.event.AbstractAuthenticationEvent")
@ConditionalOnMissingBean(AbstractAuthenticationAuditListener.class)
public AuthenticationAuditListener authenticationAuditListener() throws Exception {
    return new AuthenticationAuditListener();
}
项目:spring-boot-concourse    文件:AuditAutoConfiguration.java   
@Bean
@ConditionalOnClass(name = "org.springframework.security.authentication.event.AbstractAuthenticationEvent")
@ConditionalOnMissingBean(AbstractAuthenticationAuditListener.class)
public AuthenticationAuditListener authenticationAuditListener() throws Exception {
    return new AuthenticationAuditListener();
}
项目:contestparser    文件:AuditAutoConfiguration.java   
@Bean
@ConditionalOnClass(name = "org.springframework.security.authentication.event.AbstractAuthenticationEvent")
public AuthenticationAuditListener authenticationAuditListener() throws Exception {
    return new AuthenticationAuditListener();
}