I have my application on a test server being executed exclusively over https. When I navigate without redirecting, it works perfectly:
Example:
<p:menuitem value="#{msg.customerScreen}" url="/restrict/customer.xhtml" />
<p:menuitem value="#{msg.productScreen}" url="/restrict/product.xhtml" />
But when I need to redirect to another page, it is redirecting to http instead of https. When using over http, it works perfectly:
<p:commandLink ajax="false" action="/commerce/store.xhtml?faces-redirect=true">
<h:graphicImage library="images/BTN" name="btn_to_shop.gif"/>
</p:commandLink>
As a workaround I tryed to reconstruct the URL:
<p:commandLink ajax="false" action="#{authorizerBean.getCompleteURL('/commerce/store.xhtml?faces-redirect=true')}">
<h:graphicImage library="images/BTN" name="btn_to_shop.gif"/>
</p:commandLink>
public String getCompleteURL(String page) {
try {
FacesContext ctxt = FacesContext.getCurrentInstance();
ExternalContext ext = ctxt.getExternalContext();
URI uri = new URI(ext.getRequestScheme(), null, ext.getRequestServerName(), ext.getRequestServerPort(), ext.getRequestContextPath(), null, null);
return uri.toASCIIString() + page;
} catch (URISyntaxException e) {
throw new FacesException(e);
}
}
The method getCompleteURL is being called and returning the URL correclty, but JSF is not redirecting to the new URL.
JBoss is receiving an HTTP connection. Who manages the HTTPS is Apache, that redirects to JBoss:
<VirtualHost *:443>
...
ProxyPass / http://server:8080/
ProxyPassReverse / http://server:8080/
</VirtualHost>
I would prefer to solve this issue without using the getCompleteURL, but if it is not possible, please help me with other approaches.