当前位置: 首页>>代码示例>>Java>>正文


Java JsonHelper.getFirstNode方法代码示例

本文整理汇总了Java中org.pac4j.oauth.profile.JsonHelper.getFirstNode方法的典型用法代码示例。如果您正苦于以下问题:Java JsonHelper.getFirstNode方法的具体用法?Java JsonHelper.getFirstNode怎么用?Java JsonHelper.getFirstNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.pac4j.oauth.profile.JsonHelper的用法示例。


在下文中一共展示了JsonHelper.getFirstNode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: extractUserProfile

import org.pac4j.oauth.profile.JsonHelper; //导入方法依赖的package包/类
@Override
public FacebookProfile extractUserProfile(final String body) throws HttpAction {
    final FacebookProfile profile = newProfile();
    final JsonNode json = JsonHelper.getFirstNode(body);
    if (json != null) {
        profile.setId(JsonHelper.getElement(json, "id"));
        for (final String attribute : getPrimaryAttributes()) {
            convertAndAdd(profile, attribute, JsonHelper.getElement(json, attribute));
        }
        extractData(profile, json, org.pac4j.oauth.profile.facebook.FacebookProfileDefinition.FRIENDS);
        extractData(profile, json, org.pac4j.oauth.profile.facebook.FacebookProfileDefinition.MOVIES);
        extractData(profile, json, org.pac4j.oauth.profile.facebook.FacebookProfileDefinition.MUSIC);
        extractData(profile, json, org.pac4j.oauth.profile.facebook.FacebookProfileDefinition.BOOKS);
        extractData(profile, json, org.pac4j.oauth.profile.facebook.FacebookProfileDefinition.LIKES);
        extractData(profile, json, org.pac4j.oauth.profile.facebook.FacebookProfileDefinition.ALBUMS);
        extractData(profile, json, org.pac4j.oauth.profile.facebook.FacebookProfileDefinition.EVENTS);
        extractData(profile, json, org.pac4j.oauth.profile.facebook.FacebookProfileDefinition.GROUPS);
        extractData(profile, json, org.pac4j.oauth.profile.facebook.FacebookProfileDefinition.MUSIC_LISTENS);
        extractData(profile, json, org.pac4j.oauth.profile.facebook.FacebookProfileDefinition.PICTURE);
    }
    return profile;
}
 
开发者ID:millross,项目名称:pac4j-async,代码行数:23,代码来源:FacebookProfileDefinition.java

示例2: extractUserProfile

