|
|
@@ -0,0 +1,73 @@
|
|
|
+package com.uas.service.donate;
|
|
|
+
|
|
|
+import com.uas.account.web.AccountConfigurer;
|
|
|
+import com.uas.service.donate.profile.Dev;
|
|
|
+import com.uas.service.donate.profile.Prod;
|
|
|
+import com.uas.service.donate.profile.Test;
|
|
|
+import com.uas.service.donate.util.ContextUtils;
|
|
|
+import com.uas.service.donate.web.filter.SSOInterceptor;
|
|
|
+import org.springframework.context.annotation.Bean;
|
|
|
+import org.springframework.context.annotation.Configuration;
|
|
|
+import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
|
|
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
|
|
+
|
|
|
+import java.util.Properties;
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * SSOconfig 配置
|
|
|
+ *
|
|
|
+ * @author hejq
|
|
|
+ */
|
|
|
+@Configuration
|
|
|
+public class SSOConfiguration extends WebMvcConfigurerAdapter {
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void addInterceptors(InterceptorRegistry registry) {
|
|
|
+ /**
|
|
|
+ * 拦截器配置
|
|
|
+ */
|
|
|
+// registry.addInterceptor(new SSOInterceptor()).addPathPatterns("/**").
|
|
|
+// excludePathPatterns("/WEB-INF/**","/**/static/**", "/login/**", "/logout/**");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Bean
|
|
|
+ @Dev
|
|
|
+ public AccountConfigurer devAccountConfigurer() {
|
|
|
+ return accountConfigurer("dev");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Bean
|
|
|
+ @Test
|
|
|
+ public AccountConfigurer testAccountConfigurer() {
|
|
|
+ return accountConfigurer("test");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Bean
|
|
|
+ @Prod
|
|
|
+ public AccountConfigurer prodAccountConfigurer() {
|
|
|
+ return accountConfigurer("prod");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取当前环境下的配置
|
|
|
+ *
|
|
|
+ * @param profile
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private AccountConfigurer accountConfigurer(String profile) {
|
|
|
+ AccountConfigurer accountConfigurer = new AccountConfigurer();
|
|
|
+ accountConfigurer.setApplicationContext(ContextUtils.getApplicationContext());
|
|
|
+ Properties properties = new Properties();
|
|
|
+ String configPath = profile + "/account.properties";
|
|
|
+ try {
|
|
|
+ properties.load(this.getClass().getClassLoader().getResourceAsStream(configPath));
|
|
|
+ } catch (Throwable e) {
|
|
|
+ throw new IllegalStateException("配置加载失败" + configPath);
|
|
|
+ }
|
|
|
+ accountConfigurer.initProperties(properties);
|
|
|
+ return accountConfigurer;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|