use of org.springframework.social.facebook.api.Facebook in project ORCID-Source by ORCID.
the class SocialAjaxAuthenticationSuccessHandler method retrieveUserDetails.
private Map<String, String> retrieveUserDetails(SocialType connectionType) {
Map<String, String> userMap = new HashMap<String, String>();
if (SocialType.FACEBOOK.equals(connectionType)) {
Facebook facebook = socialContext.getFacebook();
User user = facebook.fetchObject("me", User.class, "id", "email", "name");
userMap.put("providerUserId", user.getId());
userMap.put("userName", user.getName());
userMap.put("email", user.getEmail());
} else if (SocialType.GOOGLE.equals(connectionType)) {
Google google = socialContext.getGoogle();
Person person = google.plusOperations().getGoogleProfile();
userMap.put("providerUserId", person.getId());
userMap.put("userName", person.getDisplayName());
userMap.put("email", person.getAccountEmail());
}
return userMap;
}
use of org.springframework.social.facebook.api.Facebook in project ORCID-Source by ORCID.
the class SocialController method retrieveUserDetails.
private Map<String, String> retrieveUserDetails(SocialType connectionType) {
Map<String, String> userMap = new HashMap<String, String>();
if (SocialType.FACEBOOK.equals(connectionType)) {
Facebook facebook = socialContext.getFacebook();
User user = facebook.fetchObject("me", User.class, "id", "email", "name", "first_name", "last_name");
userMap.put("providerUserId", user.getId());
userMap.put("userName", user.getName());
userMap.put("email", user.getEmail());
userMap.put("firstName", user.getFirstName());
userMap.put("lastName", user.getLastName());
} else if (SocialType.GOOGLE.equals(connectionType)) {
Google google = socialContext.getGoogle();
Person person = google.plusOperations().getGoogleProfile();
userMap.put("providerUserId", person.getId());
userMap.put("userName", person.getDisplayName());
userMap.put("email", person.getAccountEmail());
userMap.put("firstName", person.getGivenName());
userMap.put("lastName", person.getFamilyName());
}
return userMap;
}
use of org.springframework.social.facebook.api.Facebook in project engine by craftercms.
the class ConfigAwareConnectionFactoryLocatorTest method setUp.
@Override
@Before
public void setUp() throws Exception {
super.setUp();
CacheTemplateMockUtils.setUpWithNoCaching(cacheTemplate);
ConfigurationParser<?> configParserStub = new FacebookConnectionFactoryConfigParser() {
@Override
protected ConnectionFactory<Facebook> createFacebookConnectionFactory(String appId, String appSecret) {
return new FacebookConnectionFactoryStub(appId, appSecret);
}
};
locator = new ConfigAwareConnectionFactoryLocator();
locator.setCacheTemplate(cacheTemplate);
locator.setDefaultLocator(new ConnectionFactoryRegistry());
locator.setConfigParsers(Arrays.<ConfigurationParser<?>>asList(configParserStub));
}
use of org.springframework.social.facebook.api.Facebook in project ORCID-Source by ORCID.
the class SocialContext method isConnectedFacebookUser.
private boolean isConnectedFacebookUser(String userId) {
ConnectionRepository connectionRepo = connectionRepository.createConnectionRepository(userId);
Connection<Facebook> facebookConnection = connectionRepo.findPrimaryConnection(Facebook.class);
return facebookConnection != null;
}
Aggregations