tags:

views:

38

answers:

1

Hi!

I have a login page that I would like to show in https. After validating the user, I would like to transfer him back to http.

So I declared in web.xml

<security-constraint>
  <web-resource-collection>
   <web-resource-name>Login and Restricted Space URLs</web-resource-name>
   <url-pattern>/general/enter.jsf</url-pattern>
  </web-resource-collection>  
  <user-data-constraint>
   <transport-guarantee>CONFIDENTIAL</transport-guarantee>
  </user-data-constraint>
 </security-constraint>

 <security-constraint>
  <web-resource-collection>
   <web-resource-name>Rest of the Application</web-resource-name>
   <url-pattern>/general/home.jsf</url-pattern>
     </web-resource-collection>
  <user-data-constraint>
   <transport-guarantee>NONE</transport-guarantee>
  </user-data-constraint>
 </security-constraint>

and I see that the login page is in https.

But in my action:

public String doLogin() throws Exception {
  ...
  User user = service.getUserByNameAndCompany(name, company);
  ......
                return "/general/home.jsf";
 }

The bean redirects the user to

https ://mycomputer:8443/MYProject/general/home.jsf

and I would like it to be back

http: //mycomputer:8080/MYProject/general/home.jsf

How can I do it?

+2  A: 

JSF navigation will redirect you to a page within the same application (that means you can navigate only inside https: //mycomputer:8080/MYProject ).

What you can do is to navigate to a page like /general/redirect.jsf and from there use a header or javascript redirection to the url you want.

pakore
but the header or javascript probably need the full URL like:http: //mycomputer:8080/MYProject/general/home.jsfand I wouldn't want to put the full URL since the computer name/port/project may change. I would like it to be relevant to the application..
Odelya
Use a configuration file or so or change 8080/8443 to 80/443 so that you don't need to use port numbers, but just replace "https" by "http" in URL. Use `ExternalContext#redirect()` to redirect programmatically and then `return null` (or just declare method `void`).
BalusC
You can read the URL from the request and then parse and remove the "s" in the URL: You can do this in Javascript o programmatically in your backing bean as BalusC suggests.
pakore