mirror of
https://gitee.com/dromara/MaxKey.git
synced 2026-05-14 04:22:08 +08:00
maxkey-entity & maxkey-commons 拆分
maxkey-cache maxkey-core maxkey-crypto maxkey-ldap
This commit is contained in:
@@ -6,9 +6,14 @@ dependencies {
|
||||
//local jars
|
||||
implementation fileTree(dir: '../maxkey-lib/', include: '*/*.jar')
|
||||
|
||||
implementation project(":maxkey-commons:maxkey-cache")
|
||||
implementation project(":maxkey-commons:maxkey-common")
|
||||
implementation project(":maxkey-commons:maxkey-core")
|
||||
implementation project(":maxkey-commons:maxkey-crypto")
|
||||
|
||||
implementation project(":maxkey-entity")
|
||||
implementation project(":maxkey-persistence")
|
||||
|
||||
implementation project(":maxkey-starter:maxkey-starter-otp")
|
||||
|
||||
}
|
||||
@@ -6,7 +6,12 @@ dependencies {
|
||||
//local jars
|
||||
implementation fileTree(dir: '../maxkey-lib/', include: '*/*.jar')
|
||||
|
||||
implementation project(":maxkey-commons:maxkey-cache")
|
||||
implementation project(":maxkey-commons:maxkey-common")
|
||||
implementation project(":maxkey-commons:maxkey-core")
|
||||
implementation project(":maxkey-commons:maxkey-crypto")
|
||||
implementation project(":maxkey-commons:maxkey-ldap")
|
||||
|
||||
implementation project(":maxkey-entity")
|
||||
implementation project(":maxkey-persistence")
|
||||
|
||||
|
||||
@@ -6,7 +6,12 @@ dependencies {
|
||||
//local jars
|
||||
implementation fileTree(dir: '../maxkey-lib/', include: '*/*.jar')
|
||||
|
||||
implementation project(":maxkey-commons:maxkey-cache")
|
||||
implementation project(":maxkey-commons:maxkey-common")
|
||||
implementation project(":maxkey-commons:maxkey-core")
|
||||
implementation project(":maxkey-commons:maxkey-crypto")
|
||||
implementation project(":maxkey-commons:maxkey-ldap")
|
||||
|
||||
implementation project(":maxkey-entity")
|
||||
implementation project(":maxkey-persistence")
|
||||
|
||||
|
||||
10
maxkey-commons/maxkey-cache/build.gradle
Normal file
10
maxkey-commons/maxkey-cache/build.gradle
Normal file
@@ -0,0 +1,10 @@
|
||||
description = "maxkey-cache"
|
||||
|
||||
dependencies {
|
||||
implementation project(":maxkey-commons:maxkey-common")
|
||||
implementation project(":maxkey-commons:maxkey-crypto")
|
||||
|
||||
//local jars
|
||||
implementation fileTree(dir: '../maxkey-lib/', include: '*/*.jar')
|
||||
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
description = "maxkey-common"
|
||||
|
||||
dependencies {
|
||||
implementation project(":maxkey-commons:maxkey-crypto")
|
||||
|
||||
//local jars
|
||||
implementation fileTree(dir: '../maxkey-lib/', include: '*/*.jar')
|
||||
|
||||
|
||||
@@ -17,8 +17,6 @@
|
||||
|
||||
package org.dromara.maxkey.constants;
|
||||
|
||||
import org.dromara.maxkey.configuration.ApplicationConfig;
|
||||
|
||||
public class ConstsDatabase {
|
||||
|
||||
public static final String MYSQL = "MySQL";
|
||||
@@ -30,9 +28,6 @@ public class ConstsDatabase {
|
||||
public static final String MSSQLSERVER = "SQL Server";
|
||||
|
||||
public static final String DB2 = "db2";
|
||||
|
||||
public static boolean compare(String databaseProduct) {
|
||||
return databaseProduct.equalsIgnoreCase(ApplicationConfig.getDatabaseProduct());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -26,6 +26,7 @@ import java.util.Random;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.dromara.maxkey.crypto.Base64Utils;
|
||||
import org.dromara.maxkey.crypto.ReciprocalUtils.Algorithm;
|
||||
|
||||
public class StringGenerator {
|
||||
|
||||
@@ -169,4 +170,22 @@ public class StringGenerator {
|
||||
return uuidString.matches(uuidRegex);
|
||||
}
|
||||
|
||||
/**
|
||||
* generate Key for DES , AES , Blowfish and DESede ,default is unique string
|
||||
* @param algorithm
|
||||
* @return
|
||||
*/
|
||||
public static String generateKey(String algorithm) {
|
||||
if (algorithm.equals(Algorithm.DES)) {
|
||||
return (new StringGenerator(8)).randomGenerate();
|
||||
} else if (algorithm.equals(Algorithm.AES)) {
|
||||
return (new StringGenerator(16)).randomGenerate();
|
||||
} else if (algorithm.equals(Algorithm.Blowfish)) {
|
||||
return (new StringGenerator(16)).randomGenerate();
|
||||
} else if (algorithm.equals(Algorithm.DESede)) {
|
||||
return (new StringGenerator(24)).randomGenerate();
|
||||
} else {
|
||||
return (new StringGenerator()).uniqueGenerate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
12
maxkey-commons/maxkey-core/build.gradle
Normal file
12
maxkey-commons/maxkey-core/build.gradle
Normal file
@@ -0,0 +1,12 @@
|
||||
description = "maxkey-core"
|
||||
|
||||
dependencies {
|
||||
implementation project(":maxkey-commons:maxkey-common")
|
||||
implementation project(":maxkey-commons:maxkey-crypto")
|
||||
|
||||
implementation project(":maxkey-entity")
|
||||
|
||||
//local jars
|
||||
implementation fileTree(dir: '../maxkey-lib/', include: '*/*.jar')
|
||||
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
Manifest-Version: 1.0
|
||||
Class-Path:
|
||||
|
||||
@@ -537,6 +537,10 @@ public final class WebContext {
|
||||
return new ModelAndView("forward:" + forwardUrl);
|
||||
}
|
||||
|
||||
public static boolean compare(String databaseProduct) {
|
||||
return databaseProduct.equalsIgnoreCase(ApplicationConfig.getDatabaseProduct());
|
||||
}
|
||||
|
||||
public static String version() {
|
||||
StringBuffer version = new StringBuffer();
|
||||
version.append("-----------------------------------------------------------");
|
||||
|
Before Width: | Height: | Size: 66 KiB After Width: | Height: | Size: 66 KiB |
37
maxkey-commons/maxkey-core/src/test/resources/log4j2.xml
Normal file
37
maxkey-commons/maxkey-core/src/test/resources/log4j2.xml
Normal file
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--DOCTYPE log4j:configuration SYSTEM "log4j.dtd" -->
|
||||
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"
|
||||
status="INFO" monitorInterval="300"
|
||||
>
|
||||
<appenders>
|
||||
|
||||
<Console name="consolePrint" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="%d{YYYY-MM-dd HH:mm:ss,SSS} %-5level [%t] %logger{36}:%L - %msg%n" />
|
||||
</Console>
|
||||
|
||||
<!-- 输出到文件,按天或者超过128MB分割 每天进行归档yyyy-MM-dd -->
|
||||
<RollingFile name="RollingFile" fileName="logs/maxkey.log" filePattern="logs/$${date:yyyyMMdd}/maxkey-%d{yyyy-MM-dd}-%i.log.gz">
|
||||
<!-- 需要记录的级别 -->
|
||||
<!-- <ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY" /> -->
|
||||
<PatternLayout pattern="%d{YYYY-MM-dd HH:mm:ss,SSS} %-5level [%t] %logger{36}:%L - %msg%n" />
|
||||
<Policies>
|
||||
<OnStartupTriggeringPolicy />
|
||||
<TimeBasedTriggeringPolicy />
|
||||
<SizeBasedTriggeringPolicy size="128 MB" />
|
||||
</Policies>
|
||||
<DefaultRolloverStrategy max="100"/>
|
||||
</RollingFile>
|
||||
</appenders>
|
||||
|
||||
<loggers>
|
||||
<Logger name="org.springframework" level="INFO"></Logger>
|
||||
<Logger name="org.apache.logging" level="INFO"></Logger>
|
||||
<Logger name="org.maxkey" level="DEBUG"></Logger>
|
||||
|
||||
|
||||
<root level="INFO">
|
||||
<appender-ref ref="consolePrint" />
|
||||
<appender-ref ref="RollingFile" />
|
||||
</root>
|
||||
</loggers>
|
||||
</log4j:configuration>
|
||||
8
maxkey-commons/maxkey-crypto/build.gradle
Normal file
8
maxkey-commons/maxkey-crypto/build.gradle
Normal file
@@ -0,0 +1,8 @@
|
||||
description = "maxkey-crypto"
|
||||
|
||||
dependencies {
|
||||
//local jars
|
||||
implementation fileTree(dir: '../maxkey-lib/', include: '*/*.jar')
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
Manifest-Version: 1.0
|
||||
Class-Path:
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
package org.dromara.maxkey.crypto;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.security.Provider;
|
||||
import java.security.Security;
|
||||
|
||||
@@ -30,8 +31,6 @@ import javax.crypto.spec.SecretKeySpec;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.dromara.maxkey.util.Instance;
|
||||
import org.dromara.maxkey.util.StringGenerator;
|
||||
|
||||
/**
|
||||
* Reciprocal cipher or Symmetric-key algorithm
|
||||
@@ -59,7 +58,7 @@ public final class ReciprocalUtils {
|
||||
static {
|
||||
if(System.getProperty("java.version").startsWith("1.8")) {
|
||||
try {
|
||||
Security.addProvider((Provider)Instance.newInstance("com.sun.crypto.provider.SunJCE"));
|
||||
Security.addProvider((Provider)newInstance("com.sun.crypto.provider.SunJCE"));
|
||||
}catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -234,18 +233,17 @@ public final class ReciprocalUtils {
|
||||
public static String aesDecoder(String ciphers, String secretKey) {
|
||||
return decoderHex(ciphers, secretKey, Algorithm.AES);
|
||||
}
|
||||
|
||||
public static Object newInstance(String className) {
|
||||
Class<?> cls;
|
||||
try {
|
||||
cls = Class.forName(className);
|
||||
Constructor<?> constructor = cls.getConstructor();
|
||||
return constructor.newInstance();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
|
||||
public static String generateKey(String algorithm) {
|
||||
if (algorithm.equals(Algorithm.DES)) {
|
||||
return (new StringGenerator(8)).randomGenerate();
|
||||
} else if (algorithm.equals(Algorithm.AES)) {
|
||||
return (new StringGenerator(16)).randomGenerate();
|
||||
} else if (algorithm.equals(Algorithm.Blowfish)) {
|
||||
return (new StringGenerator(16)).randomGenerate();
|
||||
} else if (algorithm.equals(Algorithm.DESede)) {
|
||||
return (new StringGenerator(24)).randomGenerate();
|
||||
} else {
|
||||
return (new StringGenerator()).uniqueGenerate();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,9 @@ package org.dromara.maxkey.crypto.jose.keystore;
|
||||
******************************************************************************/
|
||||
|
||||
import com.google.common.io.CharStreams;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.nimbusds.jose.JOSEException;
|
||||
import com.nimbusds.jose.jwk.JWK;
|
||||
import com.nimbusds.jose.jwk.JWKSet;
|
||||
@@ -31,7 +34,6 @@ import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.dromara.maxkey.crypto.RSAUtils;
|
||||
import org.dromara.maxkey.pretty.PrettyFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.core.io.Resource;
|
||||
@@ -184,12 +186,21 @@ public class JWKSetKeyStore {
|
||||
|
||||
}else {
|
||||
//RSA Only
|
||||
metaDataString.append(PrettyFactory.getJsonPretty().format(
|
||||
jwkSet.toPublicJWKSet().toString()));
|
||||
metaDataString.append(format(jwkSet.toPublicJWKSet().toString()));
|
||||
}
|
||||
}else {
|
||||
metaDataString.append("RSA Only");
|
||||
}
|
||||
return metaDataString.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param jsonString
|
||||
* @return formated json string
|
||||
*/
|
||||
public String format(String jsonString){
|
||||
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||
return gson.toJson(JsonParser.parseString(jsonString));
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user