I'm a little new to Spring, but I will try to help you. Interception-url looks great.
I do not think the authenticator provider is right. Take a look at my code:
<beans:bean id="MyUserDetailsService" class="path.to.MyAuthenticationService"/>
<beans:bean id="userDetailsService" class="org.springframework.security.userdetails.hierarchicalroles.UserDetailsServiceWrapper" > <beans:property name="roleHierarchy" ref="roleHierarchy" /> <beans:property name="userDetailsService"> <beans:ref bean="MyUserDetailsService"/> </beans:property> </beans:bean> <authentication-provider user-service-ref="userDetailsService"> <password-encoder hash="md5"/> </authentication-provider>
You may not need the role of a hierarchy.
You have a jsp page login form. The form should start like this:
<form:form modelAttribute="login">
You must also match the corresponding fields.
<form:input path="login"> <form:password path="password">
in your context-security.xml application, specify the login page:
<form-login login-page="/login.jsp" default-target-url="/login.html" always-use-default-target="true" authentication-failure-url="/login.jsp?login_error=1"/>
login.html must be mapped to your LoginController.java, which extends BaseController and implements a login method that takes at least HttpServletRequest and Model as parameters. Then mine works by calling the following Spring class / methods:
String userlogin = SecurityContextHolder.getContext().getAuthentication().getName();
If your CustomAuthenticationProvider is implemented correctly, you can (hopefully) get user details from your model and finally
return "redirect:homepage.html";
Maybe I missed something, if you still have problems, let me know in the comment.
Robbr
source share