Package org.brickred.socialauth.exception

Examples of org.brickred.socialauth.exception.SocialAuthException


    if (accessGrant != null) {
      accessToken = accessGrant.getKey();
      LOG.debug("Obtaining user profile");
      return getProfile();
    } else {
      throw new SocialAuthException("Access token not found");
    }
  }
View Full Code Here


    Profile profile = new Profile();
    Response serviceResponse;
    try {
      serviceResponse = authenticationStrategy.executeFeed(PROFILE_URL);
    } catch (Exception e) {
      throw new SocialAuthException(
          "Failed to retrieve the user profile from  " + PROFILE_URL,
          e);
    }
    String res;
    try {
      res = serviceResponse.getResponseBodyAsString(Constants.ENCODING);
    } catch (Exception exc) {
      throw new SocialAuthException("Failed to read response from  "
          + PROFILE_URL, exc);
    }

    JSONObject jobj = new JSONObject(res);
    JSONObject rObj;
    JSONObject uObj;
    if (jobj.has("response")) {
      rObj = jobj.getJSONObject("response");
    } else {
      throw new SocialAuthException(
          "Failed to parse the user profile json : " + res);
    }
    if (rObj.has("user")) {
      uObj = rObj.getJSONObject("user");
    } else {
      throw new SocialAuthException(
          "Failed to parse the user profile json : " + res);
    }
    if (uObj.has("id")) {
      profile.setValidatedId(uObj.getString("id"));
    }
View Full Code Here

    Response serviceResponse;
    try {
      serviceResponse = authenticationStrategy.executeFeed(CONTACTS_URL);
    } catch (Exception e) {
      throw new SocialAuthException("Error while getting contacts from "
          + CONTACTS_URL, e);
    }
    if (serviceResponse.getStatus() != 200) {
      throw new SocialAuthException("Error while getting contacts from "
          + CONTACTS_URL + "Status : " + serviceResponse.getStatus());
    }
    String respStr;
    try {
      respStr = serviceResponse
          .getResponseBodyAsString(Constants.ENCODING);
    } catch (Exception exc) {
      throw new SocialAuthException("Failed to read response from  "
          + CONTACTS_URL, exc);
    }
    LOG.debug("User Contacts list in JSON " + respStr);
    JSONObject resp = new JSONObject(respStr);
    List<Contact> plist = new ArrayList<Contact>();
    JSONArray items = new JSONArray();
    if (resp.has("response")) {
      JSONObject robj = resp.getJSONObject("response");
      if (robj.has("friends")) {
        JSONObject fobj = robj.getJSONObject("friends");
        if (fobj.has("items")) {
          items = fobj.getJSONArray("items");
        }
      } else {
        throw new SocialAuthException(
            "Failed to parse the user profile json : " + respStr);
      }
    } else {
      throw new SocialAuthException(
          "Failed to parse the user profile json : " + respStr);
    }
    LOG.debug("Contacts Found : " + items.length());
    for (int i = 0; i < items.length(); i++) {
      JSONObject obj = items.getJSONObject(i);
View Full Code Here

   * @throws Exception
   */
  @Override
  public Response updateStatus(final String msg) throws Exception {
    LOG.warn("WARNING: Not implemented for FourSquare");
    throw new SocialAuthException(
        "Update Status is not implemented for FourSquare");
  }
View Full Code Here

    LOG.debug("Calling URL : " + url);
    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;
  }
View Full Code Here

  @Override
  public Response uploadImage(final String message, final String fileName,
      final InputStream inputStream) throws Exception {
    LOG.warn("WARNING: Not implemented for FourSquare");
    throw new SocialAuthException(
        "Update Status is not implemented for FourSquare");
  }
View Full Code Here

      throws Exception {
    if (requestParams.containsKey(STATE)) {
      String stateStr = requestParams.get(STATE);
      System.out.println("-------------" + stateStr);
      if (!state.equals(stateStr)) {
        throw new SocialAuthException(
            "State parameter value does not match with expected value");
      }
    }
    return doVerifyResponse(requestParams);
  }
View Full Code Here

    Response serviceResponse = null;
    try {
      serviceResponse = authenticationStrategy.executeFeed(CONNECTION_URL
          + authenticationStrategy.getAccessGrant().getKey());
    } catch (Exception ie) {
      throw new SocialAuthException(
          "Failed to retrieve the contacts from " + CONNECTION_URL,
          ie);
    }
    Element root;
    try {
View Full Code Here

      serviceResponse = authenticationStrategy.executeFeed(
          UPDATE_STATUS_URL
              + authenticationStrategy.getAccessGrant().getKey(),
          MethodType.POST.toString(), null, headerParams, msgBody);
    } catch (Exception ie) {
      throw new SocialAuthException("Failed to update status on "
          + UPDATE_STATUS_URL, ie);
    }
    LOG.debug("Status Updated and return status code is : "
        + serviceResponse.getStatus());
    // return 201
View Full Code Here

    Response serviceResponse = null;
    try {
      serviceResponse = authenticationStrategy.executeFeed(PROFILE_URL
          + authenticationStrategy.getAccessGrant().getKey());
    } catch (Exception e) {
      throw new SocialAuthException(
          "Failed to retrieve the user profile from  " + PROFILE_URL,
          e);
    }
    if (serviceResponse.getStatus() != 200) {
      throw new SocialAuthException(
          "Failed to retrieve the user profile from  " + PROFILE_URL
              + ". Staus :" + serviceResponse.getStatus());
    }

    Element root;
View Full Code Here

TOP

Related Classes of org.brickred.socialauth.exception.SocialAuthException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.