Forráskód Böngészése

v 1.5.0 RC2

v 1.5.0 RC2
shimingxy 5 éve
szülő
commit
e33c6dfd0b
37 módosított fájl, 933 hozzáadás és 1211 törlés
  1. 1 0
      build.gradle
  2. 3 3
      gradle.properties
  3. 5 0
      maxkey-core/src/main/java/org/maxkey/authn/support/rememberme/RedisRemeberMeService.java
  4. 7 16
      maxkey-core/src/main/java/org/maxkey/config/ApplicationConfig.java
  5. 4 4
      maxkey-core/src/main/java/org/maxkey/config/CharacterEncodingConfig.java
  6. 0 177
      maxkey-core/src/main/java/org/maxkey/config/DataSoruceConfig.java
  7. 19 19
      maxkey-core/src/main/java/org/maxkey/config/EmailConfig.java
  8. 36 0
      maxkey-core/src/main/java/org/maxkey/config/KaptchaAutoConfiguration.java
  9. 187 0
      maxkey-core/src/main/java/org/maxkey/config/MvcAutoConfiguration.java
  10. 1 1
      maxkey-core/src/main/java/org/maxkey/crypto/password/opt/impl/MailOtpAuthn.java
  11. 132 126
      maxkey-core/src/main/java/org/maxkey/persistence/redis/RedisConnectionFactory.java
  12. 0 174
      maxkey-core/src/main/java/org/maxkey/web/ImageEndpoint.java
  13. 103 0
      maxkey-core/src/main/java/org/maxkey/web/image/AbstractImageEndpoint.java
  14. 76 0
      maxkey-core/src/main/java/org/maxkey/web/image/ImageCaptchaEndpoint.java
  15. 40 0
      maxkey-core/src/main/java/org/maxkey/web/image/ImageEndpoint.java
  16. BIN
      maxkey-lib/mybatis-jpa-extra-spring-boot-starter-2.0.jar
  17. 0 69
      maxkey-web-manage/src/main/java/org/maxkey/MaxKeyMgtApplication.java
  18. 80 0
      maxkey-web-manage/src/main/java/org/maxkey/MaxKeyMgtConfig.java
  19. 5 0
      maxkey-web-manage/src/main/resources/META-INF/spring.factories
  20. 31 6
      maxkey-web-manage/src/main/resources/application.properties
  21. 6 60
      maxkey-web-manage/src/main/resources/config/applicationConfig.properties
  22. 0 0
      maxkey-web-manage/src/main/resources/kaptcha.properties
  23. 0 90
      maxkey-web-manage/src/main/resources/spring/maxkey-mgt-persistence.xml
  24. 0 131
      maxkey-web-manage/src/main/resources/spring/maxkey-mgt-web.xml
  25. 19 4
      maxkey-web-manage/src/main/resources/spring/maxkey-mgt.xml
  26. 67 27
      maxkey-web-maxkey/src/main/java/org/maxkey/MaxKeyConfig.java
  27. 50 0
      maxkey-web-maxkey/src/main/java/org/maxkey/RedisAutoConfiguration.java
  28. 1 1
      maxkey-web-maxkey/src/main/java/org/maxkey/web/contorller/OneTimePasswordController.java
  29. 1 1
      maxkey-web-maxkey/src/main/java/org/maxkey/web/contorller/RegistrationController.java
  30. 5 0
      maxkey-web-maxkey/src/main/resources/META-INF/spring.factories
  31. 41 7
      maxkey-web-maxkey/src/main/resources/application.properties
  32. 8 65
      maxkey-web-maxkey/src/main/resources/config/applicationConfig.properties
  33. 0 0
      maxkey-web-maxkey/src/main/resources/kaptcha.properties
  34. 0 103
      maxkey-web-maxkey/src/main/resources/spring/maxkey-persistence.xml
  35. 5 15
      maxkey-web-maxkey/src/main/resources/spring/maxkey-security.xml
  36. 0 108
      maxkey-web-maxkey/src/main/resources/spring/maxkey-web.xml
  37. 0 4
      maxkey-web-maxkey/src/main/resources/spring/maxkey.xml

+ 1 - 0
build.gradle

@@ -248,6 +248,7 @@ subprojects {
 		 //database
 		 compile group: 'mysql', name: 'mysql-connector-java', version: '5.1.48'
 		 compile group: 'com.alibaba', name: 'druid', version: '1.1.21'
+		 compile group: 'com.alibaba', name: 'druid-spring-boot-starter', version: '1.1.21'
          compile group: 'redis.clients', name: 'jedis', version: '3.2.0'
          compile group: 'org.ehcache', name: 'ehcache', version: '3.8.1'
 		 //mybatis

+ 3 - 3
gradle.properties

@@ -5,9 +5,9 @@ author	=shimingxy
 #Version For use jar
 jackson2Version      	=2.9.8
 log4jVersion         	=2.13.2
-springVersion        	=5.2.5.RELEASE
-springBootVersion    	=2.2.6.RELEASE
-springSecurityVersion	=5.3.0.RELEASE
+springVersion        	=5.2.6.RELEASE
+springBootVersion    	=2.3.0.RELEASE
+springSecurityVersion	=5.3.2.RELEASE
 hibernateVersion	 	=6.1.2.Final
 slf4jVersion	 	 	=1.7.30
 jacksonVersion		 	=2.10.3

+ 5 - 0
maxkey-core/src/main/java/org/maxkey/authn/support/rememberme/RedisRemeberMeService.java

@@ -41,4 +41,9 @@ public class RedisRemeberMeService extends AbstractRemeberMeService {
         conn.close();
     }
 
+    public void setConnectionFactory(RedisConnectionFactory connectionFactory) {
+        this.connectionFactory = connectionFactory;
+    }
+
+    
 }

+ 7 - 16
maxkey-core/src/main/java/org/maxkey/config/ApplicationConfig.java

