मैं प्रमाणीकरण उद्देश्य के लिए स्प्रिंग 3.1 का उपयोग कर रहा हूं।एकाधिक लॉगिन पृष्ठों के लिए वसंत 3.x कॉन्फ़िगरेशन
मेरे आवश्यकता:
- दो अलग प्रवेश पृष्ठों। एक ग्राहक के लिए और दूसरे कर्मचारी के लिए।
- सफल प्रमाणीकरण के बाद प्रत्येक को संबंधित सफल यूआरएल में भेजा जाएगा।
मेरे वसंत सुरक्षा विन्यास:
<sec:http pattern="/resources/**" security="none" />
<sec:http auto-config="true">
<sec:intercept-url pattern="/**" access="IS_AUTHENTICATED_ANONYMOUSLY" />
<sec:intercept-url pattern="/customer/**" access="ROLE_CUSTOMER" />
<sec:intercept-url pattern="/employee/**" access="ROLE_EMPLOYEE" />
</sec:http>
<bean id="springSecurityFilterChain" class="org.springframework.security.web.FilterChainProxy">
<sec:filter-chain-map path-type="ant">
<sec:filter-chain pattern="/**"
filters="authenticationProcessingFilterForCustomer,authenticationProcessingFilterForEmployee" />
</sec:filter-chain-map>
</bean>
<bean id="authenticationProcessingFilterForCustomer"
class="org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter">
<property name="authenticationManager" ref="authenticationManagerForCustomer" />
<property name="filterProcessesUrl" value="/j_spring_security_check_for_customer" />
<property name="authenticationSuccessHandler" ref="customerSuccessHandler" />
<property name="authenticationFailureHandler" ref="customerFailureHandler" />
</bean>
<bean id="customerSuccessHandler"
class="org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler">
<property name="defaultTargetUrl" value="/customer/index.html" />
</bean>
<bean id="customerFailureHandler"
class="org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler">
<property name="defaultFailureUrl" value="/customer.html?login_error=1" />
</bean>
<bean id="authenticationManagerForCustomer"
class="org.springframework.security.authentication.ProviderManager">
<property name="providers">
<list>
<ref bean="customCustomerAuthenticationProvider" />
</list>
</property>
</bean>
<bean id="customCustomerAuthenticationProvider" class="com.edu.CustomerCustomAuthenticationProvider">
<property name="userDetailsService">
<bean class="com.edu.CustomerUserDetailsService" />
</property>
</bean>
<bean id="authenticationProcessingFilterForEmployee"
class="org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter">
<property name="authenticationManager" ref="authenticationManagerForEmployee" />
<property name="filterProcessesUrl" value="/j_spring_security_check_for_employee" />
<property name="authenticationSuccessHandler" ref="employeeSuccessHandler" />
<property name="authenticationFailureHandler" ref="employeeFailureHandler" />
</bean>
<bean id="employeeSuccessHandler"
class="org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler">
<property name="defaultTargetUrl" value="/employee/index.html" />
</bean>
<bean id="employeeFailureHandler"
class="org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler">
<property name="defaultFailureUrl" value="/employee.html?login_error=1" />
</bean>
<bean id="authenticationManagerForEmployee"
class="org.springframework.security.authentication.ProviderManager">
<property name="providers">
<list>
<ref bean="customEmployeeAuthenticationProvider" />
</list>
</property>
</bean>
<bean id="customEmployeeAuthenticationProvider" class="com.edu.EmployeeCustomAuthenticationProvider">
<property name="userDetailsService">
<bean class="com.edu.EmployeeUserDetailsService" />
</property>
</bean>
<sec:authentication-manager alias="authenticationManager">
<sec:authentication-provider ref="customCustomerAuthenticationProvider" />
<sec:authentication-provider ref="customEmployeeAuthenticationProvider" />
</sec:authentication-manager>
दोनों CustomAuthenticationProvider समर्थन विधि को लागू किया है इस प्रकार है:
public boolean supports(Class<? extends Object> authentication) {
return UsernamePasswordAuthenticationToken.class.isAssignableFrom(authentication);
}
, ऐप्लिकेशन को लॉन्च करने प्रमाणित करने के प्रयास के बाद, संदेश प्रवेश पृष्ठों में दिखाया गया हैं :
आपका लॉगिन प्रयास एन था ओटी सफल, पुनः प्रयास करें।
कारण: नहीं AuthenticationProvider org.springframework.security.authentication.UsernamePasswordAuthenticationToken
मैं वसंत 3.1 उपयोग कर रहा हूँ के लिए मिल गया। किसी भी मदद की सराहना की।
धन्यवाद
शायद http://stackoverflow.com/questions/4783063/configuring-spring-security-3-x-to-have-multiple-entry- पॉइंट्स से संबंधित या डुप्लिकेट से संबंधित है? – Raghuram
"एकाधिक प्रविष्टि बिंदुओं के लिए स्प्रिंग सुरक्षा 3.x को कॉन्फ़िगर करने" के लिए हल समाधान, विभिन्न प्रकार के उपयोगकर्ता के लिए एकल प्रविष्टि बिंदु और एकल सफल पृष्ठ है। मुद्दा मेरे पास एकाधिक प्रविष्टि बिंदु है और प्रत्येक का अपना सफल पृष्ठ है। –
@ManasSahu क्या आप अपने प्रश्न में अपने कस्टम प्रमाणीकरण प्रदाताओं के 'समर्थन()' विधियों का कोड जोड़ सकते हैं? – Ritesh