cr.setParameters(parameters);
resp.getChallengeRequests().add(cr);
resp.setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
} else {
getLogger().info("Found Access Token " + accessToken);
ClientResource authResource = new CookieCopyClientResource(
validateRef);
JSONObject request;
try {
request = createValidationRequest(accessToken, req);
// Representation repr = this.createJsonRepresentation(request);
Representation repr = new JsonStringRepresentation(request);
getLogger().info("Posting to validator... json = " + request);
// RETRIEVE JSON...WORKAROUND TO HANDLE ANDROID
Representation r = authResource.post(repr);
getLogger().info("After posting to validator...");
repr.release();
getLogger().info(
"Got Respose from auth resource OK "
+ r.getClass().getCanonicalName());
JsonRepresentation returned = new JsonRepresentation(r);
// GET OBJECT
JSONObject response = returned.getJsonObject();
boolean authenticated = response.getBoolean("authenticated");
if (response.has("tokenOwner"))
this.setUser(req, response, accessToken);
String error = null;
if (response.has("error"))
error = response.getString("error");
getLogger().info("In Auth Filer -> " + authenticated);
// Clean-up
returned.release();
r.release();
authResource.release();
if (authenticated)
return true;
// handle any errors:
handleError(error, resp);
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
if (authResource != null) {
authResource.getResponse().release();
authResource.release();
}
}
}
return false;