@@ -21,8 +21,7 @@ import org.springframework.stereotype.Component;
 @PropertySource("classpath:/config/applicationConfig.properties")
 public class ApplicationConfig {
     private static final Logger _logger = LoggerFactory.getLogger(ApplicationConfig.class);
-    @Autowired
-    DataSoruceConfig dataSoruceConfig;
+
     @Autowired
     EmailConfig emailConfig;
     @Autowired
@@ -45,8 +44,8 @@ public class ApplicationConfig {
     @Value("${config.server.default.uri}")
     String defaultUri;
 
-    @Value("${config.server.manage.uri}")
-    String manageUri;
+    @Value("${config.server.management.uri}")
+    String managementUri;
 
     /*
      * //is enable whiteList for ipAddress filter boolean whiteList;
@@ -80,14 +79,6 @@ public class ApplicationConfig {
 
     }
 
-    public DataSoruceConfig getDataSoruceConfig() {
-        return dataSoruceConfig;
-    }
-
-    public void setDataSoruceConfig(DataSoruceConfig dataSoruceConfig) {
-        this.dataSoruceConfig = dataSoruceConfig;
-    }
-
     /**
      * @return the characterEncodingConfig
      */
@@ -179,12 +170,12 @@ public class ApplicationConfig {
         this.emailConfig = emailConfig;
     }
 
-    public String getManageUri() {
-        return manageUri;
+    public String getManagementUri() {
+        return managementUri;
     }
 
-    public void setManageUri(String manageUri) {
-        this.manageUri = manageUri;
+    public void setManagementUri(String managementUri) {
+        this.managementUri = managementUri;
     }
 
     public String getDefaultUri() {

+ 4 - 4
maxkey-core/src/main/java/org/maxkey/config/CharacterEncodingConfig.java

@@ -12,25 +12,25 @@ import org.springframework.context.annotation.PropertySource;
  *
  */
 @Configuration
-@PropertySource("classpath:/config/applicationConfig.properties")
+@PropertySource("classpath:/application.properties")
 public class CharacterEncodingConfig {
 
     /**
      * 源字符集.
      */
-    @Value("${config.characterencoding.charset.from}")
+    @Value("${server.servlet.encoding.charset.from:UTF-8}")
     String fromCharSet;
 
     /**
      * 目标字符集.
      */
-    @Value("${config.characterencoding.charset.to}")
+    @Value("${server.servlet.encoding.charset:UTF-8}")
     String toCharSet;
 
     /**
      * 转换标志.
      */
-    @Value("${config.characterencoding.encoding}")
+    @Value("${server.servlet.encoding.enabled:false}")
     boolean encoding = false;
 
     public CharacterEncodingConfig() {

+ 0 - 177
maxkey-core/src/main/java/org/maxkey/config/DataSoruceConfig.java

@@ -1,177 +0,0 @@
-package org.maxkey.config;
-
-import org.apache.commons.logging.LogFactory;
-import org.apache.mybatis.jpa.dialect.Dialect;
-import org.maxkey.crypto.password.PasswordReciprocal;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.PropertySource;
-
-/*
- * 数据源配置.
- *
- *  @author Crystal.Sea
- *  dataSource.driverClassName=com.mysql.jdbc.Driver
- *  dataSource.url=jdbc:mysql://192.168.1.49/parasecdb?autoReconnect=true&characterEncoding=UTF-8
- *  dataSource.username=root
- *  dataSource.password=connsec
- *  dataSource.type=mysql
- *
- */
-@Configuration
-@PropertySource("classpath:/config/applicationConfig.properties")
-public class DataSoruceConfig {
-
-    /*
-     * 数据库类型
-     */
-    @Value("${config.datasource.database:mysql}")
-    String database;
-    /*
-     * jdbc驱动类
-     */
-    @Value("${config.datasource.driverclass:com.mysql.jdbc.Driver}")
-    String driverClass;
-    /*
-     * jdbc连接地址
-     */
-    @Value("${config.datasource.url:" 
-            + "jdbc:mysql://localhost/maxkey?autoReconnect=true&characterEncoding=UTF-8}")
-    String url;
-    /*
-     * 数据库用户名
-     */
-    @Value("${config.datasource.username:root}")
-    String username;
-    /*
-     * 数据库密码
-     */
-    @Value("${config.datasource.password:maxkey}")
-    String password;
-
-    /*
-     * 数据库密码是否加密
-     */
-    @Value("${config.datasource.password.encrypt}")
-    boolean encrypt = false;
-
-    /*
-     * 数据库dialect for mybatis
-     */
-    String dialect;
-
-    public DataSoruceConfig() {
-        super();
-    }
-
-    public String getUrl() {
-        return url;
-    }
-
-    public void setUrl(String url) {
-        this.url = url;
-    }
-
-    public String getUsername() {
-        return username;
-    }
-
-    public void setUsername(String username) {
-        this.username = username;
-    }
-
-    /**
-     * 取得数据库密码 如果是加密密码(encrypt==true),则进行解密.
-     * 
-     * @return decodePassword
-     */
-    public String getPassword() {
-        String decodePassword = "";
-        LogFactory.getLog(DataSoruceConfig.class).debug("password is " + password);
-        if (encrypt) {
-            decodePassword = PasswordReciprocal.getInstance().decoder(password);
-        } else {
-            decodePassword = password;
-        }
-        LogFactory.getLog(DataSoruceConfig.class)
-                .debug("password is " + password + " , decodePassword is " + decodePassword);
-        return decodePassword;
-    }
-
-    public void setPassword(String password) {
-        this.password = password;
-    }
-
-    /*
-     * 
-     * @return the database
-     */
-    public String getDatabase() {
-        return database;
-    }
-
-    /*
-     * @param database the database to set
-     */
-    public void setDatabase(String database) {
-        this.database = database;
-
-    }
-
-    /*
-     * @return the driverClass
-     */
-    public String getDriverClass() {
-        return driverClass;
-    }
-
-    /*
-     * @param driverClass the driverClass to set
-     */
-    public void setDriverClass(String driverClass) {
-        this.driverClass = driverClass;
-    }
-
-    public boolean isEncrypt() {
-        return encrypt;
-    }
-
-    public void setEncrypt(boolean encrypt) {
-        this.encrypt = encrypt;
-    }
-
-    /**
-     * getDialect.
-     * @return the dialect
-     */
-    public String getDialect() {
-        if (this.dialect == null) {
-            this.dialect = Dialect.getDialectMap().get(database);
-        }
-        return dialect;
-    }
-
-    /*
-     * @param dialect the dialect to set
-     */
-    public void setDialect(String dialect) {
-        this.dialect = dialect;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see java.lang.Object#toString()
-     */
-    @Override
-    public String toString() {
-        return "DataSoruceConfig [database=" + database 
-                + ", driverClass=" + driverClass 
-                + ", url=" + url
-                + ", username=" + username 
-                + ", password=" + password 
-                + ", encrypt=" + encrypt 
-                + "]";
-    }
-
-}

+ 19 - 19
maxkey-core/src/main/java/org/maxkey/config/EmailConfig.java

@@ -5,24 +5,28 @@ import org.springframework.context.annotation.Configuration;
 import org.springframework.context.annotation.PropertySource;
 
 @Configuration
-@PropertySource("classpath:/config/applicationConfig.properties")
+@PropertySource("classpath:/application.properties")
 public class EmailConfig {
 
-    @Value("${config.email.username}")
+    @Value("${spring.mail.username}")
     private String username;
-    @Value("${config.email.password}")
+    
+    @Value("${spring.mail.password}")
     private String password;
-    @Value("${config.email.smtpHost}")
+    
+    @Value("${spring.mail.host}")
     private String smtpHost;
-    @Value("${config.email.senderMail}")
-    private String senderMail;
-    @Value("${config.email.port}")
+    
+    @Value("${spring.mail.port}")
     private Integer port;
-    @Value("${config.email.ssl}")
+    
+    @Value("${spring.mail.properties.ssl}")
     private boolean ssl;
+    
+    @Value("${spring.mail.properties.sender}")
+    private String sender;
 
     public EmailConfig() {
-        // TODO Auto-generated constructor stub
     }
 
     /*
@@ -67,18 +71,14 @@ public class EmailConfig {
         this.smtpHost = smtpHost;
     }
 
-    /*
-     * @return the senderMail
-     */
-    public String getSenderMail() {
-        return senderMail;
+
+
+    public String getSender() {
+        return sender;
     }
 
-    /*
-     * @param senderMail the senderMail to set
-     */
-    public void setSenderMail(String senderMail) {
-        this.senderMail = senderMail;
+    public void setSender(String sender) {
+        this.sender = sender;
     }
 
     /*

+ 36 - 0
maxkey-core/src/main/java/org/maxkey/config/KaptchaAutoConfiguration.java

@@ -0,0 +1,36 @@
+package org.maxkey.config;
+
+import com.google.code.kaptcha.Producer;
+import com.google.code.kaptcha.impl.DefaultKaptcha;
+import com.google.code.kaptcha.util.Config;
+import java.io.IOException;
+import java.util.Properties;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.Resource;
+
+
+@Configuration
+public class KaptchaAutoConfiguration {
+    private static final  Logger _logger = LoggerFactory.getLogger(KaptchaAutoConfiguration.class);
+    
+    /**
+     * Captcha Producer  Config .
+     * @return Producer
+     * @throws IOException kaptcha.properties is null
+     */
+    @Bean (name = "captchaProducer")
+    public Producer captchaProducer() throws IOException {
+        Resource resource = new ClassPathResource("/kaptcha.properties");
+        _logger.debug("Kaptcha config file " + resource.getURL());
+        DefaultKaptcha  kaptcha = new DefaultKaptcha();
+        Properties properties = new Properties();
+        properties.load(resource.getInputStream());
+        Config config = new Config(properties);
+        kaptcha.setConfig(config);
+        return kaptcha;
+    }
+}

+ 187 - 0
maxkey-core/src/main/java/org/maxkey/config/MvcAutoConfiguration.java

@@ -0,0 +1,187 @@
+package org.maxkey.config;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.PropertySource;
+import org.springframework.context.support.ReloadableResourceBundleMessageSource;
+import org.springframework.http.MediaType;
+import org.springframework.http.converter.HttpMessageConverter;
+import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
+import org.springframework.http.converter.xml.MarshallingHttpMessageConverter;
+import org.springframework.oxm.jaxb.Jaxb2Marshaller;
+import org.springframework.web.client.RestTemplate;
+import org.springframework.web.multipart.commons.CommonsMultipartResolver;
+import org.springframework.web.servlet.i18n.CookieLocaleResolver;
+import org.springframework.web.servlet.i18n.LocaleChangeInterceptor;
+import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter;
+import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
+
+
+@Configuration
+@PropertySource("classpath:/application.properties")
+@PropertySource("classpath:/config/applicationConfig.properties")
+public class MvcAutoConfiguration {
+    private static final  Logger _logger = LoggerFactory.getLogger(MvcAutoConfiguration.class);
+    
+    @Value("${config.server.domain.sub}")
+    String subDomainName;
+    @Value("${spring.servlet.multipart.max-file-size:4194304}")
+    int maxUploadSize;
+    @Value("${spring.messages.basename:classpath:messages/message}")
+    String messagesBasename;
+ 
+    /**
+     * cookieLocaleResolver .
+     * @return cookieLocaleResolver
+     */
+    @Bean (name = "localeResolver")
+    public CookieLocaleResolver cookieLocaleResolver() {
+        _logger.debug("subDomainName " + subDomainName);
+        CookieLocaleResolver cookieLocaleResolver = new CookieLocaleResolver();
+        cookieLocaleResolver.setCookieName("maxkey_lang");
+        cookieLocaleResolver.setCookieDomain(subDomainName);
+        cookieLocaleResolver.setCookieMaxAge(604800);
+        return cookieLocaleResolver;
+    }
+    
+    /**
+     * 消息处理,可以直接使用properties的key值,返回的是对应的value值
+     * messageSource .
+     * @return messageSource
+     */
+    @Bean (name = "messageSource")
+    public ReloadableResourceBundleMessageSource reloadableResourceBundleMessageSource()  {
+        _logger.debug("Basename " + messagesBasename);
+        ReloadableResourceBundleMessageSource messageSource = 
+                new ReloadableResourceBundleMessageSource();
+        messageSource.setBasename(messagesBasename);
+        messageSource.setUseCodeAsDefaultMessage(false);
+        return messageSource;
+    }
+    
+    /**
+     * Locale Change Interceptor and Resolver definition .
+     * @return localeChangeInterceptor
+     */
+    //@Primary
+    @Bean (name = "localeChangeInterceptor")
+    public LocaleChangeInterceptor localeChangeInterceptor()  {
+        LocaleChangeInterceptor localeChangeInterceptor = 
+                new LocaleChangeInterceptor();
+        localeChangeInterceptor.setParamName("language");
+        return localeChangeInterceptor;
+    }
+    
+    /**
+     * upload file support .
+     * @return multipartResolver
+     */
+    @Bean (name = "multipartResolver")
+    public CommonsMultipartResolver commonsMultipartResolver()  {
+        _logger.debug("maxUploadSize " + maxUploadSize);
+        CommonsMultipartResolver multipartResolver = 
+                new CommonsMultipartResolver();
+        multipartResolver.setMaxUploadSize(maxUploadSize);
+        return multipartResolver;
+    }
+    
+    /**
+     * handlerMapping .
+     * @return handlerMapping
+     */
+    @Bean (name = "handlerMapping")
+    public RequestMappingHandlerMapping requestMappingHandlerMapping(
+                                    LocaleChangeInterceptor localeChangeInterceptor) {
+        RequestMappingHandlerMapping requestMappingHandlerMapping = 
+                new RequestMappingHandlerMapping();
+        requestMappingHandlerMapping.setInterceptors(localeChangeInterceptor);
+        return requestMappingHandlerMapping;
+    }
+    
+    /**
+     * jaxb2Marshaller .
+     * @return jaxb2Marshaller
+     */
+    @Bean (name = "jaxb2Marshaller")
+    public Jaxb2Marshaller jaxb2Marshaller() {
+        Jaxb2Marshaller jaxb2Marshaller = new Jaxb2Marshaller();
+        jaxb2Marshaller.setClassesToBeBound(org.maxkey.domain.xml.UserInfoXML.class);;
+        return jaxb2Marshaller;
+    }
+    
+    /**
+     * marshallingHttpMessageConverter .
+     * @return marshallingHttpMessageConverter
+     */
+    @Bean (name = "marshallingHttpMessageConverter")
+    public MarshallingHttpMessageConverter marshallingHttpMessageConverter(
+                                                Jaxb2Marshaller jaxb2Marshaller) {
+        MarshallingHttpMessageConverter marshallingHttpMessageConverter = 
+                new MarshallingHttpMessageConverter();
+        marshallingHttpMessageConverter.setMarshaller(jaxb2Marshaller);
+        marshallingHttpMessageConverter.setUnmarshaller(jaxb2Marshaller);
+        ArrayList<MediaType> mediaTypesList = new ArrayList<MediaType>();
+        mediaTypesList.add(MediaType.APPLICATION_XML);
+        marshallingHttpMessageConverter.setSupportedMediaTypes(mediaTypesList);
+        return marshallingHttpMessageConverter;
+    }
+    
+    /**
+     * mappingJacksonHttpMessageConverter .
+     * @return mappingJacksonHttpMessageConverter
+     */
+    @Bean (name = "mappingJacksonHttpMessageConverter")
+    public MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter() {
+        MappingJackson2HttpMessageConverter mappingJacksonHttpMessageConverter = 
+                new MappingJackson2HttpMessageConverter();
+        ArrayList<MediaType> mediaTypesList = new ArrayList<MediaType>();
+        mediaTypesList.add(MediaType.APPLICATION_JSON);
+        mappingJacksonHttpMessageConverter.setSupportedMediaTypes(mediaTypesList);
+        return mappingJacksonHttpMessageConverter;
+    }
+    
+    /**
+     * AnnotationMethodHandlerAdapter
+     * requestMappingHandlerAdapter .
+     * @return requestMappingHandlerAdapter
+     */
+    @Bean (name = "requestMappingHandlerAdapter")
+    public RequestMappingHandlerAdapter requestMappingHandlerAdapter(
+            MappingJackson2HttpMessageConverter mappingJacksonHttpMessageConverter,
+            MarshallingHttpMessageConverter marshallingHttpMessageConverter) {
+        RequestMappingHandlerAdapter requestMappingHandlerAdapter = 
+                new RequestMappingHandlerAdapter();
+        List<HttpMessageConverter<?>> httpMessageConverterList = 
+                new ArrayList<HttpMessageConverter<?>>();
+        httpMessageConverterList.add(mappingJacksonHttpMessageConverter);
+        httpMessageConverterList.add(marshallingHttpMessageConverter);
+        requestMappingHandlerAdapter.setMessageConverters(httpMessageConverterList);
+        return requestMappingHandlerAdapter;
+    }
+    
+    /**
+     * restTemplate .
+     * @return restTemplate
+     */
+    @Bean (name = "restTemplate")
+    public RestTemplate restTemplate(
+            MappingJackson2HttpMessageConverter mappingJacksonHttpMessageConverter,
+            MarshallingHttpMessageConverter marshallingHttpMessageConverter) {
+        RestTemplate restTemplate = new RestTemplate();
+        List<HttpMessageConverter<?>> httpMessageConverterList = 
+                new ArrayList<HttpMessageConverter<?>>();
+        httpMessageConverterList.add(mappingJacksonHttpMessageConverter);
+        httpMessageConverterList.add(marshallingHttpMessageConverter);
+        restTemplate.setMessageConverters(httpMessageConverterList);
+        return restTemplate;
+    }
+    
+    
+    
+    
+}

+ 1 - 1
maxkey-core/src/main/java/org/maxkey/crypto/password/opt/impl/MailOtpAuthn.java

@@ -35,7 +35,7 @@ public class MailOtpAuthn extends AbstractOptAuthn {
             email.setAuthenticator(
                     new DefaultAuthenticator(emailConfig.getUsername(), emailConfig.getPassword()));
             
-            email.setFrom(emailConfig.getSenderMail());
+            email.setFrom(emailConfig.getSender());
             email.setSubject(subject);
             email.setMsg(
                     MessageFormat.format(

+ 132 - 126
maxkey-core/src/main/java/org/maxkey/persistence/redis/RedisConnectionFactory.java

@@ -6,134 +6,140 @@ import redis.clients.jedis.JedisPoolConfig;
 
 public class RedisConnectionFactory {
 
-	public static  class  DEFAULT_CONFIG{
-		/**
-		 * Redis默认服务器IP
-		 */
-		public static String DEFAULT_ADDRESS = "127.0.0.1";
-	    /**
-	     * Redis默认端口号
-	     */
-		public static int DEFAULT_PORT = 6379;
-	    /**
-	     *  访问密码
-	     */
-		public static String  DEFAULT_AUTH = "admin";
-	    /**
-	     * 可用连接实例的最大数目,默认值为8;<br>
-	     *如果赋值为-1,则表示不限制;如果pool已经分配了maxActive个jedis实例,则此时pool的状态为exhausted(耗尽)。
-	     **/
-		public static int DEFAULT_MAX_ACTIVE = 5000;
-	    
-	    /**
-	     * 控制一个pool最多有多少个状态为idle(空闲的)的jedis实例,默认值也是8。
-	     */
-		public static int DEFAULT_MAX_IDLE = 5000;
-	    
-	    /**
-	     * 等待可用连接的最大时间,单位毫秒,默认值为-1,表示永不超时。如果超过等待时间,则直接抛出JedisConnectionException;
-	     */
-		public static int DEFAULT_MAX_WAIT_MILLIS = 10000;
-	    
-		public static int DEFAULT_TIMEOUT = 10000;
-	    
-	    /**
-	     * 在borrow一个jedis实例时,是否提前进行validate操作;如果为true,则得到的jedis实例均是可用的;
-	     */
-		public static boolean DEFAULT_TEST_ON_BORROW = true;
-	    /**
-	     * 默认过期时间
-	     */
-		public static int DEFAULT_LIFETIME = 600;
-	}
-
-	JedisPoolConfig poolConfig;
-    
-    private  JedisPool jedisPool = null;
-    
-    private String hostname;
+    public static class DEFAULT_CONFIG {
+        /**
+         * Redis默认服务器IP
+         */
+        public static String DEFAULT_ADDRESS = "127.0.0.1";
+        /**
+         * Redis默认端口号
+         */
+        public static int DEFAULT_PORT = 6379;
+        /**
+         * 访问密码
+         */
+        public static String DEFAULT_AUTH = "admin";
+        /**
+         * 可用连接实例的最大数目,默认值为8;<br>
+         * 如果赋值为-1,则表示不限制;如果pool已经分配了maxActive个jedis实例,则此时pool的状态为exhausted(耗尽)。
+         **/
+        public static int DEFAULT_MAX_ACTIVE = 5000;
+
+        /**
+         * 控制一个pool最多有多少个状态为idle(空闲的)的jedis实例,默认值也是8。
+         */
+        public static int DEFAULT_MAX_IDLE = 5000;
+
+        /**
+         * 等待可用连接的最大时间,单位毫秒,默认值为-1,表示永不超时。如果超过等待时间,则直接抛出JedisConnectionException;
+         */
+        public static int DEFAULT_MAX_WAIT_MILLIS = 10000;
+
+        public static int DEFAULT_TIMEOUT = 10000;
+
+        /**
+         * 在borrow一个jedis实例时,是否提前进行validate操作;如果为true,则得到的jedis实例均是可用的;
+         */
+        public static boolean DEFAULT_TEST_ON_BORROW = true;
+        /**
+         * 默认过期时间
+         */
+        public static int DEFAULT_LIFETIME = 600;
+    }
+
+    JedisPoolConfig poolConfig;
+
+    private JedisPool jedisPool = null;
+
+    private String hostName;
     private int port;
     private String password;
     private int timeOut;
+
+    public RedisConnectionFactory() {
+
+    }
+
+    public void initConnectionFactory() {
+        if (jedisPool == null) {
+            try {
+                if (this.hostName == null || hostName.equals("")) {
+                    hostName = DEFAULT_CONFIG.DEFAULT_ADDRESS;
+                }
+                if (port == 0) {
+                    port = DEFAULT_CONFIG.DEFAULT_PORT;
+                }
+                if (timeOut == 0) {
+                    timeOut = DEFAULT_CONFIG.DEFAULT_TIMEOUT;
+                }
+
+                if (this.password == null || this.password.equals("") || this.password.equalsIgnoreCase("password")) {
+                    this.password = null;
+                }
+                jedisPool = new JedisPool(poolConfig, hostName, port, timeOut, password);
+
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+    public synchronized RedisConnection getConnection() {
+        initConnectionFactory();
+        RedisConnection redisConnection = new RedisConnection(this);
+        return redisConnection;
+    }
+
+    public Jedis open() {
+        return jedisPool.getResource();
+    }
+
+    public void close(Jedis conn) {
+        // jedisPool.returnResource(conn);
+        conn.close();
+    }
+
+   
+    public String getHostName() {
+        return hostName;
+    }
+
+    public void setHostName(String hostName) {
+        this.hostName = hostName;
+    }
+
+    public int getPort() {
+        return port;
+    }
+
+    public void setPort(int port) {
+        this.port = port;
+    }
+
+    public String getPassword() {
+        return password;
+    }
+
+    public void setPassword(String password) {
+        this.password = password;
+    }
+
+    public int getTimeOut() {
+        return timeOut;
+    }
+
+    public void setTimeOut(int timeOut) {
+        this.timeOut = timeOut;
+    }
+
+    public void setPoolConfig(JedisPoolConfig poolConfig) {
+        this.poolConfig = poolConfig;
+    }
+
+    public JedisPoolConfig getPoolConfig() {
+        return poolConfig;
+    }
+    
     
-	public RedisConnectionFactory() {
-		
-	}
-
-	public void initConnectionFactory() {
-		if(jedisPool==null){
-			try {
-				if(this.hostname==null||hostname.equals("")){
-					hostname= DEFAULT_CONFIG.DEFAULT_ADDRESS;
-				}
-				if(port==0){
-					port= DEFAULT_CONFIG.DEFAULT_PORT;
-				}
-				if(timeOut==0){
-					timeOut=DEFAULT_CONFIG.DEFAULT_TIMEOUT;
-				}
-
-				if(this.password==null||this.password.equals("")||this.password.equalsIgnoreCase("password")){
-					this.password=null;
-				}
-				jedisPool = new JedisPool(poolConfig, hostname, port, timeOut, password);
-	            
-	        } catch (Exception e) {
-	            e.printStackTrace();
-	        }
-		}
-	}
-	
-	public synchronized  RedisConnection  getConnection(){
-		initConnectionFactory();
-		RedisConnection redisConnection=new RedisConnection(this);
-		return redisConnection;
-	}
-	
-	public Jedis open(){
-		return jedisPool.getResource();
-	}
-
-	public void  close(Jedis conn){
-		//jedisPool.returnResource(conn);
-		conn.close();
-	}
-	
-	public String getHostname() {
-		return hostname;
-	}
-
-	public void setHostname(String hostname) {
-		this.hostname = hostname;
-	}
-
-	public int getPort() {
-		return port;
-	}
-
-	public void setPort(int port) {
-		this.port = port;
-	}
-
-	public String getPassword() {
-		return password;
-	}
-
-	public void setPassword(String password) {
-		this.password = password;
-	}
-
-	public int getTimeOut() {
-		return timeOut;
-	}
-
-	public void setTimeOut(int timeOut) {
-		this.timeOut = timeOut;
-	}
-
-	public void setPoolConfig(JedisPoolConfig poolConfig) {
-		this.poolConfig = poolConfig;
-	}
-	
-	
+
 }

+ 0 - 174
maxkey-core/src/main/java/org/maxkey/web/ImageEndpoint.java

@@ -1,174 +0,0 @@
-package org.maxkey.web;
-
-import com.google.code.kaptcha.Producer;
-import java.awt.image.BufferedImage;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import javax.imageio.ImageIO;
-import javax.servlet.ServletOutputStream;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import org.maxkey.config.ApplicationConfig;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestMapping;
-
-
-/**
- * ImageEndpoint  Producer Image and captcha.
- * @author Crystal.Sea
- *
- */
-@Controller
-public class ImageEndpoint {
-    private static final Logger _logger = LoggerFactory.getLogger(ImageEndpoint.class);
-
-    @Autowired
-    private Producer captchaProducer;
-    
-    @Autowired
-    @Qualifier("applicationConfig")
-    ApplicationConfig applicationConfig;
-
-    /**
-     * captcha image Producer.
-     * 
-     * @param request HttpServletRequest
-     * @param response HttpServletResponse
-     */
-    @RequestMapping(value = "/captcha")
-    public void captchaHandleRequest(HttpServletRequest request, HttpServletResponse response) {
-        try {
-           
-            String kaptchaText = captchaProducer.createText();
-            if (applicationConfig.getLoginConfig().getCaptchaType()
-                                        .equalsIgnoreCase("Arithmetic")) {
-                Integer intParamA = Integer.valueOf(kaptchaText.substring(0, 1));
-                Integer intParamB = Integer.valueOf(kaptchaText.substring(1, 2));
-                Integer calculateValue = 0;
-                if ((intParamA > intParamB) && ((intParamA + intParamB) % 5 > 3)) {
-                    calculateValue = intParamA - intParamB;
-                    kaptchaText = intParamA + "-" + intParamB + "=?";
-                } else {
-                    calculateValue = intParamA + intParamB;
-                    kaptchaText = intParamA + "+" + intParamB + "=?";
-                }
-                _logger.trace("Sesssion id " + request.getSession().getId() 
-                        + " , Arithmetic calculate Value is " + calculateValue);
-                request.getSession().setAttribute(
-                        WebConstants.KAPTCHA_SESSION_KEY, calculateValue + "");
-            } else {
-                // store the text in the session
-                request.getSession().setAttribute(WebConstants.KAPTCHA_SESSION_KEY, kaptchaText);
-            }
-            _logger.trace("Sesssion id " + request.getSession().getId() 
-                                + " , Captcha Text is " + kaptchaText);
-           
-            // create the image with the text
-            BufferedImage bufferedImage = captchaProducer.createImage(kaptchaText);
-            producerImage(request,response,bufferedImage);
-        } catch (Exception e) {
-            _logger.error("captcha Producer Error " + e.getMessage());
-        }
-    }
-
-    /**
-     * Session Image Producer.
-     * 
-     * @param request HttpServletRequest
-     * @param response HttpServletResponse
-     */
-
-    @RequestMapping("/image/{id}")
-    public void imageHandleRequest(HttpServletRequest request, HttpServletResponse response,
-            @PathVariable("id") String id) {
-        try {
-            // get session image bytes
-            byte[] image = (byte[]) request.getSession().getAttribute(id);
-            producerImage(request,response,byte2BufferedImage(image));
-        } catch (Exception e) {
-            _logger.error("captcha Producer Error " + e.getMessage());
-        }   
-    }
-
-    /**
-     * producerImage.
-     * @param request HttpServletRequest
-     * @param response HttpServletResponse
-     * @param bufferedImage BufferedImage
-     * @throws IOException error
-     */
-    public static void producerImage(HttpServletRequest request, 
-                              HttpServletResponse response,
-                              BufferedImage bufferedImage) throws IOException {
-        // Set to expire far in the past.
-        response.setDateHeader("Expires", 0);
-        // Set standard HTTP/1.1 no-cache headers.
-        response.setHeader("Cache-Control", "no-store, no-cache, must-revalidate");
-        // Set IE extended HTTP/1.1 no-cache headers (use addHeader).
-        response.addHeader("Cache-Control", "post-check=0, pre-check=0");
-        // Set standard HTTP/1.0 no-cache header.
-        response.setHeader("Pragma", "no-cache");
-        // return a jpeg/gif
-        response.setContentType("image/gif");
-        
-        // create the image
-        if (bufferedImage != null) {
-            ServletOutputStream out = response.getOutputStream();
-            // write the data out
-            ImageIO.write(bufferedImage, "gif", out);
-            try {
-                out.flush();
-            } finally {
-                out.close();
-            }
-        }
-    }
-    
-    /**
-     * byte2BufferedImage.
-     * @param imageByte bytes
-     * @return
-     */
-    public static BufferedImage byte2BufferedImage(byte[] imageByte) {
-        try {
-            InputStream in = new ByteArrayInputStream(imageByte);
-            BufferedImage bufferedImage = ImageIO.read(in);
-            return bufferedImage;
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-        return null;
-    }
-
-    /**
-     * bufferedImage2Byte.
-     * @param bufferedImage  BufferedImage
-     * @return
-     */
-    public static byte[] bufferedImage2Byte(BufferedImage bufferedImage) {
-        try {
-            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
-            ImageIO.write(bufferedImage, "gif", byteArrayOutputStream);
-            return byteArrayOutputStream.toByteArray();
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-        return null;
-    }
-
-    public void setCaptchaProducer(Producer captchaProducer) {
-        this.captchaProducer = captchaProducer;
-    }
-
-    public void setApplicationConfig(ApplicationConfig applicationConfig) {
-        this.applicationConfig = applicationConfig;
-    }
-
-}

+ 103 - 0
maxkey-core/src/main/java/org/maxkey/web/image/AbstractImageEndpoint.java

@@ -0,0 +1,103 @@
+package org.maxkey.web.image;
+
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import javax.imageio.ImageIO;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import org.maxkey.config.ApplicationConfig;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+
+
+/**
+ * AbstractImageEndpoint  Producer Image .
+ * @author Crystal.Sea
+ *
+ */
+
+public class AbstractImageEndpoint {
+    private static final Logger _logger = LoggerFactory.getLogger(AbstractImageEndpoint.class);
+
+    @Autowired
+    @Qualifier("applicationConfig")
+    ApplicationConfig applicationConfig;
+
+    /**
+     * producerImage.
+     * @param request HttpServletRequest
+     * @param response HttpServletResponse
+     * @param bufferedImage BufferedImage
+     * @throws IOException error
+     */
+    public static void producerImage(HttpServletRequest request, 
+                              HttpServletResponse response,
+                              BufferedImage bufferedImage) throws IOException {
+        // Set to expire far in the past.
+        response.setDateHeader("Expires", 0);
+        // Set standard HTTP/1.1 no-cache headers.
+        response.setHeader("Cache-Control", "no-store, no-cache, must-revalidate");
+        // Set IE extended HTTP/1.1 no-cache headers (use addHeader).
+        response.addHeader("Cache-Control", "post-check=0, pre-check=0");
+        // Set standard HTTP/1.0 no-cache header.
+        response.setHeader("Pragma", "no-cache");
+        // return a jpeg/gif
+        response.setContentType("image/gif");
+        _logger.trace("create the image");
+        // create the image
+        if (bufferedImage != null) {
+            ServletOutputStream out = response.getOutputStream();
+            // write the data out
+            ImageIO.write(bufferedImage, "gif", out);
+            try {
+                out.flush();
+            } finally {
+                out.close();
+            }
+        }
+    }
+    
+    /**
+     * byte2BufferedImage.
+     * @param imageByte bytes
+     * @return
+     */
+    public static BufferedImage byte2BufferedImage(byte[] imageByte) {
+        try {
+            InputStream in = new ByteArrayInputStream(imageByte);
+            BufferedImage bufferedImage = ImageIO.read(in);
+            return bufferedImage;
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+    /**
+     * bufferedImage2Byte.
+     * @param bufferedImage  BufferedImage
+     * @return
+     */
+    public static byte[] bufferedImage2Byte(BufferedImage bufferedImage) {
+        try {
+            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+            ImageIO.write(bufferedImage, "gif", byteArrayOutputStream);
+            return byteArrayOutputStream.toByteArray();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+
+    public void setApplicationConfig(ApplicationConfig applicationConfig) {
+        this.applicationConfig = applicationConfig;
+    }
+
+}

+ 76 - 0
maxkey-core/src/main/java/org/maxkey/web/image/ImageCaptchaEndpoint.java

@@ -0,0 +1,76 @@
+package org.maxkey.web.image;
+
+import com.google.code.kaptcha.Producer;
+import java.awt.image.BufferedImage;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import org.maxkey.web.WebConstants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+
+/**
+ * ImageCaptchaEndpoint  Producer captcha.
+ * @author Crystal.Sea
+ *
+ */
+@Controller
+public class ImageCaptchaEndpoint extends AbstractImageEndpoint {
+    private static final Logger _logger = LoggerFactory.getLogger(ImageCaptchaEndpoint.class);
+
+    @Autowired
+    private Producer captchaProducer;
+
+    /**
+     * captcha image Producer.
+     * 
+     * @param request HttpServletRequest
+     * @param response HttpServletResponse
+     */
+    @RequestMapping(value = "/captcha")
+    public void captchaHandleRequest(HttpServletRequest request, HttpServletResponse response) {
+        try {
+           
+            String kaptchaText = captchaProducer.createText();
+            if (applicationConfig.getLoginConfig().getCaptchaType()
+                                        .equalsIgnoreCase("Arithmetic")) {
+                Integer intParamA = Integer.valueOf(kaptchaText.substring(0, 1));
+                Integer intParamB = Integer.valueOf(kaptchaText.substring(1, 2));
+                Integer calculateValue = 0;
+                if ((intParamA > intParamB) && ((intParamA + intParamB) % 5 > 3)) {
+                    calculateValue = intParamA - intParamB;
+                    kaptchaText = intParamA + "-" + intParamB + "=?";
+                } else {
+                    calculateValue = intParamA + intParamB;
+                    kaptchaText = intParamA + "+" + intParamB + "=?";
+                }
+                _logger.trace("Sesssion id " + request.getSession().getId() 
+                        + " , Arithmetic calculate Value is " + calculateValue);
+                request.getSession().setAttribute(
+                        WebConstants.KAPTCHA_SESSION_KEY, calculateValue + "");
+            } else {
+                // store the text in the session
+                request.getSession().setAttribute(WebConstants.KAPTCHA_SESSION_KEY, kaptchaText);
+            }
+            _logger.trace("Sesssion id " + request.getSession().getId() 
+                                + " , Captcha Text is " + kaptchaText);
+           
+            // create the image with the text
+            BufferedImage bufferedImage = captchaProducer.createImage(kaptchaText);
+            producerImage(request,response,bufferedImage);
+        } catch (Exception e) {
+            _logger.error("captcha Producer Error " + e.getMessage());
+        }
+    }
+
+ 
+
+    public void setCaptchaProducer(Producer captchaProducer) {
+        this.captchaProducer = captchaProducer;
+    }
+
+
+}

+ 40 - 0
maxkey-core/src/main/java/org/maxkey/web/image/ImageEndpoint.java

@@ -0,0 +1,40 @@
+package org.maxkey.web.image;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+
+/**
+ * ImageEndpoint  Producer Image and captcha.
+ * @author Crystal.Sea
+ *
+ */
+@Controller
+public class ImageEndpoint extends AbstractImageEndpoint {
+    private static final Logger _logger = LoggerFactory.getLogger(ImageEndpoint.class);
+
+    /**
+     * Session Image Producer.
+     * 
+     * @param request HttpServletRequest
+     * @param response HttpServletResponse
+     */
+
+    @RequestMapping("/image/{id}")
+    public void imageHandleRequest(HttpServletRequest request, HttpServletResponse response,
+            @PathVariable("id") String id) {
+        try {
+            // get session image bytes
+            byte[] image = (byte[]) request.getSession().getAttribute(id);
+            producerImage(request,response,byte2BufferedImage(image));
+        } catch (Exception e) {
+            _logger.error("captcha Producer Error " + e.getMessage());
+        }   
+    }
+
+}

BIN
maxkey-lib/mybatis-jpa-extra-spring-boot-starter-2.0.jar


+ 0 - 69
maxkey-web-manage/src/main/java/org/maxkey/MaxKeyMgtApplication.java

@@ -1,34 +1,17 @@
 package org.maxkey;
 
-import java.io.IOException;
 import java.util.Date;
-import java.util.Properties;
-
 import javax.servlet.ServletException;
-
-import org.maxkey.authn.SavedRequestAwareAuthenticationSuccessHandler;
-import org.maxkey.crypto.password.PasswordReciprocal;
 import org.maxkey.web.InitializeContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.boot.builder.SpringApplicationBuilder;
-import org.springframework.boot.web.server.ConfigurableWebServerFactory;
-import org.springframework.boot.web.server.ErrorPage;
-import org.springframework.boot.web.server.WebServerFactoryCustomizer;
 import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
 import org.springframework.context.ConfigurableApplicationContext;
-import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.ComponentScan;
 import org.springframework.context.annotation.ImportResource;
-import org.springframework.core.io.ClassPathResource;
-import org.springframework.core.io.Resource;
-import org.springframework.http.HttpStatus;
-
-import com.google.code.kaptcha.Producer;
-import com.google.code.kaptcha.impl.DefaultKaptcha;
-import com.google.code.kaptcha.util.Config;
 
 @SpringBootApplication
 @ImportResource(locations={"classpath:spring/maxkey-mgt.xml"})
@@ -63,57 +46,5 @@ public class MaxKeyMgtApplication extends SpringBootServletInitializer {
 		
 		return application.sources(MaxKeyMgtApplication.class);
 	}
-	
-	@Bean
-    MaxKeyMgtConfig MaxKeyMgtConfig() {
-        return new MaxKeyMgtConfig();
-    }
-	
-	   /**
-     * 配置默认错误页面(仅用于内嵌tomcat启动时)
-     * 使用这种方式,在打包为war后不起作用
-     *
-     * @return
-     */  
-    @Bean
-    public WebServerFactoryCustomizer<ConfigurableWebServerFactory> webServerFactoryCustomizer() {
-        return new WebServerFactoryCustomizer<ConfigurableWebServerFactory>() {
-            @Override
-            public void customize(ConfigurableWebServerFactory factory) {
-                 ErrorPage errorPage400 = new ErrorPage(HttpStatus.BAD_REQUEST,"/exception/error/400");
-                 ErrorPage errorPage404 = new ErrorPage(HttpStatus.NOT_FOUND,"/exception/error/404");
-                 ErrorPage errorPage500 = new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR,"/exception/error/500");
-                 factory.addErrorPages(errorPage400, errorPage404,errorPage500);
-
-            }
-        };
-    }
-    
-    @Bean(name = "passwordReciprocal")
-    public PasswordReciprocal passwordReciprocal() {
-        return new PasswordReciprocal();
-    }
-    
-    @Bean(name = "savedRequestSuccessHandler")
-    public SavedRequestAwareAuthenticationSuccessHandler SavedRequestAwareAuthenticationSuccessHandler() {
-        return new SavedRequestAwareAuthenticationSuccessHandler();
-    }
-    
-    /**
-     * Captcha Producer  Config .
-     * @return Producer
-     * @throws IOException
-     */
-    @Bean(name = "captchaProducer")
-    public Producer captchaProducer() throws IOException{
-        Resource resource = new ClassPathResource("config/kaptcha.properties");
-        _logger.debug("Kaptcha config file " + resource.getURL());
-        DefaultKaptcha  kaptcha=new DefaultKaptcha();
-        Properties properties = new Properties();
-        properties.load(resource.getInputStream());
-        Config config = new Config(properties);
-        kaptcha.setConfig(config);
-        return kaptcha;
-    }
 
 }

+ 80 - 0
maxkey-web-manage/src/main/java/org/maxkey/MaxKeyMgtConfig.java

@@ -1,15 +1,42 @@
 package org.maxkey;
 
+import javax.sql.DataSource;
+import org.apache.ibatis.session.SqlSessionFactory;
+import org.maxkey.authn.SavedRequestAwareAuthenticationSuccessHandler;
+import org.maxkey.crypto.password.PasswordReciprocal;
+import org.mybatis.spring.annotation.MapperScan;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.boot.web.server.ConfigurableWebServerFactory;
+import org.springframework.boot.web.server.ErrorPage;
+import org.springframework.boot.web.server.WebServerFactoryCustomizer;
+import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Primary;
 import org.springframework.context.annotation.PropertySource;
+import org.springframework.http.HttpStatus;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.jdbc.datasource.DataSourceTransactionManager;
+import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder;
 
 @Configuration
 @PropertySource("classpath:/application.properties")
+@MapperScan("org.maxkey.dao.persistence,")
 public class MaxKeyMgtConfig {
     private static final  Logger _logger = LoggerFactory.getLogger(MaxKeyMgtConfig.class);
+    
+    @Autowired
+    @Qualifier("dataSource")
+    DataSource dataSource;
+    
+    @Autowired
+    @Qualifier("sqlSessionFactory")
+    SqlSessionFactory sqlSessionFactory;
+    
 	@Value("${server.port:8080}")
     private int port;
 
@@ -21,5 +48,58 @@ public class MaxKeyMgtConfig {
 		this.port = port;
 	}
 	
+    @Bean
+    @Primary
+    @ConfigurationProperties("spring.datasource")
+    public DataSource dataSource() {
+        return DruidDataSourceBuilder.create().build();
+    }
+    
+    @Bean(name = "passwordReciprocal")
+    public PasswordReciprocal passwordReciprocal() {
+        return new PasswordReciprocal();
+    }
+    
+    @Bean(name = "savedRequestSuccessHandler")
+    public SavedRequestAwareAuthenticationSuccessHandler SavedRequestAwareAuthenticationSuccessHandler() {
+        return new SavedRequestAwareAuthenticationSuccessHandler();
+    }
+    
+
+    @Bean(name = "jdbcTemplate")
+    public JdbcTemplate jdbcTemplate() {
+        return new JdbcTemplate(dataSource);
+    }
+    /*
+    @Bean(name = "sqlSession")
+    public SqlSessionTemplate sqlSession() throws Exception {
+        return new SqlSessionTemplate(sqlSessionFactory);
+    }*/
+    
+    @Bean(name = "transactionManager")
+    DataSourceTransactionManager transactionManager() {
+        return new DataSourceTransactionManager(dataSource);
+    }
+    
+    /**
+  * 配置默认错误页面(仅用于内嵌tomcat启动时)
+  * 使用这种方式,在打包为war后不起作用
+  *
+  * @return
+  */  
+ @Bean
+ public WebServerFactoryCustomizer<ConfigurableWebServerFactory> webServerFactoryCustomizer() {
+     return new WebServerFactoryCustomizer<ConfigurableWebServerFactory>() {
+         @Override
+         public void customize(ConfigurableWebServerFactory factory) {
+             _logger.debug("WebServerFactoryCustomizer ... ");
+             ErrorPage errorPage400 = new ErrorPage(HttpStatus.BAD_REQUEST,"/exception/error/400");
+             ErrorPage errorPage404 = new ErrorPage(HttpStatus.NOT_FOUND,"/exception/error/404");
+             ErrorPage errorPage500 = new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR,"/exception/error/500");
+             factory.addErrorPages(errorPage400, errorPage404,errorPage500);
+
+         }
+     };
+ }
 
 }

+ 5 - 0
maxkey-web-manage/src/main/resources/META-INF/spring.factories

@@ -0,0 +1,5 @@
+# Auto Configure
+org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
+org.maxkey.MaxKeyMgtConfig,\
+org.maxkey.config.KaptchaAutoConfiguration,\
+org.maxkey.config.MvcAutoConfiguration

+ 31 - 6
maxkey-web-manage/src/main/resources/application.properties

@@ -1,14 +1,39 @@
-#server config
 #spring.profiles.active=dev
+#application
+application.title=MaxKey
+application.name=MaxKey-Mgt
+application.formatted-version=v1.5.0 GA
+
+#server config
 #server port
 server.port=9521
 #web app context path
 server.servlet.context-path=/maxkey-mgt
-
-application.name=MaxKey-Mgt
-application.formatted-version=v1.5.0 GA
-
-#for freemarker
+spring.servlet.multipart.enabled=true
+spring.servlet.multipart.max-file-size=4194304
+#server.servlet.encoding.charset.from=
+#server.servlet.encoding.charset=
+#server.servlet.encoding.enabled=
+#server.servlet.encoding.force=
+#datasource
+spring.datasource.username=root
+spring.datasource.password=maxkey
+spring.datasource.url=jdbc:mysql://localhost/maxkey?autoReconnect=true&characterEncoding=UTF-8
+spring.datasource.driver-class-name=com.mysql.jdbc.Driver
+spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
+#mybatis
+mybatis.type-aliases-package=org.maxkey.domain,org.maxkey.domain.apps,
+mybatis.mapper-locations=classpath*:/org/maxkey/dao/persistence/xml/mysql/*.xml
+#mail
+spring.mail.default-encoding=utf-8
+spring.mail.host=smtp.163.com
+spring.mail.port=465
+spring.mail.username=maxkey@163.com
+spring.mail.password=password
+spring.mail.protocol=smtp
+spring.mail.properties.ssl=true
+spring.mail.properties.sender=maxkey@163.com
+#freemarker
 spring.freemarker.template-loader-path=classpath:/templates/views
 spring.freemarker.cache=false
 spring.freemarker.charset=UTF-8

+ 6 - 60
maxkey-web-manage/src/main/resources/config/applicationConfig.properties

@@ -10,75 +10,21 @@ config.server.prefix.uri=${config.server.name}:9521/maxkey-mgt
 config.server.default.uri=${config.server.prefix.uri}/main
 config.maxkey.uri=${config.server.name}/maxkey
 ############################################################################
-#              Application Configuration
-############################################################################
-#                          DataBase configuration                          
-# JDBC Driver                                                              
-#     for MySql         com.mysql.jdbc.Driver                              
-#     for oracle        oracle.jdbc.driver.OracleDriver                    
-#     for DB2           com.ibm.db2.jdbc.app.DB2Driver                     
-#     for SqlServer     com.microsoft.jdbc.sqlserver.SQLServerDriver        
-#     for SyBase        com.sybase.jdbc.SybDriver                          
-#     for PostgreSQL    org.postgresql.Driver      
-#	  for Derby			org.apache.derby.jdbc.ClientDriver  
-config.datasource.driverclass=com.mysql.jdbc.Driver
-# JDBC URL
-#    you need database hostname,port,databasename
-#     for MySql           jdbc:mysql://hostname:port/secdb
-#     for oracle          jdbc:oracle:thin:@hostname:port:secdb
-#     for DB2             jdbc:db2://hostname:port/secdb
-#     for SqlServer       jdbc:microsoft:sqlserver://hostname:port;DatabaseName=secdb
-#     for SyBase          jdbc:sybase:Tds:hostname:port/secdb
-#	  for Derby			  jdbc:derby://localhost:1527/secdb
-#
-config.datasource.url=jdbc:mysql://localhost/maxkey?autoReconnect=true&characterEncoding=UTF-8
-config.datasource.username=root
-#root/maxkey
-config.datasource.password=maxkey
-#db2,derby,mysql,oracle,postgresql,sqlserver at Dialect
-config.datasource.database=mysql
-config.datasource.password.encrypt=false
-#                        End  DataBase configuration 
-############################################################################  
-#                        CharacterEncoding
-#CharacterEncoding true/false
-config.characterencoding.encoding=true
-config.characterencoding.fromcharset=iso8859-1
-config.characterencoding.tocharset=UTF-8
-#                        End CharacterEncoding
-############################################################################ 
-
-############################################################################ 
-#                        Login
-config.login.captcha=false
-#text or arithmetic
-config.login.captcha.type=text
-config.login.socialAuth=true
-config.login.msad.kerberos=false
-#                        End Login
-############################################################################ 
-#                EMAIL configuration
-
-config.email.username=test@maxkey.org
-config.email.password=3&8Ujbnm5hkjhFD
-config.email.smtpHost=smtp.exmail.qq.com
-config.email.port=25
-config.email.senderMail=test@maxkey.org
-config.email.ssl=false
-############################################################################
 #                Login configuration
 #enable captcha
 config.login.captcha=true
+#text or arithmetic
+config.login.captcha.type=text
 #enable two factor,use one time password
-config.login.onetimepwd=true
+config.login.onetimepwd=false
 #enable social sign on
-config.login.socialsignon=true
+config.login.socialsignon=false
 #Enable kerberos/SPNEGO
-config.login.kerberos=true
+config.login.kerberos=false
 #wsFederation
 config.login.wsfederation=false
 #remeberme
-config.login.remeberme=true
+config.login.remeberme=false
 #validity
 config.login.remeberme.validity=
 #default.uri

+ 0 - 0
maxkey-web-manage/src/main/resources/config/kaptcha.properties → maxkey-web-manage/src/main/resources/kaptcha.properties


+ 0 - 90
maxkey-web-manage/src/main/resources/spring/maxkey-mgt-persistence.xml

@@ -1,90 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<beans 	xmlns="http://www.springframework.org/schema/beans"
-		xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
-		xmlns:aop="http://www.springframework.org/schema/aop"
-		xmlns:tx="http://www.springframework.org/schema/tx" 
-		xmlns:jdbc="http://www.springframework.org/schema/jdbc"
-		xmlns:context="http://www.springframework.org/schema/context"
-		xsi:schemaLocation="
-	     http://www.springframework.org/schema/context 
-	     http://www.springframework.org/schema/context/spring-context.xsd
-	     http://www.springframework.org/schema/beans 
-	     http://www.springframework.org/schema/beans/spring-beans.xsd
-	     http://www.springframework.org/schema/jdbc 
-	     http://www.springframework.org/schema/jdbc/spring-jdbc.xsd
-	     http://www.springframework.org/schema/tx 
-	     http://www.springframework.org/schema/tx/spring-tx.xsd
-	     http://www.springframework.org/schema/aop 
-	     http://www.springframework.org/schema/aop/spring-aop.xsd">
-
-	<!-- dataSource define begin -->
-	<!-- dataSource configuration -->
-	<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"  destroy-method="close" >      
-	   <!--  <property name="driverClass" value="#{dataSoruceConfig.driverClass}"/>     -->  
-	    <property name="url" value="#{dataSoruceConfig.url}"/>      
-	    <property name="username" value="#{dataSoruceConfig.username}"/>      
-	    <property name="password" value="#{dataSoruceConfig.password}"/>      
-	</bean> 
-	
-	<!-- JNDI data source  configuration -->
-	<!-- jndiName is jndi name -->
-	<!-- if you don,t want use prefix 'java:comp/env/' set resourceRef to true,default is false -->
-    <!-- 
-    <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">  
-        <property name="jndiName" value="jndi_maxkey_db" />
-        <property name="resourceRef" value="true" />  
-    </bean>  -->
-	<!-- dataSource define end -->
-	
-	<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">  
-		<property name="dataSource" ref="dataSource"></property>  
-	</bean> 
-
-	 <!-- Declare a transaction manager -->
- 	<!-- transaction manager, use JtaTransactionManager for global tx-->
-    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
-        <property name="dataSource" ref="dataSource" />
-    </bean> 
-    
-	<!-- Enable annotation style of managing transactions 
-	<tx:annotation-driven transaction-manager="transactionManager" />-->
-    
-    <!-- enable component scanning (beware that this does not enable mapper scanning!) -->    
-    <context:component-scan base-package="org.maxkey.dao.service" />
-    
-    <!-- enable autowire -->
-    <context:annotation-config />
-
-    <!-- enable transaction demarcation with annotations 
-    <tx:annotation-driven />-->
-
-
-	<!--<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">-->
-	<bean id="sqlSessionFactory" class="org.apache.mybatis.jpa.MyBatisSessionFactoryBean">
-		<property name="dataSource" ref="dataSource" />
-		<property name="dialect" value="mysql" />
-		<property name="timeout" value="30" />
-		<property name="transactionFactory">
-			<bean class="org.apache.ibatis.transaction.managed.ManagedTransactionFactory" />
-		</property>
-		<property name="typeAliasesPackage" 
-        		  value="
-	        			org.maxkey.domain,
-	        			org.maxkey.domain.apps,
-        			" />
-		<property name="mapperLocations" value="classpath*:org/maxkey/dao/persistence/xml/#{dataSoruceConfig.database}/*.xml" />
-	</bean>
-	
-	<bean id="sqlSession" class="org.mybatis.spring.SqlSessionTemplate">
-		<constructor-arg index="0" ref="sqlSessionFactory" />
-	</bean>
-	
-    <!-- scan for mappers and let them be autowired -->
-    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
-        <property name="basePackage" 
-        		  value="
-        		  		org.maxkey.dao.persistence,
-        		  		" />
-    </bean>
-	
-</beans>

+ 0 - 131
maxkey-web-manage/src/main/resources/spring/maxkey-mgt-web.xml

@@ -1,131 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<beans 	xmlns="http://www.springframework.org/schema/beans"
-		xmlns:context="http://www.springframework.org/schema/context"
-		xmlns:mvc="http://www.springframework.org/schema/mvc"
-		xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-		xmlns:p="http://www.springframework.org/schema/p"
-		xmlns:tx="http://www.springframework.org/schema/tx"
-		xmlns:util="http://www.springframework.org/schema/util"
-		xsi:schemaLocation="
-	        http://www.springframework.org/schema/beans     
-	        http://www.springframework.org/schema/beans/spring-beans.xsd
-	        http://www.springframework.org/schema/context 
-	        http://www.springframework.org/schema/context/spring-context.xsd
-	        http://www.springframework.org/schema/tx 
-	        http://www.springframework.org/schema/tx/spring-tx.xsd
-	        http://www.springframework.org/schema/util     
-	        http://www.springframework.org/schema/util/spring-util.xsd
-	        http://www.springframework.org/schema/mvc 
-	        http://www.springframework.org/schema/mvc/spring-mvc.xsd">
-	<!-- enable autowire -->
-    <context:annotation-config />
-    <!-- language select must remove -->
-	<mvc:annotation-driven />
-	
-	<!-- Scans the classpath for annotated components that will be auto-registered as Spring beans.
- 	 @Controller and @Service. Make sure to set the correct base-package-->
- 
- 	<!-- domain bean  -->
- 	<context:component-scan base-package="org.maxkey.domain" />
- 	<context:component-scan base-package="org.maxkey.domain.apps" />
- 	<context:component-scan base-package="org.maxkey.domain.userinfo" />
-	
-	
-	<!-- Business  Contorller -->
-	<context:component-scan base-package="org.maxkey.web.endpoint" />
-	<context:component-scan base-package="org.maxkey.web.contorller" />
-	<context:component-scan base-package="org.maxkey.web.apps.contorller" />
-	<context:component-scan base-package="org.maxkey.web.endpoint" />
-	<context:component-scan base-package="org.maxkey.authn" />
-	<context:component-scan base-package="org.maxkey.dao" />
-	<context:component-scan base-package="org.maxkey.web" />
-	<context:component-scan base-package="org.maxkey.web.tag" />
-	
-	<!-- LocaleResolver -->
-	<bean id="localeResolver" class="org.springframework.web.servlet.i18n.CookieLocaleResolver">
-		<property name="cookieDomain" value="#{applicationConfig.subDomainName}"/>
-		<property name="cookieName" value="single_sign_on_lang"/>
-		<property name="cookieMaxAge" value="604800" />
-		<!-- auto select language by brower remove -->
-		<!--<property name="defaultLocale" value="en" />  -->
-	</bean>
-	
-	<!-- 消息处理,可以直接使用properties的key值,返回的是对应的value值 -->
-    <bean id="messageSource"
-          class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
-        <property name="basenames">
-            <list>
-            	<value>classpath:messages/message</value>
-            </list>
-        </property>
-        <!-- 必须设置成false,否则hibernate原有的校验信息无法返回value值-->
-        <property name="useCodeAsDefaultMessage" value="false"/>
-    </bean>
-
-	<!-- Locale Change Interceptor and Resolver definition -->
-	<bean id="localeChangeInterceptor" class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
-		<property name="paramName" value="language" />
-	</bean>
-	
-	<!-- XML bean Marshaller define  -->
-	<bean id="Jaxb2Marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
-		<property name="classesToBeBound">
-			<list>
-				<value>org.maxkey.domain.xml.UserInfoXML</value>
-			</list>
-		</property>
-	</bean>
-	
-	<!-- MarshallingHttpMessageConverter -->
-	<bean id="marshallingHttpMessageConverter" class="org.springframework.http.converter.xml.MarshallingHttpMessageConverter">
-		<property name="marshaller" ref="Jaxb2Marshaller" />
-		<property name="unmarshaller" ref="Jaxb2Marshaller" />
-		<property name="supportedMediaTypes">
-			<list>
-				<value>application/xml;charset=UTF-8</value>
-			</list>
-		</property>
-	</bean>
-	
-	<!--MappingJacksonHttpMessageConverter  -->
-	<bean id="mappingJacksonHttpMessageConverter" class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
-		<property name="supportedMediaTypes">
-			<list>
-				<value>application/json;charset=UTF-8</value>
-			</list>
-		</property>
-	</bean>
-
-	<!-- REST Client -->
-	<bean id="restTemplate" class="org.springframework.web.client.RestTemplate">
-		<property name="messageConverters">
-			<list>
-				<ref bean="marshallingHttpMessageConverter" />
-				<ref bean="mappingJacksonHttpMessageConverter" />
-			</list>
-		</property>
-	</bean>
-	
-	<!-- AnnotationMethodHandlerAdapter -->
-	<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
-		<property name="messageConverters">
-			<util:list id="beanList">
-				<ref bean="marshallingHttpMessageConverter" />
-				<ref bean="mappingJacksonHttpMessageConverter" />
-			</util:list>
-		</property>
-	</bean>
-	
-	<bean id="handlerMapping" class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping">
-		<property name="interceptors">
-			<list>
-				<ref bean="localeChangeInterceptor" />
-			</list>
-		</property>
-	</bean>
-
-	<!-- upload file support -->
-    <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
-    	<property name="maxUploadSize" value="4194304" />  
-    </bean> 
-</beans>

+ 19 - 4
maxkey-web-manage/src/main/resources/spring/maxkey-mgt.xml

@@ -34,6 +34,25 @@
 	</bean>
 	
 	<context:component-scan base-package="org.maxkey.config" />
+	<!-- Scans the classpath for annotated components that will be auto-registered as Spring beans.
+     @Controller and @Service. Make sure to set the correct base-package-->
+ 
+    <!-- domain bean  -->
+    <context:component-scan base-package="org.maxkey.domain" />
+    <context:component-scan base-package="org.maxkey.domain.apps" />
+    <context:component-scan base-package="org.maxkey.domain.userinfo" />
+    
+    
+    <!-- Business  Contorller -->
+    <context:component-scan base-package="org.maxkey.web.endpoint" />
+    <context:component-scan base-package="org.maxkey.web.contorller" />
+    <context:component-scan base-package="org.maxkey.web.apps.contorller" />
+    <context:component-scan base-package="org.maxkey.web.endpoint" />
+    <context:component-scan base-package="org.maxkey.authn" />
+    <context:component-scan base-package="org.maxkey.dao" />
+    <context:component-scan base-package="org.maxkey.web" />
+    <context:component-scan base-package="org.maxkey.web.tag" />
+    
 	
 	<bean id="keyStoreLoader" class="org.maxkey.crypto.keystore.KeyStoreLoader">
     	<property name="entityName" value="${config.saml.v20.idp.issuing.entity.id}" />
@@ -61,10 +80,6 @@
 		<property name="passwordEncoder" ref="passwordReciprocal"></property>
 	</bean>
 	
-	<import resource="maxkey-mgt-persistence.xml"/>
-	
-	<import resource="maxkey-mgt-web.xml"/>
-	
 	<import resource="maxkey-mgt-security.xml"/>
 	
 	<import resource="maxkey-mgt-task.xml"/>

+ 67 - 27
maxkey-web-maxkey/src/main/java/org/maxkey/MaxKeyConfig.java

@@ -1,18 +1,23 @@
 package org.maxkey;
 
-import java.io.IOException;
-import java.util.Properties;
-
+import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder;
+import javax.sql.DataSource;
 import org.apache.catalina.Context;
 import org.apache.catalina.connector.Connector;
+import org.apache.ibatis.session.SqlSessionFactory;
 import org.apache.tomcat.util.descriptor.web.SecurityCollection;
 import org.apache.tomcat.util.descriptor.web.SecurityConstraint;
 import org.maxkey.authz.oauth2.provider.endpoint.TokenEndpointAuthenticationFilter;
+import org.maxkey.authn.RealmAuthenticationProvider;
 import org.maxkey.authn.SavedRequestAwareAuthenticationSuccessHandler;
 import org.maxkey.crypto.password.PasswordReciprocal;
+import org.maxkey.crypto.password.opt.algorithm.KeyUriFormat;
+import org.mybatis.spring.SqlSessionTemplate;
+import org.mybatis.spring.annotation.MapperScan;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.context.properties.ConfigurationProperties;
 import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
 import org.springframework.boot.web.server.ConfigurableWebServerFactory;
 import org.springframework.boot.web.server.ErrorPage;
@@ -21,20 +26,20 @@ import org.springframework.boot.web.servlet.FilterRegistrationBean;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.context.annotation.ImportResource;
+import org.springframework.context.annotation.Primary;
 import org.springframework.context.annotation.PropertySource;
-import org.springframework.core.io.ClassPathResource;
-import org.springframework.core.io.Resource;
 import org.springframework.http.HttpStatus;
-
-import com.google.code.kaptcha.Producer;
-import com.google.code.kaptcha.impl.DefaultKaptcha;
-import com.google.code.kaptcha.util.Config;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.jdbc.datasource.DataSourceTransactionManager;
 
 @Configuration
 @ImportResource(locations = { "classpath:spring/maxkey.xml" })
 @PropertySource("classpath:/application.properties")
+@PropertySource("classpath:/config/applicationConfig.properties")
+@MapperScan("org.maxkey.dao.persistence,")
 public class MaxKeyConfig {
     private static final  Logger _logger = LoggerFactory.getLogger(MaxKeyConfig.class);
+    
     @Value("${server.port:8080}")
     private int port;
 
@@ -42,10 +47,13 @@ public class MaxKeyConfig {
         return port;
     }
 
-    public void setPort(int port) {
-        this.port = port;
+    @Bean
+    @Primary
+    @ConfigurationProperties("spring.datasource")
+    public DataSource dataSource() {
+        return DruidDataSourceBuilder.create().build();
     }
-
+    
     @Bean
     public FilterRegistrationBean<TokenEndpointAuthenticationFilter> TokenEndpointAuthenticationFilter() {
         FilterRegistrationBean<TokenEndpointAuthenticationFilter> registration = new FilterRegistrationBean<TokenEndpointAuthenticationFilter>();
@@ -66,6 +74,7 @@ public class MaxKeyConfig {
         return new WebServerFactoryCustomizer<ConfigurableWebServerFactory>() {
             @Override
             public void customize(ConfigurableWebServerFactory factory) {
+                _logger.debug("WebServerFactoryCustomizer ... ");
                 ErrorPage errorPage400 = new ErrorPage(HttpStatus.BAD_REQUEST, "/exception/error/400");
                 ErrorPage errorPage404 = new ErrorPage(HttpStatus.NOT_FOUND, "/exception/error/404");
                 ErrorPage errorPage500 = new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/exception/error/500");
@@ -111,21 +120,52 @@ public class MaxKeyConfig {
         return new SavedRequestAwareAuthenticationSuccessHandler();
     }
     
-    /**
-     * Captcha Producer  Config .
-     * @return Producer
-     * @throws IOException
-     */
-    @Bean(name = "captchaProducer")
-    public Producer captchaProducer() throws IOException{
-        Resource resource = new ClassPathResource("config/kaptcha.properties");
-        _logger.debug("Kaptcha config file " + resource.getURL());
-        DefaultKaptcha  kaptcha=new DefaultKaptcha();
-        Properties properties = new Properties();
-        properties.load(resource.getInputStream());
-        Config config = new Config(properties);
-        kaptcha.setConfig(config);
-        return kaptcha;
+    
+    @Value("${config.otp.keyuri.format.type:totp}")
+    String keyuriFormatType;
+    
+    @Value("${config.otp.keyuri.format.domain:MaxKey.top}")
+    String keyuriFormatDomain;
+    
+    @Value("${config.otp.keyuri.format.issuer:MaxKey}")
+    String keyuriFormatIssuer;
+    
+    @Value("${config.otp.keyuri.format.digits:6}")
+    int keyuriFormatDigits;
+    
+    @Value("${config.otp.keyuri.format.period:30}")
+    int keyuriFormatPeriod;
+    
+    @Bean(name = "keyUriFormat")
+    public KeyUriFormat keyUriFormat() {
+        KeyUriFormat keyUriFormat=new KeyUriFormat();
+        keyUriFormat.setType(keyuriFormatType);
+        keyUriFormat.setDomain(keyuriFormatDomain);
+        keyUriFormat.setIssuer(keyuriFormatIssuer);
+        keyUriFormat.setDigits(keyuriFormatDigits);
+        keyUriFormat.setPeriod(keyuriFormatPeriod);
+        _logger.debug("KeyUri Format " + keyUriFormat);
+        return keyUriFormat;
     }
 
+    @Bean(name = "authenticationProvider")
+    public RealmAuthenticationProvider authenticationProvider() {
+        return new RealmAuthenticationProvider();
+    }
+    
+    @Bean(name = "jdbcTemplate")
+    public JdbcTemplate jdbcTemplate(DataSource dataSource) {
+        return new JdbcTemplate(dataSource);
+    }
+    
+    @Bean(name = "sqlSession")
+    public SqlSessionTemplate sqlSession(SqlSessionFactory sqlSessionFactory) throws Exception {
+        return new SqlSessionTemplate(sqlSessionFactory);
+    }
+    
+    @Bean(name = "transactionManager")
+    DataSourceTransactionManager transactionManager(DataSource dataSource) {
+        return new DataSourceTransactionManager(dataSource);
+    }
+    
 }

+ 50 - 0
maxkey-web-maxkey/src/main/java/org/maxkey/RedisAutoConfiguration.java

@@ -0,0 +1,50 @@
+package org.maxkey;
+
+import org.maxkey.persistence.redis.RedisConnectionFactory;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.PropertySource;
+
+import redis.clients.jedis.JedisPoolConfig;
+
+@Configuration
+@PropertySource("classpath:/application.properties")
+public class RedisAutoConfiguration {
+    
+    @Value("${spring.redis.host}")
+    private String host;
+    @Value("${spring.redis.port}")
+    private int port;
+    @Value("${spring.redis.timeout}")
+    private int timeout;
+    @Value("${spring.redis.password}")
+    private String password;
+    @Value("${spring.redis.lettuce.pool.max-active}")
+    private int maxActive;
+    @Value("${spring.redis.jedis.pool.max-wait}")
+    private int maxWait;
+    @Value("${spring.redis.jedis.pool.max-idle}")
+    private int maxIdle;
+    @Value("${spring.redis.lettuce.pool.min-idle}")
+    private int minIdle;
+    
+    @Bean
+    public RedisConnectionFactory redisConnectionFactory() {
+        RedisConnectionFactory factory = new RedisConnectionFactory();
+        factory.setHostName(host);
+        factory.setPort(port);
+        factory.setTimeOut(timeout); 
+        factory.setPassword(password);
+        
+        JedisPoolConfig poolConfig = new JedisPoolConfig();
+        poolConfig.setMaxIdle(maxIdle);
+        poolConfig.setMinIdle(minIdle);
+        poolConfig.setMaxTotal(maxActive);
+        poolConfig.setMaxWaitMillis(maxWait);
+        
+        factory.setPoolConfig(poolConfig);
+        
+        return factory;
+    }
+}

+ 1 - 1
maxkey-web-maxkey/src/main/java/org/maxkey/web/contorller/OneTimePasswordController.java

@@ -10,8 +10,8 @@ import org.maxkey.crypto.password.opt.algorithm.OtpSecret;
 import org.maxkey.dao.service.UserInfoService;
 import org.maxkey.domain.UserInfo;
 import org.maxkey.util.RQCodeUtils;
-import org.maxkey.web.ImageEndpoint;
 import org.maxkey.web.WebContext;
+import org.maxkey.web.image.ImageEndpoint;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;

+ 1 - 1
maxkey-web-maxkey/src/main/java/org/maxkey/web/contorller/RegistrationController.java

@@ -80,7 +80,7 @@ public class RegistrationController {
 			email.setAuthenticator(new DefaultAuthenticator(applicationConfig.getEmailConfig().getUsername(), applicationConfig.getEmailConfig().getPassword()));
 			
 			email.addTo(registration.getWorkEmail(), registration.getLastName()+registration.getFirstName());
-			email.setFrom(applicationConfig.getEmailConfig().getSenderMail(), "ConnSec");
+			email.setFrom(applicationConfig.getEmailConfig().getSender(), "ConnSec");
 			email.setSubject("ConnSec Cloud Identity & Access Registration activate Email .");
 			  
 			String activateUrl=WebContext.getHttpContextPath()+"/registration/forward/activate/"+registration.getId();

+ 5 - 0
maxkey-web-maxkey/src/main/resources/META-INF/spring.factories

@@ -0,0 +1,5 @@
+# Auto Configure
+org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
+org.maxkey.RedisAutoConfiguration,\
+org.maxkey.config.KaptchaAutoConfiguration,\
+org.maxkey.config.MvcAutoConfiguration

+ 41 - 7
maxkey-web-maxkey/src/main/resources/application.properties

@@ -1,3 +1,8 @@
+#spring.profiles.active=dev
+#application
+application.title=MaxKey
+application.name=MaxKey
+application.formatted-version=v1.5.0 GA
 #server config
 #spring.profiles.active=dev
 #server port
@@ -9,13 +14,41 @@ server.ssl.key-alias=maxkey
 server.ssl.enabled=true
 server.ssl.key-store-password=maxkey
 server.ssl.key-store-type=JKS
-
 #web app context path
 server.servlet.context-path=/maxkey
-
-application.name=MaxKey
-application.formatted-version=v1.5.0 GA
-
+spring.servlet.multipart.enabled=true
+spring.servlet.multipart.max-file-size=4194304
+#encoding
+#server.servlet.encoding.charset=UTF-8
+#server.servlet.encoding.enabled=true
+#server.servlet.encoding.force=true
+#datasource
+spring.datasource.username=root
+spring.datasource.password=maxkey
+spring.datasource.url=jdbc:mysql://localhost/maxkey?autoReconnect=true&characterEncoding=UTF-8
+spring.datasource.driver-class-name=com.mysql.jdbc.Driver
+spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
+#mybatis
+mybatis.type-aliases-package=org.maxkey.domain,org.maxkey.domain.apps,
+mybatis.mapper-locations=classpath*:/org/maxkey/dao/persistence/xml/mysql/*.xml
+#redis
+spring.redis.host=127.0.0.1
+spring.redis.port=6379
+spring.redis.password=password
+spring.redis.timeout=10000
+spring.redis.jedis.pool.max-wait=1000
+spring.redis.jedis.pool.max-idle=200
+spring.redis.lettuce.pool.max-active=-1
+spring.redis.lettuce.pool.min-idle=0
+#mail
+spring.mail.default-encoding=utf-8
+spring.mail.host=smtp.163.com
+spring.mail.port=465
+spring.mail.username=maxkey@163.com
+spring.mail.password=password
+spring.mail.protocol=smtp
+spring.mail.properties.ssl=true
+spring.mail.properties.sender=maxkey@163.com
 #for freemarker
 spring.freemarker.template-loader-path=classpath:/templates/views
 spring.freemarker.cache=false
@@ -26,8 +59,9 @@ spring.freemarker.expose-request-attributes=false
 spring.freemarker.expose-session-attributes=false
 spring.freemarker.request-context-attribute=request
 spring.freemarker.suffix=.ftl
-
 #static resources
 spring.mvc.static-path-pattern=/static/**
-
+spring.messages.basename=classpath:messages/message
+spring.messages.encoding=UTF-8
+#main
 spring.main.allow-bean-definition-overriding=true

+ 8 - 65
maxkey-web-maxkey/src/main/resources/config/applicationConfig.properties

@@ -8,73 +8,9 @@ config.server.name=http://${config.server.domain.sub}
 config.server.prefix.uri=${config.server.name}/maxkey
 #default.uri
 config.server.default.uri=${config.server.prefix.uri}/maxkey/appList
-config.server.manage.uri=${config.server.name}:9521/maxkey-mgt/login
-
-############################################################################
-#                DataBase configuration  
-############################################################################
-#db2,derby,mysql,oracle,postgresql,sqlserver at com.connsec.db.mybatis.dialect.Dialect
-config.datasource.database=mysql
-# JDBC Driver                                                              
-#     for MySql         com.mysql.jdbc.Driver                              
-#     for oracle        oracle.jdbc.driver.OracleDriver                    
-#     for DB2           com.ibm.db2.jdbc.app.DB2Driver                     
-#     for SqlServer     com.microsoft.jdbc.sqlserver.SQLServerDriver        
-#     for SyBase        com.sybase.jdbc.SybDriver                          
-#     for PostgreSQL    org.postgresql.Driver        
-#	  for Derby			org.apache.derby.jdbc.ClientDriver  
-config.datasource.driverclass=com.mysql.jdbc.Driver
-# JDBC URL
-#    you need database hostname,port,databasename
-#     for MySql           jdbc:mysql://hostname:port/secdb
-#     for oracle          jdbc:oracle:thin:@hostname:port:secdb
-#     for DB2             jdbc:db2://hostname:port/secdb
-#     for SqlServer       jdbc:microsoft:sqlserver://hostname:port;DatabaseName=secdb
-#     for SyBase          jdbc:sybase:Tds:hostname:port/secdb
-#	  for Derby			  jdbc:derby://localhost:1527/secdb
-#
-config.datasource.url=jdbc:mysql://localhost/maxkey?autoReconnect=true&characterEncoding=UTF-8
-config.datasource.username=root
-config.datasource.password=maxkey
-config.datasource.password.encrypt=false
-############################################################################ 
-#                EMAIL configuration
-############################################################################
-config.email.username=maxkey@163.com
-config.email.password=password
-config.email.smtpHost=smtp.163.com
-config.email.port=465
-config.email.senderMail=maxkey@163.com
-config.email.ssl=true
-
-############################################################################
-#               CharacterEncoding configuration
-############################################################################
-#				CharacterEncoding true/false
-
-config.characterencoding.encoding=true
-config.characterencoding.charset.from=iso8859-1
-config.characterencoding.charset.to=UTF-8
-
+config.server.management.uri=${config.server.name}:9521/maxkey-mgt/login
 
 config.app.issuer=CN=ConSec,CN=COM,CN=SH
-############################################################################ 
-#IP  
-config.redis.hostname=127.0.0.1
-#port  
-config.redis.port=6379
-#password  
-config.redis.password=password
-#
-config.redis.timeout=10000
-#
-config.redis.pool.maxtotal=1000
-# 
-config.redis.pool.maxidle=200
-#  
-config.redis.pool.maxwaitmillis=1000
-# 
-config.redis.pool.testonborrow=true
 ############################################################################
 #                Login configuration
 #enable captcha
@@ -98,6 +34,13 @@ config.login.remeberme.validity=
 config.login.default.uri=appList
 
 config.ipaddress.whitelist=false
+
+config.otp.keyuri.format.type=totp
+config.otp.keyuri.format.digits=6
+config.otp.keyuri.format.issuer=MaxKey
+config.otp.keyuri.format.domain=${config.server.domain}
+config.otp.keyuri.format.period=30
+
 ############################################################################ 
 #                Kerberos Login configuration
 ############################################################################

+ 0 - 0
maxkey-web-maxkey/src/main/resources/config/kaptcha.properties → maxkey-web-maxkey/src/main/resources/kaptcha.properties


+ 0 - 103
maxkey-web-maxkey/src/main/resources/spring/maxkey-persistence.xml

@@ -1,103 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<beans 	xmlns="http://www.springframework.org/schema/beans"
-		xmlns:context="http://www.springframework.org/schema/context"
-		xmlns:mvc="http://www.springframework.org/schema/mvc"
-		xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-		xmlns:p="http://www.springframework.org/schema/p"
-		xmlns:util="http://www.springframework.org/schema/util"
-		xsi:schemaLocation="
-	        http://www.springframework.org/schema/beans 
-			http://www.springframework.org/schema/beans/spring-beans.xsd
-			http://www.springframework.org/schema/context 
-			http://www.springframework.org/schema/context/spring-context.xsd
-	        http://www.springframework.org/schema/util     
-	        http://www.springframework.org/schema/util/spring-util.xsd
-	        http://www.springframework.org/schema/mvc 
-			http://www.springframework.org/schema/mvc/spring-mvc.xsd">
-
-	<!-- dataSource define begin -->
-	<!-- dataSource configuration -->
-	<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"  destroy-method="close" >      
-	   <!--  <property name="driverClass" value="#{dataSoruceConfig.driverClass}"/>     -->  
-	    <property name="url" value="#{dataSoruceConfig.url}"/>      
-	    <property name="username" value="#{dataSoruceConfig.username}"/>      
-	    <property name="password" value="#{dataSoruceConfig.password}"/>      
-	</bean> 
-	
-	<!-- JNDI data source  configuration -->
-	<!-- jndiName is jndi name -->
-	<!-- if you don,t want use prefix 'java:comp/env/' set resourceRef to true,default is false -->
-    <!-- 
-    <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">  
-        <property name="jndiName" value="jndi_maxkey_db" />
-        <property name="resourceRef" value="true" />  
-    </bean>  -->
-	<!-- dataSource define end -->
-	
-	<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">  
-		<property name="dataSource" ref="dataSource"></property>  
-	</bean> 
-
-	 <!-- Declare a transaction manager -->
- 	<!-- transaction manager, use JtaTransactionManager for global tx-->
-    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
-        <property name="dataSource" ref="dataSource" />
-    </bean> 
-    
-	<!-- Enable annotation style of managing transactions 
-	<tx:annotation-driven transaction-manager="transactionManager" />-->
-    
-    <!-- enable component scanning (beware that this does not enable mapper scanning!) -->    
-    <context:component-scan base-package="org.maxkey.dao.service" />
-    
-    <!-- enable autowire -->
-    <context:annotation-config />
-
-    <!-- enable transaction demarcation with annotations 
-    <tx:annotation-driven />-->
-
-
-	<!--<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">-->
-	<bean id="sqlSessionFactory" class="org.apache.mybatis.jpa.MyBatisSessionFactoryBean">
-		<property name="dataSource" ref="dataSource" />
-		<property name="dialect" value="mysql" />
-		<property name="timeout" value="30" />
-		<property name="transactionFactory">
-			<bean class="org.apache.ibatis.transaction.managed.ManagedTransactionFactory" />
-		</property>
-		<property name="typeAliasesPackage" 
-        		  value="
-	        			org.maxkey.domain,
-	        			org.maxkey.domain.apps,
-        			" />
-		<property name="mapperLocations" value="classpath*:/org/maxkey/dao/persistence/xml/#{dataSoruceConfig.database}/*.xml" />
-	</bean>
-	
-	<bean id="sqlSession" class="org.mybatis.spring.SqlSessionTemplate">
-		<constructor-arg index="0" ref="sqlSessionFactory" />
-	</bean>
-	
-
-    <!-- scan for mappers and let them be autowired -->
-    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
-        <property name="basePackage" 
-        		  value="
-        		  		org.maxkey.dao.persistence,
-        		  		" />
-    </bean>
-
-	<bean id="redisConnectionFactory" class="org.maxkey.persistence.redis.RedisConnectionFactory">
-		<property name="hostname" value="${config.redis.hostname}"/>
-		<property name="port" value="${config.redis.port}"/>
-		<property name="timeOut" value="${config.redis.timeout}"/>
-		<property name="poolConfig"  >
-			<bean class="redis.clients.jedis.JedisPoolConfig">
-				<property name="maxTotal" value="${config.redis.pool.maxtotal}" />
-				<property name="maxIdle" value="${config.redis.pool.maxidle}" />
-				<property name="maxWaitMillis" value="${config.redis.pool.maxwaitmillis}" />
-				<property name="testOnBorrow" value="${config.redis.pool.testonborrow}" />
-			</bean>  
-		</property>
-	</bean>
-	
-</beans>

+ 5 - 15
maxkey-web-maxkey/src/main/resources/spring/maxkey-security.xml

@@ -75,15 +75,11 @@
 	  
 	<bean id="remeberMeService" class="org.maxkey.authn.support.rememberme.InMemoryRemeberMeService">
 	</bean>
-	
-	<bean id="keyUriFormat" class="org.maxkey.crypto.password.opt.algorithm.KeyUriFormat">
-		<property name="type" value="totp" />
-		<property name="digits" value="6" />
-		<property name="issuer" value="MaxKey" />
-		<property name="domain" value="MaxKey.org" />
-		<property name="period" value="30" />
-	</bean>
-	
+	 <!--
+	<bean id="remeberMeService" class="org.maxkey.authn.support.rememberme.RedisRemeberMeService">
+	   <property name="connectionFactory" ref="redisConnectionFactory"></property>
+    </bean>
+    -->
 	<bean id="tfaOptAuthn" class="org.maxkey.crypto.password.opt.impl.TimeBasedOtpAuthn">
 	</bean>
 	<!-- 
@@ -98,7 +94,6 @@
 	<bean id="tfaMobileOptAuthn" class="org.maxkey.crypto.password.opt.impl.sms.SmsOtpAuthnYunxin">
 	</bean>
 	 
-
 	<!-- Authentication Password Encoder Config -->
 	<bean id="passwordEncoder" class="org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder"></bean>   
 	
@@ -146,11 +141,6 @@
 	<bean id="authenticationRealm" class="org.maxkey.authn.realm.jdbc.JdbcAuthenticationRealm">
 		<constructor-arg ref="jdbcTemplate"/>
 	</bean>
-	
-		
-	<!-- Authentication providers -->
-    <bean id="authenticationProvider" class="org.maxkey.authn.RealmAuthenticationProvider" >
-    </bean>
    
 	<mvc:annotation-driven />
 

+ 0 - 108
maxkey-web-maxkey/src/main/resources/spring/maxkey-web.xml

@@ -1,108 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<beans 	xmlns="http://www.springframework.org/schema/beans"
-		xmlns:context="http://www.springframework.org/schema/context"
-		xmlns:mvc="http://www.springframework.org/schema/mvc"
-		xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-		xmlns:p="http://www.springframework.org/schema/p"
-		xmlns:tx="http://www.springframework.org/schema/tx"
-		xmlns:util="http://www.springframework.org/schema/util"
-		xsi:schemaLocation="
-	        http://www.springframework.org/schema/beans     
-	        http://www.springframework.org/schema/beans/spring-beans.xsd
-	        http://www.springframework.org/schema/context 
-	        http://www.springframework.org/schema/context/spring-context.xsd
-	        http://www.springframework.org/schema/tx 
-	        http://www.springframework.org/schema/tx/spring-tx.xsd
-	        http://www.springframework.org/schema/util     
-	        http://www.springframework.org/schema/util/spring-util.xsd
-	        http://www.springframework.org/schema/mvc 
-	        http://www.springframework.org/schema/mvc/spring-mvc.xsd">
-
-	<!-- LocaleResolver -->
-	<bean id="localeResolver" class="org.springframework.web.servlet.i18n.CookieLocaleResolver">
-		<property name="cookieDomain" value="#{applicationConfig.subDomainName}"/>
-		<property name="cookieName" value="maxkey_lang"/>
-		<property name="cookieMaxAge" value="604800" />
-		<!-- auto select language by brower remove -->
-		<!--<property name="defaultLocale" value="en" />  -->
-	</bean>
-	
-	<!-- 消息处理,可以直接使用properties的key值,返回的是对应的value值 -->
-    <bean id="messageSource"
-          class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
-        <property name="basenames">
-            <list>
-            	<value>classpath:messages/message</value>
-            </list>
-        </property>
-        <!-- 必须设置成false,否则hibernate原有的校验信息无法返回value值-->
-        <property name="useCodeAsDefaultMessage" value="false"/>
-    </bean>
-
-	<!-- Locale Change Interceptor and Resolver definition -->
-	<bean id="localeChangeInterceptor" class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
-		<property name="paramName" value="language" />
-	</bean>
-	
-	<!-- XML bean Marshaller define  -->
-	<bean id="Jaxb2Marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
-		<property name="classesToBeBound">
-			<list>
-				<value>org.maxkey.domain.xml.UserInfoXML</value>
-			</list>
-		</property>
-	</bean>
-	
-	<!-- MarshallingHttpMessageConverter -->
-	<bean id="marshallingHttpMessageConverter" class="org.springframework.http.converter.xml.MarshallingHttpMessageConverter">
-		<property name="marshaller" ref="Jaxb2Marshaller" />
-		<property name="unmarshaller" ref="Jaxb2Marshaller" />
-		<property name="supportedMediaTypes">
-			<list>
-				<value>application/xml;charset=UTF-8</value>
-			</list>
-		</property>
-	</bean>
-	
-	<!--MappingJacksonHttpMessageConverter  -->
-	<bean id="mappingJacksonHttpMessageConverter" class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
-		<property name="supportedMediaTypes">
-			<list>
-				<value>application/json;charset=UTF-8</value>
-			</list>
-		</property>
-	</bean>
-
-	<!-- REST Client -->
-	<bean id="restTemplate" class="org.springframework.web.client.RestTemplate">
-		<property name="messageConverters">
-			<list>
-				<ref bean="marshallingHttpMessageConverter" />
-				<ref bean="mappingJacksonHttpMessageConverter" />
-			</list>
-		</property>
-	</bean>
-	
-	<!-- AnnotationMethodHandlerAdapter -->
-	<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
-		<property name="messageConverters">
-			<util:list id="beanList">
-				<ref bean="marshallingHttpMessageConverter" />
-				<ref bean="mappingJacksonHttpMessageConverter" />
-			</util:list>
-		</property>
-	</bean>
-	
-	<bean id="handlerMapping" class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping">
-		<property name="interceptors">
-			<list>
-				<ref bean="localeChangeInterceptor" />
-			</list>
-		</property>
-	</bean>
-
-	<!-- upload file support -->
-    <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
-    	<property name="maxUploadSize" value="4194304" />  
-    </bean> 
-</beans>

+ 0 - 4
maxkey-web-maxkey/src/main/resources/spring/maxkey.xml

@@ -43,8 +43,6 @@
 	<context:component-scan base-package="org.maxkey.web.endpoint" />
 	<context:component-scan base-package="org.maxkey.web.contorller" />
 	
- 	<!-- persistence configuration  -->
- 	<import resource="maxkey-persistence.xml"/>
 	<!-- authn support -->
  	<import resource="maxkey-support.xml"/>
  	<!-- single sign on protocol -->
@@ -53,7 +51,5 @@
  	<import resource="maxkey-task.xml"/>
 	<!-- Basic Authn  for user login -->
  	<import resource="maxkey-security.xml"/>
- 	<!-- web mvc  configuration -->
- 	<import resource="maxkey-web.xml"/>
  	
 </beans>