Package org.brickred.socialauth.exception

Examples of org.brickred.socialauth.exception.SocialAuthException


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


    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);
View Full Code Here

    try {
      serviceResponse = authenticationStrategy.executeFeed(
          UPDATE_STATUS_URL, MethodType.POST.toString(), null, null,
          strb.toString());
      if (serviceResponse.getStatus() != 200) {
        throw new SocialAuthException(
            "Status not updated. Return Status code :"
                + serviceResponse.getStatus());
      }
    } catch (Exception e) {
      throw new SocialAuthException(e);
    }
    return serviceResponse;

  }
View Full Code Here

    try {
      Response response = authenticationStrategy
          .executeFeed(CONTACTS_URL);
      respStr = response.getResponseBodyAsString(Constants.ENCODING);
    } catch (Exception e) {
      throw new SocialAuthException("Error while getting contacts from "
          + CONTACTS_URL, e);
    }
    try {
      LOG.debug("User Contacts list in json : " + respStr);
      JSONObject resp = new JSONObject(respStr);
View Full Code Here

    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;
  }
View Full Code Here

            message = message.toLowerCase();
          }
          if (message.contains("session has expired")) {
            throw new AccessTokenExpireException();
          } else {
            throw new SocialAuthException("Message :: " + message);
          }
        } else {
          throw new SocialAuthException("Message :: " + respStr);
        }

      } catch (Exception e) {
        if (AccessTokenExpireException.class.isInstance(e)) {
          new AccessTokenExpireException();
        } else if (SocialAuthException.class.isInstance(e)) {
          throw new SocialAuthException(e.getMessage());
        }
      }
    }
  }
View Full Code Here

        MethodType.GET.toString(), null, null);
    String result = null;
    try {
      result = response.getResponseBodyAsString(Constants.ENCODING);
    } catch (Exception e) {
      throw new SocialAuthException(e);
    }

    Map<String, Object> attributes = new HashMap<String, Object>();
    String[] pairs = result.split("&");
    AccessGrant ag = new AccessGrant();
    for (String pair : pairs) {
      String[] kv = pair.split("=");
      if (kv.length != 2) {
        throw new SocialAuthException(
            "Unexpected response from refresh token call");
      } else {
        if (kv[0].equals("access_token")) {
          ag.setKey(kv[1]);
        } else if (kv[0].equals("expires")) {
View Full Code Here

    LOG.debug("Preparing to get Access Token");
    LOG.debug("Given Access Token URL : " + accessTokenURL);
    LOG.debug("Given Request Token : " + reqToken.toString());

    if (reqToken.getKey() == null || reqToken.getKey().length() == 0) {
      throw new SocialAuthException(
          "Key in Request Token is null or blank");
    }
    Map<String, String> params = new HashMap<String, String>();
    AccessGrant accessToken = null;
    if (reqToken.getAttribute(OAUTH_VERIFIER) != null) {
      params.put(OAUTH_VERIFIER, reqToken.getAttribute(OAUTH_VERIFIER)
          .toString());
    }
    params.put(OAUTH_TOKEN, reqToken.getKey());
    putOauthParams(params);

    String reqURL = accessTokenURL;
    String sig = generateSignature(config.get_signatureMethod(),
        config.get_transportName(), reqURL, params, reqToken);
    LOG.debug(config.get_signatureMethod()
        + " Signature for access token : " + sig);
    params.put(OAUTH_SIGNATURE, sig);
    String body = null;
    if (MethodType.GET.toString().equals(config.get_transportName())) {
      reqURL += "?" + HttpUtil.buildParams(params);
    } else {
      body = HttpUtil.buildParams(params);
    }
    LOG.debug("Access Token URL : " + reqURL);
    Response response = null;
    try {
      response = HttpUtil.doHttpRequest(reqURL,
          config.get_transportName(), body, null);
    } catch (Exception e) {
      LOG.debug("Error while getting Access Token");
      throw new SocialAuthException("Error while getting Access Token", e);
    }

    if (response.getStatus() == 200) {
      accessToken = new AccessGrant();
      parse(response.getInputStream(), accessToken);
    } else {
      throw new SocialAuthException(
          "Unable to retrieve the access token. Status: "
              + response.getStatus());
    }
    return accessToken;
  }
View Full Code Here

      String line = null;
      while ((line = reader.readLine()) != null) {
        sb.append(line);
      }
    } catch (Exception exc) {
      throw new SocialAuthException("Failed to parse response");
    }

    String[] pairs = sb.toString().split("&");
    String key = null, secret = null;
    for (String pair : pairs) {
View Full Code Here

    Response serviceResponse = null;
    try {
      serviceResponse = providerSupport.api(PROFILE_URL
          + providerSupport.getAccessGrant().getKey());
    } catch (Exception ie) {
      throw new SocialAuthException(
          "Failed to retrieve the career details from " + PROFILE_URL,
          ie);
    }
    Element root;
    try {
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.