我已经读过,拥有多个http元素并为它们定义不同身份验证管理器的解决方案是使用ID而不是ALIAS。
我已经尝试了这个和许多其他解决方案,请帮助。
<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-3.1.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.1.xsd">
<!-- Exclude public pages and static resources -->
<http pattern="/favicon.ico" security="none" />
<http pattern="/js/**" security="none" />
<http pattern="/css/**" security="none" />
<http pattern="/img/**" security="none" />
<http pattern="/test*" use-expressions="true" authentication-manager-ref="smsAuthManager">
<intercept-url pattern="/test" access="hasRole('ROLE_SMS_USER')" />
<intercept-url pattern="/refreshLoginPageTuring" access="permitAll" />
<form-login login-page="/loginTuring" default-target-url="/test" login-processing-url="/loginTuring" always-use-default-target="true" authentication-failure-url="/accessdenied"/>
<logout logout-url="/logout" invalidate-session="true"/>
<!-- <access-denied-handler ref="accessDeniedHandler"/> -->
</http>
<!-- <beans:bean id="smsAuthManager" class="org.springframework.security.authentication.ProviderManager">
<beans:constructor-arg>
<beans:list>
<beans:bean class="com.swivelsecure.userportal.SMSAuthenticationProvider"/>
</beans:list>
</beans:constructor-arg>
</beans:bean> -->
<authentication-manager id="smsAuthManager">
<authentication-provider ref="sMSAuthenticationProvider" />
</authentication-manager>
<http auto-config="true" use-expressions="true" authentication-manager-ref="userPortal">
<intercept-url pattern="/getQRCode" access="permitAll" />
<intercept-url pattern="/refreshLoginPageTuring" access="permitAll" />
<intercept-url pattern="/login" access="permitAll" />
<intercept-url pattern="/logout" access="permitAll" />
<intercept-url pattern="/accessdenied" access="permitAll" />
<!-- <intercept-url pattern="/**" access="hasRole('USER')" /> -->
<form-login login-page="/login" default-target-url="/menu" login-processing-url="/login"
authentication-failure-url="/accessdenied" />
<logout logout-success-url="/logout" />
<intercept-url pattern="/errors/error" access="hasRole('USER')" />
<intercept-url pattern="/menu" access="hasRole('USER')" />
</http>
<authentication-manager alias="userPortal">
<authentication-provider ref="userPortalAuthenticationProvider" />
</authentication-manager>
</beans:beans>
例外:
Error creating bean with name 'org.springframework.security.filterChains': Cannot resolve reference to bean 'org.springframework.security.web.DefaultSecurityFilterChain#4' while setting bean property 'sourceList' with key [4]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.DefaultSecurityFilterChain#4': Cannot resolve reference to bean 'org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0' while setting constructor argument with key [2]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0': Cannot resolve reference to bean 'org.springframework.security.authentication.ProviderManager#0' while setting bean property 'authenticationManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.authentication.ProviderManager#0': Cannot resolve reference to bean 'smsAuthManager' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'smsAuthManager': Cannot resolve reference to bean 'sMSAuthenticationProvider' while setting constructor argument with key [0]; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'sMSAuthenticationProvider' is defined
答案 0 :(得分:0)
问题在您的例外中定义:
没有名为“sMSAuthenticationProvider&#39;已定义
要修复它,请确保定义bean。根据您的示例,它可能看起来像这样:
<beans:bean id="sMSAuthenticationProvider"
class="com.swivelsecure.userportal.SMSAuthenticationProvider"/>