瀏覽代碼

separate common

MaxKey 4 年之前
父節點
當前提交
647d899771
共有 100 個文件被更改,包括 1605 次插入76 次删除
  1. 1 0
      .gitignore
  2. 7 7
      build.gradle
  3. 1 1
      gradle.properties
  4. 1 0
      maxkey-authentications/maxkey-authentication-captcha/build.gradle
  5. 1 0
      maxkey-authentications/maxkey-authentication-core/build.gradle
  6. 13 0
      maxkey-authentications/maxkey-authentication-otp/build.gradle
  7. 3 0
      maxkey-authentications/maxkey-authentication-otp/src/main/java/META-INF/MANIFEST.MF
  8. 7 7
      maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/AbstractOtpAuthn.java
  9. 1 1
      maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/OneTimePassword.java
  10. 1 1
      maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/algorithm/HOTP.java
  11. 1 1
      maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/algorithm/HmacOTP.java
  12. 1 1
      maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/algorithm/KeyUriFormat.java
  13. 1 1
      maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/algorithm/OtpSecret.java
  14. 1 1
      maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/algorithm/TimeBasedOTP.java
  15. 3 3
      maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/impl/CapOtpAuthn.java
  16. 4 4
      maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/impl/CounterBasedOtpAuthn.java
  17. 4 4
      maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/impl/HotpOtpAuthn.java
  18. 3 3
      maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/impl/MailOtpAuthn.java
  19. 3 3
      maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/impl/MobileOtpAuthn.java
  20. 3 3
      maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/impl/RsaOtpAuthn.java
  21. 3 3
      maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/impl/SmsOtpAuthn.java
  22. 4 4
      maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/impl/TimeBasedOtpAuthn.java
  23. 2 2
      maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/impl/sms/SmsOtpAuthnAliyun.java
  24. 2 2
      maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/impl/sms/SmsOtpAuthnTencentCloud.java
  25. 2 2
      maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/impl/sms/SmsOtpAuthnYunxin.java
  26. 1 1
      maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/impl/sms/SmsOtpAuthnYunxinCheckSumBuilder.java
  27. 2 2
      maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/token/AbstractOtpTokenStore.java
  28. 5 5
      maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/token/InMemoryOtpTokenStore.java
  29. 4 4
      maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/token/RedisOtpTokenStore.java
  30. 2 2
      maxkey-authentications/maxkey-authentication-otp/src/test/java/org/maxkey/otp/algorithm/HmacOTPTest.java
  31. 1 1
      maxkey-authentications/maxkey-authentication-otp/src/test/java/org/maxkey/otp/algorithm/KeyUriFormatTest.java
  32. 1 1
      maxkey-authentications/maxkey-authentication-otp/src/test/java/org/maxkey/otp/algorithm/TimeBasedOTPTest.java
  33. 1 0
      maxkey-authentications/maxkey-authentication-social/build.gradle
  34. 7 0
      maxkey-common/build.gradle
  35. 3 0
      maxkey-common/src/main/java/META-INF/MANIFEST.MF
  36. 0 0
      maxkey-common/src/main/java/org/maxkey/cache/AbstractCache.java
  37. 0 0
      maxkey-common/src/main/java/org/maxkey/cache/CacheFactory.java
  38. 0 0
      maxkey-common/src/main/java/org/maxkey/cache/package-info.java
  39. 230 0
      maxkey-common/src/main/java/org/maxkey/configuration/ApplicationConfig.java
  40. 115 0
      maxkey-common/src/main/java/org/maxkey/configuration/CharacterEncodingConfig.java
  41. 149 0
      maxkey-common/src/main/java/org/maxkey/configuration/EmailConfig.java
  42. 147 0
      maxkey-common/src/main/java/org/maxkey/configuration/LoginConfig.java
  43. 57 0
      maxkey-common/src/main/java/org/maxkey/configuration/oidc/OIDCProviderMetadata.java
  44. 151 0
      maxkey-common/src/main/java/org/maxkey/configuration/oidc/OIDCProviderMetadataDetails.java
  45. 58 0
      maxkey-common/src/main/java/org/maxkey/constants/Boolean.java
  46. 29 0
      maxkey-common/src/main/java/org/maxkey/constants/ConstantsEntryType.java
  47. 37 0
      maxkey-common/src/main/java/org/maxkey/constants/ConstantsLoginType.java
  48. 36 0
      maxkey-common/src/main/java/org/maxkey/constants/ConstantsOperateAction.java
  49. 31 0
      maxkey-common/src/main/java/org/maxkey/constants/ConstantsOperateMessage.java
  50. 35 0
      maxkey-common/src/main/java/org/maxkey/constants/ConstantsPasswordSetType.java
  51. 33 0
      maxkey-common/src/main/java/org/maxkey/constants/ConstantsPersistence.java
  52. 27 0
      maxkey-common/src/main/java/org/maxkey/constants/ConstantsPlatformRole.java
  53. 41 0
      maxkey-common/src/main/java/org/maxkey/constants/ConstantsProperties.java
  54. 48 0
      maxkey-common/src/main/java/org/maxkey/constants/ConstantsProtocols.java
  55. 137 0
      maxkey-common/src/main/java/org/maxkey/constants/ConstantsServiceMessage.java
  56. 49 0
      maxkey-common/src/main/java/org/maxkey/constants/ConstantsStatus.java
  57. 40 0
      maxkey-common/src/main/java/org/maxkey/constants/ConstantsTimeInterval.java
  58. 50 0
      maxkey-common/src/main/java/org/maxkey/constants/ContentType.java
  59. 0 0
      maxkey-common/src/main/java/org/maxkey/crypto/Base32Utils.java
  60. 0 0
      maxkey-common/src/main/java/org/maxkey/crypto/Base64Utils.java
  61. 0 0
      maxkey-common/src/main/java/org/maxkey/crypto/BytesUtils.java
  62. 0 0
      maxkey-common/src/main/java/org/maxkey/crypto/DigestUtils.java
  63. 0 0
      maxkey-common/src/main/java/org/maxkey/crypto/HexUtils.java
  64. 0 0
      maxkey-common/src/main/java/org/maxkey/crypto/KeyPairSize.java
  65. 0 0
      maxkey-common/src/main/java/org/maxkey/crypto/KeyPairType.java
  66. 0 0
      maxkey-common/src/main/java/org/maxkey/crypto/KeyPairUtil.java
  67. 0 0
      maxkey-common/src/main/java/org/maxkey/crypto/Md5Sum.java
  68. 0 0
      maxkey-common/src/main/java/org/maxkey/crypto/RSAUtils.java
  69. 0 0
      maxkey-common/src/main/java/org/maxkey/crypto/ReciprocalUtils.java
  70. 0 0
      maxkey-common/src/main/java/org/maxkey/crypto/SM3.java
  71. 0 0
      maxkey-common/src/main/java/org/maxkey/crypto/cert/CertCrypto.java
  72. 0 0
      maxkey-common/src/main/java/org/maxkey/crypto/cert/CertSigner.java
  73. 0 0
      maxkey-common/src/main/java/org/maxkey/crypto/cert/CryptoException.java
  74. 0 0
      maxkey-common/src/main/java/org/maxkey/crypto/cert/NameUtil.java
  75. 0 0
      maxkey-common/src/main/java/org/maxkey/crypto/cert/NetUtil.java
  76. 0 0
      maxkey-common/src/main/java/org/maxkey/crypto/cert/SignatureType.java
  77. 0 0
      maxkey-common/src/main/java/org/maxkey/crypto/cert/StringUtil.java
  78. 0 0
      maxkey-common/src/main/java/org/maxkey/crypto/cert/X509CertUtils.java
  79. 0 0
      maxkey-common/src/main/java/org/maxkey/crypto/cert/X509V3CertGen.java
  80. 0 0
      maxkey-common/src/main/java/org/maxkey/crypto/jose/JWEAlgorithmEmbed.java
  81. 0 0
      maxkey-common/src/main/java/org/maxkey/crypto/jose/JWEEncryptionMethodEmbed.java
  82. 0 0
      maxkey-common/src/main/java/org/maxkey/crypto/jose/JWSAlgorithmEmbed.java
  83. 0 0
      maxkey-common/src/main/java/org/maxkey/crypto/jose/keystore/JWKSetKeyStore.java
  84. 0 0
      maxkey-common/src/main/java/org/maxkey/crypto/jwt/encryption/service/JwtEncryptionAndDecryptionService.java
  85. 0 0
      maxkey-common/src/main/java/org/maxkey/crypto/jwt/encryption/service/impl/DefaultJwtEncryptionAndDecryptionService.java
  86. 0 0
      maxkey-common/src/main/java/org/maxkey/crypto/jwt/encryption/service/impl/RecipientJwtEncryptionAndDecryptionServiceBuilder.java
  87. 0 0
      maxkey-common/src/main/java/org/maxkey/crypto/jwt/signer/service/JwtSigningAndValidationService.java
  88. 0 0
      maxkey-common/src/main/java/org/maxkey/crypto/jwt/signer/service/impl/DefaultJwtSigningAndValidationService.java
  89. 0 0
      maxkey-common/src/main/java/org/maxkey/crypto/jwt/signer/service/impl/JWKSetCacheService.java
  90. 5 6
      maxkey-common/src/main/java/org/maxkey/crypto/jwt/signer/service/impl/SymmetricCacheService.java
  91. 0 0
      maxkey-common/src/main/java/org/maxkey/crypto/jwt/signer/service/impl/SymmetricSigningAndValidationServiceBuilder.java
  92. 0 0
      maxkey-common/src/main/java/org/maxkey/crypto/keystore/KeyStoreLoader.java
  93. 0 0
      maxkey-common/src/main/java/org/maxkey/crypto/keystore/KeyStoreType.java
  94. 0 0
      maxkey-common/src/main/java/org/maxkey/crypto/keystore/KeyStoreUtil.java
  95. 0 0
      maxkey-common/src/main/java/org/maxkey/crypto/password/Digester.java
  96. 0 0
      maxkey-common/src/main/java/org/maxkey/crypto/password/LdapShaPasswordEncoder.java
  97. 0 0
      maxkey-common/src/main/java/org/maxkey/crypto/password/Md4.java
  98. 0 0
      maxkey-common/src/main/java/org/maxkey/crypto/password/Md4PasswordEncoder.java
  99. 0 0
      maxkey-common/src/main/java/org/maxkey/crypto/password/MessageDigestPasswordEncoder.java
  100. 0 0
      maxkey-common/src/main/java/org/maxkey/crypto/password/NoOpPasswordEncoder.java

