use of org.xdi.oxauth.client.UserInfoClient in project oxAuth by GluuFederation.
the class UserInfoAction method exec.
public void exec() {
try {
UserInfoRequest request = new UserInfoRequest(accessToken);
request.setAuthorizationMethod(authorizationMethod);
UserInfoClient client = new UserInfoClient(userInfoEndpoint);
client.setRequest(request);
client.exec();
showResults = true;
requestString = client.getRequestAsString();
responseString = client.getResponseAsString();
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
use of org.xdi.oxauth.client.UserInfoClient in project oxAuth by GluuFederation.
the class RpDemoServlet method doGet.
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
try {
resp.setContentType("text/html;charset=utf-8");
PrintWriter pw = resp.getWriter();
pw.println("<h1>RP Demo</h1>");
pw.println("<br/><br/>");
String accessToken = (String) req.getSession().getAttribute("access_token");
String userInfoEndpoint = (String) req.getSession().getAttribute("userinfo_endpoint");
LOG.trace("access_token: " + accessToken + ", userinfo_endpoint: " + userInfoEndpoint);
UserInfoClient userInfoClient = new UserInfoClient(userInfoEndpoint);
userInfoClient.setExecutor(Utils.createTrustAllExecutor());
UserInfoResponse response = userInfoClient.execUserInfo(accessToken);
LOG.trace("UserInfo response: " + response);
if (response.getStatus() != 200) {
pw.print("Failed to fetch user info claims");
return;
}
pw.println("<h2>User Info Claims:</h2>");
pw.println("<br/>");
for (Map.Entry<String, List<String>> entry : response.getClaims().entrySet()) {
pw.print("Name: " + entry.getKey() + " Value: " + entry.getValue());
pw.println("<br/>");
}
} catch (Exception e) {
LOG.error(e.getMessage(), e);
throw new RuntimeException(e);
}
}
Aggregations