As expected, the login page loads when a secure / secure resource is requested:
<login-config> <auth-method>FORM</auth-method> <realm-name>jdbc</realm-name> <form-login-config> <form-login-page>/login.xhtml</form-login-page> <form-error-page>/login.xhtml</form-error-page> </form-login-config> </login-config>
I understand that j_security_check will automatically switch to a secure / secure resource if authentication is successful:
<form method="post" action="j_security_check"> <input type="text" name="j_username"> <input type="password" name= "j_password"> </form>
However, I would like users to register (or login) to continue, so I used JSF 2.0: <h:form... , EL: #{loginBean.register()}... etc ... and I am doing authentication programmatically using Servlet 3.0:
public void register() { HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest(); try {
How to find out what the resource originally requested? Maybe:
- Get a "saved request" from a session (specific container)?
- Try in some way to access the "source request"? ()
- Anything related to the query manager (wild guess)?
- Use the header "referer" (bad idea)?
- Create a server authentication module (SAM) (not easy)?
Any advice would be greatly appreciated!
source share