org.usergrid.security.providers.FacebookProvider Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of usergrid-services Show documentation
Show all versions of usergrid-services Show documentation
Service layer for Usergrid system.
package org.usergrid.security.providers;
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.api.client.config.ClientConfig;
import com.sun.jersey.api.client.config.DefaultClientConfig;
import com.sun.jersey.api.json.JSONConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.usergrid.management.ManagementService;
import org.usergrid.persistence.*;
import org.usergrid.persistence.entities.User;
import org.usergrid.security.tokens.exceptions.BadTokenException;
import org.usergrid.utils.JsonUtils;
import org.usergrid.utils.MapUtils;
import javax.ws.rs.core.MediaType;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.UUID;
import static org.usergrid.persistence.Schema.PROPERTY_MODIFIED;
import static org.usergrid.utils.ListUtils.anyNull;
/**
* Provider implementation for sign-in-as with facebook
* @author zznate
*/
public class FacebookProvider extends AbstractProvider {
private static final String DEF_API_URL = "https://graph.facebook.com/me";
private static final String DEF_PICTURE_URL = "http://graph.facebook.com/%s/picture";
private Logger logger = LoggerFactory.getLogger(FacebookProvider.class);
private String apiUrl = DEF_API_URL;
private String pictureUrl = DEF_PICTURE_URL;
FacebookProvider(EntityManager entityManager,
ManagementService managementService) {
super(entityManager, managementService);
}
@Override
void configure() {
try {
Map config = loadConfigurationFor("facebookProvider");
if ( config != null ) {
String foundApiUrl = (String)config.get("api_url");
if ( foundApiUrl != null ) {
apiUrl = foundApiUrl;
}
String foundPicUrl = (String)config.get("pic_url");
if ( foundPicUrl != null) {
pictureUrl = foundApiUrl;
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
@Override
public Map
© 2015 - 2024 Weber Informatics LLC | Privacy Policy