I have a webservice call to get an authorization token and use it for subsequent webservice calls. Now what we did earlier was when we made some kind of web service call, first we make a marker web service, and then we make a call for the actual web service.
The method for obtaining the token is shown below. Basically, what this code does is call the webservice to get the token and use GSON to parse the response and get the token.
public static String getAuthTicket() {
String authTicket = null;
HttpResponse httpResponse = getAuthResponse();
String body;
if (httpResponse.getStatusLine().getStatusCode() == 200) {
try {
body = IOUtils.toString(httpResponse.getEntity().getContent());
Gson gson = new GsonBuilder().disableHtmlEscaping().create();
ResponseTicket responseTicket = gson.fromJson(body, ResponseTicket.class);
authTicket = responseTicket.getTicket();
} catch (UnsupportedOperationException e) {
LOGGER.error("UnsupportedOperationException : ",e);
} catch (IOException e) {
LOGGER.error("IO Exception : ",e);
}
}
return authTicket;
}
This has obviously led to performance issues. Therefore, the party providing the web service for receiving the token made the token valid for 30 minutes.
, , , - 30. 30, , token .
, , , authtoken - .
. , .