diff --git a/maxkey-core/src/main/java/org/maxkey/config/MvcAutoConfiguration.java b/maxkey-core/src/main/java/org/maxkey/config/MvcAutoConfiguration.java
index ddaf1b68f..165da1d20 100644
--- a/maxkey-core/src/main/java/org/maxkey/config/MvcAutoConfiguration.java
+++ b/maxkey-core/src/main/java/org/maxkey/config/MvcAutoConfiguration.java
@@ -1,14 +1,18 @@
package org.maxkey.config;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.InitializingBean;
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.PropertySourcesPlaceholderConfigurer;
import org.springframework.context.support.ReloadableResourceBundleMessageSource;
+import org.springframework.core.io.ClassPathResource;
import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
@@ -25,22 +29,39 @@ import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandl
@Configuration
@PropertySource("classpath:/application.properties")
@PropertySource("classpath:/config/applicationConfig.properties")
-public class MvcAutoConfiguration {
+public class MvcAutoConfiguration implements InitializingBean {
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;
+
+ /**
+ * propertySourcesPlaceholderConfigurer .
+ * @return propertySourcesPlaceholderConfigurer
+ * @throws IOException null
+ */
+ @Bean (name = "propertySourcesPlaceholderConfigurer")
+ public PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer()
+ throws IOException {
+ ClassPathResource classPathResource1 =
+ new ClassPathResource("/config/applicationConfig.properties");
+ ClassPathResource classPathResource2 = new ClassPathResource("/application.properties");
+
+ PropertySourcesPlaceholderConfigurer configurer =
+ new PropertySourcesPlaceholderConfigurer();
+ configurer.setLocations(
+ classPathResource1,
+ classPathResource2
+ );
+ configurer.setIgnoreUnresolvablePlaceholders(true);
+ return configurer;
+ }
+
/**
* cookieLocaleResolver .
* @return cookieLocaleResolver
*/
@Bean (name = "localeResolver")
- public CookieLocaleResolver cookieLocaleResolver() {
+ public CookieLocaleResolver cookieLocaleResolver(
+ @Value("${config.server.domain.sub:maxkey.top}")String subDomainName) {
_logger.debug("subDomainName " + subDomainName);
CookieLocaleResolver cookieLocaleResolver = new CookieLocaleResolver();
cookieLocaleResolver.setCookieName("maxkey_lang");
@@ -55,8 +76,11 @@ public class MvcAutoConfiguration {
* @return messageSource
*/
@Bean (name = "messageSource")
- public ReloadableResourceBundleMessageSource reloadableResourceBundleMessageSource() {
+ public ReloadableResourceBundleMessageSource reloadableResourceBundleMessageSource(
+ @Value("${spring.messages.basename:classpath:messages/message}")
+ String messagesBasename) {
_logger.debug("Basename " + messagesBasename);
+
ReloadableResourceBundleMessageSource messageSource =
new ReloadableResourceBundleMessageSource();
messageSource.setBasename(messagesBasename);
@@ -82,7 +106,8 @@ public class MvcAutoConfiguration {
* @return multipartResolver
*/
@Bean (name = "multipartResolver")
- public CommonsMultipartResolver commonsMultipartResolver() {
+ public CommonsMultipartResolver commonsMultipartResolver(
+ @Value("${spring.servlet.multipart.max-file-size:0}") int maxUploadSize) {
_logger.debug("maxUploadSize " + maxUploadSize);
CommonsMultipartResolver multipartResolver =
new CommonsMultipartResolver();
@@ -180,8 +205,12 @@ public class MvcAutoConfiguration {
restTemplate.setMessageConverters(httpMessageConverterList);
return restTemplate;
}
-
-
+
+ @Override
+ public void afterPropertiesSet() throws Exception {
+ // TODO Auto-generated method stub
+
+ }
}
diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/password/opt/algorithm/KeyUriFormat.java b/maxkey-core/src/main/java/org/maxkey/crypto/password/opt/algorithm/KeyUriFormat.java
index c504f8707..00d729427 100644
--- a/maxkey-core/src/main/java/org/maxkey/crypto/password/opt/algorithm/KeyUriFormat.java
+++ b/maxkey-core/src/main/java/org/maxkey/crypto/password/opt/algorithm/KeyUriFormat.java
@@ -202,4 +202,11 @@ public class KeyUriFormat {
return uri.toString();
}
+ @Override
+ public String toString() {
+ return "KeyUriFormat [crypto=" + crypto + ", type=" + type + ", secret=" + secret + ", issuer=" + issuer
+ + ", domain=" + domain + ", digits=" + digits + ", counter=" + counter + ", period=" + period
+ + ", account=" + account + "]";
+ }
+
}
diff --git a/maxkey-web-manage/src/main/resources/application.properties b/maxkey-web-manage/src/main/resources/application.properties
index f722138b4..856c6060d 100644
--- a/maxkey-web-manage/src/main/resources/application.properties
+++ b/maxkey-web-manage/src/main/resources/application.properties
@@ -47,5 +47,7 @@ spring.freemarker.suffix=.ftl
#static resources
spring.mvc.static-path-pattern=/static/**
+spring.messages.basename=classpath:messages/message
+spring.messages.encoding=UTF-8
spring.main.allow-bean-definition-overriding=true
\ No newline at end of file
diff --git a/maxkey-web-manage/src/main/resources/spring/maxkey-mgt.xml b/maxkey-web-manage/src/main/resources/spring/maxkey-mgt.xml
index db3d124a6..a24d596c8 100644
--- a/maxkey-web-manage/src/main/resources/spring/maxkey-mgt.xml
+++ b/maxkey-web-manage/src/main/resources/spring/maxkey-mgt.xml
@@ -21,18 +21,7 @@
-
-
-
-
-
- classpath:config/applicationConfig.properties
- classpath:application.properties
-
-
-
-
-
+
diff --git a/maxkey-web-maxkey/src/main/java/org/maxkey/MaxKeyConfig.java b/maxkey-web-maxkey/src/main/java/org/maxkey/MaxKeyConfig.java
index eff36cdb3..a3d229020 100644
--- a/maxkey-web-maxkey/src/main/java/org/maxkey/MaxKeyConfig.java
+++ b/maxkey-web-maxkey/src/main/java/org/maxkey/MaxKeyConfig.java
@@ -120,24 +120,19 @@ public class MaxKeyConfig {
return new SavedRequestAwareAuthenticationSuccessHandler();
}
-
- @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() {
+ public KeyUriFormat keyUriFormat(
+ @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) {
+
KeyUriFormat keyUriFormat=new KeyUriFormat();
keyUriFormat.setType(keyuriFormatType);
keyUriFormat.setDomain(keyuriFormatDomain);
diff --git a/maxkey-web-maxkey/src/main/resources/spring/maxkey.xml b/maxkey-web-maxkey/src/main/resources/spring/maxkey.xml
index fd224c6a7..e723a020f 100644
--- a/maxkey-web-maxkey/src/main/resources/spring/maxkey.xml
+++ b/maxkey-web-maxkey/src/main/resources/spring/maxkey.xml
@@ -17,17 +17,6 @@
http://www.springframework.org/schema/util/spring-util.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd">
-
-
-
-
-
- classpath:config/applicationConfig.properties
- classpath:application.properties
-
-
-
-