+++ /dev/null
-package de.juplo.facebook.errors;
-
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.BeansException;
-import org.springframework.beans.factory.config.BeanPostProcessor;
-import org.springframework.boot.autoconfigure.AutoConfigureAfter;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
-import org.springframework.boot.autoconfigure.security.oauth2.OAuth2AutoConfiguration;
-import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.security.oauth2.client.OAuth2RestTemplate;
-import org.springframework.security.oauth2.client.http.OAuth2ErrorHandler;
-
-
-/**
- * Automatic configuration for Srping-Security-OAuth2
- *
- * @author Kai Moritz
- */
-@Configuration
-@ConditionalOnClass(value = OAuth2RestTemplate.class)
-@AutoConfigureAfter({
- WebMvcAutoConfiguration.class,
- OAuth2AutoConfiguration.class
- })
-public class FacebookErrorsOAuth2AutoConfiguration
-{
- private static final Logger LOG =
- LoggerFactory.getLogger(FacebookErrorsOAuth2AutoConfiguration.class);
-
- @Bean
- static public BeanPostProcessor errorHandlerInjectorOAuth2()
- {
- LOG.info("Configuring OAuth2GraphApiErrorHandler for handling error-messages");
-
- return new BeanPostProcessor()
- {
- @Override
- public Object postProcessBeforeInitialization(
- Object bean,
- String beanName
- )
- throws
- BeansException
- {
- if (bean instanceof OAuth2RestTemplate)
- {
- LOG.debug("Injecting OAuth2GraphApiErrorHandler in {}", bean);
- OAuth2RestTemplate template = (OAuth2RestTemplate) bean;
- template.setErrorHandler(
- new OAuth2GraphApiErrorHandler(
- (OAuth2ErrorHandler)template.getErrorHandler()
- )
- );
- }
-
- return bean;
- }
-
- @Override
- public Object postProcessAfterInitialization(
- Object bean,
- String beanName
- )
- throws
- BeansException
- {
- return bean;
- }
- };
- }
-}