Gemalto is now part of the Thales Group, find out more.

You are here

Get URL from Socket | Thales IoT Developer Community

December 2, 2016 - 5:28pm, 2289 views

Hello!
I have built an app with BGS5T which handles HTTP requests to manage an equipment. This is working pretty well but now I'm developing security measures for the system. 
In the following code, I create a socket with my network profile, socket that will handle my requests from the website:

server = (ServerSocketConnection) Connector.open("socket://:" + portoX + ";bearer_type=GPRS;access_point=" + APNX + ";username="+ LoginX + ";password=" + PasswordX + ";dns_value=" + DNSX+ ";timeout=0");

SocketConnection sc = (SocketConnection) server.acceptAndOpen();

When the connection is accepted, 

I open an inputstream,

is = openInputStream();

and read the content in that said stream to keep the http request and manipulate it. 

The only thing that I'm being able to keep is the IP of the website using the getAdress() method and the header of the http request.

Example:

"GET /api.html?ATCOMMAND=AT^....."

The thing is that I would like to get the URL from the client trying to connect to the modem. This would allow me to block undesired connections from other websites. I'm already doing this by IP, but I'm afraid that the website IP might change.
Since we're stuck to j2me library, I can't use tools that would make the task easier.
Any suggestions?

Thanks