• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java FacebookProfile类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



FacebookProfile类属于org.pac4j.oauth.profile.facebook包,在下文中一共展示了FacebookProfile类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: extractUserProfile

import org.pac4j.oauth.profile.facebook.FacebookProfile; //导入依赖的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


示例2: verifyOk

import org.pac4j.oauth.profile.facebook.FacebookProfile; //导入依赖的package包/类
@Test
public void verifyOk() throws GeneralSecurityException, PreventedException {
    final FacebookProfile facebookProfile = new FacebookProfile();
    facebookProfile.setId(ID);
    this.fbClient.setFacebookProfile(facebookProfile);
    final HandlerResult result = this.handler.authenticate(this.clientCredential);
    final Principal principal = result.getPrincipal();
    assertEquals(FacebookProfile.class.getSimpleName() + '#' + ID, principal.getId());
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:10,代码来源:ClientAuthenticationHandlerTests.java


示例3: verifyOkWithSimpleIdentifier

import org.pac4j.oauth.profile.facebook.FacebookProfile; //导入依赖的package包/类
@Test
public void verifyOkWithSimpleIdentifier() throws GeneralSecurityException, PreventedException {
    this.handler.setTypedIdUsed(false);
    final FacebookProfile facebookProfile = new FacebookProfile();
    facebookProfile.setId(ID);
    this.fbClient.setFacebookProfile(facebookProfile);
    final HandlerResult result = this.handler.authenticate(this.clientCredential);
    final Principal principal = result.getPrincipal();
    assertEquals(ID, principal.getId());
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:11,代码来源:ClientAuthenticationHandlerTests.java


示例4: verifyOk

import org.pac4j.oauth.profile.facebook.FacebookProfile; //导入依赖的package包/类
@Test
public void verifyOk() throws GeneralSecurityException, PreventedException {
    final FacebookProfile facebookProfile = new FacebookProfile();
    facebookProfile.setId(ID);
    this.fbClient.setFacebookProfile(facebookProfile);
    final HandlerResult result = this.handler.authenticate(this.clientCredential);
    final Principal principal = result.getPrincipal();
    assertEquals(FacebookProfile.class.getSimpleName() + "#" + ID, principal.getId());
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:10,代码来源:ClientAuthenticationHandlerTests.java


示例5: verifyOk

import org.pac4j.oauth.profile.facebook.FacebookProfile; //导入依赖的package包/类
@Test
public void verifyOk() throws GeneralSecurityException, PreventedException {
    final FacebookProfile facebookProfile = new FacebookProfile();
    facebookProfile.setId(ID);
    this.fbClient.setProfileCreator((oAuth20Credentials, webContext) -> facebookProfile);
    final HandlerResult result = this.handler.authenticate(this.clientCredential);
    final Principal principal = result.getPrincipal();
    assertEquals(FacebookProfile.class.getName() + '#' + ID, principal.getId());
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:10,代码来源:ClientAuthenticationHandlerTests.java


示例6: verifyOkWithSimpleIdentifier

import org.pac4j.oauth.profile.facebook.FacebookProfile; //导入依赖的package包/类
@Test
public void verifyOkWithSimpleIdentifier() throws GeneralSecurityException, PreventedException {
    this.handler.setTypedIdUsed(false);

    final FacebookProfile facebookProfile = new FacebookProfile();
    facebookProfile.setId(ID);
    this.fbClient.setProfileCreator((oAuth20Credentials, webContext) -> facebookProfile);
    final HandlerResult result = this.handler.authenticate(this.clientCredential);
    final Principal principal = result.getPrincipal();
    assertEquals(ID, principal.getId());
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:12,代码来源:ClientAuthenticationHandlerTests.java


示例7: retrieveUserProfileFromToken

import org.pac4j.oauth.profile.facebook.FacebookProfile; //导入依赖的package包/类
@Override
protected FacebookProfile retrieveUserProfileFromToken(final OAuth2AccessToken accessToken) throws HttpAction {
    String body = sendRequestForData(accessToken, getProfileUrl(accessToken));
    if (body == null) {
        throw new HttpCommunicationException("Not data found for accessToken: " + accessToken);
    }
    final FacebookProfile profile = extractUserProfile(body);
    addAccessTokenToProfile(profile, accessToken);
    if (profile != null && this.requiresExtendedToken) {
        String url = CommonHelper.addParameter(EXCHANGE_TOKEN_URL, OAuthConstants.CLIENT_ID, getKey());
        url = CommonHelper.addParameter(url, OAuthConstants.CLIENT_SECRET, getSecret());
        url = addExchangeToken(url, accessToken);
        final OAuthRequest request = createOAuthRequest(url);
        final long t0 = System.currentTimeMillis();
        final Response response = request.send();
        final int code = response.getCode();
        body = response.getBody();
        final long t1 = System.currentTimeMillis();
        logger.debug("Request took: " + (t1 - t0) + " ms for: " + url);
        logger.debug("response code: {} / response body: {}", code, body);
        if (code == 200) {
            logger.debug("Retrieve extended token from  {}", body);
            final OAuth2AccessToken extendedAccessToken = ((DefaultApi20) getApi()).getAccessTokenExtractor().extract(body);
            logger.debug("Extended token: {}", extendedAccessToken);
            addAccessTokenToProfile(profile, extendedAccessToken);
        } else {
            logger.error("Cannot get extended token: {} / {}", code, body);
        }
    }
    return profile;
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:32,代码来源:FacebookClient.java


示例8: testGenerateAuthenticateSub

import org.pac4j.oauth.profile.facebook.FacebookProfile; //导入依赖的package包/类
@Test(expected = TechnicalException.class)
public void testGenerateAuthenticateSub() throws HttpAction {
    final JwtGenerator<FacebookProfile> generator = new JwtGenerator<>(new SecretSignatureConfiguration(MAC_SECRET));
    final FacebookProfile profile = createProfile();
    profile.addAttribute(JwtClaims.SUBJECT, VALUE);
    final String token = generator.generate(profile);
    assertToken(profile, token);
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:9,代码来源:JwtTests.java


示例9: testGenerateAuthenticateIat

import org.pac4j.oauth.profile.facebook.FacebookProfile; //导入依赖的package包/类
@Test(expected = TechnicalException.class)
public void testGenerateAuthenticateIat() throws HttpAction {
    final JwtGenerator<FacebookProfile> generator = new JwtGenerator<>(new SecretSignatureConfiguration(MAC_SECRET));
    final FacebookProfile profile = createProfile();
    profile.addAttribute(JwtClaims.ISSUED_AT, VALUE);
    final String token = generator.generate(profile);
    assertToken(profile, token);
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:9,代码来源:JwtTests.java


示例10: testPlainJwtWithSignatureConfigurations

import org.pac4j.oauth.profile.facebook.FacebookProfile; //导入依赖的package包/类
@Test(expected = CredentialsException.class)
public void testPlainJwtWithSignatureConfigurations() throws HttpAction {
    final JwtGenerator<FacebookProfile> generator = new JwtGenerator<>();
    final FacebookProfile profile = createProfile();
    final String token = generator.generate(profile);
    assertToken(profile, token);
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:8,代码来源:JwtTests.java


示例11: testPlainJwtWithoutSignatureConfigurations

import org.pac4j.oauth.profile.facebook.FacebookProfile; //导入依赖的package包/类
@Test
public void testPlainJwtWithoutSignatureConfigurations() throws HttpAction {
    final JwtGenerator<FacebookProfile> generator = new JwtGenerator<>();
    final FacebookProfile profile = createProfile();
    final String token = generator.generate(profile);
    assertToken(profile, token, new JwtAuthenticator());
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:8,代码来源:JwtTests.java


示例12: testPlainJwtNotExpired

import org.pac4j.oauth.profile.facebook.FacebookProfile; //导入依赖的package包/类
@Test
public void testPlainJwtNotExpired() throws HttpAction {
    final JwtGenerator<FacebookProfile> generator = new JwtGenerator<>();
    Map<String, Object> claims = new HashMap<>();
    claims.put(JwtClaims.SUBJECT, ID);
    claims.put(JwtClaims.EXPIRATION_TIME, tomorrow());
    final String token = generator.generate(claims);
    JwtAuthenticator authenticator = new JwtAuthenticator();
    assertNotNull(authenticator.validateToken(token));
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:11,代码来源:JwtTests.java


示例13: testPlainJwtExpired

import org.pac4j.oauth.profile.facebook.FacebookProfile; //导入依赖的package包/类
@Test
public void testPlainJwtExpired() throws HttpAction {
    final JwtGenerator<FacebookProfile> generator = new JwtGenerator<>();
    Map<String, Object> claims = new HashMap<>();
    claims.put(JwtClaims.SUBJECT, ID);
    claims.put(JwtClaims.EXPIRATION_TIME, yesterday());
    final String token = generator.generate(claims);
    JwtAuthenticator authenticator = new JwtAuthenticator();
    assertNull(authenticator.validateToken(token));
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:11,代码来源:JwtTests.java


示例14: testPlainJwtNoSubject

import org.pac4j.oauth.profile.facebook.FacebookProfile; //导入依赖的package包/类
@Test
public void testPlainJwtNoSubject() throws HttpAction {
    final JwtGenerator<FacebookProfile> generator = new JwtGenerator<>();
    final String token = generator.generate(new HashMap<>());
    JwtAuthenticator authenticator = new JwtAuthenticator();
    TestsHelper.expectException(() -> authenticator.validateToken(token), TechnicalException.class, "JWT must contain a subject ('sub' claim)");
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:8,代码来源:JwtTests.java


示例15: testPemJwt

import org.pac4j.oauth.profile.facebook.FacebookProfile; //导入依赖的package包/类
@Test
public void testPemJwt() throws Exception {
    final FacebookProfile profile = createProfile();
    final ECSignatureConfiguration signatureConfiguration = buildECSignatureConfiguration();
    final JwtGenerator<FacebookProfile> generator = new JwtGenerator<>(signatureConfiguration);
    final String token = generator.generate(profile);
    final JwtAuthenticator authenticator = new JwtAuthenticator();
    authenticator.addSignatureConfiguration(signatureConfiguration);
    assertToken(profile, token, authenticator);
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:11,代码来源:JwtTests.java


示例16: testGenerateAuthenticate

import org.pac4j.oauth.profile.facebook.FacebookProfile; //导入依赖的package包/类
@Test
public void testGenerateAuthenticate() throws HttpAction {
    final JwtGenerator<FacebookProfile> generator = new JwtGenerator<>(new SecretSignatureConfiguration(MAC_SECRET), new SecretEncryptionConfiguration(MAC_SECRET));
    final FacebookProfile profile = createProfile();
    final String token = generator.generate(profile);
    assertToken(profile, token);
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:8,代码来源:JwtTests.java


示例17: testGenerateAuthenticateDifferentSecrets

import org.pac4j.oauth.profile.facebook.FacebookProfile; //导入依赖的package包/类
@Test
public void testGenerateAuthenticateDifferentSecrets() throws HttpAction {
    final SignatureConfiguration signatureConfiguration = new SecretSignatureConfiguration(MAC_SECRET);
    final EncryptionConfiguration encryptionConfiguration = new SecretEncryptionConfiguration(KEY2);
    final JwtGenerator<FacebookProfile> generator = new JwtGenerator<>(signatureConfiguration, encryptionConfiguration);
    final FacebookProfile profile = createProfile();
    final String token = generator.generate(profile);
    assertToken(profile, token, new JwtAuthenticator(signatureConfiguration, encryptionConfiguration));
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:10,代码来源:JwtTests.java


示例18: testGenerateAuthenticateUselessSignatureConfiguration

import org.pac4j.oauth.profile.facebook.FacebookProfile; //导入依赖的package包/类
@Test
public void testGenerateAuthenticateUselessSignatureConfiguration() throws HttpAction {
    final SignatureConfiguration signatureConfiguration = new SecretSignatureConfiguration(KEY2);
    final SignatureConfiguration signatureConfiguration2 = new SecretSignatureConfiguration(MAC_SECRET);
    final EncryptionConfiguration encryptionConfiguration = new SecretEncryptionConfiguration(MAC_SECRET);
    final JwtGenerator<FacebookProfile> generator = new JwtGenerator<>(signatureConfiguration, encryptionConfiguration);
    final FacebookProfile profile = createProfile();
    final String token = generator.generate(profile);
    final JwtAuthenticator jwtAuthenticator = new JwtAuthenticator();
    jwtAuthenticator.addSignatureConfiguration(signatureConfiguration);
    jwtAuthenticator.addSignatureConfiguration(signatureConfiguration2);
    jwtAuthenticator.setEncryptionConfiguration(encryptionConfiguration);
    assertToken(profile, token, jwtAuthenticator);
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:15,代码来源:JwtTests.java


示例19: testGenerateAuthenticateSlightlyDifferentSignatureConfiguration

import org.pac4j.oauth.profile.facebook.FacebookProfile; //导入依赖的package包/类
@Test
public void testGenerateAuthenticateSlightlyDifferentSignatureConfiguration() throws HttpAction {
    final JwtGenerator<FacebookProfile> generator = new JwtGenerator<>(new SecretSignatureConfiguration(KEY2));
    final FacebookProfile profile = createProfile();
    final String token = generator.generate(profile);
    final JwtAuthenticator jwtAuthenticator = new JwtAuthenticator();
    jwtAuthenticator.addSignatureConfiguration(new SecretSignatureConfiguration(MAC_SECRET));
    final Exception e = TestsHelper.expectException(() -> assertToken(profile, token, jwtAuthenticator));
    assertTrue(e.getMessage().startsWith("JWT verification failed"));
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:11,代码来源:JwtTests.java


示例20: testGenerateAuthenticateDifferentSignatureConfiguration

import org.pac4j.oauth.profile.facebook.FacebookProfile; //导入依赖的package包/类
@Test
public void testGenerateAuthenticateDifferentSignatureConfiguration() throws Exception {
    final JwtGenerator<FacebookProfile> generator = new JwtGenerator<>(new SecretSignatureConfiguration(KEY2));
    final FacebookProfile profile = createProfile();
    final String token = generator.generate(profile);
    final JwtAuthenticator jwtAuthenticator = new JwtAuthenticator();
    jwtAuthenticator.addSignatureConfiguration(buildECSignatureConfiguration());
    final Exception e = TestsHelper.expectException(() -> assertToken(profile, token, jwtAuthenticator));
    assertTrue(e.getMessage().startsWith("No signature algorithm found for JWT:"));
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:11,代码来源:JwtTests.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Base64类代码示例发布时间:2022-05-22
下一篇:
Java PomTarget类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap