Map<String, String> axOptional = new HashMap<String, String>();
Identifier i = verifyResponse(axRequired, axOptional);
if (i == null) {
log.info("Authentication Failed");
getResponse().setStatus(Status.CLIENT_ERROR_NOT_FOUND);
return new StringRepresentation("Authentication Failed");
}
log.info("Identifier = " + i.getIdentifier());
String id = i.getIdentifier();
if (id != null) {
// New Code, always return JSON and let filter handle any
// callback.
// TODO maybe move it to use Principal.
JSONObject obj = new JSONObject();
try {
obj.put("id", i.getIdentifier());
for (String s : axRequired.keySet()) {
obj.put(s, axRequired.get(s));
}
for (String s : axOptional.keySet()) {
obj.put(s, axOptional.get(s));
}
} catch (JSONException e) {
log.log(Level.WARNING, "Failed to get the ID!", e);
}
getResponse().setEntity(new JsonRepresentation(obj));
}
// cleanup of cookie
getResponse().getCookieSettings().remove(DESCRIPTOR_COOKIE);
CookieSetting disc = new CookieSetting(DESCRIPTOR_COOKIE, "");
disc.setMaxAge(0);
getResponse().getCookieSettings().add(disc);
// TODO save the identifier // send back to OAuth
return getResponse().getEntity();
}
String target = params.getFirstValue("openid_identifier");
if (target == null || target.length() == 0) {
// No target - might be Yadis discovery
String location = setXRDSHeader();
StringBuilder html = new StringBuilder();
html.append("<html><head><meta http-equiv=\"X-XRDS-Location\" content=\"");
html.append(location);
html.append("\"/></head></html>");
return new StringRepresentation(html.toString(),
MediaType.TEXT_HTML);
}
try {
StringBuilder returnToUrl = new StringBuilder();