コード例 #1
0
ファイル: GitHubImpl.java プロジェクト: jolivares/socialauth
 @Override
 public Response api(
     final String url,
     final String methodType,
     final Map<String, String> params,
     final Map<String, String> headerParams,
     final String body)
     throws Exception {
   LOG.info("Calling api function for url	:	" + url);
   Response response = null;
   try {
     response = authenticationStrategy.executeFeed(url, methodType, params, headerParams, body);
   } catch (Exception e) {
     throw new SocialAuthException("Error while making request to URL : " + url, e);
   }
   return response;
 }
コード例 #2
0
ファイル: GitHubImpl.java プロジェクト: jolivares/socialauth
  private Profile getProfile() throws Exception {
    String presp;

    try {
      Response response = authenticationStrategy.executeFeed(PROFILE_URL);
      presp = response.getResponseBodyAsString(Constants.ENCODING);
    } catch (Exception e) {
      throw new SocialAuthException("Error while getting profile from " + PROFILE_URL, e);
    }
    try {
      LOG.debug("User Profile : " + presp);
      JSONObject resp = new JSONObject(presp);
      Profile p = new Profile();
      p.setValidatedId(resp.getString("id"));
      if (resp.has("name")) {
        p.setFullName(resp.getString("name"));
      }
      if (resp.has("email")) {
        String email = resp.getString("email");
        if (!"null".equals(email)) {
          p.setEmail(resp.getString("email"));
        }
      }
      if (resp.has("location")) {
        p.setLocation(resp.getString("location"));
      }
      if (resp.has("avatar_url")) {
        p.setProfileImageURL(resp.getString("avatar_url"));
      }
      p.setProviderId(getProviderId());
      userProfile = p;
      return p;
    } catch (Exception ex) {
      throw new ServerDataException("Failed to parse the user profile json : " + presp, ex);
    }
  }