maxkey-entity & maxkey-commons 拆分

maxkey-cache
maxkey-core
maxkey-crypto
maxkey-ldap
This commit is contained in:
MaxKey
2025-07-27 08:36:33 +08:00
parent c6224f9f9d
commit ca90c0ba93
208 changed files with 608 additions and 274 deletions

View File

@@ -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")
}

View File

@@ -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")

View File

@@ -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")

View 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')
}

View File

@@ -1,6 +1,8 @@
description = "maxkey-common"
dependencies {
implementation project(":maxkey-commons:maxkey-crypto")
//local jars
implementation fileTree(dir: '../maxkey-lib/', include: '*/*.jar')

View File

@@ -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());
}
}

View File

@@ -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();
}
}
}

View 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')
}

View File

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

View File

@@ -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("-----------------------------------------------------------");

View File

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 66 KiB

View 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>

View File

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

View File

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

View File

@@ -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();
}
}
}
}

View File

@@ -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