Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring安全与AOP_Spring_Spring Security_Aop_Spring Aop - Fatal编程技术网

Spring安全与AOP

Spring安全与AOP,spring,spring-security,aop,spring-aop,Spring,Spring Security,Aop,Spring Aop,是否可以创建自定义@Aspect并将其应用于SpringSecurity(3.0.3)中的类/方法 我正在尝试对登录/注销请求进行一些日志记录,但没有触发我的任何建议 我正在使用@AspectJ注释,下面是我如何装饰我的方法: @After("execution (* org.springframework.security.authentication.ProviderManager.doAuthentication(..))") 而是使用ApplicationListener捕获成功登录。

是否可以创建自定义@Aspect并将其应用于SpringSecurity(3.0.3)中的类/方法

我正在尝试对登录/注销请求进行一些日志记录,但没有触发我的任何建议

我正在使用@AspectJ注释,下面是我如何装饰我的方法:

@After("execution (* org.springframework.security.authentication.ProviderManager.doAuthentication(..))")

而是使用
ApplicationListener
捕获成功登录。有关其他事件类型,请参见

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationListener;
import org.springframework.security.authentication.event.AuthenticationSuccessEvent;
import org.springframework.stereotype.Component;

@Component
public class AuthenticationSuccessListener implements ApplicationListener<AuthenticationSuccessEvent> {
    private static final Logger logger = LoggerFactory.getLogger(AuthenticationSuccessListener.class);

    @Override
    public void onApplicationEvent(final AuthenticationSuccessEvent event) {
        logger.debug("User {} logged in", event.getAuthentication().getName());
    }
}
import org.slf4j.Logger;
导入org.slf4j.LoggerFactory;
导入org.springframework.context.ApplicationListener;
导入org.springframework.security.authentication.event.AuthenticationSuccessEvent;
导入org.springframework.stereotype.Component;
@组成部分
公共类AuthenticationSuccessListener实现ApplicationListener{
私有静态最终记录器Logger=LoggerFactory.getLogger(AuthenticationSuccessListener.class);
@凌驾
ApplicationEvent上的公共无效(最终身份验证成功事件){
debug(“用户{}登录”,event.getAuthentication().getName());
}
}

好主意,谢谢!然而,我能够使我的方面正常工作,但我也将尝试这一点,以便更加熟悉。