0

I'm implementing a custom API on top of SBT. I'm doing this so I can manipulate and transform the response from connections before returning it to the user.

The basic auth with username and password is working. But I can't seem to find out how I can add the JSESSIONID header to ClientService (ClientService.Args) on a request before its sent.

Any idea how this can be done ?

rbrastad
  • 36
  • 2
  • I asked a team mate to look at this... but normally I search GitHub to look at https://github.com/OpenNTF/SocialSDK/blob/master/src/eclipse/plugins/com.ibm.sbt.core/src/com/ibm/sbt/services/client/ClientService.java you might look at protected boolean addParameter(StringBuilder b, boolean first, String name, int value) throws ClientServicesException { if (value != 0) { return addParameter(b, first, name, Integer.toString(value)); } return first; } – Paul Bastide Sep 18 '13 at 20:09

2 Answers2

1

Since REST is stateless, in theory you should not be needing JSESSIONID cookie, which is used for preserving state of loggedin user. However if you do wish to add that you should be doing it in below way :

In the specific endpoint class ( like BasicEndpoint.java for Basic Authentication ), look for the initialize method, it would be registering an interceptor, BasicInterceptor in this case. In process method of BasicInterceptor you can add the cookie like

request.setHeader("Cookie", "JESSION string goes here");

This code intercepts all outgoing requests and would add the cookie header.

Hope this helps.

0

when you make the request, the JSESSIONID cookie should already be in the response when you do the BASICAUTH.

Also JSESSIONID is not guaranteed to be the unique identifier for a WAS appserver.

Paul Bastide
  • 1,505
  • 4
  • 17
  • 22
  • I can't use the built in proxypass functionality due to my requirement to do some transformation before returning it to the user. That's why I want to copy the headers and pass them along on a new request to connections – rbrastad Sep 19 '13 at 06:26