Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/379.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
Java 在Spring Security中将身份验证对象从筛选器传递给提供程序_Java_Spring_Spring Security - Fatal编程技术网

Java 在Spring Security中将身份验证对象从筛选器传递给提供程序

Java 在Spring Security中将身份验证对象从筛选器传递给提供程序,java,spring,spring-security,Java,Spring,Spring Security,我需要向身份验证对象添加一个自定义参数。因此,我为包含自定义参数的身份验证对象创建了一个包装器。然后在CustomAuthenticationProcessingFilter中创建此对象 然后在CustomAuthenticationProvider中,我获得了身份验证对象,并希望将其强制转换为CustomAuthentication。这引发了ClassCastException。传递给CustomAuthenticationProvider的对象是否与我在CustomAuthenticatio

我需要向身份验证对象添加一个自定义参数。因此,我为包含自定义参数的身份验证对象创建了一个包装器。然后在CustomAuthenticationProcessingFilter中创建此对象

然后在CustomAuthenticationProvider中,我获得了身份验证对象,并希望将其强制转换为CustomAuthentication。这引发了ClassCastException。传递给CustomAuthenticationProvider的对象是否与我在CustomAuthenticationProcessingFilter中创建的对象相同

这是我的Spring安全配置-

<sec:http entry-point-ref="entryPoint" auto-config="false"> ... <sec:custom-filter ref="customAuthenticationProcessingFilter" position="FORM_LOGIN_FILTER"/> </sec:http>

您能否演示如何设置Spring安全性以使用CustomAuthenticationProcessingFilter? ... 答案是UsernamePasswordAuthenticationFilter内的attemptAuthentication。。。1创建UsernamePasswordAuthenticationToken 2调用getAuthenticationManager.authenticate,后者反过来调用provider.authenticate。所以,如果试图重新定义身份验证对象,他应该重写UsernamePasswordAuthenticationFilter.attemptAuthentication方法并自己提取所有http参数。通过扩展默认详细信息对象和DetailsSource对象,使用token.details字段向身份验证对象添加自定义参数更方便。由中的一些SpringSecurity组成,可能对某些人有用。您可以演示如何设置Spring security以使用CustomAuthenticationProcessingFilter吗? ... 答案是UsernamePasswordAuthenticationFilter内的attemptAuthentication。。。1创建UsernamePasswordAuthenticationToken 2调用getAuthenticationManager.authenticate,后者反过来调用provider.authenticate。所以,如果试图重新定义身份验证对象,他应该重写UsernamePasswordAuthenticationFilter.attemptAuthentication方法并自己提取所有http参数。通过扩展默认详细信息对象和DetailsSource对象,使用token.details字段将自定义参数添加到身份验证对象更方便。由中的一些SpringSecurity组成,可能对某些人有用。
<sec:http entry-point-ref="entryPoint" auto-config="false"> ... <sec:custom-filter ref="customAuthenticationProcessingFilter" position="FORM_LOGIN_FILTER"/> </sec:http>