请找到我的以下配置,将Spring Security v3.2.5与Web Logic Server v7集成。
我试图在几个地方找到如何整合但没有运气。
当我使用以下配置运行我的应用程序时,我得到“找不到org.springframework.security.authentication.UsernamePasswordAuthenticationToken的身份验证提供者”。
如果我们看一下配置已经提到“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 -->
答案 0 :(得分:0)
您的配置中包含form-login
,这将创建UsernamePasswordAuthenticationToken
并将其提交给身份验证管理器。但是,后者只有PreAuthenticatedAuthenticationProvider
无法处理此类型的身份验证,因此会出错。
您需要添加AuthenticationProvider
来处理用户名/密码身份验证。
此外,您似乎混合了命名空间配置和显式bean配置。你应该选择其中一个 - 这使你很难弄清楚你所发布的例子中实际使用的是什么。