Forums de discussion

Send a POST from JSF portlet

Micael Ericsson, modifié il y a 10 années.

Send a POST from JSF portlet

Regular Member Publications: 169 Date d'inscription: 11/12/12 Publications récentes
I am developing a JSF portlet which has to send a HTTP POST to our CAS (security management server) to verify username and password.

Right now it's working with a standard <form> and standard <input> HTML fields.

But I need to implement form and input fields using JSF components. I see 2 possible solutions:

1) Keep code as is and change form -> h:form and input to h:inputText etc. This implementation gives improper ids for username and password. With JSF/Portlet the ids are prefixed with "j2345:i234" (or similar). Then CAS which is expecting "uid" gets "j2345:i234:uid" and can't handle input.
- Is it possible to "clear" component id to only "uid".

2) As 1) but a redirect from within JSF code. This could solve id problem. But according to my tests and other forum posts it is not possible to send a HTTP POST from within a Jsf Portlet.

A third solution would be to have the correct JSF page (with jsf components) to call a html-page with data and a JavaScript which do autopost. This is not a accepted solution for us.

Suggestions to:
1) "clear" component ids in post.
2) possibility to send a HTTP POST from with a JSF portlet.
other suggestions?
thumbnail
David H Nebinger, modifié il y a 10 années.

RE: Send a POST from JSF portlet

Liferay Legend Publications: 14919 Date d'inscription: 02/09/06 Publications récentes
Do you have a non-standard CAS implementation? Liferay does have some CAS authentication mechanisms, have you tried those?
Micael Ericsson, modifié il y a 10 années.

RE: Send a POST from JSF portlet

Regular Member Publications: 169 Date d'inscription: 11/12/12 Publications récentes
David H Nebinger:
Do you have a non-standard CAS implementation? Liferay does have some CAS authentication mechanisms, have you tried those?


I third party has delivered the CAS implementation. Our portal an other parts are included. We cannot use Liferays CAS authentication methods.
thumbnail
Kyle Joseph Stiemann, modifié il y a 10 années.

RE: Send a POST from JSF portlet

Liferay Master Publications: 760 Date d'inscription: 14/01/13 Publications récentes
Hi Micael,
Like David said, the typical approach would be to use the out-of-the-box Liferay sign-in portlet with the Liferay CAS autologin feature. Perhaps you could modify the CASAutoLogin.java class to suit your needs?

Otherwise you can use a JSF portlet like the JSF2 Login Portlet.

- Kyle
Micael Ericsson, modifié il y a 10 années.

RE: Send a POST from JSF portlet

Regular Member Publications: 169 Date d'inscription: 11/12/12 Publications récentes
It is not possible to use out-of-the-box or modified version of Liferay sign-in and CAS autologin feature.

We simplify this to:
- From a JSF Portlet page send a POST to a specific URL (which resides on another server).
- Two public input param and 4 hidden param.

The other side requires:
- a http post
- the params uid and password. Prefix id versions like J123123:J231123:uid doesn't work.

Solution from:
- xhtml page. A can't find a way create a POST with correct ids.
or
- ManagedBean. I cant find a way to send a HTTP POST from within a ManagedBean.
thumbnail
Kyle Joseph Stiemann, modifié il y a 10 années.

RE: Send a POST from JSF portlet

Liferay Master Publications: 760 Date d'inscription: 14/01/13 Publications récentes
If you use an h:form, the JSF lifecycle will be invoked and the HTTP_POST will not be compatible with your CAS authenticator. Maybe, you could use the backing bean of the JSF portlet with commons-httpclient (now called Apache HttpComponents) to create a subsequent POST programmatically, which can be sent to your CAS authenticator. This also enables you to hide that fact that you are authenticating against another service. This might not work though, because it is bypassing the Liferay login mechanism.

- Kyle