本文整理汇总了Java中org.pac4j.oauth.profile.JsonHelper类的典型用法代码示例。如果您正苦于以下问题:Java JsonHelper类的具体用法?Java JsonHelper怎么用?Java JsonHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JsonHelper类属于org.pac4j.oauth.profile包,在下文中一共展示了JsonHelper类的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: buildUserRoles
import org.pac4j.oauth.profile.JsonHelper; //导入依赖的package包/类
/**
* Builds a list of Revenue Sharing roles according to the roles retrieved
* from the idm and the email of the user
* @param rolesNode, A JSON array containing the roles provided by the idm
* @param email, Email of the user
* @return List of revenue sharing roles
*/
public List<Role> buildUserRoles(ArrayNode rolesNode, String email) {
List<Role> userRoles = new ArrayList<>();
// Include idm defined roles
for (JsonNode node : rolesNode) {
Role r = new Role();
String role = (String) JsonHelper.get(node, "name");
r.setId((String) JsonHelper.get(node, "id"));
r.setName(role.toLowerCase());
userRoles.add(r);
}
// Check aggregator role
if (this.aggregatorDao.getById(email) != null) {
Role ag = new Role();
ag.setId("0");
ag.setName("aggregator");
userRoles.add(ag);
}
return userRoles;
}
示例6: 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;
}
示例7: convert
import org.pac4j.oauth.profile.JsonHelper; //导入依赖的package包/类
public Object convert(final Object attribute) {
if (attribute != null) {
if (attribute instanceof String) {
return parseString((String) attribute, arrayClazz);
} else if (attribute instanceof JsonNode) {
return JsonHelper.getAsType((JsonNode) attribute, arrayClazz);
} else if (attribute instanceof List) {
final List list = (List) attribute;
final List newList = new ArrayList<>();
for (final Object o : list) {
if (o != null) {
if (o instanceof String) {
final String s = (String) o;
if (elementClazz.isAssignableFrom(String.class)) {
newList.add(s);
} else {
newList.add(parseString(s, elementClazz));
}
} else if (o.getClass().isAssignableFrom(elementClazz)) {
newList.add(o);
}
}
}
return newList;
}
}
return null;
}
示例8: 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;
}
示例9: 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;
}
示例10: 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;
}
示例11: 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;
}
示例12: 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;
}
示例13: extractUserProfile
import org.pac4j.oauth.profile.JsonHelper; //导入依赖的package包/类
@Override
protected WindowsLiveProfile extractUserProfile(final String body) throws HttpAction {
final WindowsLiveProfile profile = new WindowsLiveProfile();
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;
}
示例14: 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;
}
示例15: 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;
}