diff --git a/devkit-utils/README.md b/common-toolbox/README.md similarity index 100% rename from devkit-utils/README.md rename to common-toolbox/README.md diff --git a/devkit-utils/build.gradle.kts b/common-toolbox/build.gradle.kts similarity index 90% rename from devkit-utils/build.gradle.kts rename to common-toolbox/build.gradle.kts index 3d6bcd2..37b5e9d 100644 --- a/devkit-utils/build.gradle.kts +++ b/common-toolbox/build.gradle.kts @@ -64,14 +64,14 @@ tasks.test { publishing { publications { - create("devkitUtils") { + create("commonToolbox") { groupId = group.toString() - artifactId = "devkit-utils" + artifactId = "common-toolbox" version = artefactVersion pom { name = "OnixByte Common Toolbox" - description = "The utils module of JDevKit." + description = "The utils module of OnixByte toolbox." url = projectUrl licenses { @@ -82,8 +82,8 @@ publishing { } scm { - connection = "scm:git:git://github.com:onixbyte/onixbyte-toolbox.git" - developerConnection = "scm:git:git://github.com:onixbyte/onixbyte-toolbox.git" + connection = "scm:git:git://github.com:OnixByte/JDevKit.git" + developerConnection = "scm:git:git://github.com:OnixByte/JDevKit.git" url = projectGithubUrl } @@ -107,7 +107,7 @@ publishing { from(components["java"]) signing { - sign(publishing.publications["devkitUtils"]) + sign(publishing.publications["commonToolbox"]) } } @@ -122,4 +122,4 @@ publishing { } } } -} +} \ No newline at end of file diff --git a/devkit-utils/src/main/java/com/onixbyte/devkit/utils/AesUtil.java b/common-toolbox/src/main/java/com/onixbyte/common/util/AesUtil.java similarity index 99% rename from devkit-utils/src/main/java/com/onixbyte/devkit/utils/AesUtil.java rename to common-toolbox/src/main/java/com/onixbyte/common/util/AesUtil.java index 00619a3..65b02a9 100644 --- a/devkit-utils/src/main/java/com/onixbyte/devkit/utils/AesUtil.java +++ b/common-toolbox/src/main/java/com/onixbyte/common/util/AesUtil.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.onixbyte.devkit.utils; +package com.onixbyte.common.util; import javax.crypto.Cipher; import javax.crypto.spec.IvParameterSpec; diff --git a/devkit-utils/src/main/java/com/onixbyte/devkit/utils/Base64Util.java b/common-toolbox/src/main/java/com/onixbyte/common/util/Base64Util.java similarity index 99% rename from devkit-utils/src/main/java/com/onixbyte/devkit/utils/Base64Util.java rename to common-toolbox/src/main/java/com/onixbyte/common/util/Base64Util.java index 93d0347..51084d9 100644 --- a/devkit-utils/src/main/java/com/onixbyte/devkit/utils/Base64Util.java +++ b/common-toolbox/src/main/java/com/onixbyte/common/util/Base64Util.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.onixbyte.devkit.utils; +package com.onixbyte.common.util; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; @@ -209,4 +209,4 @@ public static String decodeUrlComponents(String value) { private static Base64.Decoder urlDecoder; -} \ No newline at end of file +} diff --git a/devkit-utils/src/main/java/com/onixbyte/devkit/utils/BoolUtil.java b/common-toolbox/src/main/java/com/onixbyte/common/util/BoolUtil.java similarity index 98% rename from devkit-utils/src/main/java/com/onixbyte/devkit/utils/BoolUtil.java rename to common-toolbox/src/main/java/com/onixbyte/common/util/BoolUtil.java index 4bf81da..858b750 100644 --- a/devkit-utils/src/main/java/com/onixbyte/devkit/utils/BoolUtil.java +++ b/common-toolbox/src/main/java/com/onixbyte/common/util/BoolUtil.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.onixbyte.devkit.utils; +package com.onixbyte.common.util; import java.util.Arrays; import java.util.Objects; diff --git a/devkit-utils/src/main/java/com/onixbyte/devkit/utils/BranchUtil.java b/common-toolbox/src/main/java/com/onixbyte/common/util/BranchUtil.java similarity index 99% rename from devkit-utils/src/main/java/com/onixbyte/devkit/utils/BranchUtil.java rename to common-toolbox/src/main/java/com/onixbyte/common/util/BranchUtil.java index f493a70..a2c9ca8 100644 --- a/devkit-utils/src/main/java/com/onixbyte/devkit/utils/BranchUtil.java +++ b/common-toolbox/src/main/java/com/onixbyte/common/util/BranchUtil.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.onixbyte.devkit.utils; +package com.onixbyte.common.util; import java.util.Objects; import java.util.function.BooleanSupplier; diff --git a/devkit-utils/src/main/java/com/onixbyte/devkit/utils/CollectionUtil.java b/common-toolbox/src/main/java/com/onixbyte/common/util/CollectionUtil.java similarity index 99% rename from devkit-utils/src/main/java/com/onixbyte/devkit/utils/CollectionUtil.java rename to common-toolbox/src/main/java/com/onixbyte/common/util/CollectionUtil.java index fd4534a..3a72dd9 100644 --- a/devkit-utils/src/main/java/com/onixbyte/devkit/utils/CollectionUtil.java +++ b/common-toolbox/src/main/java/com/onixbyte/common/util/CollectionUtil.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.onixbyte.devkit.utils; +package com.onixbyte.common.util; import java.util.ArrayList; import java.util.Collection; diff --git a/devkit-utils/src/main/java/com/onixbyte/devkit/utils/HashUtil.java b/common-toolbox/src/main/java/com/onixbyte/common/util/HashUtil.java similarity index 99% rename from devkit-utils/src/main/java/com/onixbyte/devkit/utils/HashUtil.java rename to common-toolbox/src/main/java/com/onixbyte/common/util/HashUtil.java index 8fa7156..168729a 100644 --- a/devkit-utils/src/main/java/com/onixbyte/devkit/utils/HashUtil.java +++ b/common-toolbox/src/main/java/com/onixbyte/common/util/HashUtil.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.onixbyte.devkit.utils; +package com.onixbyte.common.util; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; diff --git a/devkit-utils/src/main/java/com/onixbyte/devkit/utils/MapUtil.java b/common-toolbox/src/main/java/com/onixbyte/common/util/MapUtil.java similarity index 99% rename from devkit-utils/src/main/java/com/onixbyte/devkit/utils/MapUtil.java rename to common-toolbox/src/main/java/com/onixbyte/common/util/MapUtil.java index 4fa5d78..80dec76 100644 --- a/devkit-utils/src/main/java/com/onixbyte/devkit/utils/MapUtil.java +++ b/common-toolbox/src/main/java/com/onixbyte/common/util/MapUtil.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.onixbyte.devkit.utils; +package com.onixbyte.common.util; import java.util.Map; diff --git a/devkit-utils/src/main/java/com/onixbyte/devkit/utils/ObjectMapAdapter.java b/common-toolbox/src/main/java/com/onixbyte/common/util/ObjectMapAdapter.java similarity index 98% rename from devkit-utils/src/main/java/com/onixbyte/devkit/utils/ObjectMapAdapter.java rename to common-toolbox/src/main/java/com/onixbyte/common/util/ObjectMapAdapter.java index 9dde1ff..5e7314a 100644 --- a/devkit-utils/src/main/java/com/onixbyte/devkit/utils/ObjectMapAdapter.java +++ b/common-toolbox/src/main/java/com/onixbyte/common/util/ObjectMapAdapter.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.onixbyte.devkit.utils; +package com.onixbyte.common.util; import java.util.Map; diff --git a/devkit-utils/src/main/java/com/onixbyte/devkit/utils/RangeUtil.java b/common-toolbox/src/main/java/com/onixbyte/common/util/RangeUtil.java similarity index 99% rename from devkit-utils/src/main/java/com/onixbyte/devkit/utils/RangeUtil.java rename to common-toolbox/src/main/java/com/onixbyte/common/util/RangeUtil.java index 2437e8b..d7ca49c 100644 --- a/devkit-utils/src/main/java/com/onixbyte/devkit/utils/RangeUtil.java +++ b/common-toolbox/src/main/java/com/onixbyte/common/util/RangeUtil.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.onixbyte.devkit.utils; +package com.onixbyte.common.util; import java.util.stream.IntStream; diff --git a/devkit-utils/src/main/resources/logback.xml b/common-toolbox/src/main/resources/logback.xml similarity index 100% rename from devkit-utils/src/main/resources/logback.xml rename to common-toolbox/src/main/resources/logback.xml diff --git a/devkit-utils/src/test/java/com/onixbyte/devkit/utils/AesUtilTest.java b/common-toolbox/src/test/java/com/onixbyte/common/util/AesUtilTest.java similarity index 98% rename from devkit-utils/src/test/java/com/onixbyte/devkit/utils/AesUtilTest.java rename to common-toolbox/src/test/java/com/onixbyte/common/util/AesUtilTest.java index c8390d1..2e69401 100644 --- a/devkit-utils/src/test/java/com/onixbyte/devkit/utils/AesUtilTest.java +++ b/common-toolbox/src/test/java/com/onixbyte/common/util/AesUtilTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.onixbyte.devkit.utils; +package com.onixbyte.common.util; import org.junit.jupiter.api.Test; diff --git a/devkit-utils/src/test/java/com/onixbyte/devkit/utils/Base64UtilTest.java b/common-toolbox/src/test/java/com/onixbyte/common/util/Base64UtilTest.java similarity index 98% rename from devkit-utils/src/test/java/com/onixbyte/devkit/utils/Base64UtilTest.java rename to common-toolbox/src/test/java/com/onixbyte/common/util/Base64UtilTest.java index e044098..732b4c1 100644 --- a/devkit-utils/src/test/java/com/onixbyte/devkit/utils/Base64UtilTest.java +++ b/common-toolbox/src/test/java/com/onixbyte/common/util/Base64UtilTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.onixbyte.devkit.utils; +package com.onixbyte.common.util; import org.junit.jupiter.api.Test; diff --git a/devkit-utils/src/test/java/com/onixbyte/devkit/utils/BoolUtilTest.java b/common-toolbox/src/test/java/com/onixbyte/common/util/BoolUtilTest.java similarity index 99% rename from devkit-utils/src/test/java/com/onixbyte/devkit/utils/BoolUtilTest.java rename to common-toolbox/src/test/java/com/onixbyte/common/util/BoolUtilTest.java index 23d38de..f6302b5 100644 --- a/devkit-utils/src/test/java/com/onixbyte/devkit/utils/BoolUtilTest.java +++ b/common-toolbox/src/test/java/com/onixbyte/common/util/BoolUtilTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.onixbyte.devkit.utils; +package com.onixbyte.common.util; import org.junit.jupiter.api.Test; diff --git a/devkit-utils/src/test/java/com/onixbyte/devkit/utils/BranchUtilTest.java b/common-toolbox/src/test/java/com/onixbyte/common/util/BranchUtilTest.java similarity index 99% rename from devkit-utils/src/test/java/com/onixbyte/devkit/utils/BranchUtilTest.java rename to common-toolbox/src/test/java/com/onixbyte/common/util/BranchUtilTest.java index 05a2f14..f90f058 100644 --- a/devkit-utils/src/test/java/com/onixbyte/devkit/utils/BranchUtilTest.java +++ b/common-toolbox/src/test/java/com/onixbyte/common/util/BranchUtilTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.onixbyte.devkit.utils; +package com.onixbyte.common.util; import org.junit.jupiter.api.Test; diff --git a/devkit-utils/src/test/java/com/onixbyte/devkit/utils/CollectionUtilTest.java b/common-toolbox/src/test/java/com/onixbyte/common/util/CollectionUtilTest.java similarity index 99% rename from devkit-utils/src/test/java/com/onixbyte/devkit/utils/CollectionUtilTest.java rename to common-toolbox/src/test/java/com/onixbyte/common/util/CollectionUtilTest.java index 4c7f197..7807753 100644 --- a/devkit-utils/src/test/java/com/onixbyte/devkit/utils/CollectionUtilTest.java +++ b/common-toolbox/src/test/java/com/onixbyte/common/util/CollectionUtilTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.onixbyte.devkit.utils; +package com.onixbyte.common.util; import org.junit.jupiter.api.Test; diff --git a/devkit-utils/src/test/java/com/onixbyte/devkit/utils/HashUtilTest.java b/common-toolbox/src/test/java/com/onixbyte/common/util/HashUtilTest.java similarity index 99% rename from devkit-utils/src/test/java/com/onixbyte/devkit/utils/HashUtilTest.java rename to common-toolbox/src/test/java/com/onixbyte/common/util/HashUtilTest.java index 6b9cb6b..9bb1fef 100644 --- a/devkit-utils/src/test/java/com/onixbyte/devkit/utils/HashUtilTest.java +++ b/common-toolbox/src/test/java/com/onixbyte/common/util/HashUtilTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.onixbyte.devkit.utils; +package com.onixbyte.common.util; import org.junit.jupiter.api.Test; diff --git a/devkit-utils/src/test/java/com/onixbyte/devkit/utils/RangeUtilTest.java b/common-toolbox/src/test/java/com/onixbyte/common/util/RangeUtilTest.java similarity index 99% rename from devkit-utils/src/test/java/com/onixbyte/devkit/utils/RangeUtilTest.java rename to common-toolbox/src/test/java/com/onixbyte/common/util/RangeUtilTest.java index 13db7fb..a53ed6d 100644 --- a/devkit-utils/src/test/java/com/onixbyte/devkit/utils/RangeUtilTest.java +++ b/common-toolbox/src/test/java/com/onixbyte/common/util/RangeUtilTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.onixbyte.devkit.utils; +package com.onixbyte.common.util; import org.junit.jupiter.api.Test; diff --git a/key-pair-loader/README.md b/crypto-toolbox/README.md similarity index 100% rename from key-pair-loader/README.md rename to crypto-toolbox/README.md diff --git a/key-pair-loader/build.gradle.kts b/crypto-toolbox/build.gradle.kts similarity index 92% rename from key-pair-loader/build.gradle.kts rename to crypto-toolbox/build.gradle.kts index 0ecec51..e980f8d 100644 --- a/key-pair-loader/build.gradle.kts +++ b/crypto-toolbox/build.gradle.kts @@ -68,9 +68,9 @@ tasks.test { publishing { publications { - create("keyPairLoader") { + create("cryptoToolbox") { groupId = group.toString() - artifactId = "key-pair-loader" + artifactId = "crypto-toolbox" version = artefactVersion pom { @@ -87,8 +87,8 @@ publishing { } scm { - connection = "scm:git:git://github.com:onixbyte/onixbyte-toolbox.git" - developerConnection = "scm:git:git://github.com:onixbyte/onixbyte-toolbox.git" + connection = "scm:git:git://github.com:OnixByte/JDevKit.git" + developerConnection = "scm:git:git://github.com:OnixByte/JDevKit.git" url = projectGithubUrl } @@ -112,7 +112,7 @@ publishing { from(components["java"]) signing { - sign(publishing.publications["keyPairLoader"]) + sign(publishing.publications["cryptoToolbox"]) } } @@ -127,4 +127,4 @@ publishing { } } } -} +} \ No newline at end of file diff --git a/crypto-toolbox/src/main/java/com/onixbyte/crypto/PrivateKeyLoader.java b/crypto-toolbox/src/main/java/com/onixbyte/crypto/PrivateKeyLoader.java new file mode 100644 index 0000000..228e3cd --- /dev/null +++ b/crypto-toolbox/src/main/java/com/onixbyte/crypto/PrivateKeyLoader.java @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2024-2025 OnixByte. + * + * 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 com.onixbyte.crypto; + +import java.security.PrivateKey; + +/** + * The {@code PrivateKeyLoader} interface provides utility methods for loading keys pairs from + * PEM-formatted key text. This class supports loading both private and public keys. + * + * @author zihluwang + * @author siujamo + * @version 2.0.0 + * @since 1.6.0 + */ +public interface PrivateKeyLoader { + + /** + * Load private key from pem-formatted key text. + * + * @param pemKeyText pem-formatted key text + * @return loaded private key + */ + PrivateKey loadPrivateKey(String pemKeyText); +} diff --git a/crypto-toolbox/src/main/java/com/onixbyte/crypto/PublicKeyLoader.java b/crypto-toolbox/src/main/java/com/onixbyte/crypto/PublicKeyLoader.java new file mode 100644 index 0000000..ecfb3e3 --- /dev/null +++ b/crypto-toolbox/src/main/java/com/onixbyte/crypto/PublicKeyLoader.java @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2024-2025 OnixByte. + * + * 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 com.onixbyte.crypto; + +import com.onixbyte.crypto.exception.KeyLoadingException; + +import java.security.PublicKey; +import java.security.interfaces.ECPublicKey; +import java.security.interfaces.RSAPublicKey; + +/** + * + * @author siujamo + * @version 3.0.0 + */ +public interface PublicKeyLoader { + + /** + * Load public key from pem-formatted key text. + * + * @param pemKeyText pem-formatted key text + * @return loaded private key + */ + PublicKey loadPublicKey(String pemKeyText); + + /** + * Loads an EC public key using the provided x and y coordinates together with the curve name. + *

+ * This default implementation throws a {@link KeyLoadingException} to signify that this key + * loader does not support loading an EC public key. Implementing classes are expected to + * override this method to supply their own loading logic. + * + * @param xHex the hexadecimal string representing the x coordinate of the EC point + * @param yHex the hexadecimal string representing the y coordinate of the EC point + * @param curveName the name of the elliptic curve + * @return the loaded {@link ECPublicKey} instance + * @throws KeyLoadingException if loading is not supported or fails + */ + default ECPublicKey loadPublicKey(String xHex, String yHex, String curveName) { + throw new KeyLoadingException("This key loader does not support loading an EC public key."); + } + + /** + * Loads an RSA public key using the provided modulus and exponent. + *

+ * This default implementation throws a {@link KeyLoadingException} to signify that this key + * loader does not support loading an RSA public key. Implementing classes are expected to + * override this method to supply their own loading logic. + * + * @param modulus the modulus value of the RSA public key, usually represented in hexadecimal + * or Base64 string format + * @param exponent the public exponent value of the RSA public key, usually represented in + * hexadecimal or Base64 string format + * @return the loaded {@link RSAPublicKey} instance + * @throws KeyLoadingException if loading is not supported or fails + */ + default RSAPublicKey loadPublicKey(String modulus, String exponent) { + throw new KeyLoadingException("This key loader does not support loading an RSA public key."); + } +} diff --git a/crypto-toolbox/src/main/java/com/onixbyte/crypto/algorithm/ecdsa/ECPrivateKeyLoader.java b/crypto-toolbox/src/main/java/com/onixbyte/crypto/algorithm/ecdsa/ECPrivateKeyLoader.java new file mode 100644 index 0000000..672c65f --- /dev/null +++ b/crypto-toolbox/src/main/java/com/onixbyte/crypto/algorithm/ecdsa/ECPrivateKeyLoader.java @@ -0,0 +1,102 @@ +/* + * Copyright (C) 2024-2025 OnixByte. + * + * 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 com.onixbyte.crypto.algorithm.ecdsa; + +import com.onixbyte.crypto.PrivateKeyLoader; +import com.onixbyte.crypto.exception.KeyLoadingException; +import com.onixbyte.crypto.util.CryptoUtil; + +import java.math.BigInteger; +import java.security.AlgorithmParameters; +import java.security.KeyFactory; +import java.security.NoSuchAlgorithmException; +import java.security.interfaces.ECPrivateKey; +import java.security.interfaces.ECPublicKey; +import java.security.spec.*; +import java.util.Base64; +import java.util.HashSet; +import java.util.Set; + +/** + * Key pair loader for loading key pairs for ECDSA-based algorithms. + *

+ * + * Example usage for ECDSA: + *

{@code
+ * PrivateKeyLoader keyLoader = new EcKeyLoader();
+ * String pemPrivateKey = """
+ *                        -----BEGIN EC PRIVATE KEY-----
+ *                        ...
+ *                        -----END EC PRIVATE KEY-----""";
+ * ECPrivateKey privateKey = PrivateKeyLoader.loadEcdsaPrivateKey(pemPrivateKey);
+ *
+ * String pemPublicKey = """
+ *                       -----BEGIN EC PUBLIC KEY-----
+ *                       ...
+ *                       -----END EC PUBLIC KEY-----""";
+ * ECPublicKey publicKey = PrivateKeyLoader.loadPublicKey(pemPublicKey);
+ * }
+ * + * @author zihluwang + * @version 2.0.0 + * @since 2.0.0 + */ +public class ECPrivateKeyLoader implements PrivateKeyLoader { + + private final KeyFactory keyFactory; + + private final Base64.Decoder decoder; + + /** + * Initialise a key loader for EC-based algorithms. + */ + public ECPrivateKeyLoader() { + try { + this.keyFactory = KeyFactory.getInstance("EC"); + this.decoder = Base64.getDecoder(); + } catch (NoSuchAlgorithmException e) { + throw new KeyLoadingException(e); + } + } + + /** + * Load ECDSA private key from pem-formatted key text. + * + * @param pemKeyText pem-formatted key text + * @return loaded private key + * @throws KeyLoadingException if the generated key is not a {@link ECPrivateKey} instance, + * or EC Key Factory is not loaded, or key spec is invalid + */ + @Override + public ECPrivateKey loadPrivateKey(String pemKeyText) { + try { + pemKeyText = CryptoUtil.getRawContent(pemKeyText); + var decodedKeyString = decoder.decode(pemKeyText); + var keySpec = new PKCS8EncodedKeySpec(decodedKeyString); + + var _key = keyFactory.generatePrivate(keySpec); + if (_key instanceof ECPrivateKey privateKey) { + return privateKey; + } else { + throw new KeyLoadingException("Unable to load private key from pem-formatted key text."); + } + } catch (InvalidKeySpecException e) { + throw new KeyLoadingException("Key spec is invalid.", e); + } + } +} diff --git a/key-pair-loader/src/main/java/com/onixbyte/security/impl/ECKeyLoader.java b/crypto-toolbox/src/main/java/com/onixbyte/crypto/algorithm/ecdsa/ECPublicKeyLoader.java similarity index 70% rename from key-pair-loader/src/main/java/com/onixbyte/security/impl/ECKeyLoader.java rename to crypto-toolbox/src/main/java/com/onixbyte/crypto/algorithm/ecdsa/ECPublicKeyLoader.java index e482c0f..a31f98a 100644 --- a/key-pair-loader/src/main/java/com/onixbyte/security/impl/ECKeyLoader.java +++ b/crypto-toolbox/src/main/java/com/onixbyte/crypto/algorithm/ecdsa/ECPublicKeyLoader.java @@ -15,10 +15,11 @@ * limitations under the License. */ -package com.onixbyte.security.impl; +package com.onixbyte.crypto.algorithm.ecdsa; -import com.onixbyte.security.KeyLoader; -import com.onixbyte.security.exception.KeyLoadingException; +import com.onixbyte.crypto.PublicKeyLoader; +import com.onixbyte.crypto.exception.KeyLoadingException; +import com.onixbyte.crypto.util.CryptoUtil; import java.math.BigInteger; import java.security.AlgorithmParameters; @@ -31,47 +32,23 @@ import java.util.HashSet; import java.util.Set; -/** - * Key pair loader for loading key pairs for ECDSA-based algorithms. - *

- * - * Example usage for ECDSA: - *

{@code
- * KeyLoader keyLoader = new EcKeyLoader();
- * String pemPrivateKey = """
- *                        -----BEGIN EC PRIVATE KEY-----
- *                        ...
- *                        -----END EC PRIVATE KEY-----""";
- * ECPrivateKey privateKey = KeyLoader.loadEcdsaPrivateKey(pemPrivateKey);
- *
- * String pemPublicKey = """
- *                       -----BEGIN EC PUBLIC KEY-----
- *                       ...
- *                       -----END EC PUBLIC KEY-----""";
- * ECPublicKey publicKey = KeyLoader.loadPublicKey(pemPublicKey);
- * }
- * - * @author zihluwang - * @version 2.0.0 - * @since 2.0.0 - */ -public class ECKeyLoader implements KeyLoader { - - private final KeyFactory keyFactory; - - private final Base64.Decoder decoder; +public class ECPublicKeyLoader implements PublicKeyLoader { /** * Supported curves. */ public static final Set SUPPORTED_CURVES = new HashSet<>(Set.of( - "secp256r1", "secp384r1", "secp521r1", "secp224r1" + "secp256r1", "secp384r1", "secp521r1", "secp224r1" )); + private final KeyFactory keyFactory; + + private final Base64.Decoder decoder; + /** * Initialise a key loader for EC-based algorithms. */ - public ECKeyLoader() { + public ECPublicKeyLoader() { try { this.keyFactory = KeyFactory.getInstance("EC"); this.decoder = Base64.getDecoder(); @@ -80,32 +57,6 @@ public ECKeyLoader() { } } - /** - * Load ECDSA private key from pem-formatted key text. - * - * @param pemKeyText pem-formatted key text - * @return loaded private key - * @throws KeyLoadingException if the generated key is not a {@link ECPrivateKey} instance, - * or EC Key Factory is not loaded, or key spec is invalid - */ - @Override - public ECPrivateKey loadPrivateKey(String pemKeyText) { - try { - pemKeyText = getRawContent(pemKeyText); - var decodedKeyString = decoder.decode(pemKeyText); - var keySpec = new PKCS8EncodedKeySpec(decodedKeyString); - - var _key = keyFactory.generatePrivate(keySpec); - if (_key instanceof ECPrivateKey privateKey) { - return privateKey; - } else { - throw new KeyLoadingException("Unable to load private key from pem-formatted key text."); - } - } catch (InvalidKeySpecException e) { - throw new KeyLoadingException("Key spec is invalid.", e); - } - } - /** * Load public key from pem-formatted key text. * @@ -117,7 +68,7 @@ public ECPrivateKey loadPrivateKey(String pemKeyText) { @Override public ECPublicKey loadPublicKey(String pemKeyText) { try { - pemKeyText = getRawContent(pemKeyText); + pemKeyText = CryptoUtil.getRawContent(pemKeyText); var keyBytes = decoder.decode(pemKeyText); var spec = new X509EncodedKeySpec(keyBytes); var key = keyFactory.generatePublic(spec); diff --git a/crypto-toolbox/src/main/java/com/onixbyte/crypto/algorithm/rsa/RSAPrivateKeyLoader.java b/crypto-toolbox/src/main/java/com/onixbyte/crypto/algorithm/rsa/RSAPrivateKeyLoader.java new file mode 100644 index 0000000..1f8c357 --- /dev/null +++ b/crypto-toolbox/src/main/java/com/onixbyte/crypto/algorithm/rsa/RSAPrivateKeyLoader.java @@ -0,0 +1,102 @@ +/* + * Copyright (C) 2024-2025 OnixByte. + * + * 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 com.onixbyte.crypto.algorithm.rsa; + +import com.onixbyte.crypto.PrivateKeyLoader; +import com.onixbyte.crypto.exception.KeyLoadingException; +import com.onixbyte.crypto.util.CryptoUtil; + +import java.math.BigInteger; +import java.security.KeyFactory; +import java.security.NoSuchAlgorithmException; +import java.security.interfaces.RSAPrivateKey; +import java.security.interfaces.RSAPublicKey; +import java.security.spec.*; +import java.util.Base64; + +/** + * A class responsible for loading RSA keys from PEM formatted text. + *

+ * This class implements the {@link PrivateKeyLoader} interface and provides methods to load both private + * and public RSA keys. The keys are expected to be in the standard PEM format, which includes + * Base64-encoded key content surrounded by header and footer lines. The class handles the decoding + * of Base64 content and the generation of keys using the RSA key factory. + *

+ * Any exceptions encountered during the loading process are encapsulated in a + * {@link KeyLoadingException}, allowing for flexible error handling. + * + * @author siujamo + * @see PrivateKeyLoader + * @see KeyLoadingException + */ +public class RSAPrivateKeyLoader implements PrivateKeyLoader { + + private final Base64.Decoder decoder; + + private final KeyFactory keyFactory; + + /** + * Constructs an instance of {@code RsaKeyLoader}. + *

+ * This constructor initialises the Base64 decoder and the RSA {@link KeyFactory}. It may throw + * a {@link KeyLoadingException} if the RSA algorithm is not available. + */ + public RSAPrivateKeyLoader() { + try { + this.decoder = Base64.getDecoder(); + this.keyFactory = KeyFactory.getInstance("RSA"); + } catch (NoSuchAlgorithmException e) { + throw new KeyLoadingException(e); + } + } + + /** + * Loads an RSA private key from a given PEM formatted key text. + *

+ * This method extracts the raw key content from the provided PEM text, decodes the + * Base64-encoded content, and generates an instance of {@link RSAPrivateKey}. If the key cannot + * be loaded due to invalid specifications or types, a {@link KeyLoadingException} is thrown. + * + * @param pemKeyText the PEM formatted private key text + * @return an instance of {@link RSAPrivateKey} + * @throws KeyLoadingException if the key loading process encounters an error + */ + @Override + public RSAPrivateKey loadPrivateKey(String pemKeyText) { + // Extract the raw key content + var rawKeyContent = CryptoUtil.getRawContent(pemKeyText); + + // Decode the Base64-encoded content + var keyBytes = decoder.decode(rawKeyContent); + + // Create a PKCS8EncodedKeySpec from the decoded bytes + var keySpec = new PKCS8EncodedKeySpec(keyBytes); + + try { + // Get an RSA KeyFactory and generate the private key + var _key = keyFactory.generatePrivate(keySpec); + if (_key instanceof RSAPrivateKey key) { + return key; + } else { + throw new KeyLoadingException("Unable to load private key from pem-formatted key text."); + } + } catch (InvalidKeySpecException e) { + throw new KeyLoadingException("Key spec is invalid.", e); + } + } +} diff --git a/key-pair-loader/src/main/java/com/onixbyte/security/impl/RSAKeyLoader.java b/crypto-toolbox/src/main/java/com/onixbyte/crypto/algorithm/rsa/RSAPublicKeyLoader.java similarity index 61% rename from key-pair-loader/src/main/java/com/onixbyte/security/impl/RSAKeyLoader.java rename to crypto-toolbox/src/main/java/com/onixbyte/crypto/algorithm/rsa/RSAPublicKeyLoader.java index 3cf9324..2e14518 100644 --- a/key-pair-loader/src/main/java/com/onixbyte/security/impl/RSAKeyLoader.java +++ b/crypto-toolbox/src/main/java/com/onixbyte/crypto/algorithm/rsa/RSAPublicKeyLoader.java @@ -15,35 +15,23 @@ * limitations under the License. */ -package com.onixbyte.security.impl; +package com.onixbyte.crypto.algorithm.rsa; -import com.onixbyte.security.KeyLoader; -import com.onixbyte.security.exception.KeyLoadingException; +import com.onixbyte.crypto.PublicKeyLoader; +import com.onixbyte.crypto.exception.KeyLoadingException; +import com.onixbyte.crypto.util.CryptoUtil; import java.math.BigInteger; import java.security.KeyFactory; import java.security.NoSuchAlgorithmException; -import java.security.interfaces.RSAPrivateKey; import java.security.interfaces.RSAPublicKey; -import java.security.spec.*; +import java.security.spec.InvalidKeySpecException; +import java.security.spec.KeySpec; +import java.security.spec.RSAPublicKeySpec; +import java.security.spec.X509EncodedKeySpec; import java.util.Base64; -/** - * A class responsible for loading RSA keys from PEM formatted text. - *

- * This class implements the {@link KeyLoader} interface and provides methods to load both private - * and public RSA keys. The keys are expected to be in the standard PEM format, which includes - * Base64-encoded key content surrounded by header and footer lines. The class handles the decoding - * of Base64 content and the generation of keys using the RSA key factory. - *

- * Any exceptions encountered during the loading process are encapsulated in a - * {@link KeyLoadingException}, allowing for flexible error handling. - * - * @author siujamo - * @see KeyLoader - * @see KeyLoadingException - */ -public class RSAKeyLoader implements KeyLoader { +public class RSAPublicKeyLoader implements PublicKeyLoader { private final Base64.Decoder decoder; @@ -57,7 +45,7 @@ public class RSAKeyLoader implements KeyLoader { * This constructor initialises the Base64 decoder and the RSA {@link KeyFactory}. It may throw * a {@link KeyLoadingException} if the RSA algorithm is not available. */ - public RSAKeyLoader() { + public RSAPublicKeyLoader() { try { this.decoder = Base64.getDecoder(); this.urlDecoder = Base64.getUrlDecoder(); @@ -67,41 +55,6 @@ public RSAKeyLoader() { } } - /** - * Loads an RSA private key from a given PEM formatted key text. - *

- * This method extracts the raw key content from the provided PEM text, decodes the - * Base64-encoded content, and generates an instance of {@link RSAPrivateKey}. If the key cannot - * be loaded due to invalid specifications or types, a {@link KeyLoadingException} is thrown. - * - * @param pemKeyText the PEM formatted private key text - * @return an instance of {@link RSAPrivateKey} - * @throws KeyLoadingException if the key loading process encounters an error - */ - @Override - public RSAPrivateKey loadPrivateKey(String pemKeyText) { - // Extract the raw key content - var rawKeyContent = getRawContent(pemKeyText); - - // Decode the Base64-encoded content - var keyBytes = decoder.decode(rawKeyContent); - - // Create a PKCS8EncodedKeySpec from the decoded bytes - var keySpec = new PKCS8EncodedKeySpec(keyBytes); - - try { - // Get an RSA KeyFactory and generate the private key - var _key = keyFactory.generatePrivate(keySpec); - if (_key instanceof RSAPrivateKey key) { - return key; - } else { - throw new KeyLoadingException("Unable to load private key from pem-formatted key text."); - } - } catch (InvalidKeySpecException e) { - throw new KeyLoadingException("Key spec is invalid.", e); - } - } - /** * Loads an RSA public key from a given PEM formatted key text. *

@@ -116,7 +69,7 @@ public RSAPrivateKey loadPrivateKey(String pemKeyText) { @Override public RSAPublicKey loadPublicKey(String pemKeyText) { // Extract the raw key content - var rawKeyContent = getRawContent(pemKeyText); + var rawKeyContent = CryptoUtil.getRawContent(pemKeyText); // Decode the Base64-encoded content var keyBytes = decoder.decode(rawKeyContent); diff --git a/key-pair-loader/src/main/java/com/onixbyte/security/exception/KeyLoadingException.java b/crypto-toolbox/src/main/java/com/onixbyte/crypto/exception/KeyLoadingException.java similarity index 96% rename from key-pair-loader/src/main/java/com/onixbyte/security/exception/KeyLoadingException.java rename to crypto-toolbox/src/main/java/com/onixbyte/crypto/exception/KeyLoadingException.java index 3c4cabc..9ae5b7f 100644 --- a/key-pair-loader/src/main/java/com/onixbyte/security/exception/KeyLoadingException.java +++ b/crypto-toolbox/src/main/java/com/onixbyte/crypto/exception/KeyLoadingException.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.onixbyte.security.exception; +package com.onixbyte.crypto.exception; /** * The {@code KeyLoadingException} class represents an exception that is thrown when there is an @@ -29,7 +29,7 @@ *

Example usage:

*
{@code
  * try {
- *     KeyLoader keyLoader = new EcKeyLoader();
+ *     PrivateKeyLoader keyLoader = new ECPrivateKeyLoader();
  *     ECPrivateKey privateKey = keyLoader.loadPrivateKey(pemPrivateKey);
  * } catch (KeyLoadingException e) {
  *     // Handle the exception
@@ -38,7 +38,7 @@
  * }
* * @author zihluwang - * @version 2.0.0 + * @version 3.0.0 * @since 1.6.0 */ public class KeyLoadingException extends RuntimeException { diff --git a/crypto-toolbox/src/main/java/com/onixbyte/crypto/util/CryptoUtil.java b/crypto-toolbox/src/main/java/com/onixbyte/crypto/util/CryptoUtil.java new file mode 100644 index 0000000..3cb66d0 --- /dev/null +++ b/crypto-toolbox/src/main/java/com/onixbyte/crypto/util/CryptoUtil.java @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2024-2025 OnixByte. + * + * 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 com.onixbyte.crypto.util; + +public final class CryptoUtil { + + private CryptoUtil() { + } + + /** + * Retrieves the raw content of a PEM formatted key by removing unnecessary headers, footers, + * and new line characters. + * + *

+ * This method processes the provided PEM key text to return a cleaned string that contains + * only the key content. The method strips away the + * {@code "-----BEGIN (EC )?(PRIVATE|PUBLIC) KEY-----"} and + * {@code "-----END (EC )?(PRIVATE|PUBLIC) KEY-----"} lines, as well as any new line characters, + * resulting in a continuous string representation of the key, which can be used for further + * cryptographic operations. + * + * @param pemKeyText the PEM formatted key as a string, which may include headers, footers and + * line breaks + * @return a string containing the raw key content devoid of any unnecessary formatting + * or whitespace + */ + public static String getRawContent(String pemKeyText) { + // remove all unnecessary parts of the pem key text + return pemKeyText + .replaceAll("-----BEGIN ((EC )|(RSA ))?(PRIVATE|PUBLIC) KEY-----", "") + .replaceAll("-----END ((EC )|(RSA ))?(PRIVATE|PUBLIC) KEY-----", "") + .replaceAll("\n", ""); + } +} diff --git a/key-pair-loader/src/main/resources/logback.xml b/crypto-toolbox/src/main/resources/logback.xml similarity index 100% rename from key-pair-loader/src/main/resources/logback.xml rename to crypto-toolbox/src/main/resources/logback.xml diff --git a/key-pair-loader/src/test/resources/ec_private_key.pem b/crypto-toolbox/src/test/resources/ec_private_key.pem similarity index 100% rename from key-pair-loader/src/test/resources/ec_private_key.pem rename to crypto-toolbox/src/test/resources/ec_private_key.pem diff --git a/key-pair-loader/src/test/resources/ec_public_key.pem b/crypto-toolbox/src/test/resources/ec_public_key.pem similarity index 100% rename from key-pair-loader/src/test/resources/ec_public_key.pem rename to crypto-toolbox/src/test/resources/ec_public_key.pem diff --git a/key-pair-loader/src/test/resources/rsa_private_key.pem b/crypto-toolbox/src/test/resources/rsa_private_key.pem similarity index 100% rename from key-pair-loader/src/test/resources/rsa_private_key.pem rename to crypto-toolbox/src/test/resources/rsa_private_key.pem diff --git a/key-pair-loader/src/test/resources/rsa_public_key.pem b/crypto-toolbox/src/test/resources/rsa_public_key.pem similarity index 100% rename from key-pair-loader/src/test/resources/rsa_public_key.pem rename to crypto-toolbox/src/test/resources/rsa_public_key.pem diff --git a/guid/README.md b/identity-generator/README.md similarity index 96% rename from guid/README.md rename to identity-generator/README.md index 501a1f5..d77c49d 100644 --- a/guid/README.md +++ b/identity-generator/README.md @@ -4,7 +4,7 @@ Module `guid` serves as a guid creator for other `JDevKit` modules. You can also use this module as a guid creator standards. -We have already implemented `SnowflakeGuidCreator`, you can also implement a custom guid creations by implementing `com.onixbyte.guid.GuidCreator`. +We have already implemented `SnowflakeGuidCreator`, you can also implement a custom guid creations by implementing `com.onixbyte.identitygenerator.IdentityGenerator`. ## Example usage diff --git a/guid/build.gradle.kts b/identity-generator/build.gradle.kts similarity index 91% rename from guid/build.gradle.kts rename to identity-generator/build.gradle.kts index 6f357b2..8821412 100644 --- a/guid/build.gradle.kts +++ b/identity-generator/build.gradle.kts @@ -64,9 +64,9 @@ tasks.test { publishing { publications { - create("guid") { + create("identityGenerator") { groupId = group.toString() - artifactId = "guid" + artifactId = "identity-generator" version = artefactVersion pom { @@ -82,8 +82,8 @@ publishing { } scm { - connection = "scm:git:git://github.com:onixbyte/onixbyte-toolbox.git" - developerConnection = "scm:git:git://github.com:onixbyte/onixbyte-toolbox.git" + connection = "scm:git:git://github.com:OnixByte/JDevKit.git" + developerConnection = "scm:git:git://github.com:OnixByte/JDevKit.git" url = projectGithubUrl } @@ -107,7 +107,7 @@ publishing { from(components["java"]) signing { - sign(publishing.publications["guid"]) + sign(publishing.publications["identityGenerator"]) } } diff --git a/guid/src/main/java/com/onixbyte/guid/GuidCreator.java b/identity-generator/src/main/java/com/onixbyte/identitygenerator/IdentityGenerator.java similarity index 81% rename from guid/src/main/java/com/onixbyte/guid/GuidCreator.java rename to identity-generator/src/main/java/com/onixbyte/identitygenerator/IdentityGenerator.java index 266c85f..823d85b 100644 --- a/guid/src/main/java/com/onixbyte/guid/GuidCreator.java +++ b/identity-generator/src/main/java/com/onixbyte/identitygenerator/IdentityGenerator.java @@ -15,10 +15,10 @@ * limitations under the License. */ -package com.onixbyte.guid; +package com.onixbyte.identitygenerator; /** - * The {@code GuidCreator} is a generic interface for generating globally unique identifiers (GUIDs) + * The {@code IdentityGenerator} is a generic interface for generating globally unique identifiers (GUIDs) * of a specific type. *

* The type of ID is determined by the class implementing this interface. @@ -26,7 +26,7 @@ * *

Example usage:

*
{@code
- * public class StringGuidCreator implements GuidCreator {
+ * public class StringGuidCreator implements IdentityGenerator {
  *     private final AtomicLong counter = new AtomicLong();
  *
  *     @Override
@@ -37,7 +37,7 @@
  *
  * public class Example {
  *     public static void main(String[] args) {
- *         GuidCreator guidCreator = new StringGuidCreator();
+ *         IdentityGenerator guidCreator = new StringGuidCreator();
  *         String guid = guidCreator.nextId();
  *         System.out.println("Generated GUID: " + guid);
  *     }
@@ -49,7 +49,7 @@
  * @version 1.1.0
  * @since 1.0.0
  */
-public interface GuidCreator {
+public interface IdentityGenerator {
 
     /**
      * Generates and returns the next globally unique ID.
@@ -58,4 +58,4 @@ public interface GuidCreator {
      */
     IdType nextId();
 
-}
\ No newline at end of file
+}
diff --git a/guid/src/main/java/com/onixbyte/guid/exceptions/TimingException.java b/identity-generator/src/main/java/com/onixbyte/identitygenerator/exceptions/TimingException.java
similarity index 97%
rename from guid/src/main/java/com/onixbyte/guid/exceptions/TimingException.java
rename to identity-generator/src/main/java/com/onixbyte/identitygenerator/exceptions/TimingException.java
index 611e5fb..9eeeea2 100644
--- a/guid/src/main/java/com/onixbyte/guid/exceptions/TimingException.java
+++ b/identity-generator/src/main/java/com/onixbyte/identitygenerator/exceptions/TimingException.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package com.onixbyte.guid.exceptions;
+package com.onixbyte.identitygenerator.exceptions;
 
 /**
  * The {@code TimingException} class represents an exception that is thrown when there is an error
diff --git a/guid/src/main/java/com/onixbyte/guid/impl/SequentialUuidCreator.java b/identity-generator/src/main/java/com/onixbyte/identitygenerator/impl/SequentialUuidGenerator.java
similarity index 84%
rename from guid/src/main/java/com/onixbyte/guid/impl/SequentialUuidCreator.java
rename to identity-generator/src/main/java/com/onixbyte/identitygenerator/impl/SequentialUuidGenerator.java
index 88b35f3..d6a3e3c 100644
--- a/guid/src/main/java/com/onixbyte/guid/impl/SequentialUuidCreator.java
+++ b/identity-generator/src/main/java/com/onixbyte/identitygenerator/impl/SequentialUuidGenerator.java
@@ -15,16 +15,16 @@
  * limitations under the License.
  */
 
-package com.onixbyte.guid.impl;
+package com.onixbyte.identitygenerator.impl;
 
-import com.onixbyte.guid.GuidCreator;
+import com.onixbyte.identitygenerator.IdentityGenerator;
 
 import java.nio.ByteBuffer;
 import java.security.SecureRandom;
 import java.util.UUID;
 
 /**
- * A {@code SequentialUuidCreator} is responsible for generating UUIDs following the UUID version 7 specification, which
+ * A {@code SequentialUuidGenerator} is responsible for generating UUIDs following the UUID version 7 specification, which
  * combines a timestamp with random bytes to create time-ordered unique identifiers.
  * 

* This implementation utilises a cryptographically strong {@link SecureRandom} instance to produce the random @@ -34,14 +34,14 @@ * The generated UUID adheres strictly to the layout and variant bits of UUID version 7 as defined in the specification. *

*/ -public class SequentialUuidCreator implements GuidCreator { +public class SequentialUuidGenerator implements IdentityGenerator { private final SecureRandom random; /** - * Constructs a new {@code SequentialUuidCreator} with its own {@link SecureRandom} instance. + * Constructs a new {@code SequentialUuidGenerator} with its own {@link SecureRandom} instance. */ - public SequentialUuidCreator() { + public SequentialUuidGenerator() { this.random = new SecureRandom(); } diff --git a/guid/src/main/java/com/onixbyte/guid/impl/SnowflakeGuidCreator.java b/identity-generator/src/main/java/com/onixbyte/identitygenerator/impl/SnowflakeIdentityGenerator.java similarity index 91% rename from guid/src/main/java/com/onixbyte/guid/impl/SnowflakeGuidCreator.java rename to identity-generator/src/main/java/com/onixbyte/identitygenerator/impl/SnowflakeIdentityGenerator.java index 4df7203..9d57099 100644 --- a/guid/src/main/java/com/onixbyte/guid/impl/SnowflakeGuidCreator.java +++ b/identity-generator/src/main/java/com/onixbyte/identitygenerator/impl/SnowflakeIdentityGenerator.java @@ -15,16 +15,16 @@ * limitations under the License. */ -package com.onixbyte.guid.impl; +package com.onixbyte.identitygenerator.impl; -import com.onixbyte.guid.GuidCreator; -import com.onixbyte.guid.exceptions.TimingException; +import com.onixbyte.identitygenerator.IdentityGenerator; +import com.onixbyte.identitygenerator.exceptions.TimingException; import java.time.LocalDateTime; import java.time.ZoneId; /** - * The {@code SnowflakeGuidCreator} generates unique identifiers using the Snowflake algorithm, + * The {@code SnowflakeIdentityGenerator} generates unique identifiers using the Snowflake algorithm, * which combines a timestamp, worker ID, and data centre ID to create 64-bit long integers. The bit * distribution for the generated IDs is as follows: *
    @@ -35,7 +35,7 @@ *
  • 12 bits for sequence number (per millisecond)
  • *
*

- * When initializing a {@link SnowflakeGuidCreator}, you must provide the worker ID and data centre + * When initializing a {@link SnowflakeIdentityGenerator}, you must provide the worker ID and data centre * ID, ensuring they are within the valid range defined by the bit size. The generator maintains an * internal sequence number that increments for IDs generated within the same millisecond. If the * system clock moves backward, an exception is thrown to prevent generating IDs with @@ -45,7 +45,7 @@ * @version 1.1.0 * @since 1.0.0 */ -public final class SnowflakeGuidCreator implements GuidCreator { +public final class SnowflakeIdentityGenerator implements IdentityGenerator { /** * Constructs a SnowflakeGuidGenerator with the default start epoch and custom worker ID, data @@ -54,7 +54,7 @@ public final class SnowflakeGuidCreator implements GuidCreator { * @param dataCentreId the data centre ID (between 0 and 31) * @param workerId the worker ID (between 0 and 31) */ - public SnowflakeGuidCreator(long dataCentreId, long workerId) { + public SnowflakeIdentityGenerator(long dataCentreId, long workerId) { this(dataCentreId, workerId, DEFAULT_CUSTOM_EPOCH); } @@ -67,7 +67,7 @@ public SnowflakeGuidCreator(long dataCentreId, long workerId) { * @throws IllegalArgumentException if the start epoch is greater than the current timestamp, * or if the worker ID or data centre ID is out of range */ - public SnowflakeGuidCreator(long dataCentreId, long workerId, long startEpoch) { + public SnowflakeIdentityGenerator(long dataCentreId, long workerId, long startEpoch) { if (startEpoch > currentTimestamp()) { throw new IllegalArgumentException("Start Epoch can not be greater than current timestamp!"); } diff --git a/guid/src/main/resources/logback.xml b/identity-generator/src/main/resources/logback.xml similarity index 100% rename from guid/src/main/resources/logback.xml rename to identity-generator/src/main/resources/logback.xml diff --git a/simple-jwt-authzero/README.md b/jwt-toolbox-auth0/README.md similarity index 93% rename from simple-jwt-authzero/README.md rename to jwt-toolbox-auth0/README.md index fbebcda..ee055b3 100644 --- a/simple-jwt-authzero/README.md +++ b/jwt-toolbox-auth0/README.md @@ -50,7 +50,7 @@ implementation 'cn.org.codecrafters:simple-jwt-authzero:${simple-jwt-authzero.ve ## Use the `AuthzeroTokenResolver` -We have implemented `TokenResolver` to make sure you can add JWT to your Java application as soon as possible. All you need to do is to create an instance of `com.onixbyte.simplejwt.authzero.AuthzeroTokenResolver` and other operations to JWT could follow our instruction in [`simple-jwt-facade`](../simple-jwt-facade/README.md). +We have implemented `TokenResolver` to make sure you can add JWT to your Java application as soon as possible. All you need to do is to create an instance of `com.onixbyte.jwt.auth0.AuthzeroTokenResolver` and other operations to JWT could follow our instruction in [`simple-jwt-facade`](../simple-jwt-facade/README.md). ## Contact diff --git a/simple-jwt-authzero/build.gradle.kts b/jwt-toolbox-auth0/build.gradle.kts similarity index 86% rename from simple-jwt-authzero/build.gradle.kts rename to jwt-toolbox-auth0/build.gradle.kts index ccf4367..91c2151 100644 --- a/simple-jwt-authzero/build.gradle.kts +++ b/jwt-toolbox-auth0/build.gradle.kts @@ -55,10 +55,10 @@ dependencies { compileOnly(libs.slf4j) implementation(libs.logback) - api(project(":devkit-utils")) - api(project(":guid")) - api(project(":key-pair-loader")) - api(project(":simple-jwt-facade")) + api(project(":common-toolbox")) + api(project(":identity-generator")) + api(project(":crypto-toolbox")) + api(project(":jwt-toolbox-facade")) api(libs.jackson.databind) api(libs.jwt.core) @@ -72,13 +72,13 @@ tasks.test { publishing { publications { - create("simpleJwtAuthzero") { + create("jwtToolboxAuth0") { groupId = group.toString() - artifactId = "simple-jwt-authzero" + artifactId = "jwt-toolbox-auth0" version = artefactVersion pom { - name = "OnixByte JWT Toolbox :: Auth0 Implementation" + name = "OnixByte JWT Toolbox :: Auth0" description = "Simple JWT implemented with com.auth0:java-jwt." url = projectUrl @@ -90,8 +90,8 @@ publishing { } scm { - connection = "scm:git:git://github.com:onixbyte/onixbyte-toolbox.git" - developerConnection = "scm:git:git://github.com:onixbyte/onixbyte-toolbox.git" + connection = "scm:git:git://github.com:OnixByte/JDevKit.git" + developerConnection = "scm:git:git://github.com:OnixByte/JDevKit.git" url = projectGithubUrl } @@ -115,7 +115,7 @@ publishing { from(components["java"]) signing { - sign(publishing.publications["simpleJwtAuthzero"]) + sign(publishing.publications["jwtToolboxAuth0"]) } } diff --git a/simple-jwt-authzero/src/main/java/com/onixbyte/simplejwt/authzero/AuthzeroTokenResolver.java b/jwt-toolbox-auth0/src/main/java/com/onixbyte/jwt/auth0/AuthzeroTokenResolver.java similarity index 94% rename from simple-jwt-authzero/src/main/java/com/onixbyte/simplejwt/authzero/AuthzeroTokenResolver.java rename to jwt-toolbox-auth0/src/main/java/com/onixbyte/jwt/auth0/AuthzeroTokenResolver.java index 790700c..b6e6206 100644 --- a/simple-jwt-authzero/src/main/java/com/onixbyte/simplejwt/authzero/AuthzeroTokenResolver.java +++ b/jwt-toolbox-auth0/src/main/java/com/onixbyte/jwt/auth0/AuthzeroTokenResolver.java @@ -15,17 +15,17 @@ * limitations under the License. */ -package com.onixbyte.simplejwt.authzero; - -import com.onixbyte.devkit.utils.Base64Util; -import com.onixbyte.guid.GuidCreator; -import com.onixbyte.security.impl.ECKeyLoader; -import com.onixbyte.simplejwt.TokenPayload; -import com.onixbyte.simplejwt.TokenResolver; -import com.onixbyte.simplejwt.annotations.ExcludeFromPayload; -import com.onixbyte.simplejwt.annotations.TokenEnum; -import com.onixbyte.simplejwt.constants.PredefinedKeys; -import com.onixbyte.simplejwt.constants.TokenAlgorithm; +package com.onixbyte.jwt.auth0; + +import com.onixbyte.common.util.Base64Util; +import com.onixbyte.crypto.algorithm.ecdsa.ECPrivateKeyLoader; +import com.onixbyte.identitygenerator.IdentityGenerator; +import com.onixbyte.jwt.TokenPayload; +import com.onixbyte.jwt.TokenResolver; +import com.onixbyte.jwt.annotations.ExcludeFromPayload; +import com.onixbyte.jwt.annotations.TokenEnum; +import com.onixbyte.jwt.constants.PredefinedKeys; +import com.onixbyte.jwt.constants.TokenAlgorithm; import com.auth0.jwt.JWT; import com.auth0.jwt.JWTCreator; import com.auth0.jwt.algorithms.Algorithm; @@ -35,9 +35,9 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ObjectNode; -import com.onixbyte.simplejwt.exceptions.IllegalKeyPairException; -import com.onixbyte.simplejwt.exceptions.IllegalSecretException; -import com.onixbyte.simplejwt.exceptions.UnsupportedAlgorithmException; +import com.onixbyte.jwt.exceptions.IllegalKeyPairException; +import com.onixbyte.jwt.exceptions.IllegalSecretException; +import com.onixbyte.jwt.exceptions.UnsupportedAlgorithmException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -92,7 +92,7 @@ * * @author Zihlu Wang * @version 1.1.1 - * @see GuidCreator + * @see IdentityGenerator * @see Algorithm * @see JWTVerifier * @see JWTCreator @@ -118,9 +118,9 @@ public static Builder builder() { public static class Builder { /** - * GuidCreator used for generating unique identifiers for "jti" claim in JWT tokens. + * IdentityGenerator used for generating unique identifiers for "jti" claim in JWT tokens. */ - private GuidCreator jtiCreator; + private IdentityGenerator jtiCreator; /** * The algorithm used for signing and verifying JWT tokens. @@ -177,8 +177,8 @@ public Builder secret(String secret) { * @return the builder instance */ public Builder keyPair(String publicKey, String privateKey) { - var keyLoader = new ECKeyLoader(); - this.publicKey = keyLoader.loadPublicKey(publicKey); + var keyLoader = new ECPrivateKeyLoader(); + // this.publicKey = keyLoader.loadPublicKey(publicKey); this.privateKey = keyLoader.loadPrivateKey(privateKey); return this; } @@ -234,7 +234,7 @@ public Builder objectMapper(ObjectMapper objectMapper) { * @param jtiCreator a creator to create JWT id * @return the builder instance */ - public Builder jtiCreator(GuidCreator jtiCreator) { + public Builder jtiCreator(IdentityGenerator jtiCreator) { this.jtiCreator = jtiCreator; return this; } @@ -597,9 +597,9 @@ public static class MapTypeReference extends TypeReference> } /** - * GuidCreator used for generating unique identifiers for "jti" claim in JWT tokens. + * IdentityGenerator used for generating unique identifiers for "jti" claim in JWT tokens. */ - private final GuidCreator jtiCreator; + private final IdentityGenerator jtiCreator; /** * The algorithm used for signing and verifying JWT tokens. @@ -647,7 +647,7 @@ public static class MapTypeReference extends TypeReference> * @param issuer the person or organisation who issued this JWT * @param objectMapper a mapper for handling JSON serialisation and deserialization */ - private AuthzeroTokenResolver(GuidCreator jtiCreator, Algorithm algorithm, String issuer, ObjectMapper objectMapper) { + private AuthzeroTokenResolver(IdentityGenerator jtiCreator, Algorithm algorithm, String issuer, ObjectMapper objectMapper) { this.jtiCreator = jtiCreator; this.algorithm = algorithm; this.issuer = issuer; diff --git a/simple-jwt-authzero/src/main/resources/logback.xml b/jwt-toolbox-auth0/src/main/resources/logback.xml similarity index 100% rename from simple-jwt-authzero/src/main/resources/logback.xml rename to jwt-toolbox-auth0/src/main/resources/logback.xml diff --git a/simple-jwt-authzero/src/test/java/com/onixbyte/simplejwt/authzero/test/TestAuthzeroTokenResolver.java b/jwt-toolbox-auth0/src/test/java/com/onixbyte/jwt/auth0/test/TestAuthzeroTokenResolver.java similarity index 93% rename from simple-jwt-authzero/src/test/java/com/onixbyte/simplejwt/authzero/test/TestAuthzeroTokenResolver.java rename to jwt-toolbox-auth0/src/test/java/com/onixbyte/jwt/auth0/test/TestAuthzeroTokenResolver.java index dc13543..68ecf82 100644 --- a/simple-jwt-authzero/src/test/java/com/onixbyte/simplejwt/authzero/test/TestAuthzeroTokenResolver.java +++ b/jwt-toolbox-auth0/src/test/java/com/onixbyte/jwt/auth0/test/TestAuthzeroTokenResolver.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.onixbyte.simplejwt.authzero.test; +package com.onixbyte.jwt.auth0.test; /** * TestAuthzeroTokenResolver diff --git a/simple-jwt-facade/README.md b/jwt-toolbox-facade/README.md similarity index 100% rename from simple-jwt-facade/README.md rename to jwt-toolbox-facade/README.md diff --git a/simple-jwt-facade/build.gradle.kts b/jwt-toolbox-facade/build.gradle.kts similarity index 89% rename from simple-jwt-facade/build.gradle.kts rename to jwt-toolbox-facade/build.gradle.kts index b19f97b..6f3dddd 100644 --- a/simple-jwt-facade/build.gradle.kts +++ b/jwt-toolbox-facade/build.gradle.kts @@ -55,8 +55,8 @@ dependencies { compileOnly(libs.slf4j) implementation(libs.logback) - api(project(":devkit-utils")) - api(project(":guid")) + api(project(":common-toolbox")) + api(project(":identity-generator")) testImplementation(platform(libs.junit.bom)) testImplementation(libs.junit.jupiter) @@ -68,9 +68,9 @@ tasks.test { publishing { publications { - create("simpleJwtFacade") { + create("jwtToolboxFacade") { groupId = group.toString() - artifactId = "simple-jwt-facade" + artifactId = "jwt-toolbox-facade" version = artefactVersion pom { @@ -86,8 +86,8 @@ publishing { } scm { - connection = "scm:git:git://github.com:onixbyte/onixbyte-toolbox.git" - developerConnection = "scm:git:git://github.com:onixbyte/onixbyte-toolbox.git" + connection = "scm:git:git://github.com:OnixByte/JDevKit.git" + developerConnection = "scm:git:git://github.com:OnixByte/JDevKit.git" url = projectGithubUrl } @@ -111,7 +111,7 @@ publishing { from(components["java"]) signing { - sign(publishing.publications["simpleJwtFacade"]) + sign(publishing.publications["jwtToolboxFacade"]) } } diff --git a/simple-jwt-facade/src/main/java/com/onixbyte/simplejwt/SecretCreator.java b/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/SecretCreator.java similarity index 98% rename from simple-jwt-facade/src/main/java/com/onixbyte/simplejwt/SecretCreator.java rename to jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/SecretCreator.java index 0b24439..0e8ba02 100644 --- a/simple-jwt-facade/src/main/java/com/onixbyte/simplejwt/SecretCreator.java +++ b/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/SecretCreator.java @@ -15,9 +15,9 @@ * limitations under the License. */ -package com.onixbyte.simplejwt; +package com.onixbyte.jwt; -import com.onixbyte.simplejwt.exceptions.WeakSecretException; +import com.onixbyte.jwt.exceptions.WeakSecretException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/simple-jwt-facade/src/main/java/com/onixbyte/simplejwt/TokenPayload.java b/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/TokenPayload.java similarity index 97% rename from simple-jwt-facade/src/main/java/com/onixbyte/simplejwt/TokenPayload.java rename to jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/TokenPayload.java index 1234c6c..a8f5b0d 100644 --- a/simple-jwt-facade/src/main/java/com/onixbyte/simplejwt/TokenPayload.java +++ b/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/TokenPayload.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.onixbyte.simplejwt; +package com.onixbyte.jwt; /** * {@code TokenPayload} interface is used to mark a data class as suitable diff --git a/simple-jwt-facade/src/main/java/com/onixbyte/simplejwt/TokenResolver.java b/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/TokenResolver.java similarity index 99% rename from simple-jwt-facade/src/main/java/com/onixbyte/simplejwt/TokenResolver.java rename to jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/TokenResolver.java index c2ea124..09b6ab1 100644 --- a/simple-jwt-facade/src/main/java/com/onixbyte/simplejwt/TokenResolver.java +++ b/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/TokenResolver.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.onixbyte.simplejwt; +package com.onixbyte.jwt; import java.time.Duration; import java.util.Map; diff --git a/simple-jwt-facade/src/main/java/com/onixbyte/simplejwt/annotations/ExcludeFromPayload.java b/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/annotations/ExcludeFromPayload.java similarity index 97% rename from simple-jwt-facade/src/main/java/com/onixbyte/simplejwt/annotations/ExcludeFromPayload.java rename to jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/annotations/ExcludeFromPayload.java index 0253755..d9432f3 100644 --- a/simple-jwt-facade/src/main/java/com/onixbyte/simplejwt/annotations/ExcludeFromPayload.java +++ b/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/annotations/ExcludeFromPayload.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.onixbyte.simplejwt.annotations; +package com.onixbyte.jwt.annotations; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/simple-jwt-facade/src/main/java/com/onixbyte/simplejwt/annotations/TokenEnum.java b/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/annotations/TokenEnum.java similarity index 93% rename from simple-jwt-facade/src/main/java/com/onixbyte/simplejwt/annotations/TokenEnum.java rename to jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/annotations/TokenEnum.java index ffb5e2f..e2f626b 100644 --- a/simple-jwt-facade/src/main/java/com/onixbyte/simplejwt/annotations/TokenEnum.java +++ b/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/annotations/TokenEnum.java @@ -15,9 +15,9 @@ * limitations under the License. */ -package com.onixbyte.simplejwt.annotations; +package com.onixbyte.jwt.annotations; -import com.onixbyte.simplejwt.constants.TokenDataType; +import com.onixbyte.jwt.constants.TokenDataType; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/simple-jwt-facade/src/main/java/com/onixbyte/simplejwt/constants/PredefinedKeys.java b/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/constants/PredefinedKeys.java similarity index 98% rename from simple-jwt-facade/src/main/java/com/onixbyte/simplejwt/constants/PredefinedKeys.java rename to jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/constants/PredefinedKeys.java index af3b315..36de075 100644 --- a/simple-jwt-facade/src/main/java/com/onixbyte/simplejwt/constants/PredefinedKeys.java +++ b/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/constants/PredefinedKeys.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.onixbyte.simplejwt.constants; +package com.onixbyte.jwt.constants; import java.util.List; diff --git a/simple-jwt-facade/src/main/java/com/onixbyte/simplejwt/constants/TokenAlgorithm.java b/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/constants/TokenAlgorithm.java similarity index 98% rename from simple-jwt-facade/src/main/java/com/onixbyte/simplejwt/constants/TokenAlgorithm.java rename to jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/constants/TokenAlgorithm.java index 21d34c2..af77fd1 100644 --- a/simple-jwt-facade/src/main/java/com/onixbyte/simplejwt/constants/TokenAlgorithm.java +++ b/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/constants/TokenAlgorithm.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.onixbyte.simplejwt.constants; +package com.onixbyte.jwt.constants; import java.util.List; diff --git a/simple-jwt-facade/src/main/java/com/onixbyte/simplejwt/constants/TokenDataType.java b/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/constants/TokenDataType.java similarity index 97% rename from simple-jwt-facade/src/main/java/com/onixbyte/simplejwt/constants/TokenDataType.java rename to jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/constants/TokenDataType.java index 187b2e9..98bdf43 100644 --- a/simple-jwt-facade/src/main/java/com/onixbyte/simplejwt/constants/TokenDataType.java +++ b/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/constants/TokenDataType.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.onixbyte.simplejwt.constants; +package com.onixbyte.jwt.constants; /** * The base data types used to process enum data. diff --git a/simple-jwt-facade/src/main/java/com/onixbyte/simplejwt/exceptions/IllegalKeyPairException.java b/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/exceptions/IllegalKeyPairException.java similarity index 97% rename from simple-jwt-facade/src/main/java/com/onixbyte/simplejwt/exceptions/IllegalKeyPairException.java rename to jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/exceptions/IllegalKeyPairException.java index 55959ce..8ba5a89 100644 --- a/simple-jwt-facade/src/main/java/com/onixbyte/simplejwt/exceptions/IllegalKeyPairException.java +++ b/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/exceptions/IllegalKeyPairException.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.onixbyte.simplejwt.exceptions; +package com.onixbyte.jwt.exceptions; /** * {@link IllegalKeyPairException} indicates an exception that the key pair is invalid. diff --git a/simple-jwt-facade/src/main/java/com/onixbyte/simplejwt/exceptions/IllegalSecretException.java b/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/exceptions/IllegalSecretException.java similarity index 97% rename from simple-jwt-facade/src/main/java/com/onixbyte/simplejwt/exceptions/IllegalSecretException.java rename to jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/exceptions/IllegalSecretException.java index 3ade2f2..eddf440 100644 --- a/simple-jwt-facade/src/main/java/com/onixbyte/simplejwt/exceptions/IllegalSecretException.java +++ b/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/exceptions/IllegalSecretException.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.onixbyte.simplejwt.exceptions; +package com.onixbyte.jwt.exceptions; /** * {@link IllegalKeyPairException} indicates the secret to sign a JWT is illegal. diff --git a/simple-jwt-facade/src/main/java/com/onixbyte/simplejwt/exceptions/UnsupportedAlgorithmException.java b/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/exceptions/UnsupportedAlgorithmException.java similarity index 97% rename from simple-jwt-facade/src/main/java/com/onixbyte/simplejwt/exceptions/UnsupportedAlgorithmException.java rename to jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/exceptions/UnsupportedAlgorithmException.java index c626e40..a79d02d 100644 --- a/simple-jwt-facade/src/main/java/com/onixbyte/simplejwt/exceptions/UnsupportedAlgorithmException.java +++ b/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/exceptions/UnsupportedAlgorithmException.java @@ -15,9 +15,9 @@ * limitations under the License. */ -package com.onixbyte.simplejwt.exceptions; +package com.onixbyte.jwt.exceptions; -import com.onixbyte.simplejwt.TokenResolver; +import com.onixbyte.jwt.TokenResolver; /** * This {@code UnsupportedAlgorithmException} represents the given diff --git a/simple-jwt-facade/src/main/java/com/onixbyte/simplejwt/exceptions/WeakSecretException.java b/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/exceptions/WeakSecretException.java similarity index 98% rename from simple-jwt-facade/src/main/java/com/onixbyte/simplejwt/exceptions/WeakSecretException.java rename to jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/exceptions/WeakSecretException.java index a7a57e7..7c81641 100644 --- a/simple-jwt-facade/src/main/java/com/onixbyte/simplejwt/exceptions/WeakSecretException.java +++ b/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/exceptions/WeakSecretException.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.onixbyte.simplejwt.exceptions; +package com.onixbyte.jwt.exceptions; /** * {@code WeakSecretException} represents that your secret is too weak to be diff --git a/simple-jwt-facade/src/main/resources/logback.xml b/jwt-toolbox-facade/src/main/resources/logback.xml similarity index 100% rename from simple-jwt-facade/src/main/resources/logback.xml rename to jwt-toolbox-facade/src/main/resources/logback.xml diff --git a/simple-jwt-spring-boot-starter/README.md b/jwt-toolbox-spring-boot-starter/README.md similarity index 97% rename from simple-jwt-spring-boot-starter/README.md rename to jwt-toolbox-spring-boot-starter/README.md index 8b3a8ca..38bc51e 100644 --- a/simple-jwt-spring-boot-starter/README.md +++ b/jwt-toolbox-spring-boot-starter/README.md @@ -66,7 +66,7 @@ implementation 'com.onixbyte:simple-jwt-spring-boot-starter:${simple-jwt-spring- We need a `GuidCreator` instance to create JWT ID, though we did implemented a simple `GuidCreator`, but you can still customize it. -First, please implement the `com.onixbyte.guid.GuidCreator` interface based on your own rules for generating JWT IDs. +First, please implement the `com.onixbyte.identitygenerator.IdentityGenerator` interface based on your own rules for generating JWT IDs. Then, add the instance of your own guid creator to spring container, whose name is `jtiCreator`. @@ -98,4 +98,4 @@ public GuidCreator jtiCreator() { If you have any suggestions, ideas, don't hesitate contacting us via [GitHub Issues](https://github.com/CodeCraftersCN/jdevkit/issues/new) or [Discord Community](https://discord.gg/NQK9tjcBB8). -If you face any bugs while using our library and you are able to fix any bugs in our library, we would be happy to accept pull requests from you on [GitHub](https://github.com/CodeCraftersCN/jdevkit/compare). \ No newline at end of file +If you face any bugs while using our library and you are able to fix any bugs in our library, we would be happy to accept pull requests from you on [GitHub](https://github.com/CodeCraftersCN/jdevkit/compare). diff --git a/simple-jwt-spring-boot-starter/build.gradle.kts b/jwt-toolbox-spring-boot-starter/build.gradle.kts similarity index 89% rename from simple-jwt-spring-boot-starter/build.gradle.kts rename to jwt-toolbox-spring-boot-starter/build.gradle.kts index 8bd585b..65d0eac 100644 --- a/simple-jwt-spring-boot-starter/build.gradle.kts +++ b/jwt-toolbox-spring-boot-starter/build.gradle.kts @@ -55,9 +55,9 @@ dependencies { compileOnly(libs.slf4j) implementation(libs.logback) - api(project(":guid")) - api(project(":simple-jwt-facade")) - api(project(":simple-jwt-authzero")) + api(project(":identity-generator")) + api(project(":jwt-toolbox-facade")) + api(project(":jwt-toolbox-auth0")) implementation(libs.springBoot.autoconfigure) implementation(libs.springBoot.starter.logging) implementation(libs.springBoot.configurationProcessor) @@ -81,9 +81,9 @@ tasks.test { publishing { publications { - create("simpleJwtSpringBootStarter") { + create("jwtSpringBootStarter") { groupId = group.toString() - artifactId = "simple-jwt-spring-boot-starter" + artifactId = "jwt-spring-boot-starter" version = artefactVersion pom { @@ -99,8 +99,8 @@ publishing { } scm { - connection = "scm:git:git://github.com:onixbyte/onixbyte-toolbox.git" - developerConnection = "scm:git:git://github.com:onixbyte/onixbyte-toolbox.git" + connection = "scm:git:git://github.com:OnixByte/JDevKit.git" + developerConnection = "scm:git:git://github.com:OnixByte/JDevKit.git" url = projectGithubUrl } @@ -124,7 +124,7 @@ publishing { from(components["java"]) signing { - sign(publishing.publications["simpleJwtSpringBootStarter"]) + sign(publishing.publications["jwtSpringBootStarter"]) } } diff --git a/simple-jwt-spring-boot-starter/src/main/java/com/onixbyte/simplejwt/autoconfiguration/AuthzeroTokenResolverAutoConfiguration.java b/jwt-toolbox-spring-boot-starter/src/main/java/com/onixbyte/jwt/autoconfiguration/AuthzeroTokenResolverAutoConfiguration.java similarity index 89% rename from simple-jwt-spring-boot-starter/src/main/java/com/onixbyte/simplejwt/autoconfiguration/AuthzeroTokenResolverAutoConfiguration.java rename to jwt-toolbox-spring-boot-starter/src/main/java/com/onixbyte/jwt/autoconfiguration/AuthzeroTokenResolverAutoConfiguration.java index dd30bde..f1a5e4f 100644 --- a/simple-jwt-spring-boot-starter/src/main/java/com/onixbyte/simplejwt/autoconfiguration/AuthzeroTokenResolverAutoConfiguration.java +++ b/jwt-toolbox-spring-boot-starter/src/main/java/com/onixbyte/jwt/autoconfiguration/AuthzeroTokenResolverAutoConfiguration.java @@ -15,15 +15,15 @@ * limitations under the License. */ -package com.onixbyte.simplejwt.autoconfiguration; +package com.onixbyte.jwt.autoconfiguration; -import com.onixbyte.guid.GuidCreator; -import com.onixbyte.simplejwt.TokenResolver; -import com.onixbyte.simplejwt.authzero.AuthzeroTokenResolver; -import com.onixbyte.simplejwt.autoconfiguration.properties.SimpleJwtProperties; +import com.onixbyte.identitygenerator.IdentityGenerator; +import com.onixbyte.jwt.TokenResolver; +import com.onixbyte.jwt.auth0.AuthzeroTokenResolver; +import com.onixbyte.jwt.autoconfiguration.properties.SimpleJwtProperties; import com.auth0.jwt.interfaces.DecodedJWT; import com.fasterxml.jackson.databind.ObjectMapper; -import com.onixbyte.simplejwt.constants.TokenAlgorithm; +import com.onixbyte.jwt.constants.TokenAlgorithm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -60,7 +60,7 @@ @EnableConfigurationProperties(value = {SimpleJwtProperties.class}) @ConditionalOnClass({DecodedJWT.class, AuthzeroTokenResolver.class}) @ConditionalOnMissingBean({TokenResolver.class}) -@ConditionalOnBean(value = {GuidCreator.class}, name = "jtiCreator") +@ConditionalOnBean(value = {IdentityGenerator.class}, name = "jtiCreator") @AutoConfigureAfter(value = GuidAutoConfiguration.class) public class AuthzeroTokenResolverAutoConfiguration { @@ -76,7 +76,7 @@ public class AuthzeroTokenResolverAutoConfiguration { */ @Autowired public AuthzeroTokenResolverAutoConfiguration(SimpleJwtProperties simpleJwtProperties, - @Qualifier("jtiCreator") GuidCreator jtiCreator, + @Qualifier("jtiCreator") IdentityGenerator jtiCreator, ObjectMapper objectMapper) { this.jtiCreator = jtiCreator; this.simpleJwtProperties = simpleJwtProperties; @@ -86,7 +86,7 @@ public AuthzeroTokenResolverAutoConfiguration(SimpleJwtProperties simpleJwtPrope /** * Creates a new {@link TokenResolver} bean using {@link AuthzeroTokenResolver} if no existing * {@link TokenResolver} bean is found. The {@link AuthzeroTokenResolver} is configured with the - * provided {@link GuidCreator}, {@code algorithm}, {@code issuer}, and {@code secret} + * provided {@link IdentityGenerator}, {@code algorithm}, {@code issuer}, and {@code secret} * properties from {@link SimpleJwtProperties}. * * @return the {@link TokenResolver} instance @@ -110,7 +110,7 @@ public TokenResolver tokenResolver() { return builder.build(); } - private final GuidCreator jtiCreator; + private final IdentityGenerator jtiCreator; private final SimpleJwtProperties simpleJwtProperties; diff --git a/simple-jwt-spring-boot-starter/src/main/java/com/onixbyte/simplejwt/autoconfiguration/GuidAutoConfiguration.java b/jwt-toolbox-spring-boot-starter/src/main/java/com/onixbyte/jwt/autoconfiguration/GuidAutoConfiguration.java similarity index 81% rename from simple-jwt-spring-boot-starter/src/main/java/com/onixbyte/simplejwt/autoconfiguration/GuidAutoConfiguration.java rename to jwt-toolbox-spring-boot-starter/src/main/java/com/onixbyte/jwt/autoconfiguration/GuidAutoConfiguration.java index 149aabf..674e2dd 100644 --- a/simple-jwt-spring-boot-starter/src/main/java/com/onixbyte/simplejwt/autoconfiguration/GuidAutoConfiguration.java +++ b/jwt-toolbox-spring-boot-starter/src/main/java/com/onixbyte/jwt/autoconfiguration/GuidAutoConfiguration.java @@ -15,10 +15,10 @@ * limitations under the License. */ -package com.onixbyte.simplejwt.autoconfiguration; +package com.onixbyte.jwt.autoconfiguration; -import com.onixbyte.guid.GuidCreator; -import com.onixbyte.simplejwt.autoconfiguration.conditions.GuidCreatorCondition; +import com.onixbyte.identitygenerator.IdentityGenerator; +import com.onixbyte.jwt.autoconfiguration.conditions.GuidCreatorCondition; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.autoconfigure.AutoConfiguration; @@ -28,7 +28,7 @@ import java.util.UUID; /** - * Autoconfiguration for injecting a {@link GuidCreator} for generating jwt id. + * Autoconfiguration for injecting a {@link IdentityGenerator} for generating jwt id. * * @author Zihlu Wang * @version 1.1.0 @@ -52,7 +52,7 @@ public GuidAutoConfiguration() { */ @Bean(name = "jtiCreator") @Conditional(GuidCreatorCondition.class) - public GuidCreator jtiCreator() { + public IdentityGenerator jtiCreator() { return UUID::randomUUID; } diff --git a/simple-jwt-spring-boot-starter/src/main/java/com/onixbyte/simplejwt/autoconfiguration/conditions/GuidCreatorCondition.java b/jwt-toolbox-spring-boot-starter/src/main/java/com/onixbyte/jwt/autoconfiguration/conditions/GuidCreatorCondition.java similarity index 89% rename from simple-jwt-spring-boot-starter/src/main/java/com/onixbyte/simplejwt/autoconfiguration/conditions/GuidCreatorCondition.java rename to jwt-toolbox-spring-boot-starter/src/main/java/com/onixbyte/jwt/autoconfiguration/conditions/GuidCreatorCondition.java index ff0410a..0b62b61 100644 --- a/simple-jwt-spring-boot-starter/src/main/java/com/onixbyte/simplejwt/autoconfiguration/conditions/GuidCreatorCondition.java +++ b/jwt-toolbox-spring-boot-starter/src/main/java/com/onixbyte/jwt/autoconfiguration/conditions/GuidCreatorCondition.java @@ -15,9 +15,9 @@ * limitations under the License. */ -package com.onixbyte.simplejwt.autoconfiguration.conditions; +package com.onixbyte.jwt.autoconfiguration.conditions; -import com.onixbyte.guid.GuidCreator; +import com.onixbyte.identitygenerator.IdentityGenerator; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.annotation.Condition; @@ -46,7 +46,7 @@ public GuidCreatorCondition() { /** * The condition to create bean {@code jtiCreator}. *

- * If Spring does not have a bean of type {@link GuidCreator} named {@code jtiCreator} in the + * If Spring does not have a bean of type {@link IdentityGenerator} named {@code jtiCreator} in the * application context, then create {@code jtiCreator}. * * @param context the spring application context @@ -59,7 +59,7 @@ public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) final var beanFactory = Objects.requireNonNull(context.getBeanFactory()); var isContainJtiCreator = beanFactory.containsBean("jtiCreator"); if (isContainJtiCreator) { - return !(beanFactory.getBean("jtiCreator") instanceof GuidCreator); + return !(beanFactory.getBean("jtiCreator") instanceof IdentityGenerator); } return true; } diff --git a/simple-jwt-spring-boot-starter/src/main/java/com/onixbyte/simplejwt/autoconfiguration/properties/SimpleJwtProperties.java b/jwt-toolbox-spring-boot-starter/src/main/java/com/onixbyte/jwt/autoconfiguration/properties/SimpleJwtProperties.java similarity index 94% rename from simple-jwt-spring-boot-starter/src/main/java/com/onixbyte/simplejwt/autoconfiguration/properties/SimpleJwtProperties.java rename to jwt-toolbox-spring-boot-starter/src/main/java/com/onixbyte/jwt/autoconfiguration/properties/SimpleJwtProperties.java index 826d108..a855305 100644 --- a/simple-jwt-spring-boot-starter/src/main/java/com/onixbyte/simplejwt/autoconfiguration/properties/SimpleJwtProperties.java +++ b/jwt-toolbox-spring-boot-starter/src/main/java/com/onixbyte/jwt/autoconfiguration/properties/SimpleJwtProperties.java @@ -15,11 +15,11 @@ * limitations under the License. */ -package com.onixbyte.simplejwt.autoconfiguration.properties; +package com.onixbyte.jwt.autoconfiguration.properties; -import com.onixbyte.simplejwt.SecretCreator; -import com.onixbyte.simplejwt.autoconfiguration.AuthzeroTokenResolverAutoConfiguration; -import com.onixbyte.simplejwt.constants.TokenAlgorithm; +import com.onixbyte.jwt.SecretCreator; +import com.onixbyte.jwt.autoconfiguration.AuthzeroTokenResolverAutoConfiguration; +import com.onixbyte.jwt.constants.TokenAlgorithm; import org.springframework.boot.context.properties.ConfigurationProperties; /** diff --git a/jwt-toolbox-spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/jwt-toolbox-spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 0000000..fbd0048 --- /dev/null +++ b/jwt-toolbox-spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1,2 @@ +com.onixbyte.jwt.autoconfiguration.GuidAutoConfiguration +com.onixbyte.jwt.autoconfiguration.AuthzeroTokenResolverAutoConfiguration diff --git a/simple-jwt-spring-boot-starter/src/main/resources/logback.xml b/jwt-toolbox-spring-boot-starter/src/main/resources/logback.xml similarity index 100% rename from simple-jwt-spring-boot-starter/src/main/resources/logback.xml rename to jwt-toolbox-spring-boot-starter/src/main/resources/logback.xml diff --git a/key-pair-loader/src/main/java/com/onixbyte/security/KeyLoader.java b/key-pair-loader/src/main/java/com/onixbyte/security/KeyLoader.java deleted file mode 100644 index 7476c8f..0000000 --- a/key-pair-loader/src/main/java/com/onixbyte/security/KeyLoader.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (C) 2024-2025 OnixByte. - * - * 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 com.onixbyte.security; - -import com.onixbyte.security.exception.KeyLoadingException; - -import java.security.PrivateKey; -import java.security.PublicKey; -import java.security.interfaces.ECPublicKey; -import java.security.interfaces.RSAPublicKey; - -/** - * The {@code KeyLoader} class provides utility methods for loading keys pairs from PEM-formatted - * key text. This class supports loading both private and public keys. - *

- * The utility methods in this class are useful for scenarios where ECDSA keys need to be loaded - * from PEM-formatted strings for cryptographic operations. - * - * @author zihluwang - * @version 2.0.0 - * @since 1.6.0 - */ -public interface KeyLoader { - - /** - * Load private key from pem-formatted key text. - * - * @param pemKeyText pem-formatted key text - * @return loaded private key - */ - PrivateKey loadPrivateKey(String pemKeyText); - - /** - * Load public key from pem-formatted key text. - * - * @param pemKeyText pem-formatted key text - * @return loaded private key - */ - PublicKey loadPublicKey(String pemKeyText); - - /** - * Loads an RSA public key using the provided modulus and exponent. - *

- * This default implementation throws a {@link KeyLoadingException} to signify that this key loader does not support - * loading an RSA public key. Implementing classes are expected to override this method to supply their own - * loading logic. - * - * @param modulus the modulus value of the RSA public key, usually represented in hexadecimal or Base64 - * string format - * @param exponent the public exponent value of the RSA public key, usually represented in hexadecimal or Base64 - * string format - * @return the loaded {@link RSAPublicKey} instance - * @throws KeyLoadingException if loading is not supported or fails - */ - default RSAPublicKey loadPublicKey(String modulus, String exponent) { - throw new KeyLoadingException("This key loader does not support loading an RSA public key."); - } - - /** - * Loads an EC public key using the provided x and y coordinates together with the curve name. - *

- * This default implementation throws a {@link KeyLoadingException} to signify that this key loader does not support - * loading an EC public key. Implementing classes are expected to override this method to supply their own - * loading logic. - * - * @param xHex the hexadecimal string representing the x coordinate of the EC point - * @param yHex the hexadecimal string representing the y coordinate of the EC point - * @param curveName the name of the elliptic curve - * @return the loaded {@link ECPublicKey} instance - * @throws KeyLoadingException if loading is not supported or fails - */ - default ECPublicKey loadPublicKey(String xHex, String yHex, String curveName) { - throw new KeyLoadingException("This key loader does not support loading an EC public key."); - } - - /** - * Retrieves the raw content of a PEM formatted key by removing unnecessary headers, footers, - * and new line characters. - * - *

- * This method processes the provided PEM key text to return a cleaned string that contains - * only the key content. The method strips away the - * {@code "-----BEGIN (EC )?(PRIVATE|PUBLIC) KEY-----"} and - * {@code "-----END (EC )?(PRIVATE|PUBLIC) KEY-----"} lines, as well as any new line characters, - * resulting in a continuous string representation of the key, which can be used for further - * cryptographic operations. - * - * @param pemKeyText the PEM formatted key as a string, which may include headers, footers and - * line breaks - * @return a string containing the raw key content devoid of any unnecessary formatting - * or whitespace - */ - default String getRawContent(String pemKeyText) { - // remove all unnecessary parts of the pem key text - return pemKeyText - .replaceAll("-----BEGIN ((EC )|(RSA ))?(PRIVATE|PUBLIC) KEY-----", "") - .replaceAll("-----END ((EC )|(RSA ))?(PRIVATE|PUBLIC) KEY-----", "") - .replaceAll("\n", ""); - } - -} diff --git a/num4j/README.md b/math-toolbox/README.md similarity index 100% rename from num4j/README.md rename to math-toolbox/README.md diff --git a/num4j/build.gradle.kts b/math-toolbox/build.gradle.kts similarity index 92% rename from num4j/build.gradle.kts rename to math-toolbox/build.gradle.kts index c1cf949..520d6dd 100644 --- a/num4j/build.gradle.kts +++ b/math-toolbox/build.gradle.kts @@ -64,9 +64,9 @@ tasks.test { publishing { publications { - create("num4j") { + create("mathToolbox") { groupId = group.toString() - artifactId = "num4j" + artifactId = "math-toolbox" version = artefactVersion pom { @@ -83,8 +83,8 @@ publishing { } scm { - connection = "scm:git:git://github.com:onixbyte/onixbyte-toolbox.git" - developerConnection = "scm:git:git://github.com:onixbyte/onixbyte-toolbox.git" + connection = "scm:git:git://github.com:OnixByte/JDevKit.git" + developerConnection = "scm:git:git://github.com:OnixByte/JDevKit.git" url = projectGithubUrl } @@ -108,7 +108,7 @@ publishing { from(components["java"]) signing { - sign(publishing.publications["num4j"]) + sign(publishing.publications["mathToolbox"]) } } diff --git a/num4j/src/main/java/com/onixbyte/nums/ChainedCalcUtil.java b/math-toolbox/src/main/java/com/onixbyte/math/ChainedCalcUtil.java similarity index 99% rename from num4j/src/main/java/com/onixbyte/nums/ChainedCalcUtil.java rename to math-toolbox/src/main/java/com/onixbyte/math/ChainedCalcUtil.java index 62a7f61..bce105a 100644 --- a/num4j/src/main/java/com/onixbyte/nums/ChainedCalcUtil.java +++ b/math-toolbox/src/main/java/com/onixbyte/math/ChainedCalcUtil.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.onixbyte.nums; +package com.onixbyte.math; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/num4j/src/main/java/com/onixbyte/nums/PercentileCalculator.java b/math-toolbox/src/main/java/com/onixbyte/math/PercentileCalculator.java similarity index 98% rename from num4j/src/main/java/com/onixbyte/nums/PercentileCalculator.java rename to math-toolbox/src/main/java/com/onixbyte/math/PercentileCalculator.java index 3578ec5..3b3439e 100644 --- a/num4j/src/main/java/com/onixbyte/nums/PercentileCalculator.java +++ b/math-toolbox/src/main/java/com/onixbyte/math/PercentileCalculator.java @@ -15,9 +15,9 @@ * limitations under the License. */ -package com.onixbyte.nums; +package com.onixbyte.math; -import com.onixbyte.nums.model.QuartileBounds; +import com.onixbyte.math.model.QuartileBounds; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/num4j/src/main/java/com/onixbyte/nums/model/QuartileBounds.java b/math-toolbox/src/main/java/com/onixbyte/math/model/QuartileBounds.java similarity index 99% rename from num4j/src/main/java/com/onixbyte/nums/model/QuartileBounds.java rename to math-toolbox/src/main/java/com/onixbyte/math/model/QuartileBounds.java index 60b9470..60dafd0 100644 --- a/num4j/src/main/java/com/onixbyte/nums/model/QuartileBounds.java +++ b/math-toolbox/src/main/java/com/onixbyte/math/model/QuartileBounds.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package com.onixbyte.nums.model; +package com.onixbyte.math.model; /** * A record representing the quartile bounds of a dataset. diff --git a/num4j/src/main/resources/logback.xml b/math-toolbox/src/main/resources/logback.xml similarity index 100% rename from num4j/src/main/resources/logback.xml rename to math-toolbox/src/main/resources/logback.xml diff --git a/settings.gradle.kts b/settings.gradle.kts index a87eb97..467fc86 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -18,12 +18,12 @@ rootProject.name = "onixbyte-toolbox" include( - "devkit-bom", - "devkit-utils", - "guid", - "key-pair-loader", - "num4j", - "simple-jwt-facade", - "simple-jwt-authzero", - "simple-jwt-spring-boot-starter", + "version-catalogue", + "common-toolbox", + "identity-generator", + "crypto-toolbox", + "math-toolbox", + "jwt-toolbox-facade", + "jwt-toolbox-auth0", + "jwt-toolbox-spring-boot-starter", ) diff --git a/simple-jwt-spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/simple-jwt-spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports deleted file mode 100644 index a7b7bbe..0000000 --- a/simple-jwt-spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ /dev/null @@ -1,2 +0,0 @@ -com.onixbyte.simplejwt.autoconfiguration.GuidAutoConfiguration -com.onixbyte.simplejwt.autoconfiguration.AuthzeroTokenResolverAutoConfiguration \ No newline at end of file diff --git a/devkit-bom/README.md b/version-catalogue/README.md similarity index 100% rename from devkit-bom/README.md rename to version-catalogue/README.md diff --git a/devkit-bom/build.gradle.kts b/version-catalogue/build.gradle.kts similarity index 95% rename from devkit-bom/build.gradle.kts rename to version-catalogue/build.gradle.kts index e5c2ed2..398eacf 100644 --- a/devkit-bom/build.gradle.kts +++ b/version-catalogue/build.gradle.kts @@ -49,9 +49,9 @@ dependencies { publishing { publications { - create("devkitBom") { + create("versionCatalogue") { groupId = group.toString() - artifactId = "devkit-bom" + artifactId = "version-catalogue" version = artefactVersion pom { @@ -92,7 +92,7 @@ publishing { from(components["javaPlatform"]) signing { - sign(publishing.publications["devkitBom"]) + sign(publishing.publications["versionCatalogue"]) } }