Does OpenId + JSF redirect the user to the page that he enters?

I am using OpenId4Java with a JSF application. I have added security restrictions to my web.xml something like this.

<security-constraint> <web-resource-collection> <web-resource-name>Restricted</web-resource-name> <url-pattern>/core/*</url-pattern> <http-method>GET</http-method> <http-method>POST</http-method> </web-resource-collection> </security-constraint> <login-config> <auth-method>FORM</auth-method> <form-login-config> <form-login-page>/user/login.xhtml</form-login-page> <form-error-page>/user/logout.xhtml</form-error-page> </form-login-config> </login-config> 

Now that the launch of the application and the user want to access

http: //www.somehost: 8080 / myapp / core / abc.xhtml

using web.xml , I can show the user the login page, now I put the login with openid, like Google, Yahoo now my question is how can I tell openid that my return url is

http: //www.somehost: 8080 / myapp / core / abc.xhtml

Or if the user is from

http: //www.somehost: 8080 / myapp / core / xyz.xhtml

this URL, after successful login, the user will be redirected to this page.

+6
source share
2 answers

To get the source URL that the user tried to access, try using the RequestDispatcher.FORWARD_REQUEST_URI variable.

This variable will only be available if you are redirected to the login page from another restricted page. And therefore, please remember that you have a default URL if the user directly gets to the login page.

As rrufai pointed out, once the original URL requested by the user is available, you can follow the steps mentioned in this article to redirect to that URL when authentication is complete.

0
source

Use redirection for direct control on the next page.

 String returnToUrl = returnToUrl("/nextPage.xhtml"); FacesContext.getCurrentInstance().getExternalContext().dispatch(returnToUrl); 

Look at this:

http://blog.enterpriselab.ch/tdmarti/2011/04/06/openid-in-a-web-application-based-on-java-ee-and-jsf-2-0/

Update:

To determine from which page request, please refer to these posts:

How to get previous page url from request to servlet after dispatcher.forward (request, response)

How to get the source URL of a request from a servlet / jsp after redirecting multiple servlets

http://www.coderanch.com/t/361942/Servlets/java/Track-Jsp-request-coming-Servlet

0
source

All Articles