本文整理汇总了Java中org.pac4j.oauth.profile.twitter.TwitterProfile类的典型用法代码示例。如果您正苦于以下问题:Java TwitterProfile类的具体用法?Java TwitterProfile怎么用?Java TwitterProfile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TwitterProfile类属于org.pac4j.oauth.profile.twitter包,在下文中一共展示了TwitterProfile类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: extractUserProfile
import org.pac4j.oauth.profile.twitter.TwitterProfile; //导入依赖的package包/类
@Override
protected TwitterProfile extractUserProfile(final String body) throws HttpAction {
final TwitterProfile profile = new TwitterProfile();
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;
}
示例2: verifyProfile
import org.pac4j.oauth.profile.twitter.TwitterProfile; //导入依赖的package包/类
@Override
protected void verifyProfile(CommonProfile userProfile) {
final TwitterProfile profile = (TwitterProfile) userProfile;
assertEquals("488358057", profile.getId());
assertEquals(TwitterProfile.class.getName() + CommonProfile.SEPARATOR + "488358057", profile.getTypedId());
assertTrue(ProfileHelper.isTypedIdOf(profile.getTypedId(), TwitterProfile.class));
assertTrue(CommonHelper.isNotBlank(profile.getAccessToken()));
assertCommonProfile(userProfile, null, null, null, "test scribeUP", "testscribeUP", Gender.UNSPECIFIED,
Locale.UK, ".twimg.com/sticky/default_profile_images/default_profile_5_normal.png",
"http://t.co/fNjYqp7wZ8", "New York");
assertFalse(profile.getContributorsEnabled());
assertEquals(TestsHelper.getFormattedDate(1328872224000L, "EEE MMM dd HH:mm:ss Z yyyy", Locale.US), profile
.getCreatedAt().toString());
assertTrue(profile.getDefaultProfile());
assertTrue(profile.getDefaultProfileImage());
assertEquals("biographie", profile.getDescription());
assertEquals(0, profile.getFavouritesCount().intValue());
assertFalse(profile.getFollowRequestSent());
assertEquals(0, profile.getFollowersCount().intValue());
assertFalse(profile.getFollowing());
assertEquals(0, profile.getFriendsCount().intValue());
assertFalse(profile.getGeoEnabled());
assertFalse(profile.getIsTranslator());
assertEquals(0, profile.getListedCount().intValue());
assertFalse(profile.getNotifications());
assertTrue(profile.getProfileBackgroundImageUrl().contains(".twimg.com/images/themes/theme1/bg.png"));
assertTrue(profile.getProfileBackgroundImageUrlHttps().endsWith("/images/themes/theme1/bg.png"));
assertFalse(profile.getProfileBackgroundTile());
assertTrue(profile.getProfileImageUrlHttps().endsWith(
"/sticky/default_profile_images/default_profile_5_normal.png"));
assertTrue(profile.getProfileUseBackgroundImage());
assertTrue(profile.getProtected());
assertNull(profile.getShowAllInlineMedia());
assertEquals(0, profile.getStatusesCount().intValue());
assertEquals("Amsterdam", profile.getTimeZone());
assertEquals(7200, profile.getUtcOffset().intValue());
assertFalse(profile.getVerified());
assertNotNull(profile.getAccessSecret());
assertEquals(37, profile.getAttributes().size());
}
示例3: getAuthenticationType
import org.pac4j.oauth.profile.twitter.TwitterProfile; //导入依赖的package包/类
public static AuthenticationType getAuthenticationType(Authentication authentication) {
if (authentication != null && authentication instanceof ClientAuthenticationToken) {
ClientAuthenticationToken token = (ClientAuthenticationToken) authentication;
if (token.getUserProfile() instanceof Google2Profile) {
return AuthenticationType.OAUTH2_GOOGLE;
} else if (token.getUserProfile() instanceof TwitterProfile) {
return AuthenticationType.TWITTER;
} else if (token.getUserProfile() instanceof GitHubProfile) {
return AuthenticationType.GITHUB;
} else {
throw new IllegalStateException("Invalid user profile type");
}
}
return AuthenticationType.LOCAL;
}
示例4: registerForKryo
import org.pac4j.oauth.profile.twitter.TwitterProfile; //导入依赖的package包/类
@Override
protected void registerForKryo(final Kryo kryo) {
kryo.register(TwitterProfile.class);
}
示例5: User
import org.pac4j.oauth.profile.twitter.TwitterProfile; //导入依赖的package包/类
public User(TwitterProfile profile) {
setUsername(profile.getUsername());
setType(User.TWITTER);
}