尝试在Spring Security中动态加载拦截器时出错

时间:2013-03-19 00:27:56

标签: spring-security interceptor

我已经配置了弹簧安全性,可以从DB动态生成拦截器。我有导游here。当我尝试从登录页面访问主页时出现以下错误:

An Authentication object was not found in the SecurityContext

这个错误发生在以下行的AbstractSecurityInterceptor类中(我做了调试):

if (SecurityContextHolder.getContext().getAuthentication() == null) {
            credentialsNotFound(messages.getMessage("AbstractSecurityInterceptor.authenticationNotFound",
                    "An Authentication object was not found in the SecurityContext"), object, attributes);
        }

这是日志:

org.springframework.security.authentication.AuthenticationCredentialsNotFoundException: An Authentication object was not found in the SecurityContext
    org.springframework.security.access.intercept.AbstractSecurityInterceptor.credentialsNotFound(AbstractSecurityInterceptor.java:339)
    org.springframework.security.access.intercept.AbstractSecurityInterceptor.beforeInvocation(AbstractSecurityInterceptor.java:198)
    org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:115)
    org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
    org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
    org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
    org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)

这是我的Spring Security文件配置的link

我不明白,因为发生此错误,在我的应用程序中登录的用户具有SYS_ADMIN角色。该角色有权访问主页...

我已经调试并检查了类InterceptorApplicationService(此类实现接口FilterInvocationSecurityMetadataSource)返回SYS_ADMN角色和方法getAttributes和getAllConfigAttributes中的角色列表

1 个答案:

答案 0 :(得分:0)

我解决了这个问题。这是post