I’m using BOS 5.10 - Ubuntu, with java-7-openjdk-amd64.
I’ve been searching for a month for an answer how to retrieve the Initiator’s ip address but with no success, no thread about this subject in the forums answers this question in details.
Could anyone please help me in the most simple way to be able to run a Script-Connector (groovy) that can get the loggedUser’s IP address?
it is surely not:
java.net.InetAddress.getLocalHost().getHostAddress();
because this returns the local ip of the server that runs bonita-server.
I think i’m looking for something like: servletRequest.getRemoteAddr(), to get a remote address and not local, but javax.servlet.ServletRequest.getRemoteAddr() does not exist in BOS 5.10 (or maybe i’m wrong but the groovy editor can’t find it).
On the other hand, i don’t want to force the client side to run Java locally in order for this function to work.
If there is any solution with a built-in function/API I think it will be best.
Please if anyone can guide me how to do it and be able to store that data in a form-variable i’l be greatful!
Thanks.
Your issue is that the groovy script is in the process classloader, whereas the servlet is at the server level. They don’t see each other.
I’ve never tried it but here is a potential a solution:
- add a servlet filter to the bonita webapp (in the web.xml). Its goal would be to filter url accessing Bonita forms.
- grab from the URL the information required by a Bonita api call to update an Activity variable (process id, activity id, etc…)
- update your variable using the Bonita API from the the Servlet Filter (you have access to javax.servlet.ServletRequest.getRemoteAddr from the filter)
Hope it helps,
Francois
There is currently no easier way that I can think of to provide a connector with the visibility on the ServletRequest.
Bonitasoft Professionnal Services Team could help you with such development if needed.
In the mean time, are you sure that your client will have a static ip address?
What is your use case?
If you are authenticated in the user XP you can retrieve the name of the loggedUser from you groovy script. Isn’t it good enought?
Hi,
What is your client? Are you using the User XP?
yes i’m using the user XP
Question,
Doesn’t it seem to you that grabbing the loggedUser’s IP address should be easier and somehow already built-in ? this is a lot of hassle just to get something so basic.
In my case , logging the ip address of a person that submits a form is used as a signature of the person.
Is there or could there be an easier answer on how to run a connector in a task in the form that could get the loggedUser’s IP address?
thanks.
I agree. Not only the ip address actually but the webapp context in general.
This is an improvement candidate for 7.x
having that said, could you come up with a simpler solution perhaps?
also the answer that you have posted is too complicated for my knowledge and i can seem to understand where to begin or what to actually do.
thanks
I don’t think there is an easier solution in v5. Our Professional Services could help you with such implementation.
In the mean time, I was wondering: are you sure that you clients have static ip?
Why not just using the loggedUser provided by Bonita?