diff --git a/.gitignore b/.gitignore index 4c69ab163..41410d080 100644 --- a/.gitignore +++ b/.gitignore @@ -45,3 +45,4 @@ classpath-data.json /.gradle/* /build/ setEnvVars.bat +/bin/ diff --git a/build.gradle b/build.gradle index 1756c2ce5..87e5e13cf 100644 --- a/build.gradle +++ b/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/=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/=UTF-8') //use UTF-8 + } + */ /* wtp { diff --git a/gradle.properties b/gradle.properties index 4533cb364..fc41f4df0 100644 --- a/gradle.properties +++ b/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 diff --git a/maxkey-authentications/maxkey-authentication-captcha/build.gradle b/maxkey-authentications/maxkey-authentication-captcha/build.gradle index 0d0fcc9ae..c162e72b0 100644 --- a/maxkey-authentications/maxkey-authentication-captcha/build.gradle +++ b/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") diff --git a/maxkey-authentications/maxkey-authentication-core/build.gradle b/maxkey-authentications/maxkey-authentication-core/build.gradle index 82d21ab4f..c00f8d9e2 100644 --- a/maxkey-authentications/maxkey-authentication-core/build.gradle +++ b/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") diff --git a/maxkey-authentications/maxkey-authentication-otp/build.gradle b/maxkey-authentications/maxkey-authentication-otp/build.gradle new file mode 100644 index 000000000..7c63fa12a --- /dev/null +++ b/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") + +} \ No newline at end of file diff --git a/maxkey-authentications/maxkey-authentication-otp/src/main/java/META-INF/MANIFEST.MF b/maxkey-authentications/maxkey-authentication-otp/src/main/java/META-INF/MANIFEST.MF new file mode 100644 index 000000000..254272e1c --- /dev/null +++ b/maxkey-authentications/maxkey-authentication-otp/src/main/java/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Class-Path: + diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/password/opt/AbstractOptAuthn.java b/maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/AbstractOtpAuthn.java similarity index 90% rename from maxkey-core/src/main/java/org/maxkey/crypto/password/opt/AbstractOptAuthn.java rename to maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/AbstractOtpAuthn.java index 4e72fd34c..ca50c7e51 100644 --- a/maxkey-core/src/main/java/org/maxkey/crypto/password/opt/AbstractOptAuthn.java +++ b/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; } diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/password/opt/OneTimePassword.java b/maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/OneTimePassword.java similarity index 98% rename from maxkey-core/src/main/java/org/maxkey/crypto/password/opt/OneTimePassword.java rename to maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/OneTimePassword.java index ef0d49eb3..2292669f6 100644 --- a/maxkey-core/src/main/java/org/maxkey/crypto/password/opt/OneTimePassword.java +++ b/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; diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/password/opt/algorithm/HOTP.java b/maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/algorithm/HOTP.java similarity index 99% rename from maxkey-core/src/main/java/org/maxkey/crypto/password/opt/algorithm/HOTP.java rename to maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/algorithm/HOTP.java index 9a3b6862b..0bd8d9a8c 100644 --- a/maxkey-core/src/main/java/org/maxkey/crypto/password/opt/algorithm/HOTP.java +++ b/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; diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/password/opt/algorithm/HmacOTP.java b/maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/algorithm/HmacOTP.java similarity index 98% rename from maxkey-core/src/main/java/org/maxkey/crypto/password/opt/algorithm/HmacOTP.java rename to maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/algorithm/HmacOTP.java index dc1be6304..ed4e6a230 100644 --- a/maxkey-core/src/main/java/org/maxkey/crypto/password/opt/algorithm/HmacOTP.java +++ b/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; diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/password/opt/algorithm/KeyUriFormat.java b/maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/algorithm/KeyUriFormat.java similarity index 98% rename from maxkey-core/src/main/java/org/maxkey/crypto/password/opt/algorithm/KeyUriFormat.java rename to maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/algorithm/KeyUriFormat.java index 61eac5ee9..5dc1ecbf4 100644 --- a/maxkey-core/src/main/java/org/maxkey/crypto/password/opt/algorithm/KeyUriFormat.java +++ b/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 { diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/password/opt/algorithm/OtpSecret.java b/maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/algorithm/OtpSecret.java similarity index 97% rename from maxkey-core/src/main/java/org/maxkey/crypto/password/opt/algorithm/OtpSecret.java rename to maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/algorithm/OtpSecret.java index 8dcbc0c88..c972f0e3d 100644 --- a/maxkey-core/src/main/java/org/maxkey/crypto/password/opt/algorithm/OtpSecret.java +++ b/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; diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/password/opt/algorithm/TimeBasedOTP.java b/maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/algorithm/TimeBasedOTP.java similarity index 99% rename from maxkey-core/src/main/java/org/maxkey/crypto/password/opt/algorithm/TimeBasedOTP.java rename to maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/algorithm/TimeBasedOTP.java index 5dff723ce..5bef2ce63 100644 --- a/maxkey-core/src/main/java/org/maxkey/crypto/password/opt/algorithm/TimeBasedOTP.java +++ b/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; diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/password/opt/impl/CapOtpAuthn.java b/maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/impl/CapOtpAuthn.java similarity index 90% rename from maxkey-core/src/main/java/org/maxkey/crypto/password/opt/impl/CapOtpAuthn.java rename to maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/impl/CapOtpAuthn.java index 729f4f214..aec19ead3 100644 --- a/maxkey-core/src/main/java/org/maxkey/crypto/password/opt/impl/CapOtpAuthn.java +++ b/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 { diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/password/opt/impl/CounterBasedOtpAuthn.java b/maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/impl/CounterBasedOtpAuthn.java similarity index 91% rename from maxkey-core/src/main/java/org/maxkey/crypto/password/opt/impl/CounterBasedOtpAuthn.java rename to maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/impl/CounterBasedOtpAuthn.java index 474b85b34..52b71b475 100644 --- a/maxkey-core/src/main/java/org/maxkey/crypto/password/opt/impl/CounterBasedOtpAuthn.java +++ b/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); diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/password/opt/impl/HotpOtpAuthn.java b/maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/impl/HotpOtpAuthn.java similarity index 92% rename from maxkey-core/src/main/java/org/maxkey/crypto/password/opt/impl/HotpOtpAuthn.java rename to maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/impl/HotpOtpAuthn.java index b8c0cc7ae..6889d516b 100644 --- a/maxkey-core/src/main/java/org/maxkey/crypto/password/opt/impl/HotpOtpAuthn.java +++ b/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; diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/password/opt/impl/MailOtpAuthn.java b/maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/impl/MailOtpAuthn.java similarity index 95% rename from maxkey-core/src/main/java/org/maxkey/crypto/password/opt/impl/MailOtpAuthn.java rename to maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/impl/MailOtpAuthn.java index 3169c26f0..5e7c48a9c 100644 --- a/maxkey-core/src/main/java/org/maxkey/crypto/password/opt/impl/MailOtpAuthn.java +++ b/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 diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/password/opt/impl/MobileOtpAuthn.java b/maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/impl/MobileOtpAuthn.java similarity index 86% rename from maxkey-core/src/main/java/org/maxkey/crypto/password/opt/impl/MobileOtpAuthn.java rename to maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/impl/MobileOtpAuthn.java index 6c900ca14..f1c207366 100644 --- a/maxkey-core/src/main/java/org/maxkey/crypto/password/opt/impl/MobileOtpAuthn.java +++ b/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 { diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/password/opt/impl/RsaOtpAuthn.java b/maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/impl/RsaOtpAuthn.java similarity index 90% rename from maxkey-core/src/main/java/org/maxkey/crypto/password/opt/impl/RsaOtpAuthn.java rename to maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/impl/RsaOtpAuthn.java index dd9e7172d..20033cfb1 100644 --- a/maxkey-core/src/main/java/org/maxkey/crypto/password/opt/impl/RsaOtpAuthn.java +++ b/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 { diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/password/opt/impl/SmsOtpAuthn.java b/maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/impl/SmsOtpAuthn.java similarity index 92% rename from maxkey-core/src/main/java/org/maxkey/crypto/password/opt/impl/SmsOtpAuthn.java rename to maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/impl/SmsOtpAuthn.java index 215728456..5fa441d9d 100644 --- a/maxkey-core/src/main/java/org/maxkey/crypto/password/opt/impl/SmsOtpAuthn.java +++ b/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; diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/password/opt/impl/TimeBasedOtpAuthn.java b/maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/impl/TimeBasedOtpAuthn.java similarity index 92% rename from maxkey-core/src/main/java/org/maxkey/crypto/password/opt/impl/TimeBasedOtpAuthn.java rename to maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/impl/TimeBasedOtpAuthn.java index 984903d71..a1bf4f16e 100644 --- a/maxkey-core/src/main/java/org/maxkey/crypto/password/opt/impl/TimeBasedOtpAuthn.java +++ b/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"); diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/password/opt/impl/sms/SmsOtpAuthnAliyun.java b/maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/impl/sms/SmsOtpAuthnAliyun.java similarity index 97% rename from maxkey-core/src/main/java/org/maxkey/crypto/password/opt/impl/sms/SmsOtpAuthnAliyun.java rename to maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/impl/sms/SmsOtpAuthnAliyun.java index dbd3e9644..70fd71e79 100644 --- a/maxkey-core/src/main/java/org/maxkey/crypto/password/opt/impl/sms/SmsOtpAuthnAliyun.java +++ b/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; diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/password/opt/impl/sms/SmsOtpAuthnTencentCloud.java b/maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/impl/sms/SmsOtpAuthnTencentCloud.java similarity index 97% rename from maxkey-core/src/main/java/org/maxkey/crypto/password/opt/impl/sms/SmsOtpAuthnTencentCloud.java rename to maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/impl/sms/SmsOtpAuthnTencentCloud.java index d7247f9eb..385f1e61a 100644 --- a/maxkey-core/src/main/java/org/maxkey/crypto/password/opt/impl/sms/SmsOtpAuthnTencentCloud.java +++ b/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; diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/password/opt/impl/sms/SmsOtpAuthnYunxin.java b/maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/impl/sms/SmsOtpAuthnYunxin.java similarity index 98% rename from maxkey-core/src/main/java/org/maxkey/crypto/password/opt/impl/sms/SmsOtpAuthnYunxin.java rename to maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/impl/sms/SmsOtpAuthnYunxin.java index 73c5e118c..06cce98ab 100644 --- a/maxkey-core/src/main/java/org/maxkey/crypto/password/opt/impl/sms/SmsOtpAuthnYunxin.java +++ b/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; diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/password/opt/impl/sms/SmsOtpAuthnYunxinCheckSumBuilder.java b/maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/impl/sms/SmsOtpAuthnYunxinCheckSumBuilder.java similarity index 97% rename from maxkey-core/src/main/java/org/maxkey/crypto/password/opt/impl/sms/SmsOtpAuthnYunxinCheckSumBuilder.java rename to maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/impl/sms/SmsOtpAuthnYunxinCheckSumBuilder.java index 8a3448d36..da3cc544d 100644 --- a/maxkey-core/src/main/java/org/maxkey/crypto/password/opt/impl/sms/SmsOtpAuthnYunxinCheckSumBuilder.java +++ b/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; diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/password/opt/token/AbstractOptTokenStore.java b/maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/token/AbstractOtpTokenStore.java similarity index 90% rename from maxkey-core/src/main/java/org/maxkey/crypto/password/opt/token/AbstractOptTokenStore.java rename to maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/token/AbstractOtpTokenStore.java index 6ea0a36ab..134bafdb7 100644 --- a/maxkey-core/src/main/java/org/maxkey/crypto/password/opt/token/AbstractOptTokenStore.java +++ b/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); diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/password/opt/token/InMemoryOptTokenStore.java b/maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/token/InMemoryOtpTokenStore.java similarity index 92% rename from maxkey-core/src/main/java/org/maxkey/crypto/password/opt/token/InMemoryOptTokenStore.java rename to maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/token/InMemoryOtpTokenStore.java index 06d871cf1..d72899e4a 100644 --- a/maxkey-core/src/main/java/org/maxkey/crypto/password/opt/token/InMemoryOptTokenStore.java +++ b/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 optTokenStore = UserManagedCacheBuilder.newUserManagedCacheBuilder(String.class, OneTimePassword.class) @@ -73,7 +73,7 @@ public class InMemoryOptTokenStore extends AbstractOptTokenStore { return false; } - public InMemoryOptTokenStore() { + public InMemoryOtpTokenStore() { } } diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/password/opt/token/RedisOptTokenStore.java b/maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/token/RedisOtpTokenStore.java similarity index 90% rename from maxkey-core/src/main/java/org/maxkey/crypto/password/opt/token/RedisOptTokenStore.java rename to maxkey-authentications/maxkey-authentication-otp/src/main/java/org/maxkey/crypto/password/otp/token/RedisOtpTokenStore.java index 24b35db41..81b426e24 100644 --- a/maxkey-core/src/main/java/org/maxkey/crypto/password/opt/token/RedisOptTokenStore.java +++ b/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; } diff --git a/maxkey-core/src/test/java/org/maxkey/otp/algorithm/HmacOTPTest.java b/maxkey-authentications/maxkey-authentication-otp/src/test/java/org/maxkey/otp/algorithm/HmacOTPTest.java similarity index 92% rename from maxkey-core/src/test/java/org/maxkey/otp/algorithm/HmacOTPTest.java rename to maxkey-authentications/maxkey-authentication-otp/src/test/java/org/maxkey/otp/algorithm/HmacOTPTest.java index 3406e5df6..5540953dd 100644 --- a/maxkey-core/src/test/java/org/maxkey/otp/algorithm/HmacOTPTest.java +++ b/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 { diff --git a/maxkey-core/src/test/java/org/maxkey/otp/algorithm/KeyUriFormatTest.java b/maxkey-authentications/maxkey-authentication-otp/src/test/java/org/maxkey/otp/algorithm/KeyUriFormatTest.java similarity index 96% rename from maxkey-core/src/test/java/org/maxkey/otp/algorithm/KeyUriFormatTest.java rename to maxkey-authentications/maxkey-authentication-otp/src/test/java/org/maxkey/otp/algorithm/KeyUriFormatTest.java index a845aef44..2ad7bd38b 100644 --- a/maxkey-core/src/test/java/org/maxkey/otp/algorithm/KeyUriFormatTest.java +++ b/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; diff --git a/maxkey-core/src/test/java/org/maxkey/otp/algorithm/TimeBasedOTPTest.java b/maxkey-authentications/maxkey-authentication-otp/src/test/java/org/maxkey/otp/algorithm/TimeBasedOTPTest.java similarity index 97% rename from maxkey-core/src/test/java/org/maxkey/otp/algorithm/TimeBasedOTPTest.java rename to maxkey-authentications/maxkey-authentication-otp/src/test/java/org/maxkey/otp/algorithm/TimeBasedOTPTest.java index 5e8677b69..74c2ae170 100644 --- a/maxkey-core/src/test/java/org/maxkey/otp/algorithm/TimeBasedOTPTest.java +++ b/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 diff --git a/maxkey-authentications/maxkey-authentication-social/build.gradle b/maxkey-authentications/maxkey-authentication-social/build.gradle index 3854f1536..5b42dda83 100644 --- a/maxkey-authentications/maxkey-authentication-social/build.gradle +++ b/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") diff --git a/maxkey-common/build.gradle b/maxkey-common/build.gradle new file mode 100644 index 000000000..d08ecf19c --- /dev/null +++ b/maxkey-common/build.gradle @@ -0,0 +1,7 @@ +description = "maxkey-common" + +dependencies { + //local jars + compile fileTree(dir: '../maxkey-lib/', include: '*/*.jar') + +} \ No newline at end of file diff --git a/maxkey-common/src/main/java/META-INF/MANIFEST.MF b/maxkey-common/src/main/java/META-INF/MANIFEST.MF new file mode 100644 index 000000000..254272e1c --- /dev/null +++ b/maxkey-common/src/main/java/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Class-Path: + diff --git a/maxkey-core/src/main/java/org/maxkey/cache/AbstractCache.java b/maxkey-common/src/main/java/org/maxkey/cache/AbstractCache.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/cache/AbstractCache.java rename to maxkey-common/src/main/java/org/maxkey/cache/AbstractCache.java diff --git a/maxkey-core/src/main/java/org/maxkey/cache/CacheFactory.java b/maxkey-common/src/main/java/org/maxkey/cache/CacheFactory.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/cache/CacheFactory.java rename to maxkey-common/src/main/java/org/maxkey/cache/CacheFactory.java diff --git a/maxkey-core/src/main/java/org/maxkey/cache/package-info.java b/maxkey-common/src/main/java/org/maxkey/cache/package-info.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/cache/package-info.java rename to maxkey-common/src/main/java/org/maxkey/cache/package-info.java diff --git a/maxkey-common/src/main/java/org/maxkey/configuration/ApplicationConfig.java b/maxkey-common/src/main/java/org/maxkey/configuration/ApplicationConfig.java new file mode 100644 index 000000000..bb57945b1 --- /dev/null +++ b/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(); + } + +} diff --git a/maxkey-common/src/main/java/org/maxkey/configuration/CharacterEncodingConfig.java b/maxkey-common/src/main/java/org/maxkey/configuration/CharacterEncodingConfig.java new file mode 100644 index 000000000..a28c181e4 --- /dev/null +++ b/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(); + } + +} diff --git a/maxkey-common/src/main/java/org/maxkey/configuration/EmailConfig.java b/maxkey-common/src/main/java/org/maxkey/configuration/EmailConfig.java new file mode 100644 index 000000000..9a4a508b8 --- /dev/null +++ b/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(); + } + +} diff --git a/maxkey-common/src/main/java/org/maxkey/configuration/LoginConfig.java b/maxkey-common/src/main/java/org/maxkey/configuration/LoginConfig.java new file mode 100644 index 000000000..c1b10f607 --- /dev/null +++ b/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(); + } + +} diff --git a/maxkey-common/src/main/java/org/maxkey/configuration/oidc/OIDCProviderMetadata.java b/maxkey-common/src/main/java/org/maxkey/configuration/oidc/OIDCProviderMetadata.java new file mode 100644 index 000000000..27a243317 --- /dev/null +++ b/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 getScopesSupported(); + + public void setScopesSupported(Set scopesSupported); + + public Set getResponseTypesSupported(); + + public void setResponseTypesSupported(Set responseTypesSupported); + +} diff --git a/maxkey-common/src/main/java/org/maxkey/configuration/oidc/OIDCProviderMetadataDetails.java b/maxkey-common/src/main/java/org/maxkey/configuration/oidc/OIDCProviderMetadataDetails.java new file mode 100644 index 000000000..37d0f3ec3 --- /dev/null +++ b/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 scopesSupported; + + protected Set 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 getScopesSupported() { + return scopesSupported; + } + + public void setScopesSupported(Set scopesSupported) { + this.scopesSupported = scopesSupported; + } + + public Set getResponseTypesSupported() { + return responseTypesSupported; + } + + public void setResponseTypesSupported(Set 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 + +} diff --git a/maxkey-common/src/main/java/org/maxkey/constants/Boolean.java b/maxkey-common/src/main/java/org/maxkey/constants/Boolean.java new file mode 100644 index 000000000..80eba979b --- /dev/null +++ b/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; + } + +} diff --git a/maxkey-common/src/main/java/org/maxkey/constants/ConstantsEntryType.java b/maxkey-common/src/main/java/org/maxkey/constants/ConstantsEntryType.java new file mode 100644 index 000000000..69d7d0914 --- /dev/null +++ b/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; + +} diff --git a/maxkey-common/src/main/java/org/maxkey/constants/ConstantsLoginType.java b/maxkey-common/src/main/java/org/maxkey/constants/ConstantsLoginType.java new file mode 100644 index 000000000..c0fae461e --- /dev/null +++ b/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"; + +} diff --git a/maxkey-common/src/main/java/org/maxkey/constants/ConstantsOperateAction.java b/maxkey-common/src/main/java/org/maxkey/constants/ConstantsOperateAction.java new file mode 100644 index 000000000..75a994ece --- /dev/null +++ b/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; + +} diff --git a/maxkey-common/src/main/java/org/maxkey/constants/ConstantsOperateMessage.java b/maxkey-common/src/main/java/org/maxkey/constants/ConstantsOperateMessage.java new file mode 100644 index 000000000..d97641b9f --- /dev/null +++ b/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"; + +} diff --git a/maxkey-common/src/main/java/org/maxkey/constants/ConstantsPasswordSetType.java b/maxkey-common/src/main/java/org/maxkey/constants/ConstantsPasswordSetType.java new file mode 100644 index 000000000..9bb709ea1 --- /dev/null +++ b/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; + +} diff --git a/maxkey-common/src/main/java/org/maxkey/constants/ConstantsPersistence.java b/maxkey-common/src/main/java/org/maxkey/constants/ConstantsPersistence.java new file mode 100644 index 000000000..3a40a943b --- /dev/null +++ b/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; + +} diff --git a/maxkey-common/src/main/java/org/maxkey/constants/ConstantsPlatformRole.java b/maxkey-common/src/main/java/org/maxkey/constants/ConstantsPlatformRole.java new file mode 100644 index 000000000..ea5b30bdb --- /dev/null +++ b/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"; +} diff --git a/maxkey-common/src/main/java/org/maxkey/constants/ConstantsProperties.java b/maxkey-common/src/main/java/org/maxkey/constants/ConstantsProperties.java new file mode 100644 index 000000000..d38ba8f01 --- /dev/null +++ b/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)); + } +} diff --git a/maxkey-common/src/main/java/org/maxkey/constants/ConstantsProtocols.java b/maxkey-common/src/main/java/org/maxkey/constants/ConstantsProtocols.java new file mode 100644 index 000000000..85d0f2996 --- /dev/null +++ b/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"; + +} diff --git a/maxkey-common/src/main/java/org/maxkey/constants/ConstantsServiceMessage.java b/maxkey-common/src/main/java/org/maxkey/constants/ConstantsServiceMessage.java new file mode 100644 index 000000000..b5ba1e58e --- /dev/null +++ b/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"; + } +} diff --git a/maxkey-common/src/main/java/org/maxkey/constants/ConstantsStatus.java b/maxkey-common/src/main/java/org/maxkey/constants/ConstantsStatus.java new file mode 100644 index 000000000..af3c3e32d --- /dev/null +++ b/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; + +} diff --git a/maxkey-common/src/main/java/org/maxkey/constants/ConstantsTimeInterval.java b/maxkey-common/src/main/java/org/maxkey/constants/ConstantsTimeInterval.java new file mode 100644 index 000000000..f142b2a07 --- /dev/null +++ b/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; +} diff --git a/maxkey-common/src/main/java/org/maxkey/constants/ContentType.java b/maxkey-common/src/main/java/org/maxkey/constants/ContentType.java new file mode 100644 index 000000000..a95376610 --- /dev/null +++ b/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"; + + + +} diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/Base32Utils.java b/maxkey-common/src/main/java/org/maxkey/crypto/Base32Utils.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/crypto/Base32Utils.java rename to maxkey-common/src/main/java/org/maxkey/crypto/Base32Utils.java diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/Base64Utils.java b/maxkey-common/src/main/java/org/maxkey/crypto/Base64Utils.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/crypto/Base64Utils.java rename to maxkey-common/src/main/java/org/maxkey/crypto/Base64Utils.java diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/BytesUtils.java b/maxkey-common/src/main/java/org/maxkey/crypto/BytesUtils.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/crypto/BytesUtils.java rename to maxkey-common/src/main/java/org/maxkey/crypto/BytesUtils.java diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/DigestUtils.java b/maxkey-common/src/main/java/org/maxkey/crypto/DigestUtils.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/crypto/DigestUtils.java rename to maxkey-common/src/main/java/org/maxkey/crypto/DigestUtils.java diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/HexUtils.java b/maxkey-common/src/main/java/org/maxkey/crypto/HexUtils.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/crypto/HexUtils.java rename to maxkey-common/src/main/java/org/maxkey/crypto/HexUtils.java diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/KeyPairSize.java b/maxkey-common/src/main/java/org/maxkey/crypto/KeyPairSize.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/crypto/KeyPairSize.java rename to maxkey-common/src/main/java/org/maxkey/crypto/KeyPairSize.java diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/KeyPairType.java b/maxkey-common/src/main/java/org/maxkey/crypto/KeyPairType.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/crypto/KeyPairType.java rename to maxkey-common/src/main/java/org/maxkey/crypto/KeyPairType.java diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/KeyPairUtil.java b/maxkey-common/src/main/java/org/maxkey/crypto/KeyPairUtil.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/crypto/KeyPairUtil.java rename to maxkey-common/src/main/java/org/maxkey/crypto/KeyPairUtil.java diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/Md5Sum.java b/maxkey-common/src/main/java/org/maxkey/crypto/Md5Sum.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/crypto/Md5Sum.java rename to maxkey-common/src/main/java/org/maxkey/crypto/Md5Sum.java diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/RSAUtils.java b/maxkey-common/src/main/java/org/maxkey/crypto/RSAUtils.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/crypto/RSAUtils.java rename to maxkey-common/src/main/java/org/maxkey/crypto/RSAUtils.java diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/ReciprocalUtils.java b/maxkey-common/src/main/java/org/maxkey/crypto/ReciprocalUtils.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/crypto/ReciprocalUtils.java rename to maxkey-common/src/main/java/org/maxkey/crypto/ReciprocalUtils.java diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/SM3.java b/maxkey-common/src/main/java/org/maxkey/crypto/SM3.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/crypto/SM3.java rename to maxkey-common/src/main/java/org/maxkey/crypto/SM3.java diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/cert/CertCrypto.java b/maxkey-common/src/main/java/org/maxkey/crypto/cert/CertCrypto.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/crypto/cert/CertCrypto.java rename to maxkey-common/src/main/java/org/maxkey/crypto/cert/CertCrypto.java diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/cert/CertSigner.java b/maxkey-common/src/main/java/org/maxkey/crypto/cert/CertSigner.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/crypto/cert/CertSigner.java rename to maxkey-common/src/main/java/org/maxkey/crypto/cert/CertSigner.java diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/cert/CryptoException.java b/maxkey-common/src/main/java/org/maxkey/crypto/cert/CryptoException.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/crypto/cert/CryptoException.java rename to maxkey-common/src/main/java/org/maxkey/crypto/cert/CryptoException.java diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/cert/NameUtil.java b/maxkey-common/src/main/java/org/maxkey/crypto/cert/NameUtil.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/crypto/cert/NameUtil.java rename to maxkey-common/src/main/java/org/maxkey/crypto/cert/NameUtil.java diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/cert/NetUtil.java b/maxkey-common/src/main/java/org/maxkey/crypto/cert/NetUtil.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/crypto/cert/NetUtil.java rename to maxkey-common/src/main/java/org/maxkey/crypto/cert/NetUtil.java diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/cert/SignatureType.java b/maxkey-common/src/main/java/org/maxkey/crypto/cert/SignatureType.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/crypto/cert/SignatureType.java rename to maxkey-common/src/main/java/org/maxkey/crypto/cert/SignatureType.java diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/cert/StringUtil.java b/maxkey-common/src/main/java/org/maxkey/crypto/cert/StringUtil.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/crypto/cert/StringUtil.java rename to maxkey-common/src/main/java/org/maxkey/crypto/cert/StringUtil.java diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/cert/X509CertUtils.java b/maxkey-common/src/main/java/org/maxkey/crypto/cert/X509CertUtils.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/crypto/cert/X509CertUtils.java rename to maxkey-common/src/main/java/org/maxkey/crypto/cert/X509CertUtils.java diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/cert/X509V3CertGen.java b/maxkey-common/src/main/java/org/maxkey/crypto/cert/X509V3CertGen.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/crypto/cert/X509V3CertGen.java rename to maxkey-common/src/main/java/org/maxkey/crypto/cert/X509V3CertGen.java diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/jose/JWEAlgorithmEmbed.java b/maxkey-common/src/main/java/org/maxkey/crypto/jose/JWEAlgorithmEmbed.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/crypto/jose/JWEAlgorithmEmbed.java rename to maxkey-common/src/main/java/org/maxkey/crypto/jose/JWEAlgorithmEmbed.java diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/jose/JWEEncryptionMethodEmbed.java b/maxkey-common/src/main/java/org/maxkey/crypto/jose/JWEEncryptionMethodEmbed.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/crypto/jose/JWEEncryptionMethodEmbed.java rename to maxkey-common/src/main/java/org/maxkey/crypto/jose/JWEEncryptionMethodEmbed.java diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/jose/JWSAlgorithmEmbed.java b/maxkey-common/src/main/java/org/maxkey/crypto/jose/JWSAlgorithmEmbed.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/crypto/jose/JWSAlgorithmEmbed.java rename to maxkey-common/src/main/java/org/maxkey/crypto/jose/JWSAlgorithmEmbed.java diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/jose/keystore/JWKSetKeyStore.java b/maxkey-common/src/main/java/org/maxkey/crypto/jose/keystore/JWKSetKeyStore.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/crypto/jose/keystore/JWKSetKeyStore.java rename to maxkey-common/src/main/java/org/maxkey/crypto/jose/keystore/JWKSetKeyStore.java diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/jwt/encryption/service/JwtEncryptionAndDecryptionService.java b/maxkey-common/src/main/java/org/maxkey/crypto/jwt/encryption/service/JwtEncryptionAndDecryptionService.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/crypto/jwt/encryption/service/JwtEncryptionAndDecryptionService.java rename to maxkey-common/src/main/java/org/maxkey/crypto/jwt/encryption/service/JwtEncryptionAndDecryptionService.java diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/jwt/encryption/service/impl/DefaultJwtEncryptionAndDecryptionService.java b/maxkey-common/src/main/java/org/maxkey/crypto/jwt/encryption/service/impl/DefaultJwtEncryptionAndDecryptionService.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/crypto/jwt/encryption/service/impl/DefaultJwtEncryptionAndDecryptionService.java rename to maxkey-common/src/main/java/org/maxkey/crypto/jwt/encryption/service/impl/DefaultJwtEncryptionAndDecryptionService.java diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/jwt/encryption/service/impl/RecipientJwtEncryptionAndDecryptionServiceBuilder.java b/maxkey-common/src/main/java/org/maxkey/crypto/jwt/encryption/service/impl/RecipientJwtEncryptionAndDecryptionServiceBuilder.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/crypto/jwt/encryption/service/impl/RecipientJwtEncryptionAndDecryptionServiceBuilder.java rename to maxkey-common/src/main/java/org/maxkey/crypto/jwt/encryption/service/impl/RecipientJwtEncryptionAndDecryptionServiceBuilder.java diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/jwt/signer/service/JwtSigningAndValidationService.java b/maxkey-common/src/main/java/org/maxkey/crypto/jwt/signer/service/JwtSigningAndValidationService.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/crypto/jwt/signer/service/JwtSigningAndValidationService.java rename to maxkey-common/src/main/java/org/maxkey/crypto/jwt/signer/service/JwtSigningAndValidationService.java diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/jwt/signer/service/impl/DefaultJwtSigningAndValidationService.java b/maxkey-common/src/main/java/org/maxkey/crypto/jwt/signer/service/impl/DefaultJwtSigningAndValidationService.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/crypto/jwt/signer/service/impl/DefaultJwtSigningAndValidationService.java rename to maxkey-common/src/main/java/org/maxkey/crypto/jwt/signer/service/impl/DefaultJwtSigningAndValidationService.java diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/jwt/signer/service/impl/JWKSetCacheService.java b/maxkey-common/src/main/java/org/maxkey/crypto/jwt/signer/service/impl/JWKSetCacheService.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/crypto/jwt/signer/service/impl/JWKSetCacheService.java rename to maxkey-common/src/main/java/org/maxkey/crypto/jwt/signer/service/impl/JWKSetCacheService.java diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/jwt/signer/service/impl/SymmetricCacheService.java b/maxkey-common/src/main/java/org/maxkey/crypto/jwt/signer/service/impl/SymmetricCacheService.java similarity index 91% rename from maxkey-core/src/main/java/org/maxkey/crypto/jwt/signer/service/impl/SymmetricCacheService.java rename to maxkey-common/src/main/java/org/maxkey/crypto/jwt/signer/service/impl/SymmetricCacheService.java index 45fcd0312..f88b7d134 100644 --- a/maxkey-core/src/main/java/org/maxkey/crypto/jwt/signer/service/impl/SymmetricCacheService.java +++ b/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; diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/jwt/signer/service/impl/SymmetricSigningAndValidationServiceBuilder.java b/maxkey-common/src/main/java/org/maxkey/crypto/jwt/signer/service/impl/SymmetricSigningAndValidationServiceBuilder.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/crypto/jwt/signer/service/impl/SymmetricSigningAndValidationServiceBuilder.java rename to maxkey-common/src/main/java/org/maxkey/crypto/jwt/signer/service/impl/SymmetricSigningAndValidationServiceBuilder.java diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/keystore/KeyStoreLoader.java b/maxkey-common/src/main/java/org/maxkey/crypto/keystore/KeyStoreLoader.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/crypto/keystore/KeyStoreLoader.java rename to maxkey-common/src/main/java/org/maxkey/crypto/keystore/KeyStoreLoader.java diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/keystore/KeyStoreType.java b/maxkey-common/src/main/java/org/maxkey/crypto/keystore/KeyStoreType.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/crypto/keystore/KeyStoreType.java rename to maxkey-common/src/main/java/org/maxkey/crypto/keystore/KeyStoreType.java diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/keystore/KeyStoreUtil.java b/maxkey-common/src/main/java/org/maxkey/crypto/keystore/KeyStoreUtil.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/crypto/keystore/KeyStoreUtil.java rename to maxkey-common/src/main/java/org/maxkey/crypto/keystore/KeyStoreUtil.java diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/password/Digester.java b/maxkey-common/src/main/java/org/maxkey/crypto/password/Digester.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/crypto/password/Digester.java rename to maxkey-common/src/main/java/org/maxkey/crypto/password/Digester.java diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/password/LdapShaPasswordEncoder.java b/maxkey-common/src/main/java/org/maxkey/crypto/password/LdapShaPasswordEncoder.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/crypto/password/LdapShaPasswordEncoder.java rename to maxkey-common/src/main/java/org/maxkey/crypto/password/LdapShaPasswordEncoder.java diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/password/Md4.java b/maxkey-common/src/main/java/org/maxkey/crypto/password/Md4.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/crypto/password/Md4.java rename to maxkey-common/src/main/java/org/maxkey/crypto/password/Md4.java diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/password/Md4PasswordEncoder.java b/maxkey-common/src/main/java/org/maxkey/crypto/password/Md4PasswordEncoder.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/crypto/password/Md4PasswordEncoder.java rename to maxkey-common/src/main/java/org/maxkey/crypto/password/Md4PasswordEncoder.java diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/password/MessageDigestPasswordEncoder.java b/maxkey-common/src/main/java/org/maxkey/crypto/password/MessageDigestPasswordEncoder.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/crypto/password/MessageDigestPasswordEncoder.java rename to maxkey-common/src/main/java/org/maxkey/crypto/password/MessageDigestPasswordEncoder.java diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/password/NoOpPasswordEncoder.java b/maxkey-common/src/main/java/org/maxkey/crypto/password/NoOpPasswordEncoder.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/crypto/password/NoOpPasswordEncoder.java rename to maxkey-common/src/main/java/org/maxkey/crypto/password/NoOpPasswordEncoder.java diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/password/PasswordEncoderUtils.java b/maxkey-common/src/main/java/org/maxkey/crypto/password/PasswordEncoderUtils.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/crypto/password/PasswordEncoderUtils.java rename to maxkey-common/src/main/java/org/maxkey/crypto/password/PasswordEncoderUtils.java diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/password/PasswordGen.java b/maxkey-common/src/main/java/org/maxkey/crypto/password/PasswordGen.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/crypto/password/PasswordGen.java rename to maxkey-common/src/main/java/org/maxkey/crypto/password/PasswordGen.java diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/password/PasswordReciprocal.java b/maxkey-common/src/main/java/org/maxkey/crypto/password/PasswordReciprocal.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/crypto/password/PasswordReciprocal.java rename to maxkey-common/src/main/java/org/maxkey/crypto/password/PasswordReciprocal.java diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/password/SM3PasswordEncoder.java b/maxkey-common/src/main/java/org/maxkey/crypto/password/SM3PasswordEncoder.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/crypto/password/SM3PasswordEncoder.java rename to maxkey-common/src/main/java/org/maxkey/crypto/password/SM3PasswordEncoder.java diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/password/StandardPasswordEncoder.java b/maxkey-common/src/main/java/org/maxkey/crypto/password/StandardPasswordEncoder.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/crypto/password/StandardPasswordEncoder.java rename to maxkey-common/src/main/java/org/maxkey/crypto/password/StandardPasswordEncoder.java diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/signature/DsaSigner.java b/maxkey-common/src/main/java/org/maxkey/crypto/signature/DsaSigner.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/crypto/signature/DsaSigner.java rename to maxkey-common/src/main/java/org/maxkey/crypto/signature/DsaSigner.java diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/signature/ISigner.java b/maxkey-common/src/main/java/org/maxkey/crypto/signature/ISigner.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/crypto/signature/ISigner.java rename to maxkey-common/src/main/java/org/maxkey/crypto/signature/ISigner.java diff --git a/maxkey-core/src/main/java/org/maxkey/crypto/signature/RsaSigner.java b/maxkey-common/src/main/java/org/maxkey/crypto/signature/RsaSigner.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/crypto/signature/RsaSigner.java rename to maxkey-common/src/main/java/org/maxkey/crypto/signature/RsaSigner.java diff --git a/maxkey-core/src/main/java/org/maxkey/json/JsonDateDeserializer.java b/maxkey-common/src/main/java/org/maxkey/json/JsonDateDeserializer.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/json/JsonDateDeserializer.java rename to maxkey-common/src/main/java/org/maxkey/json/JsonDateDeserializer.java diff --git a/maxkey-core/src/main/java/org/maxkey/json/JsonDateSerializer.java b/maxkey-common/src/main/java/org/maxkey/json/JsonDateSerializer.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/json/JsonDateSerializer.java rename to maxkey-common/src/main/java/org/maxkey/json/JsonDateSerializer.java diff --git a/maxkey-core/src/main/java/org/maxkey/json/JsonDateTimeDeserializer.java b/maxkey-common/src/main/java/org/maxkey/json/JsonDateTimeDeserializer.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/json/JsonDateTimeDeserializer.java rename to maxkey-common/src/main/java/org/maxkey/json/JsonDateTimeDeserializer.java diff --git a/maxkey-core/src/main/java/org/maxkey/json/JsonDateTimeSerializer.java b/maxkey-common/src/main/java/org/maxkey/json/JsonDateTimeSerializer.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/json/JsonDateTimeSerializer.java rename to maxkey-common/src/main/java/org/maxkey/json/JsonDateTimeSerializer.java diff --git a/maxkey-core/src/main/java/org/maxkey/json/JsonISODateDeserializer.java b/maxkey-common/src/main/java/org/maxkey/json/JsonISODateDeserializer.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/json/JsonISODateDeserializer.java rename to maxkey-common/src/main/java/org/maxkey/json/JsonISODateDeserializer.java diff --git a/maxkey-core/src/main/java/org/maxkey/json/JsonISODateSerializer.java b/maxkey-common/src/main/java/org/maxkey/json/JsonISODateSerializer.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/json/JsonISODateSerializer.java rename to maxkey-common/src/main/java/org/maxkey/json/JsonISODateSerializer.java diff --git a/maxkey-core/src/main/java/org/maxkey/pretty/Pretty.java b/maxkey-common/src/main/java/org/maxkey/pretty/Pretty.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/pretty/Pretty.java rename to maxkey-common/src/main/java/org/maxkey/pretty/Pretty.java diff --git a/maxkey-core/src/main/java/org/maxkey/pretty/PrettyFactory.java b/maxkey-common/src/main/java/org/maxkey/pretty/PrettyFactory.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/pretty/PrettyFactory.java rename to maxkey-common/src/main/java/org/maxkey/pretty/PrettyFactory.java diff --git a/maxkey-core/src/main/java/org/maxkey/pretty/impl/JsonPretty.java b/maxkey-common/src/main/java/org/maxkey/pretty/impl/JsonPretty.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/pretty/impl/JsonPretty.java rename to maxkey-common/src/main/java/org/maxkey/pretty/impl/JsonPretty.java diff --git a/maxkey-core/src/main/java/org/maxkey/pretty/impl/SqlPretty.java b/maxkey-common/src/main/java/org/maxkey/pretty/impl/SqlPretty.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/pretty/impl/SqlPretty.java rename to maxkey-common/src/main/java/org/maxkey/pretty/impl/SqlPretty.java diff --git a/maxkey-core/src/main/java/org/maxkey/pretty/impl/XMLHelper.java b/maxkey-common/src/main/java/org/maxkey/pretty/impl/XMLHelper.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/pretty/impl/XMLHelper.java rename to maxkey-common/src/main/java/org/maxkey/pretty/impl/XMLHelper.java diff --git a/maxkey-core/src/main/java/org/maxkey/pretty/impl/XmlPretty.java b/maxkey-common/src/main/java/org/maxkey/pretty/impl/XmlPretty.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/pretty/impl/XmlPretty.java rename to maxkey-common/src/main/java/org/maxkey/pretty/impl/XmlPretty.java diff --git a/maxkey-core/src/main/java/org/maxkey/pretty/impl/package-info.java b/maxkey-common/src/main/java/org/maxkey/pretty/impl/package-info.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/pretty/impl/package-info.java rename to maxkey-common/src/main/java/org/maxkey/pretty/impl/package-info.java diff --git a/maxkey-core/src/main/java/org/maxkey/util/AuthorizationHeaderUtils.java b/maxkey-common/src/main/java/org/maxkey/util/AuthorizationHeaderUtils.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/util/AuthorizationHeaderUtils.java rename to maxkey-common/src/main/java/org/maxkey/util/AuthorizationHeaderUtils.java diff --git a/maxkey-core/src/main/java/org/maxkey/util/BeanConvert.java b/maxkey-common/src/main/java/org/maxkey/util/BeanConvert.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/util/BeanConvert.java rename to maxkey-common/src/main/java/org/maxkey/util/BeanConvert.java diff --git a/maxkey-core/src/main/java/org/maxkey/util/BeanUtil.java b/maxkey-common/src/main/java/org/maxkey/util/BeanUtil.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/util/BeanUtil.java rename to maxkey-common/src/main/java/org/maxkey/util/BeanUtil.java diff --git a/maxkey-core/src/main/java/org/maxkey/util/DateUtils.java b/maxkey-common/src/main/java/org/maxkey/util/DateUtils.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/util/DateUtils.java rename to maxkey-common/src/main/java/org/maxkey/util/DateUtils.java diff --git a/maxkey-core/src/main/java/org/maxkey/util/DynaBean.java b/maxkey-common/src/main/java/org/maxkey/util/DynaBean.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/util/DynaBean.java rename to maxkey-common/src/main/java/org/maxkey/util/DynaBean.java diff --git a/maxkey-core/src/main/java/org/maxkey/util/EthernetAddress.java b/maxkey-common/src/main/java/org/maxkey/util/EthernetAddress.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/util/EthernetAddress.java rename to maxkey-common/src/main/java/org/maxkey/util/EthernetAddress.java diff --git a/maxkey-core/src/main/java/org/maxkey/util/HttpEncoder.java b/maxkey-common/src/main/java/org/maxkey/util/HttpEncoder.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/util/HttpEncoder.java rename to maxkey-common/src/main/java/org/maxkey/util/HttpEncoder.java diff --git a/maxkey-core/src/main/java/org/maxkey/util/HttpsTrusts.java b/maxkey-common/src/main/java/org/maxkey/util/HttpsTrusts.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/util/HttpsTrusts.java rename to maxkey-common/src/main/java/org/maxkey/util/HttpsTrusts.java diff --git a/maxkey-core/src/main/java/org/maxkey/util/IdSequence.java b/maxkey-common/src/main/java/org/maxkey/util/IdSequence.java similarity index 92% rename from maxkey-core/src/main/java/org/maxkey/util/IdSequence.java rename to maxkey-common/src/main/java/org/maxkey/util/IdSequence.java index 12bdb998e..99e6e6a02 100644 --- a/maxkey-core/src/main/java/org/maxkey/util/IdSequence.java +++ b/maxkey-common/src/main/java/org/maxkey/util/IdSequence.java @@ -21,8 +21,6 @@ package org.maxkey.util; import java.util.Date; - -import org.maxkey.web.WebContext; import org.slf4j.LoggerFactory; /** @@ -69,11 +67,11 @@ public class IdSequence { return sequenceNumber.toString(); } - public static final String getNodeNumber(){ + public static final String initNodeNumber(String nodeNumbers){ if(STATIC_NODE_NUMBER.equals("--")){ - if(null!=WebContext.getAttribute("config.node.number")&&!WebContext.getAttribute("config.node.number").equals("")){ + if(null!=nodeNumbers&&!nodeNumbers.equals("")){ - String ipAddressConfigValue=WebContext.getAttribute("config.node.number").toString(); + String ipAddressConfigValue=nodeNumbers; LoggerFactory.getLogger(IdSequence.class).info("ARE config.node.number : "+ipAddressConfigValue); if(ipAddressConfigValue.indexOf(",")>-1){ @@ -95,7 +93,7 @@ public class IdSequence { } }else{ - STATIC_NODE_NUMBER=WebContext.getAttribute("config.node.number").toString(); + STATIC_NODE_NUMBER=nodeNumbers; } LoggerFactory.getLogger(IdSequence.class).info("STATIC_NODE_SEQUENCE_NUMBER : "+STATIC_NODE_NUMBER); if(STATIC_NODE_NUMBER.length()!=2){ @@ -107,6 +105,10 @@ public class IdSequence { } return STATIC_NODE_NUMBER; } + + public static final String getNodeNumber(){ + return STATIC_NODE_NUMBER; + } /** * 同一时刻只有一个访问 * @return diff --git a/maxkey-core/src/main/java/org/maxkey/util/Instance.java b/maxkey-common/src/main/java/org/maxkey/util/Instance.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/util/Instance.java rename to maxkey-common/src/main/java/org/maxkey/util/Instance.java diff --git a/maxkey-core/src/main/java/org/maxkey/util/JsonUtils.java b/maxkey-common/src/main/java/org/maxkey/util/JsonUtils.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/util/JsonUtils.java rename to maxkey-common/src/main/java/org/maxkey/util/JsonUtils.java diff --git a/maxkey-core/src/main/java/org/maxkey/util/MacAddress.java b/maxkey-common/src/main/java/org/maxkey/util/MacAddress.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/util/MacAddress.java rename to maxkey-common/src/main/java/org/maxkey/util/MacAddress.java diff --git a/maxkey-core/src/main/java/org/maxkey/util/MethodInvoke.java b/maxkey-common/src/main/java/org/maxkey/util/MethodInvoke.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/util/MethodInvoke.java rename to maxkey-common/src/main/java/org/maxkey/util/MethodInvoke.java diff --git a/maxkey-core/src/main/java/org/maxkey/util/ObjectTransformer.java b/maxkey-common/src/main/java/org/maxkey/util/ObjectTransformer.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/util/ObjectTransformer.java rename to maxkey-common/src/main/java/org/maxkey/util/ObjectTransformer.java diff --git a/maxkey-core/src/main/java/org/maxkey/util/PathUtils.java b/maxkey-common/src/main/java/org/maxkey/util/PathUtils.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/util/PathUtils.java rename to maxkey-common/src/main/java/org/maxkey/util/PathUtils.java diff --git a/maxkey-core/src/main/java/org/maxkey/util/QRCode.java b/maxkey-common/src/main/java/org/maxkey/util/QRCode.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/util/QRCode.java rename to maxkey-common/src/main/java/org/maxkey/util/QRCode.java diff --git a/maxkey-core/src/main/java/org/maxkey/util/QRCodeConfig.java b/maxkey-common/src/main/java/org/maxkey/util/QRCodeConfig.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/util/QRCodeConfig.java rename to maxkey-common/src/main/java/org/maxkey/util/QRCodeConfig.java diff --git a/maxkey-core/src/main/java/org/maxkey/util/RQCodeUtils.java b/maxkey-common/src/main/java/org/maxkey/util/RQCodeUtils.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/util/RQCodeUtils.java rename to maxkey-common/src/main/java/org/maxkey/util/RQCodeUtils.java diff --git a/maxkey-core/src/main/java/org/maxkey/util/SerializationUtils.java b/maxkey-common/src/main/java/org/maxkey/util/SerializationUtils.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/util/SerializationUtils.java rename to maxkey-common/src/main/java/org/maxkey/util/SerializationUtils.java diff --git a/maxkey-core/src/main/java/org/maxkey/util/StringGenerator.java b/maxkey-common/src/main/java/org/maxkey/util/StringGenerator.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/util/StringGenerator.java rename to maxkey-common/src/main/java/org/maxkey/util/StringGenerator.java diff --git a/maxkey-core/src/main/java/org/maxkey/util/StringUtils.java b/maxkey-common/src/main/java/org/maxkey/util/StringUtils.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/util/StringUtils.java rename to maxkey-common/src/main/java/org/maxkey/util/StringUtils.java diff --git a/maxkey-core/src/main/java/org/maxkey/util/UUIDGenerator.java b/maxkey-common/src/main/java/org/maxkey/util/UUIDGenerator.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/util/UUIDGenerator.java rename to maxkey-common/src/main/java/org/maxkey/util/UUIDGenerator.java diff --git a/maxkey-core/src/main/java/org/maxkey/uuid/NodeIDGetter.java b/maxkey-common/src/main/java/org/maxkey/uuid/NodeIDGetter.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/uuid/NodeIDGetter.java rename to maxkey-common/src/main/java/org/maxkey/uuid/NodeIDGetter.java diff --git a/maxkey-core/src/main/java/org/maxkey/uuid/TimestampUUIDGenerator.java b/maxkey-common/src/main/java/org/maxkey/uuid/TimestampUUIDGenerator.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/uuid/TimestampUUIDGenerator.java rename to maxkey-common/src/main/java/org/maxkey/uuid/TimestampUUIDGenerator.java diff --git a/maxkey-core/src/main/java/org/maxkey/uuid/UUID.java b/maxkey-common/src/main/java/org/maxkey/uuid/UUID.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/uuid/UUID.java rename to maxkey-common/src/main/java/org/maxkey/uuid/UUID.java diff --git a/maxkey-core/src/main/java/org/maxkey/uuid/UUIDGenerator.java b/maxkey-common/src/main/java/org/maxkey/uuid/UUIDGenerator.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/uuid/UUIDGenerator.java rename to maxkey-common/src/main/java/org/maxkey/uuid/UUIDGenerator.java diff --git a/maxkey-core/src/main/java/org/maxkey/uuid/UUIDRandomness.java b/maxkey-common/src/main/java/org/maxkey/uuid/UUIDRandomness.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/uuid/UUIDRandomness.java rename to maxkey-common/src/main/java/org/maxkey/uuid/UUIDRandomness.java diff --git a/maxkey-core/src/main/java/org/maxkey/uuid/UnsynchronizedTimestampUUIDGenerator.java b/maxkey-common/src/main/java/org/maxkey/uuid/UnsynchronizedTimestampUUIDGenerator.java similarity index 100% rename from maxkey-core/src/main/java/org/maxkey/uuid/UnsynchronizedTimestampUUIDGenerator.java rename to maxkey-common/src/main/java/org/maxkey/uuid/UnsynchronizedTimestampUUIDGenerator.java diff --git a/maxkey-common/src/main/resources/messages/passwordpolicy_message.properties b/maxkey-common/src/main/resources/messages/passwordpolicy_message.properties new file mode 100644 index 000000000..ac8f2f772 --- /dev/null +++ b/maxkey-common/src/main/resources/messages/passwordpolicy_message.properties @@ -0,0 +1,48 @@ +#password +PasswordPolicy.HISTORY_VIOLATION=\u5bc6\u7801\u5339\u914d\u4e86{0}\u5386\u53f2\u5bc6\u7801. +PasswordPolicy.ILLEGAL_WORD=\u5bc6\u7801\u5305\u542b\u5728\u5bc6\u7801\u5b57\u5178{0}. +PasswordPolicy.ILLEGAL_WORD_REVERSED=\u5bc6\u7801\u5305\u542b\u5728\u5bc6\u7801\u5b57\u5178\u5012\u5e8f{0}. +PasswordPolicy.ILLEGAL_DIGEST_WORD=\u5bc6\u7801\u5305\u542b\u5728\u5b57\u5178\u4e2d. +PasswordPolicy.ILLEGAL_DIGEST_WORD_REVERSED=\u5bc6\u7801\u5305\u542b\u5728\u5b57\u5178\u5012\u5e8f\u4e2d. +PasswordPolicy.ILLEGAL_MATCH=\u5bc6\u7801\u5339\u914d\u975e\u6cd5\u89c4\u5219{0}. +PasswordPolicy.ALLOWED_MATCH=\u5bc6\u7801\u5fc5\u987b\u5339\u914d\u89c4\u5219{0}. +PasswordPolicy.ILLEGAL_CHAR=\u5bc6\u7801{1}\u5305\u542b\u975e\u6cd5\u5b57\u7b26{0}. +PasswordPolicy.ALLOWED_CHAR=\u5bc6\u7801{1}\u975e\u6cd5\u5b57\u7b26{0}. +PasswordPolicy.ILLEGAL_QWERTY_SEQUENCE=\u5bc6\u7801\u5305\u542b\u952e\u76d8\u5e8f\u5217{0}. +PasswordPolicy.ILLEGAL_ALPHABETICAL_SEQUENCE=\u5bc6\u7801\u5305\u542b\u5b57\u7b26\u5e8f\u5217{0}. +PasswordPolicy.ILLEGAL_NUMERICAL_SEQUENCE=\u5bc6\u7801\u5305\u542b\u6570\u5b57\u5e8f\u5217{0}. +PasswordPolicy.ILLEGAL_USERNAME=\u5bc6\u7801\u4e0d\u80fd\u5305\u542b\u767b\u5f55\u540d{0}. +PasswordPolicy.ILLEGAL_USERNAME_REVERSED=\u5bc6\u7801{1} \u5305\u542b\u767b\u5f55\u540d{0}\u5012\u5e8f. +PasswordPolicy.ILLEGAL_WHITESPACE=\u5bc6\u7801{1}\u5305\u542b\u7a7a\u683c. +PasswordPolicy.ILLEGAL_NUMBER_RANGE=\u5bc6\u7801{1}\u6570\u5b57 {0}. +PasswordPolicy.ILLEGAL_REPEATED_CHARS=\u5bc6\u7801{2}\u5e8f\u5217{0}\u6216\u8005\u591a\u4e2a\u5b57\u7b26, \u4f46{1}\u5141\u8bb8:{3}\u6b21. +PasswordPolicy.INSUFFICIENT_UPPERCASE=\u5bc6\u7801\u81f3\u5c11\u5305\u542b{0}\u4f4d\u5927\u5199\u5b57\u6bcd. +PasswordPolicy.INSUFFICIENT_LOWERCASE=\u5bc6\u7801\u81f3\u5c11\u5305\u542b{0}\u4f4d\u5c0f\u5199\u5b57\u6bcd. +PasswordPolicy.INSUFFICIENT_ALPHABETICAL=\u5bc6\u7801\u5305\u542b\u5b57\u7b26\u5e8f\u5217{0}. +PasswordPolicy.INSUFFICIENT_DIGIT=\u5bc6\u7801\u81f3\u5c11\u5305\u542b{0}\u4f4d\u6570\u5b57\u5b57\u6bcd. +PasswordPolicy.INSUFFICIENT_SPECIAL=\u5bc6\u7801\u81f3\u5c11\u5305\u542b{0}\u4f4d\u7279\u6b8a\u5b57\u7b26. +PasswordPolicy.INSUFFICIENT_CHARACTERISTICS=\u5bc6\u7801\u5339\u914d {0} of{2}\u5b57\u7b26\u89c4\u5219, \u4f46{1} \u5fc5\u987b. +PasswordPolicy.INSUFFICIENT_COMPLEXITY=\u5bc6\u7801\u9047\u5230{1}\u590d\u6742\u89c4\u5219, \u4f46{2}\u5fc5\u987b. +PasswordPolicy.INSUFFICIENT_COMPLEXITY_RULES=\u6ca1\u6709\u914d\u7f6e\u5bc6\u7801\u957f\u5ea6\u89c4\u5219 {0}. +PasswordPolicy.SOURCE_VIOLATION=\u5bc6\u7801\u4e0d\u80fd\u5305\u542b{0}\u5bc6\u7801. +PasswordPolicy.TOO_LONG=\u5bc6\u7801\u6700\u591a{1}\u4f4d\u5b57\u7b26. +PasswordPolicy.TOO_SHORT=\u5bc6\u7801\u81f3\u5c11{0}\u4f4d\u5b57\u7b26. +PasswordPolicy.TOO_MANY_OCCURRENCES=\u5bc6\u7801\u5305\u542b{0}\u51fa\u73b0{1}, \u6700\u591a{2} \u6b21. +PasswordPolicy.OLD_PASSWORD_NOT_MATCH=\u539f\u5bc6\u7801\u4e0d\u5339\u914d. +PasswordPolicy.CONFIRMPASSWORD_NOT_MATCH=\u65b0\u5bc6\u7801\u4e0e\u786e\u8ba4\u5bc6\u7801\u4e0d\u4e00\u81f4. +PasswordPolicy.OLD_PASSWORD_MATCH=\u65b0\u5bc6\u7801\u4e0d\u80fd\u4e0e\u65e7\u5bc6\u7801\u4e00\u81f4. + +#\u7528\u6237\u767b\u5f55\u9519\u8bef\u63d0\u9192 +login.error.attempts={0}\u5c1d\u8bd5\u767b\u9646{1}\u6b21\u6570\u8fbe\u5230\u6700\u5927\u9650\u5236\uff0c\u8bf7\u7a0d\u540e\u518d\u767b\u9646. +login.error.locked=\u7528\u6237\u88ab\u9501\u5b9a. +login.error.inactive=\u7528\u6237\u975e\u6d3b\u52a8\u72b6\u6001. +login.error.password=\u767b\u5f55\u5bc6\u7801\u65e0\u6548. +login.error.username=\u7528\u6237\u540d\u65e0\u6548. +login.error.username.null=\u7528\u6237\u540d\u4e0d\u80fd\u4e3a\u7a7a. +login.error.email.null=\u767b\u5f55\u90ae\u7bb1\u4e0d\u80fd\u4e3a\u7a7a. +login.error.password.null=\u5bc6\u7801\u4e0d\u80fd\u4e3a\u7a7a. +login.error.captcha=\u9a8c\u8bc1\u7801\u9519\u8bef\uff0c\u8bf7\u91cd\u65b0\u767b\u9646. +login.error.authtype=\u767b\u5f55\u8ba4\u8bc1\u7c7b\u578b\u9519\u8bef. +login.error.session=\u767b\u5f55\u4f1a\u8bdd\u5931\u6548\uff0c\u8bf7\u91cd\u65b0\u767b\u9646. +login.error.social=\u793e\u4ea4\u8d26\u53f7\u6388\u6743\u5931\u8d25\uff0c\u8bf7\u91cd\u8bd5. + diff --git a/maxkey-common/src/main/resources/messages/passwordpolicy_message_en.properties b/maxkey-common/src/main/resources/messages/passwordpolicy_message_en.properties new file mode 100644 index 000000000..914463a39 --- /dev/null +++ b/maxkey-common/src/main/resources/messages/passwordpolicy_message_en.properties @@ -0,0 +1,47 @@ +#password +PasswordPolicy.HISTORY_VIOLATION=Password matches one of {0} previous passwords. +PasswordPolicy.ILLEGAL_WORD=Password contains the dictionary word {0}. +PasswordPolicy.ILLEGAL_WORD_REVERSED=Password contains the reversed dictionary word {0}. +PasswordPolicy.ILLEGAL_DIGEST_WORD=Password contains a dictionary word. +PasswordPolicy.ILLEGAL_DIGEST_WORD_REVERSED=Password contains a reversed dictionary word. +PasswordPolicy.ILLEGAL_MATCH=Password matches the illegal pattern {0}. +PasswordPolicy.ALLOWED_MATCH=Password must match pattern {0}. +PasswordPolicy.ILLEGAL_CHAR=Password {1} the illegal character {0}. +PasswordPolicy.ALLOWED_CHAR=Password {1} the illegal character {0}. +PasswordPolicy.ILLEGAL_QWERTY_SEQUENCE=Password contains the illegal QWERTY sequence {0}. +PasswordPolicy.ILLEGAL_ALPHABETICAL_SEQUENCE=Password contains the illegal alphabetical sequence {0}. +PasswordPolicy.ILLEGAL_NUMERICAL_SEQUENCE=Password contains the illegal numerical sequence {0}. +PasswordPolicy.ILLEGAL_USERNAME=Password {1} the user id {0}. +PasswordPolicy.ILLEGAL_USERNAME_REVERSED=Password {1} the user id {0} in reverse. +PasswordPolicy.ILLEGAL_WHITESPACE=Password {1} a whitespace character. +PasswordPolicy.ILLEGAL_NUMBER_RANGE=Password {1} the number {0}. +PasswordPolicy.ILLEGAL_REPEATED_CHARS=Password contains {2} sequences of {0} or more repeated characters, but only {1} allowed: {3}. +PasswordPolicy.INSUFFICIENT_UPPERCASE=Password must contain {0} or more uppercase characters. +PasswordPolicy.INSUFFICIENT_LOWERCASE=Password must contain {0} or more lowercase characters. +PasswordPolicy.INSUFFICIENT_ALPHABETICAL=Password must contain {0} or more alphabetical characters. +PasswordPolicy.INSUFFICIENT_DIGIT=Password must contain {0} or more digit characters. +PasswordPolicy.INSUFFICIENT_SPECIAL=Password must contain {0} or more special characters. +PasswordPolicy.INSUFFICIENT_CHARACTERISTICS=Password matches {0} of {2} character rules, but {1} are required. +PasswordPolicy.INSUFFICIENT_COMPLEXITY=Password meets {1} complexity rules, but {2} are required. +PasswordPolicy.INSUFFICIENT_COMPLEXITY_RULES=No rules have been configured for a password of length {0}. +PasswordPolicy.SOURCE_VIOLATION=Password cannot be the same as your {0} password. +PasswordPolicy.TOO_LONG=Password must be no more than {1} characters in length. +PasswordPolicy.TOO_SHORT=Password must be {0} or more characters in length . +PasswordPolicy.TOO_MANY_OCCURRENCES=Password contains {1} occurrences of the character {0}, but at most {2} are allowed. +PasswordPolicy.OLD_PASSWORD_NOT_MATCH=old password not match. +PasswordPolicy.CONFIRMPASSWORD_NOT_MATCH=new password not match confirm password. +PasswordPolicy.OLD_PASSWORD_MATCH=new password match old password. + +#for user login +login.error.attempts={0} login attempts the maximum number of {1} times, please login later. +login.error.locked=The user is locked. +login.error.inactive=User inactive state. +login.error.password=Invalid password. +login.error.username=Invalid username. +login.error.username.null=username cannot be empty. +login.error.email.null=email cannot be empty. +login.error.password.null=Password cannot be empty. +login.error.captcha=Verification code error, please login again. +login.error.authtype=Login authentication type error. +login.error.session=Login session failed. please login again. +login.error.social=Social login failed. please retry. \ No newline at end of file diff --git a/maxkey-common/src/main/resources/messages/passwordpolicy_message_zh_CN.properties b/maxkey-common/src/main/resources/messages/passwordpolicy_message_zh_CN.properties new file mode 100644 index 000000000..d90d52b63 --- /dev/null +++ b/maxkey-common/src/main/resources/messages/passwordpolicy_message_zh_CN.properties @@ -0,0 +1,47 @@ +#password +PasswordPolicy.HISTORY_VIOLATION=\u5bc6\u7801\u5339\u914d\u4e86{0}\u5386\u53f2\u5bc6\u7801. +PasswordPolicy.ILLEGAL_WORD=\u5bc6\u7801\u5305\u542b\u5728\u5bc6\u7801\u5b57\u5178{0}. +PasswordPolicy.ILLEGAL_WORD_REVERSED=\u5bc6\u7801\u5305\u542b\u5728\u5bc6\u7801\u5b57\u5178\u5012\u5e8f{0}. +PasswordPolicy.ILLEGAL_DIGEST_WORD=\u5bc6\u7801\u5305\u542b\u5728\u5b57\u5178\u4e2d. +PasswordPolicy.ILLEGAL_DIGEST_WORD_REVERSED=\u5bc6\u7801\u5305\u542b\u5728\u5b57\u5178\u5012\u5e8f\u4e2d. +PasswordPolicy.ILLEGAL_MATCH=\u5bc6\u7801\u5339\u914d\u975e\u6cd5\u89c4\u5219{0}. +PasswordPolicy.ALLOWED_MATCH=\u5bc6\u7801\u5fc5\u987b\u5339\u914d\u89c4\u5219{0}. +PasswordPolicy.ILLEGAL_CHAR=\u5bc6\u7801{1}\u5305\u542b\u975e\u6cd5\u5b57\u7b26{0}. +PasswordPolicy.ALLOWED_CHAR=\u5bc6\u7801{1}\u975e\u6cd5\u5b57\u7b26{0}. +PasswordPolicy.ILLEGAL_QWERTY_SEQUENCE=\u5bc6\u7801\u5305\u542b\u952e\u76d8\u5e8f\u5217{0}. +PasswordPolicy.ILLEGAL_ALPHABETICAL_SEQUENCE=\u5bc6\u7801\u5305\u542b\u5b57\u7b26\u5e8f\u5217{0}. +PasswordPolicy.ILLEGAL_NUMERICAL_SEQUENCE=\u5bc6\u7801\u5305\u542b\u6570\u5b57\u5e8f\u5217{0}. +PasswordPolicy.ILLEGAL_USERNAME=\u5bc6\u7801\u4e0d\u80fd\u5305\u542b\u767b\u5f55\u540d{0}. +PasswordPolicy.ILLEGAL_USERNAME_REVERSED=\u5bc6\u7801{1} \u5305\u542b\u767b\u5f55\u540d{0}\u5012\u5e8f. +PasswordPolicy.ILLEGAL_WHITESPACE=\u5bc6\u7801{1}\u5305\u542b\u7a7a\u683c. +PasswordPolicy.ILLEGAL_NUMBER_RANGE=\u5bc6\u7801{1}\u6570\u5b57 {0}. +PasswordPolicy.ILLEGAL_REPEATED_CHARS=\u5bc6\u7801{2}\u5e8f\u5217{0}\u6216\u8005\u591a\u4e2a\u5b57\u7b26, \u4f46{1}\u5141\u8bb8:{3}\u6b21. +PasswordPolicy.INSUFFICIENT_UPPERCASE=\u5bc6\u7801\u81f3\u5c11\u5305\u542b{0}\u4f4d\u5927\u5199\u5b57\u6bcd. +PasswordPolicy.INSUFFICIENT_LOWERCASE=\u5bc6\u7801\u81f3\u5c11\u5305\u542b{0}\u4f4d\u5c0f\u5199\u5b57\u6bcd. +PasswordPolicy.INSUFFICIENT_ALPHABETICAL=\u5bc6\u7801\u5305\u542b\u5b57\u7b26\u5e8f\u5217{0}. +PasswordPolicy.INSUFFICIENT_DIGIT=\u5bc6\u7801\u81f3\u5c11\u5305\u542b{0}\u4f4d\u6570\u5b57\u5b57\u6bcd. +PasswordPolicy.INSUFFICIENT_SPECIAL=\u5bc6\u7801\u81f3\u5c11\u5305\u542b{0}\u4f4d\u7279\u6b8a\u5b57\u7b26. +PasswordPolicy.INSUFFICIENT_CHARACTERISTICS=\u5bc6\u7801\u5339\u914d {0} of{2}\u5b57\u7b26\u89c4\u5219, \u4f46{1} \u5fc5\u987b. +PasswordPolicy.INSUFFICIENT_COMPLEXITY=\u5bc6\u7801\u9047\u5230{1}\u590d\u6742\u89c4\u5219, \u4f46{2}\u5fc5\u987b. +PasswordPolicy.INSUFFICIENT_COMPLEXITY_RULES=\u6ca1\u6709\u914d\u7f6e\u5bc6\u7801\u957f\u5ea6\u89c4\u5219 {0}. +PasswordPolicy.SOURCE_VIOLATION=\u5bc6\u7801\u4e0d\u80fd\u5305\u542b{0}\u5bc6\u7801. +PasswordPolicy.TOO_LONG=\u5bc6\u7801\u6700\u591a{1}\u4f4d\u5b57\u7b26. +PasswordPolicy.TOO_SHORT=\u5bc6\u7801\u81f3\u5c11{0}\u4f4d\u5b57\u7b26. +PasswordPolicy.TOO_MANY_OCCURRENCES=\u5bc6\u7801\u5305\u542b{0}\u51fa\u73b0{1}, \u6700\u591a{2} \u6b21. +PasswordPolicy.OLD_PASSWORD_NOT_MATCH=\u539f\u5bc6\u7801\u4e0d\u5339\u914d. +PasswordPolicy.CONFIRMPASSWORD_NOT_MATCH=\u65b0\u5bc6\u7801\u4e0e\u786e\u8ba4\u5bc6\u7801\u4e0d\u4e00\u81f4. +PasswordPolicy.OLD_PASSWORD_MATCH=\u65b0\u5bc6\u7801\u4e0d\u80fd\u4e0e\u65e7\u5bc6\u7801\u4e00\u81f4. + +#\u7528\u6237\u767b\u5f55\u9519\u8bef\u63d0\u9192 +login.error.attempts={0}\u5c1d\u8bd5\u767b\u9646{1}\u6b21\u6570\u8fbe\u5230\u6700\u5927\u9650\u5236\uff0c\u8bf7\u7a0d\u540e\u518d\u767b\u9646. +login.error.locked=\u7528\u6237\u88ab\u9501\u5b9a. +login.error.inactive=\u7528\u6237\u975e\u6d3b\u52a8\u72b6\u6001. +login.error.password=\u767b\u5f55\u5bc6\u7801\u65e0\u6548. +login.error.username=\u7528\u6237\u540d\u65e0\u6548. +login.error.username.null=\u7528\u6237\u540d\u4e0d\u80fd\u4e3a\u7a7a. +login.error.email.null=\u767b\u5f55\u90ae\u7bb1\u4e0d\u80fd\u4e3a\u7a7a. +login.error.password.null=\u5bc6\u7801\u4e0d\u80fd\u4e3a\u7a7a. +login.error.captcha=\u9a8c\u8bc1\u7801\u9519\u8bef\uff0c\u8bf7\u91cd\u65b0\u767b\u9646. +login.error.authtype=\u767b\u5f55\u8ba4\u8bc1\u7c7b\u578b\u9519\u8bef. +login.error.session=\u767b\u5f55\u4f1a\u8bdd\u5931\u6548\uff0c\u8bf7\u91cd\u65b0\u767b\u9646. +login.error.social=\u793e\u4ea4\u8d26\u53f7\u6388\u6743\u5931\u8d25\uff0c\u8bf7\u91cd\u8bd5. \ No newline at end of file diff --git a/maxkey-common/src/main/resources/org/maxkey/util/PathUtils.properties b/maxkey-common/src/main/resources/org/maxkey/util/PathUtils.properties new file mode 100644 index 000000000..c7292c84b --- /dev/null +++ b/maxkey-common/src/main/resources/org/maxkey/util/PathUtils.properties @@ -0,0 +1 @@ +org.maxkey.util.PathUtils \ No newline at end of file diff --git a/maxkey-common/src/main/resources/top_weak_password.txt b/maxkey-common/src/main/resources/top_weak_password.txt new file mode 100644 index 000000000..00abe43c4 --- /dev/null +++ b/maxkey-common/src/main/resources/top_weak_password.txt @@ -0,0 +1,1100 @@ +123456 +password +12345678 +qwerty +123456789 +12345 +1234 +111111 +1234567 +dragon +123123 +baseball +abc123 +football +monkey +letmein +696969 +shadow +master +666666 +qwertyuiop +123321 +mustang +1234567890 +michael +654321 +pussy +superman +1qaz2wsx +7777777 +fuckyou +121212 +000000 +qazwsx +123qwe +killer +trustno1 +jordan +jennifer +zxcvbnm +asdfgh +hunter +buster +soccer +harley +batman +andrew +tigger +sunshine +iloveyou +fuckme +2000 +charlie +robert +thomas +hockey +ranger +daniel +starwars +klaster +112233 +george +asshole +computer +michelle +jessica +pepper +1111 +zxcvbn +555555 +11111111 +131313 +freedom +777777 +pass +fuck +maggie +159753 +aaaaaa +ginger +princess +joshua +cheese +amanda +summer +love +ashley +6969 +nicole +chelsea +biteme +matthew +access +yankees +987654321 +dallas +austin +thunder +taylor +matrix +william +corvette +hello +martin +heather +secret +fucker +merlin +diamond +1234qwer +gfhjkm +hammer +silver +222222 +88888888 +anthony +justin +test +bailey +q1w2e3r4t5 +patrick +internet +scooter +orange +11111 +golfer +cookie +richard +samantha +bigdog +guitar +jackson +whatever +mickey +chicken +sparky +snoopy +maverick +phoenix +camaro +sexy +peanut +morgan +welcome +falcon +cowboy +ferrari +samsung +andrea +smokey +steelers +joseph +mercedes +dakota +arsenal +eagles +melissa +boomer +booboo +spider +nascar +monster +tigers +yellow +xxxxxx +123123123 +gateway +marina +diablo +bulldog +qwer1234 +compaq +purple +hardcore +banana +junior +hannah +123654 +porsche +lakers +iceman +money +cowboys +987654 +london +tennis +999999 +ncc1701 +coffee +scooby +0000 +miller +boston +q1w2e3r4 +fuckoff +brandon +yamaha +chester +mother +forever +johnny +edward +333333 +oliver +redsox +player +nikita +knight +fender +barney +midnight +please +brandy +chicago +badboy +iwantu +slayer +rangers +charles +angel +flower +bigdaddy +rabbit +wizard +bigdick +jasper +enter +rachel +chris +steven +winner +adidas +victoria +natasha +1q2w3e4r +jasmine +winter +prince +panties +marine +ghbdtn +fishing +cocacola +casper +james +232323 +raiders +888888 +marlboro +gandalf +asdfasdf +crystal +87654321 +12344321 +sexsex +golden +blowme +bigtits +8675309 +panther +lauren +angela +bitch +spanky +thx1138 +angels +madison +winston +shannon +mike +toyota +blowjob +jordan23 +canada +sophie +Password +apples +dick +tiger +razz +123abc +pokemon +qazxsw +55555 +qwaszx +muffin +johnson +murphy +cooper +jonathan +liverpoo +david +danielle +159357 +jackie +1990 +123456a +789456 +turtle +horny +abcd1234 +scorpion +qazwsxedc +101010 +butter +carlos +password1 +dennis +slipknot +qwerty123 +booger +asdf +1991 +black +startrek +12341234 +cameron +newyork +rainbow +nathan +john +1992 +rocket +viking +redskins +butthead +asdfghjkl +1212 +sierra +peaches +gemini +doctor +wilson +sandra +helpme +qwertyui +victor +florida +dolphin +pookie +captain +tucker +blue +liverpool +theman +bandit +dolphins +maddog +packers +jaguar +lovers +nicholas +united +tiffany +maxwell +zzzzzz +nirvana +jeremy +suckit +stupid +porn +monica +elephant +giants +jackass +hotdog +rosebud +success +debbie +mountain +444444 +xxxxxxxx +warrior +1q2w3e4r5t +q1w2e3 +123456q +albert +metallic +lucky +azerty +7777 +shithead +alex +bond007 +alexis +1111111 +samson +5150 +willie +scorpio +bonnie +gators +benjamin +voodoo +driver +dexter +2112 +jason +calvin +freddy +212121 +creative +12345a +sydney +rush2112 +1989 +asdfghjk +red123 +bubba +4815162342 +passw0rd +trouble +gunner +happy +fucking +gordon +legend +jessie +stella +qwert +eminem +arthur +apple +nissan +bullshit +bear +america +1qazxsw2 +nothing +parker +4444 +rebecca +qweqwe +garfield +01012011 +beavis +69696969 +jack +asdasd +december +2222 +102030 +252525 +11223344 +magic +apollo +skippy +315475 +girls +kitten +golf +copper +braves +shelby +godzilla +beaver +fred +tomcat +august +buddy +airborne +1993 +1988 +lifehack +qqqqqq +brooklyn +animal +platinum +phantom +online +xavier +darkness +blink182 +power +fish +green +789456123 +voyager +police +travis +12qwaszx +heaven +snowball +lover +abcdef +00000 +pakistan +007007 +walter +playboy +blazer +cricket +sniper +hooters +donkey +willow +loveme +saturn +therock +redwings +bigboy +pumpkin +trinity +williams +tits +nintendo +digital +destiny +topgun +runner +marvin +guinness +chance +bubbles +testing +fire +november +minecraft +asdf1234 +lasvegas +sergey +broncos +cartman +private +celtic +birdie +little +cassie +babygirl +donald +beatles +1313 +dickhead +family +12121212 +school +louise +gabriel +eclipse +fluffy +147258369 +lol123 +explorer +beer +nelson +flyers +spencer +scott +lovely +gibson +doggie +cherry +andrey +snickers +buffalo +pantera +metallica +member +carter +qwertyu +peter +alexande +steve +bronco +paradise +goober +5555 +samuel +montana +mexico +dreams +michigan +cock +carolina +yankee +friends +magnum +surfer +poopoo +maximus +genius +cool +vampire +lacrosse +asd123 +aaaa +christin +kimberly +speedy +sharon +carmen +111222 +kristina +sammy +racing +ou812 +sabrina +horses +0987654321 +qwerty1 +pimpin +baby +stalker +enigma +147147 +star +poohbear +boobies +147258 +simple +bollocks +12345q +marcus +brian +1987 +qweasdzxc +drowssap +hahaha +caroline +barbara +dave +viper +drummer +action +einstein +bitches +genesis +hello1 +scotty +friend +forest +010203 +hotrod +google +vanessa +spitfire +badger +maryjane +friday +alaska +1232323q +tester +jester +jake +champion +billy +147852 +rock +hawaii +badass +chevy +420420 +walker +stephen +eagle1 +bill +1986 +october +gregory +svetlana +pamela +1984 +music +shorty +westside +stanley +diesel +courtney +242424 +kevin +porno +hitman +boobs +mark +12345qwert +reddog +frank +qwe123 +popcorn +patricia +aaaaaaaa +1969 +teresa +mozart +buddha +anderson +paul +melanie +abcdefg +security +lucky1 +lizard +denise +3333 +a12345 +123789 +ruslan +stargate +simpsons +scarface +eagle +123456789a +thumper +olivia +naruto +1234554321 +general +cherokee +a123456 +vincent +Usuckballz1 +spooky +qweasd +cumshot +free +frankie +douglas +death +1980 +loveyou +kitty +kelly +veronica +suzuki +semperfi +penguin +mercury +liberty +spirit +scotland +natalie +marley +vikings +system +sucker +king +allison +marshall +1979 +098765 +qwerty12 +hummer +adrian +1985 +vfhbyf +sandman +rocky +leslie +antonio +98765432 +4321 +softball +passion +mnbvcxz +bastard +passport +horney +rascal +howard +franklin +bigred +assman +alexander +homer +redrum +jupiter +claudia +55555555 +141414 +zaq12wsx +shit +patches +nigger +cunt +raider +infinity +andre +54321 +galore +college +russia +kawasaki +bishop +77777777 +vladimir +money1 +freeuser +wildcats +francis +disney +budlight +brittany +1994 +00000000 +sweet +oksana +honda +domino +bulldogs +brutus +swordfis +norman +monday +jimmy +ironman +ford +fantasy +9999 +7654321 +PASSWORD +hentai +duncan +cougar +1977 +jeffrey +house +dancer +brooke +timothy +super +marines +justice +digger +connor +patriots +karina +202020 +molly +everton +tinker +alicia +rasdzv3 +poop +pearljam +stinky +naughty +colorado +123123a +water +test123 +ncc1701d +motorola +ireland +asdfg +slut +matt +houston +boogie +zombie +accord +vision +bradley +reggie +kermit +froggy +ducati +avalon +6666 +9379992 +sarah +saints +logitech +chopper +852456 +simpson +madonna +juventus +claire +159951 +zachary +yfnfif +wolverin +warcraft +hello123 +extreme +penis +peekaboo +fireman +eugene +brenda +123654789 +russell +panthers +georgia +smith +skyline +jesus +elizabet +spiderma +smooth +pirate +empire +bullet +8888 +virginia +valentin +psycho +predator +arizona +134679 +mitchell +alyssa +vegeta +titanic +christ +goblue +fylhtq +wolf +mmmmmm +kirill +indian +hiphop +baxter +awesome +people +danger +roland +mookie +741852963 +1111111111 +dreamer +bambam +arnold +1981 +skipper +serega +rolltide +elvis +changeme +simon +1q2w3e +lovelove +fktrcfylh +denver +tommy +mine +loverboy +hobbes +happy1 +alison +nemesis +chevelle +cardinal +burton +wanker +picard +151515 +tweety +michael1 +147852369 +12312 +xxxx +windows +turkey +456789 +1974 +vfrcbv +sublime +1975 +galina +bobby +newport +manutd +daddy +american +alexandr +1966 +victory +rooster +qqq111 +madmax +electric +bigcock +a1b2c3 +wolfpack +spring +phpbb +lalala +suckme +spiderman +eric +darkside +classic +raptor +123456789q +hendrix +1982 +wombat +avatar +alpha +zxc123 +crazy +hard +england +brazil +1978 +01011980 +wildcat +polina +freepass +123456789 +a123456 +123456 +a123456789 +1234567890 +woaini1314 +qq123456 +abc123456 +123456a +123456789a +147258369 +zxcvbnm +987654321 +12345678910 +abc123 +qq123456789 +123456789. +7708801314520 +woaini +5201314520 +q123456 +123456abc +1233211234567 +123123123 +123456. +0123456789 +asd123456 +aa123456 +135792468 +q123456789 +abcd123456 +12345678900 +woaini520 +woaini123 +zxcvbnm123 +1111111111111111 +w123456 +aini1314 +abc123456789 +111111 +woaini521 +qwertyuiop +1314520520 +1234567891 +qwe123456 +asd123 +000000 +1472583690 +1357924680 +789456123 +123456789abc +z123456 +1234567899 +aaa123456 +abcd1234 +www123456 +123456789q +123abc +qwe123 +w123456789 +7894561230 +123456qq +zxc123456 +123456789qq +1111111111 +111111111 +0000000000000000 +1234567891234567 +qazwsxedc +qwerty +123456.. +zxc123 +asdfghjkl +0000000000 +1234554321 +123456q +123456aa +9876543210 +110120119 +qaz123456 +qq5201314 +123698745 +5201314 +000000000 +as123456 +123123 +5841314520 +z123456789 +52013145201314 +a123123 +caonima +a5201314 +wang123456 +abcd123 +123456789.. +woaini1314520 +123456asd +aa123456789 +741852963 +a12345678 \ No newline at end of file diff --git a/maxkey-common/src/test/java/org/maxkey/Copyright.java b/maxkey-common/src/test/java/org/maxkey/Copyright.java new file mode 100644 index 000000000..4d09056cf --- /dev/null +++ b/maxkey-common/src/test/java/org/maxkey/Copyright.java @@ -0,0 +1,166 @@ +/* + * 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; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; + +/** + * 给java文件批量添加License信息. + * @author MaxKey Copyright Adder + * + */ +public class Copyright { + // 存放java文件的文件夹,必须是文件夹 + private static String srcFolder = "C:\\IDES\\shimi\\eclipse-workspace\\MaxKey"; + //已添加标识 + private static String copyRightText = "http://www.apache.org/licenses/LICENSE-2.0"; + //扫描目录 + private String folder; + //版权信息 + private String copyRight; + //待添加所以文件统计 + private long fileCount = 0; + //添加的问题就统计 + private long copyRightFileCount = 0; + private static String lineSeperator = System.getProperty("line.separator"); + private static String encode = "UTF-8"; + + /** + * Copyright. + * @param folder java文件夹. + * @param copyRight 版权内容. + */ + public Copyright(String folder, String copyRight) { + this.folder = folder; + this.copyRight = copyRight; + } + + /** + * main . + * @param args String + * @throws IOException IOException + */ + public static void main(String[] args) throws IOException { + // 从文件读取版权内容 + // 在D盘创建一个copyright.txt文件,把版权内容放进去即可 + String copyright = readCopyrightFromFile( + Copyright.class.getResource("copyright.txt").getFile()); + new Copyright(srcFolder, copyright).process(); + + + } + + /** + * process. + * @throws IOException not + */ + public void process() throws IOException { + this.addCopyright(new File(folder)); + System.out.println("fileCount " + fileCount); + System.out.println("copyRightFileCount " + copyRightFileCount); + } + + private void addCopyright(File folder) throws IOException { + File[] files = folder.listFiles(); + + if (files == null || files.length == 0) { + return; + } + + for (File f : files) { + if (f.isFile()) { + doAddCopyright(f); + } else { + addCopyright(f); + } + } + } + + private void doAddCopyright(File file) throws IOException { + String fileName = file.getName(); + boolean isJavaFile = fileName.toLowerCase().endsWith(".java"); + this.fileCount++; + if (isJavaFile && !isAddCopyrightFile(file.getAbsolutePath())) { + copyRightFileCount++; + System.out.println(file.getAbsolutePath()); + try { + this.doWrite(file); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + private void doWrite(File file) throws IOException { + StringBuilder javaFileContent = new StringBuilder(); + String line = null; + // 先添加copyright到文件头 + javaFileContent.append(copyRight).append(lineSeperator); + // 追加剩余内容 + BufferedReader br = new BufferedReader( + new InputStreamReader(new FileInputStream(file), encode)); + while ((line = br.readLine()) != null) { + javaFileContent.append(line).append(lineSeperator); + } + + OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(file), encode); + writer.write(javaFileContent.toString()); + writer.close(); + br.close(); + } + + private static String readCopyrightFromFile(String copyFilePath) throws IOException { + StringBuilder copyright = new StringBuilder(); + + String line = null; + + BufferedReader br = new BufferedReader( + new InputStreamReader(new FileInputStream(copyFilePath), encode)); + + while ((line = br.readLine()) != null) { + copyright.append(line).append(lineSeperator); + } + br.close(); + + return copyright.toString(); + } + + private static boolean isAddCopyrightFile(String filePath) throws IOException { + boolean isAddCopyright = false; + String line = null; + + BufferedReader br = new BufferedReader( + new InputStreamReader(new FileInputStream(filePath), encode)); + + while ((line = br.readLine()) != null) { + if (line.indexOf(copyRightText) > -1) { + isAddCopyright = true; + break; + } + } + br.close(); + + return isAddCopyright; + } + +} \ No newline at end of file diff --git a/maxkey-common/src/test/java/org/maxkey/cache/CacheFactoryTest.java b/maxkey-common/src/test/java/org/maxkey/cache/CacheFactoryTest.java new file mode 100644 index 000000000..ba6c3d917 --- /dev/null +++ b/maxkey-common/src/test/java/org/maxkey/cache/CacheFactoryTest.java @@ -0,0 +1,54 @@ +/* + * 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.cache; + +import java.util.ArrayList; + +import org.maxkey.cache.AbstractCache; +import org.maxkey.cache.CacheFactory; + +/** + * @author amarsoft + * + */ +public class CacheFactoryTest { + + /** + * + */ + public CacheFactoryTest() { + // TODO Auto-generated constructor stub + } + + /** + * @param args + */ + public static void main(String[] args) { + // TODO Auto-generated method stub + RandomCache randomCache=new RandomCache(); + ArrayList cacheList=new ArrayList(); + cacheList.add(randomCache); + CacheFactory cacheFactory=new CacheFactory(); + cacheFactory.setCache(cacheList); + cacheFactory.start(); + } + +} diff --git a/maxkey-common/src/test/java/org/maxkey/cache/RandomCache.java b/maxkey-common/src/test/java/org/maxkey/cache/RandomCache.java new file mode 100644 index 000000000..5077d11ef --- /dev/null +++ b/maxkey-common/src/test/java/org/maxkey/cache/RandomCache.java @@ -0,0 +1,73 @@ +/* + * 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.cache; + +import java.util.Random; + +import org.maxkey.cache.AbstractCache; + +/** + * @author amarsoft + * + */ +public class RandomCache extends AbstractCache { + java.util.Random random=new Random(); + + int i; + + /** + * + */ + public RandomCache() { + // TODO Auto-generated constructor stub + this.setInterval(5); + } + + /** + * @param name + */ + public RandomCache(String name) { + super(name); + // TODO Auto-generated constructor stub + } + + + /* (non-Javadoc) + * @see com.connsec.cache.AbstractCache#business() + */ + @Override + public void business() { + // TODO Auto-generated method stub + i=random.nextInt(100); + System.out.println(i); + } + + public int getI() { + return i; + } + + public void setI(int i) { + this.i = i; + } + + + +} diff --git a/maxkey-common/src/test/java/org/maxkey/copyright.txt b/maxkey-common/src/test/java/org/maxkey/copyright.txt new file mode 100644 index 000000000..9759194f1 --- /dev/null +++ b/maxkey-common/src/test/java/org/maxkey/copyright.txt @@ -0,0 +1,16 @@ +/* + * Copyright [2021] [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. + */ + \ No newline at end of file diff --git a/maxkey-common/src/test/java/org/maxkey/crypto/Base64UtilsTest.java b/maxkey-common/src/test/java/org/maxkey/crypto/Base64UtilsTest.java new file mode 100644 index 000000000..95e7daeec --- /dev/null +++ b/maxkey-common/src/test/java/org/maxkey/crypto/Base64UtilsTest.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.crypto; + +import org.junit.Test; +import org.maxkey.crypto.Base64Utils; + +public class Base64UtilsTest { + + /** + * @param args + */ + @Test + public void test() { + // TODO Auto-generated method stub + String encode=Base64Utils.encoder("base64ToFile".getBytes()); + System.out.println(encode); + String decode=Base64Utils.decode(encode); + System.out.println(decode); + + + + String urlEncode=Base64Utils.base64UrlEncode("{\"typ\":\"JWT\",\"alg\":\"HS256\"}".getBytes()); + System.out.println(urlEncode); + String urlDecode=new String(Base64Utils.base64UrlDecode(urlEncode)); + System.out.println(urlDecode); + + System.out.println(Base64Utils.decode("AAMkADU2OWY1MGQ3LWEyNWQtNDFmOC04MWFiLTI5YTE2NGM5YTZmNABGAAAAAABPKgpqnlfYQ7BVC/BfH2XIBwCS0xhUjzMYSLVky9bw7LddAAAAjov5AACS0xhUjzMYSLVky9bw7LddAAADzoyxAAA=")); + + + + } + +} diff --git a/maxkey-common/src/test/java/org/maxkey/crypto/DigestUtilsTest.java b/maxkey-common/src/test/java/org/maxkey/crypto/DigestUtilsTest.java new file mode 100644 index 000000000..ffa59cfd5 --- /dev/null +++ b/maxkey-common/src/test/java/org/maxkey/crypto/DigestUtilsTest.java @@ -0,0 +1,59 @@ +/* + * 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.crypto; + +import java.util.Date; + +import org.junit.Test; +import org.maxkey.crypto.DigestUtils; + +public class DigestUtilsTest { +/* + @Test + public void test() { + + System.out.println(DigestUtils.shaB64("mytest")); + + System.out.println(DigestUtils.sha1B64("e707c852-29a4-bf56-f8b9-014716850d89")); + + System.out.println(DigestUtils.sha256B64("mytest")); + + System.out.println(DigestUtils.sha384B64("mytest")); + + System.out.println(DigestUtils.sha512B64("mytest")); + + System.out.println(DigestUtils.md5B64("e707c852-29a4-bf56-f8b9-014716850d89")); + } + */ + @Test + public void testHex() { + + System.out.println(DigestUtils.shaHex("mytest")); + + System.out.println(DigestUtils.sha1Hex("mytest")); + + System.out.println(DigestUtils.sha256Hex("mytest")); + + System.out.println(DigestUtils.sha384Hex("mytest")); + + System.out.println(DigestUtils.sha512Hex("mytest")); + + System.out.println(DigestUtils.md5Hex("seamingxy99")); + System.out.println((new Date()).getTime()); + } +} diff --git a/maxkey-common/src/test/java/org/maxkey/crypto/KeyGen.java b/maxkey-common/src/test/java/org/maxkey/crypto/KeyGen.java new file mode 100644 index 000000000..e2a8e57fe --- /dev/null +++ b/maxkey-common/src/test/java/org/maxkey/crypto/KeyGen.java @@ -0,0 +1,63 @@ +/* + * 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.crypto; +import java.io.FileOutputStream; +import java.io.ObjectOutputStream; +import java.security.KeyPair; +import java.security.KeyPairGenerator; +import java.security.PrivateKey; +import java.security.PublicKey; +import java.security.SecureRandom; + + +public class KeyGen { + public static void main(String[] args) throws Exception { + String keyInfo="ASDFSDFNUGD__TYTY"; + KeyGen kg = new KeyGen(); + kg.genKeys(keyInfo); + } + + + public void genKeys(String keyInfo) throws Exception { + KeyPairGenerator keygen = KeyPairGenerator.getInstance("RSA"); + SecureRandom random = new SecureRandom(); + random.setSeed(keyInfo.getBytes()); + + keygen.initialize(512, random); + // ȡ����Կ�� + KeyPair kp = keygen.generateKeyPair(); + // ȡ�ù�Կ + PublicKey publicKey = kp.getPublic(); + System.out.println(publicKey); + saveFile(publicKey, "pk.dat"); + // ȡ��˽Կ + PrivateKey privateKey = kp.getPrivate(); + saveFile(privateKey, "sk.dat"); + } + + private void saveFile(Object obj, String fileName) throws Exception { + ObjectOutputStream output=new ObjectOutputStream( + new FileOutputStream(fileName)); + output.writeObject(obj); + output.close(); + } +} +//���ù�Կ���ܣ�˽Կ���ܣ� + + + diff --git a/maxkey-common/src/test/java/org/maxkey/crypto/Md5SumTest.java b/maxkey-common/src/test/java/org/maxkey/crypto/Md5SumTest.java new file mode 100644 index 000000000..b3a555a17 --- /dev/null +++ b/maxkey-common/src/test/java/org/maxkey/crypto/Md5SumTest.java @@ -0,0 +1,42 @@ +/* + * 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.crypto; + +import java.io.File; +import java.io.FileNotFoundException; + +import org.maxkey.crypto.Md5Sum; + +public class Md5SumTest { + + public Md5SumTest() { + // TODO Auto-generated constructor stub + } + + public static void main(String[] args) throws FileNotFoundException { + // TODO Auto-generated method stub + //String md5value=Md5Sum.produce(new File("E:/transwarp-4.3.4-Final-el6/transwarp-4.3.4-Final-26854-zh.el6.x86_64.tar.gz")); + File f=new File("E:/Soft/Xmanager4_setup.1410342608.exe"); + String md5value=Md5Sum.produce(f); + + System.out.println(""+md5value); + + System.out.println(Md5Sum.check(f,md5value)); + } + +} diff --git a/maxkey-common/src/test/java/org/maxkey/crypto/PasswordGenTest.java b/maxkey-common/src/test/java/org/maxkey/crypto/PasswordGenTest.java new file mode 100644 index 000000000..4809a32bc --- /dev/null +++ b/maxkey-common/src/test/java/org/maxkey/crypto/PasswordGenTest.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.crypto; + +import org.maxkey.crypto.password.PasswordGen; + +public class PasswordGenTest { + + public PasswordGenTest() { + // TODO Auto-generated constructor stub + } + + public static void main(String[] args) { + // TODO Auto-generated method stub + PasswordGen gen=new PasswordGen(); + System.out.println(gen.gen(2,2,2,1)); + for(int i=1;i<100;i++){ + //System.out.println(gen.gen()); + //System.out.println(gen.gen(6)); + //System.out.println(gen.gen(2,2,2,0)); + } + + } + +} diff --git a/maxkey-common/src/test/java/org/maxkey/crypto/RSAUtilsTest.java b/maxkey-common/src/test/java/org/maxkey/crypto/RSAUtilsTest.java new file mode 100644 index 000000000..cd44025cd --- /dev/null +++ b/maxkey-common/src/test/java/org/maxkey/crypto/RSAUtilsTest.java @@ -0,0 +1,53 @@ +/* + * 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.crypto; + +import java.security.Key; +import java.util.Map; + +import org.junit.Test; +import org.maxkey.crypto.Base64Utils; +import org.maxkey.crypto.HexUtils; +import org.maxkey.crypto.RSAUtils; + +public class RSAUtilsTest { + + //@Test + public void test() throws Exception { + + // ˽Կ���ܡ�����Կ���� + // ˽Կǩ����Կ��֤ǩ�� + Map key = RSAUtils.genKeyPair(); + String privateKey = RSAUtils.getPublicKey2Hex(key); + String publicKey = RSAUtils.getPrivateKey2Hex(key); + System.out.println("privateKey:" + privateKey); + System.out.println("publicKey:" + publicKey); + String signString = "my name is shiming"; + Key keyp = (Key) key.get(RSAUtils.PUBLIC_KEY); + System.out.println("privateKey:" + Base64Utils.base64UrlEncode(keyp.getEncoded())); + + byte[] encodedData = RSAUtils.encryptByPrivateKey(signString.getBytes(), privateKey); + System.out.println("���ܺ�\r\n" + new String(encodedData)); + System.out.println("���ܺ�B64��\r\n" + HexUtils.bytes2HexString(encodedData)); + byte[] decodedData = RSAUtils.decryptByPublicKey(encodedData, publicKey); + String target = new String(decodedData); + System.out.println("target:" + target); + + } + +} diff --git a/maxkey-common/src/test/java/org/maxkey/crypto/ReciprocalUtilsTest.java b/maxkey-common/src/test/java/org/maxkey/crypto/ReciprocalUtilsTest.java new file mode 100644 index 000000000..b1077afac --- /dev/null +++ b/maxkey-common/src/test/java/org/maxkey/crypto/ReciprocalUtilsTest.java @@ -0,0 +1,70 @@ +/* + * 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.crypto; + +import java.io.UnsupportedEncodingException; + +import org.junit.Test; +import org.maxkey.crypto.ReciprocalUtils; + +public class ReciprocalUtilsTest { + @Test + public void test() throws UnsupportedEncodingException { + /* + //System.out.println(ReciprocalUtils.generateKey(ReciprocalUtils.Algorithm.AES)); + + System.out.println( ReciprocalUtils.aesDecoder("7f8cbcd348ea99914f077250b9d14421e32eb7335be127f4838db9ea24f59ea0be2e17e0ce63da63ff29c50150b3343703ed778f2505ea50486236d2c682fa7f49d1efd7dc37fd62b5c518c2a7285d6063dd1d5d1a5c8cd53a622fff407c6537540f0bba5957180835d928082f3901d5aedf4e6ae873f5ab17dc46b7b385a1e306abab90696aed1fbfb147308d6114f5", "846KZSzYq56M6d5o")); + + //System.out.println(ReciprocalUtils.blowfishEncode("sadf","1111")); + + // System.out.println(ReciprocalUtils.blowfishDecoder("3547433be1e3a817","1111")); + System.out.println( ReciprocalUtils.encode("0eFm6iHvTgNs")); + + System.out.println( ReciprocalUtils.decoder("76efad66eb7d10140dc2d9ef41c51df0")); + + System.out.println( ReciprocalUtils.generatorDefaultKey(ReciprocalUtils.Algorithm.DESede)); + + + + + String urlencodeString="中国"; + String urlencode = java.net.URLEncoder.encode(urlencodeString, "utf-8"); + System.out.println(urlencode); + String urldecodeString="http://exchange.connsec.com/owa/?ae=Item&a=Open&t=IPM.Note&id=RgAAAABPKgpqnlfYQ7BVC%2fBfH2XIBwCS0xhUjzMYSLVky9bw7LddAAAAjov5AACS0xhUjzMYSLVky9bw7LddAAADzoy%2fAAAA&pspid=_1428036768398_867461813"; + String urldcode = java.net.URLDecoder.decode(urldecodeString, "utf-8"); + + + + + System.out.println(urldcode);*/ + System.out.println( ReciprocalUtils.decoder("76efad66eb7d10140dc2d9ef41c51df0")); + + + + + + + String encoderString="root"; + System.out.println( ReciprocalUtils.encode(encoderString)); + + encoderString="ead67db5c4f55eace090ab0044682451"; + encoderString=ReciprocalUtils.decoder(encoderString); + System.out.println(encoderString ); + + } +} diff --git a/maxkey-common/src/test/java/org/maxkey/crypto/RsaMessage.java b/maxkey-common/src/test/java/org/maxkey/crypto/RsaMessage.java new file mode 100644 index 000000000..058db6fe7 --- /dev/null +++ b/maxkey-common/src/test/java/org/maxkey/crypto/RsaMessage.java @@ -0,0 +1,168 @@ +/* + * 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.crypto; + import java.io.FileInputStream; + import java.io.ObjectInputStream; + import java.security.Key; + import java.security.PrivateKey; + import java.security.PublicKey; + import java.security.Signature; + import java.security.interfaces.RSAPrivateKey; + import java.security.interfaces.RSAPublicKey; + + import javax.crypto.Cipher; + + + /** + * RSA�ӽ���,RSAǩ��ǩ����֤�� + * + * @author Administrator + * + */ + public class RsaMessage { + + + + + public static void main(String[] args) throws Exception { + String str = "hello,�����ĵ����"; + System.out.println("ԭ�ģ�" + str); + + RsaMessage rsa = new RsaMessage(); + RSAPrivateKey privateKey = (RSAPrivateKey) rsa.readFromFile("sk.dat"); + RSAPublicKey publickKey = (RSAPublicKey) rsa.readFromFile("pk.dat"); + + byte[] encbyte = rsa.encrypt(str, privateKey); + System.out.println("˽Կ���ܺ�"); + String encStr = toHexString(encbyte); + System.out.println(encStr); + + byte[] signBytes = rsa.sign(str, privateKey); + System.out.println("ǩ��ֵ��"); + String signStr = toHexString(signBytes); + System.out.println(signStr); + + byte[] decByte = rsa.decrypt(encStr, publickKey); + System.out.println("��Կ���ܺ�"); + String decStr = new String(decByte); + System.out.println(decStr); + + if (rsa.verifySign(str, signStr, publickKey)) { + System.out.println("rsa sign check success"); + } else { + System.out.println("rsa sign check failure"); + } + } + + /** + * ����,key�����ǹ�Կ��Ҳ������˽Կ + * + * @param message + * @return + * @throws Exception + */ + public byte[] encrypt(String message, Key key) throws Exception { + Cipher cipher = Cipher.getInstance("RSA"); + cipher.init(Cipher.ENCRYPT_MODE, key); + return cipher.doFinal(message.getBytes()); + } + + /** + * ���ܣ�key�����ǹ�Կ��Ҳ������˽Կ������ǹ�Կ���ܾ���˽Կ���ܣ���֮��Ȼ + * + * @param message + * @return + * @throws Exception + */ + public byte[] decrypt(String message, Key key) throws Exception { + Cipher cipher = Cipher.getInstance("RSA"); + cipher.init(Cipher.DECRYPT_MODE, key); + return cipher.doFinal(toBytes(message)); + } + + /** + * ��˽Կǩ�� + * + * @param message + * @param key + * @return + * @throws Exception + */ + public byte[] sign(String message, PrivateKey key) throws Exception { + Signature signetcheck = Signature.getInstance("MD5withRSA"); + signetcheck.initSign(key); + signetcheck.update(message.getBytes("ISO-8859-1")); + return signetcheck.sign(); + } + + /** + * �ù�Կ��֤ǩ�����ȷ�� + * + * @param message + * @param signStr + * @return + * @throws Exception + */ + public boolean verifySign(String message, String signStr, PublicKey key) + throws Exception { + if (message == null || signStr == null || key == null) { + return false; + } + Signature signetcheck = Signature.getInstance("MD5withRSA"); + signetcheck.initVerify(key); + signetcheck.update(message.getBytes("ISO-8859-1")); + return signetcheck.verify(toBytes(signStr)); + } + + /** + * ���ļ���ȡobject + * + * @param fileName + * @return + * @throws Exception + */ + private Object readFromFile(String fileName) throws Exception { + ObjectInputStream input = new ObjectInputStream(new FileInputStream( + fileName)); + Object obj = input.readObject(); + input.close(); + return obj; + } + + public static String toHexString(byte[] b) { + StringBuilder sb = new StringBuilder(b.length * 2); + for (int i = 0; i < b.length; i++) { + sb.append(HEXCHAR[(b[i] & 0xf0) >>> 4]); + sb.append(HEXCHAR[b[i] & 0x0f]); + } + return sb.toString(); + } + + public static final byte[] toBytes(String s) { + byte[] bytes; + bytes = new byte[s.length() / 2]; + for (int i = 0; i < bytes.length; i++) { + bytes[i] = (byte) Integer.parseInt(s.substring(2 * i, 2 * i + 2), + 16); + } + return bytes; + } + + private static char[] HEXCHAR = { '0', '1', '2', '3', '4', '5', '6', '7', + '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; + } diff --git a/maxkey-common/src/test/java/org/maxkey/crypto/SCryptPasswordEncoderTest.java b/maxkey-common/src/test/java/org/maxkey/crypto/SCryptPasswordEncoderTest.java new file mode 100644 index 000000000..42f2bdd75 --- /dev/null +++ b/maxkey-common/src/test/java/org/maxkey/crypto/SCryptPasswordEncoderTest.java @@ -0,0 +1,38 @@ +/* + * 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.crypto; + +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; + +public class SCryptPasswordEncoderTest { + + public SCryptPasswordEncoderTest() { + // TODO Auto-generated constructor stub + } + + public static void main(String[] args) { + // TODO Auto-generated method stub + BCryptPasswordEncoder pe=new BCryptPasswordEncoder(); + //String c="$e0801$7Holo9EgzBeg5xf/WLZu3/5IQwOyEPDLJPgMXkF9jnekBrbQUMt4CF9O2trkz3zBCnCLpUMR437q/AjQ5TTToA==$oYB8KRSxAsxkKkt5r79W6r6P0wTUcKwGye1ivXRN0Ts=" + //; + System.out.println(pe.encode("admin")); + // System.out.println(pe.encode("shimingxy")+"_password"); + //System.out.println(pe.matches("shimingxy"+"_password", c)); + } + +} diff --git a/maxkey-common/src/test/java/org/maxkey/crypto/cert/X509CertUtilsTest.java b/maxkey-common/src/test/java/org/maxkey/crypto/cert/X509CertUtilsTest.java new file mode 100644 index 000000000..5c639524f --- /dev/null +++ b/maxkey-common/src/test/java/org/maxkey/crypto/cert/X509CertUtilsTest.java @@ -0,0 +1,104 @@ +/* + * 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.crypto.cert; + * + * import java.io.FileInputStream; import java.io.FileOutputStream; import + * java.io.IOException; import java.security.InvalidKeyException; import + * java.security.KeyStore; import java.security.KeyStoreException; import + * java.security.NoSuchAlgorithmException; import + * java.security.NoSuchProviderException; import java.security.PrivateKey; + * import java.security.SignatureException; import + * java.security.UnrecoverableKeyException; import + * java.security.cert.CertificateException; import java.util.Date; + * + * import org.junit.Test; + * + * import sun.security.x509.AlgorithmId; import + * sun.security.x509.CertificateAlgorithmId; import + * sun.security.x509.CertificateIssuerName; import + * sun.security.x509.CertificateSerialNumber; import + * sun.security.x509.CertificateSubjectName; import + * sun.security.x509.CertificateValidity; import sun.security.x509.X500Name; + * import sun.security.x509.X509CertImpl; import sun.security.x509.X509CertInfo; + * + * public class X509CertUtilsTest { + * + * //@Test public void test() throws KeyStoreException, + * NoSuchAlgorithmException, CertificateException, IOException, + * UnrecoverableKeyException, InvalidKeyException, NoSuchProviderException, + * SignatureException { //// + * + * String keystoreFile = "c:\\keyStoreFile.jks"; String caAlias = "caAlias"; + * String certToSignAlias = "cert"; String newAlias = "newAlias"; + * + * char[] password = new char[] { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h' }; + * char[] caPassword = new char[] { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h' }; + * char[] certPassword = new char[] { 'a', 'b', 'c', 'd', 'e', 'f', 'g','h' }; + * + * FileInputStream input = new FileInputStream(keystoreFile); KeyStore keyStore + * = KeyStore.getInstance("JKS"); keyStore.load(input, password); input.close(); + * + * PrivateKey caPrivateKey = (PrivateKey) keyStore.getKey(caAlias,caPassword); + * java.security.cert.Certificate caCert = keyStore.getCertificate(caAlias); + * + * byte[] encoded = caCert.getEncoded(); X509CertImpl caCertImpl = new + * X509CertImpl(encoded); + * + * X509CertInfo caCertInfo = (X509CertInfo) caCertImpl.get(X509CertImpl.NAME + + * "." + X509CertImpl.INFO); + * + * X500Name issuer = (X500Name) caCertInfo.get(X509CertInfo.SUBJECT + "."+ + * CertificateIssuerName.DN_NAME); + * + * java.security.cert.Certificate cert = + * keyStore.getCertificate(certToSignAlias); PrivateKey privateKey = + * (PrivateKey) keyStore.getKey(certToSignAlias,certPassword); encoded = + * cert.getEncoded(); X509CertImpl certImpl = new X509CertImpl(encoded); + * X509CertInfo certInfo = (X509CertInfo) certImpl.get(X509CertImpl.NAME+ "." + + * X509CertImpl.INFO); + * + * Date firstDate = new Date(); Date lastDate = new Date(firstDate.getTime() + + * 365 * 24 * 60 * 60* 1000L); CertificateValidity interval = new + * CertificateValidity(firstDate,lastDate); + * + * certInfo.set(X509CertInfo.VALIDITY, interval); + * + * certInfo.set(X509CertInfo.SERIAL_NUMBER, new CertificateSerialNumber((int) + * (firstDate.getTime() / 1000))); + * + * certInfo.set(X509CertInfo.ISSUER + "." + + * CertificateSubjectName.DN_NAME,issuer); + * + * AlgorithmId algorithm = new + * AlgorithmId(AlgorithmId.md5WithRSAEncryption_oid); + * certInfo.set(CertificateAlgorithmId.NAME + "."+ + * CertificateAlgorithmId.ALGORITHM, algorithm); X509CertImpl newCert = new + * X509CertImpl(certInfo); + * + * newCert.sign(caPrivateKey, "MD5WithRSA"); + * + * keyStore.setKeyEntry(newAlias, privateKey, certPassword,new + * java.security.cert.Certificate[] { newCert }); + * + * FileOutputStream output = new FileOutputStream(keystoreFile); + * keyStore.store(output, password); output.close(); + * + * } + * + * } + */ diff --git a/maxkey-common/src/test/java/org/maxkey/crypto/cert/X509V3CertGenTest.java b/maxkey-common/src/test/java/org/maxkey/crypto/cert/X509V3CertGenTest.java new file mode 100644 index 000000000..3e0507265 --- /dev/null +++ b/maxkey-common/src/test/java/org/maxkey/crypto/cert/X509V3CertGenTest.java @@ -0,0 +1,59 @@ +/* + * 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.crypto.cert; + +import java.io.File; +import java.io.FileOutputStream; +import java.security.KeyPair; +import java.security.Security; +import java.security.cert.X509Certificate; +import java.util.Date; + +import org.joda.time.DateTime; +import org.junit.Test; +import org.maxkey.crypto.cert.X509V3CertGen; + +public class X509V3CertGenTest { + + //@Test + public void generateV3() throws Exception { + Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider()); + KeyPair keyPair =X509V3CertGen.genRSAKeyPair(); + String issuer="CN=maxkey.top,O=maxkey,L=SH,ST=SH,C=CN"; + Date startDate=DateTime.now().toDate(); + Date endDate=DateTime.now().plusMonths(10).toDate(); + System.out.println("Private : "+ keyPair.getPrivate().toString()); + + System.out.println("Public : "+ keyPair.getPublic().toString()); + X509Certificate cert = X509V3CertGen.genV3Certificate(issuer,issuer,startDate,endDate,keyPair); + String certFileString = "D:\\MaxKey\\Workspaces\\maxkey\\Cert345.cer"; + File certFile =new File(certFileString); + if(certFile.exists()) { + certFile.deleteOnExit(); + } + + FileOutputStream out = new FileOutputStream(certFileString); + out.write(cert.getEncoded()); + out.close(); + + cert.checkValidity(new Date()); + cert.verify(cert.getPublicKey()); + + } + +} diff --git a/maxkey-common/src/test/java/org/maxkey/crypto/password/PasswordReciprocalTest.java b/maxkey-common/src/test/java/org/maxkey/crypto/password/PasswordReciprocalTest.java new file mode 100644 index 000000000..ce456de31 --- /dev/null +++ b/maxkey-common/src/test/java/org/maxkey/crypto/password/PasswordReciprocalTest.java @@ -0,0 +1,38 @@ +/* + * 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.crypto.password; + +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; + +public class PasswordReciprocalTest { + + public PasswordReciprocalTest() { + // TODO Auto-generated constructor stub + } + + public static void main(String[] args) { + // TODO Auto-generated method stub + BCryptPasswordEncoder spe= new BCryptPasswordEncoder(); + String pass=PasswordReciprocal.getInstance().rawPassword("admin", "admin"); + String epass=spe.encode(pass); + System.out.println("PasswordEncoder "+epass); + + System.out.println(PasswordReciprocal.getInstance().decoder("f1ee1e9b912f05333a06925c99daf9c0")); + } + +} diff --git a/maxkey-common/src/test/java/org/maxkey/crypto/password/SM3PasswordEncoderTest.java b/maxkey-common/src/test/java/org/maxkey/crypto/password/SM3PasswordEncoderTest.java new file mode 100644 index 000000000..631f27204 --- /dev/null +++ b/maxkey-common/src/test/java/org/maxkey/crypto/password/SM3PasswordEncoderTest.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.crypto.password; + +public class SM3PasswordEncoderTest { + + public static void main(String[] args) { + // TODO Auto-generated method stub + SM3PasswordEncoder sm3 = new SM3PasswordEncoder(); + System.out.println(sm3.encode("maxkeypassword")); + + String c="f4679d46e96d95d67db4c8c91fcf8aaaa4e1d437ffee278d2ea97f41f7f48c12"; + System.out.println(sm3.matches("maxkeypassword",c)); + } + +} diff --git a/maxkey-common/src/test/java/org/maxkey/crypto/signature/DsaSignerTest.java b/maxkey-common/src/test/java/org/maxkey/crypto/signature/DsaSignerTest.java new file mode 100644 index 000000000..b38ce1985 --- /dev/null +++ b/maxkey-common/src/test/java/org/maxkey/crypto/signature/DsaSignerTest.java @@ -0,0 +1,52 @@ +/* + * 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.crypto.signature; + +import java.util.Map; + +import org.junit.Test; +import org.maxkey.crypto.KeyPairUtil; +import org.maxkey.crypto.signature.DsaSigner; + +public final class DsaSignerTest { + @Test + public void test() throws Exception { + + DsaSigner dsaSigner = new DsaSigner(); + // genKeyPair + Map keyMap = KeyPairUtil.genKeyPairMap(DsaSigner.KEY_ALGORITHM); + + String publicKey = KeyPairUtil.getPublicKey(keyMap); + String privateKey = KeyPairUtil.getPrivateKey(keyMap); + System.out.println("privateKey:" + privateKey); + System.out.println("privateKey:" + privateKey.length()); + System.out.println("publicKey:" + publicKey); + System.out.println("publicKey:" + publicKey.length()); + + String signStr = "my data need to sign use DSA Digital signature"; + System.out.println("signStr:" + signStr); + + String sign = dsaSigner.signB64(signStr, privateKey); + System.out.println("sign��" + sign); + // verify + boolean status = dsaSigner.verifyB64(signStr, publicKey, sign); + System.out.println("status��" + status); + + } + +} diff --git a/maxkey-common/src/test/java/org/maxkey/crypto/signature/RsaSignerTest.java b/maxkey-common/src/test/java/org/maxkey/crypto/signature/RsaSignerTest.java new file mode 100644 index 000000000..0be0a6198 --- /dev/null +++ b/maxkey-common/src/test/java/org/maxkey/crypto/signature/RsaSignerTest.java @@ -0,0 +1,53 @@ +/* + * 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.crypto.signature; + +import java.util.Map; + +import org.junit.Test; +import org.maxkey.crypto.KeyPairUtil; +import org.maxkey.crypto.signature.RsaSigner; + + +public final class RsaSignerTest { + + @Test + public void test() throws Exception { + + RsaSigner rsaSigner = new RsaSigner(); + Map key = KeyPairUtil.genKeyPairMap(RsaSigner.KEY_ALGORTHM); + String privateKey = KeyPairUtil.getPrivateKey(key); + String publicKey = KeyPairUtil.getPublicKey(key); + System.out.println("privateKey:" + privateKey); + System.out.println("privateKey:" + privateKey.length()); + System.out.println("publicKey:" + publicKey); + System.out.println("publicKey:" + publicKey.length()); + String sdata = "MIIBSwIBADCCASwGByqGSM44BAEwggEfAoGBAP1/U4EddRIpUt9KnC7s5Of2EbdSPO9EAMMeP4C2USZpRV1AIlH7WT2NWPq/xfW6MPbLm1Vs14E7gB00b/JmYLdrmVClpJ+f6AR7ECLCT7up1/63xhv4O1fnxqimFQ8E+4P208UewwI1VBNaFpEy9nXzrith1yrv8iIDGZ3RSAHHAhUAl2BQjxUjC8yykrmCouuEC/BYHPUCgYEA9+GghdabPd7LvKtcNrhXuXmUr7v6OuqC+VdMCz0HgmdRWVeOutRZT+ZxBxCBgLRJFnEj6EwoFhO3zwkyjMim4TwWeotUfI0o4KOuHiuzpnWRbqN/C/ohNWLx+2J6ASQ7zKTxvqhRkImog9/hWuWfBpKLZl6Ae1UlZAFMO/7PSSoEFgIUWEKjQXEsmz9cfPNxwhAlXl90U8c="; + String signedStringuuid = rsaSigner.signB64(sdata, privateKey); + System.out.println("signedStringuuid:" + signedStringuuid); + System.out.println("signedStringuuid:" + signedStringuuid.length()); + boolean isSigneduuid = rsaSigner.verifyB64(sdata, publicKey, + signedStringuuid); + System.out.println("isSigneduuid:" + isSigneduuid); + + } + +} diff --git a/maxkey-common/src/test/java/org/maxkey/mail/MailTest.java b/maxkey-common/src/test/java/org/maxkey/mail/MailTest.java new file mode 100644 index 000000000..26d351e6e --- /dev/null +++ b/maxkey-common/src/test/java/org/maxkey/mail/MailTest.java @@ -0,0 +1,47 @@ +/* + * 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.mail; + +import org.apache.commons.mail.DefaultAuthenticator; +import org.apache.commons.mail.Email; +import org.apache.commons.mail.SimpleEmail; +import org.junit.Test; + +public class MailTest { + + //@Test + public void test() throws Exception { + String username="test@connsec.com"; + String password="3&8Ujbnm5hkjhFD"; + String smtpHost="smtp.exmail.qq.com"; + int port=465; + boolean ssl=true; + String senderMail="test@connsec.com"; + + Email email = new SimpleEmail(); + email.setHostName(smtpHost); + email.setSmtpPort(port); + email.setAuthenticator(new DefaultAuthenticator(username, password)); + email.setSSLOnConnect(ssl); + email.setFrom(senderMail); + email.setSubject("One Time PassWord"); + email.setMsg("You Token is "+111+" , it validity in "+5 +" minutes"); + email.addTo("shimingxy@qq.com"); + email.send(); + } +} diff --git a/maxkey-common/src/test/java/org/maxkey/otp/algorithm/RQcodeTest.java b/maxkey-common/src/test/java/org/maxkey/otp/algorithm/RQcodeTest.java new file mode 100644 index 000000000..e2d42d94a --- /dev/null +++ b/maxkey-common/src/test/java/org/maxkey/otp/algorithm/RQcodeTest.java @@ -0,0 +1,112 @@ +/* + * 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.otp.algorithm; + +import java.io.File; + +import org.maxkey.util.QRCode; + +import com.google.zxing.BarcodeFormat; +import com.google.zxing.MultiFormatWriter; +import com.google.zxing.common.BitMatrix; + +public class RQcodeTest { + + /* + * BEGIN:VCARD +VERSION:3.0 +N:Gump;Forrest;;Mr. +FN:Forrest Gump +ORG:Bubba Gump Shrimp Co. +TITLE:Shrimp Man +PHOTO;VALUE=URL;TYPE=GIF:http://www.example.com/dir_photos/my_photo.gif +TEL;TYPE=WORK,VOICE:(111) 555-12121 +TEL;TYPE=HOME,VOICE:(404) 555-1212 +ADR;TYPE=WORK:;;100 Waters Edge;Baytown;LA;30314;United States of America +LABEL;TYPE=WORK:100 Waters Edge\nBaytown, LA 30314\nUnited States of America +ADR;TYPE=HOME:;;42 Plantation St.;Baytown;LA;30314;United States of America +LABEL;TYPE=HOME:42 Plantation St.\nBaytown, LA 30314\nUnited States of America +EMAIL;TYPE=PREF,INTERNET:forrestgump@example.com +REV:2008-04-24T19:52:43Z +END:VCARD + + + +BEGIN:VCARD +VERSION:4.0 +N:Gump;Forrest;;; +FN:Forrest Gump +ORG:Bubba Gump Shrimp Co. +TITLE:Shrimp Man +PHOTO;MEDIATYPE=image/gif:http://www.example.com/dir_photos/my_photo.gif +TEL;TYPE=work,voice;VALUE=uri:tel:+1-111-555-1212 +TEL;TYPE=home,voice;VALUE=uri:tel:+1-404-555-1212 +ADR;TYPE=work;LABEL="100 Waters Edge\nBaytown, LA 30314\nUnited States of America" + :;;100 Waters Edge;Baytown;LA;30314;United States of America +ADR;TYPE=home;LABEL="42 Plantation St.\nBaytown, LA 30314\nUnited States of America" + :;;42 Plantation St.;Baytown;LA;30314;United States of America +EMAIL:forrestgump@example.com +REV:20080424T195243Z +END:VCARD + */ + // 编码 + public static void main(String[] args) { + try { + + String str = "BEGIN:VCARD\n" + + "VERSION:3.0\n" + + "N:石明海\n" + + "EMAIL:shimh@qq.com\n" + + "TEL:15618726256\n" + + "TEL;CELL:12345678912" + + "ADR:上海\n" + + "ORG:" + + "Connsec\n" + + "TITLE:技术总监\n" + + //"URL:http://blog.csdn.net/lidew521\n" + + //"NOTE:呼呼测试下吧。。。\n" + + "END:VCARD"; + + String str1 = "BEGIN:VCARD\n" + + "VERSION:3.0\n" + + "N:Gump;Forrest;;Mr.\n" + + "ORG:Bubba Gump Shrimp Co.\n" + + "TITLE:Shrimp Man\n" + + "TEL;TYPE=WORK,VOICE:(111) 555-12121\n" + + "ADR;TYPE=WORK:;;100 Waters Edge;Baytown;LA;30314;United States of America\n" + + "EMAIL;TYPE=PREF,INTERNET:forrestgump@example.com\n" + + "URL:http://www.johndoe.com\n" + + "GENDER:F\n"+ + "REV:2008-04-24T19:52:43Z\n" + + "END:VCARD\n" ; + + //String str = "CN:男;COP:公司;ZW:职务";// 二维码内容 + String path = "D:\\hwy.png"; + BitMatrix byteMatrix; + byteMatrix = new MultiFormatWriter().encode(new String(str1.getBytes("UTF-8"),"iso-8859-1"), + BarcodeFormat.QR_CODE, 300, 300); + File file = new File(path); + + QRCode.writeToPath(byteMatrix, "png", file); + } catch (Exception e) { + e.printStackTrace(); + } + } + + +} diff --git a/maxkey-common/src/test/java/org/maxkey/package-info.java b/maxkey-common/src/test/java/org/maxkey/package-info.java new file mode 100644 index 000000000..ab406d82c --- /dev/null +++ b/maxkey-common/src/test/java/org/maxkey/package-info.java @@ -0,0 +1,18 @@ +/* + * 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; diff --git a/maxkey-common/src/test/java/org/maxkey/persistence/derby/DerbyTest.java b/maxkey-common/src/test/java/org/maxkey/persistence/derby/DerbyTest.java new file mode 100644 index 000000000..fb136224b --- /dev/null +++ b/maxkey-common/src/test/java/org/maxkey/persistence/derby/DerbyTest.java @@ -0,0 +1,65 @@ +/* + * 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.persistence.derby; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; + + +public class DerbyTest { +/** + * 1. + * first SET JAVA_HOME,DERBY_HOME,PATH + * set PATH=%DERBY_HOME%\bin;%PATH% + * 2. + * startNetworkServer Start Derby Database + * 3. + * create db seconddb1 , user is tquist + * CONNECT 'jdbc:derby://localhost:1527/seconddb1;create=true;user=tquist'; + * 4. + * Configuring NATIVE authentication + * call SYSCS_UTIL.SYSCS_CREATE_USER( 'tquist', 'tquist' ); + * 5. + * then restart derby database + */ + /** + * @param args + * @throws SQLException + */ + public static void main(String[] args) throws SQLException { + // TODO Auto-generated method stub + String nsURL="jdbc:derby://localhost:1527/seconddb1"; + java.util.Properties props = new java.util.Properties(); + props.setProperty("user","tquist"); + props.setProperty("password","tquist"); + + Connection conn = DriverManager.getConnection(nsURL, props); + + /*interact with Derby*/ + Statement s = conn.createStatement(); + + ResultSet rs = s.executeQuery("SELECT * FROM SECONDTABLE"); + + while(rs.next()){ + System.out.println("key : "+rs.getInt("ID")+" ,name : "+rs.getString("NAME")); + } + } + +} diff --git a/maxkey-common/src/test/java/org/maxkey/rest/AuthorizationHeaderTest.java b/maxkey-common/src/test/java/org/maxkey/rest/AuthorizationHeaderTest.java new file mode 100644 index 000000000..ba686b572 --- /dev/null +++ b/maxkey-common/src/test/java/org/maxkey/rest/AuthorizationHeaderTest.java @@ -0,0 +1,32 @@ +/* + * 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.rest; + +import org.junit.Test; +import org.maxkey.util.AuthorizationHeaderUtils; + +public class AuthorizationHeaderTest { + + @Test + public void test() { + String basic =AuthorizationHeaderUtils.createBasic("Aladdin", "open sesame"); + System.out.println(basic); + String []rb=AuthorizationHeaderUtils.resolveBasic(basic); + System.out.println(rb[0]+":"+rb[1]); + } +} diff --git a/maxkey-common/src/test/java/org/maxkey/util/DateUtilsTest.java b/maxkey-common/src/test/java/org/maxkey/util/DateUtilsTest.java new file mode 100644 index 000000000..ad4ee22f3 --- /dev/null +++ b/maxkey-common/src/test/java/org/maxkey/util/DateUtilsTest.java @@ -0,0 +1,79 @@ +/* + * 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.util; + +import java.util.Date; + +import org.maxkey.util.DateUtils; + +public class DateUtilsTest { + + /** + * Main method for test. + * + * @param args + * @throws EncryptException + */ + public static void main(String[] args) throws Exception { + String stringValue = "20110610090519"; + System.out.println(stringValue); +// System.out.println("Parse \"" + stringValue +// + "\" using format pattern \"" + DateUtils.FORMAT_DATE_DEFAULT +// + "\" with method \"DateUtils.parse()\", result: " +// + DateUtils.parse(stringValue)); +// stringValue = "20080506"; +// System.out.println("Parse \"" + stringValue +// + "\" using method \"DateUtils.tryParse()\", result: " +// + DateUtils.tryParse(stringValue)); +// String s = DateUtils.getExchangeFormat(stringValue,FORMAT_DATE_YYYYMMDDHHMMSS,DateUtils.FORMAT_DATE_YYYY_MM_DD_HH_MM_SS); +// System.out.print("--->>>"+s); + +// String str = "2011-08-09"; +// System.out.println(UserPasswordUtil.decrypt("PVuyeIHtXnXv5oSPwPUug66w==")); +// System.out.println(DateUtils.getFormtPattern1ToPattern2(str, DateUtils.FORMAT_DATE_YYYY_MM_DD, DateUtils.FORMAT_DATE_YYYY_MM_DD_HH_MM_SS)); +// str = "aaa\r\nbbb"; +// List list = StringUtil.strToList(str, "\r\n"); +// System.out.println(list.size()); +// System.out.println(StringUtil.listToStr(null, ",")); + +// String value = "a,b,,c,,"; +// System.out.println(value.split("\\,").length); +// System.out.println(StringUtil.removeSplit(value, ",")); + +// Class clazz = TmEmployeeUserInfo.class; +// Field field = clazz.getDeclaredField("spellName"); +// System.out.println(field.getName()); + +// System.out.println(UserPasswordUtil.encrypt("oscwebadmin@163.com")); + //System.out.println(JCEnDecrypt.randomDecrypt("2AF5022B2E78478A9761FD3381BB")); +// System.out.println(JCEnDecrypt.randomEncrypt("aaa")); 41l2Iw4V +// String regEx="[1]{1}[3,5,8,6]{1}[0-9]{9}"; //��ʾa��f +// System.out.println(Pattern.compile(regEx).matcher("18258842633").find()); +// Date lockoutDate = DateUtils.addDate(new Date(), 0, 30, 0); //解锁时间 +// System.out.println(DateUtils.format(lockoutDate, DateUtils.FORMAT_DATE_YYYY_MM_DD_HH_MM_SS)); + Date date = new Date(); + System.out.println(DateUtils.format(DateUtils.addDate(date, 0, 0, 1, 0, 0, 0),DateUtils.FORMAT_DATE_YYYY_MM_DD_HH_MM_SS)); + + System.out.println(DateUtils.format(DateUtils.addMinutes(new Date(), Integer.parseInt("2")*1000),DateUtils.FORMAT_DATE_ISO_TIMESTAMP)); + System.out.println(DateUtils.toUtc(date)); + + System.out.println(DateUtils.toUtcLocal("2015-11-04T16:00:22.875Z")); + System.out.println(DateUtils.toUtcLocal("2015-11-04T23:58:14.286+08:00")); + + } +} diff --git a/maxkey-common/src/test/java/org/maxkey/util/EthernetAddressTest.java b/maxkey-common/src/test/java/org/maxkey/util/EthernetAddressTest.java new file mode 100644 index 000000000..7db3af45f --- /dev/null +++ b/maxkey-common/src/test/java/org/maxkey/util/EthernetAddressTest.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.util; + +import org.maxkey.util.EthernetAddress; + +public class EthernetAddressTest { + + public static void main(String[] args) { + System.out.println(EthernetAddress.fromInterface()); + + } + +} diff --git a/maxkey-common/src/test/java/org/maxkey/util/IdSequenceTest.java b/maxkey-common/src/test/java/org/maxkey/util/IdSequenceTest.java new file mode 100644 index 000000000..6124136d6 --- /dev/null +++ b/maxkey-common/src/test/java/org/maxkey/util/IdSequenceTest.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.util; + +public class IdSequenceTest { + + public static void main(String[] args) { + // TODO Auto-generated method stub + long s =System.currentTimeMillis(); + int k; + for(int i=1;i<=10010;i++){ + k=(i)%10000; + System.out.println(k); + } + System.out.println(System.currentTimeMillis()-s); + } + +} diff --git a/maxkey-common/src/test/java/org/maxkey/util/MacAddressTest.java b/maxkey-common/src/test/java/org/maxkey/util/MacAddressTest.java new file mode 100644 index 000000000..cba766dc6 --- /dev/null +++ b/maxkey-common/src/test/java/org/maxkey/util/MacAddressTest.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.util; + +import org.maxkey.util.MacAddress; + +public class MacAddressTest { + + public static void main(String[] args) { + // TODO Auto-generated method stub + System.out.println(MacAddress.getAllHostMacAddress()); + } + +} diff --git a/maxkey-common/src/test/java/org/maxkey/util/ObjectTransformerTest.java b/maxkey-common/src/test/java/org/maxkey/util/ObjectTransformerTest.java new file mode 100644 index 000000000..3921ad0dd --- /dev/null +++ b/maxkey-common/src/test/java/org/maxkey/util/ObjectTransformerTest.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.util; + +import java.util.HashMap; +import org.maxkey.util.ObjectTransformer; + +public class ObjectTransformerTest { + + /** + * @param args + */ + public static void main(String[] args) { + // TODO Auto-generated method stub + HashMap ut=new HashMap(); + + ut.put("username","shimingxy"); + ut.put("password","test"); + ut.put("department","我的部门"); + + String hexString =ObjectTransformer.serialize(ut); + + System.out.println("hexString "+hexString); + System.out.println(hexString.length()); + + HashMap u2=ObjectTransformer.deserialize(hexString); + + System.out.println("deserialize "+u2.toString()); + + System.out.println("{’id’:’be90f66d-95df-4daf-93c1-ece002542702’,’tid’:null,’tname’:null,’description’:null,’status’:0,’sortOrder’:0,’createdBy’:’admin’,’createdDate’:’2014-11-07 21:27:38’,’modifiedBy’:null,’modifiedDate’:null,’startDate’:null,’endDate’:null,’username’:’yyyyy’,’password’:’Pt3dCf6Zad9h3g7q/DI0e7jQ5evO2Jn+tk2TjtdJ0eY=’,’decipherable’:’yaOLYlcdjfF5hFOskBOOxQ==’,’sharedSecret’:null,’sharedCounter’:null,’userType’:’EMPLOYEE’,’windowsAccount’:null,’displayName’:’test’,’nickName’:null,’nameZHSpell’:’test’,’nameZHShortSpell’:’test’,’givenName’:null,’middleName’:null,’familyName’:null,’honorificPrefix’:null,’honorificSuffix’:null,’formattedName’:null,’married’:0,’gender’:1,’birthDate’:null,’idType’:0,’idCardNo’:null,’webSite’:null,’startWorkDate’:null,’authnType’:0,’email’:null,’emailVerified’:0,’mobile’:null,’mobileVerified’:0,’passwordQuestion’:null,’passwordAnswer’:null,’appLoginAuthnType’:0,’appLoginPassword’:null,’protectedApps’:null,’passwordLastSetTime’:’2014-11-07 21:27:38’,’badPasswordCount’:0,’unLockTime’:null,’isLocked’:0,’lastLoginTime’:null,’lastLogoffTime’:null,’passwordSetType’:0,’locale’:’zh_CN’,’timeZone’:’Asia/Shanghai’,’preferredLanguage’:’zh_CN’,’workCountry’:’CHN’,’workRegion’:null,’workLocality’:null,’workStreetAddress’:null,’workAddressFormatted’:null,’workEmail’:null,’workPhoneNumber’:null,’workPostalCode’:null,’workFax’:null,’homeCountry’:’CHN’,’homeRegion’:null,’homeLocality’:null,’homeStreetAddress’:null,’homeAddressFormatted’:null,’homeEmail’:null,’homePhoneNumber’:null,’homePostalCode’:null,’homeFax’:null,’employeeNumber’:null,’costCenter’:null,’organization’:null,’division’:null,’departmentId’:null,’department’:null,’jobTitle’:null,’jobLevel’:null,’managerId’:null,’manager’:null,’assistantId’:null,’assistant’:null,’entryDate’:null,’quitDate’:null,’ims’:’QQ:\r\nWeiXin:\r\nSinaWeibo:\r\nGtalk:\r\nYiXin:\r\nIMessage:\r\nSkype:\r\nYahoo:\r\nMSN:\r\nAim:\r\nICQ :\r\nXmpp :’,’extraAttribute’:null,’extraAttributeName’:null,’extraAttributeValue’:null,’online’:0,’ldapDn’:null}".length()); + } + +} diff --git a/maxkey-common/src/test/java/org/maxkey/util/PathUtilsTest.java b/maxkey-common/src/test/java/org/maxkey/util/PathUtilsTest.java new file mode 100644 index 000000000..0192a8326 --- /dev/null +++ b/maxkey-common/src/test/java/org/maxkey/util/PathUtilsTest.java @@ -0,0 +1,30 @@ +/* + * 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.util; + +import org.junit.Test; +import org.maxkey.util.PathUtils; + +public class PathUtilsTest { + @Test + public void test() { + //System.out.println(PathUtils.getInstance().getAppPath()); + //System.out.println(PathUtils.getInstance().getWebInf()); + //System.out.println(PathUtils.getInstance().getClassPath()); + } +} diff --git a/maxkey-common/src/test/java/org/maxkey/util/SqlPrettyTest.java b/maxkey-common/src/test/java/org/maxkey/util/SqlPrettyTest.java new file mode 100644 index 000000000..c666a18f9 --- /dev/null +++ b/maxkey-common/src/test/java/org/maxkey/util/SqlPrettyTest.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.util; + +import org.junit.Test; +import org.maxkey.pretty.PrettyFactory; + +public class SqlPrettyTest { + + public SqlPrettyTest() { + + } + + @Test + public void testSqlFormat() { + String sqlString="select * from userinfo where t='111' order by t,s,t"; + System.out.println(PrettyFactory.getSqlPretty().format(sqlString)); + } + +} diff --git a/maxkey-common/src/test/java/org/maxkey/util/StringGeneratorTest.java b/maxkey-common/src/test/java/org/maxkey/util/StringGeneratorTest.java new file mode 100644 index 000000000..7b654c9b6 --- /dev/null +++ b/maxkey-common/src/test/java/org/maxkey/util/StringGeneratorTest.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.util; + +import java.util.UUID; + +import org.junit.Test; +import org.maxkey.util.StringGenerator; + +public class StringGeneratorTest { + @Test + public void test() { + StringGenerator stringGenerator=new StringGenerator(); + System.out.println(stringGenerator.uuidGenerate()); + System.out.println(stringGenerator.uuidGenerate().length()); + System.out.println(stringGenerator.uniqueGenerate()); + System.out.println(stringGenerator.uniqueGenerate().length()); + + System.out.println(StringGenerator.uuidMatches(stringGenerator.uuidGenerate())); + System.out.println(StringGenerator.uuidMatches(UUID.randomUUID().toString())); + System.out.println(StringGenerator.uuidMatches("408192be-cab9-4b5b-8d41-4cd827cc4091")); + + + } +} diff --git a/maxkey-common/src/test/java/org/maxkey/util/UUIDGeneratorTest.java b/maxkey-common/src/test/java/org/maxkey/util/UUIDGeneratorTest.java new file mode 100644 index 000000000..366fa4aea --- /dev/null +++ b/maxkey-common/src/test/java/org/maxkey/util/UUIDGeneratorTest.java @@ -0,0 +1,59 @@ +/* + * 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.util; + +import java.util.Date; +//import java.util.UUID; + +import org.maxkey.uuid.UUID; +import org.junit.Test; +import org.maxkey.util.UUIDGenerator; + +public class UUIDGeneratorTest { + + @Test + public void test() { + Date sd=new Date(); + + //for(int i=0;i<100000;i++){ + UUIDGenerator generated=new UUIDGenerator(); + generated.toString(); + //System.out.println(generated.toString()); + + //} + Date ed=new Date(); + System.out.println("usertime "+(ed.getTime()-sd.getTime())); + + // UUIDGenerator.version(generated); + + + System.out.println("JDK UUID"); + Date ssd=new Date(); + // for(int i=0;i<100000;i++){ + //UUID.randomUUID().toString(); + UUID.generate().toString(); + // System.out.println(UUID.randomUUID().toString()); + //} + Date sed=new Date(); + System.out.println("usertime "+(sed.getTime()-ssd.getTime())); + + UUIDGenerator.version(new UUIDGenerator(UUID.generate().toString())); + + + } +} diff --git a/maxkey-common/src/test/java/org/maxkey/util/XMLHelperTest.java b/maxkey-common/src/test/java/org/maxkey/util/XMLHelperTest.java new file mode 100644 index 000000000..eee2076de --- /dev/null +++ b/maxkey-common/src/test/java/org/maxkey/util/XMLHelperTest.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.util; + +import java.io.OutputStream; +import java.io.StringWriter; +import java.io.Writer; +import java.util.Map; + +import org.junit.Test; +import org.maxkey.pretty.PrettyFactory; +import org.maxkey.pretty.impl.XMLHelper; +import org.w3c.dom.DOMConfiguration; +import org.w3c.dom.DOMImplementation; +import org.w3c.dom.Document; +import org.w3c.dom.Node; +import org.w3c.dom.ls.DOMImplementationLS; +import org.w3c.dom.ls.LSOutput; +import org.w3c.dom.ls.LSSerializer; +import org.w3c.dom.ls.LSSerializerFilter; + +import net.shibboleth.utilities.java.support.collection.LazyMap; + +public class XMLHelperTest { + + @Test + public void testSqlFormat() { + String sqlString="maxkey"; + System.out.println(XMLHelper.prettyPrintXML(sqlString)); + System.out.println(XMLHelper.transformer(sqlString)); + } + +} diff --git a/maxkey-common/src/test/java/org/maxkey/word/CharacterCase.java b/maxkey-common/src/test/java/org/maxkey/word/CharacterCase.java new file mode 100644 index 000000000..89629da5f --- /dev/null +++ b/maxkey-common/src/test/java/org/maxkey/word/CharacterCase.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.word; + +public class CharacterCase { + + /** + * @param args + */ + public static void main(String[] args) { + // TODO Auto-generated method stub + String word="partner "; + + System.out.println(word.toUpperCase()); + System.out.println(word.toLowerCase()); + } + +} diff --git a/maxkey-common/src/test/java/org/maxkey/word/SubStr.java b/maxkey-common/src/test/java/org/maxkey/word/SubStr.java new file mode 100644 index 000000000..9b5427223 --- /dev/null +++ b/maxkey-common/src/test/java/org/maxkey/word/SubStr.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.word; + +public class SubStr { + + /** + * @param args + */ + public static void main(String[] args) { + // TODO Auto-generated method stub + String browser="Chrome/44.0.2369.0"; + System.out.println(browser.indexOf('.')); + } + +} diff --git a/maxkey-common/src/test/resources/log4j2.xml b/maxkey-common/src/test/resources/log4j2.xml new file mode 100644 index 000000000..dfb480698 --- /dev/null +++ b/maxkey-common/src/test/resources/log4j2.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/maxkey-core/build.gradle b/maxkey-core/build.gradle index 56eba0616..df55b93db 100644 --- a/maxkey-core/build.gradle +++ b/maxkey-core/build.gradle @@ -1,6 +1,9 @@ description = "maxkey-core" dependencies { + compile project(":maxkey-common") + compile project(":maxkey-authentications:maxkey-authentication-otp") + //local jars compile fileTree(dir: '../maxkey-lib/', include: '*/*.jar') diff --git a/maxkey-core/src/main/java/org/maxkey/authn/AbstractAuthenticationProvider.java b/maxkey-core/src/main/java/org/maxkey/authn/AbstractAuthenticationProvider.java index 7bb151632..2550cebfb 100644 --- a/maxkey-core/src/main/java/org/maxkey/authn/AbstractAuthenticationProvider.java +++ b/maxkey-core/src/main/java/org/maxkey/authn/AbstractAuthenticationProvider.java @@ -26,7 +26,7 @@ import org.maxkey.authn.support.rememberme.AbstractRemeberMeService; import org.maxkey.configuration.ApplicationConfig; import org.maxkey.constants.ConstantsLoginType; import org.maxkey.crypto.password.PasswordReciprocal; -import org.maxkey.crypto.password.opt.AbstractOptAuthn; +import org.maxkey.crypto.password.otp.AbstractOtpAuthn; import org.maxkey.domain.UserInfo; import org.maxkey.web.WebConstants; import org.maxkey.web.WebContext; @@ -60,7 +60,7 @@ public abstract class AbstractAuthenticationProvider { @Autowired @Qualifier("tfaOptAuthn") - protected AbstractOptAuthn tfaOptAuthn; + protected AbstractOtpAuthn tfaOptAuthn; @Autowired @Qualifier("remeberMeService") @@ -332,7 +332,7 @@ public abstract class AbstractAuthenticationProvider { this.authenticationRealm = authenticationRealm; } - public void setTfaOptAuthn(AbstractOptAuthn tfaOptAuthn) { + public void setTfaOptAuthn(AbstractOtpAuthn tfaOptAuthn) { this.tfaOptAuthn = tfaOptAuthn; } diff --git a/maxkey-core/src/test/java/org/maxkey/crypto/cert/X509CertUtilsTest.java b/maxkey-core/src/test/java/org/maxkey/crypto/cert/X509CertUtilsTest.java index 0dcd153b6..5c639524f 100644 --- a/maxkey-core/src/test/java/org/maxkey/crypto/cert/X509CertUtilsTest.java +++ b/maxkey-core/src/test/java/org/maxkey/crypto/cert/X509CertUtilsTest.java @@ -14,93 +14,91 @@ * limitations under the License. */ - -package org.maxkey.crypto.cert; - -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.security.InvalidKeyException; -import java.security.KeyStore; -import java.security.KeyStoreException; -import java.security.NoSuchAlgorithmException; -import java.security.NoSuchProviderException; -import java.security.PrivateKey; -import java.security.SignatureException; -import java.security.UnrecoverableKeyException; -import java.security.cert.CertificateException; -import java.util.Date; - -import org.junit.Test; - -import sun.security.x509.AlgorithmId; -import sun.security.x509.CertificateAlgorithmId; -import sun.security.x509.CertificateIssuerName; -import sun.security.x509.CertificateSerialNumber; -import sun.security.x509.CertificateSubjectName; -import sun.security.x509.CertificateValidity; -import sun.security.x509.X500Name; -import sun.security.x509.X509CertImpl; -import sun.security.x509.X509CertInfo; - -public class X509CertUtilsTest { - - //@Test - public void test() throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException, UnrecoverableKeyException, InvalidKeyException, NoSuchProviderException, SignatureException { - //// - - String keystoreFile = "c:\\keyStoreFile.jks"; - String caAlias = "caAlias"; - String certToSignAlias = "cert"; - String newAlias = "newAlias"; - - char[] password = new char[] { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h' }; - char[] caPassword = new char[] { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h' }; - char[] certPassword = new char[] { 'a', 'b', 'c', 'd', 'e', 'f', 'g','h' }; - - FileInputStream input = new FileInputStream(keystoreFile); - KeyStore keyStore = KeyStore.getInstance("JKS"); - keyStore.load(input, password); - input.close(); - - PrivateKey caPrivateKey = (PrivateKey) keyStore.getKey(caAlias,caPassword); - java.security.cert.Certificate caCert = keyStore.getCertificate(caAlias); - - byte[] encoded = caCert.getEncoded(); - X509CertImpl caCertImpl = new X509CertImpl(encoded); - - X509CertInfo caCertInfo = (X509CertInfo) caCertImpl.get(X509CertImpl.NAME + "." + X509CertImpl.INFO); - - X500Name issuer = (X500Name) caCertInfo.get(X509CertInfo.SUBJECT + "."+ CertificateIssuerName.DN_NAME); - - java.security.cert.Certificate cert = keyStore.getCertificate(certToSignAlias); - PrivateKey privateKey = (PrivateKey) keyStore.getKey(certToSignAlias,certPassword); - encoded = cert.getEncoded(); - X509CertImpl certImpl = new X509CertImpl(encoded); - X509CertInfo certInfo = (X509CertInfo) certImpl.get(X509CertImpl.NAME+ "." + X509CertImpl.INFO); - - Date firstDate = new Date(); - Date lastDate = new Date(firstDate.getTime() + 365 * 24 * 60 * 60* 1000L); - CertificateValidity interval = new CertificateValidity(firstDate,lastDate); - - certInfo.set(X509CertInfo.VALIDITY, interval); - - certInfo.set(X509CertInfo.SERIAL_NUMBER, new CertificateSerialNumber((int) (firstDate.getTime() / 1000))); - - certInfo.set(X509CertInfo.ISSUER + "." + CertificateSubjectName.DN_NAME,issuer); - - AlgorithmId algorithm = new AlgorithmId(AlgorithmId.md5WithRSAEncryption_oid); - certInfo.set(CertificateAlgorithmId.NAME + "."+ CertificateAlgorithmId.ALGORITHM, algorithm); - X509CertImpl newCert = new X509CertImpl(certInfo); - - newCert.sign(caPrivateKey, "MD5WithRSA"); - - keyStore.setKeyEntry(newAlias, privateKey, certPassword,new java.security.cert.Certificate[] { newCert }); - - FileOutputStream output = new FileOutputStream(keystoreFile); - keyStore.store(output, password); - output.close(); - - } - -} +/* + * package org.maxkey.crypto.cert; + * + * import java.io.FileInputStream; import java.io.FileOutputStream; import + * java.io.IOException; import java.security.InvalidKeyException; import + * java.security.KeyStore; import java.security.KeyStoreException; import + * java.security.NoSuchAlgorithmException; import + * java.security.NoSuchProviderException; import java.security.PrivateKey; + * import java.security.SignatureException; import + * java.security.UnrecoverableKeyException; import + * java.security.cert.CertificateException; import java.util.Date; + * + * import org.junit.Test; + * + * import sun.security.x509.AlgorithmId; import + * sun.security.x509.CertificateAlgorithmId; import + * sun.security.x509.CertificateIssuerName; import + * sun.security.x509.CertificateSerialNumber; import + * sun.security.x509.CertificateSubjectName; import + * sun.security.x509.CertificateValidity; import sun.security.x509.X500Name; + * import sun.security.x509.X509CertImpl; import sun.security.x509.X509CertInfo; + * + * public class X509CertUtilsTest { + * + * //@Test public void test() throws KeyStoreException, + * NoSuchAlgorithmException, CertificateException, IOException, + * UnrecoverableKeyException, InvalidKeyException, NoSuchProviderException, + * SignatureException { //// + * + * String keystoreFile = "c:\\keyStoreFile.jks"; String caAlias = "caAlias"; + * String certToSignAlias = "cert"; String newAlias = "newAlias"; + * + * char[] password = new char[] { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h' }; + * char[] caPassword = new char[] { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h' }; + * char[] certPassword = new char[] { 'a', 'b', 'c', 'd', 'e', 'f', 'g','h' }; + * + * FileInputStream input = new FileInputStream(keystoreFile); KeyStore keyStore + * = KeyStore.getInstance("JKS"); keyStore.load(input, password); input.close(); + * + * PrivateKey caPrivateKey = (PrivateKey) keyStore.getKey(caAlias,caPassword); + * java.security.cert.Certificate caCert = keyStore.getCertificate(caAlias); + * + * byte[] encoded = caCert.getEncoded(); X509CertImpl caCertImpl = new + * X509CertImpl(encoded); + * + * X509CertInfo caCertInfo = (X509CertInfo) caCertImpl.get(X509CertImpl.NAME + + * "." + X509CertImpl.INFO); + * + * X500Name issuer = (X500Name) caCertInfo.get(X509CertInfo.SUBJECT + "."+ + * CertificateIssuerName.DN_NAME); + * + * java.security.cert.Certificate cert = + * keyStore.getCertificate(certToSignAlias); PrivateKey privateKey = + * (PrivateKey) keyStore.getKey(certToSignAlias,certPassword); encoded = + * cert.getEncoded(); X509CertImpl certImpl = new X509CertImpl(encoded); + * X509CertInfo certInfo = (X509CertInfo) certImpl.get(X509CertImpl.NAME+ "." + + * X509CertImpl.INFO); + * + * Date firstDate = new Date(); Date lastDate = new Date(firstDate.getTime() + + * 365 * 24 * 60 * 60* 1000L); CertificateValidity interval = new + * CertificateValidity(firstDate,lastDate); + * + * certInfo.set(X509CertInfo.VALIDITY, interval); + * + * certInfo.set(X509CertInfo.SERIAL_NUMBER, new CertificateSerialNumber((int) + * (firstDate.getTime() / 1000))); + * + * certInfo.set(X509CertInfo.ISSUER + "." + + * CertificateSubjectName.DN_NAME,issuer); + * + * AlgorithmId algorithm = new + * AlgorithmId(AlgorithmId.md5WithRSAEncryption_oid); + * certInfo.set(CertificateAlgorithmId.NAME + "."+ + * CertificateAlgorithmId.ALGORITHM, algorithm); X509CertImpl newCert = new + * X509CertImpl(certInfo); + * + * newCert.sign(caPrivateKey, "MD5WithRSA"); + * + * keyStore.setKeyEntry(newAlias, privateKey, certPassword,new + * java.security.cert.Certificate[] { newCert }); + * + * FileOutputStream output = new FileOutputStream(keystoreFile); + * keyStore.store(output, password); output.close(); + * + * } + * + * } + */ diff --git a/maxkey-core/src/test/java/org/maxkey/crypto/cert/X509V3CertGenTest.java b/maxkey-core/src/test/java/org/maxkey/crypto/cert/X509V3CertGenTest.java index 5cc42df2f..3e0507265 100644 --- a/maxkey-core/src/test/java/org/maxkey/crypto/cert/X509V3CertGenTest.java +++ b/maxkey-core/src/test/java/org/maxkey/crypto/cert/X509V3CertGenTest.java @@ -30,7 +30,7 @@ import org.maxkey.crypto.cert.X509V3CertGen; public class X509V3CertGenTest { - @Test + //@Test public void generateV3() throws Exception { Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider()); KeyPair keyPair =X509V3CertGen.genRSAKeyPair(); diff --git a/maxkey-identitys/maxkey-identity-kafka/build.gradle b/maxkey-identitys/maxkey-identity-kafka/build.gradle index 749e3f01c..fff56801e 100644 --- a/maxkey-identitys/maxkey-identity-kafka/build.gradle +++ b/maxkey-identitys/maxkey-identity-kafka/build.gradle @@ -6,6 +6,7 @@ dependencies { //local jars compile fileTree(dir: '../maxkey-lib/*/', include: '*.jar') + compile project(":maxkey-common") compile project(":maxkey-core") } \ No newline at end of file diff --git a/maxkey-identitys/maxkey-identity-rest/build.gradle b/maxkey-identitys/maxkey-identity-rest/build.gradle index af68ea8de..24a6781a8 100644 --- a/maxkey-identitys/maxkey-identity-rest/build.gradle +++ b/maxkey-identitys/maxkey-identity-rest/build.gradle @@ -8,6 +8,7 @@ dependencies { //local jars compile fileTree(dir: '../maxkey-lib/*/', include: '*.jar') + compile project(":maxkey-common") compile project(":maxkey-core") compile project(":maxkey-persistence") diff --git a/maxkey-identitys/maxkey-identity-scim/build.gradle b/maxkey-identitys/maxkey-identity-scim/build.gradle index ae9bf03bb..590f97c6b 100644 --- a/maxkey-identitys/maxkey-identity-scim/build.gradle +++ b/maxkey-identitys/maxkey-identity-scim/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") diff --git a/maxkey-persistence/build.gradle b/maxkey-persistence/build.gradle index 4beee0e74..63ae6e95d 100644 --- a/maxkey-persistence/build.gradle +++ b/maxkey-persistence/build.gradle @@ -4,6 +4,7 @@ dependencies { //local jars compile fileTree(dir: '../maxkey-lib/*/', include: '*.jar') + compile project(":maxkey-common") compile project(":maxkey-core") compile project(":maxkey-identitys:maxkey-identity-kafka") } \ No newline at end of file diff --git a/maxkey-protocols/maxkey-protocol-authorize/build.gradle b/maxkey-protocols/maxkey-protocol-authorize/build.gradle index 92420f147..60a26e713 100644 --- a/maxkey-protocols/maxkey-protocol-authorize/build.gradle +++ b/maxkey-protocols/maxkey-protocol-authorize/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") //compileOnly project(":maxkey-protocols:maxkey-protocol-oauth-2.0") diff --git a/maxkey-protocols/maxkey-protocol-cas/build.gradle b/maxkey-protocols/maxkey-protocol-cas/build.gradle index cf8792862..cb4afd623 100644 --- a/maxkey-protocols/maxkey-protocol-cas/build.gradle +++ b/maxkey-protocols/maxkey-protocol-cas/build.gradle @@ -13,7 +13,7 @@ dependencies { // https://mvnrepository.com/artifact/org.pac4j/pac4j-cas testCompile group: 'org.pac4j', name: 'pac4j-cas', version: '3.8.3' - + compile project(":maxkey-common") compile project(":maxkey-core") compile project(":maxkey-persistence") compile project(":maxkey-protocols:maxkey-protocol-authorize") diff --git a/maxkey-protocols/maxkey-protocol-desktop/build.gradle b/maxkey-protocols/maxkey-protocol-desktop/build.gradle index 2439c271b..0812aa96e 100644 --- a/maxkey-protocols/maxkey-protocol-desktop/build.gradle +++ b/maxkey-protocols/maxkey-protocol-desktop/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-authorize") diff --git a/maxkey-protocols/maxkey-protocol-extendapi/build.gradle b/maxkey-protocols/maxkey-protocol-extendapi/build.gradle index 7e53d8f15..bfcead438 100644 --- a/maxkey-protocols/maxkey-protocol-extendapi/build.gradle +++ b/maxkey-protocols/maxkey-protocol-extendapi/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-authorize") diff --git a/maxkey-protocols/maxkey-protocol-formbased/build.gradle b/maxkey-protocols/maxkey-protocol-formbased/build.gradle index 9071ff4ee..2d4bff3e4 100644 --- a/maxkey-protocols/maxkey-protocol-formbased/build.gradle +++ b/maxkey-protocols/maxkey-protocol-formbased/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-authorize") diff --git a/maxkey-protocols/maxkey-protocol-jwt/build.gradle b/maxkey-protocols/maxkey-protocol-jwt/build.gradle index 6410efba5..b2a2de5da 100644 --- a/maxkey-protocols/maxkey-protocol-jwt/build.gradle +++ b/maxkey-protocols/maxkey-protocol-jwt/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-authorize") diff --git a/maxkey-protocols/maxkey-protocol-oauth-2.0/build.gradle b/maxkey-protocols/maxkey-protocol-oauth-2.0/build.gradle index 66fd5d008..b63103b04 100644 --- a/maxkey-protocols/maxkey-protocol-oauth-2.0/build.gradle +++ b/maxkey-protocols/maxkey-protocol-oauth-2.0/build.gradle @@ -4,6 +4,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-authorize") diff --git a/maxkey-protocols/maxkey-protocol-saml-2.0/build.gradle b/maxkey-protocols/maxkey-protocol-saml-2.0/build.gradle index 9f373012a..207bc0098 100644 --- a/maxkey-protocols/maxkey-protocol-saml-2.0/build.gradle +++ b/maxkey-protocols/maxkey-protocol-saml-2.0/build.gradle @@ -4,6 +4,7 @@ dependencies { //local jars compile fileTree(dir: '../maxkey-lib/*/', include: '*.jar') + compile project(":maxkey-common") compile project(":maxkey-core") compile project(":maxkey-persistence") } \ No newline at end of file diff --git a/maxkey-protocols/maxkey-protocol-tokenbased/build.gradle b/maxkey-protocols/maxkey-protocol-tokenbased/build.gradle index fb1324922..007b799f6 100644 --- a/maxkey-protocols/maxkey-protocol-tokenbased/build.gradle +++ b/maxkey-protocols/maxkey-protocol-tokenbased/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-authorize") diff --git a/maxkey-web-manage/.gitignore b/maxkey-web-manage/.gitignore index 84c048a73..83ccc54d0 100644 --- a/maxkey-web-manage/.gitignore +++ b/maxkey-web-manage/.gitignore @@ -1 +1,2 @@ /build/ +/bin/ diff --git a/maxkey-web-manage/build.gradle b/maxkey-web-manage/build.gradle index 024858fdb..05d130b64 100644 --- a/maxkey-web-manage/build.gradle +++ b/maxkey-web-manage/build.gradle @@ -60,8 +60,10 @@ jib { */ dependencies { + compile project(":maxkey-common") compile project(":maxkey-core") compile project(":maxkey-authentications:maxkey-authentication-captcha") + compile project(":maxkey-authentications:maxkey-authentication-otp") compile project(":maxkey-persistence") compile project(":maxkey-protocols:maxkey-protocol-oauth-2.0") compile project(":maxkey-protocols:maxkey-protocol-saml-2.0") diff --git a/maxkey-web-manage/src/main/java/org/maxkey/MaxKeyMgtConfig.java b/maxkey-web-manage/src/main/java/org/maxkey/MaxKeyMgtConfig.java index 54be409d0..cc83d4f8d 100644 --- a/maxkey-web-manage/src/main/java/org/maxkey/MaxKeyMgtConfig.java +++ b/maxkey-web-manage/src/main/java/org/maxkey/MaxKeyMgtConfig.java @@ -25,7 +25,7 @@ import org.maxkey.authz.oauth2.provider.token.store.InMemoryTokenStore; import org.maxkey.authz.oauth2.provider.token.store.JdbcTokenStore; import org.maxkey.authz.oauth2.provider.token.store.RedisTokenStore; import org.maxkey.constants.ConstantsProperties; -import org.maxkey.crypto.password.opt.impl.TimeBasedOtpAuthn; +import org.maxkey.crypto.password.otp.impl.TimeBasedOtpAuthn; import org.maxkey.jobs.DynamicGroupsJob; import org.maxkey.persistence.redis.RedisConnectionFactory; import org.maxkey.persistence.service.GroupsService; @@ -113,7 +113,7 @@ public class MaxKeyMgtConfig implements InitializingBean { _logger.debug("JdbcAuthenticationRealm inited."); return authenticationRealm; } - + @Bean(name = "tfaOptAuthn") public TimeBasedOtpAuthn tfaOptAuthn() { TimeBasedOtpAuthn tfaOptAuthn = new TimeBasedOtpAuthn(); diff --git a/maxkey-web-manage/src/main/resources/application.properties b/maxkey-web-manage/src/main/resources/application.properties index 8e5d98634..529bb66e3 100644 --- a/maxkey-web-manage/src/main/resources/application.properties +++ b/maxkey-web-manage/src/main/resources/application.properties @@ -2,7 +2,7 @@ #application application.title=MaxKey application.name=MaxKey-Mgt -application.formatted-version=v2.5.0 GA +application.formatted-version=v2.6.0 GA #server config #server port server.port=9521 diff --git a/maxkey-web-maxkey/.gitignore b/maxkey-web-maxkey/.gitignore index 84c048a73..83ccc54d0 100644 --- a/maxkey-web-maxkey/.gitignore +++ b/maxkey-web-maxkey/.gitignore @@ -1 +1,2 @@ /build/ +/bin/ diff --git a/maxkey-web-maxkey/build.gradle b/maxkey-web-maxkey/build.gradle index 8601cec37..e476e78fe 100644 --- a/maxkey-web-maxkey/build.gradle +++ b/maxkey-web-maxkey/build.gradle @@ -61,12 +61,14 @@ jib { */ dependencies { + compile project(":maxkey-common") compile project(":maxkey-core") compile project(":maxkey-persistence") compile project(":maxkey-authentications:maxkey-authentication-core") compile project(":maxkey-authentications:maxkey-authentication-social") compile project(":maxkey-authentications:maxkey-authentication-captcha") + compile project(":maxkey-authentications:maxkey-authentication-otp") compile project(":maxkey-protocols:maxkey-protocol-authorize") 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 43ce8a397..592d32933 100644 --- a/maxkey-web-maxkey/src/main/java/org/maxkey/MaxKeyConfig.java +++ b/maxkey-web-maxkey/src/main/java/org/maxkey/MaxKeyConfig.java @@ -29,15 +29,15 @@ import org.maxkey.authn.support.kerberos.KerberosProxy; import org.maxkey.authn.support.kerberos.RemoteKerberosService; import org.maxkey.constants.ConstantsPersistence; import org.maxkey.constants.ConstantsProperties; -import org.maxkey.crypto.password.opt.AbstractOptAuthn; -import org.maxkey.crypto.password.opt.algorithm.KeyUriFormat; -import org.maxkey.crypto.password.opt.impl.MailOtpAuthn; -import org.maxkey.crypto.password.opt.impl.SmsOtpAuthn; -import org.maxkey.crypto.password.opt.impl.TimeBasedOtpAuthn; -import org.maxkey.crypto.password.opt.impl.sms.SmsOtpAuthnAliyun; -import org.maxkey.crypto.password.opt.impl.sms.SmsOtpAuthnTencentCloud; -import org.maxkey.crypto.password.opt.impl.sms.SmsOtpAuthnYunxin; -import org.maxkey.crypto.password.opt.token.RedisOptTokenStore; +import org.maxkey.crypto.password.otp.AbstractOtpAuthn; +import org.maxkey.crypto.password.otp.algorithm.KeyUriFormat; +import org.maxkey.crypto.password.otp.impl.MailOtpAuthn; +import org.maxkey.crypto.password.otp.impl.SmsOtpAuthn; +import org.maxkey.crypto.password.otp.impl.TimeBasedOtpAuthn; +import org.maxkey.crypto.password.otp.impl.sms.SmsOtpAuthnAliyun; +import org.maxkey.crypto.password.otp.impl.sms.SmsOtpAuthnTencentCloud; +import org.maxkey.crypto.password.otp.impl.sms.SmsOtpAuthnYunxin; +import org.maxkey.crypto.password.otp.token.RedisOtpTokenStore; import org.maxkey.persistence.ldap.ActiveDirectoryUtils; import org.maxkey.persistence.ldap.LdapUtils; import org.maxkey.persistence.redis.RedisConnectionFactory; @@ -156,15 +156,22 @@ public class MaxKeyConfig implements InitializingBean { return authenticationRealm; } + @Bean(name = "tfaOptAuthn") + public TimeBasedOtpAuthn tfaOptAuthn() { + TimeBasedOtpAuthn tfaOptAuthn = new TimeBasedOtpAuthn(); + _logger.debug("TimeBasedOtpAuthn inited."); + return tfaOptAuthn; + } + //default tfaOptAuthn @Bean(name = "tfaOptAuthn") - public AbstractOptAuthn tfaOptAuthn( + public AbstractOtpAuthn tfaOptAuthn( @Value("${config.login.mfa.type}")String mfaType, @Value("${config.server.persistence}") int persistence, MailOtpAuthn tfaMailOptAuthn, RedisConnectionFactory redisConnFactory) { - AbstractOptAuthn tfaOptAuthn = null; + AbstractOtpAuthn tfaOptAuthn = null; if(mfaType.equalsIgnoreCase("SmsOtpAuthnAliyun")) { tfaOptAuthn = new SmsOtpAuthnAliyun(); _logger.debug("SmsOtpAuthnAliyun inited."); @@ -183,7 +190,7 @@ public class MaxKeyConfig implements InitializingBean { } if (persistence == ConstantsPersistence.REDIS) { - RedisOptTokenStore redisOptTokenStore = new RedisOptTokenStore(redisConnFactory); + RedisOtpTokenStore redisOptTokenStore = new RedisOtpTokenStore(redisConnFactory); tfaOptAuthn.setOptTokenStore(redisOptTokenStore); } @@ -219,7 +226,7 @@ public class MaxKeyConfig implements InitializingBean { smsOtpAuthn = new SmsOtpAuthnYunxin(); } if (persistence == ConstantsPersistence.REDIS) { - RedisOptTokenStore redisOptTokenStore = new RedisOptTokenStore(redisConnFactory); + RedisOtpTokenStore redisOptTokenStore = new RedisOtpTokenStore(redisConnFactory); smsOtpAuthn.setOptTokenStore(redisOptTokenStore); } smsOtpAuthn.initPropertys(); diff --git a/maxkey-web-maxkey/src/main/java/org/maxkey/web/contorller/ForgotPasswordContorller.java b/maxkey-web-maxkey/src/main/java/org/maxkey/web/contorller/ForgotPasswordContorller.java index 410b9bfc2..ce13ed0ea 100644 --- a/maxkey-web-maxkey/src/main/java/org/maxkey/web/contorller/ForgotPasswordContorller.java +++ b/maxkey-web-maxkey/src/main/java/org/maxkey/web/contorller/ForgotPasswordContorller.java @@ -20,7 +20,7 @@ package org.maxkey.web.contorller; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.maxkey.crypto.password.opt.AbstractOptAuthn; +import org.maxkey.crypto.password.otp.AbstractOtpAuthn; import org.maxkey.domain.UserInfo; import org.maxkey.persistence.service.UserInfoService; import org.maxkey.web.WebConstants; @@ -63,11 +63,11 @@ public class ForgotPasswordContorller { @Autowired @Qualifier("tfaMailOptAuthn") - protected AbstractOptAuthn tfaMailOptAuthn; + protected AbstractOtpAuthn tfaMailOptAuthn; @Autowired @Qualifier("tfaMobileOptAuthn") - protected AbstractOptAuthn tfaMobileOptAuthn; + protected AbstractOtpAuthn tfaMobileOptAuthn; @RequestMapping(value = { "/forward" }) diff --git a/maxkey-web-maxkey/src/main/java/org/maxkey/web/contorller/OneTimePasswordController.java b/maxkey-web-maxkey/src/main/java/org/maxkey/web/contorller/OneTimePasswordController.java index 75588b626..d0e4387ae 100644 --- a/maxkey-web-maxkey/src/main/java/org/maxkey/web/contorller/OneTimePasswordController.java +++ b/maxkey-web-maxkey/src/main/java/org/maxkey/web/contorller/OneTimePasswordController.java @@ -22,8 +22,8 @@ import java.util.UUID; import org.apache.commons.codec.binary.Hex; import org.maxkey.crypto.Base32Utils; import org.maxkey.crypto.password.PasswordReciprocal; -import org.maxkey.crypto.password.opt.algorithm.KeyUriFormat; -import org.maxkey.crypto.password.opt.algorithm.OtpSecret; +import org.maxkey.crypto.password.otp.algorithm.KeyUriFormat; +import org.maxkey.crypto.password.otp.algorithm.OtpSecret; import org.maxkey.domain.UserInfo; import org.maxkey.persistence.service.UserInfoService; import org.maxkey.util.RQCodeUtils; diff --git a/maxkey-web-maxkey/src/main/java/org/maxkey/web/endpoint/LoginEndpoint.java b/maxkey-web-maxkey/src/main/java/org/maxkey/web/endpoint/LoginEndpoint.java index f7940da63..af01d31cb 100644 --- a/maxkey-web-maxkey/src/main/java/org/maxkey/web/endpoint/LoginEndpoint.java +++ b/maxkey-web-maxkey/src/main/java/org/maxkey/web/endpoint/LoginEndpoint.java @@ -32,7 +32,7 @@ import org.maxkey.authn.support.socialsignon.service.SocialSignOnProviderService import org.maxkey.authn.support.wsfederation.WsFederationConstants; import org.maxkey.configuration.ApplicationConfig; import org.maxkey.constants.ConstantsStatus; -import org.maxkey.crypto.password.opt.AbstractOptAuthn; +import org.maxkey.crypto.password.otp.AbstractOtpAuthn; import org.maxkey.domain.UserInfo; import org.maxkey.persistence.service.UserInfoService; import org.maxkey.util.StringUtils; @@ -93,7 +93,7 @@ public class LoginEndpoint { @Autowired @Qualifier("tfaOptAuthn") - protected AbstractOptAuthn tfaOptAuthn; + protected AbstractOtpAuthn tfaOptAuthn; /* @Autowired diff --git a/maxkey-web-maxkey/src/main/resources/application.properties b/maxkey-web-maxkey/src/main/resources/application.properties index 1316de960..c2610e4f7 100644 --- a/maxkey-web-maxkey/src/main/resources/application.properties +++ b/maxkey-web-maxkey/src/main/resources/application.properties @@ -2,7 +2,7 @@ #application application.title=MaxKey application.name=MaxKey -application.formatted-version=v2.5.0 GA +application.formatted-version=v2.6.0 GA #server port #server.port=80 diff --git a/setEnvVars.bat b/setEnvVars.bat index c6b3df05f..69acfda56 100644 --- a/setEnvVars.bat +++ b/setEnvVars.bat @@ -1,7 +1,7 @@ echo off echo set env -set JAVA_HOME=D:\IDE\jdk1.8.0_202 -set GRADLE_HOME=D:\IDE\gradle-6.5.1 +set JAVA_HOME=C:\IDES\jdk-15.0.1 +set GRADLE_HOME=C:\IDES\gradle-6.7 call %JAVA_HOME%/bin/java -version call %GRADLE_HOME%/bin/gradle -version diff --git a/settings.gradle b/settings.gradle index 15558f921..0ccdffb2b 100644 --- a/settings.gradle +++ b/settings.gradle @@ -4,12 +4,14 @@ rootProject.name = 'MaxKey' //Common +include 'maxkey-common' include 'maxkey-core' include 'maxkey-persistence' //include 'maxkey-authentications' include 'maxkey-authentications:maxkey-authentication-core' include 'maxkey-authentications:maxkey-authentication-captcha' include 'maxkey-authentications:maxkey-authentication-social' +include 'maxkey-authentications:maxkey-authentication-otp' //identity include 'maxkey-identitys:maxkey-identity-scim'