请找到我下面的配置来集成SpringSecurityv3.2.5和Web v7。
我试图在几个地方找出如何集成,但没有运气。
当我在下面的配置中运行我的应用程序时,我得到了“没有为找到AuthenticationProvider”
如果我们在配置中提到"preAuthenticatedAuthenticationProvider"是身份验证管理器的身份验证提供者,因为preAuthenticatedAuthenticationProvider也提到了"preAuthenticatedUserDetailsService“。
有人能帮我解决这个问题吗。
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security.xsd">
<!-- web sphere configuration start -->
<http auto-config="false" use-expressions="true">
<intercept-url pattern="/welcome*" access="permitAll" />
<form-login login-page="/login" default-target-url="/welcome"
authentication-failure-url="/loginfailed" />
<custom-filter before="PRE_AUTH_FILTER" ref="webspherePreAuthFilter" />
<logout logout-success-url="/logout" delete-cookies="JSESSIONID" />
<session-management invalid-session-url="/logout">
<concurrency-control max-sessions="1"
error-if-maximum-exceeded="true" expired-url="/sessionexpired" />
</session-management>
</http>
<beans:bean id="filterChainProxy"
class="org.springframework.security.web.FilterChainProxy">
<filter-chain-map path-type="ant">
<!-- <filter-chain pattern="/**"
filters="sif,webspherePreAuthFilter,logoutFilter,etf,fsi" /> -->
<filter-chain pattern="/welcome*"
filters="webspherePreAuthFilter,logoutFilter,etf,fsi" />
</filter-chain-map>
</beans:bean>
<authentication-manager alias="authenticationManager">
<authentication-provider ref="preAuthenticatedAuthenticationProvider" />
</authentication-manager>
<beans:bean id="preAuthenticatedAuthenticationProvider"
class="org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationProvider">
<beans:property name="preAuthenticatedUserDetailsService"
ref="preAuthenticatedUserDetailsService" />
</beans:bean>
<beans:bean id="preAuthenticatedUserDetailsService"
class="org.springframework.security.web.authentication.preauth.PreAuthenticatedGrantedAuthoritiesUserDetailsService" />
<!-- This AbstractPreAuthenticatedProcessingFilter implementation is based
on WebSphere authentication. It will use the WebSphere RunAs user principal
name as the pre-authenticated principal. -->
<beans:bean id="webspherePreAuthFilter"
class="org.springframework.security.web.authentication.preauth.websphere.WebSpherePreAuthenticatedProcessingFilter">
<beans:property name="authenticationManager" ref="authenticationManager" />
<beans:property name="authenticationDetailsSource" ref="authenticationDetailsSource" />
</beans:bean>
<beans:bean id="authenticationDetailsSource"
class="org.springframework.security.web.authentication.preauth.websphere.WebSpherePreAuthenticatedWebAuthenticationDetailsSource">
<beans:property name="webSphereGroups2GrantedAuthoritiesMapper"
ref="websphereUserGroups2GrantedAuthoritiesMapper" />
</beans:bean>
<beans:bean id="websphereUserGroups2GrantedAuthoritiesMapper"
class="org.springframework.security.core.authority.mapping.SimpleAttributes2GrantedAuthoritiesMapper">
<beans:property name="convertAttributeToUpperCase"
value="true" />
</beans:bean>
<beans:bean id="preAuthenticatedProcessingFilterEntryPoint"
class="org.springframework.security.web.authentication.Http403ForbiddenEntryPoint" />
<beans:bean id="logoutFilter"
class="org.springframework.security.web.authentication.logout.LogoutFilter">
<beans:constructor-arg value="/" />
<beans:constructor-arg>
<beans:list>
<beans:bean
class="org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler" />
</beans:list>
</beans:constructor-arg>
</beans:bean>
<beans:bean id="etf"
class="org.springframework.security.web.access.ExceptionTranslationFilter">
<beans:property name="authenticationEntryPoint"
ref="preAuthenticatedProcessingFilterEntryPoint" />
</beans:bean>
<beans:bean id="fsi"
class="org.springframework.security.web.access.intercept.FilterSecurityInterceptor">
<beans:property name="authenticationManager" ref="authenticationManager" />
<beans:property name="accessDecisionManager" ref="httpRequestAccessDecisionManager" />
<beans:property name="securityMetadataSource">
<filter-security-metadata-source>
<intercept-url pattern="/welcome*" access="ROLE_LDP_ADMINS" />
</filter-security-metadata-source>
</beans:property>
</beans:bean>
<beans:bean id="httpRequestAccessDecisionManager"
class="org.springframework.security.access.vote.AffirmativeBased">
<beans:property name="allowIfAllAbstainDecisions"
value="false" />
<beans:property name="decisionVoters">
<beans:list>
<beans:ref bean="roleVoter" />
</beans:list>
</beans:property>
</beans:bean>
<beans:bean id="roleVoter"
class="org.springframework.security.access.vote.RoleVoter" />
<!-- web sphere configuration ends -->
发布于 2014-11-07 15:37:55
您的配置中包含了form-login,它将创建UsernamePasswordAuthenticationToken并将其提交给身份验证管理器。但是,后者只有一个无法处理这种身份验证类型的PreAuthenticatedAuthenticationProvider,因此出现了错误。
您需要添加一个可以处理用户名/密码身份验证的AuthenticationProvider。
而且,您似乎同时使用了名称空间配置和显式bean配置。你应该选择一种或另一种--这使得你很难弄清楚在你发布的例子中实际使用的是什么。
https://stackoverflow.com/questions/26775431
复制相似问题