1

In my project, I am using SSL but it works for all pages.I want to use it for only a login page, after that page it should revert to HTTP protocol. How can i do that? I found a way below, but it does not work.

    <security-constraint>
    <web-resource-collection>
        <web-resource-name>Notify page, accessed internally by application</web-resource-name>
        <url-pattern>/Login.xhtml</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>Entire Site</web-resource-name>
        <url-pattern>/*</url-pattern>
    </web-resource-collection>
    <user-data-constraint>
        <transport-guarantee>NONE</transport-guarantee>
    </user-data-constraint>
</security-constraint>

My project is a JSF 2.0 project, I am using Eclipse Helios and Tomcat 7.0.

Thanks.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
amrXX
  • 13
  • 5

1 Answers1

1

That's not possible. When the session is created by HTTPS request, then it is not available to HTTP requests. Your best bet is to create a non-secure cookie yourself during login and maintain the login by that instead.

Map<String, Object> properties = new HashMap<String, Object>();
properties.put("secure", false);
externalContext.addResponseCookie(name, value, properties);

But think once again about this, what's the point of the HTTPS login then? If you go back to HTTP after HTTPS and you want to keep the user logged-in, then you're required to set the session cookie unsecure. This way hackers will still be able to sniff the session ID in the cookie to do a session fixation hack. With login over HTTPS you only prevent that hackers learn about the actual username/password, but that has no point anymore once a hacker figures the session ID in the cookie.

I'd say, forget the switch and stick to HTTPS all the time after login.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Thanks for your useful answer. I want to switch betweeb HTTP and HTTPS after login because I am using Primefaces and some of its components(for example file uploader) give error when it is HTTPS. I do not know why but it is happening and for this I want to set SSL only to login page. If you can help about Primefaces error, of course it would be great. – amrXX May 11 '11 at 16:16
  • Ask a new question or report this issue to PrimeFaces. – BalusC May 11 '11 at 16:27