本文整理汇总了Java中org.pac4j.oauth.profile.JsonHelper.getElement方法的典型用法代码示例。如果您正苦于以下问题:Java JsonHelper.getElement方法的具体用法?Java JsonHelper.getElement怎么用?Java JsonHelper.getElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.pac4j.oauth.profile.JsonHelper
的用法示例。
在下文中一共展示了JsonHelper.getElement方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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;
}
示例4: extractData
import org.pac4j.oauth.profile.JsonHelper; //导入方法依赖的package包/类
protected void extractData(final FacebookProfile profile, final JsonNode json, final String name) {
final JsonNode data = (JsonNode) JsonHelper.getElement(json, name);
if (data != null) {
convertAndAdd(profile, name, JsonHelper.getElement(data, "data"));
}
}
示例5: extractData
import org.pac4j.oauth.profile.JsonHelper; //导入方法依赖的package包/类
protected void extractData(final FacebookProfile profile, final JsonNode json, final String name) {
final JsonNode data = (JsonNode) JsonHelper.getElement(json, name);
if (data != null) {
profile.addAttribute(name, JsonHelper.getElement(data, "data"));
}
}
示例6: addUrl
import org.pac4j.oauth.profile.JsonHelper; //导入方法依赖的package包/类
private void addUrl(final LinkedIn2Profile profile, final JsonNode json, final String name) {
final String url = (String) JsonHelper.getElement(json, name + ".url");
profile.addAttribute(name, url);
}