+ 1 - 0
.gitignore

@@ -45,3 +45,4 @@ classpath-data.json
 /.gradle/*
 /build/
 setEnvVars.bat
+/bin/

+ 7 - 7
build.gradle

@@ -47,13 +47,13 @@ allprojects {
 	compileJava.options.encoding = 'UTF-8'
 	
 	eclipse {
-		/*第一次时请注释这段eclipse设置,可能报错*/
-//		jdt  {
-//		    File f = file('.settings/org.eclipse.core.resources.prefs')
-//		    f.write('eclipse.preferences.version=1\n')
-//		    f.append('encoding/<project>=UTF-8') //use UTF-8
-//		}
-		
+		/*第一次时请注释这段eclipse设置,可能报错
+		jdt  {
+		    File f = file('.settings/org.eclipse.core.resources.prefs')
+		    f.write('eclipse.preferences.version=1\n')
+		    f.append('encoding/<project>=UTF-8') //use UTF-8
+		}
+		*/
 		
 		/*
 		wtp {

+ 1 - 1
gradle.properties

@@ -1,5 +1,5 @@
 group	=maxkey.top
-version	=2.5.0
+version	=2.6.0
 vendor	=https://www.maxkey.top
 author	=maxkeyTop
 #Version For use jar

+ 1 - 0
maxkey-authentications/maxkey-authentication-captcha/build.gradle

@@ -6,6 +6,7 @@ dependencies {
 	//local jars
 	compile fileTree(dir: '../maxkey-lib/', include: '*/*.jar')
 	
+	compile project(":maxkey-common")
 	compile project(":maxkey-core")
 	compile project(":maxkey-persistence")
    

+ 1 - 0
maxkey-authentications/maxkey-authentication-core/build.gradle

