public void acceptRepresentation(final Representation entity) throws ResourceException { final Form form = getRequest().getEntityAsForm(); final String serviceUrl = form.getFirstValue("serviceTicketUrl"); try { final Assertion authentication = this.centralAuthenticationService.validateServiceTicket( serviceTicketId, new SimpleWebApplicationServiceImpl(serviceUrl, this.httpClient)); if (authentication.getChainedAuthentications().size() > 0) { // Iterate through each of the ChainedAuthentications and put them into the JSonArray JSONArray jsonResult = new JSONArray(); for (Authentication auth : authentication.getChainedAuthentications()) { // Create the principle JSONObject principle = createJSONPrinciple(auth); JSONObject jsonAuth = new JSONObject(); jsonAuth.put("authenticated_date", auth.getAuthenticatedDate()); jsonAuth.put("attributes", principle); jsonResult.add(jsonAuth); } getResponse().setEntity(jsonResult.toJSONString(), MediaType.TEXT_PLAIN); } else { getResponse() .setEntity( java.lang.String.format("\"{\"authenticated\":\"false\"}\""), MediaType.TEXT_PLAIN); } } catch (final TicketException e) { log.error(e.getMessage(), e); getResponse() .setStatus(Status.CLIENT_ERROR_NOT_FOUND, "TicketGrantingTicket could not be found."); } catch (final Exception e) { log.error(e.getMessage(), e); getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST, e.getMessage()); } }