Java tutorial
package org.smigo.user.springsocial; /* * #%L * Smigo * %% * Copyright (C) 2015 Christian Nilsson * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Lesser Public License for more details. * * You should have received a copy of the GNU General Lesser Public * License along with this program. If not, see * <http://www.gnu.org/licenses/lgpl-3.0.html>. * #L% */ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Configuration; import org.springframework.core.env.Environment; import org.springframework.security.crypto.encrypt.Encryptors; import org.springframework.social.UserIdSource; import org.springframework.social.config.annotation.ConnectionFactoryConfigurer; import org.springframework.social.config.annotation.EnableSocial; import org.springframework.social.config.annotation.SocialConfigurer; import org.springframework.social.connect.ConnectionFactoryLocator; import org.springframework.social.connect.UsersConnectionRepository; import org.springframework.social.connect.jdbc.JdbcUsersConnectionRepository; import org.springframework.social.facebook.connect.FacebookConnectionFactory; import javax.sql.DataSource; @Configuration @EnableSocial public class SocialConfig implements SocialConfigurer { @Autowired private AddUserConnectionSignUp addUserConnectionSignUp; @Autowired private DataSource dataSource; @Value("${facebookAppId}") private String facebookAppId; @Value("${facebookAppSecret}") private String facebookAppSecret; @Override public void addConnectionFactories(ConnectionFactoryConfigurer cfConfig, Environment env) { cfConfig.addConnectionFactory(new FacebookConnectionFactory(facebookAppId, facebookAppSecret)); } @Override public UserIdSource getUserIdSource() { return new UserIdSource() { @Override public String getUserId() { throw new UnsupportedOperationException("getUserIdSource not supported"); } }; } @Override public UsersConnectionRepository getUsersConnectionRepository( ConnectionFactoryLocator connectionFactoryLocator) { final JdbcUsersConnectionRepository ret = new JdbcUsersConnectionRepository(dataSource, connectionFactoryLocator, Encryptors.noOpText()); ret.setConnectionSignUp(addUserConnectionSignUp); return ret; } }