Merge pull request #11117 from Craig Walls
* gh-11117: Complete the removal of Spring Social starters and auto-configuration Remove Spring Social starters and auto-configurationpull/11189/head
commit
abe010aba8
@ -1,91 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.autoconfigure.social;
|
||||
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type;
|
||||
import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.context.annotation.ScopedProxyMode;
|
||||
import org.springframework.social.config.annotation.EnableSocial;
|
||||
import org.springframework.social.config.annotation.SocialConfigurerAdapter;
|
||||
import org.springframework.social.connect.Connection;
|
||||
import org.springframework.social.connect.ConnectionFactory;
|
||||
import org.springframework.social.connect.ConnectionRepository;
|
||||
import org.springframework.social.connect.web.GenericConnectionStatusView;
|
||||
import org.springframework.social.facebook.api.Facebook;
|
||||
import org.springframework.social.facebook.connect.FacebookConnectionFactory;
|
||||
|
||||
/**
|
||||
* {@link EnableAutoConfiguration Auto-configuration} for Spring Social connectivity with
|
||||
* Facebook.
|
||||
*
|
||||
* @author Craig Walls
|
||||
* @since 1.1.0
|
||||
*/
|
||||
@Configuration
|
||||
@ConditionalOnClass({ SocialConfigurerAdapter.class, FacebookConnectionFactory.class })
|
||||
@ConditionalOnProperty(prefix = "spring.social.facebook", name = "app-id")
|
||||
@AutoConfigureBefore(SocialWebAutoConfiguration.class)
|
||||
@AutoConfigureAfter(WebMvcAutoConfiguration.class)
|
||||
public class FacebookAutoConfiguration {
|
||||
|
||||
@Configuration
|
||||
@EnableSocial
|
||||
@EnableConfigurationProperties(FacebookProperties.class)
|
||||
@ConditionalOnWebApplication(type = Type.SERVLET)
|
||||
protected static class FacebookConfigurerAdapter extends SocialAutoConfigurerAdapter {
|
||||
|
||||
private final FacebookProperties properties;
|
||||
|
||||
protected FacebookConfigurerAdapter(FacebookProperties properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
@Bean(name = { "connect/facebookConnect", "connect/facebookConnected" })
|
||||
@ConditionalOnProperty(prefix = "spring.social", name = "auto-connection-views")
|
||||
public GenericConnectionStatusView facebookConnectView() {
|
||||
return new GenericConnectionStatusView("facebook", "Facebook");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ConnectionFactory<?> createConnectionFactory() {
|
||||
return new FacebookConnectionFactory(this.properties.getAppId(),
|
||||
this.properties.getAppSecret());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.autoconfigure.social;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* Properties for Spring Social Facebook.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
* @since 1.2.0
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "spring.social.facebook")
|
||||
public class FacebookProperties extends SocialProperties {
|
||||
|
||||
}
|
@ -1,91 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.autoconfigure.social;
|
||||
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type;
|
||||
import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.context.annotation.ScopedProxyMode;
|
||||
import org.springframework.social.config.annotation.EnableSocial;
|
||||
import org.springframework.social.config.annotation.SocialConfigurerAdapter;
|
||||
import org.springframework.social.connect.Connection;
|
||||
import org.springframework.social.connect.ConnectionFactory;
|
||||
import org.springframework.social.connect.ConnectionRepository;
|
||||
import org.springframework.social.connect.web.GenericConnectionStatusView;
|
||||
import org.springframework.social.linkedin.api.LinkedIn;
|
||||
import org.springframework.social.linkedin.connect.LinkedInConnectionFactory;
|
||||
|
||||
/**
|
||||
* {@link EnableAutoConfiguration Auto-configuration} for Spring Social connectivity with
|
||||
* LinkedIn.
|
||||
*
|
||||
* @author Craig Walls
|
||||
* @since 1.1.0
|
||||
*/
|
||||
@Configuration
|
||||
@ConditionalOnClass({ SocialConfigurerAdapter.class, LinkedInConnectionFactory.class })
|
||||
@ConditionalOnProperty(prefix = "spring.social.linkedin", name = "app-id")
|
||||
@AutoConfigureBefore(SocialWebAutoConfiguration.class)
|
||||
@AutoConfigureAfter(WebMvcAutoConfiguration.class)
|
||||
public class LinkedInAutoConfiguration {
|
||||
|
||||
@Configuration
|
||||
@EnableSocial
|
||||
@EnableConfigurationProperties(LinkedInProperties.class)
|
||||
@ConditionalOnWebApplication(type = Type.SERVLET)
|
||||
protected static class LinkedInConfigurerAdapter extends SocialAutoConfigurerAdapter {
|
||||
|
||||
private final LinkedInProperties properties;
|
||||
|
||||
protected LinkedInConfigurerAdapter(LinkedInProperties properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(LinkedIn.class)
|
||||
@Scope(value = "request", proxyMode = ScopedProxyMode.INTERFACES)
|
||||
public LinkedIn linkedin(ConnectionRepository repository) {
|
||||
Connection<LinkedIn> connection = repository
|
||||
.findPrimaryConnection(LinkedIn.class);
|
||||
return connection != null ? connection.getApi() : null;
|
||||
}
|
||||
|
||||
@Bean(name = { "connect/linkedinConnect", "connect/linkedinConnected" })
|
||||
@ConditionalOnProperty(prefix = "spring.social", name = "auto-connection-views")
|
||||
public GenericConnectionStatusView linkedInConnectView() {
|
||||
return new GenericConnectionStatusView("linkedin", "LinkedIn");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ConnectionFactory<?> createConnectionFactory() {
|
||||
return new LinkedInConnectionFactory(this.properties.getAppId(),
|
||||
this.properties.getAppSecret());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.autoconfigure.social;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* Properties for Spring Social LinkedIn.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
* @since 1.2.0
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "spring.social.linkedin")
|
||||
public class LinkedInProperties extends SocialProperties {
|
||||
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.autoconfigure.social;
|
||||
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.social.config.annotation.ConnectionFactoryConfigurer;
|
||||
import org.springframework.social.config.annotation.SocialConfigurerAdapter;
|
||||
import org.springframework.social.connect.ConnectionFactory;
|
||||
|
||||
/**
|
||||
* Base class for auto-configured {@link SocialConfigurerAdapter}s.
|
||||
*
|
||||
* @author Craig Walls
|
||||
* @author Phillip Webb
|
||||
* @since 1.4.0
|
||||
*/
|
||||
public abstract class SocialAutoConfigurerAdapter extends SocialConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
public void addConnectionFactories(ConnectionFactoryConfigurer configurer,
|
||||
Environment environment) {
|
||||
configurer.addConnectionFactory(createConnectionFactory());
|
||||
}
|
||||
|
||||
protected abstract ConnectionFactory<?> createConnectionFactory();
|
||||
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.autoconfigure.social;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* Base {@link ConfigurationProperties properties} for spring social.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
* @since 1.4.0
|
||||
*/
|
||||
public abstract class SocialProperties {
|
||||
|
||||
/**
|
||||
* Your application's OAuth App ID.
|
||||
*/
|
||||
private String appId;
|
||||
|
||||
/**
|
||||
* Your application's OAuth secret.
|
||||
*/
|
||||
private String appSecret;
|
||||
|
||||
public String getAppId() {
|
||||
return this.appId;
|
||||
}
|
||||
|
||||
public void setAppId(String appId) {
|
||||
this.appId = appId;
|
||||
}
|
||||
|
||||
public String getAppSecret() {
|
||||
return this.appSecret;
|
||||
}
|
||||
|
||||
public void setAppSecret(String appSecret) {
|
||||
this.appSecret = appSecret;
|
||||
}
|
||||
|
||||
}
|
@ -1,187 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.autoconfigure.social;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.thymeleaf.spring5.SpringTemplateEngine;
|
||||
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type;
|
||||
import org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.context.SecurityContext;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.social.UserIdSource;
|
||||
import org.springframework.social.config.annotation.EnableSocial;
|
||||
import org.springframework.social.config.annotation.SocialConfigurerAdapter;
|
||||
import org.springframework.social.connect.ConnectionFactoryLocator;
|
||||
import org.springframework.social.connect.ConnectionRepository;
|
||||
import org.springframework.social.connect.UsersConnectionRepository;
|
||||
import org.springframework.social.connect.web.ConnectController;
|
||||
import org.springframework.social.connect.web.ConnectInterceptor;
|
||||
import org.springframework.social.connect.web.DisconnectInterceptor;
|
||||
import org.springframework.social.connect.web.ProviderSignInController;
|
||||
import org.springframework.social.connect.web.ProviderSignInInterceptor;
|
||||
import org.springframework.social.connect.web.SignInAdapter;
|
||||
import org.springframework.social.connect.web.thymeleaf.SpringSocialDialect;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.servlet.view.BeanNameViewResolver;
|
||||
|
||||
/**
|
||||
* {@link EnableAutoConfiguration Auto-configuration} for Spring Social's web connection
|
||||
* support.
|
||||
*
|
||||
* @author Craig Walls
|
||||
* @since 1.1.0
|
||||
*/
|
||||
@Configuration
|
||||
@ConditionalOnClass({ ConnectController.class, SocialConfigurerAdapter.class })
|
||||
@ConditionalOnBean({ ConnectionFactoryLocator.class, UsersConnectionRepository.class })
|
||||
@AutoConfigureBefore(ThymeleafAutoConfiguration.class)
|
||||
@AutoConfigureAfter(WebMvcAutoConfiguration.class)
|
||||
public class SocialWebAutoConfiguration {
|
||||
|
||||
@Configuration
|
||||
@EnableSocial
|
||||
@ConditionalOnWebApplication(type = Type.SERVLET)
|
||||
protected static class SocialAutoConfigurationAdapter
|
||||
extends SocialConfigurerAdapter {
|
||||
|
||||
private final List<ConnectInterceptor<?>> connectInterceptors;
|
||||
|
||||
private final List<DisconnectInterceptor<?>> disconnectInterceptors;
|
||||
|
||||
private final List<ProviderSignInInterceptor<?>> signInInterceptors;
|
||||
|
||||
public SocialAutoConfigurationAdapter(
|
||||
ObjectProvider<List<ConnectInterceptor<?>>> connectInterceptorsProvider,
|
||||
ObjectProvider<List<DisconnectInterceptor<?>>> disconnectInterceptorsProvider,
|
||||
ObjectProvider<List<ProviderSignInInterceptor<?>>> signInInterceptorsProvider) {
|
||||
this.connectInterceptors = connectInterceptorsProvider.getIfAvailable();
|
||||
this.disconnectInterceptors = disconnectInterceptorsProvider.getIfAvailable();
|
||||
this.signInInterceptors = signInInterceptorsProvider.getIfAvailable();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(ConnectController.class)
|
||||
public ConnectController connectController(
|
||||
ConnectionFactoryLocator factoryLocator,
|
||||
ConnectionRepository repository) {
|
||||
ConnectController controller = new ConnectController(factoryLocator,
|
||||
repository);
|
||||
if (!CollectionUtils.isEmpty(this.connectInterceptors)) {
|
||||
controller.setConnectInterceptors(this.connectInterceptors);
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(this.disconnectInterceptors)) {
|
||||
controller.setDisconnectInterceptors(this.disconnectInterceptors);
|
||||
}
|
||||
return controller;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
@ConditionalOnProperty(prefix = "spring.social", name = "auto-connection-views")
|
||||
public BeanNameViewResolver beanNameViewResolver() {
|
||||
BeanNameViewResolver viewResolver = new BeanNameViewResolver();
|
||||
viewResolver.setOrder(Ordered.HIGHEST_PRECEDENCE);
|
||||
return viewResolver;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnBean(SignInAdapter.class)
|
||||
@ConditionalOnMissingBean
|
||||
public ProviderSignInController signInController(
|
||||
ConnectionFactoryLocator factoryLocator,
|
||||
UsersConnectionRepository usersRepository, SignInAdapter signInAdapter) {
|
||||
ProviderSignInController controller = new ProviderSignInController(
|
||||
factoryLocator, usersRepository, signInAdapter);
|
||||
if (!CollectionUtils.isEmpty(this.signInInterceptors)) {
|
||||
controller.setSignInInterceptors(this.signInInterceptors);
|
||||
}
|
||||
return controller;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@EnableSocial
|
||||
@ConditionalOnWebApplication(type = Type.SERVLET)
|
||||
@ConditionalOnMissingClass("org.springframework.security.core.context.SecurityContextHolder")
|
||||
protected static class AnonymousUserIdSourceConfig extends SocialConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
public UserIdSource getUserIdSource() {
|
||||
return () -> "anonymous";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@EnableSocial
|
||||
@ConditionalOnWebApplication(type = Type.SERVLET)
|
||||
@ConditionalOnClass(SecurityContextHolder.class)
|
||||
protected static class AuthenticationUserIdSourceConfig
|
||||
extends SocialConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
public UserIdSource getUserIdSource() {
|
||||
return new SecurityContextUserIdSource();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@ConditionalOnClass(SpringTemplateEngine.class)
|
||||
protected static class SpringSocialThymeleafConfig {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public SpringSocialDialect springSocialDialect() {
|
||||
return new SpringSocialDialect();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class SecurityContextUserIdSource implements UserIdSource {
|
||||
|
||||
@Override
|
||||
public String getUserId() {
|
||||
SecurityContext context = SecurityContextHolder.getContext();
|
||||
Authentication authentication = context.getAuthentication();
|
||||
Assert.state(authentication != null,
|
||||
"Unable to get a ConnectionRepository: no user signed in");
|
||||
return authentication.getName();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,96 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.autoconfigure.social;
|
||||
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type;
|
||||
import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.context.annotation.ScopedProxyMode;
|
||||
import org.springframework.social.config.annotation.EnableSocial;
|
||||
import org.springframework.social.config.annotation.SocialConfigurerAdapter;
|
||||
import org.springframework.social.connect.Connection;
|
||||
import org.springframework.social.connect.ConnectionFactory;
|
||||
import org.springframework.social.connect.ConnectionRepository;
|
||||
import org.springframework.social.connect.web.GenericConnectionStatusView;
|
||||
import org.springframework.social.twitter.api.Twitter;
|
||||
import org.springframework.social.twitter.api.impl.TwitterTemplate;
|
||||
import org.springframework.social.twitter.connect.TwitterConnectionFactory;
|
||||
|
||||
/**
|
||||
* {@link EnableAutoConfiguration Auto-configuration} for Spring Social connectivity with
|
||||
* Twitter.
|
||||
*
|
||||
* @author Craig Walls
|
||||
* @since 1.1.0
|
||||
*/
|
||||
@Configuration
|
||||
@ConditionalOnClass({ SocialConfigurerAdapter.class, TwitterConnectionFactory.class })
|
||||
@ConditionalOnProperty(prefix = "spring.social.twitter", name = "app-id")
|
||||
@AutoConfigureBefore(SocialWebAutoConfiguration.class)
|
||||
@AutoConfigureAfter(WebMvcAutoConfiguration.class)
|
||||
public class TwitterAutoConfiguration {
|
||||
|
||||
@Configuration
|
||||
@EnableSocial
|
||||
@EnableConfigurationProperties(TwitterProperties.class)
|
||||
@ConditionalOnWebApplication(type = Type.SERVLET)
|
||||
protected static class TwitterConfigurerAdapter extends SocialAutoConfigurerAdapter {
|
||||
|
||||
private final TwitterProperties properties;
|
||||
|
||||
protected TwitterConfigurerAdapter(TwitterProperties properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
@Scope(value = "request", proxyMode = ScopedProxyMode.INTERFACES)
|
||||
public Twitter twitter(ConnectionRepository repository) {
|
||||
Connection<Twitter> connection = repository
|
||||
.findPrimaryConnection(Twitter.class);
|
||||
if (connection != null) {
|
||||
return connection.getApi();
|
||||
}
|
||||
return new TwitterTemplate(this.properties.getAppId(),
|
||||
this.properties.getAppSecret());
|
||||
}
|
||||
|
||||
@Bean(name = { "connect/twitterConnect", "connect/twitterConnected" })
|
||||
@ConditionalOnProperty(prefix = "spring.social", name = "auto-connection-views")
|
||||
public GenericConnectionStatusView twitterConnectView() {
|
||||
return new GenericConnectionStatusView("twitter", "Twitter");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ConnectionFactory<?> createConnectionFactory() {
|
||||
return new TwitterConnectionFactory(this.properties.getAppId(),
|
||||
this.properties.getAppSecret());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.autoconfigure.social;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* Properties for Spring Social Twitter.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
* @since 1.2.0
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "spring.social.twitter")
|
||||
public class TwitterProperties extends SocialProperties {
|
||||
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Auto-configuration for Spring Social.
|
||||
*/
|
||||
package org.springframework.boot.autoconfigure.social;
|
@ -1,71 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.autoconfigure.social;
|
||||
|
||||
import org.junit.After;
|
||||
|
||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
import org.springframework.social.UserIdSource;
|
||||
import org.springframework.social.connect.ConnectionFactoryLocator;
|
||||
import org.springframework.social.connect.ConnectionRepository;
|
||||
import org.springframework.social.connect.UsersConnectionRepository;
|
||||
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
/**
|
||||
* Abstract base class for testing Spring Social auto-configuration.
|
||||
*
|
||||
* @author Craig Walls
|
||||
*/
|
||||
public abstract class AbstractSocialAutoConfigurationTests {
|
||||
|
||||
protected AnnotationConfigWebApplicationContext context;
|
||||
|
||||
@After
|
||||
public void close() {
|
||||
if (this.context != null) {
|
||||
this.context.close();
|
||||
}
|
||||
}
|
||||
|
||||
protected void assertConnectionFrameworkBeans() {
|
||||
assertThat(this.context.getBean(UsersConnectionRepository.class)).isNotNull();
|
||||
assertThat(this.context.getBean(ConnectionRepository.class)).isNotNull();
|
||||
assertThat(this.context.getBean(ConnectionFactoryLocator.class)).isNotNull();
|
||||
assertThat(this.context.getBean(UserIdSource.class)).isNotNull();
|
||||
}
|
||||
|
||||
protected void assertNoConnectionFrameworkBeans() {
|
||||
assertMissingBean(UsersConnectionRepository.class);
|
||||
assertMissingBean(ConnectionRepository.class);
|
||||
assertMissingBean(ConnectionFactoryLocator.class);
|
||||
assertMissingBean(UserIdSource.class);
|
||||
}
|
||||
|
||||
protected void assertMissingBean(Class<?> beanClass) {
|
||||
try {
|
||||
assertThat(this.context.getBean(beanClass)).isNotNull();
|
||||
fail("Unexpected bean in context of type " + beanClass.getName());
|
||||
}
|
||||
catch (NoSuchBeanDefinitionException ex) {
|
||||
// Expected
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.autoconfigure.social;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.boot.context.properties.source.ConfigurationPropertySources;
|
||||
import org.springframework.boot.test.util.TestPropertyValues;
|
||||
import org.springframework.social.facebook.api.Facebook;
|
||||
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link FacebookAutoConfiguration}.
|
||||
*
|
||||
* @author Craig Walls
|
||||
*/
|
||||
public class FacebookAutoConfigurationTests extends AbstractSocialAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void expectedSocialBeansCreated() throws Exception {
|
||||
this.context = new AnnotationConfigWebApplicationContext();
|
||||
TestPropertyValues.of("spring.social.facebook.appId:12345").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.social.facebook.appSecret:secret")
|
||||
.applyTo(this.context);
|
||||
ConfigurationPropertySources.attach(this.context.getEnvironment());
|
||||
this.context.register(FacebookAutoConfiguration.class);
|
||||
this.context.register(SocialWebAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
assertConnectionFrameworkBeans();
|
||||
assertThat(this.context.getBean(Facebook.class)).isNotNull();
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.autoconfigure.social;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.boot.context.properties.source.ConfigurationPropertySources;
|
||||
import org.springframework.boot.test.util.TestPropertyValues;
|
||||
import org.springframework.social.linkedin.api.LinkedIn;
|
||||
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link LinkedInAutoConfiguration}.
|
||||
*
|
||||
* @author Craig Walls
|
||||
*/
|
||||
public class LinkedInAutoConfigurationTests extends AbstractSocialAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void expectedSocialBeansCreated() throws Exception {
|
||||
this.context = new AnnotationConfigWebApplicationContext();
|
||||
TestPropertyValues.of("spring.social.linkedin.appId:12345").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.social.linkedin.appSecret:secret")
|
||||
.applyTo(this.context);
|
||||
ConfigurationPropertySources.attach(this.context.getEnvironment());
|
||||
this.context.register(LinkedInAutoConfiguration.class);
|
||||
this.context.register(SocialWebAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
assertConnectionFrameworkBeans();
|
||||
assertThat(this.context.getBean(LinkedIn.class)).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void noLinkedInBeanCreatedIfPropertiesArentSet() throws Exception {
|
||||
this.context = new AnnotationConfigWebApplicationContext();
|
||||
this.context.register(LinkedInAutoConfiguration.class);
|
||||
this.context.register(SocialWebAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
assertNoConnectionFrameworkBeans();
|
||||
assertMissingBean(LinkedIn.class);
|
||||
}
|
||||
|
||||
}
|
@ -1,123 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.autoconfigure.social;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.boot.context.properties.source.ConfigurationPropertySources;
|
||||
import org.springframework.boot.test.util.TestPropertyValues;
|
||||
import org.springframework.social.facebook.api.Facebook;
|
||||
import org.springframework.social.linkedin.api.LinkedIn;
|
||||
import org.springframework.social.twitter.api.Twitter;
|
||||
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for Spring Social configuration with multiple API providers.
|
||||
*
|
||||
* @author Craig Walls
|
||||
*/
|
||||
public class MultiApiAutoConfigurationTests extends AbstractSocialAutoConfigurationTests {
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void noSocialBeansCreatedWhenPropertiesArentSet() throws Exception {
|
||||
setupContext();
|
||||
assertNoConnectionFrameworkBeans();
|
||||
assertMissingBean(Twitter.class);
|
||||
assertMissingBean(Facebook.class);
|
||||
assertMissingBean(LinkedIn.class);
|
||||
}
|
||||
|
||||
private void setupContext(String... environment) {
|
||||
this.context = new AnnotationConfigWebApplicationContext();
|
||||
TestPropertyValues.of(environment).applyTo(this.context);
|
||||
ConfigurationPropertySources.attach(this.context.getEnvironment());
|
||||
this.context.register(TwitterAutoConfiguration.class);
|
||||
this.context.register(FacebookAutoConfiguration.class);
|
||||
this.context.register(LinkedInAutoConfiguration.class);
|
||||
this.context.register(SocialWebAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
}
|
||||
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.autoconfigure.social;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.boot.context.properties.source.ConfigurationPropertySources;
|
||||
import org.springframework.boot.test.util.TestPropertyValues;
|
||||
import org.springframework.social.twitter.api.Twitter;
|
||||
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link TwitterAutoConfiguration}.
|
||||
*
|
||||
* @author Craig Walls
|
||||
*/
|
||||
public class TwitterAutoConfigurationTests extends AbstractSocialAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void expectedSocialBeansCreated() throws Exception {
|
||||
this.context = new AnnotationConfigWebApplicationContext();
|
||||
TestPropertyValues.of("spring.social.twitter.appId:12345").applyTo(this.context);
|
||||
TestPropertyValues.of("spring.social.twitter.appSecret:secret")
|
||||
.applyTo(this.context);
|
||||
ConfigurationPropertySources.attach(this.context.getEnvironment());
|
||||
this.context.register(TwitterAutoConfiguration.class);
|
||||
this.context.register(SocialWebAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
assertConnectionFrameworkBeans();
|
||||
assertThat(this.context.getBean(Twitter.class)).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void noTwitterBeanCreatedWhenPropertiesArentSet() throws Exception {
|
||||
this.context = new AnnotationConfigWebApplicationContext();
|
||||
this.context.register(TwitterAutoConfiguration.class);
|
||||
this.context.register(SocialWebAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
assertNoConnectionFrameworkBeans();
|
||||
assertMissingBean(Twitter.class);
|
||||
}
|
||||
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.cli.compiler.autoconfigure;
|
||||
|
||||
import org.codehaus.groovy.ast.ClassNode;
|
||||
import org.codehaus.groovy.control.CompilationFailedException;
|
||||
import org.codehaus.groovy.control.customizers.ImportCustomizer;
|
||||
|
||||
import org.springframework.boot.cli.compiler.AstUtils;
|
||||
import org.springframework.boot.cli.compiler.CompilerAutoConfiguration;
|
||||
import org.springframework.boot.cli.compiler.DependencyCustomizer;
|
||||
|
||||
/**
|
||||
* {@link CompilerAutoConfiguration} for Spring Social Facebook.
|
||||
*
|
||||
* @author Craig Walls
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public class SpringSocialFacebookCompilerAutoConfiguration
|
||||
extends CompilerAutoConfiguration {
|
||||
|
||||
@Override
|
||||
public boolean matches(ClassNode classNode) {
|
||||
return AstUtils.hasAtLeastOneFieldOrMethod(classNode, "Facebook");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyDependencies(DependencyCustomizer dependencies)
|
||||
throws CompilationFailedException {
|
||||
dependencies
|
||||
.ifAnyMissingClasses("org.springframework.social.facebook.api.Facebook")
|
||||
.add("spring-boot-starter-social-facebook");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyImports(ImportCustomizer imports) throws CompilationFailedException {
|
||||
imports.addStarImports("org.springframework.social.facebook.api");
|
||||
imports.addStarImports("org.springframework.social.config.annotation");
|
||||
}
|
||||
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.cli.compiler.autoconfigure;
|
||||
|
||||
import org.codehaus.groovy.ast.ClassNode;
|
||||
import org.codehaus.groovy.control.CompilationFailedException;
|
||||
import org.codehaus.groovy.control.customizers.ImportCustomizer;
|
||||
|
||||
import org.springframework.boot.cli.compiler.AstUtils;
|
||||
import org.springframework.boot.cli.compiler.CompilerAutoConfiguration;
|
||||
import org.springframework.boot.cli.compiler.DependencyCustomizer;
|
||||
|
||||
/**
|
||||
* {@link CompilerAutoConfiguration} for Spring Social LinkedIn.
|
||||
*
|
||||
* @author Craig Walls
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public class SpringSocialLinkedInCompilerAutoConfiguration
|
||||
extends CompilerAutoConfiguration {
|
||||
|
||||
@Override
|
||||
public boolean matches(ClassNode classNode) {
|
||||
return AstUtils.hasAtLeastOneFieldOrMethod(classNode, "LinkedIn");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyDependencies(DependencyCustomizer dependencies)
|
||||
throws CompilationFailedException {
|
||||
dependencies
|
||||
.ifAnyMissingClasses("org.springframework.social.linkedin.api.LinkedIn")
|
||||
.add("spring-boot-starter-social-linkedin");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyImports(ImportCustomizer imports) throws CompilationFailedException {
|
||||
imports.addStarImports("org.springframework.social.linkedin.api");
|
||||
imports.addImports("org.springframework.social.config.annotation.EnableSocial");
|
||||
}
|
||||
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.cli.compiler.autoconfigure;
|
||||
|
||||
import org.codehaus.groovy.ast.ClassNode;
|
||||
import org.codehaus.groovy.control.CompilationFailedException;
|
||||
import org.codehaus.groovy.control.customizers.ImportCustomizer;
|
||||
|
||||
import org.springframework.boot.cli.compiler.AstUtils;
|
||||
import org.springframework.boot.cli.compiler.CompilerAutoConfiguration;
|
||||
import org.springframework.boot.cli.compiler.DependencyCustomizer;
|
||||
|
||||
/**
|
||||
* {@link CompilerAutoConfiguration} for Spring Social Twitter.
|
||||
*
|
||||
* @author Craig Walls
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public class SpringSocialTwitterCompilerAutoConfiguration
|
||||
extends CompilerAutoConfiguration {
|
||||
|
||||
@Override
|
||||
public boolean matches(ClassNode classNode) {
|
||||
return AstUtils.hasAtLeastOneFieldOrMethod(classNode, "Twitter");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyDependencies(DependencyCustomizer dependencies)
|
||||
throws CompilationFailedException {
|
||||
dependencies.ifAnyMissingClasses("org.springframework.social.twitter.api.Twitter")
|
||||
.add("spring-boot-starter-social-twitter");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyImports(ImportCustomizer imports) throws CompilationFailedException {
|
||||
imports.addStarImports("org.springframework.social.twitter.api");
|
||||
imports.addImports("org.springframework.social.config.annotation.EnableSocial");
|
||||
}
|
||||
|
||||
}
|
@ -1,64 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starters</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
<artifactId>spring-boot-starter-social-facebook</artifactId>
|
||||
<name>Spring Boot Social Facebook Starter</name>
|
||||
<description>Starter for using Spring Social Facebook</description>
|
||||
<properties>
|
||||
<main.basedir>${basedir}/../../..</main.basedir>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.social</groupId>
|
||||
<artifactId>spring-social-config</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.social</groupId>
|
||||
<artifactId>spring-social-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.social</groupId>
|
||||
<artifactId>spring-social-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.social</groupId>
|
||||
<artifactId>spring-social-facebook</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.basepom.maven</groupId>
|
||||
<artifactId>duplicate-finder-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>duplicate-dependencies</id>
|
||||
<phase>validate</phase>
|
||||
<goals>
|
||||
<goal>check</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<ignoredClassPatterns>
|
||||
<ignoredClassPattern>javax.annotation.*</ignoredClassPattern>
|
||||
</ignoredClassPatterns>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
@ -1 +0,0 @@
|
||||
provides: spring-social-facebook
|
@ -1,64 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starters</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
<artifactId>spring-boot-starter-social-linkedin</artifactId>
|
||||
<name>Spring Boot Social LinkedIn Starter</name>
|
||||
<description>Stater for using Spring Social LinkedIn</description>
|
||||
<properties>
|
||||
<main.basedir>${basedir}/../../..</main.basedir>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.social</groupId>
|
||||
<artifactId>spring-social-config</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.social</groupId>
|
||||
<artifactId>spring-social-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.social</groupId>
|
||||
<artifactId>spring-social-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.social</groupId>
|
||||
<artifactId>spring-social-linkedin</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.basepom.maven</groupId>
|
||||
<artifactId>duplicate-finder-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>duplicate-dependencies</id>
|
||||
<phase>validate</phase>
|
||||
<goals>
|
||||
<goal>check</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<ignoredClassPatterns>
|
||||
<ignoredClassPattern>javax.annotation.*</ignoredClassPattern>
|
||||
</ignoredClassPatterns>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
@ -1 +0,0 @@
|
||||
provides: spring-social-linkedin
|
@ -1,64 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starters</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
<artifactId>spring-boot-starter-social-twitter</artifactId>
|
||||
<name>Spring Boot Social Twitter Starter</name>
|
||||
<description>Starter for using Spring Social Twitter</description>
|
||||
<properties>
|
||||
<main.basedir>${basedir}/../../..</main.basedir>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.social</groupId>
|
||||
<artifactId>spring-social-config</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.social</groupId>
|
||||
<artifactId>spring-social-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.social</groupId>
|
||||
<artifactId>spring-social-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.social</groupId>
|
||||
<artifactId>spring-social-twitter</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.basepom.maven</groupId>
|
||||
<artifactId>duplicate-finder-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>duplicate-dependencies</id>
|
||||
<phase>validate</phase>
|
||||
<goals>
|
||||
<goal>check</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<ignoredClassPatterns>
|
||||
<ignoredClassPattern>javax.annotation.*</ignoredClassPattern>
|
||||
</ignoredClassPatterns>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
@ -1 +0,0 @@
|
||||
provides: spring-social-twitter
|
Loading…
Reference in New Issue