Package org.brickred.socialauth

Examples of org.brickred.socialauth.Profile


        presp = presp.trim().intern();
        if (presp.startsWith("callback(") && presp.endsWith(");")) {
          presp = presp.substring(presp.indexOf("{"), presp.indexOf("}") + 1);
          Map<String, String> map = (Map<String, String>) Json.fromJson(presp);
          if (map.get("openid") != null) {
            Profile p = new Profile();
            p.setValidatedId(map.get("openid")); // QQ定义的
            p.setProviderId(getProviderId());
            userProfile = p;
           
            try {
              Map<String, String> params = new HashMap<String, String>();
              params.put("format", "json");
              params.put("openid", map.get("openid"));
              params.put("oauth_consumer_key", config.get_consumerKey());
              response = authenticationStrategy.executeFeed("https://graph.qq.com/user/get_user_info", "GET", params, null, null);
              presp = response.getResponseBodyAsString(Constants.ENCODING);
              Map<String, Object> user_info = (Map<String, Object>) Json.fromJson(presp);
              if ((Integer)user_info.get("ret") == 0 ) { //获取成功
                if (user_info.get("nickname") != null)
                  p.setDisplayName(user_info.get("nickname").toString());
                if (user_info.get("figureurl") != null)
                  p.setProfileImageURL(user_info.get("figureurl").toString());
                if (user_info.get("gender") != null)
                  p.setGender(user_info.get("gender").toString());
              }
             
              //TODO 尝试获取Email等详细信息
             
            } catch (Throwable e) {
View Full Code Here


      //System.out.println("User Profile : " + presp);
      Map<String, Object> data = Json.fromJson(Map.class, presp);
      if (!data.containsKey("id"))
        throw new SocialAuthException("Error: " + presp);
      if (userProfile == null)
        userProfile = new Profile();
      userProfile.setValidatedId(data.get("id").toString());
      userProfile.setProviderId(getProviderId());
      return userProfile;

    } catch (Exception ex) {
View Full Code Here

    try {
      Map<String, Object> data = Json.fromJson(Map.class, presp);
      if (!data.containsKey("id"))
        throw new SocialAuthException("Error: " + presp);
      if (userProfile == null)
        userProfile = new Profile();
      userProfile.setValidatedId(data.get("id").toString());
      userProfile.setProviderId(getProviderId());
      if(data.containsKey("screen_name")){
          userProfile.setDisplayName(data.get("screen_name").toString());
      }
View Full Code Here

    //获取支付宝的通知返回参数,可参考技术文档中页面跳转同步通知参数列表(以上仅供参考)//
   
    //计算得出通知验证结果
    boolean verify_result = AlipayNotify.verify(params);
    if(verify_result){//验证成功
      Profile profile = new Profile();
      profile.setValidatedId(user_id);
      profile.setProviderId(getProviderId());
      profile.setEmail(requestParams.get("email"));
      userProfile = profile;
      return profile;
    }
    throw new SocialAuthException("Auth fail!!");
  }
View Full Code Here

    PROFILE_URL = "http://gw.api.taobao.com/router/rest?method=taobao.user.get&fields=user_id&format=json";
  }

  protected Profile authLogin() throws Exception {
    Profile profile = new Profile();
    profile.setValidatedId(accessGrant.getAttribute("taobao_user_id").toString());
    profile.setDisplayName(accessGrant.getAttribute("taobao_user_nick").toString());
    profile.setProviderId(getProviderId());
    userProfile = profile;
    return profile;
  }
View Full Code Here

   
  }

  @Override
  protected Profile authLogin() throws Exception {
    Profile p = new Profile();
    p.setValidatedId(accessGrant.getAttribute("douban_user_id").toString());
    p.setProviderId(getProviderId());
    userProfile = p;
    return p;
  }
View Full Code Here

                //  String presp = authenticationStrategy.executeFeed(PROFILE_URL).getResponseBodyAsString("utf8");
                  //System.out.println(Json.toJson(Json.fromJson(presp)));
               // } catch (Throwable e) {
        //  e.printStackTrace();
        //}
                Profile p = new Profile();
                p.setValidatedId(requestParams.get("openid"));
                p.setProviderId(getProviderId());
                userProfile = p;
                return p;
        } else {
                throw new SocialAuthException("Access token not found");
        }
View Full Code Here

      throw new SocialAuthException("Error while getting profile from "
          + PROFILE_URL, e);
    }
    Map<String, Object> data = (Map<String, Object>) Json.fromJson(presp);
    if (data.get("uid") != null) {
      Profile profile = new Profile();
      profile.setValidatedId(data.get("uid").toString());
      profile.setProviderId(getProviderId());
      userProfile = profile;
      return profile;
    }
    throw new SocialAuthException("Auth fail : " + Json.toJson(data));
  }
View Full Code Here

      //System.out.println("User Profile : " + presp);
      Map<String, Object> data = Json.fromJson(Map.class, presp);
      if (!"ok".equals(data.get("msg")))
        throw new SocialAuthException("Error: " + presp);
      if (userProfile == null)
        userProfile = new Profile();
      data = (Map<String, Object>) data.get("data");
      userProfile.setValidatedId(data.get("uid").toString());
      return userProfile;

    } catch (Exception ex) {
View Full Code Here

TOP

Related Classes of org.brickred.socialauth.Profile

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.