Я пытаюсь войти, когда пользователь успешно зарегистрирован в Spring Security. Я использую Logging Aspect:Как зарегистрировать SavedRequestAwareAuthenticationSuccessHandler.onAuthenticationSuccess с Spring Aspect?
@Aspect
@Component
public class LoggingAspect {
static Logger log = Logger.getLogger(LoggingAspect.class);
@Before("execution(* com.jle.athleges.web.controller.MemberController.*(..))")
public void logBefore(JoinPoint joinPoint) {
log.info("INFO - logBefore() is running!");
log.info(joinPoint.getSignature().getName());
}
@AfterReturning(pointcut = "execution(* org.springframework.security.authentication.AuthenticationManager.authenticate(..))", returning = "result")
public void after(JoinPoint joinPoint, Object result) throws Throwable {
log.info(">>> user: " + ((Authentication) result).getName());
}
@Around("execution(* org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler.onAuthenticationSuccess(..))")
public void onAuthenticationSuccess(){
log.info(">>> user " + (SecurityContextHolder.getContext().getAuthentication().getName()) + " is now connected");
}
}
Метод после работает отлично, но журнал дважды. Я пытаюсь использовать onAuthenticationSuccess, но в консоли ничего не нажимается.
Я использую образец, объясненный в Capture successful login with AspectJ and Spring Security, но он не работает.
Любая идея?
Thanks