I have a problem. I want to get Liferay user ID in a servlet that runs in another Tomcat, not in Tomcat on which Liferay runs. If both runs in same Tomcat, no problem, Liferay API works perfectly. But in this case, when I use 'UserLocalServiceUtil.decryptUserId' in order to decrypt user ID present in cookie, I get a 'BeanLocator is null' exception.
What can I do? Has this any solution?
You can consume Liferay's web services to get User details from Liferay from your servlet. You can choose from SOAP WebServices or JSON WebServices.
My recommendation in you scenario is to use JSON WebService - get-user-by-email-address method (like this: http://<host>:<port>/api/jsonws?signature=/user/get-user-by-email-address-2-companyId-emailAddress) to get User object, and get UserId from it.
Related
I have a Java-EE application that works with JSF (ManagedBean, ManagedProperty, ect ...) and Spring framework. I need to be able to retrieve data via a javascript form sent from an external website. I have opened the rights to authorize the CORS (Cross Origin or Cross Domain).
I would like to know what is the best way to grab an external form with JSF so that it is processed by my ManagedBean.
To make my question more explicit I made a diagram
==============
EDIT
The application works with JSF, I'm looking for a way to retrieve data (from a Javascript form on an external site) in a ManagedBean under JSF. I tried to retrieve this data by creating a Java-EE standard servlet and using the doPost ... methods of HttpServlet. But this solution does not work (this was the subject of my previous question on S.O). Several people told me that in a web application do not mix Java-EE standard and JSF, it is either Servlet or JSF. I made a diagram (above) explaining quickly what I am trying to do.
To recap: I would like to retrieve data from an external website (via a Javascript form) in the ManagedBean of my application.
==============
I've already tried with a standard Java-EE servlet but it's not the right way. Indeed, with a standard servlet I can recover the data from the form but I can not access the ManagedBean. I must therefore have abandoned this hypothesis.
I did not find a similar question about Stackoverflow, If necessary I can give more indications.
Thank you for your help.
When consuming a remote portlet with wsrp, it is possible to send additional attributes and have access to them in the remote portlet? When setting a custom attribute to the current request object in liferay this attribute isn't accessible in the remote portlet, because it's a totally different session. Is there any best practice to solve this? Or isn't this a use case when consuming remote portlets with wsrp?
I'm creating TestNG tests for Java classes that are normally used from Xpages application. Since they have to call some legacy LotusScript code, I have to use agent.runWithDocumentContext call.
From Xpages this runs fine. But when I call this method from TestNG suite run from Domino Designer, I get
NotesException: Unable to pass doc context - Caller must run with user authority
I create session normally using NotesFactory.createSession()
Database is on test server and agent has Run As Web User property set, since it is called correctly form xpages in the app.
Everything runs on 9.0.1 Domino
This might give you a hint how to solve your problem, to get your code to run in a user context.
I want my Domino Servlet to get an authenticated user session
In my JSF 2.2 bases application I created a wizard which is based on #ConversationScope. To deal with errors I added CDI Conversation Filter to my web.xml.
My first question is about the right url-pattern for the filter-mapping. My Wizard runs behind the url /report/*. If I use this as pattern, all other pages throw the following exception:
javax.servlet.ServletException: A request must be associated with the context in order to load the known conversations
So, i had to use "/*" as pattern, which worked fine so far.
But now, I want to integrate container-managed security. When requesting the restricted resource, the mentioned error is thrown, when redirecting to login-page.
Does anybody know, how to solve that?
Thanks in advance.
I am using Grails with the Spring Security plugin.
I have crafted a custom filter, authentication provider, and token and registered them as beans and into filter chain:
SpringSecurityUtils.clientRegisterFilter('myFilter',SecurityFilterPosition.SECURITY_CONTEXT_FILTER.order + 10)
(I am not really sure what the order should be)
I POST to j_spring_security_check.
All seems to run smoothly to my successfulAuthentication where I set:
SecurityContextHolder.getContext().setAuthentication(authResult);
with no errors and SecurityContextHolder.getContext().getAuthentication() is set.
However Grails redirects me to login failed page.
Is something wrong with the j_spring_security_check page? Where is the error?
It was the url j_spring_security_check - it somehow rewrote the security context.
So on using custom filters DO NOT use post url "j_spring_security_check", not necessary also.