本文整理汇总了Java中org.springframework.social.facebook.api.Facebook类的典型用法代码示例。如果您正苦于以下问题:Java Facebook类的具体用法?Java Facebook怎么用?Java Facebook使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Facebook类属于org.springframework.social.facebook.api包,在下文中一共展示了Facebook类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: authenticate
import org.springframework.social.facebook.api.Facebook; //导入依赖的package包/类
public void authenticate(Connection<?> connection) {
Facebook facebook = (Facebook) connection.getApi();
String [] fields = { "id", "name", "email", "first_name", "last_name" };
User userProfile = facebook.fetchObject("me", User.class, fields);
String username = userProfile.getName();
log.info("User Profile by facebook {} {} {}", userProfile.getFirstName(), userProfile.getLastName(), userProfile.getEmail());
Optional<io.osoon.domain.User> byEmail = userService.findByEmail(userProfile.getEmail());
io.osoon.domain.User osoonUser;
if (byEmail.isPresent()) {
osoonUser = byEmail.get();
} else {
io.osoon.domain.User newUser = io.osoon.domain.User.of(userProfile.getEmail(), username);
newUser.setImageUrl(connection.getImageUrl());
osoonUser = userService.saveOne(newUser);
}
OSoonUserDetails userDetails = new OSoonUserDetails(osoonUser);
RememberMeAuthenticationToken rememberMeToken = new RememberMeAuthenticationToken("osoon-remember-me", userDetails, null);
SecurityContextHolder.getContext().setAuthentication(rememberMeToken);
log.info("User {} {} {} connected.", userProfile.getFirstName(), userProfile.getLastName(), userProfile.getEmail());
}
示例2: getFacebookConnectionForChannel
import org.springframework.social.facebook.api.Facebook; //导入依赖的package包/类
public Connection<Facebook> getFacebookConnectionForChannel(NodeRef channelNode)
{
Connection<Facebook> connection = null;
if (nodeService.exists(channelNode)
&& nodeService.hasAspect(channelNode, FacebookPublishingModel.ASPECT_DELIVERY_CHANNEL))
{
String tokenValue = (String) encryptor.decrypt(PublishingModel.PROP_OAUTH2_TOKEN, nodeService.getProperty(
channelNode, PublishingModel.PROP_OAUTH2_TOKEN));
Boolean danceComplete = (Boolean) nodeService.getProperty(channelNode, PublishingModel.PROP_AUTHORISATION_COMPLETE);
if (danceComplete)
{
AccessGrant token = new AccessGrant(tokenValue);
connection = connectionFactory.createConnection(token);
}
}
return connection;
}
示例3: loadConnections
import org.springframework.social.facebook.api.Facebook; //导入依赖的package包/类
public void loadConnections() {
// MultiValueMap<String, Connection<?>> connections = getConnectionRepository().findAllConnections();
Connection<Facebook> facebookConnection = getConnectionRepository().findPrimaryConnection(Facebook.class);
if (facebookConnection != null) {
getView().setConnectionInfo("Facebook", true, facebookConnection.getApi().userOperations().getUserProfile().getEmail(), facebookConnection.getProfileUrl(), facebookConnection.getImageUrl());
} else {
getView().setConnectionInfo("Facebook", false, "", "", null);
}
Connection<Google> googleConnection = getConnectionRepository().findPrimaryConnection(Google.class);
if (googleConnection != null) {
getView().setConnectionInfo("Google", true, googleConnection.getDisplayName(), googleConnection.getProfileUrl(), googleConnection.getImageUrl());
} else {
getView().setConnectionInfo("Google", false, "", "", null);
}
}
开发者ID:markoradinovic,项目名称:Vaadin4Spring-MVP-Sample-SpringSecuritySocial,代码行数:19,代码来源:SocialPresenter.java
示例4: getApi
import org.springframework.social.facebook.api.Facebook; //导入依赖的package包/类
@Override
public Facebook getApi(String accessToken) {
FacebookTemplate template = new FacebookTemplate(accessToken, appNamespace);
template.setApiVersion(apiVersion);
return template;
}
示例5: facebook
import org.springframework.social.facebook.api.Facebook; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean(Facebook.class)
@Scope(value = "request", proxyMode = ScopedProxyMode.INTERFACES)
public Facebook facebook(ConnectionRepository repository) {
Connection<Facebook> connection = repository
.findPrimaryConnection(Facebook.class);
return connection != null ? connection.getApi() : null;
}
示例6: expectTwitterConfigurationOnly
import org.springframework.social.facebook.api.Facebook; //导入依赖的package包/类
@Test
public void expectTwitterConfigurationOnly() throws Exception {
setupContext("spring.social.twitter.appId:12345",
"spring.social.twitter.appSecret:secret");
assertConnectionFrameworkBeans();
assertThat(this.context.getBean(Twitter.class)).isNotNull();
assertMissingBean(Facebook.class);
assertMissingBean(LinkedIn.class);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:10,代码来源:MultiApiAutoConfigurationTests.java
示例7: expectFacebookConfigurationOnly
import org.springframework.social.facebook.api.Facebook; //导入依赖的package包/类
@Test
public void expectFacebookConfigurationOnly() throws Exception {
setupContext("spring.social.facebook.appId:12345",
"spring.social.facebook.appSecret:secret");
assertConnectionFrameworkBeans();
assertThat(this.context.getBean(Facebook.class)).isNotNull();
assertMissingBean(Twitter.class);
assertMissingBean(LinkedIn.class);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:10,代码来源:MultiApiAutoConfigurationTests.java
示例8: expectLinkedInConfigurationOnly
import org.springframework.social.facebook.api.Facebook; //导入依赖的package包/类
@Test
public void expectLinkedInConfigurationOnly() throws Exception {
setupContext("spring.social.linkedin.appId:12345",
"spring.social.linkedin.appSecret:secret");
assertConnectionFrameworkBeans();
assertThat(this.context.getBean(LinkedIn.class)).isNotNull();
assertMissingBean(Twitter.class);
assertMissingBean(Facebook.class);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:10,代码来源:MultiApiAutoConfigurationTests.java
示例9: expectFacebookAndLinkedInConfigurationOnly
import org.springframework.social.facebook.api.Facebook; //导入依赖的package包/类
@Test
public void expectFacebookAndLinkedInConfigurationOnly() throws Exception {
setupContext("spring.social.facebook.appId:54321",
"spring.social.facebook.appSecret:shhhhh",
"spring.social.linkedin.appId:12345",
"spring.social.linkedin.appSecret:secret");
assertConnectionFrameworkBeans();
assertThat(this.context.getBean(Facebook.class)).isNotNull();
assertThat(this.context.getBean(LinkedIn.class)).isNotNull();
assertMissingBean(Twitter.class);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:12,代码来源:MultiApiAutoConfigurationTests.java
示例10: expectFacebookAndTwitterConfigurationOnly
import org.springframework.social.facebook.api.Facebook; //导入依赖的package包/类
@Test
public void expectFacebookAndTwitterConfigurationOnly() throws Exception {
setupContext("spring.social.facebook.appId:54321",
"spring.social.facebook.appSecret:shhhhh",
"spring.social.twitter.appId:12345",
"spring.social.twitter.appSecret:secret");
assertConnectionFrameworkBeans();
assertThat(this.context.getBean(Facebook.class)).isNotNull();
assertThat(this.context.getBean(Twitter.class)).isNotNull();
assertMissingBean(LinkedIn.class);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:12,代码来源:MultiApiAutoConfigurationTests.java
示例11: expectLinkedInAndTwitterConfigurationOnly
import org.springframework.social.facebook.api.Facebook; //导入依赖的package包/类
@Test
public void expectLinkedInAndTwitterConfigurationOnly() throws Exception {
setupContext("spring.social.linkedin.appId:54321",
"spring.social.linkedin.appSecret:shhhhh",
"spring.social.twitter.appId:12345",
"spring.social.twitter.appSecret:secret");
assertConnectionFrameworkBeans();
assertThat(this.context.getBean(LinkedIn.class)).isNotNull();
assertThat(this.context.getBean(Twitter.class)).isNotNull();
assertMissingBean(Facebook.class);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:12,代码来源:MultiApiAutoConfigurationTests.java
示例12: noSocialBeansCreatedWhenPropertiesArentSet
import org.springframework.social.facebook.api.Facebook; //导入依赖的package包/类
@Test
public void noSocialBeansCreatedWhenPropertiesArentSet() throws Exception {
setupContext();
assertNoConnectionFrameworkBeans();
assertMissingBean(Twitter.class);
assertMissingBean(Facebook.class);
assertMissingBean(LinkedIn.class);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:9,代码来源:MultiApiAutoConfigurationTests.java
示例13: expectedSocialBeansCreated
import org.springframework.social.facebook.api.Facebook; //导入依赖的package包/类
@Test
public void expectedSocialBeansCreated() throws Exception {
this.context = new AnnotationConfigWebApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context,
"spring.social.facebook.appId:12345");
EnvironmentTestUtils.addEnvironment(this.context,
"spring.social.facebook.appSecret:secret");
this.context.register(FacebookAutoConfiguration.class);
this.context.register(SocialWebAutoConfiguration.class);
this.context.refresh();
assertConnectionFrameworkBeans();
assertThat(this.context.getBean(Facebook.class)).isNotNull();
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:14,代码来源:FacebookAutoConfigurationTests.java
示例14: noFacebookBeanCreatedWhenPropertiesArentSet
import org.springframework.social.facebook.api.Facebook; //导入依赖的package包/类
@Test
public void noFacebookBeanCreatedWhenPropertiesArentSet() throws Exception {
this.context = new AnnotationConfigWebApplicationContext();
this.context.register(FacebookAutoConfiguration.class);
this.context.register(SocialWebAutoConfiguration.class);
this.context.refresh();
assertNoConnectionFrameworkBeans();
assertMissingBean(Facebook.class);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:10,代码来源:FacebookAutoConfigurationTests.java
示例15: expectTwitterConfigurationOnly
import org.springframework.social.facebook.api.Facebook; //导入依赖的package包/类
@Test
public void expectTwitterConfigurationOnly() throws Exception {
setupContext("spring.social.twitter.appId:12345",
"spring.social.twitter.appSecret:secret");
assertConnectionFrameworkBeans();
assertNotNull(this.context.getBean(Twitter.class));
assertMissingBean(Facebook.class);
assertMissingBean(LinkedIn.class);
}