import org.pac4j.oauth.profile.JsonHelper; //导入方法依赖的package包/类
@Override
protected FacebookProfile extractUserProfile(final String body) throws HttpAction {
    final FacebookProfile profile = new FacebookProfile();
    final JsonNode json = JsonHelper.getFirstNode(body);
    if (json != null) {
        profile.setId(JsonHelper.getElement(json, "id"));
        for (final String attribute : profile.getAttributesDefinition().getPrimaryAttributes()) {
            profile.addAttribute(attribute, JsonHelper.getElement(json, attribute));
        }
        extractData(profile, json, FacebookAttributesDefinition.FRIENDS);
        extractData(profile, json, FacebookAttributesDefinition.MOVIES);
        extractData(profile, json, FacebookAttributesDefinition.MUSIC);
        extractData(profile, json, FacebookAttributesDefinition.BOOKS);
        extractData(profile, json, FacebookAttributesDefinition.LIKES);
        extractData(profile, json, FacebookAttributesDefinition.ALBUMS);
        extractData(profile, json, FacebookAttributesDefinition.EVENTS);
        extractData(profile, json, FacebookAttributesDefinition.GROUPS);
        extractData(profile, json, FacebookAttributesDefinition.MUSIC_LISTENS);
        extractData(profile, json, FacebookAttributesDefinition.PICTURE);
    }
    return profile;
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:23,代码来源:FacebookClient.java

示例3: extractUserProfile

import org.pac4j.oauth.profile.JsonHelper; //导入方法依赖的package包/类
@Override
protected FoursquareProfile extractUserProfile(String body) throws HttpAction {
    FoursquareProfile profile = new FoursquareProfile();
    JsonNode json = JsonHelper.getFirstNode(body);
    if (json == null) {
        return profile;
    }
    JsonNode response = (JsonNode) JsonHelper.getElement(json, "response");
    if (response == null) {
        return profile;
    }
    JsonNode user = (JsonNode) JsonHelper.getElement(response, "user");
    if (user != null) {
        profile.setId(JsonHelper.getElement(user, "id"));

        for (final String attribute : profile.getAttributesDefinition().getPrimaryAttributes()) {
            profile.addAttribute(attribute, JsonHelper.getElement(user, attribute));
        }
    }
    return profile;
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:22,代码来源:FoursquareClient.java

示例4: extractUserProfile

import org.pac4j.oauth.profile.JsonHelper; //导入方法依赖的package包/类
@Override
protected LinkedIn2Profile extractUserProfile(final String body) throws HttpAction {
    LinkedIn2Profile profile = new LinkedIn2Profile();
    final JsonNode json = JsonHelper.getFirstNode(body);
    profile.setId(JsonHelper.getElement(json, "id"));
    for (final String attribute : profile.getAttributesDefinition().getPrimaryAttributes()) {
        profile.addAttribute(attribute, JsonHelper.getElement(json, attribute));
    }
    final Object positions = JsonHelper.getElement(json, LinkedIn2AttributesDefinition.POSITIONS);
    if (positions != null && positions instanceof JsonNode) {
        profile.addAttribute(LinkedIn2AttributesDefinition.POSITIONS, JsonHelper.getElement((JsonNode) positions, "values"));
    }
    addUrl(profile, json, LinkedIn2AttributesDefinition.SITE_STANDARD_PROFILE_REQUEST);
    addUrl(profile, json, LinkedIn2AttributesDefinition.API_STANDARD_PROFILE_REQUEST);
    return profile;
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:17,代码来源:LinkedIn2Client.java

示例5: extractUserProfile

import org.pac4j.oauth.profile.JsonHelper; //导入方法依赖的package包/类
protected WeiXinProfile extractUserProfile(String body) {
    WeiXinProfile profile = new WeiXinProfile();
    JsonNode json = JsonHelper.getFirstNode(body);
    if(json != null) {
        Iterator var4 = WeiXinAttributesDefinition.weixinDefinition.getAllAttributes().iterator();
        while(var4.hasNext()) {
            String attribute = (String)var4.next();
            profile.addAttribute(attribute, JsonHelper.get(json, attribute));
        }
    }
    return profile;
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:13,代码来源:WeiXinClientOauth.java

示例6: convert

import org.pac4j.oauth.profile.JsonHelper; //导入方法依赖的package包/类
public T convert(final Object attribute) {
    if (attribute != null) {
        if (attribute.getClass().isAssignableFrom(clazz)) {
            return (T) attribute;
        } else if (attribute instanceof String) {
            final JsonNode node = JsonHelper.getFirstNode((String) attribute);
            return JsonHelper.getAsType(node, clazz);
        } else if (attribute instanceof JsonNode) {
            final T ret = JsonHelper.getAsType((JsonNode) attribute, clazz);
            return ret;
        }
    }
    return null;
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:15,代码来源:JsonConverter.java

示例7: extractUserProfile

import org.pac4j.oauth.profile.JsonHelper; //导入方法依赖的package包/类
@Override
protected QQProfile extractUserProfile(final String body) throws HttpAction {
    final QQProfile profile = new QQProfile();
    final JsonNode json = JsonHelper.getFirstNode(body);
    if (json != null) {
        profile.setId(JsonHelper.getElement(json, "id"));
        for (final String attribute : profile.getAttributesDefinition().getPrimaryAttributes()) {
            profile.addAttribute(attribute, JsonHelper.getElement(json, attribute));
        }
    }
    return profile;
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:13,代码来源:QQClient.java

示例8: extractUserProfile

import org.pac4j.oauth.profile.JsonHelper; //导入方法依赖的package包/类
@Override
protected YahooProfile extractUserProfile(final String body) throws HttpAction {
    final YahooProfile profile = new YahooProfile();
    JsonNode json = JsonHelper.getFirstNode(body);
    if (json != null) {
        json = json.get("profile");
        if (json != null) {
            profile.setId(JsonHelper.getElement(json, "guid"));
            for (final String attribute : profile.getAttributesDefinition().getPrimaryAttributes()) {
                profile.addAttribute(attribute, JsonHelper.getElement(json, attribute));
            }
        }
    }
    return profile;
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:16,代码来源:YahooClient.java

示例9: extractUserProfile

import org.pac4j.oauth.profile.JsonHelper; //导入方法依赖的package包/类
@Override
protected GenericOAuth20Profile extractUserProfile(String body) {
    final GenericOAuth20Profile profile = new GenericOAuth20Profile();
    if (attributesDefinition != null) {
        profile.setAttributesDefinition(attributesDefinition);
    }
    final JsonNode json = JsonHelper.getFirstNode(body);
    if (json != null) {
        profile.setId(JsonHelper.getElement(json, "id"));
        for (final String attribute : profile.getAttributesDefinition().getPrimaryAttributes()) {
            profile.addAttribute(attribute, JsonHelper.getElement(json, attribute));
        }
    }
    return profile;
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:16,代码来源:GenericOAuth20Client.java

示例10: extractUserProfile

import org.pac4j.oauth.profile.JsonHelper; //导入方法依赖的package包/类
@Override
protected StravaProfile extractUserProfile(String body) throws HttpAction {
    final StravaProfile profile = new StravaProfile();
    final JsonNode json = JsonHelper.getFirstNode(body);
    if (json != null) {
        profile.setId(JsonHelper.getElement(json, StravaAttributesDefinition.ID));
        for (final String attribute : profile.getAttributesDefinition().getPrimaryAttributes()) {
            profile.addAttribute(attribute, JsonHelper.getElement(json, attribute));
        }
    }
    return profile;
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:13,代码来源:StravaClient.java

示例11: testJsonNode

import org.pac4j.oauth.profile.JsonHelper; //导入方法依赖的package包/类
@Test
public void testJsonNode() {
    final JsonNode node = JsonHelper.getFirstNode(JSON);
    final FacebookObject[] objects = (FacebookObject[]) converter.convert(node);
    assertNotNull(objects);
    assertEquals(1, objects.length);
    final FacebookObject object = objects[0];
    assertEquals("x", object.getId());
    assertEquals("y", object.getName());
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:11,代码来源:JsonListConverterTests.java

示例12: extractUserProfile

import org.pac4j.oauth.profile.JsonHelper; //导入方法依赖的package包/类
@Override
protected OkProfile extractUserProfile(String body) throws HttpAction {
    final OkProfile profile = new OkProfile();
    JsonNode userNode = JsonHelper.getFirstNode(body);
    if (userNode != null) {
        profile.setId(JsonHelper.getElement(userNode, OkAttributesDefinition.UID));
        for (final String attribute : profile.getAttributesDefinition().getPrimaryAttributes()) {
            profile.addAttribute(attribute, JsonHelper.getElement(userNode, attribute));
        }
    }
    return profile;
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:13,代码来源:OkClient.java

示例13: extractUserProfile

import org.pac4j.oauth.profile.JsonHelper; //导入方法依赖的package包/类
@Override
protected CasOAuthWrapperProfile extractUserProfile(final String body) throws HttpAction {
    final CasOAuthWrapperProfile userProfile = new CasOAuthWrapperProfile();
    JsonNode json = JsonHelper.getFirstNode(body);
    if (json != null) {
        userProfile.setId(JsonHelper.getElement(json, "id"));
        json = json.get("attributes");
        if (json != null) {
            // CAS <= v4.2
            if (json instanceof ArrayNode) {
                final Iterator<JsonNode> nodes = json.iterator();
                while (nodes.hasNext()) {
                    json = nodes.next();
                    final String attribute = json.fieldNames().next();
                    userProfile.addAttribute(attribute, JsonHelper.getElement(json, attribute));
                }
                // CAS v5
            } else if (json instanceof ObjectNode) {
                final Iterator<String> keys = json.fieldNames();
                while (keys.hasNext()) {
                    final String key = keys.next();
                    userProfile.addAttribute(key, JsonHelper.getElement(json, key));
                }
            }
        }
    }
    return userProfile;
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:29,代码来源:CasOAuthWrapperClient.java

示例14: extractUserProfile

import org.pac4j.oauth.profile.JsonHelper; //导入方法依赖的package包/类
@Override
protected PayPalProfile extractUserProfile(final String body) throws HttpAction {
    final PayPalProfile profile = new PayPalProfile();
    final JsonNode json = JsonHelper.getFirstNode(body);
    if (json != null) {
        final String userId = (String) JsonHelper.getElement(json, "user_id");
        profile.setId(CommonHelper.substringAfter(userId, "/user/"));
        for (final String attribute : profile.getAttributesDefinition().getPrimaryAttributes()) {
            profile.addAttribute(attribute, JsonHelper.getElement(json, attribute));
        }
    }
    return profile;
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:14,代码来源:PayPalClient.java

示例15: extractUserProfile

import org.pac4j.oauth.profile.JsonHelper; //导入方法依赖的package包/类
@Override
protected SinaProfile extractUserProfile(final String body) throws HttpAction {
    final SinaProfile profile = new SinaProfile();
    final JsonNode json = JsonHelper.getFirstNode(body);
    if (json != null) {
        profile.setId(JsonHelper.getElement(json, "id"));
        for (final String attribute : profile.getAttributesDefinition().getPrimaryAttributes()) {
            profile.addAttribute(attribute, JsonHelper.getElement(json, attribute));
        }
    }
    return profile;
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:13,代码来源:SinaClient.java


注:本文中的org.pac4j.oauth.profile.JsonHelper.getFirstNode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。