@@ -6,6 +6,7 @@ dependencies {
 	//local jars
 	compile fileTree(dir: '../maxkey-lib/', include: '*/*.jar')
 	
+	compile project(":maxkey-common")
 	compile project(":maxkey-core")
 	compile project(":maxkey-persistence")
    	compile project(":maxkey-protocols:maxkey-protocol-oauth-2.0")

+ 13 - 0
maxkey-authentications/maxkey-authentication-otp/build.gradle

@@ -0,0 +1,13 @@
+
+description = "maxkey-authentication-otp"
+
+
+dependencies {
+	//local jars
+	compile fileTree(dir: '../maxkey-lib/', include: '*/*.jar')
+	
+	compile project(":maxkey-common")
+	compile project(":maxkey-core")
+	compile project(":maxkey-persistence")
+   
+}

+ 3 - 0
maxkey-authentications/maxkey-authentication-otp/src/main/java/META-INF/MANIFEST.MF

@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path: 
+

+ 7 - 7
maxkey-core/src/main/java/org/maxkey/crypto/password/opt/AbstractOptAuthn.java → maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/AbstractOtpAuthn.java

@@ -15,10 +15,10 @@
  */
  
 
-package org.maxkey.crypto.password.opt;
+package org.maxkey.crypto.password.otp;
 
-import org.maxkey.crypto.password.opt.token.AbstractOptTokenStore;
-import org.maxkey.crypto.password.opt.token.InMemoryOptTokenStore;
+import org.maxkey.crypto.password.otp.token.AbstractOtpTokenStore;
+import org.maxkey.crypto.password.otp.token.InMemoryOtpTokenStore;
 import org.maxkey.domain.UserInfo;
 import org.maxkey.util.StringGenerator;
 import org.slf4j.Logger;
@@ -29,10 +29,10 @@ import org.slf4j.LoggerFactory;
  * @author Administrator
  *
  */
-public abstract class AbstractOptAuthn {
-    private static final  Logger logger = LoggerFactory.getLogger(AbstractOptAuthn.class);
+public abstract class AbstractOtpAuthn {
+    private static final  Logger logger = LoggerFactory.getLogger(AbstractOtpAuthn.class);
 
-    protected AbstractOptTokenStore optTokenStore = new InMemoryOptTokenStore();
+    protected AbstractOtpTokenStore optTokenStore = new InMemoryOtpTokenStore();
     
     //验证码有效間隔
     protected int interval = 30;
@@ -142,7 +142,7 @@ public abstract class AbstractOptAuthn {
         this.optType = optType;
     }
 
-    public void setOptTokenStore(AbstractOptTokenStore optTokenStore) {
+    public void setOptTokenStore(AbstractOtpTokenStore optTokenStore) {
         this.optTokenStore = optTokenStore;
     }
 

+ 1 - 1
maxkey-core/src/main/java/org/maxkey/crypto/password/opt/OneTimePassword.java → maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/OneTimePassword.java

@@ -15,7 +15,7 @@
  */
  
 
-package org.maxkey.crypto.password.opt;
+package org.maxkey.crypto.password.otp;
 
 import java.io.Serializable;
 

+ 1 - 1
maxkey-core/src/main/java/org/maxkey/crypto/password/opt/algorithm/HOTP.java → maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/algorithm/HOTP.java

@@ -15,7 +15,7 @@
  */
  
 
-package org.maxkey.crypto.password.opt.algorithm;
+package org.maxkey.crypto.password.otp.algorithm;
 
 import java.security.InvalidKeyException;
 import java.security.NoSuchAlgorithmException;

+ 1 - 1
maxkey-core/src/main/java/org/maxkey/crypto/password/opt/algorithm/HmacOTP.java → maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/algorithm/HmacOTP.java

@@ -15,7 +15,7 @@
  */
  
 
-package org.maxkey.crypto.password.opt.algorithm;
+package org.maxkey.crypto.password.otp.algorithm;
 
 import java.security.InvalidKeyException;
 import java.security.NoSuchAlgorithmException;

+ 1 - 1
maxkey-core/src/main/java/org/maxkey/crypto/password/opt/algorithm/KeyUriFormat.java → maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/algorithm/KeyUriFormat.java

@@ -15,7 +15,7 @@
  */
  
 
-package org.maxkey.crypto.password.opt.algorithm;
+package org.maxkey.crypto.password.otp.algorithm;
 
 public class KeyUriFormat {
 

+ 1 - 1
maxkey-core/src/main/java/org/maxkey/crypto/password/opt/algorithm/OtpSecret.java → maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/algorithm/OtpSecret.java

@@ -15,7 +15,7 @@
  */
  
 
-package org.maxkey.crypto.password.opt.algorithm;
+package org.maxkey.crypto.password.otp.algorithm;
 
 import java.util.Arrays;
 import java.util.Random;

+ 1 - 1
maxkey-core/src/main/java/org/maxkey/crypto/password/opt/algorithm/TimeBasedOTP.java → maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/algorithm/TimeBasedOTP.java

@@ -15,7 +15,7 @@
  */
  
 
-package org.maxkey.crypto.password.opt.algorithm;
+package org.maxkey.crypto.password.otp.algorithm;
 
 import java.lang.reflect.UndeclaredThrowableException;
 import java.math.BigInteger;

+ 3 - 3
maxkey-core/src/main/java/org/maxkey/crypto/password/opt/impl/CapOtpAuthn.java → maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/impl/CapOtpAuthn.java

@@ -15,9 +15,9 @@
  */
  
 
-package org.maxkey.crypto.password.opt.impl;
+package org.maxkey.crypto.password.otp.impl;
 
-import org.maxkey.crypto.password.opt.AbstractOptAuthn;
+import org.maxkey.crypto.password.otp.AbstractOtpAuthn;
 import org.maxkey.domain.UserInfo;
 
 /**
@@ -30,7 +30,7 @@ import org.maxkey.domain.UserInfo;
  * @author Crystal.Sea
  *
  */
-public class CapOtpAuthn extends AbstractOptAuthn {
+public class CapOtpAuthn extends AbstractOtpAuthn {
 
     
     

+ 4 - 4
maxkey-core/src/main/java/org/maxkey/crypto/password/opt/impl/CounterBasedOtpAuthn.java → maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/impl/CounterBasedOtpAuthn.java

@@ -15,17 +15,17 @@
  */
  
 
-package org.maxkey.crypto.password.opt.impl;
+package org.maxkey.crypto.password.otp.impl;
 
 import org.apache.commons.codec.binary.Hex;
 import org.maxkey.crypto.Base32Utils;
-import org.maxkey.crypto.password.opt.AbstractOptAuthn;
-import org.maxkey.crypto.password.opt.algorithm.TimeBasedOTP;
+import org.maxkey.crypto.password.otp.AbstractOtpAuthn;
+import org.maxkey.crypto.password.otp.algorithm.TimeBasedOTP;
 import org.maxkey.domain.UserInfo;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class CounterBasedOtpAuthn extends AbstractOptAuthn {
+public class CounterBasedOtpAuthn extends AbstractOtpAuthn {
     private static final Logger _logger = LoggerFactory.getLogger(CounterBasedOtpAuthn.class);
 
 

+ 4 - 4
maxkey-core/src/main/java/org/maxkey/crypto/password/opt/impl/HotpOtpAuthn.java → maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/impl/HotpOtpAuthn.java

@@ -15,18 +15,18 @@
  */
  
 
-package org.maxkey.crypto.password.opt.impl;
+package org.maxkey.crypto.password.otp.impl;
 
 import java.security.InvalidKeyException;
 import java.security.NoSuchAlgorithmException;
 import org.maxkey.crypto.Base32Utils;
-import org.maxkey.crypto.password.opt.AbstractOptAuthn;
-import org.maxkey.crypto.password.opt.algorithm.HOTP;
+import org.maxkey.crypto.password.otp.AbstractOtpAuthn;
+import org.maxkey.crypto.password.otp.algorithm.HOTP;
 import org.maxkey.domain.UserInfo;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class HotpOtpAuthn extends AbstractOptAuthn {
+public class HotpOtpAuthn extends AbstractOtpAuthn {
     private static final  Logger _logger = LoggerFactory.getLogger(HotpOtpAuthn.class);
 
     boolean addChecksum;

+ 3 - 3
maxkey-core/src/main/java/org/maxkey/crypto/password/opt/impl/MailOtpAuthn.java → maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/impl/MailOtpAuthn.java

@@ -15,20 +15,20 @@
  */
  
 
-package org.maxkey.crypto.password.opt.impl;
+package org.maxkey.crypto.password.otp.impl;
 
 import java.text.MessageFormat;
 import org.apache.commons.mail.DefaultAuthenticator;
 import org.apache.commons.mail.Email;
 import org.apache.commons.mail.SimpleEmail;
 import org.maxkey.configuration.EmailConfig;
-import org.maxkey.crypto.password.opt.AbstractOptAuthn;
+import org.maxkey.crypto.password.otp.AbstractOtpAuthn;
 import org.maxkey.domain.UserInfo;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 
-public class MailOtpAuthn extends AbstractOptAuthn {
+public class MailOtpAuthn extends AbstractOtpAuthn {
     private static final Logger _logger = LoggerFactory.getLogger(MailOtpAuthn.class);
     
     @Autowired

+ 3 - 3
maxkey-core/src/main/java/org/maxkey/crypto/password/opt/impl/MobileOtpAuthn.java → maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/impl/MobileOtpAuthn.java

@@ -15,12 +15,12 @@
  */
  
 
-package org.maxkey.crypto.password.opt.impl;
+package org.maxkey.crypto.password.otp.impl;
 
-import org.maxkey.crypto.password.opt.AbstractOptAuthn;
+import org.maxkey.crypto.password.otp.AbstractOtpAuthn;
 import org.maxkey.domain.UserInfo;
 
-public class MobileOtpAuthn extends AbstractOptAuthn {
+public class MobileOtpAuthn extends AbstractOtpAuthn {
 
     
     

+ 3 - 3
maxkey-core/src/main/java/org/maxkey/crypto/password/opt/impl/RsaOtpAuthn.java → maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/impl/RsaOtpAuthn.java

@@ -15,9 +15,9 @@
  */
  
 
-package org.maxkey.crypto.password.opt.impl;
+package org.maxkey.crypto.password.otp.impl;
 
-import org.maxkey.crypto.password.opt.AbstractOptAuthn;
+import org.maxkey.crypto.password.otp.AbstractOtpAuthn;
 import org.maxkey.domain.UserInfo;
 
 /**
@@ -30,7 +30,7 @@ import org.maxkey.domain.UserInfo;
  * @author Crystal.Sea
  *
  */
-public class RsaOtpAuthn extends AbstractOptAuthn {
+public class RsaOtpAuthn extends AbstractOtpAuthn {
 
     
     

+ 3 - 3
maxkey-core/src/main/java/org/maxkey/crypto/password/opt/impl/SmsOtpAuthn.java → maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/impl/SmsOtpAuthn.java

@@ -15,19 +15,19 @@
  */
  
 
-package org.maxkey.crypto.password.opt.impl;
+package org.maxkey.crypto.password.otp.impl;
 
 import java.io.IOException;
 import java.util.Properties;
 import org.maxkey.constants.ConstantsProperties;
-import org.maxkey.crypto.password.opt.AbstractOptAuthn;
+import org.maxkey.crypto.password.otp.AbstractOtpAuthn;
 import org.maxkey.domain.UserInfo;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.core.io.ClassPathResource;
 import org.springframework.core.io.Resource;
 
-public class SmsOtpAuthn extends AbstractOptAuthn {
+public class SmsOtpAuthn extends AbstractOtpAuthn {
     private static final  Logger logger = LoggerFactory.getLogger(SmsOtpAuthn.class);
     
     protected Properties properties;

+ 4 - 4
maxkey-core/src/main/java/org/maxkey/crypto/password/opt/impl/TimeBasedOtpAuthn.java → maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/impl/TimeBasedOtpAuthn.java

@@ -15,7 +15,7 @@
  */
  
 
-package org.maxkey.crypto.password.opt.impl;
+package org.maxkey.crypto.password.otp.impl;
 
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
@@ -23,13 +23,13 @@ import java.util.Date;
 import java.util.TimeZone;
 import org.apache.commons.codec.binary.Hex;
 import org.maxkey.crypto.Base32Utils;
-import org.maxkey.crypto.password.opt.AbstractOptAuthn;
-import org.maxkey.crypto.password.opt.algorithm.TimeBasedOTP;
+import org.maxkey.crypto.password.otp.AbstractOtpAuthn;
+import org.maxkey.crypto.password.otp.algorithm.TimeBasedOTP;
 import org.maxkey.domain.UserInfo;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class TimeBasedOtpAuthn extends AbstractOptAuthn {
+public class TimeBasedOtpAuthn extends AbstractOtpAuthn {
     private static final  Logger _logger = LoggerFactory.getLogger(TimeBasedOtpAuthn.class);
     DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 

+ 2 - 2
maxkey-core/src/main/java/org/maxkey/crypto/password/opt/impl/sms/SmsOtpAuthnAliyun.java → maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/impl/sms/SmsOtpAuthnAliyun.java

@@ -15,7 +15,7 @@
  */
  
 
-package org.maxkey.crypto.password.opt.impl.sms;
+package org.maxkey.crypto.password.otp.impl.sms;
 
 import com.aliyuncs.CommonRequest;
 import com.aliyuncs.CommonResponse;
@@ -26,7 +26,7 @@ import com.aliyuncs.profile.DefaultProfile;
 
 import java.io.IOException;
 
-import org.maxkey.crypto.password.opt.impl.SmsOtpAuthn;
+import org.maxkey.crypto.password.otp.impl.SmsOtpAuthn;
 import org.maxkey.domain.UserInfo;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;

+ 2 - 2
maxkey-core/src/main/java/org/maxkey/crypto/password/opt/impl/sms/SmsOtpAuthnTencentCloud.java → maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/impl/sms/SmsOtpAuthnTencentCloud.java

@@ -15,7 +15,7 @@
  */
  
 
-package org.maxkey.crypto.password.opt.impl.sms;
+package org.maxkey.crypto.password.otp.impl.sms;
 
 import com.tencentcloudapi.common.Credential;
 import com.tencentcloudapi.common.profile.ClientProfile;
@@ -26,7 +26,7 @@ import com.tencentcloudapi.sms.v20190711.models.SendSmsResponse;
 
 import java.io.IOException;
 
-import org.maxkey.crypto.password.opt.impl.SmsOtpAuthn;
+import org.maxkey.crypto.password.otp.impl.SmsOtpAuthn;
 import org.maxkey.domain.UserInfo;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;

+ 2 - 2
maxkey-core/src/main/java/org/maxkey/crypto/password/opt/impl/sms/SmsOtpAuthnYunxin.java → maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/impl/sms/SmsOtpAuthnYunxin.java

@@ -15,7 +15,7 @@
  */
  
 
-package org.maxkey.crypto.password.opt.impl.sms;
+package org.maxkey.crypto.password.otp.impl.sms;
 
 import java.io.IOException;
 import java.util.ArrayList;
@@ -29,7 +29,7 @@ import org.apache.http.client.methods.HttpPost;
 import org.apache.http.impl.client.HttpClientBuilder;
 import org.apache.http.message.BasicNameValuePair;
 import org.apache.http.util.EntityUtils;
-import org.maxkey.crypto.password.opt.impl.SmsOtpAuthn;
+import org.maxkey.crypto.password.otp.impl.SmsOtpAuthn;
 import org.maxkey.domain.UserInfo;
 import org.maxkey.util.JsonUtils;
 import org.maxkey.util.StringGenerator;

+ 1 - 1
maxkey-core/src/main/java/org/maxkey/crypto/password/opt/impl/sms/SmsOtpAuthnYunxinCheckSumBuilder.java → maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/impl/sms/SmsOtpAuthnYunxinCheckSumBuilder.java

@@ -15,7 +15,7 @@
  */
  
 
-package org.maxkey.crypto.password.opt.impl.sms;
+package org.maxkey.crypto.password.otp.impl.sms;
 
 import java.security.MessageDigest;
 

+ 2 - 2
maxkey-core/src/main/java/org/maxkey/crypto/password/opt/token/AbstractOptTokenStore.java → maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/token/AbstractOtpTokenStore.java

@@ -15,11 +15,11 @@
  */
  
 
-package org.maxkey.crypto.password.opt.token;
+package org.maxkey.crypto.password.otp.token;
 
 import org.maxkey.domain.UserInfo;
 
-public abstract class AbstractOptTokenStore {
+public abstract class AbstractOtpTokenStore {
     
     public abstract void store(UserInfo userInfo, String token, String receiver, String type);
     

+ 5 - 5
maxkey-core/src/main/java/org/maxkey/crypto/password/opt/token/InMemoryOptTokenStore.java → maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/token/InMemoryOtpTokenStore.java

@@ -15,7 +15,7 @@
  */
  
 
-package org.maxkey.crypto.password.opt.token;
+package org.maxkey.crypto.password.otp.token;
 
 import org.ehcache.UserManagedCache;
 import org.ehcache.config.builders.ExpiryPolicyBuilder;
@@ -24,13 +24,13 @@ import org.joda.time.DateTime;
 import org.joda.time.Duration;
 import org.joda.time.format.DateTimeFormat;
 import org.maxkey.constants.ConstantsTimeInterval;
-import org.maxkey.crypto.password.opt.OneTimePassword;
+import org.maxkey.crypto.password.otp.OneTimePassword;
 import org.maxkey.domain.UserInfo;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class InMemoryOptTokenStore  extends AbstractOptTokenStore {
-    private static final  Logger logger = LoggerFactory.getLogger(InMemoryOptTokenStore.class);
+public class InMemoryOtpTokenStore  extends AbstractOtpTokenStore {
+    private static final  Logger logger = LoggerFactory.getLogger(InMemoryOtpTokenStore.class);
     
     protected static final UserManagedCache<String, OneTimePassword> optTokenStore = 
             UserManagedCacheBuilder.newUserManagedCacheBuilder(String.class, OneTimePassword.class)
@@ -73,7 +73,7 @@ public class InMemoryOptTokenStore  extends AbstractOptTokenStore {
         return false;
     }
 
-    public InMemoryOptTokenStore() {
+    public InMemoryOtpTokenStore() {
         
     }    
 }

+ 4 - 4
maxkey-core/src/main/java/org/maxkey/crypto/password/opt/token/RedisOptTokenStore.java → maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/token/RedisOtpTokenStore.java

@@ -15,22 +15,22 @@
  */
  
 
-package org.maxkey.crypto.password.opt.token;
+package org.maxkey.crypto.password.otp.token;
 
 import org.joda.time.DateTime;
 import org.maxkey.constants.ConstantsTimeInterval;
-import org.maxkey.crypto.password.opt.OneTimePassword;
+import org.maxkey.crypto.password.otp.OneTimePassword;
 import org.maxkey.domain.UserInfo;
 import org.maxkey.persistence.redis.RedisConnection;
 import org.maxkey.persistence.redis.RedisConnectionFactory;
 
-public class RedisOptTokenStore  extends AbstractOptTokenStore {
+public class RedisOtpTokenStore  extends AbstractOtpTokenStore {
     
     protected int validitySeconds = ConstantsTimeInterval.ONE_MINUTE * 5;
     
     RedisConnectionFactory connectionFactory;
     
-    public RedisOptTokenStore(RedisConnectionFactory connectionFactory) {
+    public RedisOtpTokenStore(RedisConnectionFactory connectionFactory) {
         super();
         this.connectionFactory = connectionFactory;
     }

+ 2 - 2
maxkey-core/src/test/java/org/maxkey/otp/algorithm/HmacOTPTest.java → maxkey-authentications/maxkey-authentication-otp/src/test/java/org/maxkey/otp/algorithm/HmacOTPTest.java

@@ -22,8 +22,8 @@ import java.security.InvalidKeyException;
 import java.security.NoSuchAlgorithmException;
 
 import org.maxkey.crypto.Base32Utils;
-import org.maxkey.crypto.password.opt.algorithm.HOTP;
-import org.maxkey.crypto.password.opt.algorithm.HmacOTP;
+import org.maxkey.crypto.password.otp.algorithm.HOTP;
+import org.maxkey.crypto.password.otp.algorithm.HmacOTP;
 
 
 public class HmacOTPTest {

+ 1 - 1
maxkey-core/src/test/java/org/maxkey/otp/algorithm/KeyUriFormatTest.java → maxkey-authentications/maxkey-authentication-otp/src/test/java/org/maxkey/otp/algorithm/KeyUriFormatTest.java

@@ -19,7 +19,7 @@ package org.maxkey.otp.algorithm;
 
 import java.io.File;
 
-import org.maxkey.crypto.password.opt.algorithm.KeyUriFormat;
+import org.maxkey.crypto.password.otp.algorithm.KeyUriFormat;
 import org.maxkey.util.QRCode;
 
 import com.google.zxing.BarcodeFormat;

+ 1 - 1
maxkey-core/src/test/java/org/maxkey/otp/algorithm/TimeBasedOTPTest.java → maxkey-authentications/maxkey-authentication-otp/src/test/java/org/maxkey/otp/algorithm/TimeBasedOTPTest.java

@@ -26,7 +26,7 @@ import java.util.TimeZone;
 import org.apache.commons.codec.binary.Hex;
 import org.maxkey.crypto.Base32Utils;
 import org.maxkey.crypto.HexUtils;
-import org.maxkey.crypto.password.opt.algorithm.TimeBasedOTP;
+import org.maxkey.crypto.password.otp.algorithm.TimeBasedOTP;
 /**
  * goole 
  * @author Crystal.Sea

+ 1 - 0
maxkey-authentications/maxkey-authentication-social/build.gradle

@@ -6,6 +6,7 @@ dependencies {
 	//local jars
 	compile fileTree(dir: '../maxkey-lib/', include: '*/*.jar')
 	
+	compile project(":maxkey-common")
 	compile project(":maxkey-core")
 	compile project(":maxkey-persistence")
    

+ 7 - 0
maxkey-common/build.gradle

@@ -0,0 +1,7 @@
+description = "maxkey-common"
+
+dependencies {
+	//local jars
+	compile fileTree(dir: '../maxkey-lib/', include: '*/*.jar')
+	
+}

+ 3 - 0
maxkey-common/src/main/java/META-INF/MANIFEST.MF

@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path: 
+

+ 0 - 0
maxkey-core/src/main/java/org/maxkey/cache/AbstractCache.java → maxkey-common/src/main/java/org/maxkey/cache/AbstractCache.java


+ 0 - 0
maxkey-core/src/main/java/org/maxkey/cache/CacheFactory.java → maxkey-common/src/main/java/org/maxkey/cache/CacheFactory.java


+ 0 - 0
maxkey-core/src/main/java/org/maxkey/cache/package-info.java → maxkey-common/src/main/java/org/maxkey/cache/package-info.java


+ 230 - 0
maxkey-common/src/main/java/org/maxkey/configuration/ApplicationConfig.java

@@ -0,0 +1,230 @@
+/*
+ * Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ 
+
+package org.maxkey.configuration;
+
+import org.maxkey.constants.ConstantsProperties;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.PropertySource;
+import org.springframework.stereotype.Component;
+
+/**
+ * 全局应用程序配置 包含 1、数据源配置 dataSoruceConfig 2、字符集转换配置 characterEncodingConfig
+ * 3、webseal认证集成配置 webSealConfig 4、系统的配置 sysConfig 5、所有用户可访问地址配置 allAccessUrl
+ * 
+ * 其中1、2、3项在applicationContext.xml中配置,配置文件applicationConfig.properties
+ * 4项根据dynamic的属性判断是否动态从sysConfigService动态读取
+ * 
+ * @author Crystal.Sea
+ * 
+ */
+@Component
+@PropertySource(ConstantsProperties.maxKeyPropertySource)
+@PropertySource(ConstantsProperties.applicationPropertySource)
+public class ApplicationConfig {
+    private static final Logger _logger = LoggerFactory.getLogger(ApplicationConfig.class);
+
+    @Autowired
+    EmailConfig emailConfig;
+    
+    @Autowired
+    CharacterEncodingConfig characterEncodingConfig;
+    
+    @Autowired
+    LoginConfig loginConfig;
+
+    @Value("${config.server.basedomain}")
+    String baseDomainName;
+
+    @Value("${config.server.domain}")
+    String domainName;
+
+    @Value("${config.server.name}")
+    String serverName;
+
+    @Value("${config.server.uri}")
+    String serverPrefix;
+
+    @Value("${config.server.default.uri}")
+    String defaultUri;
+
+    @Value("${config.server.management.uri}")
+    String managementUri;
+
+    @Value("${server.port:8080}")
+    private int port;
+
+    @Value("${config.identity.kafkasupport:false}")
+    private boolean kafkaSupport;
+    
+    @Value("${config.maxkey.uri}")
+    private String maxKeyUri;
+    
+    public int getPort() {
+        return port;
+    }
+
+    public void setPort(int port) {
+        this.port = port;
+    }
+
+    public ApplicationConfig() {
+        super();
+    }
+
+    /**
+     * @return the characterEncodingConfig
+     */
+    public CharacterEncodingConfig getCharacterEncodingConfig() {
+        return characterEncodingConfig;
+    }
+
+    /**
+     * @param characterEncodingConfig the characterEncodingConfig to set
+     */
+    public void setCharacterEncodingConfig(CharacterEncodingConfig characterEncodingConfig) {
+        this.characterEncodingConfig = characterEncodingConfig;
+    }
+
+    public LoginConfig getLoginConfig() {
+        return loginConfig;
+    }
+
+    public void setLoginConfig(LoginConfig loginConfig) {
+        this.loginConfig = loginConfig;
+    }
+
+    public String getServerName() {
+        return serverName;
+    }
+
+    public void setServerName(String serverName) {
+        this.serverName = serverName;
+    }
+
+    public String getServerPrefix() {
+        return serverPrefix;
+    }
+
+    public void setServerPrefix(String serverPrefix) {
+        this.serverPrefix = serverPrefix;
+    }
+
+    /**
+     * @return the domainName
+     */
+    public String getDomainName() {
+        return domainName;
+    }
+
+    /**
+     * @param domainName the domainName to set
+     */
+    public void setDomainName(String domainName) {
+        this.domainName = domainName;
+       
+    }
+
+    public String getBaseDomainName() {
+        return baseDomainName;
+    }
+
+    public void setBaseDomainName(String baseDomainName) {
+        this.baseDomainName = baseDomainName;
+    }
+
+    /**
+     * @return the emailConfig
+     */
+    public EmailConfig getEmailConfig() {
+        return emailConfig;
+    }
+
+    /**
+     * @param emailConfig the emailConfig to set
+     */
+    public void setEmailConfig(EmailConfig emailConfig) {
+        this.emailConfig = emailConfig;
+    }
+
+    public String getManagementUri() {
+        return managementUri;
+    }
+
+    public void setManagementUri(String managementUri) {
+        this.managementUri = managementUri;
+    }
+
+    public String getDefaultUri() {
+        return defaultUri;
+    }
+
+    public void setDefaultUri(String defaultUri) {
+        this.defaultUri = defaultUri;
+    }
+
+    public boolean isKafkaSupport() {
+        return kafkaSupport;
+    }
+
+    public void setKafkaSupport(boolean kafkaSupport) {
+        this.kafkaSupport = kafkaSupport;
+    }
+
+    public String getMaxKeyUri() {
+        return maxKeyUri;
+    }
+
+    public void setMaxKeyUri(String maxKeyUri) {
+        this.maxKeyUri = maxKeyUri;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder builder = new StringBuilder();
+        builder.append("ApplicationConfig [emailConfig=");
+        builder.append(emailConfig);
+        builder.append(", characterEncodingConfig=");
+        builder.append(characterEncodingConfig);
+        builder.append(", loginConfig=");
+        builder.append(loginConfig);
+        builder.append(", baseDomainName=");
+        builder.append(baseDomainName);
+        builder.append(", domainName=");
+        builder.append(domainName);
+        builder.append(", serverName=");
+        builder.append(serverName);
+        builder.append(", serverPrefix=");
+        builder.append(serverPrefix);
+        builder.append(", defaultUri=");
+        builder.append(defaultUri);
+        builder.append(", managementUri=");
+        builder.append(managementUri);
+        builder.append(", port=");
+        builder.append(port);
+        builder.append(", kafkaSupport=");
+        builder.append(kafkaSupport);
+        builder.append(", maxKeyUri=");
+        builder.append(maxKeyUri);
+        builder.append("]");
+        return builder.toString();
+    }
+
+}

+ 115 - 0
maxkey-common/src/main/java/org/maxkey/configuration/CharacterEncodingConfig.java

@@ -0,0 +1,115 @@
+/*
+ * Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ 
+
+package org.maxkey.configuration;
+
+import java.io.UnsupportedEncodingException;
+
+import org.maxkey.constants.ConstantsProperties;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.PropertySource;
+
+/**
+ * 字符集转换及转换配置.
+ * 
+ * @author Crystal.Sea
+ *
+ */
+@Configuration
+@PropertySource(ConstantsProperties.applicationPropertySource)
+public class CharacterEncodingConfig {
+
+    /**
+     * 源字符集.
+     */
+    @Value("${server.servlet.encoding.charset.from:UTF-8}")
+    String fromCharSet;
+
+    /**
+     * 目标字符集.
+     */
+    @Value("${server.servlet.encoding.charset:UTF-8}")
+    String toCharSet;
+
+    /**
+     * 转换标志.
+     */
+    @Value("${server.servlet.encoding.enabled:false}")
+    boolean encoding = false;
+
+    public CharacterEncodingConfig() {
+
+    }
+
+    public String getFromCharSet() {
+        return fromCharSet;
+    }
+
+    public void setFromCharSet(String fromCharSet) {
+        this.fromCharSet = fromCharSet;
+    }
+
+    public String getToCharSet() {
+        return toCharSet;
+    }
+
+    public void setToCharSet(String toCharSet) {
+        this.toCharSet = toCharSet;
+    }
+
+    public boolean isEncoding() {
+        return encoding;
+    }
+
+    public void setEncoding(boolean encoding) {
+        this.encoding = encoding;
+    }
+
+    /**
+     * 字符集转换.
+     * 
+     * @param encodingString 源字符串
+     * @return encoded目标字符串
+     */
+    public String encoding(String encodingString) {
+        if (!this.encoding || encodingString == null) {
+            return encodingString;
+        }
+
+        try {
+            return new String(encodingString.getBytes(this.fromCharSet), this.toCharSet);
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder builder = new StringBuilder();
+        builder.append("CharacterEncodingConfig [fromCharSet=");
+        builder.append(fromCharSet);
+        builder.append(", toCharSet=");
+        builder.append(toCharSet);
+        builder.append(", encoding=");
+        builder.append(encoding);
+        builder.append("]");
+        return builder.toString();
+    }
+
+}

+ 149 - 0
maxkey-common/src/main/java/org/maxkey/configuration/EmailConfig.java

@@ -0,0 +1,149 @@
+/*
+ * Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ 
+
+package org.maxkey.configuration;
+
+import org.maxkey.constants.ConstantsProperties;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.PropertySource;
+
+@Configuration
+@PropertySource(ConstantsProperties.applicationPropertySource)
+public class EmailConfig {
+
+    @Value("${spring.mail.username}")
+    private String username;
+    
+    @Value("${spring.mail.password}")
+    private String password;
+    
+    @Value("${spring.mail.host}")
+    private String smtpHost;
+    
+    @Value("${spring.mail.port}")
+    private Integer port;
+    
+    @Value("${spring.mail.properties.ssl}")
+    private boolean ssl;
+    
+    @Value("${spring.mail.properties.sender}")
+    private String sender;
+
+    public EmailConfig() {
+    }
+
+    /*
+     * @return the username
+     */
+    public String getUsername() {
+        return username;
+    }
+
+    /*
+     * @param username the username to set
+     */
+    public void setUsername(String username) {
+        this.username = username;
+    }
+
+    /*
+     * @return the password
+     */
+    public String getPassword() {
+        return password;
+    }
+
+    /*
+     * @param password the password to set
+     */
+    public void setPassword(String password) {
+        this.password = password;
+    }
+
+    /*
+     * @return the smtpHost
+     */
+    public String getSmtpHost() {
+        return smtpHost;
+    }
+
+    /*
+     * @param smtpHost the smtpHost to set
+     */
+    public void setSmtpHost(String smtpHost) {
+        this.smtpHost = smtpHost;
+    }
+
+
+
+    public String getSender() {
+        return sender;
+    }
+
+    public void setSender(String sender) {
+        this.sender = sender;
+    }
+
+    /*
+     * @return the port
+     */
+    public Integer getPort() {
+        return port;
+    }
+
+    /*
+     * @param port the port to set
+     */
+    public void setPort(Integer port) {
+        this.port = port;
+    }
+
+    /*
+     * @return the ssl
+     */
+    public boolean isSsl() {
+        return ssl;
+    }
+
+    /*
+     * @param ssl the ssl to set
+     */
+    public void setSsl(boolean ssl) {
+        this.ssl = ssl;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder builder = new StringBuilder();
+        builder.append("EmailConfig [username=");
+        builder.append(username);
+        builder.append(", password=");
+        builder.append(password);
+        builder.append(", smtpHost=");
+        builder.append(smtpHost);
+        builder.append(", port=");
+        builder.append(port);
+        builder.append(", ssl=");
+        builder.append(ssl);
+        builder.append(", sender=");
+        builder.append(sender);
+        builder.append("]");
+        return builder.toString();
+    }
+
+}

+ 147 - 0
maxkey-common/src/main/java/org/maxkey/configuration/LoginConfig.java

@@ -0,0 +1,147 @@
+/*
+ * Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ 
+
+package org.maxkey.configuration;
+
+import org.maxkey.constants.ConstantsProperties;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.PropertySource;
+
+@Configuration
+@PropertySource(ConstantsProperties.maxKeyPropertySource)
+public class LoginConfig {
+    @Value("${config.login.captcha}")
+    boolean captcha;
+    
+    //验证码类型 text 文本 , arithmetic算术验证码
+    @Value("${config.login.captcha.type:text}")
+    String captchaType;
+    
+    @Value("${config.login.mfa}")
+    boolean mfa;
+    
+    @Value("${config.login.socialsignon}")
+    boolean socialSignOn;
+    
+    @Value("${config.login.kerberos}")
+    boolean kerberos;
+    
+    @Value("${config.login.remeberme}")
+    boolean remeberMe;
+    
+    @Value("${config.login.wsfederation}")
+    boolean wsFederation;
+    
+    @Value("${config.login.default.uri}")
+    String defaultUri;
+
+    /**
+     *  .
+     */
+    public LoginConfig() {
+        // TODO Auto-generated constructor stub
+    }
+
+    public boolean isCaptcha() {
+        return captcha;
+    }
+
+    public void setCaptcha(boolean captcha) {
+        this.captcha = captcha;
+    }
+
+    public boolean isSocialSignOn() {
+        return socialSignOn;
+    }
+
+    public void setSocialSignOn(boolean socialSignOn) {
+        this.socialSignOn = socialSignOn;
+    }
+
+    public boolean isKerberos() {
+        return kerberos;
+    }
+
+    public void setKerberos(boolean kerberos) {
+        this.kerberos = kerberos;
+    }
+
+    public boolean isMfa() {
+        return mfa;
+    }
+
+    public void setMfa(boolean mfa) {
+        this.mfa = mfa;
+    }
+
+    public String getDefaultUri() {
+        return defaultUri;
+    }
+
+    public void setDefaultUri(String defaultUri) {
+        this.defaultUri = defaultUri;
+    }
+
+    public boolean isRemeberMe() {
+        return remeberMe;
+    }
+
+    public void setRemeberMe(boolean remeberMe) {
+        this.remeberMe = remeberMe;
+    }
+
+    public boolean isWsFederation() {
+        return wsFederation;
+    }
+
+    public void setWsFederation(boolean wsFederation) {
+        this.wsFederation = wsFederation;
+    }
+    
+    public String getCaptchaType() {
+        return captchaType;
+    }
+
+    public void setCaptchaType(String captchaType) {
+        this.captchaType = captchaType;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder builder = new StringBuilder();
+        builder.append("LoginConfig [captcha=");
+        builder.append(captcha);
+        builder.append(", captchaType=");
+        builder.append(captchaType);
+        builder.append(", mfa=");
+        builder.append(mfa);
+        builder.append(", socialSignOn=");
+        builder.append(socialSignOn);
+        builder.append(", kerberos=");
+        builder.append(kerberos);
+        builder.append(", remeberMe=");
+        builder.append(remeberMe);
+        builder.append(", wsFederation=");
+        builder.append(wsFederation);
+        builder.append(", defaultUri=");
+        builder.append(defaultUri);
+        builder.append("]");
+        return builder.toString();
+    }
+
+}

+ 57 - 0
maxkey-common/src/main/java/org/maxkey/configuration/oidc/OIDCProviderMetadata.java

@@ -0,0 +1,57 @@
+/*
+ * Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ 
+
+package org.maxkey.configuration.oidc;
+
+import java.net.URI;
+import java.util.Set;
+
+public interface OIDCProviderMetadata {
+
+	public String getIssuer();
+
+	public void setIssuer(String issuer);
+
+	public URI getAuthorizationEndpoint();
+
+	public void setAuthorizationEndpoint(URI authorizationEndpoint);
+
+	public URI getTokenEndpoint();
+
+	public void setTokenEndpoint(URI tokenEndpoint);
+
+	public URI getUserinfoEndpoint();
+
+	public void setUserinfoEndpoint(URI userinfoEndpoint);
+
+	public URI getJwksUri();
+
+	public void setJwksUri(URI jwksUri);
+
+	public URI getRegistrationEndpoint();
+
+	public void setRegistrationEndpoint(URI registrationEndpoint);
+
+	public Set<String> getScopesSupported();
+
+	public void setScopesSupported(Set<String> scopesSupported);
+
+	public Set<String> getResponseTypesSupported();
+
+	public void setResponseTypesSupported(Set<String> responseTypesSupported);
+
+}

+ 151 - 0
maxkey-common/src/main/java/org/maxkey/configuration/oidc/OIDCProviderMetadataDetails.java

@@ -0,0 +1,151 @@
+/*
+ * Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ 
+
+package org.maxkey.configuration.oidc;
+
+import java.net.URI;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Set;
+
+/**
+ * OIDCProviderMetadataDetails.
+ * @author cm
+ *
+ */
+public class OIDCProviderMetadataDetails implements OIDCProviderMetadata {
+    protected String issuer;
+
+    protected URI authorizationEndpoint;
+
+    protected URI tokenEndpoint;
+
+    protected URI userinfoEndpoint;
+
+    protected URI jwksUri;
+
+    protected URI registrationEndpoint;
+
+    protected Set<String> scopesSupported;
+
+    protected Set<String> responseTypesSupported;
+
+    public String getIssuer() {
+        return issuer;
+    }
+
+    public void setIssuer(String issuer) {
+        this.issuer = issuer;
+    }
+
+    public URI getAuthorizationEndpoint() {
+        return authorizationEndpoint;
+    }
+
+    public void setAuthorizationEndpoint(URI authorizationEndpoint) {
+        this.authorizationEndpoint = authorizationEndpoint;
+    }
+
+    public URI getTokenEndpoint() {
+        return tokenEndpoint;
+    }
+
+    public void setTokenEndpoint(URI tokenEndpoint) {
+        this.tokenEndpoint = tokenEndpoint;
+    }
+
+    public URI getUserinfoEndpoint() {
+        return userinfoEndpoint;
+    }
+
+    public void setUserinfoEndpoint(URI userinfoEndpoint) {
+        this.userinfoEndpoint = userinfoEndpoint;
+    }
+
+    public URI getJwksUri() {
+        return jwksUri;
+    }
+
+    public void setJwksUri(URI jwksUri) {
+        this.jwksUri = jwksUri;
+    }
+
+    public URI getRegistrationEndpoint() {
+        return registrationEndpoint;
+    }
+
+    public void setRegistrationEndpoint(URI registrationEndpoint) {
+        this.registrationEndpoint = registrationEndpoint;
+    }
+
+    public Set<String> getScopesSupported() {
+        return scopesSupported;
+    }
+
+    public void setScopesSupported(Set<String> scopesSupported) {
+        this.scopesSupported = scopesSupported;
+    }
+
+    public Set<String> getResponseTypesSupported() {
+        return responseTypesSupported;
+    }
+
+    public void setResponseTypesSupported(Set<String> responseTypesSupported) {
+        this.responseTypesSupported = responseTypesSupported;
+    }
+
+    @Override
+    public String toString() {
+        final int maxLen = 4;
+        StringBuilder builder = new StringBuilder();
+        builder.append("OIDCProviderMetadataDetails [issuer=");
+        builder.append(issuer);
+        builder.append(", authorizationEndpoint=");
+        builder.append(authorizationEndpoint);
+        builder.append(", tokenEndpoint=");
+        builder.append(tokenEndpoint);
+        builder.append(", userinfoEndpoint=");
+        builder.append(userinfoEndpoint);
+        builder.append(", jwksUri=");
+        builder.append(jwksUri);
+        builder.append(", registrationEndpoint=");
+        builder.append(registrationEndpoint);
+        builder.append(", scopesSupported=");
+        builder.append(scopesSupported != null ? toString(scopesSupported, maxLen) : null);
+        builder.append(", responseTypesSupported=");
+        builder.append(responseTypesSupported != null ? toString(responseTypesSupported, maxLen) : null);
+        builder.append("]");
+        return builder.toString();
+    }
+
+    private String toString(Collection<?> collection, int maxLen) {
+        StringBuilder builder = new StringBuilder();
+        builder.append("[");
+        int i = 0;
+        for (Iterator<?> iterator = collection.iterator(); iterator.hasNext() && i < maxLen; i++) {
+            if (i > 0)
+                builder.append(", ");
+            builder.append(iterator.next());
+        }
+        builder.append("]");
+        return builder.toString();
+    }
+
+    // TODO: Complete remaining properties from
+    // http://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata
+    
+}

+ 58 - 0
maxkey-common/src/main/java/org/maxkey/constants/Boolean.java

@@ -0,0 +1,58 @@
+/*
+ * Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ 
+
+package org.maxkey.constants;
+
+/**
+ * Define int for boolean 0 false 1 true.
+ * 
+ * @author Crystal.Sea
+ *
+ */
+public class Boolean {
+
+    public static final int FALSE = 0;
+
+    public static  final int TRUE = 1;
+
+    private int value = FALSE;
+
+    public Boolean() {
+
+    }
+
+    public int getValue() {
+        return value;
+    }
+
+    public boolean isValue() {
+        return TRUE == value;
+    }
+
+    public void setValue(int value) {
+        this.value = value;
+    }
+
+    public static boolean isTrue(int value) {
+        return TRUE == value;
+    }
+
+    public static boolean isFalse(int value) {
+        return FALSE == value;
+    }
+
+}

+ 29 - 0
maxkey-common/src/main/java/org/maxkey/constants/ConstantsEntryType.java

@@ -0,0 +1,29 @@
+/*
+ * Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ 
+
+package org.maxkey.constants;
+
+public class ConstantsEntryType {
+
+    public static int USERINFO_TYPE = 1;
+    public static int ORG_TYPE = 2;
+    public static int GROUP_TYPE = 3;
+    public static int PASSWORD_TYPE = 4;
+    public static int RESOURCES_TYPE = 5;
+    public static int PERMISSIONS_TYPE = 6;
+
+}

+ 37 - 0
maxkey-common/src/main/java/org/maxkey/constants/ConstantsLoginType.java

@@ -0,0 +1,37 @@
+/*
+ * Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ 
+
+package org.maxkey.constants;
+
+public class ConstantsLoginType {
+
+    public static final String LOCAL = "Local Login";
+    public static final String BASIC = "Basic";
+    public static final String SOCIALSIGNON = "Social Sign On";
+    public static final String REMEBER_ME = "RemeberMe";
+    public static final String DESKTOP = "Desktop";
+    public static final String KERBEROS = "Kerberos";
+    public static final String SAMLTRUST = "SAML v2.0 Trust";
+    public static final String MSADTRUST = "MS AD Trust";
+    public static final String CAS = "CAS";
+    public static final String WSFEDERATION = "WsFederation";
+
+    public static final String JWT = "Jwt";
+
+    public static final String HTTPHEADER = "HttpHeader";
+
+}

+ 36 - 0
maxkey-common/src/main/java/org/maxkey/constants/ConstantsOperateAction.java

@@ -0,0 +1,36 @@
+/*
+ * Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ 
+
+package org.maxkey.constants;
+
+public final class ConstantsOperateAction {
+
+    public static final int CREATE_ACTION = 1;
+
+    public static final int DELETE_ACTION = 2;
+
+    public static final int UPDATE_ACTION = 3;
+
+    public static final int CHANGE_PASSWORD_ACTION = 4;
+
+    public static final int ADD_MEMBER_ACTION = 5;
+
+    public static final int DELETE_MEMBER_ACTION = 6;
+
+    public static final int VIEW_ACTION = 7;
+
+}

+ 31 - 0
maxkey-common/src/main/java/org/maxkey/constants/ConstantsOperateMessage.java

@@ -0,0 +1,31 @@
+/*
+ * Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ 
+
+package org.maxkey.constants;
+
+public final class ConstantsOperateMessage {
+
+    public static final String INSERT_SUCCESS = "message.action.insert.success";
+    public static final String INSERT_ERROR = "message.action.insert.error";
+
+    public static final String UPDATE_SUCCESS = "message.action.update.success";
+    public static final String UPDATE_ERROR = "message.action.update.error";
+
+    public static final String DELETE_SUCCESS = "message.action.delete.success";
+    public static final String DELETE_ERROR = "message.action.delete.error";
+
+}

+ 35 - 0
maxkey-common/src/main/java/org/maxkey/constants/ConstantsPasswordSetType.java

@@ -0,0 +1,35 @@
+/*
+ * Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ 
+
+package org.maxkey.constants;
+
+/**
+ * PASSWORDSETTYPE.
+ * @author Crystal.Sea
+ *
+ */
+public final class ConstantsPasswordSetType {
+
+    public static final int PASSWORD_NORMAL = 0;
+
+    public static final int INITIAL_PASSWORD = 1;
+
+    public static final int MANAGER_CHANGED_PASSWORD = 2;
+
+    public static final int PASSWORD_EXPIRED = 3;
+
+}

+ 33 - 0
maxkey-common/src/main/java/org/maxkey/constants/ConstantsPersistence.java

@@ -0,0 +1,33 @@
+/*
+ * Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ 
+
+package org.maxkey.constants;
+
+/**
+ * PROTOCOLS.
+ * @author Crystal.Sea
+ *
+ */
+public final class ConstantsPersistence {
+
+    public static final int INMEMORY = 0;
+
+    public static final int JDBC = 1;
+
+    public static final int REDIS = 2;
+
+}

+ 27 - 0
maxkey-common/src/main/java/org/maxkey/constants/ConstantsPlatformRole.java

@@ -0,0 +1,27 @@
+/*
+ * Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ 
+
+package org.maxkey.constants;
+
+public final class ConstantsPlatformRole {
+
+    public static final String PLATFORM_ADMIN = "PLATFORM_ADMIN";
+
+    public static final String TANANT_ADMIN = "TANANT_ADMIN";
+
+    public static final String ORDINARY_USER = "ORDINARY_USER";
+}

+ 41 - 0
maxkey-common/src/main/java/org/maxkey/constants/ConstantsProperties.java

@@ -0,0 +1,41 @@
+/*
+ * Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ 
+
+package org.maxkey.constants;
+
+import org.junit.Test;
+
+public class ConstantsProperties {
+
+    public static final String applicationPropertySource = 
+            "classpath:/application.properties";
+    
+    public static final String maxKeyPropertySource      = 
+            "classpath:/maxkey.properties";
+    
+    public static final String kaptchaPropertySource      = 
+            "classpath:/kaptcha.properties";
+    
+    public static String classPathResource(String propertySource) {
+        return propertySource.replaceAll("classpath:","");
+    }
+    
+    @Test
+    public void classPathResourceTest() {
+        System.out.println(classPathResource(maxKeyPropertySource));
+    }
+}

+ 48 - 0
maxkey-common/src/main/java/org/maxkey/constants/ConstantsProtocols.java

@@ -0,0 +1,48 @@
+/*
+ * Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ 
+
+package org.maxkey.constants;
+
+/**
+ * PROTOCOLS.
+ * @author Crystal.Sea
+ *
+ */
+public final class ConstantsProtocols {
+
+    public static final String DESKTOP = "Desktop";
+
+    public static final String BASIC = "Basic";
+
+    public static final String EXTEND_API = "Extend_API";
+
+    public static final String FORMBASED = "Form_Based";
+
+    public static final String TOKENBASED = "Token_Based";
+
+    // OAuth
+    public static final String OAUTH20 = "OAuth_v2.0";
+    // SAML
+    public static final String SAML20 = "SAML_v2.0";
+
+    public static final String OPEN_ID_CONNECT = "OpenID_Connect";
+
+    public static final String CAS = "CAS";
+    
+    public static final String JWT = "JWT";
+
+}

+ 137 - 0
maxkey-common/src/main/java/org/maxkey/constants/ConstantsServiceMessage.java

@@ -0,0 +1,137 @@
+/*
+ * Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ 
+
+package org.maxkey.constants;
+
+public final class ConstantsServiceMessage {
+
+    public static final class EMPLOYEES {
+        public static final String SERVICE_NAME = "employees";
+        public static final String XE00000001 = "XE00000001";
+        public static final String XE00000002 = "XE00000002";
+        public static final String XE00000003 = "XE00000003";
+        public static final String XE00000004 = "XE00000004";
+        public static final String XE00000005 = "XE00000005";
+        public static final String XE00000006 = "XE00000006";
+        public static final String XE00000007 = "XE00000007";
+        public static final String XE00000008 = "XE00000008";
+
+        public static final String XW00000001 = "XW00000001";
+        public static final String XW00000002 = "XW00000002";
+
+        public static final String XS00000001 = "XS00000001";
+        public static final String XS00000002 = "XS00000002";
+        public static final String XS00000003 = "XS00000003";
+
+    }
+
+    public static final class ENTERPRISES {
+        public static final String SERVICE_NAME = "enterprises";
+        public static final String XE00000001 = "XE00000001";
+        public static final String XE00000002 = "XE00000002";
+        public static final String XE00000003 = "XE00000003";
+        public static final String XE00000004 = "XE00000004";
+        public static final String XE00000005 = "XE00000005";
+        public static final String XE00000006 = "XE00000006";
+        public static final String XE00000007 = "XE00000007";
+        public static final String XE00000008 = "XE00000008";
+
+        public static final String XS00000001 = "XS00000001";
+        public static final String XS00000002 = "XS00000002";
+        public static final String XS00000003 = "XS00000003";
+        public static final String XS00000004 = "XS00000004";
+    }
+
+    public static final class RETRIEVEPASSWORD {
+        public static final String SERVICE_NAME = "retrievepassword";
+        public static final String XS00000001 = "XS00000001";
+        public static final String XS00000002 = "XS00000002";
+        public static final String XE00000001 = "XE00000001";
+        public static final String XE00000002 = "XE00000002";
+        public static final String XE00000003 = "XE00000003";
+
+    }
+
+    public static final class USERCENTER {
+        public static final String SERVICE_NAME = "usercenter";
+        public static final String XS00000001 = "XS00000001";
+        public static final String XS00000002 = "XS00000002";
+        public static final String XS00000003 = "XS00000003";
+        public static final String XE00000001 = "XE00000001";
+        public static final String XE00000002 = "XE00000002";
+        public static final String XE00000003 = "XE00000003";
+
+    }
+
+    public static final class APPLICATIONS {
+        public static final String SERVICE_NAME = "applications";
+        public static final String XS00000001 = "XS00000001";
+        public static final String XS00000002 = "XS00000002";
+        public static final String XS00000003 = "XS00000003";
+        public static final String XS00000004 = "XS00000004";
+
+        public static final String XE00000001 = "XE00000001";
+        public static final String XE00000002 = "XE00000002";
+        public static final String XE00000003 = "XE00000003";
+        public static final String XE00000004 = "XE00000004";
+
+    }
+
+    public static final class APPROLES {
+        public static final String SERVICE_NAME = "approles";
+        public static final String XE00000002 = "XE00000002";
+        public static final String XS00000002 = "XS00000002";
+        public static final String XE00000001 = "XE00000001";
+        public static final String XS00000001 = "XS00000001";
+        public static final String XE00000003 = "XE00000003";
+        public static final String XS00000003 = "XS00000003";
+        public static final String XE00000004 = "XE00000004";
+        public static final String XS00000004 = "XS00000004";
+        public static final String XS00000005 = "XS00000005";
+        public static final String XE00000005 = "XE00000005";
+        public static final String XE00000006 = "XE00000006";
+        public static final String XS00000006 = "XS00000006";
+        public static final String XE00000007 = "XE00000007";
+        public static final String XS00000007 = "XS00000007";
+        public static final String XS00000008 = "XS00000008";
+        public static final String XE00000008 = "XE00000008";
+        public static final String XE00000009 = "XE00000009";
+        public static final String XS00000009 = "XS00000009";
+    }
+
+    public static final class APIUSERS {
+        public static final String SERVICE_NAME = "apiusers";
+        public static final String XS00000003 = "XS00000003";
+        public static final String XE00000003 = "XE00000003";
+        public static final String XW00000001 = "XW00000001";
+        public static final String XW00000002 = "XW00000002";
+        public static final String XS00000001 = "XS00000001";
+        public static final String XE00000001 = "XE00000001";
+    }
+
+    public static final class PASSWORDPOLICY {
+        public static final String SERVICE_NAME = "passwordpolicy";
+        public static final String XW00000002 = "XW00000002";
+        public static final String XW00000001 = "XW00000001";
+        public static final String XW00000003 = "XW00000003";
+        public static final String XW00000004 = "XW00000004";
+        public static final String XW00000005 = "XW00000005";
+        public static final String XW00000006 = "XW00000006";
+        public static final String XW00000007 = "XW00000007";
+        public static final String XW00000008 = "XW00000008";
+    }
+}

+ 49 - 0
maxkey-common/src/main/java/org/maxkey/constants/ConstantsStatus.java

@@ -0,0 +1,49 @@
+/*
+ * Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ 
+
+package org.maxkey.constants;
+
+public final class ConstantsStatus {
+    public static final int ACTIVE = 1;
+
+    public static final int INACTIVE = 2;
+
+    public static final int ENABLED = 3;
+
+    public static final int DISABLED = 4;
+
+    public static final int LOCK = 5;
+
+    public static final int UNLOCK = 6;
+
+    public static final int INVALID = 7;
+
+    public static final int EXPIRED = 8;
+
+    public static final int DELETE = 9;
+
+    public static final int VALIDATED = 10;
+
+    public static final int START = 11;
+
+    public static final int STOP = 12;
+
+    public static final int APPROVED = 13;
+    
+    public static final int QUITED = 14;
+
+}

+ 40 - 0
maxkey-common/src/main/java/org/maxkey/constants/ConstantsTimeInterval.java

@@ -0,0 +1,40 @@
+/*
+ * Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ 
+
+package org.maxkey.constants;
+
+public final class ConstantsTimeInterval {
+    
+    public static final Integer ONE_MINUTE = 60; // 1 minutes 
+    
+    public static final Integer ONE_HOUR = 60 * 60; // 1 hour
+    
+    public static final Integer ONE_DAY = 60 * 60 * 24; // 1 day
+
+    public static final Integer ONE_WEEK = ONE_DAY * 7; // 1 week
+
+    public static final Integer TWO_WEEK = ONE_DAY * 14; // 2 week
+
+    public static final Integer ONE_MONTH = ONE_DAY * 30; // 1 month
+    
+    public static final Integer TWO_MONTH = ONE_DAY * 60; // 2 month
+    
+    /**
+     * The number of seconds in one year (= 60 * 60 * 24 * 365).
+     */
+    public static final Integer ONE_YEAR = 60 * 60 * 24 * 365;
+}

+ 50 - 0
maxkey-common/src/main/java/org/maxkey/constants/ContentType.java

@@ -0,0 +1,50 @@
+/*
+ * Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ 
+
+package org.maxkey.constants;
+
+public class ContentType {
+
+    public static final String TEXT_PLAIN = "text/plain";
+    
+    public static final String TEXT_PLAIN_UTF8 = "text/plain;charset=UTF-8";
+    
+    public static final String TEXT_XML = "text/xml";
+    
+    public static final String TEXT_XML_UTF8 = "text/xml;charset=UTF-8";
+    
+    public static final String APPLICATION_JSON = "application/json";
+    
+    public static final String APPLICATION_JSON_UTF8 = "application/json;charset=UTF-8";
+    
+    public static final String APPLICATION_JWT = "application/jwt";
+    
+    public static final String APPLICATION_JWT_UTF8 = "application/jwt;charset=UTF-8";
+    
+    public static final String APPLICATION_XML = "application/xml";
+    
+    public static final String APPLICATION_XML_UTF8 = "application/xml;charset=UTF-8";
+    
+    public static final String IMAGE_GIF = "image/gif";
+    
+    public static final String IMAGE_JPEG = "image/jpeg";
+
+    public static final String IMAGE_PNG = "image/png";
+    
+    
+    
+}

+ 0 - 0
maxkey-core/src/main/java/org/maxkey/crypto/Base32Utils.java → maxkey-common/src/main/java/org/maxkey/crypto/Base32Utils.java


+ 0 - 0
maxkey-core/src/main/java/org/maxkey/crypto/Base64Utils.java → maxkey-common/src/main/java/org/maxkey/crypto/Base64Utils.java


+ 0 - 0
maxkey-core/src/main/java/org/maxkey/crypto/BytesUtils.java → maxkey-common/src/main/java/org/maxkey/crypto/BytesUtils.java


+ 0 - 0
maxkey-core/src/main/java/org/maxkey/crypto/DigestUtils.java → maxkey-common/src/main/java/org/maxkey/crypto/DigestUtils.java


+ 0 - 0
maxkey-core/src/main/java/org/maxkey/crypto/HexUtils.java → maxkey-common/src/main/java/org/maxkey/crypto/HexUtils.java


+ 0 - 0
maxkey-core/src/main/java/org/maxkey/crypto/KeyPairSize.java → maxkey-common/src/main/java/org/maxkey/crypto/KeyPairSize.java


+ 0 - 0
maxkey-core/src/main/java/org/maxkey/crypto/KeyPairType.java → maxkey-common/src/main/java/org/maxkey/crypto/KeyPairType.java


+ 0 - 0
maxkey-core/src/main/java/org/maxkey/crypto/KeyPairUtil.java → maxkey-common/src/main/java/org/maxkey/crypto/KeyPairUtil.java


+ 0 - 0
maxkey-core/src/main/java/org/maxkey/crypto/Md5Sum.java → maxkey-common/src/main/java/org/maxkey/crypto/Md5Sum.java


+ 0 - 0
maxkey-core/src/main/java/org/maxkey/crypto/RSAUtils.java → maxkey-common/src/main/java/org/maxkey/crypto/RSAUtils.java


+ 0 - 0
maxkey-core/src/main/java/org/maxkey/crypto/ReciprocalUtils.java → maxkey-common/src/main/java/org/maxkey/crypto/ReciprocalUtils.java


+ 0 - 0
maxkey-core/src/main/java/org/maxkey/crypto/SM3.java → maxkey-common/src/main/java/org/maxkey/crypto/SM3.java


+ 0 - 0
maxkey-core/src/main/java/org/maxkey/crypto/cert/CertCrypto.java → maxkey-common/src/main/java/org/maxkey/crypto/cert/CertCrypto.java


+ 0 - 0
maxkey-core/src/main/java/org/maxkey/crypto/cert/CertSigner.java → maxkey-common/src/main/java/org/maxkey/crypto/cert/CertSigner.java


+ 0 - 0
maxkey-core/src/main/java/org/maxkey/crypto/cert/CryptoException.java → maxkey-common/src/main/java/org/maxkey/crypto/cert/CryptoException.java


+ 0 - 0
maxkey-core/src/main/java/org/maxkey/crypto/cert/NameUtil.java → maxkey-common/src/main/java/org/maxkey/crypto/cert/NameUtil.java


+ 0 - 0
maxkey-core/src/main/java/org/maxkey/crypto/cert/NetUtil.java → maxkey-common/src/main/java/org/maxkey/crypto/cert/NetUtil.java


+ 0 - 0
maxkey-core/src/main/java/org/maxkey/crypto/cert/SignatureType.java → maxkey-common/src/main/java/org/maxkey/crypto/cert/SignatureType.java


+ 0 - 0
maxkey-core/src/main/java/org/maxkey/crypto/cert/StringUtil.java → maxkey-common/src/main/java/org/maxkey/crypto/cert/StringUtil.java


+ 0 - 0
maxkey-core/src/main/java/org/maxkey/crypto/cert/X509CertUtils.java → maxkey-common/src/main/java/org/maxkey/crypto/cert/X509CertUtils.java


+ 0 - 0
maxkey-core/src/main/java/org/maxkey/crypto/cert/X509V3CertGen.java → maxkey-common/src/main/java/org/maxkey/crypto/cert/X509V3CertGen.java


+ 0 - 0
maxkey-core/src/main/java/org/maxkey/crypto/jose/JWEAlgorithmEmbed.java → maxkey-common/src/main/java/org/maxkey/crypto/jose/JWEAlgorithmEmbed.java


+ 0 - 0
maxkey-core/src/main/java/org/maxkey/crypto/jose/JWEEncryptionMethodEmbed.java → maxkey-common/src/main/java/org/maxkey/crypto/jose/JWEEncryptionMethodEmbed.java


+ 0 - 0
maxkey-core/src/main/java/org/maxkey/crypto/jose/JWSAlgorithmEmbed.java → maxkey-common/src/main/java/org/maxkey/crypto/jose/JWSAlgorithmEmbed.java


+ 0 - 0
maxkey-core/src/main/java/org/maxkey/crypto/jose/keystore/JWKSetKeyStore.java → maxkey-common/src/main/java/org/maxkey/crypto/jose/keystore/JWKSetKeyStore.java


+ 0 - 0
maxkey-core/src/main/java/org/maxkey/crypto/jwt/encryption/service/JwtEncryptionAndDecryptionService.java → maxkey-common/src/main/java/org/maxkey/crypto/jwt/encryption/service/JwtEncryptionAndDecryptionService.java


+ 0 - 0
maxkey-core/src/main/java/org/maxkey/crypto/jwt/encryption/service/impl/DefaultJwtEncryptionAndDecryptionService.java → maxkey-common/src/main/java/org/maxkey/crypto/jwt/encryption/service/impl/DefaultJwtEncryptionAndDecryptionService.java


+ 0 - 0
maxkey-core/src/main/java/org/maxkey/crypto/jwt/encryption/service/impl/RecipientJwtEncryptionAndDecryptionServiceBuilder.java → maxkey-common/src/main/java/org/maxkey/crypto/jwt/encryption/service/impl/RecipientJwtEncryptionAndDecryptionServiceBuilder.java


+ 0 - 0
maxkey-core/src/main/java/org/maxkey/crypto/jwt/signer/service/JwtSigningAndValidationService.java → maxkey-common/src/main/java/org/maxkey/crypto/jwt/signer/service/JwtSigningAndValidationService.java


+ 0 - 0
maxkey-core/src/main/java/org/maxkey/crypto/jwt/signer/service/impl/DefaultJwtSigningAndValidationService.java → maxkey-common/src/main/java/org/maxkey/crypto/jwt/signer/service/impl/DefaultJwtSigningAndValidationService.java


+ 0 - 0
maxkey-core/src/main/java/org/maxkey/crypto/jwt/signer/service/impl/JWKSetCacheService.java → maxkey-common/src/main/java/org/maxkey/crypto/jwt/signer/service/impl/JWKSetCacheService.java


+ 5 - 6
maxkey-core/src/main/java/org/maxkey/crypto/jwt/signer/service/impl/SymmetricCacheService.java → maxkey-common/src/main/java/org/maxkey/crypto/jwt/signer/service/impl/SymmetricCacheService.java

@@ -23,7 +23,6 @@ import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
 
 import org.maxkey.crypto.jwt.signer.service.JwtSigningAndValidationService;
-import org.maxkey.domain.apps.oauth2.provider.ClientDetails;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Service;
@@ -67,20 +66,20 @@ public class SymmetricCacheService {
 	 * @param client
 	 * @return
 	 */
-	public JwtSigningAndValidationService getSymmetricValidtor(ClientDetails client) {
+	public JwtSigningAndValidationService getSymmetricValidtor(String clientSecret) {
 
-		if (client == null) {
+		if (clientSecret == null) {
 			logger.error("Couldn't create symmetric validator for null client");
 			return null;
 		}
 
-		if (Strings.isNullOrEmpty(client.getClientSecret())) {
-			logger.error("Couldn't create symmetric validator for client " + client.getClientId() + " without a client secret");
+		if (Strings.isNullOrEmpty(clientSecret)) {
+			logger.error("Couldn't create symmetric validator for client  without a client secret");
 			return null;
 		}
 
 		try {
-			return validators.get(client.getClientSecret());
+			return validators.get(clientSecret);
 		} catch (UncheckedExecutionException ue) {
 			logger.error("Problem loading client validator", ue);
 			return null;

+ 0 - 0
maxkey-core/src/main/java/org/maxkey/crypto/jwt/signer/service/impl/SymmetricSigningAndValidationServiceBuilder.java → maxkey-common/src/main/java/org/maxkey/crypto/jwt/signer/service/impl/SymmetricSigningAndValidationServiceBuilder.java


+ 0 - 0
maxkey-core/src/main/java/org/maxkey/crypto/keystore/KeyStoreLoader.java → maxkey-common/src/main/java/org/maxkey/crypto/keystore/KeyStoreLoader.java


+ 0 - 0
maxkey-core/src/main/java/org/maxkey/crypto/keystore/KeyStoreType.java → maxkey-common/src/main/java/org/maxkey/crypto/keystore/KeyStoreType.java


+ 0 - 0
maxkey-core/src/main/java/org/maxkey/crypto/keystore/KeyStoreUtil.java → maxkey-common/src/main/java/org/maxkey/crypto/keystore/KeyStoreUtil.java


+ 0 - 0
maxkey-core/src/main/java/org/maxkey/crypto/password/Digester.java → maxkey-common/src/main/java/org/maxkey/crypto/password/Digester.java


+ 0 - 0
maxkey-core/src/main/java/org/maxkey/crypto/password/LdapShaPasswordEncoder.java → maxkey-common/src/main/java/org/maxkey/crypto/password/LdapShaPasswordEncoder.java


+ 0 - 0
maxkey-core/src/main/java/org/maxkey/crypto/password/Md4.java → maxkey-common/src/main/java/org/maxkey/crypto/password/Md4.java


+ 0 - 0
maxkey-core/src/main/java/org/maxkey/crypto/password/Md4PasswordEncoder.java → maxkey-common/src/main/java/org/maxkey/crypto/password/Md4PasswordEncoder.java


+ 0 - 0
maxkey-core/src/main/java/org/maxkey/crypto/password/MessageDigestPasswordEncoder.java → maxkey-common/src/main/java/org/maxkey/crypto/password/MessageDigestPasswordEncoder.java


+ 0 - 0
maxkey-core/src/main/java/org/maxkey/crypto/password/NoOpPasswordEncoder.java → maxkey-common/src/main/java/org/maxkey/crypto/password/NoOpPasswordEncoder.java


部分文件因文件數量過多而無法顯示