本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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());
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}