From 71e79933525271679f9e137a4c374cb9fa05a976 Mon Sep 17 00:00:00 2001 From: siujamo Date: Tue, 17 Jun 2025 16:32:57 +0800 Subject: [PATCH 1/9] refactor: rename modules Closes #75 --- {devkit-utils => common-toolbox}/README.md | 0 .../build.gradle.kts | 14 +-- .../com/onixbyte/devkit/utils/AesUtil.java | 0 .../com/onixbyte/devkit/utils/Base64Util.java | 0 .../com/onixbyte/devkit/utils/BoolUtil.java | 0 .../com/onixbyte/devkit/utils/BranchUtil.java | 0 .../onixbyte/devkit/utils/CollectionUtil.java | 0 .../com/onixbyte/devkit/utils/HashUtil.java | 0 .../com/onixbyte/devkit/utils/MapUtil.java | 0 .../devkit/utils/ObjectMapAdapter.java | 0 .../com/onixbyte/devkit/utils/RangeUtil.java | 0 .../src/main/resources/logback.xml | 0 .../onixbyte/devkit/utils/AesUtilTest.java | 0 .../onixbyte/devkit/utils/Base64UtilTest.java | 3 + .../onixbyte/devkit/utils/BoolUtilTest.java | 0 .../onixbyte/devkit/utils/BranchUtilTest.java | 0 .../devkit/utils/CollectionUtilTest.java | 0 .../onixbyte/devkit/utils/HashUtilTest.java | 0 .../onixbyte/devkit/utils/RangeUtilTest.java | 0 {key-pair-loader => crypto-toolbox}/README.md | 0 .../build.gradle.kts | 12 +- .../com/onixbyte/crypto/PrivateKeyLoader.java | 40 ++++++ .../com/onixbyte/crypto/PublicKeyLoader.java | 75 +++++++++++ .../algorithm/ecdsa/ECPrivateKeyLoader.java | 102 +++++++++++++++ .../algorithm/ecdsa/ECPublicKeyLoader.java | 77 +++--------- .../algorithm/rsa/RSAPrivateKeyLoader.java | 102 +++++++++++++++ .../algorithm/rsa/RSAPublicKeyLoader.java | 69 ++--------- .../exception/KeyLoadingException.java | 6 +- .../com/onixbyte/crypto/util/CryptoUtil.java | 49 ++++++++ .../src/main/resources/logback.xml | 0 .../src/test/resources/ec_private_key.pem | 0 .../src/test/resources/ec_public_key.pem | 0 .../src/test/resources/rsa_private_key.pem | 0 .../src/test/resources/rsa_public_key.pem | 0 {guid => identity-generator}/README.md | 2 +- {guid => identity-generator}/build.gradle.kts | 8 +- .../identitygenerator/IdentityGenerator.java | 12 +- .../exceptions/TimingException.java | 2 +- .../impl/SequentialUuidGenerator.java | 12 +- .../impl/SnowflakeIdentityGenerator.java | 16 +-- .../src/main/resources/logback.xml | 0 .../README.md | 0 .../build.gradle.kts | 16 +-- .../authzero/AuthzeroTokenResolver.java | 22 ++-- .../src/main/resources/logback.xml | 0 .../test/TestAuthzeroTokenResolver.java | 6 + .../README.md | 0 .../build.gradle.kts | 12 +- .../com/onixbyte/simplejwt/SecretCreator.java | 0 .../com/onixbyte/simplejwt/TokenPayload.java | 0 .../com/onixbyte/simplejwt/TokenResolver.java | 0 .../annotations/ExcludeFromPayload.java | 0 .../simplejwt/annotations/TokenEnum.java | 0 .../simplejwt/constants/PredefinedKeys.java | 0 .../simplejwt/constants/TokenAlgorithm.java | 0 .../simplejwt/constants/TokenDataType.java | 0 .../exceptions/IllegalKeyPairException.java | 0 .../exceptions/IllegalSecretException.java | 0 .../UnsupportedAlgorithmException.java | 0 .../exceptions/WeakSecretException.java | 0 .../src/main/resources/logback.xml | 0 .../README.md | 4 +- .../build.gradle.kts | 14 +-- ...uthzeroTokenResolverAutoConfiguration.java | 10 +- .../GuidAutoConfiguration.java | 6 +- .../conditions/GuidCreatorCondition.java | 6 +- .../properties/SimpleJwtProperties.java | 0 ...ot.autoconfigure.AutoConfiguration.imports | 0 .../src/main/resources/logback.xml | 0 .../java/com/onixbyte/security/KeyLoader.java | 116 ------------------ {num4j => math-toolbox}/README.md | 0 {num4j => math-toolbox}/build.gradle.kts | 8 +- .../com/onixbyte/nums/ChainedCalcUtil.java | 0 .../onixbyte/nums/PercentileCalculator.java | 0 .../onixbyte/nums/model/QuartileBounds.java | 0 .../src/main/resources/logback.xml | 0 settings.gradle.kts | 16 +-- {devkit-bom => version-catalogue}/README.md | 0 .../build.gradle.kts | 0 79 files changed, 501 insertions(+), 336 deletions(-) rename {devkit-utils => common-toolbox}/README.md (100%) rename {devkit-utils => common-toolbox}/build.gradle.kts (90%) rename {devkit-utils => common-toolbox}/src/main/java/com/onixbyte/devkit/utils/AesUtil.java (100%) rename {devkit-utils => common-toolbox}/src/main/java/com/onixbyte/devkit/utils/Base64Util.java (100%) rename {devkit-utils => common-toolbox}/src/main/java/com/onixbyte/devkit/utils/BoolUtil.java (100%) rename {devkit-utils => common-toolbox}/src/main/java/com/onixbyte/devkit/utils/BranchUtil.java (100%) rename {devkit-utils => common-toolbox}/src/main/java/com/onixbyte/devkit/utils/CollectionUtil.java (100%) rename {devkit-utils => common-toolbox}/src/main/java/com/onixbyte/devkit/utils/HashUtil.java (100%) rename {devkit-utils => common-toolbox}/src/main/java/com/onixbyte/devkit/utils/MapUtil.java (100%) rename {devkit-utils => common-toolbox}/src/main/java/com/onixbyte/devkit/utils/ObjectMapAdapter.java (100%) rename {devkit-utils => common-toolbox}/src/main/java/com/onixbyte/devkit/utils/RangeUtil.java (100%) rename {devkit-utils => common-toolbox}/src/main/resources/logback.xml (100%) rename {devkit-utils => common-toolbox}/src/test/java/com/onixbyte/devkit/utils/AesUtilTest.java (100%) rename {devkit-utils => common-toolbox}/src/test/java/com/onixbyte/devkit/utils/Base64UtilTest.java (97%) rename {devkit-utils => common-toolbox}/src/test/java/com/onixbyte/devkit/utils/BoolUtilTest.java (100%) rename {devkit-utils => common-toolbox}/src/test/java/com/onixbyte/devkit/utils/BranchUtilTest.java (100%) rename {devkit-utils => common-toolbox}/src/test/java/com/onixbyte/devkit/utils/CollectionUtilTest.java (100%) rename {devkit-utils => common-toolbox}/src/test/java/com/onixbyte/devkit/utils/HashUtilTest.java (100%) rename {devkit-utils => common-toolbox}/src/test/java/com/onixbyte/devkit/utils/RangeUtilTest.java (100%) rename {key-pair-loader => crypto-toolbox}/README.md (100%) rename {key-pair-loader => crypto-toolbox}/build.gradle.kts (92%) create mode 100644 crypto-toolbox/src/main/java/com/onixbyte/crypto/PrivateKeyLoader.java create mode 100644 crypto-toolbox/src/main/java/com/onixbyte/crypto/PublicKeyLoader.java create mode 100644 crypto-toolbox/src/main/java/com/onixbyte/crypto/algorithm/ecdsa/ECPrivateKeyLoader.java rename key-pair-loader/src/main/java/com/onixbyte/security/impl/ECKeyLoader.java => crypto-toolbox/src/main/java/com/onixbyte/crypto/algorithm/ecdsa/ECPublicKeyLoader.java (70%) create mode 100644 crypto-toolbox/src/main/java/com/onixbyte/crypto/algorithm/rsa/RSAPrivateKeyLoader.java rename key-pair-loader/src/main/java/com/onixbyte/security/impl/RSAKeyLoader.java => crypto-toolbox/src/main/java/com/onixbyte/crypto/algorithm/rsa/RSAPublicKeyLoader.java (61%) rename {key-pair-loader/src/main/java/com/onixbyte/security => crypto-toolbox/src/main/java/com/onixbyte/crypto}/exception/KeyLoadingException.java (96%) create mode 100644 crypto-toolbox/src/main/java/com/onixbyte/crypto/util/CryptoUtil.java rename {key-pair-loader => crypto-toolbox}/src/main/resources/logback.xml (100%) rename {key-pair-loader => crypto-toolbox}/src/test/resources/ec_private_key.pem (100%) rename {key-pair-loader => crypto-toolbox}/src/test/resources/ec_public_key.pem (100%) rename {key-pair-loader => crypto-toolbox}/src/test/resources/rsa_private_key.pem (100%) rename {key-pair-loader => crypto-toolbox}/src/test/resources/rsa_public_key.pem (100%) rename {guid => identity-generator}/README.md (96%) rename {guid => identity-generator}/build.gradle.kts (94%) rename guid/src/main/java/com/onixbyte/guid/GuidCreator.java => identity-generator/src/main/java/com/onixbyte/identitygenerator/IdentityGenerator.java (81%) rename {guid/src/main/java/com/onixbyte/guid => identity-generator/src/main/java/com/onixbyte/identitygenerator}/exceptions/TimingException.java (97%) rename guid/src/main/java/com/onixbyte/guid/impl/SequentialUuidCreator.java => identity-generator/src/main/java/com/onixbyte/identitygenerator/impl/SequentialUuidGenerator.java (84%) rename guid/src/main/java/com/onixbyte/guid/impl/SnowflakeGuidCreator.java => identity-generator/src/main/java/com/onixbyte/identitygenerator/impl/SnowflakeIdentityGenerator.java (91%) rename {guid => identity-generator}/src/main/resources/logback.xml (100%) rename {simple-jwt-authzero => jwt-toolbox-auth0}/README.md (100%) rename {simple-jwt-authzero => jwt-toolbox-auth0}/build.gradle.kts (90%) rename {simple-jwt-authzero => jwt-toolbox-auth0}/src/main/java/com/onixbyte/simplejwt/authzero/AuthzeroTokenResolver.java (96%) rename {simple-jwt-authzero => jwt-toolbox-auth0}/src/main/resources/logback.xml (100%) rename {simple-jwt-authzero => jwt-toolbox-auth0}/src/test/java/com/onixbyte/simplejwt/authzero/test/TestAuthzeroTokenResolver.java (80%) rename {simple-jwt-facade => jwt-toolbox-facade}/README.md (100%) rename {simple-jwt-facade => jwt-toolbox-facade}/build.gradle.kts (93%) rename {simple-jwt-facade => jwt-toolbox-facade}/src/main/java/com/onixbyte/simplejwt/SecretCreator.java (100%) rename {simple-jwt-facade => jwt-toolbox-facade}/src/main/java/com/onixbyte/simplejwt/TokenPayload.java (100%) rename {simple-jwt-facade => jwt-toolbox-facade}/src/main/java/com/onixbyte/simplejwt/TokenResolver.java (100%) rename {simple-jwt-facade => jwt-toolbox-facade}/src/main/java/com/onixbyte/simplejwt/annotations/ExcludeFromPayload.java (100%) rename {simple-jwt-facade => jwt-toolbox-facade}/src/main/java/com/onixbyte/simplejwt/annotations/TokenEnum.java (100%) rename {simple-jwt-facade => jwt-toolbox-facade}/src/main/java/com/onixbyte/simplejwt/constants/PredefinedKeys.java (100%) rename {simple-jwt-facade => jwt-toolbox-facade}/src/main/java/com/onixbyte/simplejwt/constants/TokenAlgorithm.java (100%) rename {simple-jwt-facade => jwt-toolbox-facade}/src/main/java/com/onixbyte/simplejwt/constants/TokenDataType.java (100%) rename {simple-jwt-facade => jwt-toolbox-facade}/src/main/java/com/onixbyte/simplejwt/exceptions/IllegalKeyPairException.java (100%) rename {simple-jwt-facade => jwt-toolbox-facade}/src/main/java/com/onixbyte/simplejwt/exceptions/IllegalSecretException.java (100%) rename {simple-jwt-facade => jwt-toolbox-facade}/src/main/java/com/onixbyte/simplejwt/exceptions/UnsupportedAlgorithmException.java (100%) rename {simple-jwt-facade => jwt-toolbox-facade}/src/main/java/com/onixbyte/simplejwt/exceptions/WeakSecretException.java (100%) rename {simple-jwt-facade => jwt-toolbox-facade}/src/main/resources/logback.xml (100%) rename {simple-jwt-spring-boot-starter => jwt-toolbox-spring-boot-starter}/README.md (97%) rename {simple-jwt-spring-boot-starter => jwt-toolbox-spring-boot-starter}/build.gradle.kts (92%) rename {simple-jwt-spring-boot-starter => jwt-toolbox-spring-boot-starter}/src/main/java/com/onixbyte/simplejwt/autoconfiguration/AuthzeroTokenResolverAutoConfiguration.java (94%) rename {simple-jwt-spring-boot-starter => jwt-toolbox-spring-boot-starter}/src/main/java/com/onixbyte/simplejwt/autoconfiguration/GuidAutoConfiguration.java (88%) rename {simple-jwt-spring-boot-starter => jwt-toolbox-spring-boot-starter}/src/main/java/com/onixbyte/simplejwt/autoconfiguration/conditions/GuidCreatorCondition.java (91%) rename {simple-jwt-spring-boot-starter => jwt-toolbox-spring-boot-starter}/src/main/java/com/onixbyte/simplejwt/autoconfiguration/properties/SimpleJwtProperties.java (100%) rename {simple-jwt-spring-boot-starter => jwt-toolbox-spring-boot-starter}/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports (100%) rename {simple-jwt-spring-boot-starter => jwt-toolbox-spring-boot-starter}/src/main/resources/logback.xml (100%) delete mode 100644 key-pair-loader/src/main/java/com/onixbyte/security/KeyLoader.java rename {num4j => math-toolbox}/README.md (100%) rename {num4j => math-toolbox}/build.gradle.kts (94%) rename {num4j => math-toolbox}/src/main/java/com/onixbyte/nums/ChainedCalcUtil.java (100%) rename {num4j => math-toolbox}/src/main/java/com/onixbyte/nums/PercentileCalculator.java (100%) rename {num4j => math-toolbox}/src/main/java/com/onixbyte/nums/model/QuartileBounds.java (100%) rename {num4j => math-toolbox}/src/main/resources/logback.xml (100%) rename {devkit-bom => version-catalogue}/README.md (100%) rename {devkit-bom => version-catalogue}/build.gradle.kts (100%) 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/devkit/utils/AesUtil.java similarity index 100% rename from devkit-utils/src/main/java/com/onixbyte/devkit/utils/AesUtil.java rename to common-toolbox/src/main/java/com/onixbyte/devkit/utils/AesUtil.java diff --git a/devkit-utils/src/main/java/com/onixbyte/devkit/utils/Base64Util.java b/common-toolbox/src/main/java/com/onixbyte/devkit/utils/Base64Util.java similarity index 100% rename from devkit-utils/src/main/java/com/onixbyte/devkit/utils/Base64Util.java rename to common-toolbox/src/main/java/com/onixbyte/devkit/utils/Base64Util.java diff --git a/devkit-utils/src/main/java/com/onixbyte/devkit/utils/BoolUtil.java b/common-toolbox/src/main/java/com/onixbyte/devkit/utils/BoolUtil.java similarity index 100% rename from devkit-utils/src/main/java/com/onixbyte/devkit/utils/BoolUtil.java rename to common-toolbox/src/main/java/com/onixbyte/devkit/utils/BoolUtil.java diff --git a/devkit-utils/src/main/java/com/onixbyte/devkit/utils/BranchUtil.java b/common-toolbox/src/main/java/com/onixbyte/devkit/utils/BranchUtil.java similarity index 100% rename from devkit-utils/src/main/java/com/onixbyte/devkit/utils/BranchUtil.java rename to common-toolbox/src/main/java/com/onixbyte/devkit/utils/BranchUtil.java diff --git a/devkit-utils/src/main/java/com/onixbyte/devkit/utils/CollectionUtil.java b/common-toolbox/src/main/java/com/onixbyte/devkit/utils/CollectionUtil.java similarity index 100% rename from devkit-utils/src/main/java/com/onixbyte/devkit/utils/CollectionUtil.java rename to common-toolbox/src/main/java/com/onixbyte/devkit/utils/CollectionUtil.java diff --git a/devkit-utils/src/main/java/com/onixbyte/devkit/utils/HashUtil.java b/common-toolbox/src/main/java/com/onixbyte/devkit/utils/HashUtil.java similarity index 100% rename from devkit-utils/src/main/java/com/onixbyte/devkit/utils/HashUtil.java rename to common-toolbox/src/main/java/com/onixbyte/devkit/utils/HashUtil.java diff --git a/devkit-utils/src/main/java/com/onixbyte/devkit/utils/MapUtil.java b/common-toolbox/src/main/java/com/onixbyte/devkit/utils/MapUtil.java similarity index 100% rename from devkit-utils/src/main/java/com/onixbyte/devkit/utils/MapUtil.java rename to common-toolbox/src/main/java/com/onixbyte/devkit/utils/MapUtil.java diff --git a/devkit-utils/src/main/java/com/onixbyte/devkit/utils/ObjectMapAdapter.java b/common-toolbox/src/main/java/com/onixbyte/devkit/utils/ObjectMapAdapter.java similarity index 100% rename from devkit-utils/src/main/java/com/onixbyte/devkit/utils/ObjectMapAdapter.java rename to common-toolbox/src/main/java/com/onixbyte/devkit/utils/ObjectMapAdapter.java diff --git a/devkit-utils/src/main/java/com/onixbyte/devkit/utils/RangeUtil.java b/common-toolbox/src/main/java/com/onixbyte/devkit/utils/RangeUtil.java similarity index 100% rename from devkit-utils/src/main/java/com/onixbyte/devkit/utils/RangeUtil.java rename to common-toolbox/src/main/java/com/onixbyte/devkit/utils/RangeUtil.java 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/devkit/utils/AesUtilTest.java similarity index 100% rename from devkit-utils/src/test/java/com/onixbyte/devkit/utils/AesUtilTest.java rename to common-toolbox/src/test/java/com/onixbyte/devkit/utils/AesUtilTest.java diff --git a/devkit-utils/src/test/java/com/onixbyte/devkit/utils/Base64UtilTest.java b/common-toolbox/src/test/java/com/onixbyte/devkit/utils/Base64UtilTest.java similarity index 97% rename from devkit-utils/src/test/java/com/onixbyte/devkit/utils/Base64UtilTest.java rename to common-toolbox/src/test/java/com/onixbyte/devkit/utils/Base64UtilTest.java index e044098..aec54fb 100644 --- a/devkit-utils/src/test/java/com/onixbyte/devkit/utils/Base64UtilTest.java +++ b/common-toolbox/src/test/java/com/onixbyte/devkit/utils/Base64UtilTest.java @@ -17,7 +17,10 @@ package com.onixbyte.devkit.utils; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.nio.charset.StandardCharsets; diff --git a/devkit-utils/src/test/java/com/onixbyte/devkit/utils/BoolUtilTest.java b/common-toolbox/src/test/java/com/onixbyte/devkit/utils/BoolUtilTest.java similarity index 100% rename from devkit-utils/src/test/java/com/onixbyte/devkit/utils/BoolUtilTest.java rename to common-toolbox/src/test/java/com/onixbyte/devkit/utils/BoolUtilTest.java diff --git a/devkit-utils/src/test/java/com/onixbyte/devkit/utils/BranchUtilTest.java b/common-toolbox/src/test/java/com/onixbyte/devkit/utils/BranchUtilTest.java similarity index 100% rename from devkit-utils/src/test/java/com/onixbyte/devkit/utils/BranchUtilTest.java rename to common-toolbox/src/test/java/com/onixbyte/devkit/utils/BranchUtilTest.java diff --git a/devkit-utils/src/test/java/com/onixbyte/devkit/utils/CollectionUtilTest.java b/common-toolbox/src/test/java/com/onixbyte/devkit/utils/CollectionUtilTest.java similarity index 100% rename from devkit-utils/src/test/java/com/onixbyte/devkit/utils/CollectionUtilTest.java rename to common-toolbox/src/test/java/com/onixbyte/devkit/utils/CollectionUtilTest.java diff --git a/devkit-utils/src/test/java/com/onixbyte/devkit/utils/HashUtilTest.java b/common-toolbox/src/test/java/com/onixbyte/devkit/utils/HashUtilTest.java similarity index 100% rename from devkit-utils/src/test/java/com/onixbyte/devkit/utils/HashUtilTest.java rename to common-toolbox/src/test/java/com/onixbyte/devkit/utils/HashUtilTest.java diff --git a/devkit-utils/src/test/java/com/onixbyte/devkit/utils/RangeUtilTest.java b/common-toolbox/src/test/java/com/onixbyte/devkit/utils/RangeUtilTest.java similarity index 100% rename from devkit-utils/src/test/java/com/onixbyte/devkit/utils/RangeUtilTest.java rename to common-toolbox/src/test/java/com/onixbyte/devkit/utils/RangeUtilTest.java 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.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
- * 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 { +public class ECPublicKeyLoader implements PublicKeyLoader { + + /** + * Supported curves. + */ + public static final Set SUPPORTED_CURVES = new HashSet<>(Set.of( + "secp256r1", "secp384r1", "secp521r1", "secp224r1" + )); private final KeyFactory keyFactory; private final Base64.Decoder decoder; - /** - * Supported curves. - */ - public static final Set SUPPORTED_CURVES = new HashSet<>(Set.of( - "secp256r1", "secp384r1", "secp521r1", "secp224r1" - )); - /** * 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 class ECKeyLoader implements KeyLoader { } } - /** - * 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 class ECKeyLoader implements KeyLoader { @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 class RSAKeyLoader implements KeyLoader { } } - /** - * 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 class RSAKeyLoader implements KeyLoader { @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 @@ package com.onixbyte.security.exception; *

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 @@ package com.onixbyte.security.exception;
  * }
* * @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 94% rename from guid/build.gradle.kts rename to identity-generator/build.gradle.kts index 6f357b2..83f970b 100644 --- a/guid/build.gradle.kts +++ b/identity-generator/build.gradle.kts @@ -70,7 +70,7 @@ publishing { version = artefactVersion pom { - name = "OnixByte Identity Generator" + name = "DevKit - GUID" description = "The module for generating GUIDs of JDevKit." url = projectUrl @@ -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 } @@ -122,4 +122,4 @@ publishing { } } } -} +} \ No newline at end of file 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 @@ package com.onixbyte.guid; * *

Example usage:

*
{@code
- * public class StringGuidCreator implements GuidCreator {
+ * public class StringGuidCreator implements IdentityGenerator {
  *     private final AtomicLong counter = new AtomicLong();
  *
  *     @Override
@@ -37,7 +37,7 @@ package com.onixbyte.guid;
  *
  * 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 @@ package com.onixbyte.guid;
  * @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 @@ import java.util.UUID; * 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 @@ import java.time.ZoneId; *
  • 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 @@ import java.time.ZoneId; * @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 final class SnowflakeGuidCreator implements GuidCreator { * @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 100% rename from simple-jwt-authzero/README.md rename to jwt-toolbox-auth0/README.md diff --git a/simple-jwt-authzero/build.gradle.kts b/jwt-toolbox-auth0/build.gradle.kts similarity index 90% rename from simple-jwt-authzero/build.gradle.kts rename to jwt-toolbox-auth0/build.gradle.kts index ccf4367..fc4d453 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) @@ -78,7 +78,7 @@ publishing { version = artefactVersion pom { - name = "OnixByte JWT Toolbox :: Auth0 Implementation" + name = "Simple JWT :: 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 } @@ -130,4 +130,4 @@ publishing { } } } -} +} \ No newline at end of file diff --git a/simple-jwt-authzero/src/main/java/com/onixbyte/simplejwt/authzero/AuthzeroTokenResolver.java b/jwt-toolbox-auth0/src/main/java/com/onixbyte/simplejwt/authzero/AuthzeroTokenResolver.java similarity index 96% rename from simple-jwt-authzero/src/main/java/com/onixbyte/simplejwt/authzero/AuthzeroTokenResolver.java rename to jwt-toolbox-auth0/src/main/java/com/onixbyte/simplejwt/authzero/AuthzeroTokenResolver.java index 790700c..5afd00c 100644 --- a/simple-jwt-authzero/src/main/java/com/onixbyte/simplejwt/authzero/AuthzeroTokenResolver.java +++ b/jwt-toolbox-auth0/src/main/java/com/onixbyte/simplejwt/authzero/AuthzeroTokenResolver.java @@ -17,9 +17,9 @@ package com.onixbyte.simplejwt.authzero; +import com.onixbyte.crypto.algorithm.ecdsa.ECPrivateKeyLoader; import com.onixbyte.devkit.utils.Base64Util; -import com.onixbyte.guid.GuidCreator; -import com.onixbyte.security.impl.ECKeyLoader; +import com.onixbyte.identitygenerator.IdentityGenerator; import com.onixbyte.simplejwt.TokenPayload; import com.onixbyte.simplejwt.TokenResolver; import com.onixbyte.simplejwt.annotations.ExcludeFromPayload; @@ -92,7 +92,7 @@ import java.util.function.Function; * * @author Zihlu Wang * @version 1.1.1 - * @see GuidCreator + * @see IdentityGenerator * @see Algorithm * @see JWTVerifier * @see JWTCreator @@ -118,9 +118,9 @@ public class AuthzeroTokenResolver implements TokenResolver { 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 class AuthzeroTokenResolver implements TokenResolver { * @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 class AuthzeroTokenResolver implements TokenResolver { * @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 class AuthzeroTokenResolver implements TokenResolver { } /** - * 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 class AuthzeroTokenResolver implements TokenResolver { * @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/simplejwt/authzero/test/TestAuthzeroTokenResolver.java similarity index 80% 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/simplejwt/authzero/test/TestAuthzeroTokenResolver.java index dc13543..be09ef3 100644 --- a/simple-jwt-authzero/src/test/java/com/onixbyte/simplejwt/authzero/test/TestAuthzeroTokenResolver.java +++ b/jwt-toolbox-auth0/src/test/java/com/onixbyte/simplejwt/authzero/test/TestAuthzeroTokenResolver.java @@ -17,6 +17,12 @@ package com.onixbyte.simplejwt.authzero.test; +import com.onixbyte.simplejwt.authzero.AuthzeroTokenResolver; +import com.onixbyte.simplejwt.constants.TokenAlgorithm; +import org.junit.jupiter.api.Test; + +import java.time.Duration; + /** * 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 93% rename from simple-jwt-facade/build.gradle.kts rename to jwt-toolbox-facade/build.gradle.kts index b19f97b..e114e39 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) @@ -74,7 +74,7 @@ publishing { version = artefactVersion pom { - name = "OnixByte JWT Toolbox :: Facade" + name = "Simple JWT :: Facade" description = "Declaration of simple JWT module." url = projectUrl @@ -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 } @@ -126,4 +126,4 @@ publishing { } } } -} +} \ No newline at end of file diff --git a/simple-jwt-facade/src/main/java/com/onixbyte/simplejwt/SecretCreator.java b/jwt-toolbox-facade/src/main/java/com/onixbyte/simplejwt/SecretCreator.java similarity index 100% rename from simple-jwt-facade/src/main/java/com/onixbyte/simplejwt/SecretCreator.java rename to jwt-toolbox-facade/src/main/java/com/onixbyte/simplejwt/SecretCreator.java diff --git a/simple-jwt-facade/src/main/java/com/onixbyte/simplejwt/TokenPayload.java b/jwt-toolbox-facade/src/main/java/com/onixbyte/simplejwt/TokenPayload.java similarity index 100% rename from simple-jwt-facade/src/main/java/com/onixbyte/simplejwt/TokenPayload.java rename to jwt-toolbox-facade/src/main/java/com/onixbyte/simplejwt/TokenPayload.java diff --git a/simple-jwt-facade/src/main/java/com/onixbyte/simplejwt/TokenResolver.java b/jwt-toolbox-facade/src/main/java/com/onixbyte/simplejwt/TokenResolver.java similarity index 100% rename from simple-jwt-facade/src/main/java/com/onixbyte/simplejwt/TokenResolver.java rename to jwt-toolbox-facade/src/main/java/com/onixbyte/simplejwt/TokenResolver.java diff --git a/simple-jwt-facade/src/main/java/com/onixbyte/simplejwt/annotations/ExcludeFromPayload.java b/jwt-toolbox-facade/src/main/java/com/onixbyte/simplejwt/annotations/ExcludeFromPayload.java similarity index 100% rename from simple-jwt-facade/src/main/java/com/onixbyte/simplejwt/annotations/ExcludeFromPayload.java rename to jwt-toolbox-facade/src/main/java/com/onixbyte/simplejwt/annotations/ExcludeFromPayload.java diff --git a/simple-jwt-facade/src/main/java/com/onixbyte/simplejwt/annotations/TokenEnum.java b/jwt-toolbox-facade/src/main/java/com/onixbyte/simplejwt/annotations/TokenEnum.java similarity index 100% rename from simple-jwt-facade/src/main/java/com/onixbyte/simplejwt/annotations/TokenEnum.java rename to jwt-toolbox-facade/src/main/java/com/onixbyte/simplejwt/annotations/TokenEnum.java diff --git a/simple-jwt-facade/src/main/java/com/onixbyte/simplejwt/constants/PredefinedKeys.java b/jwt-toolbox-facade/src/main/java/com/onixbyte/simplejwt/constants/PredefinedKeys.java similarity index 100% rename from simple-jwt-facade/src/main/java/com/onixbyte/simplejwt/constants/PredefinedKeys.java rename to jwt-toolbox-facade/src/main/java/com/onixbyte/simplejwt/constants/PredefinedKeys.java diff --git a/simple-jwt-facade/src/main/java/com/onixbyte/simplejwt/constants/TokenAlgorithm.java b/jwt-toolbox-facade/src/main/java/com/onixbyte/simplejwt/constants/TokenAlgorithm.java similarity index 100% rename from simple-jwt-facade/src/main/java/com/onixbyte/simplejwt/constants/TokenAlgorithm.java rename to jwt-toolbox-facade/src/main/java/com/onixbyte/simplejwt/constants/TokenAlgorithm.java diff --git a/simple-jwt-facade/src/main/java/com/onixbyte/simplejwt/constants/TokenDataType.java b/jwt-toolbox-facade/src/main/java/com/onixbyte/simplejwt/constants/TokenDataType.java similarity index 100% rename from simple-jwt-facade/src/main/java/com/onixbyte/simplejwt/constants/TokenDataType.java rename to jwt-toolbox-facade/src/main/java/com/onixbyte/simplejwt/constants/TokenDataType.java diff --git a/simple-jwt-facade/src/main/java/com/onixbyte/simplejwt/exceptions/IllegalKeyPairException.java b/jwt-toolbox-facade/src/main/java/com/onixbyte/simplejwt/exceptions/IllegalKeyPairException.java similarity index 100% rename from simple-jwt-facade/src/main/java/com/onixbyte/simplejwt/exceptions/IllegalKeyPairException.java rename to jwt-toolbox-facade/src/main/java/com/onixbyte/simplejwt/exceptions/IllegalKeyPairException.java diff --git a/simple-jwt-facade/src/main/java/com/onixbyte/simplejwt/exceptions/IllegalSecretException.java b/jwt-toolbox-facade/src/main/java/com/onixbyte/simplejwt/exceptions/IllegalSecretException.java similarity index 100% rename from simple-jwt-facade/src/main/java/com/onixbyte/simplejwt/exceptions/IllegalSecretException.java rename to jwt-toolbox-facade/src/main/java/com/onixbyte/simplejwt/exceptions/IllegalSecretException.java diff --git a/simple-jwt-facade/src/main/java/com/onixbyte/simplejwt/exceptions/UnsupportedAlgorithmException.java b/jwt-toolbox-facade/src/main/java/com/onixbyte/simplejwt/exceptions/UnsupportedAlgorithmException.java similarity index 100% rename from simple-jwt-facade/src/main/java/com/onixbyte/simplejwt/exceptions/UnsupportedAlgorithmException.java rename to jwt-toolbox-facade/src/main/java/com/onixbyte/simplejwt/exceptions/UnsupportedAlgorithmException.java diff --git a/simple-jwt-facade/src/main/java/com/onixbyte/simplejwt/exceptions/WeakSecretException.java b/jwt-toolbox-facade/src/main/java/com/onixbyte/simplejwt/exceptions/WeakSecretException.java similarity index 100% rename from simple-jwt-facade/src/main/java/com/onixbyte/simplejwt/exceptions/WeakSecretException.java rename to jwt-toolbox-facade/src/main/java/com/onixbyte/simplejwt/exceptions/WeakSecretException.java 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 92% rename from simple-jwt-spring-boot-starter/build.gradle.kts rename to jwt-toolbox-spring-boot-starter/build.gradle.kts index 8bd585b..1a7b0f3 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) @@ -87,7 +87,7 @@ publishing { version = artefactVersion pom { - name = "OnixByte JWT Toolbox :: Spring Boot Starter" + name = "Simple JWT :: Spring Boot Starter" description = "Simple JWT all-in-one package for Spring Boot." url = projectUrl @@ -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 } @@ -139,4 +139,4 @@ publishing { } } } -} +} \ No newline at end of file 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/simplejwt/autoconfiguration/AuthzeroTokenResolverAutoConfiguration.java similarity index 94% 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/simplejwt/autoconfiguration/AuthzeroTokenResolverAutoConfiguration.java index dd30bde..7dd52a4 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/simplejwt/autoconfiguration/AuthzeroTokenResolverAutoConfiguration.java @@ -17,7 +17,7 @@ package com.onixbyte.simplejwt.autoconfiguration; -import com.onixbyte.guid.GuidCreator; +import com.onixbyte.identitygenerator.IdentityGenerator; import com.onixbyte.simplejwt.TokenResolver; import com.onixbyte.simplejwt.authzero.AuthzeroTokenResolver; import com.onixbyte.simplejwt.autoconfiguration.properties.SimpleJwtProperties; @@ -60,7 +60,7 @@ import org.springframework.context.annotation.Bean; @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 class AuthzeroTokenResolverAutoConfiguration { /** * 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 class AuthzeroTokenResolverAutoConfiguration { 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/simplejwt/autoconfiguration/GuidAutoConfiguration.java similarity index 88% 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/simplejwt/autoconfiguration/GuidAutoConfiguration.java index 149aabf..16a42f8 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/simplejwt/autoconfiguration/GuidAutoConfiguration.java @@ -17,7 +17,7 @@ package com.onixbyte.simplejwt.autoconfiguration; -import com.onixbyte.guid.GuidCreator; +import com.onixbyte.identitygenerator.IdentityGenerator; import com.onixbyte.simplejwt.autoconfiguration.conditions.GuidCreatorCondition; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -28,7 +28,7 @@ import org.springframework.context.annotation.Conditional; 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 class 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/simplejwt/autoconfiguration/conditions/GuidCreatorCondition.java similarity index 91% 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/simplejwt/autoconfiguration/conditions/GuidCreatorCondition.java index ff0410a..f282db6 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/simplejwt/autoconfiguration/conditions/GuidCreatorCondition.java @@ -17,7 +17,7 @@ package com.onixbyte.simplejwt.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 class GuidCreatorCondition implements Condition { /** * 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 class GuidCreatorCondition implements Condition { 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/simplejwt/autoconfiguration/properties/SimpleJwtProperties.java similarity index 100% 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/simplejwt/autoconfiguration/properties/SimpleJwtProperties.java diff --git a/simple-jwt-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 similarity index 100% rename from simple-jwt-spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports rename to jwt-toolbox-spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports 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 94% rename from num4j/build.gradle.kts rename to math-toolbox/build.gradle.kts index c1cf949..e58a9e7 100644 --- a/num4j/build.gradle.kts +++ b/math-toolbox/build.gradle.kts @@ -70,7 +70,7 @@ publishing { version = artefactVersion pom { - name = "OnixByte Math Toolbox" + name = "Num4j" description = "This module is an easy-to-use util for mathematical calculations in Java." url = projectUrl @@ -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 } @@ -123,4 +123,4 @@ publishing { } } } -} +} \ No newline at end of file diff --git a/num4j/src/main/java/com/onixbyte/nums/ChainedCalcUtil.java b/math-toolbox/src/main/java/com/onixbyte/nums/ChainedCalcUtil.java similarity index 100% rename from num4j/src/main/java/com/onixbyte/nums/ChainedCalcUtil.java rename to math-toolbox/src/main/java/com/onixbyte/nums/ChainedCalcUtil.java diff --git a/num4j/src/main/java/com/onixbyte/nums/PercentileCalculator.java b/math-toolbox/src/main/java/com/onixbyte/nums/PercentileCalculator.java similarity index 100% rename from num4j/src/main/java/com/onixbyte/nums/PercentileCalculator.java rename to math-toolbox/src/main/java/com/onixbyte/nums/PercentileCalculator.java diff --git a/num4j/src/main/java/com/onixbyte/nums/model/QuartileBounds.java b/math-toolbox/src/main/java/com/onixbyte/nums/model/QuartileBounds.java similarity index 100% rename from num4j/src/main/java/com/onixbyte/nums/model/QuartileBounds.java rename to math-toolbox/src/main/java/com/onixbyte/nums/model/QuartileBounds.java 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/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 100% rename from devkit-bom/build.gradle.kts rename to version-catalogue/build.gradle.kts From c48577544a7da16718e611423680eaaf8597aa73 Mon Sep 17 00:00:00 2001 From: siujamo Date: Tue, 17 Jun 2025 17:40:21 +0800 Subject: [PATCH 2/9] refactor: rename modules Closes #75 --- .../utils => common/util}/AesUtil.java | 2 +- .../utils => common/util}/Base64Util.java | 4 ++-- .../utils => common/util}/BoolUtil.java | 2 +- .../utils => common/util}/BranchUtil.java | 2 +- .../utils => common/util}/CollectionUtil.java | 2 +- .../utils => common/util}/HashUtil.java | 2 +- .../utils => common/util}/MapUtil.java | 2 +- .../util}/ObjectMapAdapter.java | 2 +- .../utils => common/util}/RangeUtil.java | 2 +- .../utils => common/util}/AesUtilTest.java | 2 +- .../utils => common/util}/Base64UtilTest.java | 5 +---- .../utils => common/util}/BoolUtilTest.java | 2 +- .../utils => common/util}/BranchUtilTest.java | 2 +- .../util}/CollectionUtilTest.java | 2 +- .../utils => common/util}/HashUtilTest.java | 2 +- .../utils => common/util}/RangeUtilTest.java | 2 +- identity-generator/build.gradle.kts | 10 ++++----- jwt-toolbox-auth0/README.md | 2 +- jwt-toolbox-auth0/build.gradle.kts | 10 ++++----- .../auth0}/AuthzeroTokenResolver.java | 22 +++++++++---------- .../test/TestAuthzeroTokenResolver.java | 8 +------ jwt-toolbox-facade/build.gradle.kts | 10 ++++----- .../{simplejwt => jwt}/SecretCreator.java | 4 ++-- .../{simplejwt => jwt}/TokenPayload.java | 2 +- .../{simplejwt => jwt}/TokenResolver.java | 2 +- .../annotations/ExcludeFromPayload.java | 2 +- .../annotations/TokenEnum.java | 4 ++-- .../constants/PredefinedKeys.java | 2 +- .../constants/TokenAlgorithm.java | 2 +- .../constants/TokenDataType.java | 2 +- .../exceptions/IllegalKeyPairException.java | 2 +- .../exceptions/IllegalSecretException.java | 2 +- .../UnsupportedAlgorithmException.java | 4 ++-- .../exceptions/WeakSecretException.java | 2 +- .../build.gradle.kts | 10 ++++----- ...uthzeroTokenResolverAutoConfiguration.java | 10 ++++----- .../GuidAutoConfiguration.java | 4 ++-- .../conditions/GuidCreatorCondition.java | 2 +- .../properties/SimpleJwtProperties.java | 8 +++---- ...ot.autoconfigure.AutoConfiguration.imports | 4 ++-- math-toolbox/build.gradle.kts | 10 ++++----- .../{nums => math}/ChainedCalcUtil.java | 2 +- .../{nums => math}/PercentileCalculator.java | 4 ++-- .../{nums => math}/model/QuartileBounds.java | 2 +- version-catalogue/build.gradle.kts | 6 ++--- 45 files changed, 91 insertions(+), 100 deletions(-) rename common-toolbox/src/main/java/com/onixbyte/{devkit/utils => common/util}/AesUtil.java (99%) rename common-toolbox/src/main/java/com/onixbyte/{devkit/utils => common/util}/Base64Util.java (99%) rename common-toolbox/src/main/java/com/onixbyte/{devkit/utils => common/util}/BoolUtil.java (98%) rename common-toolbox/src/main/java/com/onixbyte/{devkit/utils => common/util}/BranchUtil.java (99%) rename common-toolbox/src/main/java/com/onixbyte/{devkit/utils => common/util}/CollectionUtil.java (99%) rename common-toolbox/src/main/java/com/onixbyte/{devkit/utils => common/util}/HashUtil.java (99%) rename common-toolbox/src/main/java/com/onixbyte/{devkit/utils => common/util}/MapUtil.java (99%) rename common-toolbox/src/main/java/com/onixbyte/{devkit/utils => common/util}/ObjectMapAdapter.java (98%) rename common-toolbox/src/main/java/com/onixbyte/{devkit/utils => common/util}/RangeUtil.java (99%) rename common-toolbox/src/test/java/com/onixbyte/{devkit/utils => common/util}/AesUtilTest.java (98%) rename common-toolbox/src/test/java/com/onixbyte/{devkit/utils => common/util}/Base64UtilTest.java (96%) rename common-toolbox/src/test/java/com/onixbyte/{devkit/utils => common/util}/BoolUtilTest.java (99%) rename common-toolbox/src/test/java/com/onixbyte/{devkit/utils => common/util}/BranchUtilTest.java (99%) rename common-toolbox/src/test/java/com/onixbyte/{devkit/utils => common/util}/CollectionUtilTest.java (99%) rename common-toolbox/src/test/java/com/onixbyte/{devkit/utils => common/util}/HashUtilTest.java (99%) rename common-toolbox/src/test/java/com/onixbyte/{devkit/utils => common/util}/RangeUtilTest.java (99%) rename jwt-toolbox-auth0/src/main/java/com/onixbyte/{simplejwt/authzero => jwt/auth0}/AuthzeroTokenResolver.java (97%) rename jwt-toolbox-auth0/src/test/java/com/onixbyte/{simplejwt/authzero => jwt/auth0}/test/TestAuthzeroTokenResolver.java (75%) rename jwt-toolbox-facade/src/main/java/com/onixbyte/{simplejwt => jwt}/SecretCreator.java (98%) rename jwt-toolbox-facade/src/main/java/com/onixbyte/{simplejwt => jwt}/TokenPayload.java (97%) rename jwt-toolbox-facade/src/main/java/com/onixbyte/{simplejwt => jwt}/TokenResolver.java (99%) rename jwt-toolbox-facade/src/main/java/com/onixbyte/{simplejwt => jwt}/annotations/ExcludeFromPayload.java (97%) rename jwt-toolbox-facade/src/main/java/com/onixbyte/{simplejwt => jwt}/annotations/TokenEnum.java (93%) rename jwt-toolbox-facade/src/main/java/com/onixbyte/{simplejwt => jwt}/constants/PredefinedKeys.java (98%) rename jwt-toolbox-facade/src/main/java/com/onixbyte/{simplejwt => jwt}/constants/TokenAlgorithm.java (98%) rename jwt-toolbox-facade/src/main/java/com/onixbyte/{simplejwt => jwt}/constants/TokenDataType.java (97%) rename jwt-toolbox-facade/src/main/java/com/onixbyte/{simplejwt => jwt}/exceptions/IllegalKeyPairException.java (97%) rename jwt-toolbox-facade/src/main/java/com/onixbyte/{simplejwt => jwt}/exceptions/IllegalSecretException.java (97%) rename jwt-toolbox-facade/src/main/java/com/onixbyte/{simplejwt => jwt}/exceptions/UnsupportedAlgorithmException.java (97%) rename jwt-toolbox-facade/src/main/java/com/onixbyte/{simplejwt => jwt}/exceptions/WeakSecretException.java (98%) rename jwt-toolbox-spring-boot-starter/src/main/java/com/onixbyte/{simplejwt => jwt}/autoconfiguration/AuthzeroTokenResolverAutoConfiguration.java (94%) rename jwt-toolbox-spring-boot-starter/src/main/java/com/onixbyte/{simplejwt => jwt}/autoconfiguration/GuidAutoConfiguration.java (92%) rename jwt-toolbox-spring-boot-starter/src/main/java/com/onixbyte/{simplejwt => jwt}/autoconfiguration/conditions/GuidCreatorCondition.java (97%) rename jwt-toolbox-spring-boot-starter/src/main/java/com/onixbyte/{simplejwt => jwt}/autoconfiguration/properties/SimpleJwtProperties.java (94%) rename math-toolbox/src/main/java/com/onixbyte/{nums => math}/ChainedCalcUtil.java (99%) rename math-toolbox/src/main/java/com/onixbyte/{nums => math}/PercentileCalculator.java (98%) rename math-toolbox/src/main/java/com/onixbyte/{nums => math}/model/QuartileBounds.java (99%) diff --git a/common-toolbox/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 common-toolbox/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/common-toolbox/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/common-toolbox/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 common-toolbox/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/common-toolbox/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 final class Base64Util { private static Base64.Decoder urlDecoder; -} \ No newline at end of file +} diff --git a/common-toolbox/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 common-toolbox/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/common-toolbox/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/common-toolbox/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 common-toolbox/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/common-toolbox/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/common-toolbox/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 common-toolbox/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/common-toolbox/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/common-toolbox/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 common-toolbox/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/common-toolbox/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/common-toolbox/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 common-toolbox/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/common-toolbox/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/common-toolbox/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 common-toolbox/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/common-toolbox/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/common-toolbox/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 common-toolbox/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/common-toolbox/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/common-toolbox/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 common-toolbox/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/common-toolbox/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/common-toolbox/src/test/java/com/onixbyte/devkit/utils/Base64UtilTest.java b/common-toolbox/src/test/java/com/onixbyte/common/util/Base64UtilTest.java similarity index 96% rename from common-toolbox/src/test/java/com/onixbyte/devkit/utils/Base64UtilTest.java rename to common-toolbox/src/test/java/com/onixbyte/common/util/Base64UtilTest.java index aec54fb..732b4c1 100644 --- a/common-toolbox/src/test/java/com/onixbyte/devkit/utils/Base64UtilTest.java +++ b/common-toolbox/src/test/java/com/onixbyte/common/util/Base64UtilTest.java @@ -15,12 +15,9 @@ * limitations under the License. */ -package com.onixbyte.devkit.utils; +package com.onixbyte.common.util; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.nio.charset.StandardCharsets; diff --git a/common-toolbox/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 common-toolbox/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/common-toolbox/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/common-toolbox/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 common-toolbox/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/common-toolbox/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/common-toolbox/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 common-toolbox/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/common-toolbox/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/common-toolbox/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 common-toolbox/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/common-toolbox/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/common-toolbox/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 common-toolbox/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/common-toolbox/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/identity-generator/build.gradle.kts b/identity-generator/build.gradle.kts index 83f970b..8821412 100644 --- a/identity-generator/build.gradle.kts +++ b/identity-generator/build.gradle.kts @@ -64,13 +64,13 @@ tasks.test { publishing { publications { - create("guid") { + create("identityGenerator") { groupId = group.toString() - artifactId = "guid" + artifactId = "identity-generator" version = artefactVersion pom { - name = "DevKit - GUID" + name = "OnixByte Identity Generator" description = "The module for generating GUIDs of JDevKit." url = projectUrl @@ -107,7 +107,7 @@ publishing { from(components["java"]) signing { - sign(publishing.publications["guid"]) + sign(publishing.publications["identityGenerator"]) } } @@ -122,4 +122,4 @@ publishing { } } } -} \ No newline at end of file +} diff --git a/jwt-toolbox-auth0/README.md b/jwt-toolbox-auth0/README.md index fbebcda..ee055b3 100644 --- a/jwt-toolbox-auth0/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/jwt-toolbox-auth0/build.gradle.kts b/jwt-toolbox-auth0/build.gradle.kts index fc4d453..91c2151 100644 --- a/jwt-toolbox-auth0/build.gradle.kts +++ b/jwt-toolbox-auth0/build.gradle.kts @@ -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 = "Simple JWT :: Auth0" + name = "OnixByte JWT Toolbox :: Auth0" description = "Simple JWT implemented with com.auth0:java-jwt." url = projectUrl @@ -115,7 +115,7 @@ publishing { from(components["java"]) signing { - sign(publishing.publications["simpleJwtAuthzero"]) + sign(publishing.publications["jwtToolboxAuth0"]) } } @@ -130,4 +130,4 @@ publishing { } } } -} \ No newline at end of file +} diff --git a/jwt-toolbox-auth0/src/main/java/com/onixbyte/simplejwt/authzero/AuthzeroTokenResolver.java b/jwt-toolbox-auth0/src/main/java/com/onixbyte/jwt/auth0/AuthzeroTokenResolver.java similarity index 97% rename from jwt-toolbox-auth0/src/main/java/com/onixbyte/simplejwt/authzero/AuthzeroTokenResolver.java rename to jwt-toolbox-auth0/src/main/java/com/onixbyte/jwt/auth0/AuthzeroTokenResolver.java index 5afd00c..b6e6206 100644 --- a/jwt-toolbox-auth0/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; +package com.onixbyte.jwt.auth0; +import com.onixbyte.common.util.Base64Util; import com.onixbyte.crypto.algorithm.ecdsa.ECPrivateKeyLoader; -import com.onixbyte.devkit.utils.Base64Util; import com.onixbyte.identitygenerator.IdentityGenerator; -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; +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.JsonProcessingException; 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; diff --git a/jwt-toolbox-auth0/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 75% rename from jwt-toolbox-auth0/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 be09ef3..68ecf82 100644 --- a/jwt-toolbox-auth0/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,13 +15,7 @@ * limitations under the License. */ -package com.onixbyte.simplejwt.authzero.test; - -import com.onixbyte.simplejwt.authzero.AuthzeroTokenResolver; -import com.onixbyte.simplejwt.constants.TokenAlgorithm; -import org.junit.jupiter.api.Test; - -import java.time.Duration; +package com.onixbyte.jwt.auth0.test; /** * TestAuthzeroTokenResolver diff --git a/jwt-toolbox-facade/build.gradle.kts b/jwt-toolbox-facade/build.gradle.kts index e114e39..6f3dddd 100644 --- a/jwt-toolbox-facade/build.gradle.kts +++ b/jwt-toolbox-facade/build.gradle.kts @@ -68,13 +68,13 @@ tasks.test { publishing { publications { - create("simpleJwtFacade") { + create("jwtToolboxFacade") { groupId = group.toString() - artifactId = "simple-jwt-facade" + artifactId = "jwt-toolbox-facade" version = artefactVersion pom { - name = "Simple JWT :: Facade" + name = "OnixByte JWT Toolbox :: Facade" description = "Declaration of simple JWT module." url = projectUrl @@ -111,7 +111,7 @@ publishing { from(components["java"]) signing { - sign(publishing.publications["simpleJwtFacade"]) + sign(publishing.publications["jwtToolboxFacade"]) } } @@ -126,4 +126,4 @@ publishing { } } } -} \ No newline at end of file +} diff --git a/jwt-toolbox-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 jwt-toolbox-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/jwt-toolbox-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/jwt-toolbox-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 jwt-toolbox-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/jwt-toolbox-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/jwt-toolbox-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 jwt-toolbox-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/jwt-toolbox-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/jwt-toolbox-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 jwt-toolbox-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/jwt-toolbox-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/jwt-toolbox-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 jwt-toolbox-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/jwt-toolbox-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/jwt-toolbox-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 jwt-toolbox-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/jwt-toolbox-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/jwt-toolbox-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 jwt-toolbox-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/jwt-toolbox-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/jwt-toolbox-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 jwt-toolbox-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/jwt-toolbox-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/jwt-toolbox-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 jwt-toolbox-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/jwt-toolbox-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/jwt-toolbox-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 jwt-toolbox-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/jwt-toolbox-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/jwt-toolbox-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 jwt-toolbox-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/jwt-toolbox-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/jwt-toolbox-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 jwt-toolbox-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/jwt-toolbox-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/jwt-toolbox-spring-boot-starter/build.gradle.kts b/jwt-toolbox-spring-boot-starter/build.gradle.kts index 1a7b0f3..65d0eac 100644 --- a/jwt-toolbox-spring-boot-starter/build.gradle.kts +++ b/jwt-toolbox-spring-boot-starter/build.gradle.kts @@ -81,13 +81,13 @@ 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 { - name = "Simple JWT :: Spring Boot Starter" + name = "OnixByte JWT Toolbox :: Spring Boot Starter" description = "Simple JWT all-in-one package for Spring Boot." url = projectUrl @@ -124,7 +124,7 @@ publishing { from(components["java"]) signing { - sign(publishing.publications["simpleJwtSpringBootStarter"]) + sign(publishing.publications["jwtSpringBootStarter"]) } } @@ -139,4 +139,4 @@ publishing { } } } -} \ No newline at end of file +} diff --git a/jwt-toolbox-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 94% rename from jwt-toolbox-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 7dd52a4..f1a5e4f 100644 --- a/jwt-toolbox-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.identitygenerator.IdentityGenerator; -import com.onixbyte.simplejwt.TokenResolver; -import com.onixbyte.simplejwt.authzero.AuthzeroTokenResolver; -import com.onixbyte.simplejwt.autoconfiguration.properties.SimpleJwtProperties; +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; diff --git a/jwt-toolbox-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 92% rename from jwt-toolbox-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 16a42f8..674e2dd 100644 --- a/jwt-toolbox-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.identitygenerator.IdentityGenerator; -import com.onixbyte.simplejwt.autoconfiguration.conditions.GuidCreatorCondition; +import com.onixbyte.jwt.autoconfiguration.conditions.GuidCreatorCondition; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.autoconfigure.AutoConfiguration; diff --git a/jwt-toolbox-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 97% rename from jwt-toolbox-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 f282db6..0b62b61 100644 --- a/jwt-toolbox-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,7 +15,7 @@ * limitations under the License. */ -package com.onixbyte.simplejwt.autoconfiguration.conditions; +package com.onixbyte.jwt.autoconfiguration.conditions; import com.onixbyte.identitygenerator.IdentityGenerator; import org.slf4j.Logger; diff --git a/jwt-toolbox-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 jwt-toolbox-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/jwt-toolbox-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 index a7b7bbe..fbd0048 100644 --- 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 @@ -1,2 +1,2 @@ -com.onixbyte.simplejwt.autoconfiguration.GuidAutoConfiguration -com.onixbyte.simplejwt.autoconfiguration.AuthzeroTokenResolverAutoConfiguration \ No newline at end of file +com.onixbyte.jwt.autoconfiguration.GuidAutoConfiguration +com.onixbyte.jwt.autoconfiguration.AuthzeroTokenResolverAutoConfiguration diff --git a/math-toolbox/build.gradle.kts b/math-toolbox/build.gradle.kts index e58a9e7..520d6dd 100644 --- a/math-toolbox/build.gradle.kts +++ b/math-toolbox/build.gradle.kts @@ -64,13 +64,13 @@ tasks.test { publishing { publications { - create("num4j") { + create("mathToolbox") { groupId = group.toString() - artifactId = "num4j" + artifactId = "math-toolbox" version = artefactVersion pom { - name = "Num4j" + name = "OnixByte Math Toolbox" description = "This module is an easy-to-use util for mathematical calculations in Java." url = projectUrl @@ -108,7 +108,7 @@ publishing { from(components["java"]) signing { - sign(publishing.publications["num4j"]) + sign(publishing.publications["mathToolbox"]) } } @@ -123,4 +123,4 @@ publishing { } } } -} \ No newline at end of file +} diff --git a/math-toolbox/src/main/java/com/onixbyte/nums/ChainedCalcUtil.java b/math-toolbox/src/main/java/com/onixbyte/math/ChainedCalcUtil.java similarity index 99% rename from math-toolbox/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/math-toolbox/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/math-toolbox/src/main/java/com/onixbyte/nums/PercentileCalculator.java b/math-toolbox/src/main/java/com/onixbyte/math/PercentileCalculator.java similarity index 98% rename from math-toolbox/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/math-toolbox/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/math-toolbox/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 math-toolbox/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/math-toolbox/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/version-catalogue/build.gradle.kts b/version-catalogue/build.gradle.kts index e5c2ed2..398eacf 100644 --- a/version-catalogue/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"]) } } From a8784228895955bbc42ce0b71424be06d8d04f32 Mon Sep 17 00:00:00 2001 From: zihluwang Date: Tue, 17 Jun 2025 23:07:52 +0800 Subject: [PATCH 3/9] refactor: change to MIT license and reformat codes --- CODE_OF_CONDUCT.md | 33 +- CONTRIBUTING.md | 30 +- LICENSE | 215 +----- build.gradle.kts | 29 +- common-toolbox/build.gradle.kts | 34 +- .../com/onixbyte/common/util/AesUtil.java | 65 +- .../com/onixbyte/common/util/Base64Util.java | 56 +- .../com/onixbyte/common/util/BoolUtil.java | 48 +- .../com/onixbyte/common/util/BranchUtil.java | 34 +- .../onixbyte/common/util/CollectionUtil.java | 28 +- .../com/onixbyte/common/util/HashUtil.java | 42 +- .../com/onixbyte/common/util/MapUtil.java | 52 +- .../common/util/ObjectMapAdapter.java | 36 +- .../com/onixbyte/common/util/RangeUtil.java | 49 +- common-toolbox/src/main/resources/logback.xml | 31 +- crypto-toolbox/build.gradle.kts | 34 +- .../com/onixbyte/crypto/PrivateKeyLoader.java | 30 +- .../com/onixbyte/crypto/PublicKeyLoader.java | 27 +- .../algorithm/ecdsa/ECPrivateKeyLoader.java | 41 +- .../algorithm/ecdsa/ECPublicKeyLoader.java | 30 +- .../algorithm/rsa/RSAPrivateKeyLoader.java | 36 +- .../algorithm/rsa/RSAPublicKeyLoader.java | 30 +- .../crypto/exception/KeyLoadingException.java | 28 +- .../com/onixbyte/crypto/util/CryptoUtil.java | 33 +- crypto-toolbox/src/main/resources/logback.xml | 37 +- gradle/wrapper/gradle-wrapper.jar | Bin 43462 -> 0 bytes gradlew | 26 +- identity-generator/build.gradle.kts | 28 +- .../identitygenerator/IdentityGenerator.java | 36 +- .../exceptions/TimingException.java | 31 +- .../impl/SequentialUuidGenerator.java | 46 +- .../impl/SnowflakeIdentityGenerator.java | 264 +++---- .../src/main/resources/logback.xml | 40 +- jwt-toolbox-auth0/README.md | 63 +- jwt-toolbox-auth0/build.gradle.kts | 31 +- .../jwt/auth0/Auth0TokenGenerator.java | 28 + .../onixbyte/jwt/auth0/Auth0TokenParser.java | 46 ++ .../jwt/auth0/AuthzeroTokenResolver.java | 658 ------------------ .../src/main/resources/logback.xml | 37 +- .../auth0/test/TestAuthzeroTokenResolver.java | 27 - jwt-toolbox-facade/README.md | 42 +- jwt-toolbox-facade/build.gradle.kts | 32 +- .../java/com/onixbyte/jwt/SecretCreator.java | 39 +- .../java/com/onixbyte/jwt/TokenGenerator.java | 26 + .../java/com/onixbyte/jwt/TokenParser.java | 26 + .../java/com/onixbyte/jwt/TokenPayload.java | 45 -- .../java/com/onixbyte/jwt/TokenResolver.java | 184 ----- .../jwt/annotations/ExcludeFromPayload.java | 60 -- .../onixbyte/jwt/annotations/TokenEnum.java | 51 -- .../jwt/constants/PredefinedKeys.java | 54 +- .../jwt/constants/TokenAlgorithm.java | 65 +- .../onixbyte/jwt/constants/TokenDataType.java | 78 --- .../exceptions/IllegalKeyPairException.java | 29 +- .../exceptions/IllegalSecretException.java | 29 +- .../UnsupportedAlgorithmException.java | 97 ++- .../jwt/exceptions/WeakSecretException.java | 101 +-- .../src/main/resources/logback.xml | 37 +- jwt-toolbox-spring-boot-starter/README.md | 11 +- .../build.gradle.kts | 32 +- ...uthzeroTokenResolverAutoConfiguration.java | 119 ---- .../GuidAutoConfiguration.java | 27 +- .../conditions/GuidCreatorCondition.java | 33 +- ...eJwtProperties.java => JwtProperties.java} | 42 +- ...ot.autoconfigure.AutoConfiguration.imports | 1 - .../src/main/resources/logback.xml | 37 +- math-toolbox/README.md | 5 +- math-toolbox/build.gradle.kts | 32 +- .../com/onixbyte/math/ChainedCalcUtil.java | 34 +- .../onixbyte/math/PercentileCalculator.java | 65 +- .../onixbyte/math/model/QuartileBounds.java | 51 +- math-toolbox/src/main/resources/logback.xml | 37 +- version-catalogue/README.md | 25 +- version-catalogue/build.gradle.kts | 28 +- 73 files changed, 1521 insertions(+), 2522 deletions(-) create mode 100644 jwt-toolbox-auth0/src/main/java/com/onixbyte/jwt/auth0/Auth0TokenGenerator.java create mode 100644 jwt-toolbox-auth0/src/main/java/com/onixbyte/jwt/auth0/Auth0TokenParser.java delete mode 100644 jwt-toolbox-auth0/src/main/java/com/onixbyte/jwt/auth0/AuthzeroTokenResolver.java delete mode 100644 jwt-toolbox-auth0/src/test/java/com/onixbyte/jwt/auth0/test/TestAuthzeroTokenResolver.java create mode 100644 jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/TokenGenerator.java create mode 100644 jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/TokenParser.java delete mode 100644 jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/TokenPayload.java delete mode 100644 jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/TokenResolver.java delete mode 100644 jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/annotations/ExcludeFromPayload.java delete mode 100644 jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/annotations/TokenEnum.java delete mode 100644 jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/constants/TokenDataType.java delete mode 100644 jwt-toolbox-spring-boot-starter/src/main/java/com/onixbyte/jwt/autoconfiguration/AuthzeroTokenResolverAutoConfiguration.java rename jwt-toolbox-spring-boot-starter/src/main/java/com/onixbyte/jwt/autoconfiguration/properties/{SimpleJwtProperties.java => JwtProperties.java} (67%) diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index d13e3e2..b18c455 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -2,7 +2,10 @@ ## Our Pledge -We as members, contributors, and leaders pledge to make participation in our project a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. +We as members, contributors, and leaders pledge to make participation in our project +a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, +gender identity and expression, level of experience, nationality, personal appearance, race, +religion, or sexual identity and orientation. ## Our Standards @@ -20,26 +23,40 @@ Examples of unacceptable behaviour by participants include: - Trolling, insulting, or derogatory comments - Personal or political attacks - Public or private harassment -- Publishing others’ private information, such as a physical or electronic address, without explicit permission +- Publishing others’ private information, such as a physical or electronic address, without + explicit permission - Other conduct which could reasonably be considered inappropriate in a professional setting ## Enforcement Responsibilities -Project maintainers are responsible for clarifying the standards of acceptable behaviour and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behaviour. +Project maintainers are responsible for clarifying the standards of acceptable behaviour and are +expected to take appropriate and fair corrective action in response to any instances of +unacceptable behaviour. -Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that do not align with this Code of Conduct, and will communicate reasons for moderation decisions when appropriate. +Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, +code, wiki edits, issues, and other contributions that do not align with this Code of Conduct, and +will communicate reasons for moderation decisions when appropriate. ## Scope -This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project email address, posting via an official social media account, or acting as an appointed representative at an online or offline event. +This Code of Conduct applies both within project spaces and in public spaces when an individual is +representing the project or its community. Examples of representing a project or community include +using an official project email address, posting via an official social media account, or acting as +an appointed representative at an online or offline event. ## Enforcement -Instances of abusive, harassing, or unacceptable behaviour may be reported by contacting the project team at [your-email@example.com]. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. +Instances of abusive, harassing, or unacceptable behaviour may be reported by contacting the +project team at [opensource@onixbyte.com](mailto:opensource@onixbyte.com). All complaints will be +reviewed and investigated and will result in a response that is deemed necessary and appropriate to +the circumstances. The project team is obligated to maintain confidentiality with regard to the +reporter of an incident. -Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. +Project maintainers who do not follow or enforce the Code of Conduct in good faith may face +temporary or permanent repercussions as determined by other members of the project's leadership. ## Attribution -This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org/), version 1.4, available at https://www.contributor-covenant.org/version/1/4/ +This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org/), +version 1.4, available at https://www.contributor-covenant.org/version/1/4/ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2fd937c..c89812e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,18 +1,18 @@ -# Contributing to Java Dev Kit +# Contributing to OnixByte Toolbox -We appreciate your interest in contributing to our Java Enterprise Utility Library. Contributions are welcome in various -forms such as code, documentation, bug reports, and test cases. To ensure a smooth collaboration, please follow the -guidelines outlined below. +We appreciate your interest in contributing to our Java Enterprise Utility Library. Contributions +are welcome in various forms such as code, documentation, bug reports, and test cases. To ensure a +smooth collaboration, please follow the guidelines outlined below. ## Getting Started -The Java Dev Kit is an open-source Java library designed to ease Java enterprise application development. It is built -with Java 17, and we require contributors to use OpenJDK 17. +The OnixByte Toolbox is an open-source Java library designed to ease Java enterprise +application development. It is built with Java 17, and we require contributors to use OpenJDK 17. ## Development Setup -There is no need for manual setup beyond ensuring you have JDK 17 and a stable internet connection. Our project uses -Gradle Wrapper for building, simplifying the setup process. +There is no need for manual setup beyond ensuring you have JDK 17 and a stable internet connection. +Our project uses Gradle Wrapper for building, simplifying the setup process. ```shell ./gradlew build @@ -20,13 +20,13 @@ Gradle Wrapper for building, simplifying the setup process. ## Branching Strategy -We follow the `git-flow` branching model. Contributors should fork this repository and create their work on separate -branches prefixed with `feature/` or `hotfix/` as appropriate. +We follow the `git-flow` branching model. Contributors should fork this repository and create their +work on separate branches prefixed with `feature/` or `hotfix/` as appropriate. ## Code Style -Please adhere to the coding standards specified in our `.editorconfig` file in the root of the repository. Consistent -style helps in maintaining readability and uniformity across the codebase. +Please adhere to the coding standards specified in our `.editorconfig` file in the root of +the repository. Consistent style helps in maintaining readability and uniformity across the codebase. ## Commit Messages @@ -52,8 +52,10 @@ This format helps in auto-generating changelogs and understanding the purpose be ## Testing -We encourage using JUnit Jupiter for unit and integration tests. Pull Requests with accompanying test reports are prioritised for review and merging. +We encourage using JUnit Jupiter for unit and integration tests. Pull Requests with accompanying +test reports are prioritised for review and merging. ## License -By contributing to the Java Dev Kit, you agree that your contributions will be licensed under the Apache 2.0 license. If you do not agree to this, please refrain from contributing. \ No newline at end of file +By contributing to the Java Dev Kit, you agree that your contributions will be licensed under the +MIT license. If you do not agree to this, please refrain from contributing. diff --git a/LICENSE b/LICENSE index 5548015..8c2f4a4 100644 --- a/LICENSE +++ b/LICENSE @@ -1,202 +1,21 @@ +MIT License - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ +Copyright (c) 2024-2025 OnixByte - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: - 1. Definitions. +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright 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. \ No newline at end of file +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/build.gradle.kts b/build.gradle.kts index b76a169..533233b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,16 +1,21 @@ /* - * Copyright (C) 2024-2025 OnixByte. + * 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 + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * http://www.apache.org/licenses/LICENSE-2.0 + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - */ \ No newline at end of file + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ diff --git a/common-toolbox/build.gradle.kts b/common-toolbox/build.gradle.kts index 37b5e9d..12d83a9 100644 --- a/common-toolbox/build.gradle.kts +++ b/common-toolbox/build.gradle.kts @@ -1,19 +1,25 @@ /* - * Copyright (C) 2024-2025 OnixByte. + * 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 + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * http://www.apache.org/licenses/LICENSE-2.0 + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. * - * 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. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ + import java.net.URI plugins { @@ -82,8 +88,8 @@ publishing { } scm { - connection = "scm:git:git://github.com:OnixByte/JDevKit.git" - developerConnection = "scm:git:git://github.com:OnixByte/JDevKit.git" + connection = "scm:git:git://github.com:onixbyte/onixbyte-toolbox.git" + developerConnection = "scm:git:git://github.com:onixbyte/onixbyte-toolbox.git" url = projectGithubUrl } @@ -122,4 +128,4 @@ publishing { } } } -} \ No newline at end of file +} diff --git a/common-toolbox/src/main/java/com/onixbyte/common/util/AesUtil.java b/common-toolbox/src/main/java/com/onixbyte/common/util/AesUtil.java index 65b02a9..74da677 100644 --- a/common-toolbox/src/main/java/com/onixbyte/common/util/AesUtil.java +++ b/common-toolbox/src/main/java/com/onixbyte/common/util/AesUtil.java @@ -1,18 +1,23 @@ /* - * Copyright (C) 2024-2025 OnixByte. + * 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 + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * http://www.apache.org/licenses/LICENSE-2.0 + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. * - * 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. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ package com.onixbyte.common.util; @@ -54,12 +59,27 @@ import java.util.UUID; * System.out.println(randomSecret); // Output: A randomly generated 16-character long secret * }

* - * @author hubin@baomidou - * @version 1.1.0 - * @since 1.1.0 + * @author hubin + * @version 3.0.0 */ public final class AesUtil { + /** + * The algorithm AES. + */ + private static final String AES = "AES"; + + /** + * The algorithm AES/CBC/PKCS5Padding. + */ + private static final String AES_CBC_CIPHER = "AES/CBC/PKCS5Padding"; + + /** + * Private constructor to prevent instantiation of this utility class. + */ + private AesUtil() { + } + /** * Encrypts the specified data using the AES algorithm with the provided secret key. * @@ -125,21 +145,4 @@ public final class AesUtil { public static String generateRandomSecret() { return UUID.randomUUID().toString().replaceAll("-", "").substring(0, 16); } - - /** - * Private constructor to prevent instantiation of this utility class. - */ - private AesUtil() { - } - - /** - * The algorithm AES. - */ - private static final String AES = "AES"; - - /** - * The algorithm AES/CBC/PKCS5Padding. - */ - private static final String AES_CBC_CIPHER = "AES/CBC/PKCS5Padding"; - } diff --git a/common-toolbox/src/main/java/com/onixbyte/common/util/Base64Util.java b/common-toolbox/src/main/java/com/onixbyte/common/util/Base64Util.java index 51084d9..18214b0 100644 --- a/common-toolbox/src/main/java/com/onixbyte/common/util/Base64Util.java +++ b/common-toolbox/src/main/java/com/onixbyte/common/util/Base64Util.java @@ -1,18 +1,23 @@ /* - * Copyright (C) 2024-2025 OnixByte. + * 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 + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * http://www.apache.org/licenses/LICENSE-2.0 + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. * - * 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. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ package com.onixbyte.common.util; @@ -50,11 +55,21 @@ import java.util.Objects; * encoding and decoding. * * @author zihluwang - * @version 1.1.0 - * @since 1.0.0 + * @version 3.0.0 */ public final class Base64Util { + /** + * Private constructor to prevent instantiation of this utility class. + */ + private Base64Util() { + } + + private static Base64.Encoder encoder; + private static Base64.Decoder decoder; + private static Base64.Encoder urlEncoder; + private static Base64.Decoder urlDecoder; + /** * Ensure that there is only one Base64 Encoder. * @@ -103,12 +118,6 @@ public final class Base64Util { return urlDecoder; } - /** - * Private constructor to prevent instantiation of this utility class. - */ - private Base64Util() { - } - /** * Encodes the given string using the specified charset. * @@ -200,13 +209,4 @@ public final class Base64Util { public static String decodeUrlComponents(String value) { return decodeUrlComponents(value, StandardCharsets.UTF_8); } - - private static Base64.Encoder encoder; - - private static Base64.Decoder decoder; - - private static Base64.Encoder urlEncoder; - - private static Base64.Decoder urlDecoder; - } diff --git a/common-toolbox/src/main/java/com/onixbyte/common/util/BoolUtil.java b/common-toolbox/src/main/java/com/onixbyte/common/util/BoolUtil.java index 858b750..35600ae 100644 --- a/common-toolbox/src/main/java/com/onixbyte/common/util/BoolUtil.java +++ b/common-toolbox/src/main/java/com/onixbyte/common/util/BoolUtil.java @@ -1,18 +1,23 @@ /* - * Copyright (C) 2024-2025 OnixByte. + * 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 + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * http://www.apache.org/licenses/LICENSE-2.0 + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. * - * 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. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ package com.onixbyte.common.util; @@ -30,20 +35,23 @@ import java.util.function.BooleanSupplier; *

* *

Example usage:

- *
- * {@code
+ * 
{@code
  * boolean result1 = BoolUtil.and(true, true, false); // false
  * boolean result2 = BoolUtil.or(true, false, false); // true
  * boolean result3 = BoolUtil.not(false); // true
- * }
- * 
+ * }
* * @author zihluwang - * @version 1.6.2 - * @since 1.6.2 + * @version 3.0.0 */ public final class BoolUtil { + /** + * Private constructor to prevent instantiation of this utility class. + */ + private BoolUtil() { + } + /** * Logical and calculation. * @@ -91,10 +99,4 @@ public final class BoolUtil { .filter(Objects::nonNull) .anyMatch(BooleanSupplier::getAsBoolean); } - - /** - * Private constructor to prevent instantiation of this utility class. - */ - private BoolUtil() {} - } diff --git a/common-toolbox/src/main/java/com/onixbyte/common/util/BranchUtil.java b/common-toolbox/src/main/java/com/onixbyte/common/util/BranchUtil.java index a2c9ca8..c3e5dc1 100644 --- a/common-toolbox/src/main/java/com/onixbyte/common/util/BranchUtil.java +++ b/common-toolbox/src/main/java/com/onixbyte/common/util/BranchUtil.java @@ -1,18 +1,23 @@ /* - * Copyright (C) 2024-2025 OnixByte. + * 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 + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * http://www.apache.org/licenses/LICENSE-2.0 + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. * - * 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. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ package com.onixbyte.common.util; @@ -64,11 +69,10 @@ import java.util.function.Supplier; * expressions. * * @author zihluwang - * @version 2.1.3 + * @version 3.0.0 * @see java.util.function.Supplier * @see java.util.function.BooleanSupplier * @see java.lang.Runnable - * @since 1.0.0 */ public final class BranchUtil { @@ -167,7 +171,8 @@ public final class BranchUtil { * * @param the type of the result to be handled by the methods * @param trueSupplier the supplier to be executed if the result is {@code true} - * @return the result of the executed handler, or {@code null} if result of evaluation is {@code false} + * @return the result of the executed handler, or {@code null} if result of evaluation + * is {@code false} */ public T thenSupply(Supplier trueSupplier) { return thenSupply(trueSupplier, null); @@ -205,5 +210,4 @@ public final class BranchUtil { public void then(Runnable trueHandler) { then(trueHandler, null); } - } diff --git a/common-toolbox/src/main/java/com/onixbyte/common/util/CollectionUtil.java b/common-toolbox/src/main/java/com/onixbyte/common/util/CollectionUtil.java index 3a72dd9..9737a64 100644 --- a/common-toolbox/src/main/java/com/onixbyte/common/util/CollectionUtil.java +++ b/common-toolbox/src/main/java/com/onixbyte/common/util/CollectionUtil.java @@ -1,18 +1,23 @@ /* - * Copyright (C) 2024-2025 OnixByte. + * 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 + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * http://www.apache.org/licenses/LICENSE-2.0 + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. * - * 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. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ package com.onixbyte.common.util; @@ -27,6 +32,7 @@ import java.util.function.Supplier; * A utility class providing static methods for manipulating collections. * * @author zihluwang + * @version 3.0.0 */ public final class CollectionUtil { diff --git a/common-toolbox/src/main/java/com/onixbyte/common/util/HashUtil.java b/common-toolbox/src/main/java/com/onixbyte/common/util/HashUtil.java index 168729a..181a7f7 100644 --- a/common-toolbox/src/main/java/com/onixbyte/common/util/HashUtil.java +++ b/common-toolbox/src/main/java/com/onixbyte/common/util/HashUtil.java @@ -1,18 +1,23 @@ /* - * Copyright (C) 2024-2025 OnixByte. + * 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 + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * http://www.apache.org/licenses/LICENSE-2.0 + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. * - * 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. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ package com.onixbyte.common.util; @@ -60,12 +65,17 @@ import java.util.Optional; * encryption purposes. * * @author zihluwang - * @version 1.1.0 + * @version 3.0.0 * @see java.security.MessageDigest - * @since 1.0.0 */ public final class HashUtil { + /** + * Private constructor to prevent instantiation of this utility class. + */ + private HashUtil() { + } + /** * Calculates the MD2 hash value of the specified string using the given charset. * @@ -222,12 +232,6 @@ public final class HashUtil { return hash("SHA-512", value, StandardCharsets.UTF_8); } - /** - * Private constructor to prevent instantiation of this utility class. - */ - private HashUtil() { - } - /** * Calculates the hash value of the specified string using the specified * algorithm and charset. diff --git a/common-toolbox/src/main/java/com/onixbyte/common/util/MapUtil.java b/common-toolbox/src/main/java/com/onixbyte/common/util/MapUtil.java index 80dec76..a558cb7 100644 --- a/common-toolbox/src/main/java/com/onixbyte/common/util/MapUtil.java +++ b/common-toolbox/src/main/java/com/onixbyte/common/util/MapUtil.java @@ -1,18 +1,23 @@ /* - * Copyright (C) 2024-2025 OnixByte. + * 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 + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * http://www.apache.org/licenses/LICENSE-2.0 + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. * - * 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. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ package com.onixbyte.common.util; @@ -28,15 +33,16 @@ import java.util.Map; *

* *

Example usage:

- *
- * {@code
+ * 
{@code
+ * // User.java
  * public class User {
  *     private String name;
  *     private int age;
  *     
  *     // getters and setters
  * }
- * 
+ *
+ * // UserMapAdapter.java
  * public class UserMapAdapter implements ObjectMapAdapter {
  *     @Override
  *     public Map toMap(User user) {
@@ -73,15 +79,19 @@ import java.util.Map;
  *         System.out.println(newUser.getAge());  // Output: 30
  *     }
  * }
- * }
- * 
+ * }
* * @author zihluwang - * @version 1.7.0 - * @since 1.0.0 + * @version 3.0.0 */ public final class MapUtil { + /** + * Private constructor to prevent instantiation of this utility class. + */ + private MapUtil() { + } + /** * Converts an object to a map by mapping the field names to their corresponding values. * @@ -106,10 +116,4 @@ public final class MapUtil { public static T mapToObject(Map objectMap, ObjectMapAdapter adapter) { return adapter.toObject(objectMap); } - - /** - * Private constructor to prevent instantiation of this utility class. - */ - private MapUtil() { - } } diff --git a/common-toolbox/src/main/java/com/onixbyte/common/util/ObjectMapAdapter.java b/common-toolbox/src/main/java/com/onixbyte/common/util/ObjectMapAdapter.java index 5e7314a..aa66469 100644 --- a/common-toolbox/src/main/java/com/onixbyte/common/util/ObjectMapAdapter.java +++ b/common-toolbox/src/main/java/com/onixbyte/common/util/ObjectMapAdapter.java @@ -1,18 +1,23 @@ /* - * Copyright (C) 2024-2025 OnixByte. + * 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 + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * http://www.apache.org/licenses/LICENSE-2.0 + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. * - * 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. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ package com.onixbyte.common.util; @@ -28,8 +33,7 @@ import java.util.Map; * {@code T} to a {@link Map} and vice versa.

* *

Example usage:

- *
- * {@code
+ * 
{@code
  * public class User {
  *     private String name;
  *     private int age;
@@ -54,13 +58,11 @@ import java.util.Map;
  *         return user;
  *     }
  * }
- * }
- * 
+ * }
* * @param the type of the object to be converted * @author zihluwang - * @version 1.7.0 - * @since 1.4.2 + * @version 3.0.0 */ public interface ObjectMapAdapter { diff --git a/common-toolbox/src/main/java/com/onixbyte/common/util/RangeUtil.java b/common-toolbox/src/main/java/com/onixbyte/common/util/RangeUtil.java index d7ca49c..81aa62f 100644 --- a/common-toolbox/src/main/java/com/onixbyte/common/util/RangeUtil.java +++ b/common-toolbox/src/main/java/com/onixbyte/common/util/RangeUtil.java @@ -1,18 +1,23 @@ /* - * Copyright (C) 2024-2025 OnixByte. + * 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 + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * http://www.apache.org/licenses/LICENSE-2.0 + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. * - * 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. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ package com.onixbyte.common.util; @@ -27,6 +32,7 @@ import java.util.stream.IntStream; * leverage the {@link IntStream} to provide efficient and versatile integer sequences. * * @author zihluwang + * @version 3.0.0 * @see IntStream */ public final class RangeUtil { @@ -64,7 +70,7 @@ public final class RangeUtil { public static IntStream range(int end) { if (end <= 0) { throw new IllegalArgumentException("Parameter [end] should not be less than or equal to 0, provided: " + - end); + end); } return IntStream.range(0, end); } @@ -77,8 +83,9 @@ public final class RangeUtil { * further processing. *

* If {@code start} is less than {@code end}, an ascending range (exclusive of {@code end}) - * is generated. If {@code start} is greater than {@code end}, a descending range (exclusive of {@code end}) - * is generated. If {@code start} equals {@code end}, an empty stream is returned. + * is generated. If {@code start} is greater than {@code end}, a descending range (exclusive + * of {@code end}) is generated. If {@code start} equals {@code end}, an empty stream + * is returned. *

* Example Usage: *

{@code
@@ -103,7 +110,8 @@ public final class RangeUtil {
      *
      * @param start the starting value of the range (inclusive)
      * @param end   upper-bound of the range (exclusive)
-     * @return an {@code IntStream} of integers in ascending or descending order, exclusive of {@code end}
+     * @return an {@code IntStream} of integers in ascending or descending order, exclusive
+     * of {@code end}
      * @see IntStream
      */
     public static IntStream range(int start, int end) {
@@ -150,8 +158,8 @@ public final class RangeUtil {
     }
 
     /**
-     * Generates a stream of integers starting from the specified {@code start} value, incremented by
-     * the specified {@code step}, up to the specified {@code end} value.
+     * Generates a stream of integers starting from the specified {@code start} value, incremented
+     * by the specified {@code step}, up to the specified {@code end} value.
      * 

* It creates a sequential, ordered {@code IntStream} that can be used for iteration or * further processing. @@ -180,9 +188,10 @@ public final class RangeUtil { * @param start the starting value of the range (inclusive) * @param end upper-bound of the range (exclusive) * @param step the increment or decrement between each value (non-zero) - * @return an {@code IntStream} of integers from {@code start} to {@code end} exclusive stepping by {@code step} - * @throws IllegalArgumentException if {@code step} is zero or if {@code start} and {@code end} are inconsistent - * with the direction imposed by {@code step} + * @return an {@code IntStream} of integers from {@code start} to {@code end} exclusive stepping + * by {@code step} + * @throws IllegalArgumentException if {@code step} is zero or if {@code start} and {@code end} + * are inconsistent with the direction imposed by {@code step} * @see IntStream */ public static IntStream range(int start, int end, int step) { diff --git a/common-toolbox/src/main/resources/logback.xml b/common-toolbox/src/main/resources/logback.xml index 56cd5b7..288ac4a 100644 --- a/common-toolbox/src/main/resources/logback.xml +++ b/common-toolbox/src/main/resources/logback.xml @@ -1,19 +1,24 @@ @@ -22,7 +27,7 @@ - + ${COLOURFUL_OUTPUT} @@ -31,4 +36,4 @@ - \ No newline at end of file + diff --git a/crypto-toolbox/build.gradle.kts b/crypto-toolbox/build.gradle.kts index e980f8d..81139e1 100644 --- a/crypto-toolbox/build.gradle.kts +++ b/crypto-toolbox/build.gradle.kts @@ -1,19 +1,25 @@ /* - * Copyright (C) 2024-2025 OnixByte. + * 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 + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * http://www.apache.org/licenses/LICENSE-2.0 + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. * - * 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. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ + import java.net.URI plugins { @@ -87,8 +93,8 @@ publishing { } scm { - connection = "scm:git:git://github.com:OnixByte/JDevKit.git" - developerConnection = "scm:git:git://github.com:OnixByte/JDevKit.git" + connection = "scm:git:git://github.com:onixbyte/onixbyte-toolbox.git" + developerConnection = "scm:git:git://github.com:onixbyte/onixbyte-toolbox.git" url = projectGithubUrl } @@ -127,4 +133,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 index 228e3cd..e1b7876 100644 --- a/crypto-toolbox/src/main/java/com/onixbyte/crypto/PrivateKeyLoader.java +++ b/crypto-toolbox/src/main/java/com/onixbyte/crypto/PrivateKeyLoader.java @@ -1,18 +1,23 @@ /* - * Copyright (C) 2024-2025 OnixByte. + * 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 + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * http://www.apache.org/licenses/LICENSE-2.0 + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. * - * 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. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ package com.onixbyte.crypto; @@ -25,8 +30,7 @@ import java.security.PrivateKey; * * @author zihluwang * @author siujamo - * @version 2.0.0 - * @since 1.6.0 + * @version 3.0.0 */ public interface PrivateKeyLoader { diff --git a/crypto-toolbox/src/main/java/com/onixbyte/crypto/PublicKeyLoader.java b/crypto-toolbox/src/main/java/com/onixbyte/crypto/PublicKeyLoader.java index ecfb3e3..e4dff60 100644 --- a/crypto-toolbox/src/main/java/com/onixbyte/crypto/PublicKeyLoader.java +++ b/crypto-toolbox/src/main/java/com/onixbyte/crypto/PublicKeyLoader.java @@ -1,18 +1,23 @@ /* - * Copyright (C) 2024-2025 OnixByte. + * 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 + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * http://www.apache.org/licenses/LICENSE-2.0 + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. * - * 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. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ package com.onixbyte.crypto; 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 index 672c65f..fa527ec 100644 --- 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 @@ -1,18 +1,23 @@ /* - * Copyright (C) 2024-2025 OnixByte. + * 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 + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * http://www.apache.org/licenses/LICENSE-2.0 + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. * - * 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. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ package com.onixbyte.crypto.algorithm.ecdsa; @@ -35,26 +40,18 @@ import java.util.Set; /** * Key pair loader for loading key pairs for ECDSA-based algorithms. *

- * - * Example usage for ECDSA: + * Example usage: *

{@code
- * PrivateKeyLoader keyLoader = new EcKeyLoader();
+ * PrivateKeyLoader keyLoader = new ECPrivateKeyLoader();
  * 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 + * @version 3.0.0 */ public class ECPrivateKeyLoader implements PrivateKeyLoader { diff --git a/crypto-toolbox/src/main/java/com/onixbyte/crypto/algorithm/ecdsa/ECPublicKeyLoader.java b/crypto-toolbox/src/main/java/com/onixbyte/crypto/algorithm/ecdsa/ECPublicKeyLoader.java index a31f98a..de14870 100644 --- a/crypto-toolbox/src/main/java/com/onixbyte/crypto/algorithm/ecdsa/ECPublicKeyLoader.java +++ b/crypto-toolbox/src/main/java/com/onixbyte/crypto/algorithm/ecdsa/ECPublicKeyLoader.java @@ -1,18 +1,23 @@ /* - * Copyright (C) 2024-2025 OnixByte. + * 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 + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * http://www.apache.org/licenses/LICENSE-2.0 + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. * - * 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. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ package com.onixbyte.crypto.algorithm.ecdsa; @@ -32,6 +37,9 @@ import java.util.Base64; import java.util.HashSet; import java.util.Set; +/** + * + */ public class ECPublicKeyLoader implements PublicKeyLoader { /** 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 index 1f8c357..8cd6eb9 100644 --- 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 @@ -1,18 +1,23 @@ /* - * Copyright (C) 2024-2025 OnixByte. + * 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 + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * http://www.apache.org/licenses/LICENSE-2.0 + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. * - * 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. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ package com.onixbyte.crypto.algorithm.rsa; @@ -32,14 +37,15 @@ 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. + * 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 zihluwang * @author siujamo * @see PrivateKeyLoader * @see KeyLoadingException diff --git a/crypto-toolbox/src/main/java/com/onixbyte/crypto/algorithm/rsa/RSAPublicKeyLoader.java b/crypto-toolbox/src/main/java/com/onixbyte/crypto/algorithm/rsa/RSAPublicKeyLoader.java index 2e14518..f1a5c7b 100644 --- a/crypto-toolbox/src/main/java/com/onixbyte/crypto/algorithm/rsa/RSAPublicKeyLoader.java +++ b/crypto-toolbox/src/main/java/com/onixbyte/crypto/algorithm/rsa/RSAPublicKeyLoader.java @@ -1,18 +1,23 @@ /* - * Copyright (C) 2024-2025 OnixByte. + * 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 + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * http://www.apache.org/licenses/LICENSE-2.0 + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. * - * 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. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ package com.onixbyte.crypto.algorithm.rsa; @@ -31,6 +36,9 @@ import java.security.spec.RSAPublicKeySpec; import java.security.spec.X509EncodedKeySpec; import java.util.Base64; +/** + * + */ public class RSAPublicKeyLoader implements PublicKeyLoader { private final Base64.Decoder decoder; diff --git a/crypto-toolbox/src/main/java/com/onixbyte/crypto/exception/KeyLoadingException.java b/crypto-toolbox/src/main/java/com/onixbyte/crypto/exception/KeyLoadingException.java index 9ae5b7f..648182c 100644 --- a/crypto-toolbox/src/main/java/com/onixbyte/crypto/exception/KeyLoadingException.java +++ b/crypto-toolbox/src/main/java/com/onixbyte/crypto/exception/KeyLoadingException.java @@ -1,18 +1,23 @@ /* - * Copyright (C) 2024-2025 OnixByte. + * 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 + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * http://www.apache.org/licenses/LICENSE-2.0 + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. * - * 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. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ package com.onixbyte.crypto.exception; @@ -39,7 +44,6 @@ package com.onixbyte.crypto.exception; * * @author zihluwang * @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 index 3cb66d0..9432a27 100644 --- a/crypto-toolbox/src/main/java/com/onixbyte/crypto/util/CryptoUtil.java +++ b/crypto-toolbox/src/main/java/com/onixbyte/crypto/util/CryptoUtil.java @@ -1,24 +1,35 @@ /* - * Copyright (C) 2024-2025 OnixByte. + * 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 + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * http://www.apache.org/licenses/LICENSE-2.0 + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. * - * 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. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ package com.onixbyte.crypto.util; +/** + * + */ public final class CryptoUtil { + /** + * Private constructor to prevent instantiation of this utility class. + */ private CryptoUtil() { } diff --git a/crypto-toolbox/src/main/resources/logback.xml b/crypto-toolbox/src/main/resources/logback.xml index 1cf5a50..288ac4a 100644 --- a/crypto-toolbox/src/main/resources/logback.xml +++ b/crypto-toolbox/src/main/resources/logback.xml @@ -1,26 +1,33 @@ - - + + - + ${COLOURFUL_OUTPUT} @@ -29,4 +36,4 @@ - \ No newline at end of file + diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index d64cd4917707c1f8861d8cb53dd15194d4248596..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 GIT binary patch literal 0 HcmV?d00001 literal 43462 zcma&NWl&^owk(X(xVyW%ySuwf;qI=D6|RlDJ2cR^yEKh!@I- zp9QeisK*rlxC>+~7Dk4IxIRsKBHqdR9b3+fyL=ynHmIDe&|>O*VlvO+%z5;9Z$|DJ zb4dO}-R=MKr^6EKJiOrJdLnCJn>np?~vU-1sSFgPu;pthGwf}bG z(1db%xwr#x)r+`4AGu$j7~u2MpVs3VpLp|mx&;>`0p0vH6kF+D2CY0fVdQOZ@h;A` z{infNyvmFUiu*XG}RNMNwXrbec_*a3N=2zJ|Wh5z* z5rAX$JJR{#zP>KY**>xHTuw?|-Rg|o24V)74HcfVT;WtQHXlE+_4iPE8QE#DUm%x0 zEKr75ur~W%w#-My3Tj`hH6EuEW+8K-^5P62$7Sc5OK+22qj&Pd1;)1#4tKihi=~8C zHiQSst0cpri6%OeaR`PY>HH_;CPaRNty%WTm4{wDK8V6gCZlG@U3$~JQZ;HPvDJcT1V{ z?>H@13MJcCNe#5z+MecYNi@VT5|&UiN1D4ATT+%M+h4c$t;C#UAs3O_q=GxK0}8%8 z8J(_M9bayxN}69ex4dzM_P3oh@ZGREjVvn%%r7=xjkqxJP4kj}5tlf;QosR=%4L5y zWhgejO=vao5oX%mOHbhJ8V+SG&K5dABn6!WiKl{|oPkq(9z8l&Mm%(=qGcFzI=eLu zWc_oCLyf;hVlB@dnwY98?75B20=n$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H9|F%I`Pb!>KAS3jQWKfGivTVkMJLO-HUGM_a4UQ_%RgL6WZvrW+Z4ujZn;y@ zz9$=oO!7qVTaQAA^BhX&ZxS*|5dj803M=k&2%QrXda`-Q#IoZL6E(g+tN!6CA!CP* zCpWtCujIea)ENl0liwVfj)Nc<9mV%+e@=d`haoZ*`B7+PNjEbXBkv=B+Pi^~L#EO$D$ZqTiD8f<5$eyb54-(=3 zh)6i8i|jp(@OnRrY5B8t|LFXFQVQ895n*P16cEKTrT*~yLH6Z4e*bZ5otpRDri&+A zfNbK1D5@O=sm`fN=WzWyse!za5n%^+6dHPGX#8DyIK>?9qyX}2XvBWVqbP%%D)7$= z=#$WulZlZR<{m#gU7lwqK4WS1Ne$#_P{b17qe$~UOXCl>5b|6WVh;5vVnR<%d+Lnp z$uEmML38}U4vaW8>shm6CzB(Wei3s#NAWE3)a2)z@i{4jTn;;aQS)O@l{rUM`J@K& l00vQ5JBs~;vo!vr%%-k{2_Fq1Mn4QF81S)AQ99zk{{c4yR+0b! diff --git a/gradlew b/gradlew index 1aa94a4..447618b 100755 --- a/gradlew +++ b/gradlew @@ -1,19 +1,25 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# 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 +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: # -# https://www.apache.org/licenses/LICENSE-2.0 +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. # -# 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. +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. # ############################################################################## diff --git a/identity-generator/build.gradle.kts b/identity-generator/build.gradle.kts index 8821412..d3c7471 100644 --- a/identity-generator/build.gradle.kts +++ b/identity-generator/build.gradle.kts @@ -1,19 +1,25 @@ /* - * Copyright (C) 2024-2025 OnixByte. + * 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 + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * http://www.apache.org/licenses/LICENSE-2.0 + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. * - * 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. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ + import java.net.URI plugins { diff --git a/identity-generator/src/main/java/com/onixbyte/identitygenerator/IdentityGenerator.java b/identity-generator/src/main/java/com/onixbyte/identitygenerator/IdentityGenerator.java index 823d85b..2232c43 100644 --- a/identity-generator/src/main/java/com/onixbyte/identitygenerator/IdentityGenerator.java +++ b/identity-generator/src/main/java/com/onixbyte/identitygenerator/IdentityGenerator.java @@ -1,25 +1,30 @@ /* - * Copyright (C) 2024-2025 OnixByte. + * 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 + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * http://www.apache.org/licenses/LICENSE-2.0 + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. * - * 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. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ package com.onixbyte.identitygenerator; /** - * The {@code IdentityGenerator} is a generic interface for generating globally unique identifiers (GUIDs) - * of a specific type. + * 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. *

@@ -45,9 +50,8 @@ package com.onixbyte.identitygenerator; * }
* * @param this represents the type of the Global Unique Identifier - * @author Zihlu Wang - * @version 1.1.0 - * @since 1.0.0 + * @author zihluwang + * @version 3.0.0 */ public interface IdentityGenerator { diff --git a/identity-generator/src/main/java/com/onixbyte/identitygenerator/exceptions/TimingException.java b/identity-generator/src/main/java/com/onixbyte/identitygenerator/exceptions/TimingException.java index 9eeeea2..4746a04 100644 --- a/identity-generator/src/main/java/com/onixbyte/identitygenerator/exceptions/TimingException.java +++ b/identity-generator/src/main/java/com/onixbyte/identitygenerator/exceptions/TimingException.java @@ -1,18 +1,23 @@ /* - * Copyright (C) 2024-2025 OnixByte. + * 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 + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * http://www.apache.org/licenses/LICENSE-2.0 + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. * - * 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. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ package com.onixbyte.identitygenerator.exceptions; @@ -25,8 +30,8 @@ package com.onixbyte.identitygenerator.exceptions; * provides a description of the exception, while the cause represents the underlying cause of the * exception and provides additional information about the error. * - * @author Zihlu Wang - * @since 1.0.0 + * @author zihluwang + * @since 3.0.0 */ public class TimingException extends RuntimeException { diff --git a/identity-generator/src/main/java/com/onixbyte/identitygenerator/impl/SequentialUuidGenerator.java b/identity-generator/src/main/java/com/onixbyte/identitygenerator/impl/SequentialUuidGenerator.java index d6a3e3c..48efd8f 100644 --- a/identity-generator/src/main/java/com/onixbyte/identitygenerator/impl/SequentialUuidGenerator.java +++ b/identity-generator/src/main/java/com/onixbyte/identitygenerator/impl/SequentialUuidGenerator.java @@ -1,18 +1,23 @@ /* - * Copyright (C) 2024-2025 OnixByte. + * 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 + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * http://www.apache.org/licenses/LICENSE-2.0 + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. * - * 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. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ package com.onixbyte.identitygenerator.impl; @@ -24,15 +29,20 @@ import java.security.SecureRandom; import java.util.UUID; /** - * 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. + * 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 - * component of the UUID. The first 6 bytes of the UUID encode the current timestamp in milliseconds, ensuring that - * generated UUIDs are roughly ordered by creation time. + * This implementation utilises a cryptographically strong {@link SecureRandom} instance to produce + * the random component of the UUID. The first 6 bytes of the UUID encode the current timestamp in + * milliseconds, ensuring that generated UUIDs are roughly ordered by creation time. *

- * The generated UUID adheres strictly to the layout and variant bits of UUID version 7 as defined in the specification. - *

+ * The generated UUID adheres strictly to the layout and variant bits of UUID version 7 as defined + * in the specification. + * + * @author zihluwang + * @author siujamo + * @version 3.0.0 */ public class SequentialUuidGenerator implements IdentityGenerator { diff --git a/identity-generator/src/main/java/com/onixbyte/identitygenerator/impl/SnowflakeIdentityGenerator.java b/identity-generator/src/main/java/com/onixbyte/identitygenerator/impl/SnowflakeIdentityGenerator.java index 9d57099..f3def6d 100644 --- a/identity-generator/src/main/java/com/onixbyte/identitygenerator/impl/SnowflakeIdentityGenerator.java +++ b/identity-generator/src/main/java/com/onixbyte/identitygenerator/impl/SnowflakeIdentityGenerator.java @@ -1,18 +1,23 @@ /* - * Copyright (C) 2024-2025 OnixByte. + * 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 + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * http://www.apache.org/licenses/LICENSE-2.0 + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. * - * 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. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ package com.onixbyte.identitygenerator.impl; @@ -35,129 +40,17 @@ import java.time.ZoneId; *
  • 12 bits for sequence number (per millisecond)
  • * *

    - * 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 - * repeated timestamps. + * 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 repeated timestamps. * - * @author Zihlu Wang - * @version 1.1.0 - * @since 1.0.0 + * @author zihluwang + * @version 3.0.0 */ public final class SnowflakeIdentityGenerator implements IdentityGenerator { - /** - * Constructs a SnowflakeGuidGenerator with the default start epoch and custom worker ID, data - * centre ID. - * - * @param dataCentreId the data centre ID (between 0 and 31) - * @param workerId the worker ID (between 0 and 31) - */ - public SnowflakeIdentityGenerator(long dataCentreId, long workerId) { - this(dataCentreId, workerId, DEFAULT_CUSTOM_EPOCH); - } - - /** - * Constructs a SnowflakeGuidGenerator with a custom epoch, worker ID, and data centre ID. - * - * @param dataCentreId the data centre ID (between 0 and 31) - * @param workerId the worker ID (between 0 and 31) - * @param startEpoch the custom epoch timestamp (in milliseconds) to start generating IDs from - * @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 SnowflakeIdentityGenerator(long dataCentreId, long workerId, long startEpoch) { - if (startEpoch > currentTimestamp()) { - throw new IllegalArgumentException("Start Epoch can not be greater than current timestamp!"); - } - - var maxWorkerId = ~(-1L << workerIdBits); - if (workerId > maxWorkerId || workerId < 0) { - throw new IllegalArgumentException(String.format("Worker Id can't be greater than %d or less than 0", - maxWorkerId)); - } - - var maxDataCentreId = ~(-1L << dataCentreIdBits); - if (dataCentreId > maxDataCentreId || dataCentreId < 0) { - throw new IllegalArgumentException(String.format("Data Centre Id can't be greater than %d or less than 0", - maxDataCentreId)); - } - - this.startEpoch = startEpoch; - this.workerId = workerId; - this.dataCentreId = dataCentreId; - } - - /** - * Generates the next unique ID. - * - * @return the generated unique ID - * @throws TimingException if the system clock moves backwards, indicating an invalid sequence - * of timestamps. - */ - @Override - public synchronized Long nextId() { - var timestamp = currentTimestamp(); - - // if the current time is less than the timestamp of the last ID generation, it means that - // the system clock has been set back and an exception should be thrown - if (timestamp < lastTimestamp) { - throw new TimingException("Clock moved backwards. Refusing to generate id for %d milliseconds" - .formatted(lastTimestamp - timestamp)); - } - - // if generated at the same time, perform intra-millisecond sequences - long sequenceBits = 12L; - if (lastTimestamp == timestamp) { - long sequenceMask = ~(-1L << sequenceBits); - sequence = (sequence + 1) & sequenceMask; - // sequence overflow in milliseconds - if (sequence == 0) { - // block to the next millisecond, get a new timestamp - timestamp = awaitToNextMillis(lastTimestamp); - } - } - // timestamp change, sequence reset in milliseconds - else { - sequence = 0L; - } - - // timestamp of last ID generation - lastTimestamp = timestamp; - - // shifted and put together by or operations to form a 64-bit ID - var timestampLeftShift = sequenceBits + workerIdBits + dataCentreIdBits; - var dataCentreIdShift = sequenceBits + workerIdBits; - return ((timestamp - startEpoch) << timestampLeftShift) - | (dataCentreId << dataCentreIdShift) - | (workerId << sequenceBits) - | sequence; - } - - /** - * Blocks until the next millisecond to obtain a new timestamp. - * - * @param lastTimestamp the timestamp when the last ID was generated - * @return the current timestamp - */ - private long awaitToNextMillis(long lastTimestamp) { - var timestamp = currentTimestamp(); - while (timestamp <= lastTimestamp) { - timestamp = currentTimestamp(); - } - return timestamp; - } - - /** - * Returns the current timestamp in milliseconds. - * - * @return the current timestamp - */ - private long currentTimestamp() { - return LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(); - } - /** * Default custom epoch. * @@ -200,5 +93,116 @@ public final class SnowflakeIdentityGenerator implements IdentityGenerator */ private long lastTimestamp = -1L; + /** + * Constructs a SnowflakeGuidGenerator with the default start epoch and custom worker ID, data + * centre ID. + * + * @param dataCentreId the data centre ID (between 0 and 31) + * @param workerId the worker ID (between 0 and 31) + */ + public SnowflakeIdentityGenerator(long dataCentreId, long workerId) { + this(dataCentreId, workerId, DEFAULT_CUSTOM_EPOCH); + } + + /** + * Constructs a SnowflakeGuidGenerator with a custom epoch, worker ID, and data centre ID. + * + * @param dataCentreId the data centre ID (between 0 and 31) + * @param workerId the worker ID (between 0 and 31) + * @param startEpoch the custom epoch timestamp (in milliseconds) to start generating IDs from + * @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 SnowflakeIdentityGenerator(long dataCentreId, long workerId, long startEpoch) { + if (startEpoch > currentTimestamp()) { + throw new IllegalArgumentException("Start Epoch can not be greater than current timestamp!"); + } + + var maxWorkerId = ~(-1L << workerIdBits); + if (workerId > maxWorkerId || workerId < 0) { + throw new IllegalArgumentException(String.format("Worker Id can't be greater than %d or less than 0", + maxWorkerId)); + } + + var maxDataCentreId = ~(-1L << dataCentreIdBits); + if (dataCentreId > maxDataCentreId || dataCentreId < 0) { + throw new IllegalArgumentException(String.format("Data Centre Id can't be greater than %d or less than 0", + maxDataCentreId)); + } + + this.startEpoch = startEpoch; + this.workerId = workerId; + this.dataCentreId = dataCentreId; + } + + /** + * Generates the next unique ID. + * + * @return the generated unique ID + * @throws TimingException if the system clock moves backwards, indicating an invalid sequence + * of timestamps. + */ + @Override + public synchronized Long nextId() { + var timestamp = currentTimestamp(); + + // if the current time is less than the timestamp of the last ID generation, it means that + // the system clock has been set back and an exception should be thrown + if (timestamp < lastTimestamp) { + throw new TimingException("Clock moved backwards. Refusing to generate id for %d milliseconds" + .formatted(lastTimestamp - timestamp)); + } + + // if generated at the same time, perform intra-millisecond sequences + long sequenceBits = 12L; + if (lastTimestamp == timestamp) { + long sequenceMask = ~(-1L << sequenceBits); + sequence = (sequence + 1) & sequenceMask; + // sequence overflow in milliseconds + if (sequence == 0) { + // block to the next millisecond, get a new timestamp + timestamp = awaitToNextMillis(lastTimestamp); + } + } + // timestamp change, sequence reset in milliseconds + else { + sequence = 0L; + } + + // timestamp of last ID generation + lastTimestamp = timestamp; + + // shifted and put together by or operations to form a 64-bit ID + var timestampLeftShift = sequenceBits + workerIdBits + dataCentreIdBits; + var dataCentreIdShift = sequenceBits + workerIdBits; + return ((timestamp - startEpoch) << timestampLeftShift) + | (dataCentreId << dataCentreIdShift) + | (workerId << sequenceBits) + | sequence; + } + + /** + * Blocks until the next millisecond to obtain a new timestamp. + * + * @param lastTimestamp the timestamp when the last ID was generated + * @return the current timestamp + */ + private long awaitToNextMillis(long lastTimestamp) { + var timestamp = currentTimestamp(); + while (timestamp <= lastTimestamp) { + timestamp = currentTimestamp(); + } + return timestamp; + } + + /** + * Returns the current timestamp in milliseconds. + * + * @return the current timestamp + */ + private long currentTimestamp() { + return LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(); + } + } diff --git a/identity-generator/src/main/resources/logback.xml b/identity-generator/src/main/resources/logback.xml index 7beaa9d..288ac4a 100644 --- a/identity-generator/src/main/resources/logback.xml +++ b/identity-generator/src/main/resources/logback.xml @@ -1,25 +1,33 @@ - - - - + + + + + ${COLOURFUL_OUTPUT} @@ -28,4 +36,4 @@ - \ No newline at end of file + diff --git a/jwt-toolbox-auth0/README.md b/jwt-toolbox-auth0/README.md index ee055b3..d3fca65 100644 --- a/jwt-toolbox-auth0/README.md +++ b/jwt-toolbox-auth0/README.md @@ -1,59 +1,56 @@ -# Module `simple-jwt-authzero` +# JWT Toolbox :: Auth0 ## Introduction -The `simple-jwt-authzero` module is an implementation of module `simple-jwt-facade` which uses the third-party library `com.auth0:java-jwt`. By using this module can help you use JWT to help you in your application. - -## Prerequisites - -This whole `JDevKit` is developed by **JDK 17**, which means you have to use JDK 17 for better experience. - -## Installation - -> This module has already imported `simple-jwt-facade`, there is no need to import it again. +**JWT Toolbox :: Auth0** module is an implementation of module JWT Toolbox, which uses third-party +library `com.auth0:java-jwt`. By using this module can help you use JWT to help you in +your application. ### If you are using `Maven` -It is quite simple to install this module by `Maven`. The only thing you need to do is find your `pom.xml` file in the project, then find the `` node in the `` node, and add the following codes to `` node: +It is quite simple to install this module by `Maven`. The only thing you need to do is find your +`pom.xml` file in the project, then find the `` node in the `` node, and add +the following codes to `` node: ```xml + - cn.org.codecrafters - simple-jwt-authzero - ${simple-jwt-authzero.version} + com.onixbyte + jwt-toolbox-auth0 + ${jwt-toolbox-auth0.version} ``` -And run `mvn dependency:get` in your project root folder(i.e., if your `pom.xml` is located at `/path/to/your/project/pom.xml`, then your current work folder should be `/path/to/your/project`), then `Maven` will automatically download the `jar` archive from `Maven Central Repository`. This could be **MUCH EASIER** if you are using IDE(i.e., IntelliJ IDEA), the only thing you need to do is click the refresh button of `Maven`. +And run `mvn dependency:get` in your project root folder(i.e., if your `pom.xml` is located at +`/path/to/your/project/pom.xml`, then your current work folder should be `/path/to/your/project`), +then `Maven` will automatically download the `jar` archive from `Maven Central Repository`. +This could be **MUCH EASIER** if you are using IDE(i.e., IntelliJ IDEA), the only thing you need to +do is click the refresh button of `Maven`. -If you are restricted using the Internet, and have to make `Maven` offline, you could follow the following steps. +If you are restricted using the Internet, and have to make `Maven` offline, you could follow the +following steps. -1. Download the `jar` file from any place you can get and transfer the `jar` files to your work computer. -2. Move the `jar` files to your local `Maven` Repository as the path of `/path/to/maven_local_repo/cn/org/codecrafters/simple-jwt-facade/`. +1. Download the `jar` file from any place you can get and transfer the `jar` files to your + work computer. +2. Move the `jar` files to your local `Maven` Repository as the path of + `/path/to/maven_local_repo/com/onixbyte/jwt-toolbox-auth0/`. ### If you are using `Gradle` Add this module to your project with `Gradle` is much easier than doing so with `Maven`. -Find `build.gradle` in the needed project, and add the following code to the `dependencies` closure in the build script: +Find `build.gradle` in the needed project, and add the following code to the `dependencies` closure +in the build script: ```groovy -implementation 'cn.org.codecrafters:simple-jwt-authzero:${simple-jwt-authzero.version}' +implementation 'com.onixbyte:jwt-toolbox-auth0:${jwt-toolbox-auth0.version}' ``` -### If you are not using `Maven` or `Gradle` - -1. Download the `jar` file from the Internet. -2. Create a folder in your project and name it as a name you like(i.e., for me, I prefer `vendor`). -3. Put the `jar` file to the folder you just created in Step 2. -4. Add this folder to your project `classpath`. - -## 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.jwt.auth0.AuthzeroTokenResolver` and other operations to JWT could follow our instruction in [`simple-jwt-facade`](../simple-jwt-facade/README.md). - ## Contact -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 have any suggestions, ideas, don't hesitate contacting us via +[GitHub Issues](https://github.com/onixbyte/onixbyte-toolbox/issues/new). -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). +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/onixbyte/onixbyte-toolbox/compare). diff --git a/jwt-toolbox-auth0/build.gradle.kts b/jwt-toolbox-auth0/build.gradle.kts index 91c2151..110eeb9 100644 --- a/jwt-toolbox-auth0/build.gradle.kts +++ b/jwt-toolbox-auth0/build.gradle.kts @@ -1,18 +1,23 @@ /* - * Copyright (C) 2024-2025 OnixByte. + * 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 + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * http://www.apache.org/licenses/LICENSE-2.0 + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. * - * 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. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ import java.net.URI @@ -90,8 +95,8 @@ publishing { } scm { - connection = "scm:git:git://github.com:OnixByte/JDevKit.git" - developerConnection = "scm:git:git://github.com:OnixByte/JDevKit.git" + connection = "scm:git:git://github.com:onixbyte/onixbyte-toolbox.git" + developerConnection = "scm:git:git://github.com:onixbyte/onixbyte-toolbox.git" url = projectGithubUrl } diff --git a/jwt-toolbox-auth0/src/main/java/com/onixbyte/jwt/auth0/Auth0TokenGenerator.java b/jwt-toolbox-auth0/src/main/java/com/onixbyte/jwt/auth0/Auth0TokenGenerator.java new file mode 100644 index 0000000..e5c82eb --- /dev/null +++ b/jwt-toolbox-auth0/src/main/java/com/onixbyte/jwt/auth0/Auth0TokenGenerator.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024-2025 OnixByte + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.onixbyte.jwt.auth0; + +import com.onixbyte.jwt.TokenGenerator; + +public class Auth0TokenGenerator implements TokenGenerator { +} diff --git a/jwt-toolbox-auth0/src/main/java/com/onixbyte/jwt/auth0/Auth0TokenParser.java b/jwt-toolbox-auth0/src/main/java/com/onixbyte/jwt/auth0/Auth0TokenParser.java new file mode 100644 index 0000000..7e30b50 --- /dev/null +++ b/jwt-toolbox-auth0/src/main/java/com/onixbyte/jwt/auth0/Auth0TokenParser.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024-2025 OnixByte + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.onixbyte.jwt.auth0; + +import com.onixbyte.identitygenerator.IdentityGenerator; +import com.auth0.jwt.JWTCreator; +import com.auth0.jwt.algorithms.Algorithm; +import com.auth0.jwt.interfaces.JWTVerifier; +import com.onixbyte.jwt.TokenParser; + +/** + * + * + * @author zihluwang + * @version 3.0.0 + * @see IdentityGenerator + * @see Algorithm + * @see JWTVerifier + * @see JWTCreator + * @see JWTCreator.Builder + * @since 1.0.0 + */ +public class Auth0TokenParser implements TokenParser { + + +} diff --git a/jwt-toolbox-auth0/src/main/java/com/onixbyte/jwt/auth0/AuthzeroTokenResolver.java b/jwt-toolbox-auth0/src/main/java/com/onixbyte/jwt/auth0/AuthzeroTokenResolver.java deleted file mode 100644 index b6e6206..0000000 --- a/jwt-toolbox-auth0/src/main/java/com/onixbyte/jwt/auth0/AuthzeroTokenResolver.java +++ /dev/null @@ -1,658 +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.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; -import com.auth0.jwt.interfaces.DecodedJWT; -import com.auth0.jwt.interfaces.JWTVerifier; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.ObjectNode; -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; - -import java.lang.reflect.InvocationTargetException; -import java.security.interfaces.ECPrivateKey; -import java.security.interfaces.ECPublicKey; -import java.time.Duration; -import java.time.LocalDateTime; -import java.time.ZoneId; -import java.util.*; -import java.util.function.BiFunction; -import java.util.function.Function; - -/** - * The {@code AuthzeroTokenResolver} class is an implementation of the {@link TokenResolver} - * interface. It uses the {@code com.auth0:java-jwt} library to handle JSON Web Token (JWT) - * resolution. This resolver provides functionality to create, extract, verify, and renew JWT - * tokens using various algorithms and custom payload data. - *

    - * Usage: - * To use the {@code AuthzeroTokenResolver}, first, create an instance of this class: - *

    {@code
    - * TokenResolver tokenResolver =
    - *     new AuthzeroTokenResolver(TokenAlgorithm.HS256,
    - *                               "Token Subject",
    - *                               "Token Issuer",
    - *                               "Token Secret");
    - * }
    - *

    - * Then, you can utilize the various methods provided by this resolver to handle JWT tokens: - *

    {@code
    - * // Creating a new JWT token
    - * String token =
    - *     tokenResolver.createToken(Duration.ofHours(1),
    - *                               "your_subject",
    - *                               "your_audience",
    - *                               customPayloads);
    - *
    - * // Extracting payload data from a JWT token
    - * DecodedJWT decodedJWT = tokenResolver.resolve(token);
    - * T payloadData = decodedJWT.extract(token, T.class);
    - *
    - * // Renewing an existing JWT token
    - * String renewedToken =
    - *     tokenResolver.renew(token, Duration.ofMinutes(30), customPayloads);
    - * }
    - *

    - * Note: - * It is essential to configure the appropriate algorithms, secret, and issuer according to your - * specific use case when using this resolver. Additionally, ensure that the - * {@code com.auth0:java-jwt} library is correctly configured in your project's dependencies. - * - * @author Zihlu Wang - * @version 1.1.1 - * @see IdentityGenerator - * @see Algorithm - * @see JWTVerifier - * @see JWTCreator - * @see JWTCreator.Builder - * @since 1.0.0 - */ -public class AuthzeroTokenResolver implements TokenResolver { - - private final static Logger log = LoggerFactory.getLogger(AuthzeroTokenResolver.class); - - /** - * Create a builder of {@link AuthzeroTokenResolver}. - * - * @return a builder instance - */ - public static Builder builder() { - return new Builder(); - } - - /** - * Builder for {@link AuthzeroTokenResolver} - */ - public static class Builder { - - /** - * IdentityGenerator used for generating unique identifiers for "jti" claim in JWT tokens. - */ - private IdentityGenerator jtiCreator; - - /** - * The algorithm used for signing and verifying JWT tokens. - */ - private Algorithm algorithm; - - /** - * The issuer claim value to be included in JWT tokens. - */ - private String issuer; - - /** - * Jackson JSON handler. - */ - private ObjectMapper objectMapper; - - /** - * The secret to sign a JWT with HMAC based algorithm. - */ - private String secret; - - /** - * The private key to sign a JWT with ECDSA based algorithm. - */ - private ECPrivateKey privateKey; - - /** - * The public key to read a JWT with ECDSA based algorithm. - */ - private ECPublicKey publicKey; - - /** - * Private constructor to prevent instantiation of this utility class. - */ - private Builder() { - } - - /** - * Set the secret to sign a JWT. - * - * @param secret the secret - * @return the builder instance - */ - public Builder secret(String secret) { - this.secret = secret; - return this; - } - - /** - * Set the key pair to sign a JWT. - * - * @param publicKey the pem formatted public key text - * @param privateKey the pem formatted private key text - * @return the builder instance - */ - public Builder keyPair(String publicKey, String privateKey) { - var keyLoader = new ECPrivateKeyLoader(); - // this.publicKey = keyLoader.loadPublicKey(publicKey); - this.privateKey = keyLoader.loadPrivateKey(privateKey); - return this; - } - - /** - * Set the algorithm to sign a JWT. - *

    - * A secret required by HMAC-based algorithms, or key pair required by ECDSA-based - * algorithms need to be set before initialise an algorithm. - * - * @param algorithm an {@link TokenAlgorithm} value - * @return the builder instance - */ - public Builder algorithm(TokenAlgorithm algorithm) { - // check the secret or key pair before algorithm initialised - if (HMAC_ALGORITHMS.containsKey(algorithm)) { - if (Objects.isNull(secret) || secret.isBlank()) { - throw new IllegalSecretException(""" - Please specify a secret before define an algorithm."""); - } - } else if (ECDSA_ALGORITHMS.containsKey(algorithm)) { - if (Objects.isNull(publicKey) || Objects.isNull(privateKey)) { - throw new IllegalKeyPairException(""" - Please specify a ECDSA key pair before define an algorithm."""); - } - } - - // initialise algorithm - this.algorithm = switch (algorithm) { - case HS256, HS384, HS512 -> HMAC_ALGORITHMS.get(algorithm).apply(secret); - case ES256, ES384, ES512 -> ECDSA_ALGORITHMS.get(algorithm) - .apply(publicKey, privateKey); - default -> throw new UnsupportedAlgorithmException(""" - This algorithm is not supported yet."""); - }; - return this; - } - - /** - * Set the object mapper. - * - * @param objectMapper an object mapper - * @return the builder instance - */ - public Builder objectMapper(ObjectMapper objectMapper) { - this.objectMapper = objectMapper; - return this; - } - - /** - * Set the creator of JWT id. - * - * @param jtiCreator a creator to create JWT id - * @return the builder instance - */ - public Builder jtiCreator(IdentityGenerator jtiCreator) { - this.jtiCreator = jtiCreator; - return this; - } - - /** - * Set the issuer of created JWT. - * - * @param issuer the person or organisation issued this JWT - * @return the builder instance - */ - public Builder issuer(String issuer) { - this.issuer = issuer; - return this; - } - - /** - * Create an {@link AuthzeroTokenResolver} instance - * - * @return created instance - */ - public AuthzeroTokenResolver build() { - return new AuthzeroTokenResolver(jtiCreator, algorithm, issuer, objectMapper); - } - } - - /** - * Creates a new token with the specified expiration duration, subject, and - * audience. - * - * @param expireAfter the duration after which the token will expire - * @param subject the subject of the token - * @param audience the audience for which the token is intended - * @return the generated token as a {@code String} - */ - @Override - public String createToken(Duration expireAfter, String audience, String subject) { - final var builder = JWT.create(); - buildBasicInfo(builder, expireAfter, subject, audience); - return buildToken(builder); - } - - /** - * Creates a new token with the specified expiration time, subject, - * audience, and custom payload data. - * - * @param expireAfter the duration after which the token will expire - * @param subject the subject of the token - * @param audience the audience for which the token is intended - * @param payloads the custom payload data to be included in the token - * @return the generated token as a {@code String} - */ - @Override - public String createToken(Duration expireAfter, String audience, String subject, Map payloads) { - // Create token. - final var builder = JWT.create(); - buildBasicInfo(builder, expireAfter, subject, audience); - buildMapClaims(builder, payloads); - return buildToken(builder); - } - - /** - * Creates a new token with the specified expiration time, subject, - * audience, and strongly-typed payload data. - * - * @param expireAfter the duration after which the token will expire - * @param subject the subject of the token - * @param audience the audience for which the token is intended - * @param payload the strongly-typed payload data to be included in the - * token - * @return the generated token as a {@code String} - */ - @Override - public String createToken(Duration expireAfter, String audience, String subject, T payload) { - final var builder = JWT.create(); - buildBasicInfo(builder, expireAfter, subject, audience); - - var payloadClass = payload.getClass(); - var fields = payloadClass.getDeclaredFields(); - - for (var field : fields) { - try { - var fieldName = field.getName(); - // Skip the fields which are annotated with ExcludeFromPayload - if (field.isAnnotationPresent(ExcludeFromPayload.class)) - continue; - - Object invokeObj = payload; - var getter = payloadClass.getDeclaredMethod("get" + fieldName.substring(0, 1).toUpperCase() + fieldName.substring(1)); - if (field.isAnnotationPresent(TokenEnum.class)) { - var tokenEnum = field.getAnnotation(TokenEnum.class); - invokeObj = getter.invoke(payload); - getter = field.getType().getDeclaredMethod("get" + tokenEnum.propertyName().substring(0, 1).toUpperCase() + tokenEnum.propertyName().substring(1)); - } - - // Build Claims - addClaim(builder, fieldName, getter.invoke(invokeObj)); - } catch (IllegalAccessException e) { - log.error("Cannot access field {}!", field.getName()); - } catch (NoSuchMethodException e) { - log.error("Unable to find setter according to given field name.", e); - } catch (InvocationTargetException e) { - log.info("Cannot invoke method.", e); - } - } - - return buildToken(builder); - } - - /** - * Resolves the given token into a {@link DecodedJWT} object. - * - * @param token the token to be resolved - * @return a {@link DecodedJWT} object - */ - @Override - public DecodedJWT resolve(String token) { - return jwtVerifier.verify(token); - } - - /** - * Extracts the payload information from the given token and maps it to the - * specified target type. - * - * @param token the token from which to extract the payload - * @param targetType the target class representing the payload data type - * @return an instance of the specified target type with the extracted - * payload data, or {@code null} when extraction fails - */ - @Override - public T extract(String token, Class targetType) { - try { - // Get claims from token. - var payloads = objectMapper.readValue(Base64Util.decodeUrlComponents(resolve(token).getPayload()), new MapTypeReference()); - // Get the no-argument constructor to create an instance. - var bean = targetType.getConstructor().newInstance(); - - for (var entry : payloads.entrySet()) { - // Jump all JWT pre-defined properties and the fields that are annotated to be excluded. - if (PredefinedKeys.KEYS.contains(entry.getKey()) || targetType.getDeclaredField(entry.getKey()).isAnnotationPresent(ExcludeFromPayload.class)) - continue; - - var field = targetType.getDeclaredField(entry.getKey()); - var setter = targetType.getDeclaredMethod("set" + entry.getKey().substring(0, 1).toUpperCase() + entry.getKey().substring(1), field.getType()); - var fieldValue = entry.getValue(); - if (field.isAnnotationPresent(TokenEnum.class)) { - var annotation = field.getAnnotation(TokenEnum.class); - var enumStaticLoader = field.getType().getDeclaredMethod("loadBy" + annotation.propertyName().substring(0, 1).toUpperCase() + annotation.propertyName().substring(1), annotation.dataType().getMappedClass()); - fieldValue = enumStaticLoader.invoke(null, fieldValue); - } - - if (setter.canAccess(bean)) { - setter.invoke(bean, fieldValue); - } else { - log.error("Setter for field {} can't be accessed.", entry.getKey()); - } - } - return bean; - } catch (JsonProcessingException e) { - log.error("Unable to read payload as a Map.", e); - } catch (InvocationTargetException | InstantiationException | IllegalAccessException | - NoSuchMethodException e) { - log.error("Unable to load the constructor or setter.", e); - } catch (NoSuchFieldException e) { - log.error("Unable to load the field.", e); - } - return null; - } - - /** - * Re-generate a new token with the payload in the old one. - * - * @param oldToken the old token - * @param expireAfter how long the new token can be valid for - * @return re-generated token with the payload in the old one or - * {@code null} if an {@link JsonProcessingException} occurred. - */ - @Override - public String renew(String oldToken, Duration expireAfter) { - var resolved = resolve(oldToken); - - try { - var payload = objectMapper.readValue(Base64Util.decodeUrlComponents(resolved.getPayload()), ObjectNode.class); - payload.remove(PredefinedKeys.KEYS); - - var payloadMap = objectMapper.convertValue(payload, new MapTypeReference()); - return createToken(expireAfter, resolved.getAudience().get(0), resolved.getSubject(), payloadMap); - } catch (JsonProcessingException e) { - log.error("Cannot read payload content, error details:", e); - } - - return null; - } - - /** - * Renews the given expired token with the specified custom payload data. - * - * @param oldToken the expired token to be renewed - * @param payload the custom payload data to be included in the renewed - * token - * @return the renewed token as a {@code String} - */ - @Override - public String renew(String oldToken, Duration expireAfter, Map payload) { - final var resolvedToken = this.resolve(oldToken); - var audience = resolvedToken.getAudience().get(0); - - return createToken(expireAfter, audience, resolvedToken.getSubject(), payload); - } - - /** - * Renews the given expired token with the specified custom payload data. - * - * @param oldToken the expiring token to be renewed - * @param payload the custom payload data to be included in the renewed - * token - * @return the renewed token as a {@code String} - */ - @Override - public String renew(String oldToken, Map payload) { - return renew(oldToken, Duration.ofMinutes(30), payload); - } - - /** - * Renews the given expired token with the new specified strongly-typed - * payload data. - * - * @param oldToken the expiring token to be renewed - * @param payload the strongly-typed payload data to be included in the - * renewed token - * @return the renewed token as a {@code String} - */ - @Override - public String renew(String oldToken, Duration expireAfter, T payload) { - final var resolvedToken = this.resolve(oldToken); - var audience = resolvedToken.getAudience().get(0); - - return createToken(expireAfter, audience, resolvedToken.getSubject(), payload); - } - - /** - * Renews the given expired token with the new specified strongly-typed - * payload data. - * - * @param the type of the payload data, must implement - * {@link TokenPayload} - * @param oldToken the expired token to be renewed - * @param payload the strongly-typed payload data to be included in the - * renewed token - * @return the renewed token as a {@link String} - */ - @Override - public String renew(String oldToken, T payload) { - return renew(oldToken, Duration.ofMinutes(30), payload); - } - - /** - * Builds the basic information of the JSON Web Token (JWT) using the - * provided parameters and adds it to the JWTCreator.Builder. - * - * @param subject the subject claim value to be included in the JWT - * @param audience an array of audience claim values to be included in - * the JWT - * @param expireAfter the duration after which the JWT will expire - * @param builder the JWTCreator.Builder instance to which the basic - * information will be added - */ - private void buildBasicInfo(JWTCreator.Builder builder, Duration expireAfter, String subject, String... audience) { - var now = LocalDateTime.now(); - - // bind issuer (iss) - builder.withIssuer(issuer); - // bind issued at (iat) - builder.withIssuedAt(now.atZone(ZoneId.systemDefault()).toInstant()); - // bind not before (nbf) - builder.withNotBefore(now.atZone(ZoneId.systemDefault()).toInstant()); - // bind audience (aud) - builder.withAudience(audience); - // bind subject (sub) - builder.withSubject(subject); - // bind expire at (exp) - builder.withExpiresAt(now.plus(expireAfter).atZone(ZoneId.systemDefault()).toInstant()); - // bind JWT Id (jti) - builder.withJWTId(jtiCreator.nextId().toString()); - } - - /** - * Add a claim to a builder. - * - * @param builder the builder to build this JSON Web Token - * @param name the property name - * @param value the property value - */ - private void addClaim(JWTCreator.Builder builder, String name, Object value) { - if (Objects.nonNull(value)) { - if (value instanceof Boolean v) { - builder.withClaim(name, v); - } else if (value instanceof Double v) { - builder.withClaim(name, v); - } else if (value instanceof Float v) { - builder.withClaim(name, v.doubleValue()); - } else if (value instanceof Integer v) { - builder.withClaim(name, v); - } else if (value instanceof Long v) { - builder.withClaim(name, v); - } else if (value instanceof String v) { - builder.withClaim(name, v); - } else if (value instanceof Date v) { - builder.withClaim(name, v); - } else if (value instanceof List v) { - builder.withClaim(name, v); - } else { - log.warn(""" - Unable to determine the type of field {}, we will handle it as a String.""", name); - builder.withClaim(name, value.toString()); - } - } else { - builder.withNullClaim(name); - } - } - - /** - * Builds the custom claims of the JSON Web Token (JWT) using the provided - * Map of claims and adds them to the JWTCreator.Builder. - *

    - * This method is used to add custom claims to the JWT. It takes a Map of - * claims, where each entry represents a custom claim name (key) and its - * corresponding value (value). The custom claims will be added to the JWT - * using the JWTCreator.Builder. - * - * @param claims a Map containing the custom claims to be added to the JWT - * @param builder the JWTCreator.Builder instance to which the custom - * claims will be added - */ - private void buildMapClaims(JWTCreator.Builder builder, Map claims) { - if (Objects.nonNull(claims)) { - for (var e : claims.entrySet()) { - addClaim(builder, e.getKey(), e.getValue()); - } - } - } - - /** - * Finish creating a token. - *

    - * This is the final step of create a token, to sign this token. - * - * @param builder the builder to build this JWT - * @return the generated token as a {@code String} - */ - private String buildToken(JWTCreator.Builder builder) { - return builder.sign(algorithm); - } - - /** - * Default type reference for Map. - */ - public static class MapTypeReference extends TypeReference> { - MapTypeReference() { - } - } - - /** - * IdentityGenerator used for generating unique identifiers for "jti" claim in JWT tokens. - */ - private final IdentityGenerator jtiCreator; - - /** - * The algorithm used for signing and verifying JWT tokens. - */ - private final Algorithm algorithm; - - /** - * The issuer claim value to be included in JWT tokens. - */ - private final String issuer; - - /** - * The JSON Web Token resolver. - */ - private final JWTVerifier jwtVerifier; - - /** - * Jackson JSON handler. - */ - private final ObjectMapper objectMapper; - - /** - * A map contains all HMAC-SHA based algorithms. - */ - public static final Map> HMAC_ALGORITHMS = Map.of( - TokenAlgorithm.HS256, Algorithm::HMAC256, - TokenAlgorithm.HS384, Algorithm::HMAC384, - TokenAlgorithm.HS512, Algorithm::HMAC512 - ); - - /** - * A map contains all ECDSA based algorithms. - */ - public static final Map> ECDSA_ALGORITHMS = Map.of( - TokenAlgorithm.ES256, Algorithm::ECDSA256, - TokenAlgorithm.ES384, Algorithm::ECDSA384, - TokenAlgorithm.ES512, Algorithm::ECDSA512 - ); - - /** - * Private constructor to prevent instantiation of this utility class. - * - * @param jtiCreator a creator that can create JWT id - * @param algorithm an algorithm to sign this JWT - * @param issuer the person or organisation who issued this JWT - * @param objectMapper a mapper for handling JSON serialisation and deserialization - */ - private AuthzeroTokenResolver(IdentityGenerator jtiCreator, Algorithm algorithm, String issuer, ObjectMapper objectMapper) { - this.jtiCreator = jtiCreator; - this.algorithm = algorithm; - this.issuer = issuer; - this.objectMapper = objectMapper; - this.jwtVerifier = JWT.require(algorithm).build(); - } - -} diff --git a/jwt-toolbox-auth0/src/main/resources/logback.xml b/jwt-toolbox-auth0/src/main/resources/logback.xml index 6d26440..288ac4a 100644 --- a/jwt-toolbox-auth0/src/main/resources/logback.xml +++ b/jwt-toolbox-auth0/src/main/resources/logback.xml @@ -1,26 +1,33 @@ - - + + - + ${COLOURFUL_OUTPUT} @@ -29,4 +36,4 @@ - \ No newline at end of file + diff --git a/jwt-toolbox-auth0/src/test/java/com/onixbyte/jwt/auth0/test/TestAuthzeroTokenResolver.java b/jwt-toolbox-auth0/src/test/java/com/onixbyte/jwt/auth0/test/TestAuthzeroTokenResolver.java deleted file mode 100644 index 68ecf82..0000000 --- a/jwt-toolbox-auth0/src/test/java/com/onixbyte/jwt/auth0/test/TestAuthzeroTokenResolver.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2023 CodeCraftersCN. - * - * 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.jwt.auth0.test; - -/** - * TestAuthzeroTokenResolver - * - * @author Zihlu Wang - */ -public class TestAuthzeroTokenResolver { - -} diff --git a/jwt-toolbox-facade/README.md b/jwt-toolbox-facade/README.md index 5f5623b..03efa39 100644 --- a/jwt-toolbox-facade/README.md +++ b/jwt-toolbox-facade/README.md @@ -1,12 +1,11 @@ -# Module `simple-jwt-facade` +# JWT Toolbox :: Facade ## Introduction -The `simple-jwt-facade` module is a lightweight and easy-to-use façade for working with JSON Web Tokens (JWT) in Java applications. It provides a simplified interface and utilities to handle the creation, validation, renewal, and processing of JWTs without the need for complex configurations or third-party dependencies. - -## Prerequisites - -This whole `JDevKit` is developed by **JDK 17**, which means you have to use JDK 17 for better experience. +The JWT Toolbox Facade module is a lightweight and easy-to-use façade for working with JSON Web +Tokens (JWT) in Java applications. It provides a simplified interface and utilities to handle the +creation, validation, renewal, and processing of JWTs without the need for complex configurations or +third-party dependencies. ## Installation @@ -16,27 +15,36 @@ It is quite simple to install this module by `Maven`. The only thing you need to ```xml - cn.org.codecrafters - simple-jwt-facade - ${simple-jwt-facade.version} + com.onixbyte + jwt-toolkit-facade + ${jwt-toolkit-facade.version} ``` -And run `mvn dependency:get` in your project root folder(i.e., if your `pom.xml` is located at `/path/to/your/project/pom.xml`, then your current work folder should be `/path/to/your/project`), then `Maven` will automatically download the `jar` archive from `Maven Central Repository`. This could be **MUCH EASIER** if you are using IDE(i.e., IntelliJ IDEA), the only thing you need to do is click the refresh button of `Maven`. +And run `mvn dependency:get` in your project root folder(i.e., if your `pom.xml` is located at +`/path/to/your/project/pom.xml`, then your current work folder should be `/path/to/your/project`), +then `Maven` will automatically download the `jar` archive from `Maven Central Repository`. -If you are restricted using the Internet, and have to make `Maven` offline, you could follow the following steps. +This could be **MUCH EASIER** if you are using IDE(i.e., IntelliJ IDEA), the only thing you need to +do is click the refresh button of `Maven`. -1. Download the `jar` file from any place you can get and transfer the `jar` files to your work computer. -2. Move the `jar` files to your local `Maven` Repository as the path of `/path/to/maven_local_repo/cn/org/codecrafters/simple-jwt-facade/`. +If you are restricted using the Internet, and have to make `Maven` offline, you could follow the +following steps. + +1. Download the `jar` file from any place you can get and transfer the `jar` files to your + work computer. +2. Move the `jar` files to your local `Maven` Repository as the path of + `/path/to/maven_local_repo/com/onixbyte/jwt-toolbox-facade/`. ### If you are using `Gradle` Add this module to your project with `Gradle` is much easier than doing so with `Maven`. -Find `build.gradle` in the needed project, and add the following code to the `dependencies` closure in the build script: +Find `build.gradle` in the needed project, and add the following code to the `dependencies` closure +in the build script: ```groovy -implementation 'cn.org.codecrafters:simple-jwt-facade:${simple-jwt-facade.version}' +implementation 'com.onixbyte:jwt-toolbox-facade:${jwt-toolbox-facade.version}' ``` ### If you are not using `Maven` or `Gradle` @@ -67,7 +75,7 @@ After doing all these, an implemented `TokenResolver` is ready to process JWTs. You will need an instance of the implementation to process JWTs. ```java -var tokenResolver = new ImplementedTokenResolver(/* arguments you declared */) +var tokenResolver = new ImplementedTokenResolver(/* arguments you declared */); ``` ## Create a JSON Web Token with `TokenResolver` @@ -124,4 +132,4 @@ This method allows you to pass new custom payload into the updated token. The ne 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/jwt-toolbox-facade/build.gradle.kts b/jwt-toolbox-facade/build.gradle.kts index 6f3dddd..998449e 100644 --- a/jwt-toolbox-facade/build.gradle.kts +++ b/jwt-toolbox-facade/build.gradle.kts @@ -1,19 +1,25 @@ /* - * Copyright (C) 2024-2025 OnixByte. + * 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 + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * http://www.apache.org/licenses/LICENSE-2.0 + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. * - * 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. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ + import java.net.URI plugins { @@ -86,8 +92,8 @@ publishing { } scm { - connection = "scm:git:git://github.com:OnixByte/JDevKit.git" - developerConnection = "scm:git:git://github.com:OnixByte/JDevKit.git" + connection = "scm:git:git://github.com:onixbyte/onixbyte-toolbox.git" + developerConnection = "scm:git:git://github.com:onixbyte/onixbyte-toolbox.git" url = projectGithubUrl } diff --git a/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/SecretCreator.java b/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/SecretCreator.java index 0e8ba02..a3412e4 100644 --- a/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/SecretCreator.java +++ b/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/SecretCreator.java @@ -1,18 +1,23 @@ /* - * Copyright (C) 2024-2025 OnixByte. + * 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 + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * http://www.apache.org/licenses/LICENSE-2.0 + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. * - * 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. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ package com.onixbyte.jwt; @@ -24,18 +29,16 @@ import org.slf4j.LoggerFactory; import java.util.Random; /** - * {@code SecretCreator} is a utility class that provides methods to generate - * secure secret strings. The generated secrets can be used as cryptographic - * keys or passwords for various security-sensitive purposes. + * {@code SecretCreator} is a utility class that provides methods to generate secure secret strings. + * The generated secrets can be used as cryptographic keys or passwords for various + * security-sensitive purposes. * - * @author Zihlu Wang - * @version 1.1.0 + * @author zihluwang + * @version 3.0.0 * @since 1.0.0 */ public final class SecretCreator { - private final static Logger log = LoggerFactory.getLogger(SecretCreator.class); - /** * Generates a secure secret with the specified length and character sets. * diff --git a/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/TokenGenerator.java b/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/TokenGenerator.java new file mode 100644 index 0000000..e41cd9c --- /dev/null +++ b/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/TokenGenerator.java @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024-2025 OnixByte + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.onixbyte.jwt; + +public interface TokenGenerator { +} diff --git a/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/TokenParser.java b/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/TokenParser.java new file mode 100644 index 0000000..8d08464 --- /dev/null +++ b/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/TokenParser.java @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024-2025 OnixByte + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.onixbyte.jwt; + +public interface TokenParser { +} diff --git a/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/TokenPayload.java b/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/TokenPayload.java deleted file mode 100644 index a8f5b0d..0000000 --- a/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/TokenPayload.java +++ /dev/null @@ -1,45 +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.jwt; - -/** - * {@code TokenPayload} interface is used to mark a data class as suitable - * for being used as the payload in a JSON Web Token (JWT). Any class - * implementing this interface can be used to represent the payload data that - * will be included in a JWT. - *

    - * Implementing this interface indicates that the data class contains - * information that needs to be securely transmitted and verified as part of a - * JWT. The payload typically contains claims or attributes that provide - * additional information about the JWT subject or context. - *

    - * Usage: - * To use a class as a JWT payload, simply implement the {@code TokenPayload} - * interface in the data class: - *

    - * public class UserData implements TokenPayload {
    - *     // Class implementation with payload data...
    - * }
    - * 
    - * - * @author Zihlu Wang - * @version 1.1.0 - * @since 1.0.0 - */ -public interface TokenPayload { -} diff --git a/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/TokenResolver.java b/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/TokenResolver.java deleted file mode 100644 index 09b6ab1..0000000 --- a/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/TokenResolver.java +++ /dev/null @@ -1,184 +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.jwt; - -import java.time.Duration; -import java.util.Map; - -/** - * {@code TokenResolver} defines methods for creating, extracting, and - * renewing tokens, particularly JSON Web Tokens (JWTs). It provides a set of - * methods to generate tokens with various payload configurations, extract - * payload from tokens, and renew expired tokens. - *

    - * Token Creation: - * The interface provides overloaded methods for creating tokens with different - * payload configurations, including expiration time, audience, subject, and - * custom payload data. Clients can choose the appropriate method based on - * their specific token requirements. - *

    - * Token Extraction: - * The interface includes methods to extract payload information from a given - * token. Clients can use these methods to obtain the payload data encoded in - * the token. - *

    - * Token Renewal: - * The interface also offers methods for token renewal. Clients can renew an - * expired token by providing a new expiration time, audience, subject, and - * optional custom payload data. - * - * @param the type of the result obtained by the - * third-party library when parsing JWTs - * @author Zihlu Wang - * @version 1.1.0 - * @since 1.0.0 - */ -public interface TokenResolver { - - /** - * Creates a new token with the specified expiration time, subject, and - * audience. - * - * @param expireAfter the duration after which the token will expire - * @param subject the subject of the token - * @param audience the audience for which the token is intended - * @return the generated token as a {@code String} - */ - String createToken(Duration expireAfter, String audience, String subject); - - /** - * Creates a new token with the specified expiration time, subject, - * audience, and custom payload data. - * - * @param expireAfter the duration after which the token will expire - * @param subject the subject of the token - * @param audience the audience for which the token is intended - * @param payload the custom payload data to be included in the token - * @return the generated token as a {@code String} - */ - String createToken(Duration expireAfter, String audience, String subject, Map payload); - - /** - * Creates a new token with the specified expiration time, subject, - * audience, and strongly-typed payload data. - * - * @param the type of the payload data, must implement - * {@link TokenPayload} - * @param expireAfter the duration after which the token will expire - * @param subject the subject of the token - * @param audience the audience for which the token is intended - * @param payload the strongly-typed payload data to be included in the - * token - * @return the generated token as a {@code String} - */ - String createToken(Duration expireAfter, String audience, String subject, T payload); - - /** - * Resolves the given token into a ResolvedTokenType object. - * - * @param token the token to be resolved - * @return a ResolvedTokenType object - */ - ResolvedTokenType resolve(String token); - - /** - * Extracts the payload information from the given token and maps it to the - * specified target type. - * - * @param the target type to which the payload data will be - * mapped - * @param token the token from which to extract the payload - * @param targetType the target class representing the payload data type - * @return an instance of the specified target type with the extracted - * payload data - */ - T extract(String token, Class targetType); - - /** - * Re-generate a new token with the payload in the old one. - * - * @param oldToken the old token - * @param expireAfter how long the new token can be valid for - * @return re-generated token with the payload in the old one - */ - String renew(String oldToken, Duration expireAfter); - - /** - * Re-generate a new token with the payload in the old one. - * - * @param oldToken the old token - * @return re-generated token with the payload in the old one - * @see #renew(String, Duration) - */ - default String renew(String oldToken) { - return renew(oldToken, Duration.ofMinutes(30)); - } - - /** - * Renews the given expired token with the specified custom payload data. - * - * @param oldToken the expired token to be renewed - * @param expireAfter specify when does the new token invalid - * @param payload the custom payload data to be included in the renewed - * token - * @return the renewed token as a {@code String} - */ - String renew(String oldToken, Duration expireAfter, Map payload); - - /** - * Renews the given expired token with the specified custom payload data. - * - * @param oldToken the expired token to be renewed - * @param payload the custom payload data to be included in the renewed - * token - * @return the renewed token as a {@code String} - */ - default String renew(String oldToken, Map payload) { - return renew(oldToken, Duration.ofMinutes(30), payload); - } - - /** - * Renews the given expired token with the specified strongly-typed - * payload data. - * - * @param the type of the payload data, must implement - * {@link TokenPayload} - * @param oldToken the expired token to be renewed - * @param expireAfter specify when does the new token invalid - * @param payload the strongly-typed payload data to be included in the - * renewed token - * @return the renewed token as a {@code String} - */ - String renew(String oldToken, Duration expireAfter, T payload); - - /** - * Renews the given expired token with the specified strongly-typed - * payload data. - * - * @param the type of the payload data, must implement - * {@link TokenPayload} - * @param oldToken the expired token to be renewed - * @param payload the strongly-typed payload data to be included in the - * renewed token - * @return the renewed token as a {@code String} - */ - default String renew(String oldToken, T payload) { - return renew(oldToken, Duration.ofMinutes(30), payload); - } - -} diff --git a/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/annotations/ExcludeFromPayload.java b/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/annotations/ExcludeFromPayload.java deleted file mode 100644 index d9432f3..0000000 --- a/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/annotations/ExcludeFromPayload.java +++ /dev/null @@ -1,60 +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.jwt.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Annotation {@code ExcludeFromPayload} is used to mark a property of a data - * class that should be excluded from being automatically injected into the - * JSON Web Token (JWT) payload during token generation. When a property is - * annotated by this annotation, it will not be included in the JWT payloads. - *

    - * Usage: - * To exclude a property from the JWT payload, annotate the property with - * {@code @ExcludeFromPayload}: - * - *

    {@code
    - * public class UserData implements TokenPayload {
    - *     private String username;
    - *
    - *     // This property will not be included in the JWT payload
    - *     @ExcludeFromPayload
    - *     private String sensitiveData;
    - *
    - *     // Getters and setters...
    - * }
    - * }
    - *

    - * Note: - * This annotation should be used on properties that are not intended to - * be included in the JWT payload due to their sensitive nature or for other - * reasons only. It is important to carefully choose which properties are - * excluded from the payload to ensure the JWT remains secure and efficient. - * - * @author Zihlu Wang - * @version 1.1.0 - * @since 1.0.0 - */ -@Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.FIELD}) -public @interface ExcludeFromPayload { -} diff --git a/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/annotations/TokenEnum.java b/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/annotations/TokenEnum.java deleted file mode 100644 index e2f626b..0000000 --- a/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/annotations/TokenEnum.java +++ /dev/null @@ -1,51 +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.jwt.annotations; - -import com.onixbyte.jwt.constants.TokenDataType; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * This annotation marks the enum field declared in payload class will be handled as basic data - * types in {@link TokenDataType}. - * - * @author Zihlu Wang - */ -@Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.FIELD}) -public @interface TokenEnum { - - /** - * The name of the field of the base data corresponding to the enumeration data. - * - * @return the name of the property - */ - String propertyName(); - - /** - * The attribute {@code dataType} specifies what base data type to treat this enum as. - * - * @return the data type of the token - */ - TokenDataType dataType(); - -} diff --git a/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/constants/PredefinedKeys.java b/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/constants/PredefinedKeys.java index 36de075..d8f4a12 100644 --- a/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/constants/PredefinedKeys.java +++ b/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/constants/PredefinedKeys.java @@ -1,18 +1,23 @@ /* - * Copyright (C) 2024-2025 OnixByte. + * 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 + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * http://www.apache.org/licenses/LICENSE-2.0 + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. * - * 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. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ package com.onixbyte.jwt.constants; @@ -26,13 +31,13 @@ import java.util.List; *

    * The class provides the following standard JWT claim constants: *

      - *
    • {@link #ISSUER}: Represents the "iss" (Issuer) claim.
    • - *
    • {@link #SUBJECT}: Represents the "sub" (Subject) claim.
    • - *
    • {@link #AUDIENCE}: Represents the "aud" (Audience) claim.
    • - *
    • {@link #EXPIRATION_TIME}: Represents the "exp" (Expiration Time) claim.
    • - *
    • {@link #NOT_BEFORE}: Represents the "nbf" (Not Before) claim.
    • - *
    • {@link #ISSUED_AT}: Represents the "iat" (Issued At) claim.
    • - *
    • {@link #JWT_ID}: Represents the "jti" (JWT ID) claim.
    • + *
    • {@link #ISSUER}: Represents the "iss" (Issuer) claim.
    • + *
    • {@link #SUBJECT}: Represents the "sub" (Subject) claim.
    • + *
    • {@link #AUDIENCE}: Represents the "aud" (Audience) claim.
    • + *
    • {@link #EXPIRATION_TIME}: Represents the "exp" (Expiration Time) claim.
    • + *
    • {@link #NOT_BEFORE}: Represents the "nbf" (Not Before) claim.
    • + *
    • {@link #ISSUED_AT}: Represents the "iat" (Issued At) claim.
    • + *
    • {@link #JWT_ID}: Represents the "jti" (JWT ID) claim.
    • *
    *

    * The class also contains a list of all the standard claim constants, accessible via the {@link @@ -43,7 +48,7 @@ import java.util.List; * the standard JWT claim constants. * * @author zihluwang - * @version 1.1.0 + * @version 3.0.0 * @since 1.0.0 */ public final class PredefinedKeys { @@ -86,8 +91,15 @@ public final class PredefinedKeys { /** * List containing all the standard JWT claim constants. */ - public static final List KEYS = - List.of(ISSUER, SUBJECT, AUDIENCE, EXPIRATION_TIME, NOT_BEFORE, ISSUED_AT, JWT_ID); + public static final List KEYS = List.of( + ISSUER, + SUBJECT, + AUDIENCE, + EXPIRATION_TIME, + NOT_BEFORE, + ISSUED_AT, + JWT_ID + ); /** * Private constructor to prevent instantiation of this utility class. diff --git a/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/constants/TokenAlgorithm.java b/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/constants/TokenAlgorithm.java index af77fd1..1abde7a 100644 --- a/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/constants/TokenAlgorithm.java +++ b/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/constants/TokenAlgorithm.java @@ -1,24 +1,27 @@ /* - * Copyright (C) 2024-2025 OnixByte. + * 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 + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * http://www.apache.org/licenses/LICENSE-2.0 + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. * - * 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. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ package com.onixbyte.jwt.constants; -import java.util.List; - /** * The {@code TokenAlgorithm} enum class defines the algorithms that can be * used for signing and verifying JSON Web Tokens (JWT). JWT allows various @@ -28,19 +31,19 @@ import java.util.List; *

    * Supported Algorithms: *

      - *
    • {@link TokenAlgorithm#HS256}: HMAC SHA-256
    • - *
    • {@link TokenAlgorithm#HS384}: HMAC SHA-384
    • - *
    • {@link TokenAlgorithm#HS512}: HMAC SHA-512
    • - *
    • {@link TokenAlgorithm#RS256}: RSA PKCS#1 v1.5 with SHA-256
    • - *
    • {@link TokenAlgorithm#RS384}: RSA PKCS#1 v1.5 with SHA-384
    • - *
    • {@link TokenAlgorithm#RS512}: RSA PKCS#1 v1.5 with SHA-512
    • - *
    • {@link TokenAlgorithm#ES256}: ECDSA with SHA-256
    • - *
    • {@link TokenAlgorithm#ES384}: ECDSA with SHA-384
    • - *
    • {@link TokenAlgorithm#ES512}: ECDSA with SHA-512
    • + *
    • {@link TokenAlgorithm#HS256}: HMAC SHA-256
    • + *
    • {@link TokenAlgorithm#HS384}: HMAC SHA-384
    • + *
    • {@link TokenAlgorithm#HS512}: HMAC SHA-512
    • + *
    • {@link TokenAlgorithm#RS256}: RSA PKCS#1 v1.5 with SHA-256
    • + *
    • {@link TokenAlgorithm#RS384}: RSA PKCS#1 v1.5 with SHA-384
    • + *
    • {@link TokenAlgorithm#RS512}: RSA PKCS#1 v1.5 with SHA-512
    • + *
    • {@link TokenAlgorithm#ES256}: ECDSA with SHA-256
    • + *
    • {@link TokenAlgorithm#ES384}: ECDSA with SHA-384
    • + *
    • {@link TokenAlgorithm#ES512}: ECDSA with SHA-512
    • *
    * - * @author Zihlu Wang - * @version 1.1.0 + * @author zihluwang + * @version 3.0.0 * @since 1.0.0 */ public enum TokenAlgorithm { @@ -91,18 +94,4 @@ public enum TokenAlgorithm { ES512, ; - /** - * HMAC-based algorithms. - */ - public static final List HMAC_ALGORITHMS = List.of( - TokenAlgorithm.HS256, TokenAlgorithm.HS384, TokenAlgorithm.HS512 - ); - - /** - * ECDSA-based algorithms. - */ - public static final List ECDSA_ALGORITHMS = List.of( - TokenAlgorithm.ES256, TokenAlgorithm.ES384, TokenAlgorithm.ES512 - ); - } diff --git a/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/constants/TokenDataType.java b/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/constants/TokenDataType.java deleted file mode 100644 index 98bdf43..0000000 --- a/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/constants/TokenDataType.java +++ /dev/null @@ -1,78 +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.jwt.constants; - -/** - * The base data types used to process enum data. - * - * @author Zihlu Wang - */ -public enum TokenDataType { - - /** - * Marks enumeration being processed as Boolean. - */ - BOOLEAN(Boolean.class), - - /** - * Marks enumeration being processed as Double. - */ - DOUBLE(Long.class), - - /** - * Marks enumeration being processed as Float. - */ - FLOAT(Float.class), - - /** - * Marks enumeration being processed as Integer. - */ - INTEGER(Integer.class), - - /** - * Marks enumeration being processed as Long. - */ - LONG(Long.class), - - /** - * Marks enumeration being processed as String. - */ - STRING(String.class), - ; - - /** - * The mapped class to this mark. - */ - private final Class mappedClass; - - /** - * Create a TokenDataType with a mapped class. - */ - TokenDataType(Class mappedClass) { - this.mappedClass = mappedClass; - } - - /** - * Return the target mapped class. - * - * @return mapped class - */ - public Class getMappedClass() { - return mappedClass; - } -} diff --git a/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/exceptions/IllegalKeyPairException.java b/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/exceptions/IllegalKeyPairException.java index 8ba5a89..2a70198 100644 --- a/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/exceptions/IllegalKeyPairException.java +++ b/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/exceptions/IllegalKeyPairException.java @@ -1,18 +1,23 @@ /* - * Copyright (C) 2024-2025 OnixByte. + * 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 + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * http://www.apache.org/licenses/LICENSE-2.0 + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. * - * 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. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ package com.onixbyte.jwt.exceptions; @@ -21,7 +26,7 @@ package com.onixbyte.jwt.exceptions; * {@link IllegalKeyPairException} indicates an exception that the key pair is invalid. * * @author zihluwang - * @version 1.6.0 + * @version 3.0.0 */ public class IllegalKeyPairException extends RuntimeException { diff --git a/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/exceptions/IllegalSecretException.java b/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/exceptions/IllegalSecretException.java index eddf440..c039e61 100644 --- a/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/exceptions/IllegalSecretException.java +++ b/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/exceptions/IllegalSecretException.java @@ -1,24 +1,29 @@ /* - * Copyright (C) 2024-2025 OnixByte. + * 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 + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * http://www.apache.org/licenses/LICENSE-2.0 + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. * - * 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. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ package com.onixbyte.jwt.exceptions; /** - * {@link IllegalKeyPairException} indicates the secret to sign a JWT is illegal. + * {@code IllegalKeyPairException} indicates the secret to sign a JWT is illegal. * * @author zihluwang * @version 1.6.0 diff --git a/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/exceptions/UnsupportedAlgorithmException.java b/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/exceptions/UnsupportedAlgorithmException.java index a79d02d..10609f8 100644 --- a/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/exceptions/UnsupportedAlgorithmException.java +++ b/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/exceptions/UnsupportedAlgorithmException.java @@ -1,28 +1,28 @@ /* - * Copyright (C) 2024-2025 OnixByte. + * 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 + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * http://www.apache.org/licenses/LICENSE-2.0 + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. * - * 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. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ package com.onixbyte.jwt.exceptions; -import com.onixbyte.jwt.TokenResolver; - /** - * This {@code UnsupportedAlgorithmException} represents the given - * algorithm is not supported by {@link - * TokenResolver} yet. *

    * If you want the supports to an unsupported algorithm, you could *

      @@ -30,42 +30,39 @@ import com.onixbyte.jwt.TokenResolver; *
    • Communicate with us on Discord Community.
    • *
    * - * @author Zihlu Wang - * @version 1.1.0 - * @since 1.0.0 + * @author zihluwang + * @version 3.0.0 */ public class UnsupportedAlgorithmException extends RuntimeException { /** - * Constructs a new {@code UnsupportedAlgorithmException} with {@code null} - * as its detail message. The cause is not initialized, and may - * subsequently be initialized by a call to {@link #initCause}. + * Constructs a new {@code UnsupportedAlgorithmException} with {@code null} as its + * detail message. The cause is not initialized, and may subsequently be initialized by a call + * to {@link #initCause}. */ public UnsupportedAlgorithmException() { } /** - * Constructs a new {@code UnsupportedAlgorithmException} with the - * specified detail message. The cause is not initialized, and may - * subsequently be initialized by a call to {@link #initCause}. + * Constructs a new {@code UnsupportedAlgorithmException} with the specified detail message. + * The cause is not initialized, and may subsequently be initialized by a call + * to {@link #initCause}. * - * @param message the detail message. The detail message is saved for - * later retrieval by the {@link #getMessage()} method. + * @param message the detail message. The detail message is saved for later retrieval by the {@link #getMessage()} method. */ public UnsupportedAlgorithmException(String message) { super(message); } /** - * Constructs a new {@code UnsupportedAlgorithmException} with the - * specified detail message and cause. + * Constructs a new {@code UnsupportedAlgorithmException} with the specified detail message + * and cause. * - * @param message the detail message (which is saved for later retrieval - * by the {@link #getMessage()} method). + * @param message the detail message (which is saved for later retrieval by the + * {@link #getMessage()} method) * @param cause the cause (which is saved for later retrieval by the - * {@link #getCause()} method). (A {@code null} value is - * permitted, and indicates that the cause is nonexistent or - * unknown.) + * {@link #getCause()} method). (A {@code null} value is permitted, and + * indicates that the cause is nonexistent or unknown.) * @since 1.4 */ public UnsupportedAlgorithmException(String message, Throwable cause) { @@ -73,17 +70,14 @@ public class UnsupportedAlgorithmException extends RuntimeException { } /** - * Constructs a new {@code UnsupportedAlgorithmException} with the - * specified cause and a detail message of - * {@code (cause==null ? null : cause.toString())} (which typically - * contains the class and detail message of {@code cause}). This - * constructor is useful for runtime exceptions that are little more - * than wrappers for other throwable. + * Constructs a new {@code UnsupportedAlgorithmException} with the specified cause and a detail + * message of {@code (cause==null ? null : cause.toString())} (which typically contains the + * class and detail message of {@code cause}). This constructor is useful for runtime + * exceptions that are little more than wrappers for other throwable. * * @param cause the cause (which is saved for later retrieval by the - * {@link #getCause()} method). (A {@code null} value is - * permitted, and indicates that the cause is nonexistent or - * unknown.) + * {@link #getCause()} method). (A {@code null} value is permitted, and indicates + * that the cause is nonexistent or unknown.) * @since 1.4 */ public UnsupportedAlgorithmException(Throwable cause) { @@ -91,19 +85,22 @@ public class UnsupportedAlgorithmException extends RuntimeException { } /** - * Constructs a new {@code UnsupportedAlgorithmException} with the - * specified detail message, cause, suppression enabled or disabled, and - * writable stack trace enabled or disabled. + * Constructs a new {@code UnsupportedAlgorithmException} with the specified detail message, + * cause, suppression enabled or disabled, and writable stack trace enabled or disabled. * * @param message the detail message. - * @param cause the cause (A {@code null} value is permitted, - * and indicates that the cause is nonexistent or - * unknown.) + * @param cause the cause (A {@code null} value is permitted, and indicates that + * the cause is nonexistent or unknown.) * @param enableSuppression whether suppression is enabled or disabled * @param writableStackTrace whether the stack trace should be writable * @since 1.0.0 */ - public UnsupportedAlgorithmException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { + public UnsupportedAlgorithmException( + String message, + Throwable cause, + boolean enableSuppression, + boolean writableStackTrace + ) { super(message, cause, enableSuppression, writableStackTrace); } } diff --git a/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/exceptions/WeakSecretException.java b/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/exceptions/WeakSecretException.java index 7c81641..1ee17e1 100644 --- a/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/exceptions/WeakSecretException.java +++ b/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/exceptions/WeakSecretException.java @@ -1,69 +1,69 @@ /* - * Copyright (C) 2024-2025 OnixByte. + * 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 + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * http://www.apache.org/licenses/LICENSE-2.0 + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. * - * 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. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ package com.onixbyte.jwt.exceptions; /** - * {@code WeakSecretException} represents that your secret is too weak to be - * used in signing JWTs. + * {@code WeakSecretException} represents that your secret is too weak to be used in signing JWTs. *

    - * {@code WeakSecretException} will only appears that if you are using the - * implementation module {@code cn.org.codecrafters:simple-jwt-jjwt} due to - * it is implemented by {@code io.jsonwebtoken:jjwt}. + * {@code WeakSecretException} will only appears that if you are using the implementation module + * {@code com.onixbyte:jwt-toolbox-auth0} due to it is implemented by {@code com.auth0:java-jwt}. * - * @author Zihlu Wang - * @version 1.1.0 + * @author zihluwang + * @version 3.0.0 * @since 1.0.0 */ public class WeakSecretException extends RuntimeException { /** - * Constructs a new {@code WeakSecretException} with {@code null} as its - * detail message. The cause is not initialized, and may subsequently be - * initialized by a call to {@link #initCause}. + * Constructs a new {@code WeakSecretException} with {@code null} as its detail message. + * The cause is not initialized, and may subsequently be initialized by a call + * to {@link #initCause}. */ public WeakSecretException() { } /** - * Constructs a new {@code WeakSecretException} with the specified detail - * message. The cause is not initialized, and may subsequently be - * initialized by a call to {@link #initCause}. + * Constructs a new {@code WeakSecretException} with the specified detail message. The cause is + * not initialised, and may subsequently be initialized by a call to {@link #initCause}. * - * @param message the detail message. The detail message is saved for - * later retrieval by the {@link #getMessage()} method. + * @param message the detail message. The detail message is saved for later retrieval by the + * {@link #getMessage()} method. */ public WeakSecretException(String message) { super(message); } /** - * Constructs a new {@code WeakSecretException} with the specified detail - * message and cause. + * Constructs a new {@code WeakSecretException} with the specified detail message and cause. *

    - * Note that the detail message associated with {@code cause} is not - * automatically incorporated in this runtime exception's detail message. + * Note that the detail message associated with {@code cause} is not automatically + * incorporated in this runtime exception's detail message. * - * @param message the detail message (which is saved for later retrieval - * by the {@link #getMessage()} method). + * @param message the detail message (which is saved for later retrieval by the + * {@link #getMessage()} method). * @param cause the cause (which is saved for later retrieval by the - * {@link #getCause()} method). (A {@code null} value is - * permitted, and indicates that the cause is nonexistent or - * unknown.) + * {@link #getCause()} method). (A {@code null} value is permitted, and + * indicates that the cause is nonexistent or unknown.) * @since 1.0.0 */ public WeakSecretException(String message, Throwable cause) { @@ -71,16 +71,14 @@ public class WeakSecretException extends RuntimeException { } /** - * Constructs a new {@code WeakSecretException} with the specified cause - * and a detail message of {@code (cause==null ? null : cause.toString())} - * (which typically contains the class and detail message of - * {@code cause}). This constructor is useful for runtime exceptions that - * are little more than wrappers for other throwable. + * Constructs a new {@code WeakSecretException} with the specified cause and a detail message + * of {@code (cause==null ? null : cause.toString())} (which typically contains the class and + * detail message of {@code cause}). This constructor is useful for runtime exceptions that are + * little more than wrappers for other throwable. * * @param cause the cause (which is saved for later retrieval by the - * {@link #getCause()} method). (A {@code null} value is - * permitted, and indicates that the cause is nonexistent or - * unknown.) + * {@link #getCause()} method). (A {@code null} value is permitted, and indicates + * that the cause is nonexistent or unknown.) * @since 1.0.0 */ public WeakSecretException(Throwable cause) { @@ -88,19 +86,22 @@ public class WeakSecretException extends RuntimeException { } /** - * Constructs a new {@code WeakSecretException} with the specified detail - * message, cause, suppression enabled or disabled, and writable - * stack trace enabled or disabled. + * Constructs a new {@code WeakSecretException} with the specified detail message, cause, + * suppression enabled or disabled, and writable stack trace enabled or disabled. * * @param message the detail message. - * @param cause the cause. (A {@code null} value is permitted, - * and indicates that the cause is nonexistent or - * unknown.) + * @param cause the cause. (A {@code null} value is permitted, and indicates that + * the cause is nonexistent or unknown.) * @param enableSuppression whether suppression is enabled or disabled * @param writableStackTrace whether the stack trace should be writable * @since 1.0.0 */ - public WeakSecretException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { + public WeakSecretException( + String message, + Throwable cause, + boolean enableSuppression, + boolean writableStackTrace + ) { super(message, cause, enableSuppression, writableStackTrace); } } diff --git a/jwt-toolbox-facade/src/main/resources/logback.xml b/jwt-toolbox-facade/src/main/resources/logback.xml index 6d26440..288ac4a 100644 --- a/jwt-toolbox-facade/src/main/resources/logback.xml +++ b/jwt-toolbox-facade/src/main/resources/logback.xml @@ -1,26 +1,33 @@ - - + + - + ${COLOURFUL_OUTPUT} @@ -29,4 +36,4 @@ - \ No newline at end of file + diff --git a/jwt-toolbox-spring-boot-starter/README.md b/jwt-toolbox-spring-boot-starter/README.md index 38bc51e..3c53e36 100644 --- a/jwt-toolbox-spring-boot-starter/README.md +++ b/jwt-toolbox-spring-boot-starter/README.md @@ -1,8 +1,15 @@ -# Module `simple-jwt-spring-boot-starter` +# JWT Toolbox :: Spring Boot Starter ## Introduction -Module `simple-jwt-spring-boot-starter` is a lightweight and easy-to-use Spring Boot starter module that provides seamless integration with JSON Web Token (JWT) authentication in Spring Boot applications. With this starter, developers can easily configure and enable JWT-based authentication for their APIs and web applications without the need for complex manual setup. It simplifies the process of generating and validating JWTs, making it effortless to secure endpoints and implement token-based authentication in Spring Boot projects. The module is designed to be flexible, allowing developers to customize various aspects of JWT authentication to suit their specific requirements. Overall, `simple-jwt-spring-boot-starter` is a convenient solution for adding secure and efficient JWT authentication to Spring Boot applications. +Module **JWT Toolbox :: Spring Boot Starter** is a lightweight and easy-to-use Spring Boot starter +module that provides seamless integration with JSON Web Token (JWT) authentication in Spring Boot +applications. With this starter, developers can easily configure and enable JWT-based authentication +for their APIs and web applications without the need for complex manual setup. It simplifies the +process of generating and validating JWTs, making it effortless to secure endpoints and implement +token-based authentication in Spring Boot projects. The module is designed to be flexible, allowing +developers to customize various aspects of JWT authentication to suit their specific requirements. +Overall, `jwt-toolbox-spring-boot-starter` is a convenient solution for adding secure and efficient JWT authentication to Spring Boot applications. ## Prerequisites diff --git a/jwt-toolbox-spring-boot-starter/build.gradle.kts b/jwt-toolbox-spring-boot-starter/build.gradle.kts index 65d0eac..c102025 100644 --- a/jwt-toolbox-spring-boot-starter/build.gradle.kts +++ b/jwt-toolbox-spring-boot-starter/build.gradle.kts @@ -1,19 +1,25 @@ /* - * Copyright (C) 2024-2025 OnixByte. + * 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 + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * http://www.apache.org/licenses/LICENSE-2.0 + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. * - * 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. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ + import java.net.URI plugins { @@ -99,8 +105,8 @@ publishing { } scm { - connection = "scm:git:git://github.com:OnixByte/JDevKit.git" - developerConnection = "scm:git:git://github.com:OnixByte/JDevKit.git" + connection = "scm:git:git://github.com:onixbyte/onixbyte-toolbox.git" + developerConnection = "scm:git:git://github.com:onixbyte/onixbyte-toolbox.git" url = projectGithubUrl } diff --git a/jwt-toolbox-spring-boot-starter/src/main/java/com/onixbyte/jwt/autoconfiguration/AuthzeroTokenResolverAutoConfiguration.java b/jwt-toolbox-spring-boot-starter/src/main/java/com/onixbyte/jwt/autoconfiguration/AuthzeroTokenResolverAutoConfiguration.java deleted file mode 100644 index f1a5e4f..0000000 --- a/jwt-toolbox-spring-boot-starter/src/main/java/com/onixbyte/jwt/autoconfiguration/AuthzeroTokenResolverAutoConfiguration.java +++ /dev/null @@ -1,119 +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.jwt.autoconfiguration; - -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.jwt.constants.TokenAlgorithm; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.boot.autoconfigure.AutoConfiguration; -import org.springframework.boot.autoconfigure.AutoConfigureAfter; -import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.context.annotation.Bean; - -/** - * {@code AuthzeroTokenResolverAutoConfiguration} is responsible for automatically configuring the - * Simple JWT library with - * {@code com.auth0:java-jwt} when used in a Spring Boot application. It provides default settings - * and configurations to ensure that the library works smoothly without requiring - * manual configuration. - *

    - * This autoconfiguration class sets up the necessary beans and components required for JWT - * generation and validation. It automatically creates and configures the - * {@link AuthzeroTokenResolver} bean based on the available options and properties. - *

    - * Developers using the Simple JWT library with Spring Boot do not need to explicitly configure the - * library, as the autoconfiguration takes care of setting up the necessary components and - * configurations automatically. However, developers still have the flexibility to customise the - * behavior of the library by providing their own configurations and properties. - * - * @author zihluwang - * @version 1.6.0 - * @since 1.0.0 - */ -@AutoConfiguration -@EnableConfigurationProperties(value = {SimpleJwtProperties.class}) -@ConditionalOnClass({DecodedJWT.class, AuthzeroTokenResolver.class}) -@ConditionalOnMissingBean({TokenResolver.class}) -@ConditionalOnBean(value = {IdentityGenerator.class}, name = "jtiCreator") -@AutoConfigureAfter(value = GuidAutoConfiguration.class) -public class AuthzeroTokenResolverAutoConfiguration { - - private final static Logger log = LoggerFactory.getLogger(AuthzeroTokenResolverAutoConfiguration.class); - - /** - * Constructs a new {@code SimpleJwtAutoConfiguration} instance with the - * provided SimpleJwtProperties. - * - * @param simpleJwtProperties a {@link SimpleJwtProperties} instance - * @param jtiCreator a creator to create ids for JSON Web Token - * @param objectMapper jackson JSON Handler - */ - @Autowired - public AuthzeroTokenResolverAutoConfiguration(SimpleJwtProperties simpleJwtProperties, - @Qualifier("jtiCreator") IdentityGenerator jtiCreator, - ObjectMapper objectMapper) { - this.jtiCreator = jtiCreator; - this.simpleJwtProperties = simpleJwtProperties; - this.objectMapper = objectMapper; - } - - /** - * 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 IdentityGenerator}, {@code algorithm}, {@code issuer}, and {@code secret} - * properties from {@link SimpleJwtProperties}. - * - * @return the {@link TokenResolver} instance - */ - @Bean - public TokenResolver tokenResolver() { - var builder = AuthzeroTokenResolver.builder(); - - if (TokenAlgorithm.ECDSA_ALGORITHMS.contains(simpleJwtProperties.getAlgorithm())) { - builder.keyPair(simpleJwtProperties.getPublicKey(), simpleJwtProperties.getPrivateKey()) - .algorithm(simpleJwtProperties.getAlgorithm()); - } else if (TokenAlgorithm.HMAC_ALGORITHMS.contains(simpleJwtProperties.getAlgorithm())) { - builder.secret(simpleJwtProperties.getSecret()) - .algorithm(simpleJwtProperties.getAlgorithm()); - } - - builder.issuer(simpleJwtProperties.getIssuer()); - builder.jtiCreator(jtiCreator); - builder.objectMapper(objectMapper); - - return builder.build(); - } - - private final IdentityGenerator jtiCreator; - - private final SimpleJwtProperties simpleJwtProperties; - - private final ObjectMapper objectMapper; - -} diff --git a/jwt-toolbox-spring-boot-starter/src/main/java/com/onixbyte/jwt/autoconfiguration/GuidAutoConfiguration.java b/jwt-toolbox-spring-boot-starter/src/main/java/com/onixbyte/jwt/autoconfiguration/GuidAutoConfiguration.java index 674e2dd..06ed062 100644 --- a/jwt-toolbox-spring-boot-starter/src/main/java/com/onixbyte/jwt/autoconfiguration/GuidAutoConfiguration.java +++ b/jwt-toolbox-spring-boot-starter/src/main/java/com/onixbyte/jwt/autoconfiguration/GuidAutoConfiguration.java @@ -1,18 +1,23 @@ /* - * Copyright (C) 2024-2025 OnixByte. + * 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 + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * http://www.apache.org/licenses/LICENSE-2.0 + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. * - * 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. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ package com.onixbyte.jwt.autoconfiguration; diff --git a/jwt-toolbox-spring-boot-starter/src/main/java/com/onixbyte/jwt/autoconfiguration/conditions/GuidCreatorCondition.java b/jwt-toolbox-spring-boot-starter/src/main/java/com/onixbyte/jwt/autoconfiguration/conditions/GuidCreatorCondition.java index 0b62b61..9662dac 100644 --- a/jwt-toolbox-spring-boot-starter/src/main/java/com/onixbyte/jwt/autoconfiguration/conditions/GuidCreatorCondition.java +++ b/jwt-toolbox-spring-boot-starter/src/main/java/com/onixbyte/jwt/autoconfiguration/conditions/GuidCreatorCondition.java @@ -1,18 +1,23 @@ /* - * Copyright (C) 2024-2025 OnixByte. + * 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 + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * http://www.apache.org/licenses/LICENSE-2.0 + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. * - * 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. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ package com.onixbyte.jwt.autoconfiguration.conditions; @@ -29,14 +34,12 @@ import java.util.Objects; /** * The conditions to create bean {@code jtiCreator}. * - * @author Zihlu Wang - * @version 1.1.0 + * @author zihluwang + * @version 3.0.0 * @since 1.0.0 */ public class GuidCreatorCondition implements Condition { - private final static Logger log = LoggerFactory.getLogger(GuidCreatorCondition.class); - /** * Default constructor. */ diff --git a/jwt-toolbox-spring-boot-starter/src/main/java/com/onixbyte/jwt/autoconfiguration/properties/SimpleJwtProperties.java b/jwt-toolbox-spring-boot-starter/src/main/java/com/onixbyte/jwt/autoconfiguration/properties/JwtProperties.java similarity index 67% rename from jwt-toolbox-spring-boot-starter/src/main/java/com/onixbyte/jwt/autoconfiguration/properties/SimpleJwtProperties.java rename to jwt-toolbox-spring-boot-starter/src/main/java/com/onixbyte/jwt/autoconfiguration/properties/JwtProperties.java index a855305..a10494c 100644 --- a/jwt-toolbox-spring-boot-starter/src/main/java/com/onixbyte/jwt/autoconfiguration/properties/SimpleJwtProperties.java +++ b/jwt-toolbox-spring-boot-starter/src/main/java/com/onixbyte/jwt/autoconfiguration/properties/JwtProperties.java @@ -1,39 +1,43 @@ /* - * Copyright (C) 2024-2025 OnixByte. + * 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 + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * http://www.apache.org/licenses/LICENSE-2.0 + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. * - * 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. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ package com.onixbyte.jwt.autoconfiguration.properties; import com.onixbyte.jwt.SecretCreator; -import com.onixbyte.jwt.autoconfiguration.AuthzeroTokenResolverAutoConfiguration; import com.onixbyte.jwt.constants.TokenAlgorithm; import org.springframework.boot.context.properties.ConfigurationProperties; /** - * {@code SimpleJwtProperties} is a configuration properties class used to store the properties + * {@code JwtProperties} is a configuration properties class used to store the properties * related to Simple JWT library configurations. These properties can be configured in the * application's properties file (e.g., application.properties) with the prefix * "onixbyte.simple-jwt". *

    - * {@code SimpleJwtProperties} provides configuration options for the JWT algorithm, issuer, - * and secret. The properties are used by the {@link AuthzeroTokenResolverAutoConfiguration} to + * {@code JwtProperties} provides configuration options for the JWT algorithm, issuer, + * and secret. The properties are used by the {@code Auth0AutoConfiguration} to * set up the necessary configurations for JWT generation and validation. *

    * Developers can customise the JWT algorithm, issuer, and secret by setting the corresponding - * properties in the application's properties file. The {@code SimpleJwtAutoConfiguration} class + * properties in the application's properties file. The {@code Auth0AutoConfiguration} class * reads these properties and uses them to create the TokenResolver bean with the * desired configuration. * @@ -41,13 +45,13 @@ import org.springframework.boot.context.properties.ConfigurationProperties; * @version 1.1.0 * @since 1.0.0 */ -@ConfigurationProperties(prefix = "onixbyte.simple-jwt") -public class SimpleJwtProperties { +// @ConfigurationProperties(prefix = "onixbyte.jwt") +public class JwtProperties { /** * Default constructor. */ - public SimpleJwtProperties() { + public JwtProperties() { } /** 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 index fbd0048..a164fa1 100644 --- 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 @@ -1,2 +1 @@ com.onixbyte.jwt.autoconfiguration.GuidAutoConfiguration -com.onixbyte.jwt.autoconfiguration.AuthzeroTokenResolverAutoConfiguration diff --git a/jwt-toolbox-spring-boot-starter/src/main/resources/logback.xml b/jwt-toolbox-spring-boot-starter/src/main/resources/logback.xml index fd31eac..288ac4a 100644 --- a/jwt-toolbox-spring-boot-starter/src/main/resources/logback.xml +++ b/jwt-toolbox-spring-boot-starter/src/main/resources/logback.xml @@ -1,26 +1,33 @@ - - + + - + ${COLOURFUL_OUTPUT} @@ -29,4 +36,4 @@ - \ No newline at end of file + diff --git a/math-toolbox/README.md b/math-toolbox/README.md index 7745ec1..72b11d8 100644 --- a/math-toolbox/README.md +++ b/math-toolbox/README.md @@ -1,3 +1,4 @@ -# Num4j +# Math Toolkit -`num4j` provides some mathematical algorithms and utilities such as chained high-precision mathematical calculator and percentile statistic algorithm. \ No newline at end of file +**Math Toolkit** provides some mathematical algorithms and utilities such as chained high-precision +mathematical calculator and percentile statistic algorithm. diff --git a/math-toolbox/build.gradle.kts b/math-toolbox/build.gradle.kts index 520d6dd..9226aa3 100644 --- a/math-toolbox/build.gradle.kts +++ b/math-toolbox/build.gradle.kts @@ -1,19 +1,25 @@ /* - * Copyright (C) 2024-2025 OnixByte. + * 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 + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * http://www.apache.org/licenses/LICENSE-2.0 + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. * - * 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. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ + import java.net.URI plugins { @@ -83,8 +89,8 @@ publishing { } scm { - connection = "scm:git:git://github.com:OnixByte/JDevKit.git" - developerConnection = "scm:git:git://github.com:OnixByte/JDevKit.git" + connection = "scm:git:git://github.com:onixbyte/onixbyte-toolbox.git" + developerConnection = "scm:git:git://github.com:onixbyte/onixbyte-toolbox.git" url = projectGithubUrl } diff --git a/math-toolbox/src/main/java/com/onixbyte/math/ChainedCalcUtil.java b/math-toolbox/src/main/java/com/onixbyte/math/ChainedCalcUtil.java index bce105a..51d31fd 100644 --- a/math-toolbox/src/main/java/com/onixbyte/math/ChainedCalcUtil.java +++ b/math-toolbox/src/main/java/com/onixbyte/math/ChainedCalcUtil.java @@ -1,25 +1,27 @@ /* - * Copyright (C) 2024-2025 OnixByte. + * 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 + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * http://www.apache.org/licenses/LICENSE-2.0 + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. * - * 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. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ package com.onixbyte.math; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.math.BigDecimal; import java.math.RoundingMode; import java.util.Objects; @@ -87,14 +89,12 @@ import java.util.function.Function; * and may have performance implications for extremely large numbers or complex calculations. * * @author sunzsh - * @version 1.1.0 + * @version 3.0.0 * @see BigDecimal * @since 1.0.0 */ public final class ChainedCalcUtil { - private final static Logger log = LoggerFactory.getLogger(ChainedCalcUtil.class); - /** * Creates a {@code ChainedCalcUtil} instance with the specified initial value. * diff --git a/math-toolbox/src/main/java/com/onixbyte/math/PercentileCalculator.java b/math-toolbox/src/main/java/com/onixbyte/math/PercentileCalculator.java index 3b3439e..50b624c 100644 --- a/math-toolbox/src/main/java/com/onixbyte/math/PercentileCalculator.java +++ b/math-toolbox/src/main/java/com/onixbyte/math/PercentileCalculator.java @@ -1,25 +1,28 @@ /* - * Copyright (C) 2024-2025 OnixByte. + * 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 + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * http://www.apache.org/licenses/LICENSE-2.0 + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. * - * 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. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ package com.onixbyte.math; import com.onixbyte.math.model.QuartileBounds; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.util.List; @@ -29,30 +32,30 @@ import java.util.List; *

    * This class contains static methods to: *

      - *
    • Calculate a specified percentile from a list of double values using linear interpolation.
    • - *
    • Calculate interquartile bounds (Q1, Q3) and the corresponding lower and upper bounds, - * which can be used to identify outliers in the dataset.
    • + *
    • + * Calculate a specified percentile from a list of double values using linear interpolation. + *
    • + *
    • + * Calculate interquartile bounds (Q1, Q3) and the corresponding lower and upper bounds, + * which can be used to identify outliers in the dataset. + *
    • *
    *

    * This class is final, meaning it cannot be subclassed, and it only contains static methods, * so instances of the class cannot be created. *

    Example usage:

    - *
    - * {@code
    + * 
    {@code
      * List data = Arrays.asList(1.0, 2.0, 3.0, 4.0, 5.0);
      * Double percentileValue = PercentileCalculator.calculatePercentile(data, 50.0);  // Calculates median
      * QuartileBounds bounds = PercentileCalculator.calculatePercentileBounds(data);   // Calculates IQR bounds
    - * }
    - * 
    + * }
    * * @author zihluwang - * @version 1.6.5 + * @version 3.0.0 * @since 1.6.5 */ public final class PercentileCalculator { - private final static Logger log = LoggerFactory.getLogger(PercentileCalculator.class); - /** * Private constructor to prevent instantiation of this utility class. */ @@ -100,18 +103,18 @@ public final class PercentileCalculator { */ public static QuartileBounds calculatePercentileBounds(List data) { var sorted = data.stream().sorted().toList(); - var Q1 = calculatePercentile(sorted, 25.); - var Q3 = calculatePercentile(sorted, 75.); + var q1 = calculatePercentile(sorted, 25.); + var q3 = calculatePercentile(sorted, 75.); - var IQR = Q3 - Q1; + var iqr = q3 - q1; - var lowerBound = Q1 - 1.5 * IQR; - var upperBound = Q3 + 1.5 * IQR; + var lowerBound = q1 - 1.5 * iqr; + var upperBound = q3 + 1.5 * iqr; return QuartileBounds.builder() - .upperBound(upperBound) - .lowerBound(lowerBound) - .build(); + .upperBound(upperBound) + .lowerBound(lowerBound) + .build(); } } diff --git a/math-toolbox/src/main/java/com/onixbyte/math/model/QuartileBounds.java b/math-toolbox/src/main/java/com/onixbyte/math/model/QuartileBounds.java index 60dafd0..44140be 100644 --- a/math-toolbox/src/main/java/com/onixbyte/math/model/QuartileBounds.java +++ b/math-toolbox/src/main/java/com/onixbyte/math/model/QuartileBounds.java @@ -1,18 +1,23 @@ /* - * Copyright (C) 2024-2025 OnixByte. + * 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 + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * http://www.apache.org/licenses/LICENSE-2.0 + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. * - * 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. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ package com.onixbyte.math.model; @@ -26,27 +31,31 @@ package com.onixbyte.math.model; *

    * Quartile bounds consist of: *

      - *
    • {@code lowerBound} - The lower bound of the dataset, typically {@code Q1 - 1.5 * IQR}.
    • - *
    • {@code upperBound} - The upper bound of the dataset, typically {@code Q3 + 1.5 * IQR}.
    • + *
    • + * {@code lowerBound} - The lower bound of the dataset, typically {@code Q1 - 1.5 * IQR}. + *
    • + *
    • + * {@code upperBound} - The upper bound of the dataset, typically {@code Q3 + 1.5 * IQR}. + *
    • *
    *

    * Example usage: - *

    + * 
    {@code
      * QuartileBounds bounds = QuartileBounds.builder()
    - *     .lowerBound(1.5)
    - *     .upperBound(7.5)
    - *     .build();
    - * 
    + * .lowerBound(1.5) + * .upperBound(7.5) + * .build(); + * }
    * * @param upperBound the upper bound of the dataset * @param lowerBound the lower bound of the dataset * @author zihluwang - * @version 1.6.5 + * @version 3.0.0 * @since 1.6.5 */ public record QuartileBounds( - Double upperBound, - Double lowerBound + Double upperBound, + Double lowerBound ) { /** diff --git a/math-toolbox/src/main/resources/logback.xml b/math-toolbox/src/main/resources/logback.xml index 1cf5a50..288ac4a 100644 --- a/math-toolbox/src/main/resources/logback.xml +++ b/math-toolbox/src/main/resources/logback.xml @@ -1,26 +1,33 @@ - - + + - + ${COLOURFUL_OUTPUT} @@ -29,4 +36,4 @@ - \ No newline at end of file + diff --git a/version-catalogue/README.md b/version-catalogue/README.md index 5cfbbb6..0a78861 100644 --- a/version-catalogue/README.md +++ b/version-catalogue/README.md @@ -1,17 +1,22 @@ -# DevKit BOM +# Version Catalogue -The devkit-bom (Bill of Materials) is a Maven POM file provided by OnixByte to manage dependency versions for the DevKit suite of libraries. By incorporating this BOM into your build configuration, you can ensure consistent versioning across all included dependencies without needing to specify versions explicitly in your project files. Published with Gradle metadata, this BOM supports both Maven and Gradle projects, and this document outlines how to integrate and use it effectively in both ecosystems. +The **Version Catalogue** (Bill of Materials) is a Maven POM file provided by OnixByte to manage +dependency versions for the **OnixByte Toolbox**. By incorporating this BOM into your build +configuration, you can ensure consistent versioning across all included dependencies without +needing to specify versions explicitly in your project files. Published with Gradle metadata, +this BOM supports both Maven and Gradle projects, and this document outlines how to integrate +and use it effectively in both ecosystems. ## Using in Maven -Add the `devkit-bom` to your `pom.xml` under ``: +Add the `version-catalogue` to your `pom.xml` under ``: ```xml com.onixbyte - devkit-bom + version-catalogue ${devkit-version} pom import @@ -20,7 +25,7 @@ Add the `devkit-bom` to your `pom.xml` under ``: ``` -Then reference dependencies like `devkit-core` without a version. +Then reference any dependency built by OnixByte without a version. ## Using in Gradle @@ -28,9 +33,8 @@ In your `build.gradle[.kts]`, apply the BOM using the `platform` dependency: ```groovy dependencies { - implementation platform('com.onixbyte:devkit-bom:2.0.0') - implementation 'com.onixbyte:devkit-core' - implementation 'com.onixbyte:devkit-utils' + implementation platform('com.onixbyte:version-catalogue:2.0.0') + implementation 'com.onixbyte:common-toolbox' } ``` @@ -38,9 +42,8 @@ If you are using Kotlin DSL: ```kotlin dependencies { - implementation(platform("com.onixbyte:devkit-bom:2.0.0")) - implementation("com.onixbyte:devkit-core") - implementation("com.onixbyte:devkit-utils") + implementation(platform("com.onixbyte:version-catalogue:2.0.0")) + implementation("com.onixbyte:common-toolbox") } ``` diff --git a/version-catalogue/build.gradle.kts b/version-catalogue/build.gradle.kts index 398eacf..d683310 100644 --- a/version-catalogue/build.gradle.kts +++ b/version-catalogue/build.gradle.kts @@ -1,19 +1,25 @@ /* - * Copyright (C) 2024-2025 OnixByte. + * 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 + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * http://www.apache.org/licenses/LICENSE-2.0 + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. * - * 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. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ + import java.net.URI plugins { From ee9808f471d984ec6b9dee8949698c40b2e8a728 Mon Sep 17 00:00:00 2001 From: zihluwang Date: Tue, 17 Jun 2025 23:14:28 +0800 Subject: [PATCH 4/9] docs: fix project name changing --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c89812e..5ed8874 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -57,5 +57,5 @@ test reports are prioritised for review and merging. ## License -By contributing to the Java Dev Kit, you agree that your contributions will be licensed under the +By contributing to the OnixByte Toolbox, you agree that your contributions will be licensed under the MIT license. If you do not agree to this, please refrain from contributing. From 7aaea4a306e6ec42a86af2e2a29f748327ed8a08 Mon Sep 17 00:00:00 2001 From: zihluwang Date: Wed, 18 Jun 2025 11:05:01 +0800 Subject: [PATCH 5/9] feat: delete jwt toolbox Due to differing JWT requirements across projects, after careful consideration, we have decided to remove this secondary encapsulation. --- jwt-toolbox-auth0/README.md | 56 ------ jwt-toolbox-auth0/build.gradle.kts | 138 -------------- .../jwt/auth0/Auth0TokenGenerator.java | 28 --- .../onixbyte/jwt/auth0/Auth0TokenParser.java | 46 ----- .../src/main/resources/logback.xml | 39 ---- jwt-toolbox-facade/README.md | 135 -------------- jwt-toolbox-facade/build.gradle.kts | 135 -------------- .../java/com/onixbyte/jwt/SecretCreator.java | 162 ---------------- .../java/com/onixbyte/jwt/TokenGenerator.java | 26 --- .../java/com/onixbyte/jwt/TokenParser.java | 26 --- .../jwt/constants/PredefinedKeys.java | 110 ----------- .../jwt/constants/TokenAlgorithm.java | 97 ---------- .../exceptions/IllegalKeyPairException.java | 58 ------ .../exceptions/IllegalSecretException.java | 59 ------ .../UnsupportedAlgorithmException.java | 106 ----------- .../jwt/exceptions/WeakSecretException.java | 107 ----------- .../src/main/resources/logback.xml | 39 ---- jwt-toolbox-spring-boot-starter/README.md | 108 ----------- .../build.gradle.kts | 148 --------------- .../GuidAutoConfiguration.java | 64 ------- .../conditions/GuidCreatorCondition.java | 69 ------- .../properties/JwtProperties.java | 174 ------------------ ...ot.autoconfigure.AutoConfiguration.imports | 1 - .../src/main/resources/logback.xml | 39 ---- settings.gradle.kts | 3 - 25 files changed, 1973 deletions(-) delete mode 100644 jwt-toolbox-auth0/README.md delete mode 100644 jwt-toolbox-auth0/build.gradle.kts delete mode 100644 jwt-toolbox-auth0/src/main/java/com/onixbyte/jwt/auth0/Auth0TokenGenerator.java delete mode 100644 jwt-toolbox-auth0/src/main/java/com/onixbyte/jwt/auth0/Auth0TokenParser.java delete mode 100644 jwt-toolbox-auth0/src/main/resources/logback.xml delete mode 100644 jwt-toolbox-facade/README.md delete mode 100644 jwt-toolbox-facade/build.gradle.kts delete mode 100644 jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/SecretCreator.java delete mode 100644 jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/TokenGenerator.java delete mode 100644 jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/TokenParser.java delete mode 100644 jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/constants/PredefinedKeys.java delete mode 100644 jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/constants/TokenAlgorithm.java delete mode 100644 jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/exceptions/IllegalKeyPairException.java delete mode 100644 jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/exceptions/IllegalSecretException.java delete mode 100644 jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/exceptions/UnsupportedAlgorithmException.java delete mode 100644 jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/exceptions/WeakSecretException.java delete mode 100644 jwt-toolbox-facade/src/main/resources/logback.xml delete mode 100644 jwt-toolbox-spring-boot-starter/README.md delete mode 100644 jwt-toolbox-spring-boot-starter/build.gradle.kts delete mode 100644 jwt-toolbox-spring-boot-starter/src/main/java/com/onixbyte/jwt/autoconfiguration/GuidAutoConfiguration.java delete mode 100644 jwt-toolbox-spring-boot-starter/src/main/java/com/onixbyte/jwt/autoconfiguration/conditions/GuidCreatorCondition.java delete mode 100644 jwt-toolbox-spring-boot-starter/src/main/java/com/onixbyte/jwt/autoconfiguration/properties/JwtProperties.java delete mode 100644 jwt-toolbox-spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports delete mode 100644 jwt-toolbox-spring-boot-starter/src/main/resources/logback.xml diff --git a/jwt-toolbox-auth0/README.md b/jwt-toolbox-auth0/README.md deleted file mode 100644 index d3fca65..0000000 --- a/jwt-toolbox-auth0/README.md +++ /dev/null @@ -1,56 +0,0 @@ -# JWT Toolbox :: Auth0 - -## Introduction - -**JWT Toolbox :: Auth0** module is an implementation of module JWT Toolbox, which uses third-party -library `com.auth0:java-jwt`. By using this module can help you use JWT to help you in -your application. - -### If you are using `Maven` - -It is quite simple to install this module by `Maven`. The only thing you need to do is find your -`pom.xml` file in the project, then find the `` node in the `` node, and add -the following codes to `` node: - -```xml - - - com.onixbyte - jwt-toolbox-auth0 - ${jwt-toolbox-auth0.version} - -``` - -And run `mvn dependency:get` in your project root folder(i.e., if your `pom.xml` is located at -`/path/to/your/project/pom.xml`, then your current work folder should be `/path/to/your/project`), -then `Maven` will automatically download the `jar` archive from `Maven Central Repository`. -This could be **MUCH EASIER** if you are using IDE(i.e., IntelliJ IDEA), the only thing you need to -do is click the refresh button of `Maven`. - -If you are restricted using the Internet, and have to make `Maven` offline, you could follow the -following steps. - -1. Download the `jar` file from any place you can get and transfer the `jar` files to your - work computer. -2. Move the `jar` files to your local `Maven` Repository as the path of - `/path/to/maven_local_repo/com/onixbyte/jwt-toolbox-auth0/`. - -### If you are using `Gradle` - -Add this module to your project with `Gradle` is much easier than doing so with `Maven`. - -Find `build.gradle` in the needed project, and add the following code to the `dependencies` closure -in the build script: - -```groovy -implementation 'com.onixbyte:jwt-toolbox-auth0:${jwt-toolbox-auth0.version}' -``` - -## Contact - -If you have any suggestions, ideas, don't hesitate contacting us via -[GitHub Issues](https://github.com/onixbyte/onixbyte-toolbox/issues/new). - -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/onixbyte/onixbyte-toolbox/compare). diff --git a/jwt-toolbox-auth0/build.gradle.kts b/jwt-toolbox-auth0/build.gradle.kts deleted file mode 100644 index 110eeb9..0000000 --- a/jwt-toolbox-auth0/build.gradle.kts +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright (c) 2024-2025 OnixByte - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -import java.net.URI - -plugins { - java - id("java-library") - id("maven-publish") - id("signing") -} - -val artefactVersion: String by project -val projectUrl: String by project -val projectGithubUrl: String by project -val licenseName: String by project -val licenseUrl: String by project - -group = "com.onixbyte" -version = artefactVersion - -repositories { - mavenCentral() -} - -java { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 - withSourcesJar() - withJavadocJar() -} - -tasks.withType { - options.encoding = "UTF-8" -} - -tasks.withType { - exclude("logback.xml") -} - -dependencies { - compileOnly(libs.slf4j) - implementation(libs.logback) - - 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) - - testImplementation(platform(libs.junit.bom)) - testImplementation(libs.junit.jupiter) -} - -tasks.test { - useJUnitPlatform() -} - -publishing { - publications { - create("jwtToolboxAuth0") { - groupId = group.toString() - artifactId = "jwt-toolbox-auth0" - version = artefactVersion - - pom { - name = "OnixByte JWT Toolbox :: Auth0" - description = "Simple JWT implemented with com.auth0:java-jwt." - url = projectUrl - - licenses { - license { - name = licenseName - url = licenseUrl - } - } - - scm { - connection = "scm:git:git://github.com:onixbyte/onixbyte-toolbox.git" - developerConnection = "scm:git:git://github.com:onixbyte/onixbyte-toolbox.git" - url = projectGithubUrl - } - - developers { - developer { - id = "zihluwang" - name = "Zihlu Wang" - email = "really@zihlu.wang" - timezone = "Asia/Hong_Kong" - } - - developer { - id = "siujamo" - name = "Siu Jam'o" - email = "jamo.siu@outlook.com" - timezone = "Asia/Shanghai" - } - } - } - - from(components["java"]) - - signing { - sign(publishing.publications["jwtToolboxAuth0"]) - } - } - - repositories { - maven { - name = "sonatypeNexus" - url = URI(providers.gradleProperty("repo.maven-central.host").get()) - credentials { - username = providers.gradleProperty("repo.maven-central.username").get() - password = providers.gradleProperty("repo.maven-central.password").get() - } - } - } - } -} diff --git a/jwt-toolbox-auth0/src/main/java/com/onixbyte/jwt/auth0/Auth0TokenGenerator.java b/jwt-toolbox-auth0/src/main/java/com/onixbyte/jwt/auth0/Auth0TokenGenerator.java deleted file mode 100644 index e5c82eb..0000000 --- a/jwt-toolbox-auth0/src/main/java/com/onixbyte/jwt/auth0/Auth0TokenGenerator.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2024-2025 OnixByte - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.onixbyte.jwt.auth0; - -import com.onixbyte.jwt.TokenGenerator; - -public class Auth0TokenGenerator implements TokenGenerator { -} diff --git a/jwt-toolbox-auth0/src/main/java/com/onixbyte/jwt/auth0/Auth0TokenParser.java b/jwt-toolbox-auth0/src/main/java/com/onixbyte/jwt/auth0/Auth0TokenParser.java deleted file mode 100644 index 7e30b50..0000000 --- a/jwt-toolbox-auth0/src/main/java/com/onixbyte/jwt/auth0/Auth0TokenParser.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2024-2025 OnixByte - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.onixbyte.jwt.auth0; - -import com.onixbyte.identitygenerator.IdentityGenerator; -import com.auth0.jwt.JWTCreator; -import com.auth0.jwt.algorithms.Algorithm; -import com.auth0.jwt.interfaces.JWTVerifier; -import com.onixbyte.jwt.TokenParser; - -/** - * - * - * @author zihluwang - * @version 3.0.0 - * @see IdentityGenerator - * @see Algorithm - * @see JWTVerifier - * @see JWTCreator - * @see JWTCreator.Builder - * @since 1.0.0 - */ -public class Auth0TokenParser implements TokenParser { - - -} diff --git a/jwt-toolbox-auth0/src/main/resources/logback.xml b/jwt-toolbox-auth0/src/main/resources/logback.xml deleted file mode 100644 index 288ac4a..0000000 --- a/jwt-toolbox-auth0/src/main/resources/logback.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - ${COLOURFUL_OUTPUT} - - - - - - diff --git a/jwt-toolbox-facade/README.md b/jwt-toolbox-facade/README.md deleted file mode 100644 index 03efa39..0000000 --- a/jwt-toolbox-facade/README.md +++ /dev/null @@ -1,135 +0,0 @@ -# JWT Toolbox :: Facade - -## Introduction - -The JWT Toolbox Facade module is a lightweight and easy-to-use façade for working with JSON Web -Tokens (JWT) in Java applications. It provides a simplified interface and utilities to handle the -creation, validation, renewal, and processing of JWTs without the need for complex configurations or -third-party dependencies. - -## Installation - -### If you are using `Maven` - -It is quite simple to install this module by `Maven`. The only thing you need to do is find your `pom.xml` file in the project, then find the `` node in the `` node, and add the following codes to `` node: - -```xml - - com.onixbyte - jwt-toolkit-facade - ${jwt-toolkit-facade.version} - -``` - -And run `mvn dependency:get` in your project root folder(i.e., if your `pom.xml` is located at -`/path/to/your/project/pom.xml`, then your current work folder should be `/path/to/your/project`), -then `Maven` will automatically download the `jar` archive from `Maven Central Repository`. - -This could be **MUCH EASIER** if you are using IDE(i.e., IntelliJ IDEA), the only thing you need to -do is click the refresh button of `Maven`. - -If you are restricted using the Internet, and have to make `Maven` offline, you could follow the -following steps. - -1. Download the `jar` file from any place you can get and transfer the `jar` files to your - work computer. -2. Move the `jar` files to your local `Maven` Repository as the path of - `/path/to/maven_local_repo/com/onixbyte/jwt-toolbox-facade/`. - -### If you are using `Gradle` - -Add this module to your project with `Gradle` is much easier than doing so with `Maven`. - -Find `build.gradle` in the needed project, and add the following code to the `dependencies` closure -in the build script: - -```groovy -implementation 'com.onixbyte:jwt-toolbox-facade:${jwt-toolbox-facade.version}' -``` - -### If you are not using `Maven` or `Gradle` - -1. Download the `jar` file from the Internet. -2. Create a folder in your project and name it as a name you like(i.e., for me, I prefer `vendor`). -3. Put the `jar` file to the folder you just created in Step 2. -4. Add this folder to your project `classpath`. - -## Implement a `TokenResolver` - -If you want to use `TokenResolver` to handle with JWTs, you can choose to use any implementation such as `cn.org.codecrafters:simple-jwt-authzero` or any other `simple-jwt-$implementation_artifact`. But if you do choose to use other implementation, it is not the topic we are going to talk about here. We are here for helping you to implement one by yourself. - -First, you are going to choose a third-party library or your own library which is aims to process JWTs(i.e., `com.auth0:java-jwt` and `io.jsonwebtoken:jjwt`). Then, you need to confirm which class they are going to use for a parsed JWT(i.e., `DecodedJWT` is being used in `com.auth0:java-jwt`). And let me use `com.auth0:java-jwt` for example in this tutor. - -Then, you can add these following codes in your project: - -```java -class Auth0TokenResolver implements TokenResolver { - // Dont forget to implement methods in interface TokenResolver. -} -``` - -After doing all these, an implemented `TokenResolver` is ready to process JWTs. - -**Let's pretend that you already implemented a `TokenResolver` and named as `ImplementedTokenResolver`.** - -You will need an instance of the implementation to process JWTs. - -```java -var tokenResolver = new ImplementedTokenResolver(/* arguments you declared */); -``` - -## Create a JSON Web Token with `TokenResolver` - -Then, there are 3 method to create a token: - -```java -String createToken(java.time.Duration expireAfter, String audience, String subject); - -String createToken(java.time.Duration expireAfter, String audience, String subject, Map payloads); - - String createToken(java.time.Duration expireAfter, String audience, String subject, T payload); -``` - -## Read or Verify a JSON Web Token - -There are many ways to read a JWT. - -If you want to read as the data class which is designed by the third-party library, you can just use `resolve(String token)`. If you want know what is contained in this JWT, you can use `extract(String, Class)`. - -Meanwhile, the `resolve(token)` method also serves as a token validation mechanism. If any issues arise, such as token expiration, tampering suspicion, or mismatched token signatures, corresponding exceptions will be thrown. - -## Renew a Token that is About to Expire - -When a token is about to expire, its validity period can be extended using this method, allowing users to obtain a new valid token without the need for re-login. - -**Renew a token** means that the content of the pre-defined properties by JWT, such as the audience (aud) representing the recipient of this token, will not be altered, except for the time-related fields. - -```java -String renew(String oldToken, Map payload); -``` - -This method allows you to pass new custom payload into the updated token. The new token will be available for 30 minutes. - -```java -String renew(String oldToken, Duration expireAfter, Map payload); -``` - -This method allows you to pass new custom payload into the updated token. The new token will be available for the specific duration. - -```java - String renew(String oldToken, Duration expireAfter, T payload); -``` - -This method allows you to pass new custom payload into the updated token. The new token will be available for 30 minutes. - -```java - String renew(String oldToken, Duration expireAfter, T payload); -``` - -This method allows you to pass new custom payload into the updated token. The new token will be available for the specific duration. - -## Contact - -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). diff --git a/jwt-toolbox-facade/build.gradle.kts b/jwt-toolbox-facade/build.gradle.kts deleted file mode 100644 index 998449e..0000000 --- a/jwt-toolbox-facade/build.gradle.kts +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright (c) 2024-2025 OnixByte - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -import java.net.URI - -plugins { - java - id("java-library") - id("maven-publish") - id("signing") -} - -val artefactVersion: String by project -val projectUrl: String by project -val projectGithubUrl: String by project -val licenseName: String by project -val licenseUrl: String by project - -group = "com.onixbyte" -version = artefactVersion - -repositories { - mavenCentral() -} - -java { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 - withSourcesJar() - withJavadocJar() -} - -tasks.withType { - options.encoding = "UTF-8" -} - -tasks.withType { - exclude("logback.xml") -} - -dependencies { - compileOnly(libs.slf4j) - implementation(libs.logback) - - api(project(":common-toolbox")) - api(project(":identity-generator")) - - testImplementation(platform(libs.junit.bom)) - testImplementation(libs.junit.jupiter) -} - -tasks.test { - useJUnitPlatform() -} - -publishing { - publications { - create("jwtToolboxFacade") { - groupId = group.toString() - artifactId = "jwt-toolbox-facade" - version = artefactVersion - - pom { - name = "OnixByte JWT Toolbox :: Facade" - description = "Declaration of simple JWT module." - url = projectUrl - - licenses { - license { - name = licenseName - url = licenseUrl - } - } - - scm { - connection = "scm:git:git://github.com:onixbyte/onixbyte-toolbox.git" - developerConnection = "scm:git:git://github.com:onixbyte/onixbyte-toolbox.git" - url = projectGithubUrl - } - - developers { - developer { - id = "zihluwang" - name = "Zihlu Wang" - email = "really@zihlu.wang" - timezone = "Asia/Hong_Kong" - } - - developer { - id = "siujamo" - name = "Siu Jam'o" - email = "jamo.siu@outlook.com" - timezone = "Asia/Shanghai" - } - } - } - - from(components["java"]) - - signing { - sign(publishing.publications["jwtToolboxFacade"]) - } - } - - repositories { - maven { - name = "sonatypeNexus" - url = URI(providers.gradleProperty("repo.maven-central.host").get()) - credentials { - username = providers.gradleProperty("repo.maven-central.username").get() - password = providers.gradleProperty("repo.maven-central.password").get() - } - } - } - } -} diff --git a/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/SecretCreator.java b/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/SecretCreator.java deleted file mode 100644 index a3412e4..0000000 --- a/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/SecretCreator.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Copyright (c) 2024-2025 OnixByte - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.onixbyte.jwt; - -import com.onixbyte.jwt.exceptions.WeakSecretException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.Random; - -/** - * {@code SecretCreator} is a utility class that provides methods to generate secure secret strings. - * The generated secrets can be used as cryptographic keys or passwords for various - * security-sensitive purposes. - * - * @author zihluwang - * @version 3.0.0 - * @since 1.0.0 - */ -public final class SecretCreator { - - /** - * Generates a secure secret with the specified length and character sets. - * - * @param length the length of the secret to be generated - * @param isContainCapital flag indicating if the secret should contain - * uppercase letters - * @param isContainDigital flag indicating if the secret should contain - * digits - * @param isContainSpecialSign flag indicating if the secret should contain - * special sign characters - * @return the generated secure secret - * @throws WeakSecretException if the requested secret length is less than - * 32 characters - */ - public static String createSecret(int length, - boolean isContainCapital, - boolean isContainDigital, - boolean isContainSpecialSign) { - if (length < 32) { - throw new WeakSecretException(""" - The requested secret, which is only %d characters long, is too weak. \ - Please replace it with a stronger secret.""".formatted(length)); - } - - final var randomiser = new Random(); - var charset = new StringBuilder(LOWERCASE_CHARACTERS); - - if (isContainCapital) charset.append(UPPERCASE_CHARACTERS); - if (isContainDigital) charset.append(DIGITS); - if (isContainSpecialSign) charset.append(SPECIAL_SIGNS); - - var secretBuilder = new StringBuilder(); - var charsetSize = charset.length(); - for (var i = 0; i < length; ++i) { - secretBuilder.append(charset.charAt(randomiser.nextInt(charsetSize))); - } - - return secretBuilder.toString(); - } - - /** - * Generates a secure secret with the specified length, containing - * uppercase letters and digits. - * - * @param length the length of the secret to be generated - * @param isContainCapital flag indicating if the secret should contain - * uppercase letters - * @param isContainDigital flag indicating if the secret should contain - * digits - * @return the generated secure secret - * @throws WeakSecretException if the requested secret length is less than - * 32 characters - * @see #createSecret(int, boolean, boolean, boolean) - */ - public static String createSecret(int length, - boolean isContainCapital, - boolean isContainDigital) { - return createSecret(length, isContainCapital, isContainDigital, false); - } - - /** - * Generates a secure secret with the specified length, containing - * uppercase letters. - * - * @param length the length of the secret to be generated - * @param isContainCapital flag indicating if the secret should contain - * uppercase letters - * @return the generated secure secret - * @throws WeakSecretException if the requested secret length is less than - * 32 characters - * @see #createSecret(int, boolean, boolean, boolean) - */ - public static String createSecret(int length, - boolean isContainCapital) { - return createSecret(length, isContainCapital, false, false); - } - - /** - * Generates a secure secret with the specified length, containing - * lowercase letters. - * - * @param length the length of the secret to be generated - * @return the generated secure secret - * @throws WeakSecretException if the requested secret length is less than - * 32 characters - * @see #createSecret(int, boolean, boolean, boolean) - */ - public static String createSecret(int length) { - return createSecret(length, false, false, false); - } - - /** - * Private constructor to prevent instantiation of this utility class. - */ - private SecretCreator() { - } - - /** - * The string containing all lowercase characters that can be used to - * generate the secret. - */ - private static final String LOWERCASE_CHARACTERS = "abcdefghijklmnopqrstuvwxyz"; - - /** - * The string containing all uppercase characters that can be used to - * generate the secret. - */ - private static final String UPPERCASE_CHARACTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - - /** - * The string containing all digit characters that can be used to generate - * the secret. - */ - private static final String DIGITS = "0123456789"; - - /** - * The string containing all special sign characters that can be used to - * generate the secret. - */ - private static final String SPECIAL_SIGNS = "!@#$%^&,*()_+-=,[]{}|;:,'\",.<>/?"; -} diff --git a/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/TokenGenerator.java b/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/TokenGenerator.java deleted file mode 100644 index e41cd9c..0000000 --- a/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/TokenGenerator.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2024-2025 OnixByte - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.onixbyte.jwt; - -public interface TokenGenerator { -} diff --git a/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/TokenParser.java b/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/TokenParser.java deleted file mode 100644 index 8d08464..0000000 --- a/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/TokenParser.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2024-2025 OnixByte - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.onixbyte.jwt; - -public interface TokenParser { -} diff --git a/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/constants/PredefinedKeys.java b/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/constants/PredefinedKeys.java deleted file mode 100644 index d8f4a12..0000000 --- a/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/constants/PredefinedKeys.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (c) 2024-2025 OnixByte - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.onixbyte.jwt.constants; - -import java.util.List; - -/** - * The {@code PredefinedKeys} class contains constants for standard JSON Web Token (JWT) claims. These constants - * represent the names of the standard claims that can be included in a JWT payload. Developers can use these constants - * when working with JWTs to ensure consistent naming of the claims. - *

    - * The class provides the following standard JWT claim constants: - *

      - *
    • {@link #ISSUER}: Represents the "iss" (Issuer) claim.
    • - *
    • {@link #SUBJECT}: Represents the "sub" (Subject) claim.
    • - *
    • {@link #AUDIENCE}: Represents the "aud" (Audience) claim.
    • - *
    • {@link #EXPIRATION_TIME}: Represents the "exp" (Expiration Time) claim.
    • - *
    • {@link #NOT_BEFORE}: Represents the "nbf" (Not Before) claim.
    • - *
    • {@link #ISSUED_AT}: Represents the "iat" (Issued At) claim.
    • - *
    • {@link #JWT_ID}: Represents the "jti" (JWT ID) claim.
    • - *
    - *

    - * The class also contains a list of all the standard claim constants, accessible via the {@link - * #KEYS} field. This list can be useful for iterating through all the standard claims or checking - * for the presence of specific claims. - *

    - * Note: This class is final and cannot be instantiated. It only serves as a utility class to hold - * the standard JWT claim constants. - * - * @author zihluwang - * @version 3.0.0 - * @since 1.0.0 - */ -public final class PredefinedKeys { - - /** - * Constant representing the "iss" (Issuer) claim in a JWT payload. - */ - public static final String ISSUER = "iss"; - - /** - * Constant representing the "sub" (Subject) claim in a JWT payload. - */ - public static final String SUBJECT = "sub"; - - /** - * Constant representing the "aud" (Audience) claim in a JWT payload. - */ - public static final String AUDIENCE = "aud"; - - /** - * Constant representing the "exp" (Expiration Time) claim in a JWT payload. - */ - public static final String EXPIRATION_TIME = "exp"; - - /** - * Constant representing the "nbf" (Not Before) claim in a JWT payload. - */ - public static final String NOT_BEFORE = "nbf"; - - /** - * Constant representing the "iat" (Issued At) claim in a JWT payload. - */ - public static final String ISSUED_AT = "iat"; - - /** - * Constant representing the "jti" (JWT ID) claim in a JWT payload. - */ - public static final String JWT_ID = "jti"; - - /** - * List containing all the standard JWT claim constants. - */ - public static final List KEYS = List.of( - ISSUER, - SUBJECT, - AUDIENCE, - EXPIRATION_TIME, - NOT_BEFORE, - ISSUED_AT, - JWT_ID - ); - - /** - * Private constructor to prevent instantiation of this utility class. - */ - private PredefinedKeys() { - } -} - diff --git a/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/constants/TokenAlgorithm.java b/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/constants/TokenAlgorithm.java deleted file mode 100644 index 1abde7a..0000000 --- a/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/constants/TokenAlgorithm.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2024-2025 OnixByte - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.onixbyte.jwt.constants; - -/** - * The {@code TokenAlgorithm} enum class defines the algorithms that can be - * used for signing and verifying JSON Web Tokens (JWT). JWT allows various - * cryptographic algorithms to be used for secure token generation and - * validation. This enum provides a list of supported algorithms to ensure - * consistent usage and avoid potential security issues. - *

    - * Supported Algorithms: - *

      - *
    • {@link TokenAlgorithm#HS256}: HMAC SHA-256
    • - *
    • {@link TokenAlgorithm#HS384}: HMAC SHA-384
    • - *
    • {@link TokenAlgorithm#HS512}: HMAC SHA-512
    • - *
    • {@link TokenAlgorithm#RS256}: RSA PKCS#1 v1.5 with SHA-256
    • - *
    • {@link TokenAlgorithm#RS384}: RSA PKCS#1 v1.5 with SHA-384
    • - *
    • {@link TokenAlgorithm#RS512}: RSA PKCS#1 v1.5 with SHA-512
    • - *
    • {@link TokenAlgorithm#ES256}: ECDSA with SHA-256
    • - *
    • {@link TokenAlgorithm#ES384}: ECDSA with SHA-384
    • - *
    • {@link TokenAlgorithm#ES512}: ECDSA with SHA-512
    • - *
    - * - * @author zihluwang - * @version 3.0.0 - * @since 1.0.0 - */ -public enum TokenAlgorithm { - - /** - * HMAC using SHA-256 - */ - HS256, - - /** - * HMAC using SHA-384 - */ - HS384, - - /** - * HMAC using SHA-512 - */ - HS512, - - /** - * RSASSA-PKCS-v1_5 using SHA-256 - */ - RS256, - - /** - * RSASSA-PKCS-v1_5 using SHA-384 - */ - RS384, - - /** - * RSASSA-PKCS-v1_5 using SHA-512 - */ - RS512, - - /** - * ECDSA using P-256 and SHA-256 - */ - ES256, - - /** - * ECDSA using P-384 and SHA-384 - */ - ES384, - - /** - * ECDSA using P-521 and SHA-512 - */ - ES512, - ; - -} diff --git a/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/exceptions/IllegalKeyPairException.java b/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/exceptions/IllegalKeyPairException.java deleted file mode 100644 index 2a70198..0000000 --- a/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/exceptions/IllegalKeyPairException.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2024-2025 OnixByte - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.onixbyte.jwt.exceptions; - -/** - * {@link IllegalKeyPairException} indicates an exception that the key pair is invalid. - * - * @author zihluwang - * @version 3.0.0 - */ -public class IllegalKeyPairException extends RuntimeException { - - /** - * Create a default exception instance. - */ - public IllegalKeyPairException() { - } - - /** - * Create an exception instance with specific message. - * - * @param message the message of the exception - */ - public IllegalKeyPairException(String message) { - super(message); - } - - /** - * Create an exception instance with specific message and cause. - * - * @param message the message of the exception - * @param cause the cause of the exception - */ - public IllegalKeyPairException(String message, Throwable cause) { - super(message, cause); - } - -} diff --git a/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/exceptions/IllegalSecretException.java b/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/exceptions/IllegalSecretException.java deleted file mode 100644 index c039e61..0000000 --- a/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/exceptions/IllegalSecretException.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2024-2025 OnixByte - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.onixbyte.jwt.exceptions; - -/** - * {@code IllegalKeyPairException} indicates the secret to sign a JWT is illegal. - * - * @author zihluwang - * @version 1.6.0 - * @since 1.6.0 - */ -public class IllegalSecretException extends RuntimeException { - - /** - * Create a default exception instance. - */ - public IllegalSecretException() { - } - - /** - * Create an exception instance with specific message. - * - * @param message the message of the exception - */ - public IllegalSecretException(String message) { - super(message); - } - - /** - * Create an exception instance with specific message and the cause of this exception. - * - * @param message the message of the exception - * @param cause the cause of the exception - */ - public IllegalSecretException(String message, Throwable cause) { - super(message, cause); - } - -} diff --git a/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/exceptions/UnsupportedAlgorithmException.java b/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/exceptions/UnsupportedAlgorithmException.java deleted file mode 100644 index 10609f8..0000000 --- a/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/exceptions/UnsupportedAlgorithmException.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 2024-2025 OnixByte - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.onixbyte.jwt.exceptions; - -/** - *

    - * If you want the supports to an unsupported algorithm, you could - *

      - *
    • Commit an issue at GitHub Issues or;
    • - *
    • Communicate with us on Discord Community.
    • - *
    - * - * @author zihluwang - * @version 3.0.0 - */ -public class UnsupportedAlgorithmException extends RuntimeException { - - /** - * Constructs a new {@code UnsupportedAlgorithmException} with {@code null} as its - * detail message. The cause is not initialized, and may subsequently be initialized by a call - * to {@link #initCause}. - */ - public UnsupportedAlgorithmException() { - } - - /** - * Constructs a new {@code UnsupportedAlgorithmException} with the specified detail message. - * The cause is not initialized, and may subsequently be initialized by a call - * to {@link #initCause}. - * - * @param message the detail message. The detail message is saved for later retrieval by the {@link #getMessage()} method. - */ - public UnsupportedAlgorithmException(String message) { - super(message); - } - - /** - * Constructs a new {@code UnsupportedAlgorithmException} with the specified detail message - * and cause. - * - * @param message the detail message (which is saved for later retrieval by the - * {@link #getMessage()} method) - * @param cause the cause (which is saved for later retrieval by the - * {@link #getCause()} method). (A {@code null} value is permitted, and - * indicates that the cause is nonexistent or unknown.) - * @since 1.4 - */ - public UnsupportedAlgorithmException(String message, Throwable cause) { - super(message, cause); - } - - /** - * Constructs a new {@code UnsupportedAlgorithmException} with the specified cause and a detail - * message of {@code (cause==null ? null : cause.toString())} (which typically contains the - * class and detail message of {@code cause}). This constructor is useful for runtime - * exceptions that are little more than wrappers for other throwable. - * - * @param cause the cause (which is saved for later retrieval by the - * {@link #getCause()} method). (A {@code null} value is permitted, and indicates - * that the cause is nonexistent or unknown.) - * @since 1.4 - */ - public UnsupportedAlgorithmException(Throwable cause) { - super(cause); - } - - /** - * Constructs a new {@code UnsupportedAlgorithmException} with the specified detail message, - * cause, suppression enabled or disabled, and writable stack trace enabled or disabled. - * - * @param message the detail message. - * @param cause the cause (A {@code null} value is permitted, and indicates that - * the cause is nonexistent or unknown.) - * @param enableSuppression whether suppression is enabled or disabled - * @param writableStackTrace whether the stack trace should be writable - * @since 1.0.0 - */ - public UnsupportedAlgorithmException( - String message, - Throwable cause, - boolean enableSuppression, - boolean writableStackTrace - ) { - super(message, cause, enableSuppression, writableStackTrace); - } -} diff --git a/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/exceptions/WeakSecretException.java b/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/exceptions/WeakSecretException.java deleted file mode 100644 index 1ee17e1..0000000 --- a/jwt-toolbox-facade/src/main/java/com/onixbyte/jwt/exceptions/WeakSecretException.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (c) 2024-2025 OnixByte - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.onixbyte.jwt.exceptions; - -/** - * {@code WeakSecretException} represents that your secret is too weak to be used in signing JWTs. - *

    - * {@code WeakSecretException} will only appears that if you are using the implementation module - * {@code com.onixbyte:jwt-toolbox-auth0} due to it is implemented by {@code com.auth0:java-jwt}. - * - * @author zihluwang - * @version 3.0.0 - * @since 1.0.0 - */ -public class WeakSecretException extends RuntimeException { - - /** - * Constructs a new {@code WeakSecretException} with {@code null} as its detail message. - * The cause is not initialized, and may subsequently be initialized by a call - * to {@link #initCause}. - */ - public WeakSecretException() { - } - - /** - * Constructs a new {@code WeakSecretException} with the specified detail message. The cause is - * not initialised, and may subsequently be initialized by a call to {@link #initCause}. - * - * @param message the detail message. The detail message is saved for later retrieval by the - * {@link #getMessage()} method. - */ - public WeakSecretException(String message) { - super(message); - } - - /** - * Constructs a new {@code WeakSecretException} with the specified detail message and cause. - *

    - * Note that the detail message associated with {@code cause} is not automatically - * incorporated in this runtime exception's detail message. - * - * @param message the detail message (which is saved for later retrieval by the - * {@link #getMessage()} method). - * @param cause the cause (which is saved for later retrieval by the - * {@link #getCause()} method). (A {@code null} value is permitted, and - * indicates that the cause is nonexistent or unknown.) - * @since 1.0.0 - */ - public WeakSecretException(String message, Throwable cause) { - super(message, cause); - } - - /** - * Constructs a new {@code WeakSecretException} with the specified cause and a detail message - * of {@code (cause==null ? null : cause.toString())} (which typically contains the class and - * detail message of {@code cause}). This constructor is useful for runtime exceptions that are - * little more than wrappers for other throwable. - * - * @param cause the cause (which is saved for later retrieval by the - * {@link #getCause()} method). (A {@code null} value is permitted, and indicates - * that the cause is nonexistent or unknown.) - * @since 1.0.0 - */ - public WeakSecretException(Throwable cause) { - super(cause); - } - - /** - * Constructs a new {@code WeakSecretException} with the specified detail message, cause, - * suppression enabled or disabled, and writable stack trace enabled or disabled. - * - * @param message the detail message. - * @param cause the cause. (A {@code null} value is permitted, and indicates that - * the cause is nonexistent or unknown.) - * @param enableSuppression whether suppression is enabled or disabled - * @param writableStackTrace whether the stack trace should be writable - * @since 1.0.0 - */ - public WeakSecretException( - String message, - Throwable cause, - boolean enableSuppression, - boolean writableStackTrace - ) { - super(message, cause, enableSuppression, writableStackTrace); - } -} diff --git a/jwt-toolbox-facade/src/main/resources/logback.xml b/jwt-toolbox-facade/src/main/resources/logback.xml deleted file mode 100644 index 288ac4a..0000000 --- a/jwt-toolbox-facade/src/main/resources/logback.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - ${COLOURFUL_OUTPUT} - - - - - - diff --git a/jwt-toolbox-spring-boot-starter/README.md b/jwt-toolbox-spring-boot-starter/README.md deleted file mode 100644 index 3c53e36..0000000 --- a/jwt-toolbox-spring-boot-starter/README.md +++ /dev/null @@ -1,108 +0,0 @@ -# JWT Toolbox :: Spring Boot Starter - -## Introduction - -Module **JWT Toolbox :: Spring Boot Starter** is a lightweight and easy-to-use Spring Boot starter -module that provides seamless integration with JSON Web Token (JWT) authentication in Spring Boot -applications. With this starter, developers can easily configure and enable JWT-based authentication -for their APIs and web applications without the need for complex manual setup. It simplifies the -process of generating and validating JWTs, making it effortless to secure endpoints and implement -token-based authentication in Spring Boot projects. The module is designed to be flexible, allowing -developers to customize various aspects of JWT authentication to suit their specific requirements. -Overall, `jwt-toolbox-spring-boot-starter` is a convenient solution for adding secure and efficient JWT authentication to Spring Boot applications. - -## Prerequisites - -- This whole `JDevKit` is developed by **JDK 17**, which means you have to use JDK 17 for better experience. -- You also need an implementation of any `simple-jwt-$implementation` module to make sure you can create an instance of `TokenResolver`. - -### Known Implementation - -> If you implemented one on your own, please contact us to add your artifact to this list. - -- [`cn.org.codecrafters:simple-jwt-authzero`](../simple-jwt-authzero/README.md) -- [`cn.org.codecrafters:simple-jwt-jjwt`](../simple-jwt-jjwt/README.md) - -## Installation - -### If you are using `Maven` - -It is quite simple to install this module by `Maven`. The only thing you need to do is find your `pom.xml` file in the project, then find the `` node in the `` node, and add the following codes to `` node: - -```xml - - ${implementation-builder-group-id} - simple-jwt-${any-implementation} - ${simple-jwt-${any-implementation}.version} - - - com.onixbyte - simple-jwt-spring-boot-starter - ${simple-jwt-spring-boot-starter.version} - -``` - -And run `mvn dependency:get` in your project root folder(i.e., if your `pom.xml` is located at `/path/to/your/project/pom.xml`, then your current work folder should be `/path/to/your/project`), then `Maven` will automatically download the `jar` archive from `Maven Central Repository`. This could be **MUCH EASIER** if you are using IDE(i.e., IntelliJ IDEA), the only thing you need to do is click the refresh button of `Maven`. - -If you are restricted using the Internet, and have to make `Maven` offline, you could follow the following steps. - -1. Download the `jar` file from any place you can get and transfer the `jar` files to your work computer. -2. Move the `jar` files to your local `Maven` Repository as the path of `/path/to/maven_local_repo/cn/org/codecrafters/simple-jwt-spring-boot-starter/` and `/path/to/maven_local_repo/${implementation-builder-group-seperated-by-system-seperator}/${implementation_artifact_id}`. - -### If you are using `Gradle` - -Add this module to your project with `Gradle` is much easier than doing so with `Maven`. - -Find `build.gradle` in the needed project, and add the following code to the `dependencies` closure in the build script: - -```groovy -implementation '${implementation-builder-group-id}:simple-jwt-${any-implementation}:${simple-jwt-${any-implementation}.version}' -implementation 'com.onixbyte:simple-jwt-spring-boot-starter:${simple-jwt-spring-boot-starter.version}' -``` - -### If you are not using `Maven` or `Gradle` - -1. Download the `jar` file from the Internet. -2. Create a folder in your project and name it as a name you like(i.e., for me, I prefer `vendor`). -3. Put the `jar` file to the folder you just created in Step 2. -4. Add this folder to your project `classpath`. - -## Configuration - -### Configuration for a customized JWT ID Creator - -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.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`. - -Here is a simple example which uses class `Random` to create guid. - -```java -@Bean -public GuidCreator jtiCreator() { - return new GuidCreator() { - private final Random random = new Random(); - - @Override - public Long nextId() { - return random.nextLong(); - } - }; -} -``` - -### `TokenResolver` Configuration - -| Property Name | Type | Description | -| ------------------------------------ | ---------------- | ------------------------------------------------------ | -| `code-crafters.simple-jwt.algorithm` | `TokenAlgorithm` | The algorithm used for JWT generation and validation. | -| `code-crafters.simple-jwt.issuer` | `String` | The issuer value to be included in the generated JWT. | -| `code-crafters.simple-jwt.secret` | `String` | The secret key used for JWT generation and validation. | - -## Contact - -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). diff --git a/jwt-toolbox-spring-boot-starter/build.gradle.kts b/jwt-toolbox-spring-boot-starter/build.gradle.kts deleted file mode 100644 index c102025..0000000 --- a/jwt-toolbox-spring-boot-starter/build.gradle.kts +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (c) 2024-2025 OnixByte - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -import java.net.URI - -plugins { - java - id("java-library") - id("maven-publish") - id("signing") -} - -val artefactVersion: String by project -val projectUrl: String by project -val projectGithubUrl: String by project -val licenseName: String by project -val licenseUrl: String by project - -group = "com.onixbyte" -version = artefactVersion - -repositories { - mavenCentral() -} - -java { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 - withSourcesJar() - withJavadocJar() -} - -tasks.withType { - options.encoding = "UTF-8" -} - -tasks.withType { - exclude("logback.xml") -} - -dependencies { - compileOnly(libs.slf4j) - implementation(libs.logback) - - 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) - annotationProcessor(libs.springBoot.configurationProcessor) - - testImplementation(platform(libs.junit.bom)) - testImplementation(libs.junit.jupiter) - testImplementation(libs.springBoot.starter.test) -} - -java { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 - withSourcesJar() - withJavadocJar() -} - -tasks.test { - useJUnitPlatform() -} - -publishing { - publications { - create("jwtSpringBootStarter") { - groupId = group.toString() - artifactId = "jwt-spring-boot-starter" - version = artefactVersion - - pom { - name = "OnixByte JWT Toolbox :: Spring Boot Starter" - description = "Simple JWT all-in-one package for Spring Boot." - url = projectUrl - - licenses { - license { - name = licenseName - url = licenseUrl - } - } - - scm { - connection = "scm:git:git://github.com:onixbyte/onixbyte-toolbox.git" - developerConnection = "scm:git:git://github.com:onixbyte/onixbyte-toolbox.git" - url = projectGithubUrl - } - - developers { - developer { - id = "zihluwang" - name = "Zihlu Wang" - email = "really@zihlu.wang" - timezone = "Asia/Hong_Kong" - } - - developer { - id = "siujamo" - name = "Siu Jam'o" - email = "jamo.siu@outlook.com" - timezone = "Asia/Shanghai" - } - } - } - - from(components["java"]) - - signing { - sign(publishing.publications["jwtSpringBootStarter"]) - } - } - - repositories { - maven { - name = "sonatypeNexus" - url = URI(providers.gradleProperty("repo.maven-central.host").get()) - credentials { - username = providers.gradleProperty("repo.maven-central.username").get() - password = providers.gradleProperty("repo.maven-central.password").get() - } - } - } - } -} diff --git a/jwt-toolbox-spring-boot-starter/src/main/java/com/onixbyte/jwt/autoconfiguration/GuidAutoConfiguration.java b/jwt-toolbox-spring-boot-starter/src/main/java/com/onixbyte/jwt/autoconfiguration/GuidAutoConfiguration.java deleted file mode 100644 index 06ed062..0000000 --- a/jwt-toolbox-spring-boot-starter/src/main/java/com/onixbyte/jwt/autoconfiguration/GuidAutoConfiguration.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2024-2025 OnixByte - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.onixbyte.jwt.autoconfiguration; - -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; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Conditional; - -import java.util.UUID; - -/** - * Autoconfiguration for injecting a {@link IdentityGenerator} for generating jwt id. - * - * @author Zihlu Wang - * @version 1.1.0 - * @since 1.0.0 - */ -@AutoConfiguration -public class GuidAutoConfiguration { - - private final static Logger log = LoggerFactory.getLogger(GuidAutoConfiguration.class); - - /** - * Default constructor. - */ - public GuidAutoConfiguration() { - } - - /** - * Create a default {@code jtiCreator} with UUID. - * - * @return UUID creator - */ - @Bean(name = "jtiCreator") - @Conditional(GuidCreatorCondition.class) - public IdentityGenerator jtiCreator() { - return UUID::randomUUID; - } - -} diff --git a/jwt-toolbox-spring-boot-starter/src/main/java/com/onixbyte/jwt/autoconfiguration/conditions/GuidCreatorCondition.java b/jwt-toolbox-spring-boot-starter/src/main/java/com/onixbyte/jwt/autoconfiguration/conditions/GuidCreatorCondition.java deleted file mode 100644 index 9662dac..0000000 --- a/jwt-toolbox-spring-boot-starter/src/main/java/com/onixbyte/jwt/autoconfiguration/conditions/GuidCreatorCondition.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2024-2025 OnixByte - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.onixbyte.jwt.autoconfiguration.conditions; - -import com.onixbyte.identitygenerator.IdentityGenerator; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.context.annotation.Condition; -import org.springframework.context.annotation.ConditionContext; -import org.springframework.core.type.AnnotatedTypeMetadata; - -import java.util.Objects; - -/** - * The conditions to create bean {@code jtiCreator}. - * - * @author zihluwang - * @version 3.0.0 - * @since 1.0.0 - */ -public class GuidCreatorCondition implements Condition { - - /** - * Default constructor. - */ - public GuidCreatorCondition() { - } - - /** - * The condition to create bean {@code jtiCreator}. - *

    - * 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 - * @param metadata the metadata of the {@link org.springframework.core.type.AnnotationMetadata - * class} or {@link org.springframework.core.type.MethodMetadata method} - * being checked - */ - @Override - 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 IdentityGenerator); - } - return true; - } -} diff --git a/jwt-toolbox-spring-boot-starter/src/main/java/com/onixbyte/jwt/autoconfiguration/properties/JwtProperties.java b/jwt-toolbox-spring-boot-starter/src/main/java/com/onixbyte/jwt/autoconfiguration/properties/JwtProperties.java deleted file mode 100644 index a10494c..0000000 --- a/jwt-toolbox-spring-boot-starter/src/main/java/com/onixbyte/jwt/autoconfiguration/properties/JwtProperties.java +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Copyright (c) 2024-2025 OnixByte - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.onixbyte.jwt.autoconfiguration.properties; - -import com.onixbyte.jwt.SecretCreator; -import com.onixbyte.jwt.constants.TokenAlgorithm; -import org.springframework.boot.context.properties.ConfigurationProperties; - -/** - * {@code JwtProperties} is a configuration properties class used to store the properties - * related to Simple JWT library configurations. These properties can be configured in the - * application's properties file (e.g., application.properties) with the prefix - * "onixbyte.simple-jwt". - *

    - * {@code JwtProperties} provides configuration options for the JWT algorithm, issuer, - * and secret. The properties are used by the {@code Auth0AutoConfiguration} to - * set up the necessary configurations for JWT generation and validation. - *

    - * Developers can customise the JWT algorithm, issuer, and secret by setting the corresponding - * properties in the application's properties file. The {@code Auth0AutoConfiguration} class - * reads these properties and uses them to create the TokenResolver bean with the - * desired configuration. - * - * @author Zihlu Wang - * @version 1.1.0 - * @since 1.0.0 - */ -// @ConfigurationProperties(prefix = "onixbyte.jwt") -public class JwtProperties { - - /** - * Default constructor. - */ - public JwtProperties() { - } - - /** - * The algorithm used for JWT generation and validation. Default value is - * {@link TokenAlgorithm#HS256} - */ - private TokenAlgorithm algorithm = TokenAlgorithm.HS256; - - /** - * The issuer value to be included in the generated JWT. Default value is an empty String. - */ - private String issuer = ""; - - /** - * The secret key used for JWT generation and validation. Default value is the result of call to - * {@link SecretCreator#createSecret(int, boolean, boolean, boolean)}. - */ - private String secret = SecretCreator.createSecret(32, true, true, true); - - /** - * The private key, PEM formatted. - */ - private String privateKey; - - /** - * The public key, PEM formatted - */ - private String publicKey; - - /** - * Algorithm getter. - * - * @return algorithm - */ - public TokenAlgorithm getAlgorithm() { - return algorithm; - } - - /** - * Algorithm setter. - * - * @param algorithm the algorithm - */ - public void setAlgorithm(TokenAlgorithm algorithm) { - this.algorithm = algorithm; - } - - /** - * Issuer getter. - * - * @return issuer - */ - public String getIssuer() { - return issuer; - } - - /** - * Issuer setter. - * - * @param issuer the issuer - */ - public void setIssuer(String issuer) { - this.issuer = issuer; - } - - /** - * Secret setter. - * - * @return secret - */ - public String getSecret() { - return secret; - } - - /** - * Secret setter. - * - * @param secret the secret - */ - public void setSecret(String secret) { - this.secret = secret; - } - - /** - * Private key getter. - * - * @return private key - */ - public String getPrivateKey() { - return privateKey; - } - - /** - * Private key setter. - * - * @param privateKey private key - */ - public void setPrivateKey(String privateKey) { - this.privateKey = privateKey; - } - - /** - * Public key getter. - * - * @return public key - */ - public String getPublicKey() { - return publicKey; - } - - /** - * Public key setter. - * - * @param publicKey public key - */ - public void setPublicKey(String publicKey) { - this.publicKey = publicKey; - } -} - 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 deleted file mode 100644 index a164fa1..0000000 --- a/jwt-toolbox-spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ /dev/null @@ -1 +0,0 @@ -com.onixbyte.jwt.autoconfiguration.GuidAutoConfiguration diff --git a/jwt-toolbox-spring-boot-starter/src/main/resources/logback.xml b/jwt-toolbox-spring-boot-starter/src/main/resources/logback.xml deleted file mode 100644 index 288ac4a..0000000 --- a/jwt-toolbox-spring-boot-starter/src/main/resources/logback.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - ${COLOURFUL_OUTPUT} - - - - - - diff --git a/settings.gradle.kts b/settings.gradle.kts index 467fc86..d5b4d12 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -23,7 +23,4 @@ include( "identity-generator", "crypto-toolbox", "math-toolbox", - "jwt-toolbox-facade", - "jwt-toolbox-auth0", - "jwt-toolbox-spring-boot-starter", ) From 022c1c241ae954743f4f7d70e8977fab5262d337 Mon Sep 17 00:00:00 2001 From: zihluwang Date: Wed, 18 Jun 2025 11:06:34 +0800 Subject: [PATCH 6/9] chore: update version catalogue dependencies --- version-catalogue/build.gradle.kts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/version-catalogue/build.gradle.kts b/version-catalogue/build.gradle.kts index d683310..5c440d3 100644 --- a/version-catalogue/build.gradle.kts +++ b/version-catalogue/build.gradle.kts @@ -43,13 +43,10 @@ repositories { dependencies { constraints { - api("com.onixbyte:devkit-utils:$artefactVersion") - api("com.onixbyte:guid:$artefactVersion") - api("com.onixbyte:key-pair-loader:$artefactVersion") - api("com.onixbyte:num4j:$artefactVersion") - api("com.onixbyte:simple-jwt-facade:$artefactVersion") - api("com.onixbyte:simple-jwt-authzero:$artefactVersion") - api("com.onixbyte:simple-jwt-spring-boot-starter:$artefactVersion") + api("com.onixbyte:common-toolbox:$artefactVersion") + api("com.onixbyte:identity-generator:$artefactVersion") + api("com.onixbyte:crypto-toolbox:$artefactVersion") + api("com.onixbyte:math-toolbox:$artefactVersion") } } From 0e87c0f3366ea5062b06fe6436609567b9c69fb3 Mon Sep 17 00:00:00 2001 From: zihluwang Date: Wed, 18 Jun 2025 13:57:32 +0800 Subject: [PATCH 7/9] style: reformatted codes --- common-toolbox/README.md | 5 ++-- .../onixbyte/common/util/CollectionUtil.java | 8 ++++-- .../com/onixbyte/common/util/RangeUtil.java | 2 +- crypto-toolbox/README.md | 6 ++-- .../com/onixbyte/crypto/PrivateKeyLoader.java | 4 +-- .../com/onixbyte/crypto/PublicKeyLoader.java | 7 +++-- .../algorithm/ecdsa/ECPrivateKeyLoader.java | 26 ++++++++--------- .../algorithm/ecdsa/ECPublicKeyLoader.java | 15 ++++++++++ .../algorithm/rsa/RSAPrivateKeyLoader.java | 11 ++++---- .../algorithm/rsa/RSAPublicKeyLoader.java | 15 ++++++++++ .../com/onixbyte/crypto/util/CryptoUtil.java | 28 ++++++++++--------- 11 files changed, 81 insertions(+), 46 deletions(-) diff --git a/common-toolbox/README.md b/common-toolbox/README.md index 6d2b02f..46be06b 100644 --- a/common-toolbox/README.md +++ b/common-toolbox/README.md @@ -1,8 +1,9 @@ -# Module `devkit-utils` +# Common Toolbox ## Introduction -This module provides a set of utilities to streamline Java codes. +Common Toolbox is a Java SE utility library, that provides a collection of utility to streamline +your Java coding experience. ## Features diff --git a/common-toolbox/src/main/java/com/onixbyte/common/util/CollectionUtil.java b/common-toolbox/src/main/java/com/onixbyte/common/util/CollectionUtil.java index 9737a64..615f1ee 100644 --- a/common-toolbox/src/main/java/com/onixbyte/common/util/CollectionUtil.java +++ b/common-toolbox/src/main/java/com/onixbyte/common/util/CollectionUtil.java @@ -61,9 +61,11 @@ public final class CollectionUtil { * {@code maxSize} is less than zero, or * {@code collectionFactory} is {@code null} */ - public static > List chunk(C originalCollection, - int maxSize, - Supplier collectionFactory) { + public static > List chunk( + C originalCollection, + int maxSize, + Supplier collectionFactory + ) { // check inputs if (Objects.isNull(originalCollection)) { throw new IllegalArgumentException("Collection must not be null."); diff --git a/common-toolbox/src/main/java/com/onixbyte/common/util/RangeUtil.java b/common-toolbox/src/main/java/com/onixbyte/common/util/RangeUtil.java index 81aa62f..e3a0a4c 100644 --- a/common-toolbox/src/main/java/com/onixbyte/common/util/RangeUtil.java +++ b/common-toolbox/src/main/java/com/onixbyte/common/util/RangeUtil.java @@ -122,7 +122,7 @@ public final class RangeUtil { return IntStream.range(start, end); } else { // Descending range (exclusive of end) - return IntStream.iterate(start, n -> n > end, n -> n - 1); + return IntStream.iterate(start, (n) -> n > end, (n) -> n - 1); } } diff --git a/crypto-toolbox/README.md b/crypto-toolbox/README.md index 3d32826..8e287e8 100644 --- a/crypto-toolbox/README.md +++ b/crypto-toolbox/README.md @@ -1,6 +1,6 @@ -# KeyLoader +# Crypto Toolbox -KeyLoader provides utility methods to load keys from pem-formatted key texts. +Crypto Toolbox provides methods to simplify your codes on key pairs. ## ECDSA-based algorithm @@ -110,4 +110,4 @@ pzDq72a2Rhws+dbrH0gqsg1lsLDfhhui2FomuBpDZUtHq0Jz/IEvd3X45XvegSH8 t8+yL/pFK3+YpDVtj/IzMSwL+izvnXFALvZOO+8CABeyKuSjLh/6LbAzrvoftql5 gQIDAQAB -----END PUBLIC KEY----- -``` \ 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 index e1b7876..9f3f8c7 100644 --- a/crypto-toolbox/src/main/java/com/onixbyte/crypto/PrivateKeyLoader.java +++ b/crypto-toolbox/src/main/java/com/onixbyte/crypto/PrivateKeyLoader.java @@ -25,8 +25,8 @@ 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. + * The {@code PrivateKeyLoader} provides utility methods for loading private keys from + * PEM-formatted key text. * * @author zihluwang * @author siujamo diff --git a/crypto-toolbox/src/main/java/com/onixbyte/crypto/PublicKeyLoader.java b/crypto-toolbox/src/main/java/com/onixbyte/crypto/PublicKeyLoader.java index e4dff60..943afcc 100644 --- a/crypto-toolbox/src/main/java/com/onixbyte/crypto/PublicKeyLoader.java +++ b/crypto-toolbox/src/main/java/com/onixbyte/crypto/PublicKeyLoader.java @@ -29,16 +29,19 @@ import java.security.interfaces.ECPublicKey; import java.security.interfaces.RSAPublicKey; /** + * The {@code PublicKeyLoader} provides utility methods for loading public keys from PEM-formatted + * key text. * + * @author zihluwang * @author siujamo * @version 3.0.0 */ public interface PublicKeyLoader { /** - * Load public key from pem-formatted key text. + * Load public key from PEM-formatted key text. * - * @param pemKeyText pem-formatted key text + * @param pemKeyText PEM-formatted key text * @return loaded private key */ PublicKey loadPublicKey(String pemKeyText); 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 index fa527ec..99adf89 100644 --- 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 @@ -26,32 +26,28 @@ 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. + * A class responsible for loading private ECDSA keys from PEM formatted text. *

    - * Example usage: - *

    {@code
    - * PrivateKeyLoader keyLoader = new ECPrivateKeyLoader();
    - * String pemPrivateKey = """
    - *                        -----BEGIN EC PRIVATE KEY-----
    - *                        ...
    - *                        -----END EC PRIVATE KEY-----""";
    - * ECPrivateKey privateKey = PrivateKeyLoader.loadEcdsaPrivateKey(pemPrivateKey);
    - * }
    + * This class implements the {@link PrivateKeyLoader} interface and provides methods to load private + * 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 zihluwang + * @author siujamo * @version 3.0.0 + * @see PrivateKeyLoader + * @see KeyLoadingException */ public class ECPrivateKeyLoader implements PrivateKeyLoader { diff --git a/crypto-toolbox/src/main/java/com/onixbyte/crypto/algorithm/ecdsa/ECPublicKeyLoader.java b/crypto-toolbox/src/main/java/com/onixbyte/crypto/algorithm/ecdsa/ECPublicKeyLoader.java index de14870..e3e0ef3 100644 --- a/crypto-toolbox/src/main/java/com/onixbyte/crypto/algorithm/ecdsa/ECPublicKeyLoader.java +++ b/crypto-toolbox/src/main/java/com/onixbyte/crypto/algorithm/ecdsa/ECPublicKeyLoader.java @@ -22,6 +22,7 @@ package com.onixbyte.crypto.algorithm.ecdsa; +import com.onixbyte.crypto.PrivateKeyLoader; import com.onixbyte.crypto.PublicKeyLoader; import com.onixbyte.crypto.exception.KeyLoadingException; import com.onixbyte.crypto.util.CryptoUtil; @@ -38,7 +39,21 @@ import java.util.HashSet; import java.util.Set; /** + * A class responsible for loading public ECDSA keys from PEM formatted text. + *

    + * This class implements the {@link PublicKeyLoader} interface and provides methods to load private + * 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 zihluwang + * @author siujamo + * @version 3.0.0 + * @see PrivateKeyLoader + * @see KeyLoadingException */ public class ECPublicKeyLoader implements PublicKeyLoader { 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 index 8cd6eb9..0d9f475 100644 --- 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 @@ -35,18 +35,19 @@ import java.security.spec.*; import java.util.Base64; /** - * A class responsible for loading RSA keys from PEM formatted text. + * A class responsible for loading private 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. + * This class implements the {@link PrivateKeyLoader} interface and provides methods to load private + * 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 zihluwang * @author siujamo + * @version 3.0.0 * @see PrivateKeyLoader * @see KeyLoadingException */ diff --git a/crypto-toolbox/src/main/java/com/onixbyte/crypto/algorithm/rsa/RSAPublicKeyLoader.java b/crypto-toolbox/src/main/java/com/onixbyte/crypto/algorithm/rsa/RSAPublicKeyLoader.java index f1a5c7b..c1a8810 100644 --- a/crypto-toolbox/src/main/java/com/onixbyte/crypto/algorithm/rsa/RSAPublicKeyLoader.java +++ b/crypto-toolbox/src/main/java/com/onixbyte/crypto/algorithm/rsa/RSAPublicKeyLoader.java @@ -22,6 +22,7 @@ package com.onixbyte.crypto.algorithm.rsa; +import com.onixbyte.crypto.PrivateKeyLoader; import com.onixbyte.crypto.PublicKeyLoader; import com.onixbyte.crypto.exception.KeyLoadingException; import com.onixbyte.crypto.util.CryptoUtil; @@ -37,7 +38,21 @@ import java.security.spec.X509EncodedKeySpec; import java.util.Base64; /** + * A class responsible for loading public RSA keys from PEM formatted text. + *

    + * This class implements the {@link PublicKeyLoader} interface and provides methods to load 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 zihluwang + * @author siujamo + * @version 3.0.0 + * @see PrivateKeyLoader + * @see KeyLoadingException */ public class RSAPublicKeyLoader implements PublicKeyLoader { 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 index 9432a27..9951af5 100644 --- a/crypto-toolbox/src/main/java/com/onixbyte/crypto/util/CryptoUtil.java +++ b/crypto-toolbox/src/main/java/com/onixbyte/crypto/util/CryptoUtil.java @@ -23,7 +23,11 @@ package com.onixbyte.crypto.util; /** + * Utility class for cryptographic operations. * + * @author zihluwang + * @author siujamo + * @version 3.0.0 */ public final class CryptoUtil { @@ -34,24 +38,22 @@ public final class CryptoUtil { } /** - * Retrieves the raw content of a PEM formatted key by removing unnecessary headers, footers, - * and new line characters. + * Extracts the raw content from a PEM-formatted key by removing any headers, footers, + * and newline 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. + * This method processes the given PEM key text and returns a cleaned string containing only + * the key material. It removes the lines matching the + * {@code "-----BEGIN (EC )?(RSA )?(PRIVATE|PUBLIC) KEY-----"} and + * {@code "-----END (EC )?(RSA )?(PRIVATE|PUBLIC) KEY-----"} patterns, + * as well as any newline characters, + * resulting in a continuous string that can be used directly for 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 + * @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 without 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-----", "") From bcaff326a638a8883943c8d790d8d8cd8521d3a9 Mon Sep 17 00:00:00 2001 From: zihluwang Date: Fri, 20 Jun 2025 19:10:54 +0800 Subject: [PATCH 8/9] build: upgrade v3.0.0 --- .../com/onixbyte/common/util/AesUtil.java | 77 ++++++++++++++++--- gradle.properties | 31 ++++---- gradlew.bat | 26 ++++--- 3 files changed, 101 insertions(+), 33 deletions(-) diff --git a/common-toolbox/src/main/java/com/onixbyte/common/util/AesUtil.java b/common-toolbox/src/main/java/com/onixbyte/common/util/AesUtil.java index 74da677..62ee697 100644 --- a/common-toolbox/src/main/java/com/onixbyte/common/util/AesUtil.java +++ b/common-toolbox/src/main/java/com/onixbyte/common/util/AesUtil.java @@ -80,6 +80,22 @@ public final class AesUtil { private AesUtil() { } + /** + * Encrypts the specified data using the AES algorithm with the provided secret key. + * + * @param data the data to be encrypted + * @param secret the secret key used for encryption + * @param ivParam the iv param + * @return the encrypted data as a byte array + * @throws GeneralSecurityException if any cryptographic error occurs during encryption + */ + public static byte[] encrypt(byte[] data, byte[] secret, byte[] ivParam) throws GeneralSecurityException { + var secretKeySpec = new SecretKeySpec(new SecretKeySpec(secret, AES).getEncoded(), AES); + var cipher = Cipher.getInstance(AES_CBC_CIPHER); + cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec, new IvParameterSpec(ivParam)); + return cipher.doFinal(data); + } + /** * Encrypts the specified data using the AES algorithm with the provided secret key. * @@ -89,9 +105,22 @@ public final class AesUtil { * @throws GeneralSecurityException if any cryptographic error occurs during encryption */ public static byte[] encrypt(byte[] data, byte[] secret) throws GeneralSecurityException { + return encrypt(data, secret, secret); + } + + /** + * Decrypts the specified data using the AES algorithm with the provided secret key. + * + * @param data the data to be decrypted + * @param secret the secret key used for decryption + * @param ivParam the iv param + * @return the decrypted data as a byte array + * @throws GeneralSecurityException if any cryptographic error occurs during decryption + */ + public static byte[] decrypt(byte[] data, byte[] secret, byte[] ivParam) throws GeneralSecurityException { var secretKeySpec = new SecretKeySpec(new SecretKeySpec(secret, AES).getEncoded(), AES); var cipher = Cipher.getInstance(AES_CBC_CIPHER); - cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec, new IvParameterSpec(secret)); + cipher.init(Cipher.DECRYPT_MODE, secretKeySpec, new IvParameterSpec(ivParam)); return cipher.doFinal(data); } @@ -104,10 +133,24 @@ public final class AesUtil { * @throws GeneralSecurityException if any cryptographic error occurs during decryption */ public static byte[] decrypt(byte[] data, byte[] secret) throws GeneralSecurityException { - var secretKeySpec = new SecretKeySpec(new SecretKeySpec(secret, AES).getEncoded(), AES); - var cipher = Cipher.getInstance(AES_CBC_CIPHER); - cipher.init(Cipher.DECRYPT_MODE, secretKeySpec, new IvParameterSpec(secret)); - return cipher.doFinal(data); + return decrypt(data, secret, secret); + } + + /** + * Encrypts the specified string data using the AES algorithm with the provided secret key. + * + * @param data the string data to be encrypted + * @param secret the secret key used for encryption + * @param ivParam the iv param + * @return the encrypted data encoded in Base64 + * @throws GeneralSecurityException if any cryptographic error occurs during encryption + */ + public static String encrypt(String data, String secret, String ivParam) throws GeneralSecurityException { + return Base64.getEncoder().encodeToString(encrypt( + data.getBytes(StandardCharsets.UTF_8), + secret.getBytes(StandardCharsets.UTF_8), + ivParam.getBytes(StandardCharsets.UTF_8) + )); } /** @@ -119,8 +162,24 @@ public final class AesUtil { * @throws GeneralSecurityException if any cryptographic error occurs during encryption */ public static String encrypt(String data, String secret) throws GeneralSecurityException { - return Base64.getEncoder().encodeToString(encrypt(data.getBytes(StandardCharsets.UTF_8), - secret.getBytes(StandardCharsets.UTF_8))); + return encrypt(data, secret, secret); + } + + /** + * Decrypts the specified Base64-encoded string data using the AES algorithm with the provided secret key. + * + * @param data the Base64-encoded string data to be decrypted + * @param secret the secret key used for decryption + * @return the decrypted string data + * @throws GeneralSecurityException if any cryptographic error occurs during decryption + */ + public static String decrypt(String data, String secret, String ivParam) throws GeneralSecurityException { + var decrypted = decrypt( + Base64.getDecoder().decode(data.getBytes(StandardCharsets.UTF_8)), + secret.getBytes(StandardCharsets.UTF_8), + ivParam.getBytes(StandardCharsets.UTF_8) + ); + return new String(decrypted, StandardCharsets.UTF_8); } /** @@ -132,9 +191,7 @@ public final class AesUtil { * @throws GeneralSecurityException if any cryptographic error occurs during decryption */ public static String decrypt(String data, String secret) throws GeneralSecurityException { - var decrypted = decrypt(Base64.getDecoder().decode(data.getBytes(StandardCharsets.UTF_8)), - secret.getBytes(StandardCharsets.UTF_8)); - return new String(decrypted, StandardCharsets.UTF_8); + return decrypt(data, secret, secret); } /** diff --git a/gradle.properties b/gradle.properties index 29c0ce1..00e3c6a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,22 +1,27 @@ # -# Copyright (C) 2024-2025 OnixByte. +# 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 +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: # -# http://www.apache.org/licenses/LICENSE-2.0 +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. # -# 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. +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. # -artefactVersion=2.4.0 +artefactVersion=3.0.0 projectUrl=https://onixbyte.com/projects/onixbyte-toolbox projectGithubUrl=https://github.com/onixbyte/onixbyte-toolbox -licenseName=The Apache License, Version 2.0 +licenseName=MIT licenseUrl=https://onixbyte.com/projects/onixbyte-toolbox/LICENSE.txt diff --git a/gradlew.bat b/gradlew.bat index 25da30d..e2b0bab 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,17 +1,23 @@ @rem -@rem Copyright 2015 the original author or authors. +@rem Copyright (c) 2024-2025 OnixByte @rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at +@rem Permission is hereby granted, free of charge, to any person obtaining a copy +@rem of this software and associated documentation files (the "Software"), to deal +@rem in the Software without restriction, including without limitation the rights +@rem to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +@rem copies of the Software, and to permit persons to whom the Software is +@rem furnished to do so, subject to the following conditions: @rem -@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem The above copyright notice and this permission notice shall be included in all +@rem copies or substantial portions of the Software. @rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. +@rem THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +@rem IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +@rem FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +@rem AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +@rem LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +@rem OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +@rem SOFTWARE. @rem @if "%DEBUG%"=="" @echo off From 39c5d230d67b74af0368d48cb35e5e3cf010b750 Mon Sep 17 00:00:00 2001 From: siujamo Date: Tue, 24 Jun 2025 11:28:08 +0800 Subject: [PATCH 9/9] docs: fix version errors --- version-catalogue/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/version-catalogue/README.md b/version-catalogue/README.md index 0a78861..c6e4105 100644 --- a/version-catalogue/README.md +++ b/version-catalogue/README.md @@ -17,7 +17,7 @@ Add the `version-catalogue` to your `pom.xml` under ``: com.onixbyte version-catalogue - ${devkit-version} + 3.0.0 pom import @@ -33,7 +33,7 @@ In your `build.gradle[.kts]`, apply the BOM using the `platform` dependency: ```groovy dependencies { - implementation platform('com.onixbyte:version-catalogue:2.0.0') + implementation platform('com.onixbyte:version-catalogue:3.0.0') implementation 'com.onixbyte:common-toolbox' } ``` @@ -42,7 +42,7 @@ If you are using Kotlin DSL: ```kotlin dependencies { - implementation(platform("com.onixbyte:version-catalogue:2.0.0")) + implementation(platform("com.onixbyte:version-catalogue:3.0.0")) implementation("com.onixbyte:common-toolbox") } ```