From 8635bdd0320fda06f28943dc1cba591c2b848c59 Mon Sep 17 00:00:00 2001 From: Zihlu Wang Date: Wed, 30 Aug 2023 14:09:21 +0800 Subject: [PATCH 01/27] fix(simple-jwt-authzero): Removed unused empty line in logs. --- .../codecrafters/simplejwt/authzero/AuthzeroTokenResolver.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/simple-jwt-authzero/src/main/java/cn/org/codecrafters/simplejwt/authzero/AuthzeroTokenResolver.java b/simple-jwt-authzero/src/main/java/cn/org/codecrafters/simplejwt/authzero/AuthzeroTokenResolver.java index f7ebe31..ad6b658 100644 --- a/simple-jwt-authzero/src/main/java/cn/org/codecrafters/simplejwt/authzero/AuthzeroTokenResolver.java +++ b/simple-jwt-authzero/src/main/java/cn/org/codecrafters/simplejwt/authzero/AuthzeroTokenResolver.java @@ -283,8 +283,7 @@ public class AuthzeroTokenResolver implements TokenResolver { builder.withClaim(name, v); } else { log.warn(""" - Unable to determine the type of field {}, converting it to a string now. - """, name); + Unable to determine the type of field {}, converting it to a string now.""", name); builder.withClaim(name, value.toString()); } } else { From 714c4ecd3a597a401baa78675196419f4bc1253a Mon Sep 17 00:00:00 2001 From: Zihlu Wang Date: Wed, 30 Aug 2023 14:23:44 +0800 Subject: [PATCH 02/27] build(global): Upgrade to 1.0.2 --- devkit-core/pom.xml | 2 +- devkit-utils/pom.xml | 2 +- guid/pom.xml | 2 +- pom.xml | 2 +- simple-jwt-authzero/pom.xml | 2 +- simple-jwt-facade/pom.xml | 2 +- simple-jwt-jjwt/pom.xml | 2 +- simple-jwt-spring-boot-starter/pom.xml | 2 +- webcal/pom.xml | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/devkit-core/pom.xml b/devkit-core/pom.xml index aa09102..2b64cd4 100644 --- a/devkit-core/pom.xml +++ b/devkit-core/pom.xml @@ -23,7 +23,7 @@ cn.org.codecrafters jdevkit - 1.0.1 + 1.0.2 devkit-core diff --git a/devkit-utils/pom.xml b/devkit-utils/pom.xml index 348d4c8..b735862 100644 --- a/devkit-utils/pom.xml +++ b/devkit-utils/pom.xml @@ -6,7 +6,7 @@ cn.org.codecrafters jdevkit - 1.0.1 + 1.0.2 devkit-utils diff --git a/guid/pom.xml b/guid/pom.xml index 314a524..93705e7 100644 --- a/guid/pom.xml +++ b/guid/pom.xml @@ -23,7 +23,7 @@ cn.org.codecrafters jdevkit - 1.0.1 + 1.0.2 guid diff --git a/pom.xml b/pom.xml index 49b6f1b..4e217ad 100644 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,7 @@ cn.org.codecrafters jdevkit - 1.0.1 + 1.0.2 2023 pom diff --git a/simple-jwt-authzero/pom.xml b/simple-jwt-authzero/pom.xml index d2b32ac..3935ac3 100644 --- a/simple-jwt-authzero/pom.xml +++ b/simple-jwt-authzero/pom.xml @@ -23,7 +23,7 @@ cn.org.codecrafters jdevkit - 1.0.1 + 1.0.2 simple-jwt-authzero diff --git a/simple-jwt-facade/pom.xml b/simple-jwt-facade/pom.xml index b1130f4..1c482c2 100644 --- a/simple-jwt-facade/pom.xml +++ b/simple-jwt-facade/pom.xml @@ -23,7 +23,7 @@ cn.org.codecrafters jdevkit - 1.0.1 + 1.0.2 simple-jwt-facade diff --git a/simple-jwt-jjwt/pom.xml b/simple-jwt-jjwt/pom.xml index eaf8804..6e84f7d 100644 --- a/simple-jwt-jjwt/pom.xml +++ b/simple-jwt-jjwt/pom.xml @@ -23,7 +23,7 @@ cn.org.codecrafters jdevkit - 1.0.1 + 1.0.2 simple-jwt-jjwt diff --git a/simple-jwt-spring-boot-starter/pom.xml b/simple-jwt-spring-boot-starter/pom.xml index 0a5575b..cda7727 100644 --- a/simple-jwt-spring-boot-starter/pom.xml +++ b/simple-jwt-spring-boot-starter/pom.xml @@ -23,7 +23,7 @@ cn.org.codecrafters jdevkit - 1.0.1 + 1.0.2 simple-jwt-spring-boot-starter diff --git a/webcal/pom.xml b/webcal/pom.xml index 8e77cae..178cea6 100644 --- a/webcal/pom.xml +++ b/webcal/pom.xml @@ -23,7 +23,7 @@ cn.org.codecrafters jdevkit - 1.0.1 + 1.0.2 webcal From cd2ddb95c3c5002f1882cd3a2b7a86a70673e10e Mon Sep 17 00:00:00 2001 From: Zihlu Wang Date: Wed, 30 Aug 2023 14:09:21 +0800 Subject: [PATCH 03/27] fix(simple-jwt-authzero): Removed unused empty line in logs. Closes #10 --- .../codecrafters/simplejwt/authzero/AuthzeroTokenResolver.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/simple-jwt-authzero/src/main/java/cn/org/codecrafters/simplejwt/authzero/AuthzeroTokenResolver.java b/simple-jwt-authzero/src/main/java/cn/org/codecrafters/simplejwt/authzero/AuthzeroTokenResolver.java index f7ebe31..ad6b658 100644 --- a/simple-jwt-authzero/src/main/java/cn/org/codecrafters/simplejwt/authzero/AuthzeroTokenResolver.java +++ b/simple-jwt-authzero/src/main/java/cn/org/codecrafters/simplejwt/authzero/AuthzeroTokenResolver.java @@ -283,8 +283,7 @@ public class AuthzeroTokenResolver implements TokenResolver { builder.withClaim(name, v); } else { log.warn(""" - Unable to determine the type of field {}, converting it to a string now. - """, name); + Unable to determine the type of field {}, converting it to a string now.""", name); builder.withClaim(name, value.toString()); } } else { From 81ebb01cfe8c10657dc1c6113d63ef1b63abe57d Mon Sep 17 00:00:00 2001 From: Zihlu Wang Date: Wed, 30 Aug 2023 14:23:44 +0800 Subject: [PATCH 04/27] build(global): Upgrade to 1.0.2 --- devkit-core/pom.xml | 2 +- devkit-utils/pom.xml | 2 +- guid/pom.xml | 2 +- pom.xml | 2 +- simple-jwt-authzero/pom.xml | 2 +- simple-jwt-facade/pom.xml | 2 +- simple-jwt-jjwt/pom.xml | 2 +- simple-jwt-spring-boot-starter/pom.xml | 2 +- webcal/pom.xml | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/devkit-core/pom.xml b/devkit-core/pom.xml index aa09102..2b64cd4 100644 --- a/devkit-core/pom.xml +++ b/devkit-core/pom.xml @@ -23,7 +23,7 @@ cn.org.codecrafters jdevkit - 1.0.1 + 1.0.2 devkit-core diff --git a/devkit-utils/pom.xml b/devkit-utils/pom.xml index 348d4c8..b735862 100644 --- a/devkit-utils/pom.xml +++ b/devkit-utils/pom.xml @@ -6,7 +6,7 @@ cn.org.codecrafters jdevkit - 1.0.1 + 1.0.2 devkit-utils diff --git a/guid/pom.xml b/guid/pom.xml index 314a524..93705e7 100644 --- a/guid/pom.xml +++ b/guid/pom.xml @@ -23,7 +23,7 @@ cn.org.codecrafters jdevkit - 1.0.1 + 1.0.2 guid diff --git a/pom.xml b/pom.xml index 49b6f1b..4e217ad 100644 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,7 @@ cn.org.codecrafters jdevkit - 1.0.1 + 1.0.2 2023 pom diff --git a/simple-jwt-authzero/pom.xml b/simple-jwt-authzero/pom.xml index d2b32ac..3935ac3 100644 --- a/simple-jwt-authzero/pom.xml +++ b/simple-jwt-authzero/pom.xml @@ -23,7 +23,7 @@ cn.org.codecrafters jdevkit - 1.0.1 + 1.0.2 simple-jwt-authzero diff --git a/simple-jwt-facade/pom.xml b/simple-jwt-facade/pom.xml index b1130f4..1c482c2 100644 --- a/simple-jwt-facade/pom.xml +++ b/simple-jwt-facade/pom.xml @@ -23,7 +23,7 @@ cn.org.codecrafters jdevkit - 1.0.1 + 1.0.2 simple-jwt-facade diff --git a/simple-jwt-jjwt/pom.xml b/simple-jwt-jjwt/pom.xml index eaf8804..6e84f7d 100644 --- a/simple-jwt-jjwt/pom.xml +++ b/simple-jwt-jjwt/pom.xml @@ -23,7 +23,7 @@ cn.org.codecrafters jdevkit - 1.0.1 + 1.0.2 simple-jwt-jjwt diff --git a/simple-jwt-spring-boot-starter/pom.xml b/simple-jwt-spring-boot-starter/pom.xml index 0a5575b..cda7727 100644 --- a/simple-jwt-spring-boot-starter/pom.xml +++ b/simple-jwt-spring-boot-starter/pom.xml @@ -23,7 +23,7 @@ cn.org.codecrafters jdevkit - 1.0.1 + 1.0.2 simple-jwt-spring-boot-starter diff --git a/webcal/pom.xml b/webcal/pom.xml index 8e77cae..178cea6 100644 --- a/webcal/pom.xml +++ b/webcal/pom.xml @@ -23,7 +23,7 @@ cn.org.codecrafters jdevkit - 1.0.1 + 1.0.2 webcal From c655a6d9a18fba754f09fc5421b9b75da5970d15 Mon Sep 17 00:00:00 2001 From: Zihlu Wang Date: Sat, 9 Sep 2023 18:49:43 +0800 Subject: [PATCH 05/27] feat(devkit-utils): Added AesUtil. --- .../codecrafters/devkit/utils/AesUtil.java | 135 ++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/AesUtil.java diff --git a/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/AesUtil.java b/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/AesUtil.java new file mode 100644 index 0000000..a0c916c --- /dev/null +++ b/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/AesUtil.java @@ -0,0 +1,135 @@ +/* + * 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 cn.org.codecrafters.devkit.utils; + +import lombok.extern.slf4j.Slf4j; + +import javax.crypto.BadPaddingException; +import javax.crypto.Cipher; +import javax.crypto.IllegalBlockSizeException; +import javax.crypto.NoSuchPaddingException; +import javax.crypto.spec.IvParameterSpec; +import javax.crypto.spec.SecretKeySpec; +import java.nio.charset.StandardCharsets; +import java.security.InvalidAlgorithmParameterException; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; +import java.util.Base64; +import java.util.Objects; +import java.util.UUID; + +/** + * AES Util helps you encrypt and decrypt data with specified key and AES + * algorithm. + * + * @author hubin@baomidou + * @since 1.1.0 + */ +@Slf4j +public final class AesUtil { + + private AesUtil() { + } + + private static final String AES = "AES"; + + private static final String AES_CBC_CIPHER = "AES/CBC/PKCS5Padding"; + + /** + * Encrypt the given data with given key with AES algorithm. + * + * @param data the data to be encrypted + * @param key the key to encrypt the data + * @return the encryption result or {@code null} if encryption failed + */ + public static byte[] encrypt(byte[] data, byte[] key) { + try { + var secretKeySpec = new SecretKeySpec(new SecretKeySpec(key, AES).getEncoded(), AES); + var cipher = Cipher.getInstance(AES_CBC_CIPHER); + cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec, new IvParameterSpec(key)); + return cipher.doFinal(data); + } catch (NoSuchAlgorithmException | NoSuchPaddingException | UnsupportedOperationException | + InvalidKeyException | InvalidAlgorithmParameterException | IllegalBlockSizeException | + BadPaddingException exception) { + log.error(exception.getMessage()); + for (var stackTraceElement : exception.getStackTrace()) { + log.error("{}", stackTraceElement.toString()); + } + } + return null; + } + + /** + * Decrypt the given data with given key with AES algorithm. + * + * @param data the data to be decrypted + * @param key the key to encrypt the data + * @return the decryption result or {@code null} if decryption failed + */ + public static byte[] decrypt(byte[] data, byte[] key) { + try { + var secretKeySpec = new SecretKeySpec(new SecretKeySpec(key, AES).getEncoded(), AES); + var cipher = Cipher.getInstance(AES_CBC_CIPHER); + cipher.init(Cipher.DECRYPT_MODE, secretKeySpec, new IvParameterSpec(key)); + return cipher.doFinal(data); + } catch (NoSuchAlgorithmException | NoSuchPaddingException | UnsupportedOperationException | + InvalidKeyException | InvalidAlgorithmParameterException | IllegalBlockSizeException | + BadPaddingException exception) { + log.error(exception.getMessage()); + for (var stackTraceElement : exception.getStackTrace()) { + log.error("{}", stackTraceElement.toString()); + } + } + return null; + } + + /** + * Encrypt the given data with given key with AES algorithm. + * + * @param data the data to be encrypted + * @param key the key to encrypt the data + * @return the encryption result or {@code null} if encryption failed + */ + public static String encrypt(String data, String key) { + return Base64.getEncoder().encodeToString(encrypt(data.getBytes(StandardCharsets.UTF_8), key.getBytes(StandardCharsets.UTF_8))); + } + + /** + * Decrypt the given data with given key with AES algorithm. + * + * @param data the data to be decrypted + * @param key the key to encrypt the data + * @return the decryption result or {@code null} if decryption failed + */ + public static String decrypt(String data, String key) { + return new String(Objects.requireNonNull( + decrypt(Base64.getDecoder().decode(data.getBytes()), + key.getBytes(StandardCharsets.UTF_8))) + ); + } + + /** + * Generates 16 characters-long random key. + * + * @return the generated secure secret + */ + public static String generateRandomKey() { + return UUID.randomUUID().toString().replaceAll("-", "").substring(0, 16); + } + +} From 08a2cc9f6edae4a2c895461836e2a39cec7256a5 Mon Sep 17 00:00:00 2001 From: Zihlu Wang Date: Sat, 9 Sep 2023 20:18:46 +0800 Subject: [PATCH 06/27] build(global): Upgrade to 1.1.0-alpha --- devkit-core/pom.xml | 2 +- devkit-utils/pom.xml | 2 +- guid/pom.xml | 2 +- pom.xml | 3 +- .../pom.xml | 65 +++++++++++++++++++ simple-jwt-authzero/pom.xml | 2 +- simple-jwt-facade/pom.xml | 2 +- simple-jwt-jjwt/pom.xml | 2 +- simple-jwt-spring-boot-starter/pom.xml | 2 +- webcal/pom.xml | 2 +- 10 files changed, 75 insertions(+), 9 deletions(-) create mode 100644 property-encryptor-spring-boot-starter/pom.xml diff --git a/devkit-core/pom.xml b/devkit-core/pom.xml index 2b64cd4..66d3d02 100644 --- a/devkit-core/pom.xml +++ b/devkit-core/pom.xml @@ -23,7 +23,7 @@ cn.org.codecrafters jdevkit - 1.0.2 + 1.1.0-alpha devkit-core diff --git a/devkit-utils/pom.xml b/devkit-utils/pom.xml index b735862..882de50 100644 --- a/devkit-utils/pom.xml +++ b/devkit-utils/pom.xml @@ -6,7 +6,7 @@ cn.org.codecrafters jdevkit - 1.0.2 + 1.1.0-alpha devkit-utils diff --git a/guid/pom.xml b/guid/pom.xml index 93705e7..2503160 100644 --- a/guid/pom.xml +++ b/guid/pom.xml @@ -23,7 +23,7 @@ cn.org.codecrafters jdevkit - 1.0.2 + 1.1.0-alpha guid diff --git a/pom.xml b/pom.xml index 4e217ad..3033014 100644 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,7 @@ cn.org.codecrafters jdevkit - 1.0.2 + 1.1.0-alpha 2023 pom @@ -42,6 +42,7 @@ simple-jwt-authzero simple-jwt-jjwt simple-jwt-spring-boot-starter + property-encryptor-spring-boot-starter diff --git a/property-encryptor-spring-boot-starter/pom.xml b/property-encryptor-spring-boot-starter/pom.xml new file mode 100644 index 0000000..4c30229 --- /dev/null +++ b/property-encryptor-spring-boot-starter/pom.xml @@ -0,0 +1,65 @@ + + + + + 4.0.0 + + cn.org.codecrafters + jdevkit + 1.1.0-alpha + + + property-encryptor-spring-boot-starter + + + 17 + 17 + UTF-8 + + + + + cn.org.codecrafters + devkit-utils + + + + org.springframework.boot + spring-boot-autoconfigure + + + + org.springframework.boot + spring-boot-starter-logging + + + + org.springframework.boot + spring-boot-configuration-processor + + + + org.springframework.boot + spring-boot-starter-test + test + + + + \ No newline at end of file diff --git a/simple-jwt-authzero/pom.xml b/simple-jwt-authzero/pom.xml index 3935ac3..3f9ed61 100644 --- a/simple-jwt-authzero/pom.xml +++ b/simple-jwt-authzero/pom.xml @@ -23,7 +23,7 @@ cn.org.codecrafters jdevkit - 1.0.2 + 1.1.0-alpha simple-jwt-authzero diff --git a/simple-jwt-facade/pom.xml b/simple-jwt-facade/pom.xml index 1c482c2..2bdc025 100644 --- a/simple-jwt-facade/pom.xml +++ b/simple-jwt-facade/pom.xml @@ -23,7 +23,7 @@ cn.org.codecrafters jdevkit - 1.0.2 + 1.1.0-alpha simple-jwt-facade diff --git a/simple-jwt-jjwt/pom.xml b/simple-jwt-jjwt/pom.xml index 6e84f7d..69cf8e6 100644 --- a/simple-jwt-jjwt/pom.xml +++ b/simple-jwt-jjwt/pom.xml @@ -23,7 +23,7 @@ cn.org.codecrafters jdevkit - 1.0.2 + 1.1.0-alpha simple-jwt-jjwt diff --git a/simple-jwt-spring-boot-starter/pom.xml b/simple-jwt-spring-boot-starter/pom.xml index cda7727..ed31d53 100644 --- a/simple-jwt-spring-boot-starter/pom.xml +++ b/simple-jwt-spring-boot-starter/pom.xml @@ -23,7 +23,7 @@ cn.org.codecrafters jdevkit - 1.0.2 + 1.1.0-alpha simple-jwt-spring-boot-starter diff --git a/webcal/pom.xml b/webcal/pom.xml index 178cea6..99060f5 100644 --- a/webcal/pom.xml +++ b/webcal/pom.xml @@ -23,7 +23,7 @@ cn.org.codecrafters jdevkit - 1.0.2 + 1.1.0-alpha webcal From f88ac1511b4c997327d4788417129bf3a1019848 Mon Sep 17 00:00:00 2001 From: Zihlu Wang Date: Sat, 9 Sep 2023 20:20:57 +0800 Subject: [PATCH 07/27] build: Rename property-encryptor to property-guard. --- pom.xml | 2 +- .../pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename {property-encryptor-spring-boot-starter => property-guard-spring-boot-starter}/pom.xml (96%) diff --git a/pom.xml b/pom.xml index 3033014..0d5c10a 100644 --- a/pom.xml +++ b/pom.xml @@ -42,7 +42,7 @@ simple-jwt-authzero simple-jwt-jjwt simple-jwt-spring-boot-starter - property-encryptor-spring-boot-starter + property-guard-spring-boot-starter diff --git a/property-encryptor-spring-boot-starter/pom.xml b/property-guard-spring-boot-starter/pom.xml similarity index 96% rename from property-encryptor-spring-boot-starter/pom.xml rename to property-guard-spring-boot-starter/pom.xml index 4c30229..7273c41 100644 --- a/property-encryptor-spring-boot-starter/pom.xml +++ b/property-guard-spring-boot-starter/pom.xml @@ -26,7 +26,7 @@ 1.1.0-alpha - property-encryptor-spring-boot-starter + property-guard-spring-boot-starter 17 From 956ce5de1e71c900f6f35f3a0761183d188d8567 Mon Sep 17 00:00:00 2001 From: Zihlu Wang Date: Sat, 9 Sep 2023 20:21:34 +0800 Subject: [PATCH 08/27] feat(property-guard): Added property-guard to protect the secrets in configuration files. --- .../propertyencryptor/PropertyGuard.java | 96 +++++++++++++++++++ .../main/resources/META-INF/spring.factories | 1 + 2 files changed, 97 insertions(+) create mode 100644 property-guard-spring-boot-starter/src/main/java/cn/org/codecrafters/propertyencryptor/PropertyGuard.java create mode 100644 property-guard-spring-boot-starter/src/main/resources/META-INF/spring.factories diff --git a/property-guard-spring-boot-starter/src/main/java/cn/org/codecrafters/propertyencryptor/PropertyGuard.java b/property-guard-spring-boot-starter/src/main/java/cn/org/codecrafters/propertyencryptor/PropertyGuard.java new file mode 100644 index 0000000..c1d95ef --- /dev/null +++ b/property-guard-spring-boot-starter/src/main/java/cn/org/codecrafters/propertyencryptor/PropertyGuard.java @@ -0,0 +1,96 @@ +/* + * 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 cn.org.codecrafters.propertyencryptor; + +import cn.org.codecrafters.devkit.utils.AesUtil; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.env.EnvironmentPostProcessor; +import org.springframework.boot.env.OriginTrackedMapPropertySource; +import org.springframework.core.env.ConfigurableEnvironment; +import org.springframework.core.env.MapPropertySource; +import org.springframework.core.env.SimpleCommandLinePropertySource; + +import java.util.HashMap; +import java.util.Optional; + +/** + * PropertyEncryptor is a utility class designed for encrypting configuration + * information in Spring Boot applications. + *

+ * Spring Boot applications often need to store sensitive configuration details + * such as database passwords, API keys, etc. To ensure that these sensitive + * pieces of information are not exposed, developers can utilize the + * {@code PropertyGuard} class to encrypt and store them within configuration + * files. + *

+ * Usage + * In {@code application.yml} or {@code application.properties}: + *

+ *     # original
+ *     app.example-properties=Sample Value
+ *
+ *     # encrypted with key 3856faef0d2d4f33
+ *     app.example-properties=pe:t4YBfv8M9ZmTzWgTi2gJqg==
+ * 
+ * Then, add the command line arguments like {@code --pe.key=3856faef0d2d4f33}. + *

+ * This class is extracted from MyBatis-Plus. + * + * @author hubin@baomidou + * @see org.springframework.boot.env.EnvironmentPostProcessor + */ +public class PropertyGuard implements EnvironmentPostProcessor { + + /** + * Process the encryption environment variables. + * + * @param environment the environment to post-process + * @param application the application to which the environment belongs + */ + @Override + public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) { + // Get the key for encryption from command line. + var encryptionKey = ""; + for (var ps : environment.getPropertySources()) { + if (ps instanceof SimpleCommandLinePropertySource source) { + encryptionKey = source.getProperty("pe.key"); + break; + } + } + + if (Optional.ofNullable(encryptionKey).map((key) -> !key.isEmpty()).orElse(false)) { + var map = new HashMap(); + for (var propertySources : environment.getPropertySources()) { + if (propertySources instanceof OriginTrackedMapPropertySource source) { + for (var name : source.getPropertyNames()) { + if (source.getProperty(name) instanceof String str) { + if (str.startsWith("pe:")) { + map.put(name, AesUtil.decrypt(str.substring(3), encryptionKey)); + } + } + } + } + } + // Put the decrypted data into environment variables, and made them at top-level. + if (!map.isEmpty()) { + environment.getPropertySources().addFirst(new MapPropertySource("custom-encrypt", map)); + } + } + } +} diff --git a/property-guard-spring-boot-starter/src/main/resources/META-INF/spring.factories b/property-guard-spring-boot-starter/src/main/resources/META-INF/spring.factories new file mode 100644 index 0000000..dcdcd64 --- /dev/null +++ b/property-guard-spring-boot-starter/src/main/resources/META-INF/spring.factories @@ -0,0 +1 @@ +org.springframework.boot.env.EnvironmentPostProcessor=cn.org.codecrafters.propertyencryptor.PropertyGuard \ No newline at end of file From 90a9171f42cc8200e6d848d99cde627280353a05 Mon Sep 17 00:00:00 2001 From: Zihlu Wang Date: Sat, 9 Sep 2023 20:38:02 +0800 Subject: [PATCH 09/27] refactor(property-guard): Changed the package name. --- .../autoconfiguration}/PropertyGuard.java | 2 +- .../src/main/resources/META-INF/spring.factories | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename property-guard-spring-boot-starter/src/main/java/cn/org/codecrafters/{propertyencryptor => propertyguard/autoconfiguration}/PropertyGuard.java (98%) diff --git a/property-guard-spring-boot-starter/src/main/java/cn/org/codecrafters/propertyencryptor/PropertyGuard.java b/property-guard-spring-boot-starter/src/main/java/cn/org/codecrafters/propertyguard/autoconfiguration/PropertyGuard.java similarity index 98% rename from property-guard-spring-boot-starter/src/main/java/cn/org/codecrafters/propertyencryptor/PropertyGuard.java rename to property-guard-spring-boot-starter/src/main/java/cn/org/codecrafters/propertyguard/autoconfiguration/PropertyGuard.java index c1d95ef..e02b6b1 100644 --- a/property-guard-spring-boot-starter/src/main/java/cn/org/codecrafters/propertyencryptor/PropertyGuard.java +++ b/property-guard-spring-boot-starter/src/main/java/cn/org/codecrafters/propertyguard/autoconfiguration/PropertyGuard.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package cn.org.codecrafters.propertyencryptor; +package cn.org.codecrafters.propertyguard.autoconfiguration; import cn.org.codecrafters.devkit.utils.AesUtil; import org.springframework.boot.SpringApplication; diff --git a/property-guard-spring-boot-starter/src/main/resources/META-INF/spring.factories b/property-guard-spring-boot-starter/src/main/resources/META-INF/spring.factories index dcdcd64..82e039a 100644 --- a/property-guard-spring-boot-starter/src/main/resources/META-INF/spring.factories +++ b/property-guard-spring-boot-starter/src/main/resources/META-INF/spring.factories @@ -1 +1 @@ -org.springframework.boot.env.EnvironmentPostProcessor=cn.org.codecrafters.propertyencryptor.PropertyGuard \ No newline at end of file +org.springframework.boot.env.EnvironmentPostProcessor=cn.org.codecrafters.propertyguard.autoconfiguration.PropertyGuard \ No newline at end of file From bed413dd3957f04fd832e8464589bd5232186f8b Mon Sep 17 00:00:00 2001 From: Zihlu Wang Date: Sat, 9 Sep 2023 20:44:30 +0800 Subject: [PATCH 10/27] docs(property-guard): Finished docs. --- property-guard-spring-boot-starter/README.md | 97 ++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 property-guard-spring-boot-starter/README.md diff --git a/property-guard-spring-boot-starter/README.md b/property-guard-spring-boot-starter/README.md new file mode 100644 index 0000000..0c8d843 --- /dev/null +++ b/property-guard-spring-boot-starter/README.md @@ -0,0 +1,97 @@ +# Property Guard + +## Introduction + +This feature is designed to protect the security of configurations and data, to a certain extent, to control the flow of developers leading to the leakage of sensitive information. + +## Prerequisites + +This whole `JDevKit` is developed by **JDK 17**, which means you have to use JDK 17 for better experience. Except this, this module is designed for Spring Boot framework, so you have to install Spring Boot (v3) in your application. + +## 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 + + cn.org.codecrafters + property-guard-spring-boot-starter + ${property-guard-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/property-guard-spring-boot-starter/`. + +### 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 'cn.org.codecrafters:property-guard-spring-boot-starter:${property-guard-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`. + +## Usage + +First, you need a 16-bit-long secret. If you don't have a good way to get a secret, you could consider using our `cn.org.codecrafters.devkit.utils.AesUtil` or `cn.org.codecrafters.simplejwt.SecretCreator` to create a secret. + +For example: +```java +import cn.org.codecrafters.devkit.utils.AesUtil; +import cn.org.codecrafters.simplejwt.SecretCreator; + +class GenerateRandomKeySample { + public static void main(String[] args) { + var secret1 = AesUtil.generateRandomKey(); + var secret2 = SecretCreator.createSecret(16, true, true, true); + } +} +``` + +Then, remember this secret and encrypt the configuration properties that are required high security. For example: + +```java +import cn.org.codecrafters.devkit.utils.AesUtil; + +class EncryptSample { + public static void main(String[] args) { + var dataNeedEncryption = "Sample Value"; + var key = "3856faef0d2d4f33"; + var encryptedData = AesUtil.encrypt(dataNeedEncryption, key); + } +} +``` + +After that, copy the encrypted data to `application.properties` or `application.yml`. + +For `yml`: +```yaml +app: + sample-configuration: pe:t4YBfv8M9ZmTzWgTi2gJqg== # "pe:" is the prefix that declare that this property is encrypted. +``` + +For `properties`: +```properties +app.sample-configuration=pe:t4YBfv8M9ZmTzWgTi2gJqg== +``` + +## 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). \ No newline at end of file From 23e267e91fb81720f710c865f54064cede6239ff Mon Sep 17 00:00:00 2001 From: Zihlu Wang Date: Sat, 9 Sep 2023 20:49:22 +0800 Subject: [PATCH 11/27] feat(property-guard): Remove useless imports. --- .../propertyguard/autoconfiguration/PropertyGuard.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/property-guard-spring-boot-starter/src/main/java/cn/org/codecrafters/propertyguard/autoconfiguration/PropertyGuard.java b/property-guard-spring-boot-starter/src/main/java/cn/org/codecrafters/propertyguard/autoconfiguration/PropertyGuard.java index e02b6b1..100f93e 100644 --- a/property-guard-spring-boot-starter/src/main/java/cn/org/codecrafters/propertyguard/autoconfiguration/PropertyGuard.java +++ b/property-guard-spring-boot-starter/src/main/java/cn/org/codecrafters/propertyguard/autoconfiguration/PropertyGuard.java @@ -21,6 +21,8 @@ import cn.org.codecrafters.devkit.utils.AesUtil; import org.springframework.boot.SpringApplication; import org.springframework.boot.env.EnvironmentPostProcessor; import org.springframework.boot.env.OriginTrackedMapPropertySource; +import org.springframework.core.Ordered; +import org.springframework.core.annotation.Order; import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.core.env.MapPropertySource; import org.springframework.core.env.SimpleCommandLinePropertySource; From a47081cb76037532c30c31d29ee0be22f06fc2ea Mon Sep 17 00:00:00 2001 From: Zihlu Wang Date: Sun, 10 Sep 2023 13:19:26 +0800 Subject: [PATCH 12/27] refactor(property-guard): Remove useless imports. --- .../propertyguard/autoconfiguration/PropertyGuard.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/property-guard-spring-boot-starter/src/main/java/cn/org/codecrafters/propertyguard/autoconfiguration/PropertyGuard.java b/property-guard-spring-boot-starter/src/main/java/cn/org/codecrafters/propertyguard/autoconfiguration/PropertyGuard.java index 100f93e..e02b6b1 100644 --- a/property-guard-spring-boot-starter/src/main/java/cn/org/codecrafters/propertyguard/autoconfiguration/PropertyGuard.java +++ b/property-guard-spring-boot-starter/src/main/java/cn/org/codecrafters/propertyguard/autoconfiguration/PropertyGuard.java @@ -21,8 +21,6 @@ import cn.org.codecrafters.devkit.utils.AesUtil; import org.springframework.boot.SpringApplication; import org.springframework.boot.env.EnvironmentPostProcessor; import org.springframework.boot.env.OriginTrackedMapPropertySource; -import org.springframework.core.Ordered; -import org.springframework.core.annotation.Order; import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.core.env.MapPropertySource; import org.springframework.core.env.SimpleCommandLinePropertySource; From aa2a18268ff2bb382e23e9b1465b21bf344b5968 Mon Sep 17 00:00:00 2001 From: Zihlu Wang Date: Sun, 10 Sep 2023 13:19:26 +0800 Subject: [PATCH 13/27] refactor(property-guard): Remove useless imports. Close #13 --- .../propertyguard/autoconfiguration/PropertyGuard.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/property-guard-spring-boot-starter/src/main/java/cn/org/codecrafters/propertyguard/autoconfiguration/PropertyGuard.java b/property-guard-spring-boot-starter/src/main/java/cn/org/codecrafters/propertyguard/autoconfiguration/PropertyGuard.java index 100f93e..e02b6b1 100644 --- a/property-guard-spring-boot-starter/src/main/java/cn/org/codecrafters/propertyguard/autoconfiguration/PropertyGuard.java +++ b/property-guard-spring-boot-starter/src/main/java/cn/org/codecrafters/propertyguard/autoconfiguration/PropertyGuard.java @@ -21,8 +21,6 @@ import cn.org.codecrafters.devkit.utils.AesUtil; import org.springframework.boot.SpringApplication; import org.springframework.boot.env.EnvironmentPostProcessor; import org.springframework.boot.env.OriginTrackedMapPropertySource; -import org.springframework.core.Ordered; -import org.springframework.core.annotation.Order; import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.core.env.MapPropertySource; import org.springframework.core.env.SimpleCommandLinePropertySource; From c9735c52901d4765289698b95b0f8e423168c3e0 Mon Sep 17 00:00:00 2001 From: Zihlu Wang Date: Tue, 12 Sep 2023 08:35:35 +0800 Subject: [PATCH 14/27] refactor(property-guard): Changed encryption mark from "pe:" to "pg:" BREAKING CHANGE: Changed the encryption mark from "pe:" to "pg:", this version is not compatable with v1.1.0-alpha --- .../propertyguard/autoconfiguration/PropertyGuard.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/property-guard-spring-boot-starter/src/main/java/cn/org/codecrafters/propertyguard/autoconfiguration/PropertyGuard.java b/property-guard-spring-boot-starter/src/main/java/cn/org/codecrafters/propertyguard/autoconfiguration/PropertyGuard.java index e02b6b1..a5059d6 100644 --- a/property-guard-spring-boot-starter/src/main/java/cn/org/codecrafters/propertyguard/autoconfiguration/PropertyGuard.java +++ b/property-guard-spring-boot-starter/src/main/java/cn/org/codecrafters/propertyguard/autoconfiguration/PropertyGuard.java @@ -45,18 +45,22 @@ import java.util.Optional; * app.example-properties=Sample Value * * # encrypted with key 3856faef0d2d4f33 - * app.example-properties=pe:t4YBfv8M9ZmTzWgTi2gJqg== + * app.example-properties=pg:t4YBfv8M9ZmTzWgTi2gJqg== * * Then, add the command line arguments like {@code --pe.key=3856faef0d2d4f33}. *

* This class is extracted from MyBatis-Plus. + *

+ * The prefix to specify the encrypted value is {@code pg}. * * @author hubin@baomidou * @see org.springframework.boot.env.EnvironmentPostProcessor */ public class PropertyGuard implements EnvironmentPostProcessor { + private final String PREFIX = "pg"; + /** * Process the encryption environment variables. * @@ -69,7 +73,7 @@ public class PropertyGuard implements EnvironmentPostProcessor { var encryptionKey = ""; for (var ps : environment.getPropertySources()) { if (ps instanceof SimpleCommandLinePropertySource source) { - encryptionKey = source.getProperty("pe.key"); + encryptionKey = source.getProperty("%s.key".formatted(PREFIX)); break; } } @@ -80,7 +84,7 @@ public class PropertyGuard implements EnvironmentPostProcessor { if (propertySources instanceof OriginTrackedMapPropertySource source) { for (var name : source.getPropertyNames()) { if (source.getProperty(name) instanceof String str) { - if (str.startsWith("pe:")) { + if (str.startsWith("%s:".formatted(PREFIX))) { map.put(name, AesUtil.decrypt(str.substring(3), encryptionKey)); } } From 07e7e2d4fa75e5194242843e46aedea4ff52209e Mon Sep 17 00:00:00 2001 From: Zihlu Wang Date: Tue, 12 Sep 2023 08:36:01 +0800 Subject: [PATCH 15/27] build(global): Upgrade to v1.1.0-aloha1 --- devkit-core/pom.xml | 2 +- devkit-utils/pom.xml | 2 +- guid/pom.xml | 2 +- pom.xml | 2 +- property-guard-spring-boot-starter/pom.xml | 2 +- simple-jwt-authzero/pom.xml | 2 +- simple-jwt-facade/pom.xml | 2 +- simple-jwt-jjwt/pom.xml | 2 +- simple-jwt-spring-boot-starter/pom.xml | 2 +- webcal/pom.xml | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/devkit-core/pom.xml b/devkit-core/pom.xml index 66d3d02..2452ae8 100644 --- a/devkit-core/pom.xml +++ b/devkit-core/pom.xml @@ -23,7 +23,7 @@ cn.org.codecrafters jdevkit - 1.1.0-alpha + 1.1.0-alpha1 devkit-core diff --git a/devkit-utils/pom.xml b/devkit-utils/pom.xml index 882de50..bd7e1cd 100644 --- a/devkit-utils/pom.xml +++ b/devkit-utils/pom.xml @@ -6,7 +6,7 @@ cn.org.codecrafters jdevkit - 1.1.0-alpha + 1.1.0-alpha1 devkit-utils diff --git a/guid/pom.xml b/guid/pom.xml index 2503160..831d32e 100644 --- a/guid/pom.xml +++ b/guid/pom.xml @@ -23,7 +23,7 @@ cn.org.codecrafters jdevkit - 1.1.0-alpha + 1.1.0-alpha1 guid diff --git a/pom.xml b/pom.xml index 0d5c10a..74a7338 100644 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,7 @@ cn.org.codecrafters jdevkit - 1.1.0-alpha + 1.1.0-alpha1 2023 pom diff --git a/property-guard-spring-boot-starter/pom.xml b/property-guard-spring-boot-starter/pom.xml index 7273c41..76905b7 100644 --- a/property-guard-spring-boot-starter/pom.xml +++ b/property-guard-spring-boot-starter/pom.xml @@ -23,7 +23,7 @@ cn.org.codecrafters jdevkit - 1.1.0-alpha + 1.1.0-alpha1 property-guard-spring-boot-starter diff --git a/simple-jwt-authzero/pom.xml b/simple-jwt-authzero/pom.xml index 3f9ed61..82f8683 100644 --- a/simple-jwt-authzero/pom.xml +++ b/simple-jwt-authzero/pom.xml @@ -23,7 +23,7 @@ cn.org.codecrafters jdevkit - 1.1.0-alpha + 1.1.0-alpha1 simple-jwt-authzero diff --git a/simple-jwt-facade/pom.xml b/simple-jwt-facade/pom.xml index 2bdc025..1a8c522 100644 --- a/simple-jwt-facade/pom.xml +++ b/simple-jwt-facade/pom.xml @@ -23,7 +23,7 @@ cn.org.codecrafters jdevkit - 1.1.0-alpha + 1.1.0-alpha1 simple-jwt-facade diff --git a/simple-jwt-jjwt/pom.xml b/simple-jwt-jjwt/pom.xml index 69cf8e6..f461278 100644 --- a/simple-jwt-jjwt/pom.xml +++ b/simple-jwt-jjwt/pom.xml @@ -23,7 +23,7 @@ cn.org.codecrafters jdevkit - 1.1.0-alpha + 1.1.0-alpha1 simple-jwt-jjwt diff --git a/simple-jwt-spring-boot-starter/pom.xml b/simple-jwt-spring-boot-starter/pom.xml index ed31d53..73e3439 100644 --- a/simple-jwt-spring-boot-starter/pom.xml +++ b/simple-jwt-spring-boot-starter/pom.xml @@ -23,7 +23,7 @@ cn.org.codecrafters jdevkit - 1.1.0-alpha + 1.1.0-alpha1 simple-jwt-spring-boot-starter diff --git a/webcal/pom.xml b/webcal/pom.xml index 99060f5..4234240 100644 --- a/webcal/pom.xml +++ b/webcal/pom.xml @@ -23,7 +23,7 @@ cn.org.codecrafters jdevkit - 1.1.0-alpha + 1.1.0-alpha1 webcal From baa91f626ad8b88a4b4b3c5a4c69c5dcd8efce3d Mon Sep 17 00:00:00 2001 From: Zihlu Wang Date: Fri, 15 Sep 2023 10:11:39 +0800 Subject: [PATCH 16/27] build(global): Upgrade to v1.1.0-beta --- devkit-core/pom.xml | 2 +- devkit-utils/pom.xml | 2 +- guid/pom.xml | 2 +- pom.xml | 2 +- property-guard-spring-boot-starter/pom.xml | 2 +- simple-jwt-authzero/pom.xml | 2 +- simple-jwt-facade/pom.xml | 2 +- simple-jwt-jjwt/pom.xml | 2 +- simple-jwt-spring-boot-starter/pom.xml | 2 +- webcal/pom.xml | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/devkit-core/pom.xml b/devkit-core/pom.xml index 2452ae8..c1eb033 100644 --- a/devkit-core/pom.xml +++ b/devkit-core/pom.xml @@ -23,7 +23,7 @@ cn.org.codecrafters jdevkit - 1.1.0-alpha1 + 1.1.0-beta devkit-core diff --git a/devkit-utils/pom.xml b/devkit-utils/pom.xml index bd7e1cd..59de641 100644 --- a/devkit-utils/pom.xml +++ b/devkit-utils/pom.xml @@ -6,7 +6,7 @@ cn.org.codecrafters jdevkit - 1.1.0-alpha1 + 1.1.0-beta devkit-utils diff --git a/guid/pom.xml b/guid/pom.xml index 831d32e..6ef8761 100644 --- a/guid/pom.xml +++ b/guid/pom.xml @@ -23,7 +23,7 @@ cn.org.codecrafters jdevkit - 1.1.0-alpha1 + 1.1.0-beta guid diff --git a/pom.xml b/pom.xml index 74a7338..527ad26 100644 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,7 @@ cn.org.codecrafters jdevkit - 1.1.0-alpha1 + 1.1.0-beta 2023 pom diff --git a/property-guard-spring-boot-starter/pom.xml b/property-guard-spring-boot-starter/pom.xml index 76905b7..6abbc24 100644 --- a/property-guard-spring-boot-starter/pom.xml +++ b/property-guard-spring-boot-starter/pom.xml @@ -23,7 +23,7 @@ cn.org.codecrafters jdevkit - 1.1.0-alpha1 + 1.1.0-beta property-guard-spring-boot-starter diff --git a/simple-jwt-authzero/pom.xml b/simple-jwt-authzero/pom.xml index 82f8683..abebd27 100644 --- a/simple-jwt-authzero/pom.xml +++ b/simple-jwt-authzero/pom.xml @@ -23,7 +23,7 @@ cn.org.codecrafters jdevkit - 1.1.0-alpha1 + 1.1.0-beta simple-jwt-authzero diff --git a/simple-jwt-facade/pom.xml b/simple-jwt-facade/pom.xml index 1a8c522..12f9274 100644 --- a/simple-jwt-facade/pom.xml +++ b/simple-jwt-facade/pom.xml @@ -23,7 +23,7 @@ cn.org.codecrafters jdevkit - 1.1.0-alpha1 + 1.1.0-beta simple-jwt-facade diff --git a/simple-jwt-jjwt/pom.xml b/simple-jwt-jjwt/pom.xml index f461278..d766a70 100644 --- a/simple-jwt-jjwt/pom.xml +++ b/simple-jwt-jjwt/pom.xml @@ -23,7 +23,7 @@ cn.org.codecrafters jdevkit - 1.1.0-alpha1 + 1.1.0-beta simple-jwt-jjwt diff --git a/simple-jwt-spring-boot-starter/pom.xml b/simple-jwt-spring-boot-starter/pom.xml index 73e3439..5bfb7ad 100644 --- a/simple-jwt-spring-boot-starter/pom.xml +++ b/simple-jwt-spring-boot-starter/pom.xml @@ -23,7 +23,7 @@ cn.org.codecrafters jdevkit - 1.1.0-alpha1 + 1.1.0-beta simple-jwt-spring-boot-starter diff --git a/webcal/pom.xml b/webcal/pom.xml index 4234240..4bb62a6 100644 --- a/webcal/pom.xml +++ b/webcal/pom.xml @@ -23,7 +23,7 @@ cn.org.codecrafters jdevkit - 1.1.0-alpha1 + 1.1.0-beta webcal From 6549373e8d172a69f0861b2331911641541d4250 Mon Sep 17 00:00:00 2001 From: Zihlu Wang Date: Fri, 15 Sep 2023 15:36:25 +0800 Subject: [PATCH 17/27] docs(global): Optimised javadocs. --- .../codecrafters/devkit/utils/AesUtil.java | 1 + .../codecrafters/devkit/utils/Base64Util.java | 7 +- .../codecrafters/devkit/utils/BranchUtil.java | 21 ++--- .../devkit/utils/ChainedCalcUtil.java | 26 ++---- .../codecrafters/devkit/utils/HashUtil.java | 6 +- .../codecrafters/devkit/utils/MapUtil.java | 6 +- .../cn/org/codecrafters/guid/GuidCreator.java | 5 +- .../guid/SnowflakeGuidCreator.java | 5 +- .../guid/exceptions/TimingException.java | 5 -- .../guid/exceptions/package-info.java | 4 - .../org/codecrafters/guid/package-info.java | 3 - .../autoconfiguration/PropertyGuard.java | 2 + .../authzero/AuthzeroTokenResolver.java | 8 +- .../config/AuthzeroTokenResolverConfig.java | 4 +- .../authzero/config/package-info.java | 5 -- .../simplejwt/authzero/package-info.java | 4 - .../codecrafters/simplejwt/SecretCreator.java | 2 +- .../codecrafters/simplejwt/TokenPayload.java | 8 +- .../codecrafters/simplejwt/TokenResolver.java | 6 +- .../annotations/ExcludeFromPayload.java | 12 +-- .../simplejwt/annotations/package-info.java | 1 - .../simplejwt/config/TokenResolverConfig.java | 2 - .../simplejwt/config/package-info.java | 2 - .../simplejwt/constants/PredefinedKeys.java | 13 +-- .../simplejwt/constants/TokenAlgorithm.java | 3 +- .../simplejwt/constants/package-info.java | 1 - .../UnsupportedAlgorithmException.java | 24 +++--- .../exceptions/WeakSecretException.java | 5 +- .../simplejwt/exceptions/package-info.java | 5 -- .../codecrafters/simplejwt/package-info.java | 5 -- .../simplejwt/jjwt/JjwtTokenResolver.java | 86 +++++++++++++++---- .../jjwt/config/JjwtTokenResolverConfig.java | 30 ++++++- .../simplejwt/jjwt/config/package-info.java | 5 -- .../simplejwt/jjwt/package-info.java | 4 - ...uthzeroTokenResolverAutoConfiguration.java | 8 +- .../GuidAutoConfiguration.java | 4 +- .../JjwtTokenResolverAutoConfiguration.java | 9 +- .../conditions/GuidCreatorCondition.java | 6 +- .../properties/SimpleJwtProperties.java | 14 ++- .../properties/package-info.java | 5 +- .../org/codecrafters/webcal/WebCalendar.java | 5 +- .../codecrafters/webcal/WebCalendarEvent.java | 2 +- .../codecrafters/webcal/WebCalendarNode.java | 2 +- .../webcal/config/Classification.java | 8 +- .../webcal/config/package-info.java | 1 - .../org/codecrafters/webcal/package-info.java | 1 - 46 files changed, 177 insertions(+), 214 deletions(-) diff --git a/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/AesUtil.java b/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/AesUtil.java index a0c916c..54a734c 100644 --- a/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/AesUtil.java +++ b/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/AesUtil.java @@ -39,6 +39,7 @@ import java.util.UUID; * * @author hubin@baomidou * @since 1.1.0 + * @version 1.1.0 */ @Slf4j public final class AesUtil { diff --git a/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/Base64Util.java b/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/Base64Util.java index e3548ab..96377d4 100644 --- a/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/Base64Util.java +++ b/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/Base64Util.java @@ -22,18 +22,15 @@ import java.nio.charset.StandardCharsets; import java.util.Base64; /** - *

* The {@code Base64Util} class provides static methods to encode and decode * strings using Base64 encoding. It utilizes the {@link Base64} class from the * Java standard library for performing the encoding and decoding operations. * This utility class offers convenient methods to encode and decode strings * with different character sets. - * *

* This class is designed as a final class with a private constructor to * prevent instantiation. All methods in this class are static, allowing easy * access to the Base64 encoding and decoding functionality. - * *

* Example usage: *

@@ -47,15 +44,13 @@ import java.util.Base64;
  * String decoded = Base64Util.decode(encoded);
  * System.out.println("Decoded string: " + decoded);
  * 
- * *

* Note: This utility class uses the default charset (UTF-8) if no * specific charset is provided. It is recommended to specify the charset * explicitly to ensure consistent encoding and decoding. - * * * @author Zihlu Wang - * @version 1.0.0 + * @version 1.1.0 * @since 1.0.0 */ public final class Base64Util { diff --git a/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/BranchUtil.java b/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/BranchUtil.java index 6e242b1..288f2f4 100644 --- a/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/BranchUtil.java +++ b/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/BranchUtil.java @@ -23,19 +23,14 @@ import java.util.function.BooleanSupplier; import java.util.function.Supplier; /** - *

* The BranchUtil class provides static methods to simplify conditional logic * in Java development by leveraging lambda expressions. It offers convenient * methods to replace verbose if...else statements with more concise and * expressive functional constructs. - * - * *

* Developers can use the methods in this utility class to streamline their * code, enhance readability, and promote a more functional style of * programming when dealing with branching logic and conditional statements. - * - * *

* Example: *

@@ -67,7 +62,6 @@ import java.util.function.Supplier;
  *         // do something
  *     });
  * 
- * *

* Note: * The {@link #and(Boolean...)} and {@link #or(Boolean...)} methods accept any @@ -75,7 +69,7 @@ import java.util.function.Supplier; * * @param the type of the result to be handled by the methods * @author Zihlu Wang - * @version 1.0.0 + * @version 1.1.0 * @see java.util.function.Supplier * @see java.util.function.BooleanSupplier * @see java.lang.Runnable @@ -164,15 +158,12 @@ public final class BranchUtil { } /** - *

* Handles the result of the boolean expressions by executing the * appropriate handler based on the result. - * *

* If the result is {@code true}, the {@code ifHandler} is executed. If the * result is {@code false} and an {@code elseHandler} is provided, it is * executed. - * *

* Returns the result of the executed handler. * @@ -181,7 +172,8 @@ public final class BranchUtil { * @param elseHandler the handler to be executed if the result is * {@code false} (optional) * @return the result of the executed handler, or {@code null} if no - * {@code elseHandler} is provided + * {@code elseHandler} is provided and the result of the evaluation is + * {@code false} */ public T handle(Supplier ifHandler, Supplier elseHandler) { if (this.result && Objects.nonNull(ifHandler)) { @@ -196,26 +188,23 @@ public final class BranchUtil { } /** - *

* Handles the result of the boolean expressions by executing the provided * handler if the result is {@code true}. - * *

* Returns the result of the executed handler. * * @param ifHandler the handler to be executed if the result is * {@code true} - * @return the result of the executed handler + * @return the result of the executed handler, or {@code null} if result of + * evaluation is {@code false} */ public T handle(Supplier ifHandler) { return handle(ifHandler, null); } /** - *

* Handles the result of the boolean expressions by executing the * appropriate handler based on the result. - * *

* If the result is {@code true}, the {@code ifHandler} is executed. If the * result is {@code false} and an {@code elseHandler} is provided, it is diff --git a/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/ChainedCalcUtil.java b/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/ChainedCalcUtil.java index 5817d88..98d69bf 100644 --- a/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/ChainedCalcUtil.java +++ b/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/ChainedCalcUtil.java @@ -17,6 +17,8 @@ package cn.org.codecrafters.devkit.utils; +import lombok.Getter; + import java.math.BigDecimal; import java.math.RoundingMode; import java.util.Objects; @@ -24,10 +26,7 @@ import java.util.function.BiFunction; import java.util.function.Function; /** - *

* Utility class for chained high-precision calculations using BigDecimal. - * - * *

* The ChainedCalcUtil class provides a convenient way to perform chained * high-precision calculations using BigDecimal. It allows users to perform @@ -35,8 +34,6 @@ import java.util.function.Function; * and division with customizable precision and scale. By using this utility * class, developers can achieve accurate results and avoid precision loss * in their calculations. - * - * *

* Usage: *

@@ -85,7 +82,6 @@ import java.util.function.Function;
  *  
* The above expressions perform various mathematical calculations using the * ChainedCalcUtil class. - * *

* Note: * The ChainedCalcUtil class internally uses BigDecimal to handle @@ -94,12 +90,17 @@ import java.util.function.Function; * for extremely large numbers or complex calculations. * * @author sunzsh - * @version 1.0.0 + * @version 1.1.0 * @see java.math.BigDecimal - * @since 9 Jul 2023 + * @since 1.0.0 */ +@Getter public final class ChainedCalcUtil { + /** + * -- GETTER -- + * Returns the current value as a BigDecimal. + */ private BigDecimal value; /** @@ -234,15 +235,6 @@ public final class ChainedCalcUtil { return baseOperator(otherValue -> this.value.divide(otherValue, scale, RoundingMode.HALF_UP), other, beforeOperateScale); } - /** - * Returns the current value as a BigDecimal. - * - * @return the current value as a BigDecimal - */ - public BigDecimal getValue() { - return value; - } - /** * Returns the current value as a BigDecimal with the specified scale. * diff --git a/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/HashUtil.java b/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/HashUtil.java index 37bb01b..bd33926 100644 --- a/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/HashUtil.java +++ b/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/HashUtil.java @@ -25,15 +25,12 @@ import java.util.Objects; import java.util.Optional; /** - *

* Utility class for performing hash operations on strings. - * *

* The HashUtil class provides convenient methods for calculating various hash * functions on strings, including MD2, MD5, SHA-1, SHA-224, SHA-256, SHA-384, * and SHA-512. It allows developers to easily obtain the hash value of a given * string using different algorithms. - * *

* Example usage: *

@@ -60,7 +57,6 @@ import java.util.Optional;
  * 
* The above examples demonstrate how to use the HashUtil class to calculate * hash values for a given string using different algorithms. - * *

* Note: * The hash functions provided by the HashUtil class are one-way hash @@ -69,7 +65,7 @@ import java.util.Optional; * password storage, but they should not be used for encryption purposes. * * @author Zihlu Wang - * @version 1.0.0 + * @version 1.1.0 * @see java.security.MessageDigest * @since 1.0.0 */ diff --git a/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/MapUtil.java b/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/MapUtil.java index 3d2cf36..d6e7644 100644 --- a/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/MapUtil.java +++ b/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/MapUtil.java @@ -24,17 +24,15 @@ import java.util.HashMap; import java.util.Map; /** - *

* MapUtil is a utility class that provides methods for converting objects to * maps and maps to objects. - * *

* It also provides methods for getting and setting field values using * reflection. * * @author Zihlu Wang - * @version 1.0.0 - * @since 16 Jul 2023 + * @version 1.1.0 + * @since 1.0.0 */ @Slf4j public final class MapUtil { diff --git a/guid/src/main/java/cn/org/codecrafters/guid/GuidCreator.java b/guid/src/main/java/cn/org/codecrafters/guid/GuidCreator.java index 8631876..8208b26 100644 --- a/guid/src/main/java/cn/org/codecrafters/guid/GuidCreator.java +++ b/guid/src/main/java/cn/org/codecrafters/guid/GuidCreator.java @@ -18,17 +18,14 @@ package cn.org.codecrafters.guid; /** - *

* The {@code GuidCreator} 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. - * * * @param this represents the type of the Global Unique Identifier * @author Zihlu Wang - * @version 1.0.0 + * @version 1.1.0 * @since 1.0.0 */ public interface GuidCreator { diff --git a/guid/src/main/java/cn/org/codecrafters/guid/SnowflakeGuidCreator.java b/guid/src/main/java/cn/org/codecrafters/guid/SnowflakeGuidCreator.java index 878575f..9600b51 100644 --- a/guid/src/main/java/cn/org/codecrafters/guid/SnowflakeGuidCreator.java +++ b/guid/src/main/java/cn/org/codecrafters/guid/SnowflakeGuidCreator.java @@ -23,9 +23,7 @@ import java.time.LocalDateTime; import java.time.ZoneOffset; /** - *

* SnowflakeGuidCreator - GUID generator based on the Snowflake algorithm. - * *

* The SnowflakeGuidCreator generates unique identifiers using the Snowflake * algorithm, which combines a timestamp, worker ID, and data center ID to @@ -38,7 +36,6 @@ import java.time.ZoneOffset; *

  • 5 bits for worker ID
  • *
  • 12 bits for sequence number (per millisecond)
  • * - * *

    * When initializing the SnowflakeGuidCreator, you must provide the worker ID * and data center ID, ensuring they are within the valid range defined by the @@ -48,7 +45,7 @@ import java.time.ZoneOffset; * repeated timestamps. * * @author Zihlu Wang - * @version 1.0.0 + * @version 1.1.0 * @since 1.0.0 */ public final class SnowflakeGuidCreator implements GuidCreator { diff --git a/guid/src/main/java/cn/org/codecrafters/guid/exceptions/TimingException.java b/guid/src/main/java/cn/org/codecrafters/guid/exceptions/TimingException.java index 08c446c..952213b 100644 --- a/guid/src/main/java/cn/org/codecrafters/guid/exceptions/TimingException.java +++ b/guid/src/main/java/cn/org/codecrafters/guid/exceptions/TimingException.java @@ -18,27 +18,22 @@ package cn.org.codecrafters.guid.exceptions; /** - *

    * The TimingException class represents an exception that is thrown when there * is an error related to time sequence. - * *

    * This class extends the RuntimeException class, which means that instances of * TimingException do not need to be declared in a method or constructor's * throws clause. - * *

    * Instances of TimingException can be created with or without a message and a * cause. The message provides a description of the exception, while the cause * represents the underlying cause of the exception and provides additional * information about the error. - * *

    * TimingException is typically used to handle exceptions related to timing, * such as timeouts or synchronization issues. It is a subclass of * RuntimeException, which means it is an unchecked exception and does not need * to be caught or declared. - * * * @author Zihlu Wang * @since 1.0.0 diff --git a/guid/src/main/java/cn/org/codecrafters/guid/exceptions/package-info.java b/guid/src/main/java/cn/org/codecrafters/guid/exceptions/package-info.java index 565cad2..e12ea58 100644 --- a/guid/src/main/java/cn/org/codecrafters/guid/exceptions/package-info.java +++ b/guid/src/main/java/cn/org/codecrafters/guid/exceptions/package-info.java @@ -16,17 +16,14 @@ */ /** - *

    * This package contains the custom exception classes related to GUID * generation. These exceptions are thrown when there are issues or errors * during the generation or processing of global unique identifiers (GUIDs). - * *

    * The main exception class in this package is {@link * cn.org.codecrafters.guid.exceptions.TimingException}, which is a runtime * exception and serves as the base exception for all other custom exceptions * related to GUID generation. - * *

    * Custom exceptions in this package provide specific information about the * type of error that occurred during GUID generation, making it easier for @@ -34,7 +31,6 @@ * GUIDs. They are designed to enhance the robustness and reliability of the * GUID generation process by providing clear and meaningful error messages to * the developers. - * *

    * Developers using the GUID generation module should be aware of the possible * exceptions that can be thrown and handle them appropriately to ensure smooth diff --git a/guid/src/main/java/cn/org/codecrafters/guid/package-info.java b/guid/src/main/java/cn/org/codecrafters/guid/package-info.java index 8e7f31a..a9e9def 100644 --- a/guid/src/main/java/cn/org/codecrafters/guid/package-info.java +++ b/guid/src/main/java/cn/org/codecrafters/guid/package-info.java @@ -16,15 +16,12 @@ */ /** - *

    * The package provides a set of tools for generating globally unique * identifiers (GUIDs). - * *

    * The goal of this library is to provide an efficient, reliable way to * generate globally unique identifiers without requiring any specific * environment or configuration. - * *

    * Key features include: *

      diff --git a/property-guard-spring-boot-starter/src/main/java/cn/org/codecrafters/propertyguard/autoconfiguration/PropertyGuard.java b/property-guard-spring-boot-starter/src/main/java/cn/org/codecrafters/propertyguard/autoconfiguration/PropertyGuard.java index a5059d6..776cbdc 100644 --- a/property-guard-spring-boot-starter/src/main/java/cn/org/codecrafters/propertyguard/autoconfiguration/PropertyGuard.java +++ b/property-guard-spring-boot-starter/src/main/java/cn/org/codecrafters/propertyguard/autoconfiguration/PropertyGuard.java @@ -55,7 +55,9 @@ import java.util.Optional; * The prefix to specify the encrypted value is {@code pg}. * * @author hubin@baomidou + * @version 1.1.0 * @see org.springframework.boot.env.EnvironmentPostProcessor + * @since 1.1.0 (3.3.2 of MyBatis-Plus) */ public class PropertyGuard implements EnvironmentPostProcessor { diff --git a/simple-jwt-authzero/src/main/java/cn/org/codecrafters/simplejwt/authzero/AuthzeroTokenResolver.java b/simple-jwt-authzero/src/main/java/cn/org/codecrafters/simplejwt/authzero/AuthzeroTokenResolver.java index ad6b658..653fd3b 100644 --- a/simple-jwt-authzero/src/main/java/cn/org/codecrafters/simplejwt/authzero/AuthzeroTokenResolver.java +++ b/simple-jwt-authzero/src/main/java/cn/org/codecrafters/simplejwt/authzero/AuthzeroTokenResolver.java @@ -39,19 +39,16 @@ import java.time.ZoneId; import java.util.*; /** - *

      * The {@code AuthzeroTokenResolver} class is an implementation of the {@link * cn.org.codecrafters.simplejwt.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. - * *

      * Dependencies: * This implementation relies on the {@code com.auth0:java-jwt} library. Please * ensure you have added this library as a dependency to your project before * using this resolver. - * *

      * Usage: * To use the {@code AuthzeroTokenResolver}, first, create an instance of this @@ -63,11 +60,9 @@ import java.util.*; * "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 =
      @@ -84,7 +79,6 @@ import java.util.*;
        * String renewedToken =
        *     tokenResolver.renew(token, Duration.ofMinutes(30), customPayloads);
        * }
      - * *

      * Note: * It is essential to configure the appropriate algorithms, secret, and issuer @@ -93,7 +87,7 @@ import java.util.*; * correctly configured in your project's dependencies. * * @author Zihlu Wang - * @version 1.0.0 + * @version 1.1.0 * @see GuidCreator * @see Algorithm * @see JWTVerifier diff --git a/simple-jwt-authzero/src/main/java/cn/org/codecrafters/simplejwt/authzero/config/AuthzeroTokenResolverConfig.java b/simple-jwt-authzero/src/main/java/cn/org/codecrafters/simplejwt/authzero/config/AuthzeroTokenResolverConfig.java index 80403c6..9377571 100644 --- a/simple-jwt-authzero/src/main/java/cn/org/codecrafters/simplejwt/authzero/config/AuthzeroTokenResolverConfig.java +++ b/simple-jwt-authzero/src/main/java/cn/org/codecrafters/simplejwt/authzero/config/AuthzeroTokenResolverConfig.java @@ -37,7 +37,6 @@ import java.util.function.Function; * the specific algorithms used by the Auth0 Java JWT library, which is the * underlying library used by AuthzeroTokenResolver to handle JSON Web Tokens * (JWTs). - * *

      * Algorithm Mapping: * The AuthzeroTokenResolverConfig class allows specifying the relationship @@ -47,7 +46,6 @@ import java.util.function.Function; * keys are the standard TokenAlgorithm instances, and the values represent the * algorithm functions used by Auth0 Java JWT library for each corresponding * key. - * *

      * Note: * The provided algorithm mapping should be consistent with the actual @@ -56,7 +54,7 @@ import java.util.function.Function; * and processing within the AuthzeroTokenResolver. * * @author Zihlu Wang - * @version 1.0.0 + * @version 1.1.0 * @since 1.0.0 */ public final class AuthzeroTokenResolverConfig implements TokenResolverConfig> { diff --git a/simple-jwt-authzero/src/main/java/cn/org/codecrafters/simplejwt/authzero/config/package-info.java b/simple-jwt-authzero/src/main/java/cn/org/codecrafters/simplejwt/authzero/config/package-info.java index 19f0774..5f3abd7 100644 --- a/simple-jwt-authzero/src/main/java/cn/org/codecrafters/simplejwt/authzero/config/package-info.java +++ b/simple-jwt-authzero/src/main/java/cn/org/codecrafters/simplejwt/authzero/config/package-info.java @@ -16,17 +16,14 @@ */ /** - *

      * The package {@code cn.org.codecrafters.simplejwt.authzero.config} contains * configuration classes related to the {@link * cn.org.codecrafters.simplejwt.authzero.AuthzeroTokenResolver} * implementation. - * *

      * The classes in this package provide configuration options and settings for * the {@link cn.org.codecrafters.simplejwt.authzero.AuthzeroTokenResolver}, * which is used for resolving JSON Web Tokens (JWT) using the Auth0 library. - * *

      * The {@link * cn.org.codecrafters.simplejwt.authzero.config.AuthzeroTokenResolverConfig} @@ -37,7 +34,6 @@ * JWT algorithms. It enables developers to specify and customize the * algorithm functions according to the chosen JWT algorithm and the library * being used. - * *

      * The configuration options in this package help developers integrate and * configure the {@link @@ -45,7 +41,6 @@ * into their Spring Boot applications. Developers can fine-tune the token * resolution process and customize algorithm handling to align with their * specific requirements and desired level of security. - * *

      * It is recommended to explore the classes in this package to understand how * to configure and use the {@link diff --git a/simple-jwt-authzero/src/main/java/cn/org/codecrafters/simplejwt/authzero/package-info.java b/simple-jwt-authzero/src/main/java/cn/org/codecrafters/simplejwt/authzero/package-info.java index c8e75cb..c99a3dd 100644 --- a/simple-jwt-authzero/src/main/java/cn/org/codecrafters/simplejwt/authzero/package-info.java +++ b/simple-jwt-authzero/src/main/java/cn/org/codecrafters/simplejwt/authzero/package-info.java @@ -23,7 +23,6 @@ * solutions for web and mobile applications. The classes in this package * provide the necessary functionality to handle JSON Web Tokens (JWTs) using * the {@code com.auth0:java-jwt} library. - * *

      * The main class in this package is the {@link * cn.org.codecrafters.simplejwt.authzero.AuthzeroTokenResolver}, which @@ -33,14 +32,12 @@ * {@code com.auth0:java-jwt} library. Developers can use this class as the * main token resolver in the Simple JWT project when integrating {@code * com.auth0:java-jwt} as the JWT management library. - * *

      * The {@code AuthzeroTokenResolver} relies on the {@code com.auth0:java-jwt} * library to handle the underlying JWT operations, including token creation, * validation, and extraction. It utilizes the {@code com.auth0:java-jwt} * {@code Algorithm} class to define and use different algorithms for JWT * signing and verification. - * *

      * To use the {@code AuthzeroTokenResolver}, developers must provide the * necessary configurations and dependencies, such as the {@code GuidCreator} @@ -48,7 +45,6 @@ * issuer name, and the secret key used for token signing and validation. The * {@code AuthzeroTokenResolverConfig} class provides a convenient way to * configure these dependencies. - * *

      * Developers using the {@code com.auth0:java-jwt} integration should be * familiar with the concepts and usage of the {@code com.auth0:java-jwt} diff --git a/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/SecretCreator.java b/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/SecretCreator.java index 23b064c..de06136 100644 --- a/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/SecretCreator.java +++ b/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/SecretCreator.java @@ -27,7 +27,7 @@ import java.util.Random; * passwords for various security-sensitive purposes. * * @author Zihlu Wang - * @version 1.0.0 + * @version 1.1.0 * @since 1.0.0 */ public final class SecretCreator { diff --git a/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/TokenPayload.java b/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/TokenPayload.java index a7b5d0c..e69a480 100644 --- a/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/TokenPayload.java +++ b/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/TokenPayload.java @@ -22,19 +22,19 @@ import java.util.Map; /** *

      * TokenPayload - Interface for JWT Payload Data Classes. - * + * *

      * The {@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} @@ -45,8 +45,8 @@ import java.util.Map; * } * * + * @version 1.1.0 * @since 1.0.0 - * @version 1.0.0 */ public interface TokenPayload { diff --git a/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/TokenResolver.java b/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/TokenResolver.java index 65189d3..17fcce4 100644 --- a/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/TokenResolver.java +++ b/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/TokenResolver.java @@ -22,25 +22,21 @@ import java.time.Duration; import java.util.Map; /** - *

      * The {@code TokenResolver} interface 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 @@ -50,7 +46,7 @@ import java.util.Map; * @param the type of the result obtained by the * third-party library when parsing JWTs * @author Zihlu Wang - * @version 1.0.0 + * @version 1.1.0 * @since 1.0.0 */ public interface TokenResolver { diff --git a/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/annotations/ExcludeFromPayload.java b/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/annotations/ExcludeFromPayload.java index 26fe1bd..2aa1450 100644 --- a/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/annotations/ExcludeFromPayload.java +++ b/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/annotations/ExcludeFromPayload.java @@ -28,9 +28,8 @@ import java.lang.annotation.Target; * excluded from being automatically injected into the JSON Web Token (JWT) * payload during token generation. When a property is annotated with this * annotation, it will not be included as part of the JWT payload. - * - * - *

      Usage: + *

      + * Usage: * To exclude a property from the JWT payload, annotate the property with * {@code @ExcludeFromPayload}: * @@ -45,14 +44,15 @@ import java.lang.annotation.Target; * // Getters and setters... * } * } - * - *

      Note: + *

      + * Note: * This annotation should be used only on properties that are not intended to * be included in the JWT payload due to their sensitive nature or for other * reasons. It is important to carefully choose which properties are excluded * from the payload to ensure the JWT remains secure and efficient. * - * @version 1.0.0 + * @author Zihlu Wang + * @version 1.1.0 * @since 1.0.0 */ @Retention(RetentionPolicy.RUNTIME) diff --git a/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/annotations/package-info.java b/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/annotations/package-info.java index 86f3e22..0aca24d 100644 --- a/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/annotations/package-info.java +++ b/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/annotations/package-info.java @@ -22,7 +22,6 @@ * properties of a data class to exclude them from being included as part * of the JWT payload. * - * @version 1.0.0 * @since 1.0.0 */ package cn.org.codecrafters.simplejwt.annotations; \ No newline at end of file diff --git a/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/config/TokenResolverConfig.java b/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/config/TokenResolverConfig.java index 619b0c9..da64e21 100644 --- a/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/config/TokenResolverConfig.java +++ b/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/config/TokenResolverConfig.java @@ -20,10 +20,8 @@ package cn.org.codecrafters.simplejwt.config; import cn.org.codecrafters.simplejwt.constants.TokenAlgorithm; /** - *

      * The TokenResolverConfig interface provides a mechanism to configure a * TokenResolver with algorithm functions. - * *

      * This generic interface is used to define the configuration details for a * TokenResolver that utilizes algorithm functions. The interface allows for diff --git a/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/config/package-info.java b/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/config/package-info.java index 2b30c2d..1a8784c 100644 --- a/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/config/package-info.java +++ b/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/config/package-info.java @@ -16,12 +16,10 @@ */ /** - *

      * The classes in this package provide configuration options and settings for * the Simple JWT library. They are used to customize the behavior of the * library and allow developers to fine-tune various aspects of JWT generation * and validation. - * *

      * Other configuration classes may be added in the future to support additional * customization options and features. Developers using the Simple JWT library diff --git a/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/constants/PredefinedKeys.java b/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/constants/PredefinedKeys.java index c648b19..467869b 100644 --- a/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/constants/PredefinedKeys.java +++ b/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/constants/PredefinedKeys.java @@ -23,8 +23,8 @@ 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: + *

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

        *
      • {@link #ISSUER}: Represents the "iss" (Issuer) claim.
      • *
      • {@link #SUBJECT}: Represents the "sub" (Subject) claim.
      • @@ -34,13 +34,14 @@ import java.util.List; *
      • {@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 + *

      + * 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 + *

      + * Note: This class is final and cannot be instantiated. It only serves as a utility class to hold the standard JWT * claim constants. * + * @version 1.1.0 * @since 1.0.0 */ public final class PredefinedKeys { diff --git a/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/constants/TokenAlgorithm.java b/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/constants/TokenAlgorithm.java index 5b71e16..c790306 100644 --- a/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/constants/TokenAlgorithm.java +++ b/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/constants/TokenAlgorithm.java @@ -25,7 +25,6 @@ import lombok.Getter; * 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: * This enum includes the following supported algorithms: *

        @@ -40,7 +39,7 @@ import lombok.Getter; *
      • {@link TokenAlgorithm#ES512}: ECDSA with SHA-512
      • *
      * - * @version 1.0.0 + * @version 1.1.0 * @since 1.0.0 */ @Getter diff --git a/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/constants/package-info.java b/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/constants/package-info.java index 192ea9d..2c7726e 100644 --- a/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/constants/package-info.java +++ b/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/constants/package-info.java @@ -22,6 +22,5 @@ * configuration parameters. * * @since 1.0.0 - * @version 1.0.0 */ package cn.org.codecrafters.simplejwt.constants; \ No newline at end of file diff --git a/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/exceptions/UnsupportedAlgorithmException.java b/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/exceptions/UnsupportedAlgorithmException.java index 28c35cb..1ddb111 100644 --- a/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/exceptions/UnsupportedAlgorithmException.java +++ b/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/exceptions/UnsupportedAlgorithmException.java @@ -18,15 +18,14 @@ package cn.org.codecrafters.simplejwt.exceptions; /** - *

      * This {@code UnsupportedAlgorithmException} is to indicates that the given * algorithm is not supported by TokenResolver yet. - * *

      * To support a specified algorithm, you could - * * * @author Zihlu Wang + * @version 1.1.0 + * @since 1.0.0 */ public class UnsupportedAlgorithmException extends RuntimeException { @@ -51,14 +50,12 @@ public class UnsupportedAlgorithmException extends RuntimeException { } /** - *

      * Constructs a new runtime exception with the specified detail message and * cause. - * - *

      Note that the detail message associated with + *

      + * 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). @@ -95,13 +92,12 @@ public class UnsupportedAlgorithmException extends RuntimeException { * 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 or not suppression is enabled - * or disabled - * @param writableStackTrace whether or not the stack trace should - * be writable - * @since 1.7 + * @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/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/exceptions/WeakSecretException.java b/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/exceptions/WeakSecretException.java index be78140..bc46ec6 100644 --- a/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/exceptions/WeakSecretException.java +++ b/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/exceptions/WeakSecretException.java @@ -18,9 +18,12 @@ package cn.org.codecrafters.simplejwt.exceptions; /** - * WeakSecretException + * This Exception indicates that your secret is too weak to be used in signing + * JWTs. * * @author Zihlu Wang + * @version 1.1.0 + * @since 1.0.0 */ public class WeakSecretException extends RuntimeException { diff --git a/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/exceptions/package-info.java b/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/exceptions/package-info.java index fcd7929..470140c 100644 --- a/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/exceptions/package-info.java +++ b/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/exceptions/package-info.java @@ -16,13 +16,10 @@ */ /** - *

      * The {@code cn.org.codecrafters.simplejwt.exceptions} package contains * custom exception classes related to the Simple JWT library. These * exceptions are thrown when there are issues or errors during the generation * , validation, or processing of JSON Web Tokens (JWTs) in Java applications. - * - * *

      * Custom exception classes in this package are designed to enhance the * robustness and reliability of the JWT handling process by providing clear @@ -30,8 +27,6 @@ * identify and troubleshoot issues related to JWT generation, validation, or * extraction and ensure smooth operation and error handling in their * applications. - * - * *

      * Developers using the Simple JWT library should be aware of the possible * exceptions that can be thrown and handle them appropriately to ensure secure diff --git a/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/package-info.java b/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/package-info.java index feca898..497d456 100644 --- a/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/package-info.java +++ b/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/package-info.java @@ -16,7 +16,6 @@ */ /** - *

      * The {@code cn.org.codecrafters.simplejwt} package is the core package of the * Simple JWT project, which provides a lightweight and easy-to-use library for * working with JSON Web Tokens (JWTs) in Java applications. JWT is a @@ -24,16 +23,12 @@ * used to secure web and mobile applications. This library aims to simplify * the JWT handling process and provide convenient abstractions for JWT * generation, validation, and extraction. - * - * *

      * The Simple JWT library is designed to be flexible and customizable, allowing * developers to use different algorithms, token resolvers, and token payload * classes based on their specific application requirements. It aims to * simplify the JWT handling process while maintaining security and best * practices for working with JWTs. - * - * *

      * Developers should refer to the official documentation and examples for the * Simple JWT project to understand how to use the library effectively and diff --git a/simple-jwt-jjwt/src/main/java/cn/org/codecrafters/simplejwt/jjwt/JjwtTokenResolver.java b/simple-jwt-jjwt/src/main/java/cn/org/codecrafters/simplejwt/jjwt/JjwtTokenResolver.java index f38c287..fc9f4e8 100644 --- a/simple-jwt-jjwt/src/main/java/cn/org/codecrafters/simplejwt/jjwt/JjwtTokenResolver.java +++ b/simple-jwt-jjwt/src/main/java/cn/org/codecrafters/simplejwt/jjwt/JjwtTokenResolver.java @@ -43,9 +43,61 @@ import java.util.Map; import java.util.UUID; /** - * JjwtTokenResolver + * The {@link JjwtTokenResolver} class is an implementation of the {@link + * cn.org.codecrafters.simplejwt.TokenResolver} interface. It uses the {@code + * io.jsonwebtoken:jjwt} 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. + *

      + * Dependencies: + * This implementation relies on the {@code io.jsonwebtoken:jjwt} library. Please + * ensure you have added this library as a dependency to your project before + * using this resolver. + *

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

      {@code
      + *   TokenResolver tokenResolver =
      + *       new JjwtTokenResolver(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 io.jsonwebtoken:jjwt} library is + * correctly configured in your project's dependencies. * * @author Zihlu Wang + * @version 1.1.0 + * @see Claims + * @see Jws + * @see Jwts + * @see SignatureAlgorithm + * @see Keys + * @since 1.0.0 */ @Slf4j public class JjwtTokenResolver implements TokenResolver> { @@ -67,11 +119,11 @@ public class JjwtTokenResolver implements TokenResolver> { if (secret.length() <= 32) { log.error(""" - The provided secret which owns {} characters is too weak. Please replace it with a stronger one. - """, secret.length()); + The provided secret which owns {} characters is too weak. Please replace it with a stronger one.""", + secret.length()); throw new WeakSecretException(""" - The provided secret which owns %s characters is too weak. Please replace it with a stronger one. - """.formatted(secret.length())); + The provided secret which owns %s characters is too weak. Please replace it with a stronger one.""" + .formatted(secret.length())); } this.jtiCreator = jtiCreator; @@ -86,12 +138,12 @@ public class JjwtTokenResolver implements TokenResolver> { } if (secret.length() <= 32) { - log.error(""" - The provided secret which owns {} characters is too weak. Please replace it with a stronger one. - """, secret.length()); - throw new WeakSecretException(""" - The provided secret which owns %s characters is too weak. Please replace it with a stronger one. - """.formatted(secret.length())); + log.error( + "The provided secret which owns {} characters is too weak. Please replace it with a stronger one.", + secret.length()); + throw new WeakSecretException( + "The provided secret which owns %s characters is too weak. Please replace it with a stronger one." + .formatted(secret.length())); } this.jtiCreator = UUID::randomUUID; @@ -106,12 +158,12 @@ public class JjwtTokenResolver implements TokenResolver> { } if (secret.length() <= 32) { - log.error(""" - The provided secret which owns {} characters is too weak. Please replace it with a stronger one. - """, secret.length()); - throw new WeakSecretException(""" - The provided secret which owns %s characters is too weak. Please replace it with a stronger one. - """.formatted(secret.length())); + log.error( + "The provided secret which owns {} characters is too weak. Please replace it with a stronger one.", + secret.length()); + throw new WeakSecretException( + "The provided secret which owns %s characters is too weak. Please replace it with a stronger one." + .formatted(secret.length())); } this.jtiCreator = UUID::randomUUID; diff --git a/simple-jwt-jjwt/src/main/java/cn/org/codecrafters/simplejwt/jjwt/config/JjwtTokenResolverConfig.java b/simple-jwt-jjwt/src/main/java/cn/org/codecrafters/simplejwt/jjwt/config/JjwtTokenResolverConfig.java index c0e8aa2..adf118f 100644 --- a/simple-jwt-jjwt/src/main/java/cn/org/codecrafters/simplejwt/jjwt/config/JjwtTokenResolverConfig.java +++ b/simple-jwt-jjwt/src/main/java/cn/org/codecrafters/simplejwt/jjwt/config/JjwtTokenResolverConfig.java @@ -20,19 +20,45 @@ package cn.org.codecrafters.simplejwt.jjwt.config; import cn.org.codecrafters.simplejwt.config.TokenResolverConfig; import cn.org.codecrafters.simplejwt.constants.TokenAlgorithm; import cn.org.codecrafters.simplejwt.exceptions.UnsupportedAlgorithmException; +import cn.org.codecrafters.simplejwt.jjwt.JjwtTokenResolver; import io.jsonwebtoken.SignatureAlgorithm; import java.util.HashMap; import java.util.Map; /** - * JjwtTokenResolverConfig + * The JjwtTokenResolverConfig class provides the configuration for the + * JjwtTokenResolverConfig. + *

      + * This configuration class is used to establish the mapping between the + * standard TokenAlgorithm defined within the JjwtTokenResolverConfig and + * the specific algorithms used by the {@code io.jsonwebtoken:jjwt} library, + * which is the underlying library used by JjwtTokenResolverConfig to handle + * JSON Web Tokens (JWTs). + *

      + * Algorithm Mapping: + * The JjwtTokenResolverConfig class allows specifying the relationship + * between the standard TokenAlgorithm instances supported by + * JjwtTokenResolverConfig and the corresponding algorithms used by the + * {@code io.jsonwebtoken:jjwt} library. The mapping is achieved using a Map, + * where the keys are the standard TokenAlgorithm instances, and the values + * represent the algorithm functions used by {@code io.jsonwebtoken:jjwt} + * library for each corresponding key. + *

      + * Note: + * The provided algorithm mapping should be consistent with the actual + * algorithms supported and used by the {@code io.jsonwebtoken:jjwt} library. + * It is crucial to ensure that the mapping is accurate to enable proper token + * validation and processing within the {@link JjwtTokenResolver}. * * @author Zihlu Wang + * @version 1.1.0 + * @since 1.0.0 */ public final class JjwtTokenResolverConfig implements TokenResolverConfig { - private JjwtTokenResolverConfig() {} + private JjwtTokenResolverConfig() { + } private static final Map SUPPORTED_ALGORITHMS = new HashMap<>() {{ put(TokenAlgorithm.HS256, SignatureAlgorithm.HS256); diff --git a/simple-jwt-jjwt/src/main/java/cn/org/codecrafters/simplejwt/jjwt/config/package-info.java b/simple-jwt-jjwt/src/main/java/cn/org/codecrafters/simplejwt/jjwt/config/package-info.java index 3cb9167..fdc87a0 100644 --- a/simple-jwt-jjwt/src/main/java/cn/org/codecrafters/simplejwt/jjwt/config/package-info.java +++ b/simple-jwt-jjwt/src/main/java/cn/org/codecrafters/simplejwt/jjwt/config/package-info.java @@ -16,17 +16,14 @@ */ /** - *

      * The package {@code cn.org.codecrafters.simplejwt.jjwt.config} contains * configuration classes related to the {@link * cn.org.codecrafters.simplejwt.jjwt.JjwtTokenResolver} * implementation. - * *

      * The classes in this package provide configuration options and settings for * the {@link cn.org.codecrafters.simplejwt.jjwt.JjwtTokenResolver}, * which is used for resolving JSON Web Tokens (JWT) using the Auth0 library. - * *

      * The {@link * cn.org.codecrafters.simplejwt.jjwt.config.JjwtTokenResolverConfig} @@ -37,7 +34,6 @@ * JWT algorithms. It enables developers to specify and customize the * algorithm functions according to the chosen JWT algorithm and the library * being used. - * *

      * The configuration options in this package help developers integrate and * configure the {@link @@ -45,7 +41,6 @@ * into their Spring Boot applications. Developers can fine-tune the token * resolution process and customize algorithm handling to align with their * specific requirements and desired level of security. - * *

      * It is recommended to explore the classes in this package to understand how * to configure and use the {@link diff --git a/simple-jwt-jjwt/src/main/java/cn/org/codecrafters/simplejwt/jjwt/package-info.java b/simple-jwt-jjwt/src/main/java/cn/org/codecrafters/simplejwt/jjwt/package-info.java index 88c40b7..2c31f40 100644 --- a/simple-jwt-jjwt/src/main/java/cn/org/codecrafters/simplejwt/jjwt/package-info.java +++ b/simple-jwt-jjwt/src/main/java/cn/org/codecrafters/simplejwt/jjwt/package-info.java @@ -23,7 +23,6 @@ * solutions for web and mobile applications. The classes in this package * provide the necessary functionality to handle JSON Web Tokens (JWTs) using * the {@code io.jsonwebtoken:jjwt-api} library. - * *

      * The main class in this package is the {@link * cn.org.codecrafters.simplejwt.jjwt.JjwtTokenResolver}, which @@ -33,14 +32,12 @@ * JWTs using the {@code io.jsonwebtoken:jjwt-api} library. Developers can use * this class as the main token resolver in the Simple JWT project when * integrating {@code io.jsonwebtoken:jjwt-api} as the JWT management library. - * *

      * The {@code JjwtTokenResolver} relies on the {@code io.jsonwebtoken:jjwt-api} * library to handle the underlying JWT operations, including token creation, * validation, and extraction. It utilizes the {@code io.jsonwebtoken:jjwt-api} * {@code Algorithm} class to define and use different algorithms for JWT * signing and verification. - * *

      * To use the {@code JjwtTokenResolver}, developers must provide the necessary * configurations and dependencies, such as the {@code GuidCreator} for @@ -48,7 +45,6 @@ * issuer name, and the secret key used for token signing and validation. The * {@code JjwtTokenResolverConfig} class provides a convenient way to configure * these dependencies. - * *

      * Developers using the {@code io.jsonwebtoken:jjwt-api} integration should be * familiar with the concepts and usage of the {@code io.jsonwebtoken:jjwt-api} diff --git a/simple-jwt-spring-boot-starter/src/main/java/cn/org/codecrafters/simplejwt/autoconfiguration/AuthzeroTokenResolverAutoConfiguration.java b/simple-jwt-spring-boot-starter/src/main/java/cn/org/codecrafters/simplejwt/autoconfiguration/AuthzeroTokenResolverAutoConfiguration.java index 4a1907b..a32a3e2 100644 --- a/simple-jwt-spring-boot-starter/src/main/java/cn/org/codecrafters/simplejwt/autoconfiguration/AuthzeroTokenResolverAutoConfiguration.java +++ b/simple-jwt-spring-boot-starter/src/main/java/cn/org/codecrafters/simplejwt/autoconfiguration/AuthzeroTokenResolverAutoConfiguration.java @@ -34,25 +34,21 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.DependsOn; /** - *

      * SimpleJwtAutoConfiguration 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 auto-configuration class sets up the necessary beans and components + * This autoconfiguration class sets up the necessary beans and components * required for JWT generation and validation. It automatically creates and * configures the {@link TokenResolver} 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 auto-configuration takes care of + * 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 customize the behavior of * the library by providing their own configurations and properties. - * * * @author Zihlu Wang * @version 1.0.0 diff --git a/simple-jwt-spring-boot-starter/src/main/java/cn/org/codecrafters/simplejwt/autoconfiguration/GuidAutoConfiguration.java b/simple-jwt-spring-boot-starter/src/main/java/cn/org/codecrafters/simplejwt/autoconfiguration/GuidAutoConfiguration.java index 77287e4..fbc9017 100644 --- a/simple-jwt-spring-boot-starter/src/main/java/cn/org/codecrafters/simplejwt/autoconfiguration/GuidAutoConfiguration.java +++ b/simple-jwt-spring-boot-starter/src/main/java/cn/org/codecrafters/simplejwt/autoconfiguration/GuidAutoConfiguration.java @@ -29,9 +29,11 @@ import org.springframework.context.annotation.Conditional; import java.util.UUID; /** - * GuidAutoConfiguration + * Autoconfiguration for injecting a {@code GuidCreator} for generating jwt id. * * @author Zihlu Wang + * @version 1.1.0 + * @since 1.0.0 */ @Slf4j @AutoConfiguration diff --git a/simple-jwt-spring-boot-starter/src/main/java/cn/org/codecrafters/simplejwt/autoconfiguration/JjwtTokenResolverAutoConfiguration.java b/simple-jwt-spring-boot-starter/src/main/java/cn/org/codecrafters/simplejwt/autoconfiguration/JjwtTokenResolverAutoConfiguration.java index 29d5b09..452254a 100644 --- a/simple-jwt-spring-boot-starter/src/main/java/cn/org/codecrafters/simplejwt/autoconfiguration/JjwtTokenResolverAutoConfiguration.java +++ b/simple-jwt-spring-boot-starter/src/main/java/cn/org/codecrafters/simplejwt/autoconfiguration/JjwtTokenResolverAutoConfiguration.java @@ -34,28 +34,25 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties import org.springframework.context.annotation.Bean; /** - *

      * JjwtTokenResolverAutoConfiguration is responsible for automatically * configuring the Simple JWT library with {@code io.jsonwebtoken:jjwt-api} * 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 auto-configuration class sets up the necessary beans and components + * This autoconfiguration class sets up the necessary beans and components * required for JWT generation and validation. It automatically creates and * configures the {@link TokenResolver} 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 auto-configuration takes care of + * 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 customize the behavior of * the library by providing their own configurations and properties. * * @author Zihlu Wang - * @version 1.0.0 + * @version 1.1.0 * @since 1.0.0 */ @Slf4j diff --git a/simple-jwt-spring-boot-starter/src/main/java/cn/org/codecrafters/simplejwt/autoconfiguration/conditions/GuidCreatorCondition.java b/simple-jwt-spring-boot-starter/src/main/java/cn/org/codecrafters/simplejwt/autoconfiguration/conditions/GuidCreatorCondition.java index b83e2fa..4c9ecf5 100644 --- a/simple-jwt-spring-boot-starter/src/main/java/cn/org/codecrafters/simplejwt/autoconfiguration/conditions/GuidCreatorCondition.java +++ b/simple-jwt-spring-boot-starter/src/main/java/cn/org/codecrafters/simplejwt/autoconfiguration/conditions/GuidCreatorCondition.java @@ -9,11 +9,11 @@ import org.springframework.core.type.AnnotatedTypeMetadata; import java.util.Objects; /** - * GuidCreatorCondition - *

      - * Created on 28 Aug 2023 + * The condition to create bean {@code jtiCreator}. * * @author Zihlu Wang + * @version 1.1.0 + * @since 1.0.0 */ @Slf4j public class GuidCreatorCondition implements Condition { diff --git a/simple-jwt-spring-boot-starter/src/main/java/cn/org/codecrafters/simplejwt/autoconfiguration/properties/SimpleJwtProperties.java b/simple-jwt-spring-boot-starter/src/main/java/cn/org/codecrafters/simplejwt/autoconfiguration/properties/SimpleJwtProperties.java index e176893..fab5669 100644 --- a/simple-jwt-spring-boot-starter/src/main/java/cn/org/codecrafters/simplejwt/autoconfiguration/properties/SimpleJwtProperties.java +++ b/simple-jwt-spring-boot-starter/src/main/java/cn/org/codecrafters/simplejwt/autoconfiguration/properties/SimpleJwtProperties.java @@ -24,28 +24,24 @@ import lombok.Data; import org.springframework.boot.context.properties.ConfigurationProperties; /** - *

      * {@code SimpleJwtProperties} is a configuration properties class used to * store the properties related to Simple JWT library configuration. These * properties can be configured in the application's properties file (e.g., * application.properties) with the prefix "code-crafters.simple-jwt". - * - * *

      * SimpleJwtProperties provides configuration options for the JWT algorithm, * issuer, and secret. The properties are used by the {@link - * AuthzeroTokenResolverAutoConfiguration} - * class to set up the necessary configurations for JWT generation and - * validation. - * - * + * AuthzeroTokenResolverAutoConfiguration} and {@link + * cn.org.codecrafters.simplejwt.jjwt.JjwtTokenResolver} to set up the + * necessary configurations for JWT generation and validation. *

      * Developers can customize the JWT algorithm, issuer, and secret by setting * the corresponding properties in the application's properties file. The * SimpleJwtAutoConfiguration 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 */ @Data diff --git a/simple-jwt-spring-boot-starter/src/main/java/cn/org/codecrafters/simplejwt/autoconfiguration/properties/package-info.java b/simple-jwt-spring-boot-starter/src/main/java/cn/org/codecrafters/simplejwt/autoconfiguration/properties/package-info.java index fc5a7f4..be6889c 100644 --- a/simple-jwt-spring-boot-starter/src/main/java/cn/org/codecrafters/simplejwt/autoconfiguration/properties/package-info.java +++ b/simple-jwt-spring-boot-starter/src/main/java/cn/org/codecrafters/simplejwt/autoconfiguration/properties/package-info.java @@ -16,15 +16,12 @@ */ /** - *

      * The "cn.org.codecrafters.simplejwt.autoconfiguration.properties" package * contains configuration properties classes used for Simple JWT library - * auto-configuration. These classes define the properties that can be + * autoconfiguration. These classes define the properties that can be * configured in the application's properties file (e.g., * application.properties) to customize the behavior and settings of the Simple * JWT library. - * - * *

      * Developers can customize the JWT algorithm, issuer, and secret by setting * the corresponding properties in the application's properties file with the diff --git a/webcal/src/main/java/cn/org/codecrafters/webcal/WebCalendar.java b/webcal/src/main/java/cn/org/codecrafters/webcal/WebCalendar.java index 616dc21..9174a2b 100644 --- a/webcal/src/main/java/cn/org/codecrafters/webcal/WebCalendar.java +++ b/webcal/src/main/java/cn/org/codecrafters/webcal/WebCalendar.java @@ -22,11 +22,9 @@ import java.util.List; /** * The WebCalendar class represents a web calendar in iCalendar format. - * *

      * It allows users to create and customize calendar components and events and * generate an iCalendar string containing all the calendar information. - * *

      Usage Example: *

        * WebCalendar calendar = new WebCalendar()
      @@ -39,14 +37,13 @@ import java.util.List;
        *         .addEvent(event2);
        * String iCalendarString = calendar.resolve();
        * 
      - * *

      * The WebCalendar class is designed to generate an iCalendar string conforming * to the iCalendar specification, which can be used to share calendar data * with other calendar applications or services. * * @author Zihlu Wang - * @version 1.0.0 + * @version 1.1.0 * @since 1.0.0 */ public final class WebCalendar { diff --git a/webcal/src/main/java/cn/org/codecrafters/webcal/WebCalendarEvent.java b/webcal/src/main/java/cn/org/codecrafters/webcal/WebCalendarEvent.java index e700900..23ce851 100644 --- a/webcal/src/main/java/cn/org/codecrafters/webcal/WebCalendarEvent.java +++ b/webcal/src/main/java/cn/org/codecrafters/webcal/WebCalendarEvent.java @@ -41,7 +41,7 @@ import java.util.UUID; * iCalendar content for the event. * * @author Zihlu Wang - * @version 1.0.0 + * @version 1.1.0 * @since 1.0.0 */ public final class WebCalendarEvent extends WebCalendarNode { diff --git a/webcal/src/main/java/cn/org/codecrafters/webcal/WebCalendarNode.java b/webcal/src/main/java/cn/org/codecrafters/webcal/WebCalendarNode.java index dba99b6..ed85ab0 100644 --- a/webcal/src/main/java/cn/org/codecrafters/webcal/WebCalendarNode.java +++ b/webcal/src/main/java/cn/org/codecrafters/webcal/WebCalendarNode.java @@ -35,7 +35,7 @@ import java.util.List; * component or event. * * @author Zihlu Wang - * @version 1.0.0 + * @version 1.1.0 * @since 1.0.0 */ public abstract sealed class WebCalendarNode diff --git a/webcal/src/main/java/cn/org/codecrafters/webcal/config/Classification.java b/webcal/src/main/java/cn/org/codecrafters/webcal/config/Classification.java index 6b45c5f..79a8ff1 100644 --- a/webcal/src/main/java/cn/org/codecrafters/webcal/config/Classification.java +++ b/webcal/src/main/java/cn/org/codecrafters/webcal/config/Classification.java @@ -22,7 +22,6 @@ import lombok.Getter; /** * The Classification enum represents the classification levels of calendar * content based on RFC 5545. - * *

      * Calendar events or components can be classified as one of the following * levels: @@ -42,7 +41,7 @@ import lombok.Getter; *

    * * @author Zihlu Wang - * @version 1.0.0 + * @version 1.1.0 * @since 1.0.0 */ @Getter @@ -50,7 +49,6 @@ public enum Classification { /** * Public classification level. - * *

    * Indicates that the calendar content is public and can be freely * distributed. @@ -59,7 +57,6 @@ public enum Classification { /** * Private classification level. - * *

    * Indicates that the calendar content is private and should not be shared * with others. @@ -68,7 +65,6 @@ public enum Classification { /** * Confidential classification level. - * *

    * Indicates that the calendar content is confidential and should be kept * strictly private. @@ -79,8 +75,6 @@ public enum Classification { /** * -- GETTER -- * Get the string representation of the classification level. - * - * @return the string representation of the classification level */ private final String classification; diff --git a/webcal/src/main/java/cn/org/codecrafters/webcal/config/package-info.java b/webcal/src/main/java/cn/org/codecrafters/webcal/config/package-info.java index 894709e..f0cf59d 100644 --- a/webcal/src/main/java/cn/org/codecrafters/webcal/config/package-info.java +++ b/webcal/src/main/java/cn/org/codecrafters/webcal/config/package-info.java @@ -20,7 +20,6 @@ * the configuration and settings of the web calendar module. It provides * various configurations and constants used in the generation and resolution * of iCalendar content. - * *

    The classes in this package include:

    *
      *
    • diff --git a/webcal/src/main/java/cn/org/codecrafters/webcal/package-info.java b/webcal/src/main/java/cn/org/codecrafters/webcal/package-info.java index 0091201..ce089b6 100644 --- a/webcal/src/main/java/cn/org/codecrafters/webcal/package-info.java +++ b/webcal/src/main/java/cn/org/codecrafters/webcal/package-info.java @@ -19,7 +19,6 @@ * The package {@code cn.org.codecrafters.webcal} contains classes and modules * related to web calendar generation and resolution. It provides functionality * to create and manage iCalendar content for web-based calendar applications. - * *

      * The main classes and modules in this package include: *

        From 7b653edb3baffff3340674a88b2b6459f42bf03a Mon Sep 17 00:00:00 2001 From: Zihlu Wang Date: Fri, 15 Sep 2023 15:41:23 +0800 Subject: [PATCH 18/27] docs(global): Changed spelling with BrE. --- README.md | 2 +- .../devkit/utils/ChainedCalcUtil.java | 2 +- .../guid/SnowflakeGuidCreator.java | 20 +++++++++---------- .../guid/exceptions/TimingException.java | 2 +- .../authzero/config/package-info.java | 2 +- .../simplejwt/authzero/package-info.java | 2 +- .../simplejwt/config/package-info.java | 2 +- .../codecrafters/simplejwt/package-info.java | 2 +- .../simplejwt/jjwt/config/package-info.java | 2 +- .../simplejwt/jjwt/package-info.java | 2 +- webcal/README.md | 4 ++-- .../org/codecrafters/webcal/package-info.java | 2 +- 12 files changed, 22 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index e03f953..603bca4 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ A module for generating globally unique IDs. It includes a facade interface and _[Learn more](https://github.com/CodeCraftersCN/jdevkit/webcal/README.md)_ -The module `webcal` is a Java library that facilitates the generation and resolution of iCalendar content for web-based calendar applications. It provides a flexible and easy-to-use API for creating web calendars with customizable settings and events. +The module `webcal` is a Java library that facilitates the generation and resolution of iCalendar content for web-based calendar applications. It provides a flexible and easy-to-use API for creating web calendars with customisable settings and events. With the `webcal` module, developers can easily integrate calendar functionality into web applications, enabling users to view, add, and manage events in a structured and standardized format. It is designed to simplify calendar-related tasks and enhance the overall user experience when dealing with calendar data on the web. diff --git a/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/ChainedCalcUtil.java b/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/ChainedCalcUtil.java index 98d69bf..21a9273 100644 --- a/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/ChainedCalcUtil.java +++ b/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/ChainedCalcUtil.java @@ -31,7 +31,7 @@ import java.util.function.Function; * The ChainedCalcUtil class provides a convenient way to perform chained * high-precision calculations using BigDecimal. It allows users to perform * mathematical operations such as addition, subtraction, multiplication, - * and division with customizable precision and scale. By using this utility + * and division with customisable precision and scale. By using this utility * class, developers can achieve accurate results and avoid precision loss * in their calculations. *

        diff --git a/guid/src/main/java/cn/org/codecrafters/guid/SnowflakeGuidCreator.java b/guid/src/main/java/cn/org/codecrafters/guid/SnowflakeGuidCreator.java index 9600b51..582bd2e 100644 --- a/guid/src/main/java/cn/org/codecrafters/guid/SnowflakeGuidCreator.java +++ b/guid/src/main/java/cn/org/codecrafters/guid/SnowflakeGuidCreator.java @@ -26,19 +26,19 @@ import java.time.ZoneOffset; * SnowflakeGuidCreator - GUID generator based on the Snowflake algorithm. *

        * The SnowflakeGuidCreator generates unique identifiers using the Snowflake - * algorithm, which combines a timestamp, worker ID, and data center ID to + * 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: *

          *
        • 1 bit for sign
        • *
        • 41 bits for timestamp (in milliseconds)
        • - *
        • 5 bits for data center ID
        • + *
        • 5 bits for data centre ID
        • *
        • 5 bits for worker ID
        • *
        • 12 bits for sequence number (per millisecond)
        • *
        *

        * When initializing the SnowflakeGuidCreator, you must provide the worker ID - * and data center ID, ensuring they are within the valid range defined by the + * 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 @@ -68,7 +68,7 @@ public final class SnowflakeGuidCreator implements GuidCreator { private final long workerIdBits = 5L; /** - * The number of bits reserved for the data center ID. + * The number of bits reserved for the data centre ID. */ private final long dataCentreIdBits = 5L; @@ -78,7 +78,7 @@ public final class SnowflakeGuidCreator implements GuidCreator { private final long workerId; /** - * The data center ID assigned to this generator. + * The data centre ID assigned to this generator. */ private final long dataCentreId; @@ -94,10 +94,10 @@ public final class SnowflakeGuidCreator implements GuidCreator { /** * Constructs a SnowflakeGuidGenerator with the default start epoch and - * custom worker ID, data center ID. + * custom worker ID, data centre ID. * * @param workerId the worker ID (between 0 and 31). - * @param dataCentreId the data center ID (between 0 and 31). + * @param dataCentreId the data centre ID (between 0 and 31). */ public SnowflakeGuidCreator(long workerId, long dataCentreId) { this(workerId, dataCentreId, DEFAULT_CUSTOM_EPOCH); @@ -105,15 +105,15 @@ public final class SnowflakeGuidCreator implements GuidCreator { /** * Constructs a SnowflakeGuidGenerator with a custom epoch, worker ID, and - * data center ID. + * data centre ID. * * @param startEpoch the custom epoch timestamp (in milliseconds) to * start generating IDs from * @param workerId the worker ID (between 0 and 31) - * @param dataCentreId the data center ID (between 0 and 31) + * @param dataCentreId the data centre ID (between 0 and 31) * @throws IllegalArgumentException if the start epoch is greater than the * current timestamp, or if the worker ID - * or data center ID is out of range + * or data centre ID is out of range */ public SnowflakeGuidCreator(long workerId, long dataCentreId, long startEpoch) { if (startEpoch > currentTimestamp()) { diff --git a/guid/src/main/java/cn/org/codecrafters/guid/exceptions/TimingException.java b/guid/src/main/java/cn/org/codecrafters/guid/exceptions/TimingException.java index 952213b..ab9abae 100644 --- a/guid/src/main/java/cn/org/codecrafters/guid/exceptions/TimingException.java +++ b/guid/src/main/java/cn/org/codecrafters/guid/exceptions/TimingException.java @@ -31,7 +31,7 @@ package cn.org.codecrafters.guid.exceptions; * information about the error. *

        * TimingException is typically used to handle exceptions related to timing, - * such as timeouts or synchronization issues. It is a subclass of + * such as timeouts or synchronisation issues. It is a subclass of * RuntimeException, which means it is an unchecked exception and does not need * to be caught or declared. * diff --git a/simple-jwt-authzero/src/main/java/cn/org/codecrafters/simplejwt/authzero/config/package-info.java b/simple-jwt-authzero/src/main/java/cn/org/codecrafters/simplejwt/authzero/config/package-info.java index 5f3abd7..5d6a0ae 100644 --- a/simple-jwt-authzero/src/main/java/cn/org/codecrafters/simplejwt/authzero/config/package-info.java +++ b/simple-jwt-authzero/src/main/java/cn/org/codecrafters/simplejwt/authzero/config/package-info.java @@ -46,7 +46,7 @@ * to configure and use the {@link * cn.org.codecrafters.simplejwt.authzero.AuthzeroTokenResolver} effectively * in the Spring Boot environment to handle JWT authentication and - * authorization securely and efficiently. + * authorisation securely and efficiently. * * @since 1.0.0 */ diff --git a/simple-jwt-authzero/src/main/java/cn/org/codecrafters/simplejwt/authzero/package-info.java b/simple-jwt-authzero/src/main/java/cn/org/codecrafters/simplejwt/authzero/package-info.java index c99a3dd..c8ba91c 100644 --- a/simple-jwt-authzero/src/main/java/cn/org/codecrafters/simplejwt/authzero/package-info.java +++ b/simple-jwt-authzero/src/main/java/cn/org/codecrafters/simplejwt/authzero/package-info.java @@ -19,7 +19,7 @@ * This package contains classes related to the integration of the {@code * com.auth0:java-jwt} library in the Simple JWT project. {@code * com.auth0:java-jwt} is a powerful and widely-used Identity as a Service - * (IDaaS) platform that provides secure authentication and authorization + * (IDaaS) platform that provides secure authentication and authorisation * solutions for web and mobile applications. The classes in this package * provide the necessary functionality to handle JSON Web Tokens (JWTs) using * the {@code com.auth0:java-jwt} library. diff --git a/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/config/package-info.java b/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/config/package-info.java index 1a8784c..0fa35ff 100644 --- a/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/config/package-info.java +++ b/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/config/package-info.java @@ -22,7 +22,7 @@ * and validation. *

        * Other configuration classes may be added in the future to support additional - * customization options and features. Developers using the Simple JWT library + * customisation options and features. Developers using the Simple JWT library * should be familiar with the available configuration options to ensure proper * integration and usage of the library. * diff --git a/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/package-info.java b/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/package-info.java index 497d456..490200b 100644 --- a/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/package-info.java +++ b/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/package-info.java @@ -24,7 +24,7 @@ * the JWT handling process and provide convenient abstractions for JWT * generation, validation, and extraction. *

        - * The Simple JWT library is designed to be flexible and customizable, allowing + * The Simple JWT library is designed to be flexible and customisable, allowing * developers to use different algorithms, token resolvers, and token payload * classes based on their specific application requirements. It aims to * simplify the JWT handling process while maintaining security and best diff --git a/simple-jwt-jjwt/src/main/java/cn/org/codecrafters/simplejwt/jjwt/config/package-info.java b/simple-jwt-jjwt/src/main/java/cn/org/codecrafters/simplejwt/jjwt/config/package-info.java index fdc87a0..5ebbeaf 100644 --- a/simple-jwt-jjwt/src/main/java/cn/org/codecrafters/simplejwt/jjwt/config/package-info.java +++ b/simple-jwt-jjwt/src/main/java/cn/org/codecrafters/simplejwt/jjwt/config/package-info.java @@ -46,7 +46,7 @@ * to configure and use the {@link * cn.org.codecrafters.simplejwt.jjwt.JjwtTokenResolver} effectively * in the Spring Boot environment to handle JWT authentication and - * authorization securely and efficiently. + * authorisation securely and efficiently. * * @since 1.0.0 */ diff --git a/simple-jwt-jjwt/src/main/java/cn/org/codecrafters/simplejwt/jjwt/package-info.java b/simple-jwt-jjwt/src/main/java/cn/org/codecrafters/simplejwt/jjwt/package-info.java index 2c31f40..5a3eca5 100644 --- a/simple-jwt-jjwt/src/main/java/cn/org/codecrafters/simplejwt/jjwt/package-info.java +++ b/simple-jwt-jjwt/src/main/java/cn/org/codecrafters/simplejwt/jjwt/package-info.java @@ -19,7 +19,7 @@ * This package contains classes related to the integration of the {@code * io.jsonwebtoken:jjwt-api} library in the Simple JWT project. {@code * io.jsonwebtoken:jjwt-api} is a powerful and widely-used Identity as a Service - * (IDaaS) platform that provides secure authentication and authorization + * (IDaaS) platform that provides secure authentication and authorisation * solutions for web and mobile applications. The classes in this package * provide the necessary functionality to handle JSON Web Tokens (JWTs) using * the {@code io.jsonwebtoken:jjwt-api} library. diff --git a/webcal/README.md b/webcal/README.md index ec896ed..d421196 100644 --- a/webcal/README.md +++ b/webcal/README.md @@ -2,12 +2,12 @@ ## Introduction -The module `webcal` is a Java library that facilitates the generation and resolution of iCalendar content for web-based calendar applications. It provides a flexible and easy-to-use API for creating web calendars with customizable settings and events. +The module `webcal` is a Java library that facilitates the generation and resolution of iCalendar content for web-based calendar applications. It provides a flexible and easy-to-use API for creating web calendars with customisable settings and events. ### Key features - Create and manage web calendars with events, including event details such as summary, description, location, and more. -- Define event classifications and categories for better organization and filtering of calendar data. +- Define event classifications and categories for better organisation and filtering of calendar data. - Set event start and end times, durations, and time zones to handle various scheduling scenarios. - Configure event priorities and completion percentages for visual representation in the calendar. - Generate iCalendar format output suitable for web calendar applications. diff --git a/webcal/src/main/java/cn/org/codecrafters/webcal/package-info.java b/webcal/src/main/java/cn/org/codecrafters/webcal/package-info.java index ce089b6..3cfd07d 100644 --- a/webcal/src/main/java/cn/org/codecrafters/webcal/package-info.java +++ b/webcal/src/main/java/cn/org/codecrafters/webcal/package-info.java @@ -24,7 +24,7 @@ *

          *
        • * {@link cn.org.codecrafters.webcal.WebCalendar}: A class for - * generating web calendars with customizable settings and events. + * generating web calendars with customisable settings and events. *
        • *
        • * {@link cn.org.codecrafters.webcal.WebCalendarEvent}: A class From a66879a99b6af54af5a7377c3f63e1356f05c517 Mon Sep 17 00:00:00 2001 From: Zihlu Wang Date: Sat, 16 Sep 2023 17:08:04 +0800 Subject: [PATCH 19/27] docs(devkit-utils): Optimised javadoc, changed to better expression. --- .../codecrafters/devkit/utils/HashUtil.java | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/HashUtil.java b/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/HashUtil.java index bd33926..e15892d 100644 --- a/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/HashUtil.java +++ b/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/HashUtil.java @@ -117,7 +117,7 @@ public final class HashUtil { * Calculates the MD2 hash value of the specified string using the given * charset. * - * @param value the string to calculate the MD2 hash value for + * @param value the string to calculate with the MD2 algorithm * @param charset the charset to use for encoding the string (default is * UTF-8 if null) * @return the MD2 hash value as a hexadecimal string @@ -131,7 +131,7 @@ public final class HashUtil { * Calculates the MD2 hash value of the specified string using the UTF-8 * charset. * - * @param value the string to calculate the MD2 hash value for + * @param value the string to calculate with the MD2 algorithm * @return the MD2 hash value as a hexadecimal string */ public static String md2(String value) { @@ -142,7 +142,7 @@ public final class HashUtil { * Calculates the MD5 hash value of the specified string using the given * charset. * - * @param value the string to calculate the MD5 hash value for + * @param value the string to calculate with the MD5 algorithm * @param charset the charset to use for encoding the string (default is * UTF-8 if null) * @return the MD5 hash value as a hexadecimal string @@ -156,7 +156,7 @@ public final class HashUtil { * Calculates the MD5 hash value of the specified string using the UTF-8 * charset. * - * @param value the string to calculate the MD5 hash value for + * @param value the string to calculate with the MD5 algorithm * @return the MD5 hash value as a hexadecimal string */ public static String md5(String value) { @@ -167,7 +167,7 @@ public final class HashUtil { * Calculates the SHA-1 hash value of the specified string using the given * charset. * - * @param value the string to calculate the SHA-1 hash value for + * @param value the string to calculate with the SHA-1 algorithm * @param charset the charset to use for encoding the string (default is * UTF-8 if null) * @return the SHA-1 hash value as a hexadecimal string @@ -181,7 +181,7 @@ public final class HashUtil { * Calculates the SHA-1 hash value of the specified string using the UTF-8 * charset. * - * @param value the string to calculate the SHA-1 hash value for + * @param value the string to calculate with the SHA-1 algorithm * @return the SHA-1 hash value as a hexadecimal string */ public static String sha1(String value) { @@ -192,7 +192,7 @@ public final class HashUtil { * Calculates the SHA-224 hash value of the specified string using the * given charset. * - * @param value the string to calculate the SHA-224 hash value for + * @param value the string to calculate with the SHA-225 algorithm * @param charset the charset to use for encoding the string (default is * UTF-8 if null) * @return the SHA-224 hash value as a hexadecimal string @@ -206,7 +206,7 @@ public final class HashUtil { * Calculates the SHA-224 hash value of the specified string using the * UTF-8 charset. * - * @param value the string to calculate the SHA-224 hash value for + * @param value the string to calculate with the SHA-224 algorithm * @return the SHA-224 hash value as a hexadecimal string */ public static String sha224(String value) { @@ -217,7 +217,7 @@ public final class HashUtil { * Calculates the SHA-256 hash value of the specified string using the * given charset. * - * @param value the string to calculate the SHA-256 hash value for + * @param value the string to calculate with the SHA-256 algorithm * @param charset the charset to use for encoding the string (default is * UTF-8 if null) * @return the SHA-256 hash value as a hexadecimal string @@ -231,7 +231,7 @@ public final class HashUtil { * Calculates the SHA-256 hash value of the specified string using the * UTF-8 charset. * - * @param value the string to calculate the SHA-256 hash value for + * @param value the string to calculate with the SHA-256 algorithm * @return the SHA-256 hash value as a hexadecimal string */ public static String sha256(String value) { @@ -242,7 +242,7 @@ public final class HashUtil { * Calculates the SHA-384 hash value of the specified string using the * given charset. * - * @param value the string to calculate the SHA-384 hash value for + * @param value the string to calculate with the SHA-384 algorithm * @param charset the charset to use for encoding the string (default is * UTF-8 if null) * @return the SHA-384 hash value as a hexadecimal string @@ -256,7 +256,7 @@ public final class HashUtil { * Calculates the SHA-384 hash value of the specified string using the * UTF-8 charset. * - * @param value the string to calculate the SHA-384 hash value for + * @param value the string to calculate with the SHA-384 algorithm * @return the SHA-384 hash value as a hexadecimal string */ public static String sha384(String value) { @@ -267,7 +267,7 @@ public final class HashUtil { * Calculates the SHA-512 hash value of the specified string using the * given charset. * - * @param value the string to calculate the SHA-384 hash value for + * @param value the string to calculate with the SHA-512 algorithm * @param charset the charset to use for encoding the string (default is * UTF-8 if null) * @return the SHA-512 hash value as a hexadecimal string @@ -281,7 +281,7 @@ public final class HashUtil { * Calculates the SHA-512 hash value of the specified string using the * UTF-8 charset. * - * @param value the string to calculate the SHA-384 hash value for + * @param value the string to calculate with the SHA-512 algorithm * @return the SHA-512 hash value as a hexadecimal string */ public static String sha512(String value) { From 52f90e6507f293d17450561c3a8f9aa6cc6c6c99 Mon Sep 17 00:00:00 2001 From: Zihlu Wang Date: Mon, 18 Sep 2023 09:25:16 +0800 Subject: [PATCH 20/27] docs(devkit-utils): Optimised javadoc. --- .../codecrafters/guid/exceptions/TimingException.java | 9 --------- 1 file changed, 9 deletions(-) diff --git a/guid/src/main/java/cn/org/codecrafters/guid/exceptions/TimingException.java b/guid/src/main/java/cn/org/codecrafters/guid/exceptions/TimingException.java index ab9abae..feb1ed2 100644 --- a/guid/src/main/java/cn/org/codecrafters/guid/exceptions/TimingException.java +++ b/guid/src/main/java/cn/org/codecrafters/guid/exceptions/TimingException.java @@ -21,19 +21,10 @@ package cn.org.codecrafters.guid.exceptions; * The TimingException class represents an exception that is thrown when there * is an error related to time sequence. *

          - * This class extends the RuntimeException class, which means that instances of - * TimingException do not need to be declared in a method or constructor's - * throws clause. - *

          * Instances of TimingException can be created with or without a message and a * cause. The message provides a description of the exception, while the cause * represents the underlying cause of the exception and provides additional * information about the error. - *

          - * TimingException is typically used to handle exceptions related to timing, - * such as timeouts or synchronisation issues. It is a subclass of - * RuntimeException, which means it is an unchecked exception and does not need - * to be caught or declared. * * @author Zihlu Wang * @since 1.0.0 From 09c973dde424f5baf06163cb59a180fd1f662466 Mon Sep 17 00:00:00 2001 From: Zihlu Wang Date: Mon, 18 Sep 2023 09:51:00 +0800 Subject: [PATCH 21/27] refactor(devkit-utils): Changed the order of the parameters. --- .../codecrafters/guid/SnowflakeGuidCreator.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/guid/src/main/java/cn/org/codecrafters/guid/SnowflakeGuidCreator.java b/guid/src/main/java/cn/org/codecrafters/guid/SnowflakeGuidCreator.java index 582bd2e..ea737a9 100644 --- a/guid/src/main/java/cn/org/codecrafters/guid/SnowflakeGuidCreator.java +++ b/guid/src/main/java/cn/org/codecrafters/guid/SnowflakeGuidCreator.java @@ -96,26 +96,26 @@ public final class SnowflakeGuidCreator implements GuidCreator { * Constructs a SnowflakeGuidGenerator with the default start epoch and * custom worker ID, data centre ID. * - * @param workerId the worker ID (between 0 and 31). - * @param dataCentreId the data centre ID (between 0 and 31). + * @param dataCentreId the data centre ID (between 0 and 31) + * @param workerId the worker ID (between 0 and 31) */ - public SnowflakeGuidCreator(long workerId, long dataCentreId) { - this(workerId, dataCentreId, DEFAULT_CUSTOM_EPOCH); + public SnowflakeGuidCreator(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 - * @param workerId the worker ID (between 0 and 31) - * @param dataCentreId the data centre ID (between 0 and 31) * @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 workerId, long dataCentreId, long startEpoch) { + public SnowflakeGuidCreator(long dataCentreId, long workerId, long startEpoch) { if (startEpoch > currentTimestamp()) { throw new IllegalArgumentException("Start Epoch can not be greater than current timestamp!"); } From 007d192b01ddb980923332bd26953ebb058bef7f Mon Sep 17 00:00:00 2001 From: Zihlu Wang Date: Mon, 18 Sep 2023 10:01:27 +0800 Subject: [PATCH 22/27] refactor(devkit-utils): Optimised the time zone for getting current timestamp. --- .../java/cn/org/codecrafters/guid/SnowflakeGuidCreator.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/guid/src/main/java/cn/org/codecrafters/guid/SnowflakeGuidCreator.java b/guid/src/main/java/cn/org/codecrafters/guid/SnowflakeGuidCreator.java index ea737a9..78cd3bc 100644 --- a/guid/src/main/java/cn/org/codecrafters/guid/SnowflakeGuidCreator.java +++ b/guid/src/main/java/cn/org/codecrafters/guid/SnowflakeGuidCreator.java @@ -20,6 +20,7 @@ package cn.org.codecrafters.guid; import cn.org.codecrafters.guid.exceptions.TimingException; import java.time.LocalDateTime; +import java.time.ZoneId; import java.time.ZoneOffset; /** @@ -203,7 +204,7 @@ public final class SnowflakeGuidCreator implements GuidCreator { * @return the current timestamp */ private long currentTimestamp() { - return LocalDateTime.now().toInstant(ZoneOffset.UTC).toEpochMilli(); + return LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(); } } From fee85d5d84a1e6a1bc2fb78536a740e38bee1d92 Mon Sep 17 00:00:00 2001 From: Zihlu Wang Date: Mon, 18 Sep 2023 11:12:16 +0800 Subject: [PATCH 23/27] docs(devkit-core): Optimised javadoc. --- .../core/exceptions/NotImplementedException.java | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/devkit-core/src/main/java/cn/org/codecrafters/devkit/core/exceptions/NotImplementedException.java b/devkit-core/src/main/java/cn/org/codecrafters/devkit/core/exceptions/NotImplementedException.java index dbf1b5a..095ae72 100644 --- a/devkit-core/src/main/java/cn/org/codecrafters/devkit/core/exceptions/NotImplementedException.java +++ b/devkit-core/src/main/java/cn/org/codecrafters/devkit/core/exceptions/NotImplementedException.java @@ -18,31 +18,23 @@ package cn.org.codecrafters.devkit.core.exceptions; /** - * NotImplementedException - Custom Runtime Exception - *

          * The {@code NotImplementedException} class is a custom runtime exception * that represents a situation where a particular method or functionality is - * not implemented or is currently unavailable in the codebase. It extends the - * standard {@code RuntimeException} class, making it an unchecked exception. - * + * not implemented or is currently unavailable in the codebase. *

          * This exception is typically thrown when developers need to indicate that a * specific part of the code is incomplete or requires further implementation. * It serves as a placeholder to highlight unfinished sections of the * application during development and testing phases. - * *

          * Usage Example: - * *

            * public void someMethod() {
            *     // Some code...
            *     throw new NotImplementedException("""
          - *     This feature will be implemented in a future release.
          - *     """);
          + *     This feature will be implemented in a future release.""");
            * }
            * 
          - * * Contact *
            *
          • @@ -55,7 +47,7 @@ package cn.org.codecrafters.devkit.core.exceptions; *
          * * @author Zihlu Wang - * @version 1.0.0 + * @version 1.1.0 * @see RuntimeException * @since 1.0.0 */ From f80c47e8adb9c7810de4ad68890a00593a346ce6 Mon Sep 17 00:00:00 2001 From: Zihlu Wang Date: Mon, 18 Sep 2023 15:04:10 +0800 Subject: [PATCH 24/27] docs(global): Optimised javadoc, changed the spelling to British English. --- .../devkit/core/exceptions/package-info.java | 2 +- .../devkit/core/package-info.java | 11 +-- .../org/codecrafters/devkit/package-info.java | 4 +- .../codecrafters/devkit/utils/AesUtil.java | 48 +++++----- .../codecrafters/devkit/utils/Base64Util.java | 39 ++++++-- .../codecrafters/devkit/utils/BranchUtil.java | 18 ++-- .../devkit/utils/ChainedCalcUtil.java | 71 +++++++-------- .../codecrafters/devkit/utils/HashUtil.java | 14 ++- .../codecrafters/devkit/utils/MapUtil.java | 12 +-- .../guid/SnowflakeGuidCreator.java | 18 ++-- .../guid/exceptions/TimingException.java | 14 +-- property-guard-spring-boot-starter/README.md | 2 +- .../autoconfiguration/PropertyGuard.java | 29 ++++-- .../authzero/AuthzeroTokenResolver.java | 51 +++++------ .../config/AuthzeroTokenResolverConfig.java | 91 +++++++++---------- .../simplejwt/authzero/package-info.java | 25 ++--- .../codecrafters/simplejwt/SecretCreator.java | 20 ++-- .../codecrafters/simplejwt/TokenPayload.java | 8 +- .../codecrafters/simplejwt/TokenResolver.java | 8 +- .../annotations/ExcludeFromPayload.java | 15 ++- .../simplejwt/config/TokenResolverConfig.java | 34 ++++--- .../simplejwt/config/package-info.java | 13 +-- .../simplejwt/constants/PredefinedKeys.java | 8 +- .../simplejwt/constants/TokenAlgorithm.java | 4 +- .../UnsupportedAlgorithmException.java | 48 +++++----- .../exceptions/WeakSecretException.java | 54 ++++++----- .../simplejwt/exceptions/package-info.java | 18 ++-- .../codecrafters/simplejwt/package-info.java | 22 ++--- .../simplejwt/jjwt/JjwtTokenResolver.java | 8 +- .../jjwt/config/JjwtTokenResolverConfig.java | 46 +++++----- .../simplejwt/jjwt/package-info.java | 20 ++-- ...uthzeroTokenResolverAutoConfiguration.java | 15 +-- .../GuidAutoConfiguration.java | 2 +- .../JjwtTokenResolverAutoConfiguration.java | 6 +- .../conditions/GuidCreatorCondition.java | 2 +- .../properties/SimpleJwtProperties.java | 12 +-- .../org/codecrafters/webcal/WebCalendar.java | 19 ++-- .../codecrafters/webcal/WebCalendarEvent.java | 19 ++-- .../codecrafters/webcal/WebCalendarNode.java | 13 ++- .../webcal/config/Classification.java | 26 +----- .../webcal/config/package-info.java | 8 +- 41 files changed, 459 insertions(+), 438 deletions(-) diff --git a/devkit-core/src/main/java/cn/org/codecrafters/devkit/core/exceptions/package-info.java b/devkit-core/src/main/java/cn/org/codecrafters/devkit/core/exceptions/package-info.java index 826c497..dfac4fe 100644 --- a/devkit-core/src/main/java/cn/org/codecrafters/devkit/core/exceptions/package-info.java +++ b/devkit-core/src/main/java/cn/org/codecrafters/devkit/core/exceptions/package-info.java @@ -16,7 +16,7 @@ */ /** - * Commonly used exceptions will be used in JDevKit. + * This package contains commonly used exceptions will be used in JDevKit. * * @author Zihlu Wang * @since 1.0.0 diff --git a/devkit-core/src/main/java/cn/org/codecrafters/devkit/core/package-info.java b/devkit-core/src/main/java/cn/org/codecrafters/devkit/core/package-info.java index 3dda72c..a7e930f 100644 --- a/devkit-core/src/main/java/cn/org/codecrafters/devkit/core/package-info.java +++ b/devkit-core/src/main/java/cn/org/codecrafters/devkit/core/package-info.java @@ -16,19 +16,16 @@ */ /** - * This package is a part of JDevKit, an open-source Java Development Kit that - * provides a set of convenient tools to streamline code development and - * enhance productivity. This package serves as the core package containing - * common exceptions that are used throughout the entireJDevKit project. - * + * This package is the core part of JDevKit, an open-source Java Development + * Kit that provides a set of convenient tools to streamline code development + * and enhance productivity. This package serves as the core package containing + * common exceptions that are used throughout the entire JDevKit project. *

          * JDevKit is designed to be modular, and other specific feature modules within * the library may rely on these exceptions from the core package. - * *

          * For more information and the latest version of JDevKit, please visit our * website codecrafters.org.cn. - * *

          * Contact *

            diff --git a/devkit-core/src/main/java/cn/org/codecrafters/devkit/package-info.java b/devkit-core/src/main/java/cn/org/codecrafters/devkit/package-info.java index 0bfad9b..90647f4 100644 --- a/devkit-core/src/main/java/cn/org/codecrafters/devkit/package-info.java +++ b/devkit-core/src/main/java/cn/org/codecrafters/devkit/package-info.java @@ -19,8 +19,8 @@ * This package is the main part of JDevKit, an open-source Java class library * that provides a set of convenient tools to streamline code development and * enhance productivity. This package serves as the root package for several - * modules, containing devkit-core, guid and dev-utils module. - * + * modules, containing {@code devkit-core}, {@code guid} and {@code dev-utils} + * module. *

            * For more information and the latest version of JDevKit, please visit our * website codecrafters.org.cn. diff --git a/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/AesUtil.java b/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/AesUtil.java index 54a734c..6ccc4ce 100644 --- a/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/AesUtil.java +++ b/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/AesUtil.java @@ -34,12 +34,12 @@ import java.util.Objects; import java.util.UUID; /** - * AES Util helps you encrypt and decrypt data with specified key and AES - * algorithm. + * {@link AesUtil} can help you encrypt and decrypt data with specified secret + * by AES algorithm. * * @author hubin@baomidou - * @since 1.1.0 * @version 1.1.0 + * @since 1.1.0 */ @Slf4j public final class AesUtil { @@ -52,17 +52,17 @@ public final class AesUtil { private static final String AES_CBC_CIPHER = "AES/CBC/PKCS5Padding"; /** - * Encrypt the given data with given key with AES algorithm. + * Encrypts the data using the AES algorithm with the given secret. * - * @param data the data to be encrypted - * @param key the key to encrypt the data + * @param data the data to be encrypted + * @param secret the secret to encrypt the data * @return the encryption result or {@code null} if encryption failed */ - public static byte[] encrypt(byte[] data, byte[] key) { + public static byte[] encrypt(byte[] data, byte[] secret) { try { - var secretKeySpec = new SecretKeySpec(new SecretKeySpec(key, AES).getEncoded(), AES); + 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(key)); + cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec, new IvParameterSpec(secret)); return cipher.doFinal(data); } catch (NoSuchAlgorithmException | NoSuchPaddingException | UnsupportedOperationException | InvalidKeyException | InvalidAlgorithmParameterException | IllegalBlockSizeException | @@ -76,17 +76,17 @@ public final class AesUtil { } /** - * Decrypt the given data with given key with AES algorithm. + * Decrypts the data using the AES algorithm with the given secret. * * @param data the data to be decrypted - * @param key the key to encrypt the data + * @param secret the secret to encrypt the data * @return the decryption result or {@code null} if decryption failed */ - public static byte[] decrypt(byte[] data, byte[] key) { + public static byte[] decrypt(byte[] data, byte[] secret) { try { - var secretKeySpec = new SecretKeySpec(new SecretKeySpec(key, AES).getEncoded(), AES); + 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(key)); + cipher.init(Cipher.DECRYPT_MODE, secretKeySpec, new IvParameterSpec(secret)); return cipher.doFinal(data); } catch (NoSuchAlgorithmException | NoSuchPaddingException | UnsupportedOperationException | InvalidKeyException | InvalidAlgorithmParameterException | IllegalBlockSizeException | @@ -100,36 +100,36 @@ public final class AesUtil { } /** - * Encrypt the given data with given key with AES algorithm. + * Encrypts the data using the AES algorithm with the given secret. * * @param data the data to be encrypted - * @param key the key to encrypt the data + * @param secret the secret to encrypt the data * @return the encryption result or {@code null} if encryption failed */ - public static String encrypt(String data, String key) { - return Base64.getEncoder().encodeToString(encrypt(data.getBytes(StandardCharsets.UTF_8), key.getBytes(StandardCharsets.UTF_8))); + public static String encrypt(String data, String secret) { + return Base64.getEncoder().encodeToString(encrypt(data.getBytes(StandardCharsets.UTF_8), secret.getBytes(StandardCharsets.UTF_8))); } /** - * Decrypt the given data with given key with AES algorithm. + * Decrypts the data using the AES algorithm with the given secret. * * @param data the data to be decrypted - * @param key the key to encrypt the data + * @param secret the secret to encrypt the data * @return the decryption result or {@code null} if decryption failed */ - public static String decrypt(String data, String key) { + public static String decrypt(String data, String secret) { return new String(Objects.requireNonNull( decrypt(Base64.getDecoder().decode(data.getBytes()), - key.getBytes(StandardCharsets.UTF_8))) + secret.getBytes(StandardCharsets.UTF_8))) ); } /** - * Generates 16 characters-long random key. + * Generates 16 characters-long random secret. * * @return the generated secure secret */ - public static String generateRandomKey() { + public static String generateRandomSecret() { return UUID.randomUUID().toString().replaceAll("-", "").substring(0, 16); } diff --git a/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/Base64Util.java b/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/Base64Util.java index 96377d4..309b83c 100644 --- a/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/Base64Util.java +++ b/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/Base64Util.java @@ -20,10 +20,11 @@ package cn.org.codecrafters.devkit.utils; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.util.Base64; +import java.util.Objects; /** - * The {@code Base64Util} class provides static methods to encode and decode - * strings using Base64 encoding. It utilizes the {@link Base64} class from the + * The {@link Base64Util} class provides static methods to encode and decode + * strings with Base64 encoding. It utilizes the {@link Base64} class from the * Java standard library for performing the encoding and decoding operations. * This utility class offers convenient methods to encode and decode strings * with different character sets. @@ -55,6 +56,34 @@ import java.util.Base64; */ public final class Base64Util { + private static Base64.Encoder encoder; + + private static Base64.Decoder decoder; + + /** + * Ensure that there is only one Base64 Encoder. + * + * @return the {@link Base64.Encoder} instance + */ + private static Base64.Encoder getEncoder() { + if (Objects.isNull(encoder)) { + encoder = Base64.getEncoder(); + } + return encoder; + } + + /** + * Ensure that there is only one Base64 Encoder. + * + * @return the {@link Base64.Encoder} instance + */ + private static Base64.Decoder getDecoder() { + if (Objects.isNull(decoder)) { + decoder = Base64.getDecoder(); + } + return decoder; + } + /** * Private constructor to prevent instantiation of the class. */ @@ -69,8 +98,7 @@ public final class Base64Util { * @return the Base64 encoded string */ public static String encode(String value, Charset charset) { - var encoder = Base64.getEncoder(); - var encoded = encoder.encode(value.getBytes(charset)); + var encoded = getEncoder().encode(value.getBytes(charset)); return new String(encoded); } @@ -93,8 +121,7 @@ public final class Base64Util { * @return the decoded string */ public static String decode(String value, Charset charset) { - var decoder = Base64.getDecoder(); - var decoded = decoder.decode(value.getBytes(charset)); + var decoded = getDecoder().decode(value.getBytes(charset)); return new String(decoded); } diff --git a/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/BranchUtil.java b/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/BranchUtil.java index 288f2f4..6b9b760 100644 --- a/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/BranchUtil.java +++ b/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/BranchUtil.java @@ -23,24 +23,24 @@ import java.util.function.BooleanSupplier; import java.util.function.Supplier; /** - * The BranchUtil class provides static methods to simplify conditional logic - * in Java development by leveraging lambda expressions. It offers convenient - * methods to replace verbose if...else statements with more concise and - * expressive functional constructs. + * The {@link BranchUtil} class provides static methods to simplify conditional + * logic in Java development by leveraging lambda expressions. It offers + * convenient methods to replace verbose {@code if...else} statements with more + * concise and expressive functional constructs. *

            - * Developers can use the methods in this utility class to streamline their - * code, enhance readability, and promote a more functional style of - * programming when dealing with branching logic and conditional statements. + * Developers can use methods in this utility class to streamline their code, + * enhance readability, and promote a more functional style of programming when + * dealing with branching logic and conditional statements. *

            * Example: *

              * // If you want to simplify an if (exp1 || exp2), you can use the
              * // following code:
            - * var r1 = BranchUtil.or(1 == 1, 2 == 1)
            + * String r1 = BranchUtil.or(1 == 1, 2 == 1)
              *     .handle(() -> "1 is equal to 1 or 2 is equal to 1.");
              *
              * // If you have an else branch, you can use the following code:
            - * var r2 = BranchUtil.or(1 == 1, 2 == 1)
            + * String r2 = BranchUtil.or(1 == 1, 2 == 1)
              *     .handle(() -> "1 is equal to 1 or 2 is equal to 1.",
              *             () -> "1 is not equal to 1 and 2 is not equal to 1.");
              *
            diff --git a/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/ChainedCalcUtil.java b/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/ChainedCalcUtil.java
            index 21a9273..fc2358c 100644
            --- a/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/ChainedCalcUtil.java
            +++ b/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/ChainedCalcUtil.java
            @@ -26,14 +26,12 @@ import java.util.function.BiFunction;
             import java.util.function.Function;
             
             /**
            - * Utility class for chained high-precision calculations using BigDecimal.
            - * 

            - * The ChainedCalcUtil class provides a convenient way to perform chained - * high-precision calculations using BigDecimal. It allows users to perform - * mathematical operations such as addition, subtraction, multiplication, - * and division with customisable precision and scale. By using this utility - * class, developers can achieve accurate results and avoid precision loss - * in their calculations. + * The {@code ChainedCalcUtil} class provides a convenient way to perform + * chained high-precision calculations using {@link BigDecimal}. It allows + * users to perform mathematical operations such as addition, subtraction, + * multiplication, and division with customisable precision and scale. By using + * this utility class, developers can achieve accurate results and avoid + * precision loss in their calculations. *

            * Usage: *

            @@ -81,13 +79,13 @@ import java.util.function.Function;
              *                                      .getValue(2);
              *  
            * The above expressions perform various mathematical calculations using the - * ChainedCalcUtil class. + * {@code ChainedCalcUtil} class. *

            * Note: - * The ChainedCalcUtil class internally uses BigDecimal to handle - * high-precision calculations. It is important to note that BigDecimal - * operations can be memory-intensive and may have performance implications - * for extremely large numbers or complex calculations. + * The {@code ChainedCalcUtil} class internally uses {@link BigDecimal} to + * handle high-precision calculations. It is important to note that {@link + * BigDecimal} operations can be memory-intensive and may have performance + * implications for extremely large numbers or complex calculations. * * @author sunzsh * @version 1.1.0 @@ -104,7 +102,8 @@ public final class ChainedCalcUtil { private BigDecimal value; /** - * Creates a ChainedCalcUtil instance with the specified initial value. + * Creates a {@code ChainedCalcUtil} instance with the specified initial + * value. * * @param value the initial value for the calculation */ @@ -116,7 +115,7 @@ public final class ChainedCalcUtil { * Starts a chained calculation with the specified initial value. * * @param value the initial value for the calculation - * @return a ChainedCalcUtil instance for performing chained calculations + * @return a {@code ChainedCalcUtil} instance for performing chained calculations */ public static ChainedCalcUtil startWith(Number value) { return new ChainedCalcUtil(value); @@ -126,7 +125,7 @@ public final class ChainedCalcUtil { * Adds the specified value to the current value. * * @param other the value to be added - * @return a ChainedCalcUtil instance with the updated value + * @return a {@code ChainedCalcUtil} instance with the updated value */ public ChainedCalcUtil add(Number other) { return operator(BigDecimal::add, other); @@ -138,7 +137,7 @@ public final class ChainedCalcUtil { * * @param other the value to be added * @param beforeOperateScale the scale to be applied before the operation - * @return a ChainedCalcUtil instance with the updated value + * @return a {@code ChainedCalcUtil} instance with the updated value */ public ChainedCalcUtil add(Number other, Integer beforeOperateScale) { return operator(BigDecimal::add, other, beforeOperateScale); @@ -148,7 +147,7 @@ public final class ChainedCalcUtil { * Subtracts the specified value from the current value. * * @param other the value to be subtracted - * @return a ChainedCalcUtil instance with the updated value + * @return a {@code ChainedCalcUtil} instance with the updated value */ public ChainedCalcUtil subtract(Number other) { return operator(BigDecimal::subtract, other); @@ -160,7 +159,7 @@ public final class ChainedCalcUtil { * * @param other the value to be subtracted * @param beforeOperateScale the scale to be applied before the operation - * @return a ChainedCalcUtil instance with the updated value + * @return a {@code ChainedCalcUtil} instance with the updated value */ public ChainedCalcUtil subtract(Number other, Integer beforeOperateScale) { return operator(BigDecimal::subtract, other, beforeOperateScale); @@ -170,7 +169,7 @@ public final class ChainedCalcUtil { * Multiplies the current value by the specified value. * * @param other the value to be multiplied by - * @return a ChainedCalcUtil instance with the updated value + * @return a {@code ChainedCalcUtil} instance with the updated value */ public ChainedCalcUtil multiply(Number other) { return operator(BigDecimal::multiply, other); @@ -182,7 +181,7 @@ public final class ChainedCalcUtil { * * @param other the value to be multiplied by * @param beforeOperateScale the scale to be applied before the operation - * @return a ChainedCalcUtil instance with the updated value + * @return a {@code ChainedCalcUtil} instance with the updated value */ public ChainedCalcUtil multiply(Number other, Integer beforeOperateScale) { return operator(BigDecimal::multiply, other, beforeOperateScale); @@ -192,7 +191,7 @@ public final class ChainedCalcUtil { * Divides the current value by the specified value. * * @param other the value to divide by - * @return a ChainedCalcUtil instance with the updated value + * @return a {@code ChainedCalcUtil} instance with the updated value */ public ChainedCalcUtil divide(Number other) { return operator(BigDecimal::divide, other); @@ -204,7 +203,7 @@ public final class ChainedCalcUtil { * * @param other the value to divide by * @param beforeOperateScale the scale to be applied before the operation - * @return a ChainedCalcUtil instance with the updated value + * @return a {@code ChainedCalcUtil} instance with the updated value */ public ChainedCalcUtil divide(Number other, Integer beforeOperateScale) { return operator(BigDecimal::divide, other, beforeOperateScale); @@ -215,7 +214,7 @@ public final class ChainedCalcUtil { * * @param other the value to divide by * @param scale the scale for the result - * @return a ChainedCalcUtil instance with the updated value + * @return a {@code ChainedCalcUtil} instance with the updated value */ public ChainedCalcUtil divideWithScale(Number other, Integer scale) { return baseOperator(otherValue -> @@ -229,54 +228,54 @@ public final class ChainedCalcUtil { * @param other the value to divide by * @param scale the scale for the result * @param beforeOperateScale the scale to be applied before the operation - * @return a ChainedCalcUtil instance with the updated value + * @return a {@code ChainedCalcUtil} instance with the updated value */ public ChainedCalcUtil divideWithScale(Number other, Integer scale, Integer beforeOperateScale) { return baseOperator(otherValue -> this.value.divide(otherValue, scale, RoundingMode.HALF_UP), other, beforeOperateScale); } /** - * Returns the current value as a BigDecimal with the specified scale. + * Returns the current value as a {@link BigDecimal} with the specified scale. * * @param scale the scale for the result - * @return the current value as a BigDecimal with the specified scale + * @return the current value as a {@link BigDecimal} with the specified scale */ public BigDecimal getValue(int scale) { return value.setScale(scale, RoundingMode.HALF_UP); } /** - * Returns the current value as a Double. + * Returns the current value as a {@link Double}. * - * @return the current value as a Double + * @return the current value as a {@link Double} */ public Double getDouble() { return getValue().doubleValue(); } /** - * Returns the current value as a Double with the specified scale. + * Returns the current value as a {@link Double} with the specified scale. * * @param scale the scale for the result - * @return the current value as a Double with the specified scale + * @return the current value as a {@link Double} with the specified scale */ public Double getDouble(int scale) { return getValue(scale).doubleValue(); } /** - * Returns the current value as a Long. + * Returns the current value as a {@link Long}. * - * @return the current value as a Long + * @return the current value as a {@link Long} */ public Long getLong() { return getValue().longValue(); } /** - * Returns the current value as an Integer. + * Returns the current value as an {@link Integer}. * - * @return the current value as an Integer + * @return the current value as an {@link Integer} */ public Integer getInteger() { return getValue().intValue(); @@ -332,7 +331,7 @@ public final class ChainedCalcUtil { } /** - * Converts the specified value to a BigDecimal. + * Converts the specified value to a {@link BigDecimal}. * * @param value the value to convert * @param scale the scale to apply to the resulting BigDecimal, or null if diff --git a/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/HashUtil.java b/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/HashUtil.java index e15892d..c12c9b1 100644 --- a/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/HashUtil.java +++ b/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/HashUtil.java @@ -25,12 +25,10 @@ import java.util.Objects; import java.util.Optional; /** - * Utility class for performing hash operations on strings. - *

            - * The HashUtil class provides convenient methods for calculating various hash - * functions on strings, including MD2, MD5, SHA-1, SHA-224, SHA-256, SHA-384, - * and SHA-512. It allows developers to easily obtain the hash value of a given - * string using different algorithms. + * The {@code HashUtil} class provides convenient methods for calculating + * various hash functions on strings, including MD2, MD5, SHA-1, SHA-224, + * SHA-256, SHA-384, and SHA-512. It allows developers to easily obtain the + * hash value of a given string using different algorithms. *

            * Example usage: *

            @@ -55,8 +53,8 @@ import java.util.Optional;
              * // Perform SHA-512 hash operation
              * String sha512Hash = HashUtil.sha512("someString");
              * 
            - * The above examples demonstrate how to use the HashUtil class to calculate - * hash values for a given string using different algorithms. + * The above examples demonstrate how to use the {@code HashUtil} class to + * calculate hash values for a given string using different algorithms. *

            * Note: * The hash functions provided by the HashUtil class are one-way hash diff --git a/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/MapUtil.java b/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/MapUtil.java index d6e7644..ef54782 100644 --- a/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/MapUtil.java +++ b/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/MapUtil.java @@ -24,8 +24,8 @@ import java.util.HashMap; import java.util.Map; /** - * MapUtil is a utility class that provides methods for converting objects to - * maps and maps to objects. + * {@code MapUtil} is a utility class that provides methods for converting + * objects to maps and maps to objects. *

            * It also provides methods for getting and setting field values using * reflection. @@ -207,10 +207,10 @@ public final class MapUtil { /** * Casts the specified value to the required type. * - * @param value the value to be casted - * @param requiredType the type to which the value should be casted - * @param the type to which the value should be casted - * @return the casted value, or null if the value cannot be casted to the + * @param value the value to be cast + * @param requiredType the type to which the value should be cast + * @param the type to which the value should be cast + * @return the cast value, or null if the value cannot be cast to the * required type */ public static T cast(Object value, Class requiredType) { diff --git a/guid/src/main/java/cn/org/codecrafters/guid/SnowflakeGuidCreator.java b/guid/src/main/java/cn/org/codecrafters/guid/SnowflakeGuidCreator.java index 78cd3bc..a20de90 100644 --- a/guid/src/main/java/cn/org/codecrafters/guid/SnowflakeGuidCreator.java +++ b/guid/src/main/java/cn/org/codecrafters/guid/SnowflakeGuidCreator.java @@ -24,12 +24,10 @@ import java.time.ZoneId; import java.time.ZoneOffset; /** - * SnowflakeGuidCreator - GUID generator based on the Snowflake algorithm. - *

            - * The SnowflakeGuidCreator 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: + * The {@code SnowflakeGuidCreator} 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: *

              *
            • 1 bit for sign
            • *
            • 41 bits for timestamp (in milliseconds)
            • @@ -38,10 +36,10 @@ import java.time.ZoneOffset; *
            • 12 bits for sequence number (per millisecond)
            • *
            *

            - * When initializing the SnowflakeGuidCreator, 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 + * When initializing a {@link SnowflakeGuidCreator}, 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. * diff --git a/guid/src/main/java/cn/org/codecrafters/guid/exceptions/TimingException.java b/guid/src/main/java/cn/org/codecrafters/guid/exceptions/TimingException.java index feb1ed2..96a90ba 100644 --- a/guid/src/main/java/cn/org/codecrafters/guid/exceptions/TimingException.java +++ b/guid/src/main/java/cn/org/codecrafters/guid/exceptions/TimingException.java @@ -18,8 +18,8 @@ package cn.org.codecrafters.guid.exceptions; /** - * The TimingException class represents an exception that is thrown when there - * is an error related to time sequence. + * The {@code TimingException} class represents an exception that is thrown + * when there is an error related to time sequence. *

            * Instances of TimingException can be created with or without a message and a * cause. The message provides a description of the exception, while the cause @@ -40,9 +40,9 @@ public class TimingException extends RuntimeException { /** * A custom exception that is thrown when there is an issue with timing or - * scheduling with customized error message. + * scheduling with customised error message. * - * @param message customized message + * @param message customised message */ public TimingException(String message) { super(message); @@ -50,9 +50,9 @@ public class TimingException extends RuntimeException { /** * A custom exception that is thrown when there is an issue with timing or - * scheduling with customized error message. + * scheduling with customised error message. * - * @param message customized message + * @param message customised message * @param cause the cause of this exception */ public TimingException(String message, Throwable cause) { @@ -61,7 +61,7 @@ public class TimingException extends RuntimeException { /** * A custom exception that is thrown when there is an issue with timing or - * scheduling with customized error message. + * scheduling with customised error message. * * @param cause the cause of this exception */ diff --git a/property-guard-spring-boot-starter/README.md b/property-guard-spring-boot-starter/README.md index 0c8d843..baf2be1 100644 --- a/property-guard-spring-boot-starter/README.md +++ b/property-guard-spring-boot-starter/README.md @@ -57,7 +57,7 @@ import cn.org.codecrafters.simplejwt.SecretCreator; class GenerateRandomKeySample { public static void main(String[] args) { - var secret1 = AesUtil.generateRandomKey(); + var secret1 = AesUtil.generateRandomSecret(); var secret2 = SecretCreator.createSecret(16, true, true, true); } } diff --git a/property-guard-spring-boot-starter/src/main/java/cn/org/codecrafters/propertyguard/autoconfiguration/PropertyGuard.java b/property-guard-spring-boot-starter/src/main/java/cn/org/codecrafters/propertyguard/autoconfiguration/PropertyGuard.java index 776cbdc..c2ca6fb 100644 --- a/property-guard-spring-boot-starter/src/main/java/cn/org/codecrafters/propertyguard/autoconfiguration/PropertyGuard.java +++ b/property-guard-spring-boot-starter/src/main/java/cn/org/codecrafters/propertyguard/autoconfiguration/PropertyGuard.java @@ -29,17 +29,27 @@ import java.util.HashMap; import java.util.Optional; /** - * PropertyEncryptor is a utility class designed for encrypting configuration - * information in Spring Boot applications. + * {@code PropertyGuard} is a utility class designed for encrypting + * configuration properties in Spring Boot applications. *

            * Spring Boot applications often need to store sensitive configuration details * such as database passwords, API keys, etc. To ensure that these sensitive - * pieces of information are not exposed, developers can utilize the - * {@code PropertyGuard} class to encrypt and store them within configuration - * files. + * pieces of information are not exposed to the public, developers can utilize + * the {@code PropertyGuard} class to encrypt and store them within + * configuration files. *

            * Usage - * In {@code application.yml} or {@code application.properties}: + * You need a 16-char long secret for encrypting a configuration property. You + * can get this secret on your own, or use the helper utility class by the + * following code: + *

            {@code
            + * var secret = AesUtil.generateRandomSecret(); // Let's presume the result is
            + *                                              // "3856faef0d2d4f33"
            + * }
            + *

            + * Then, in {@code application.yml} or {@code application.properties}, change + * the original value from plain text to encrypted value with the prefix + * "pg:". *

              *     # original
              *     app.example-properties=Sample Value
            @@ -47,16 +57,15 @@ import java.util.Optional;
              *     # encrypted with key 3856faef0d2d4f33
              *     app.example-properties=pg:t4YBfv8M9ZmTzWgTi2gJqg==
              * 
            - * Then, add the command line arguments like {@code --pe.key=3856faef0d2d4f33}. + * After that, before running, you need to add the command line arguments + * "pg.key" as the following codes: {@code --pg.key=}. *

            * This class is extracted from MyBatis-Plus. - *

            - * The prefix to specify the encrypted value is {@code pg}. * * @author hubin@baomidou * @version 1.1.0 - * @see org.springframework.boot.env.EnvironmentPostProcessor + * @see EnvironmentPostProcessor * @since 1.1.0 (3.3.2 of MyBatis-Plus) */ public class PropertyGuard implements EnvironmentPostProcessor { diff --git a/simple-jwt-authzero/src/main/java/cn/org/codecrafters/simplejwt/authzero/AuthzeroTokenResolver.java b/simple-jwt-authzero/src/main/java/cn/org/codecrafters/simplejwt/authzero/AuthzeroTokenResolver.java index 653fd3b..01d3359 100644 --- a/simple-jwt-authzero/src/main/java/cn/org/codecrafters/simplejwt/authzero/AuthzeroTokenResolver.java +++ b/simple-jwt-authzero/src/main/java/cn/org/codecrafters/simplejwt/authzero/AuthzeroTokenResolver.java @@ -122,11 +122,11 @@ public class AuthzeroTokenResolver implements TokenResolver { private final AuthzeroTokenResolverConfig config = AuthzeroTokenResolverConfig.getInstance(); /** - * Creates a new instance of AuthzeroTokenResolver with the provided - * configurations. + * Creates a new instance of {@code AuthzeroTokenResolver} with the + * provided configurations. * - * @param jtiCreator the GuidCreator used for generating unique identifiers - * for "jti" claim in JWT tokens + * @param jtiCreator the {@link GuidCreator} used for generating unique + * identifiers for "jti" claim in JWT tokens * @param algorithm the algorithm used for signing and verifying JWT * tokens * @param issuer the issuer claim value to be included in JWT tokens @@ -151,8 +151,8 @@ public class AuthzeroTokenResolver implements TokenResolver { } /** - * Creates a new instance of AuthzeroTokenResolver with the provided - * configurations and a simple UUID GuidCreator. + * Creates a new instance of {@link AuthzeroTokenResolver} with the + * provided configurations and a simple UUID GuidCreator. * * @param algorithm the algorithm used for signing and verifying JWT tokens * @param issuer the issuer claim value to be included in JWT tokens @@ -168,7 +168,7 @@ public class AuthzeroTokenResolver implements TokenResolver { log.warn("The provided secret which owns {} characters is too weak. Please consider replacing it with a stronger one.", secret.length()); } - this.jtiCreator = (GuidCreator) UUID::randomUUID; + this.jtiCreator = UUID::randomUUID; this.algorithm = config .getAlgorithm(algorithm) .apply(secret); @@ -177,8 +177,9 @@ public class AuthzeroTokenResolver implements TokenResolver { } /** - * Creates a new instance of AuthzeroTokenResolver with the provided - * configurations, HMAC256 algorithm and a simple UUID GuidCreator. + * Creates a new instance of {@link AuthzeroTokenResolver} with the + * provided configurations, HMAC256 algorithm and a simple + * UUID GuidCreator. * * @param issuer the issuer claim value to be included in JWT tokens * @param secret the secret used for HMAC-based algorithms (HS256, @@ -193,7 +194,7 @@ public class AuthzeroTokenResolver implements TokenResolver { log.warn("The provided secret which owns {} characters is too weak. Please consider replacing it with a stronger one.", secret.length()); } - this.jtiCreator = (GuidCreator) UUID::randomUUID; + this.jtiCreator = UUID::randomUUID; this.algorithm = config .getAlgorithm(TokenAlgorithm.HS256) .apply(secret); @@ -202,15 +203,16 @@ public class AuthzeroTokenResolver implements TokenResolver { } /** - * Creates a new instance of AuthzeroTokenResolver with the provided - * configurations, HMAC256 algorithm and a simple UUID GuidCreator. + * Creates a new instance of {@link AuthzeroTokenResolver} with the + * provided configurations, HMAC256 algorithm and a simple + * UUID GuidCreator. * * @param issuer the issuer claim value to be included in JWT tokens */ public AuthzeroTokenResolver(String issuer) { var secret = SecretCreator.createSecret(32, true, true, true); - this.jtiCreator = (GuidCreator) UUID::randomUUID; + this.jtiCreator = UUID::randomUUID; this.algorithm = config .getAlgorithm(TokenAlgorithm.HS256) .apply(secret); @@ -286,16 +288,13 @@ public class AuthzeroTokenResolver implements TokenResolver { } /** - *

            * 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 @@ -310,9 +309,7 @@ public class AuthzeroTokenResolver implements TokenResolver { } /** - *

            * Finish creating a token. - * *

            * This is the final step of create a token, to sign this token. * @@ -324,7 +321,7 @@ public class AuthzeroTokenResolver implements TokenResolver { } /** - * Creates a new token with the specified expiration time, subject, and + * Creates a new token with the specified expiration duration, subject, and * audience. * * @param expireAfter the duration after which the token will expire @@ -387,7 +384,7 @@ public class AuthzeroTokenResolver implements TokenResolver { // Build Claims addClaim(builder, field.getName(), field.get(payload)); } catch (IllegalAccessException e) { - log.error("Cannot access field %s!".formatted(field.getName())); + log.error("Cannot access field {}!", field.getName()); } } @@ -395,10 +392,10 @@ public class AuthzeroTokenResolver implements TokenResolver { } /** - * Resolves the given token into a DecodedJWT object. + * Resolves the given token into a {@link DecodedJWT} object. * * @param token the token to be resolved - * @return a ResolvedToken object + * @return a {@link DecodedJWT} object */ @Override public DecodedJWT resolve(String token) { @@ -449,9 +446,9 @@ public class AuthzeroTokenResolver implements TokenResolver { return bean; } catch (NoSuchMethodException e) { - log.error("Unable to find a no-argument constructor declaration for class %s.".formatted(targetType.getCanonicalName())); + log.error("Unable to find a no-argument constructor declaration for class {}.", targetType.getCanonicalName()); } catch (InstantiationException | IllegalAccessException | InvocationTargetException e) { - log.error("Unable to create a new instance of class %s.".formatted(targetType.getCanonicalName())); + log.error("Unable to create a new instance of class {}.", targetType.getCanonicalName()); } return null; } @@ -475,7 +472,7 @@ public class AuthzeroTokenResolver implements TokenResolver { /** * Renews the given expired token with the specified custom payload data. * - * @param oldToken the expired token to be renewed + * @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} @@ -489,7 +486,7 @@ public class AuthzeroTokenResolver implements TokenResolver { * Renews the given expired token with the new specified strongly-typed * payload data. * - * @param oldToken the expired token to be renewed + * @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} @@ -511,7 +508,7 @@ public class AuthzeroTokenResolver implements TokenResolver { * @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} + * @return the renewed token as a {@link String} */ @Override public String renew(String oldToken, T payload) { diff --git a/simple-jwt-authzero/src/main/java/cn/org/codecrafters/simplejwt/authzero/config/AuthzeroTokenResolverConfig.java b/simple-jwt-authzero/src/main/java/cn/org/codecrafters/simplejwt/authzero/config/AuthzeroTokenResolverConfig.java index 9377571..2cda8ea 100644 --- a/simple-jwt-authzero/src/main/java/cn/org/codecrafters/simplejwt/authzero/config/AuthzeroTokenResolverConfig.java +++ b/simple-jwt-authzero/src/main/java/cn/org/codecrafters/simplejwt/authzero/config/AuthzeroTokenResolverConfig.java @@ -17,6 +17,8 @@ package cn.org.codecrafters.simplejwt.authzero.config; +import cn.org.codecrafters.simplejwt.TokenResolver; +import cn.org.codecrafters.simplejwt.authzero.AuthzeroTokenResolver; import cn.org.codecrafters.simplejwt.config.TokenResolverConfig; import cn.org.codecrafters.simplejwt.constants.TokenAlgorithm; import cn.org.codecrafters.simplejwt.exceptions.UnsupportedAlgorithmException; @@ -29,29 +31,29 @@ import java.util.Optional; import java.util.function.Function; /** - * The AuthzeroTokenResolverConfig class provides the configuration for the - * AuthzeroTokenResolver. + * The {@code AuthzeroTokenResolverConfig} class provides the configuration for + * the {@link AuthzeroTokenResolver}. *

            - * This configuration class is used to establish the mapping between the - * standard TokenAlgorithm defined within the AuthzeroTokenResolver facade and - * the specific algorithms used by the Auth0 Java JWT library, which is the - * underlying library used by AuthzeroTokenResolver to handle JSON Web Tokens - * (JWTs). + * This configuration is used to establish the mapping between the standard + * {@link TokenAlgorithm} defined within the {@link AuthzeroTokenResolver} + * facade and the specific algorithms used by the {@code com.auth0:java-jwt} + * library, which is the underlying library used by {@link + * AuthzeroTokenResolver} to handle JSON Web Tokens (JWTs). *

            * Algorithm Mapping: - * The AuthzeroTokenResolverConfig class allows specifying the relationship - * between the standard TokenAlgorithm instances supported by - * AuthzeroTokenResolver and the corresponding algorithms used by the - * com.auth0:java-jwt library. The mapping is achieved using a Map, where the - * keys are the standard TokenAlgorithm instances, and the values represent the - * algorithm functions used by Auth0 Java JWT library for each corresponding - * key. + * The {@code AuthzeroTokenResolverConfig} allows specifying the relationship + * between the standard {@link TokenAlgorithm} instances supported by + * {@link AuthzeroTokenResolver} and the corresponding algorithms used by the + * {@code com.auth0:java-jwt} library. The mapping is achieved using a Map, + * where the keys are the standard TokenAlgorithm instances, and the values + * represent the algorithm functions used by Auth0 Java JWT library for each + * corresponding key. *

            * Note: * The provided algorithm mapping should be consistent with the actual - * algorithms supported and used by the Auth0 Java JWT library. It is crucial - * to ensure that the mapping is accurate to enable proper token validation - * and processing within the AuthzeroTokenResolver. + * algorithms supported and used by the {@code com.auth0:java-jwt} library. It + * is crucial to ensure that the mapping is accurate to enable proper token + * validation and processing within the {@link AuthzeroTokenResolver}. * * @author Zihlu Wang * @version 1.1.0 @@ -60,39 +62,34 @@ import java.util.function.Function; public final class AuthzeroTokenResolverConfig implements TokenResolverConfig> { /** - *

            - * Constructs a new instance of AuthzeroTokenResolverConfig. - * + * Constructs a new instance of {@code AuthzeroTokenResolverConfig}. *

            * The constructor is set as private to enforce the singleton pattern for - * this configuration class. Instances of AuthzeroTokenResolverConfig - * should be obtained through the {@link #getInstance()} method. + * this configuration class. Instances of + * {@code AuthzeroTokenResolverConfig} should be obtained through the + * {@link #getInstance()} method. */ private AuthzeroTokenResolverConfig() { } /** - *

            - * The singleton instance of AuthzeroTokenResolverConfig. - * + * The singleton instance of {@code AuthzeroTokenResolverConfig}. *

            * This instance is used to ensure that only one instance of - * AuthzeroTokenResolverConfig is created and shared throughout the - * application. The singleton pattern is implemented to provide centralized + * {@code AuthzeroTokenResolverConfig} is created and shared throughout the + * application. The singleton pattern is implemented to provide centralised * configuration and avoid redundant object creation. */ private static AuthzeroTokenResolverConfig instance; /** - *

            * The supported algorithms and their corresponding algorithm functions. - * *

            * This map stores the supported algorithms as keys and their corresponding * algorithm functions as values. The algorithm functions represent the - * functions used by the Auth0 Java JWT library to handle the specific - * algorithms. The mapping is used to provide proper algorithm resolution - * and processing within the AuthzeroTokenResolver. + * functions used by the {@code com.auth0:java-jwt} library to handle the + * specific algorithms. The mapping is used to provide proper algorithm + * resolution and processing within the {@link AuthzeroTokenResolver}. */ private static final Map> SUPPORTED_ALGORITHMS = new HashMap<>() {{ put(TokenAlgorithm.HS256, Algorithm::HMAC256); @@ -101,14 +98,14 @@ public final class AuthzeroTokenResolverConfig implements TokenResolverConfig * This method returns the singleton instance of - * AuthzeroTokenResolverConfig. If the instance is not yet created, it will - * create a new instance and return it. Otherwise, it returns the existing - * instance. + * {@code AuthzeroTokenResolverConfig}. If the instance is not yet created, + * it will create a new instance and return it. Otherwise, it returns the + * existing instance. * - * @return the instance of AuthzeroTokenResolverConfig + * @return the instance of {@code AuthzeroTokenResolverConfig} */ public static AuthzeroTokenResolverConfig getInstance() { if (Objects.isNull(instance)) { @@ -119,20 +116,20 @@ public final class AuthzeroTokenResolverConfig implements TokenResolverConfig * Gets the algorithm function corresponding to the specified - * TokenAlgorithm. - * + * {@link TokenAlgorithm}. *

            * This method returns the algorithm function associated with the given - * TokenAlgorithm. The provided TokenAlgorithm represents the specific - * algorithm for which the corresponding algorithm function is required. - * The returned AlgorithmFunction represents the function implementation - * that can be used by the TokenResolver to handle the specific algorithm. + * {@link TokenAlgorithm}. The provided {@link TokenAlgorithm} represents + * the specific algorithm for which the corresponding algorithm function + * is required. The returned Algorithm Function represents the function + * implementation that can be used by the {@link TokenResolver} to handle + * the specific algorithm. * - * @param algorithm the TokenAlgorithm for which the algorithm function is - * required - * @return the algorithm function associated with the given TokenAlgorithm + * @param algorithm the {@link TokenAlgorithm} for which the algorithm + * function isrequired + * @return the algorithm function associated with the given {@link + * TokenAlgorithm} * @throws UnsupportedAlgorithmException if the given {@code algorithm} is * not supported by this * implementation diff --git a/simple-jwt-authzero/src/main/java/cn/org/codecrafters/simplejwt/authzero/package-info.java b/simple-jwt-authzero/src/main/java/cn/org/codecrafters/simplejwt/authzero/package-info.java index c8ba91c..11df0aa 100644 --- a/simple-jwt-authzero/src/main/java/cn/org/codecrafters/simplejwt/authzero/package-info.java +++ b/simple-jwt-authzero/src/main/java/cn/org/codecrafters/simplejwt/authzero/package-info.java @@ -33,18 +33,21 @@ * main token resolver in the Simple JWT project when integrating {@code * com.auth0:java-jwt} as the JWT management library. *

            - * The {@code AuthzeroTokenResolver} relies on the {@code com.auth0:java-jwt} - * library to handle the underlying JWT operations, including token creation, - * validation, and extraction. It utilizes the {@code com.auth0:java-jwt} - * {@code Algorithm} class to define and use different algorithms for JWT - * signing and verification. + * The {@link cn.org.codecrafters.simplejwt.authzero.AuthzeroTokenResolver} + * relies on the {@code com.auth0:java-jwt} library to handle the underlying + * JWT operations, including token creation, validation, and extraction. It + * utilizes the {@code com.auth0:java-jwt} {@link + * com.auth0.jwt.algorithms.Algorithm} class to define and use different + * algorithms for JWT signing and verification. *

            - * To use the {@code AuthzeroTokenResolver}, developers must provide the - * necessary configurations and dependencies, such as the {@code GuidCreator} - * for generating unique JWT IDs (JTI), the supported algorithm function, the - * issuer name, and the secret key used for token signing and validation. The - * {@code AuthzeroTokenResolverConfig} class provides a convenient way to - * configure these dependencies. + * To use the {@link + * cn.org.codecrafters.simplejwt.authzero.AuthzeroTokenResolver}, developers + * must provide the necessary configurations and dependencies, such as the + * {@link cn.org.codecrafters.guid.GuidCreator} for generating unique JWT IDs + * (JTI), the supported algorithm function, the issuer name, and the secret key + * used for token signing and validation. The {@link + * cn.org.codecrafters.simplejwt.authzero.config.AuthzeroTokenResolverConfig} + * class provides a convenient way to configure these dependencies. *

            * Developers using the {@code com.auth0:java-jwt} integration should be * familiar with the concepts and usage of the {@code com.auth0:java-jwt} diff --git a/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/SecretCreator.java b/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/SecretCreator.java index de06136..4f274ec 100644 --- a/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/SecretCreator.java +++ b/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/SecretCreator.java @@ -22,9 +22,9 @@ import cn.org.codecrafters.simplejwt.exceptions.WeakSecretException; import java.util.Random; /** - * 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 @@ -83,24 +83,23 @@ public final class SecretCreator { 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)); + Please replace it with a stronger secret.""".formatted(length)); } - final var randomizer = new Random(); + 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 password = new StringBuilder(); + var secretBuilder = new StringBuilder(); var charsetSize = charset.length(); for (var i = 0; i < length; ++i) { - password.append(charset.charAt(randomizer.nextInt(charsetSize))); + secretBuilder.append(charset.charAt(randomiser.nextInt(charsetSize))); } - return password.toString(); + return secretBuilder.toString(); } /** @@ -115,6 +114,7 @@ public final class SecretCreator { * @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, @@ -132,6 +132,7 @@ public final class SecretCreator { * @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) { @@ -146,6 +147,7 @@ public final class SecretCreator { * @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); diff --git a/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/TokenPayload.java b/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/TokenPayload.java index e69a480..657e83c 100644 --- a/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/TokenPayload.java +++ b/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/TokenPayload.java @@ -20,21 +20,15 @@ package cn.org.codecrafters.simplejwt; import java.util.Map; /** - *

            - * TokenPayload - Interface for JWT Payload Data Classes. - * - *

            - * The {@code TokenPayload} interface is used to mark a data class as suitable + * {@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} diff --git a/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/TokenResolver.java b/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/TokenResolver.java index 17fcce4..c69818d 100644 --- a/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/TokenResolver.java +++ b/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/TokenResolver.java @@ -22,10 +22,10 @@ import java.time.Duration; import java.util.Map; /** - * The {@code TokenResolver} interface 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. + * {@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 diff --git a/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/annotations/ExcludeFromPayload.java b/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/annotations/ExcludeFromPayload.java index 2aa1450..72dac57 100644 --- a/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/annotations/ExcludeFromPayload.java +++ b/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/annotations/ExcludeFromPayload.java @@ -23,11 +23,10 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** - *

            - * This annotation 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 with this - * annotation, it will not be included as part of the JWT payload. + * 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 @@ -46,10 +45,10 @@ import java.lang.annotation.Target; * }

            *

            * Note: - * This annotation should be used only on properties that are not intended to + * 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. It is important to carefully choose which properties are excluded - * from the payload to ensure the JWT remains secure and efficient. + * 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 diff --git a/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/config/TokenResolverConfig.java b/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/config/TokenResolverConfig.java index da64e21..2989a03 100644 --- a/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/config/TokenResolverConfig.java +++ b/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/config/TokenResolverConfig.java @@ -17,19 +17,21 @@ package cn.org.codecrafters.simplejwt.config; +import cn.org.codecrafters.simplejwt.TokenResolver; import cn.org.codecrafters.simplejwt.constants.TokenAlgorithm; /** - * The TokenResolverConfig interface provides a mechanism to configure a - * TokenResolver with algorithm functions. + * The {@code TokenResolverConfig} provides a mechanism to configure a + * {@link TokenResolver} with algorithm functions. *

            * This generic interface is used to define the configuration details for a - * TokenResolver that utilizes algorithm functions. The interface allows for - * specifying algorithm functions corresponding to different TokenAlgorithm - * instances supported by the TokenResolver implementation. + * {@link TokenResolver} that utilizes algorithm functions. The interface + * allows for specifying algorithm functions corresponding to different {@link + * TokenAlgorithm} instances supported by the {@link TokenResolver} + * implementation. * * @param the type representing algorithm functions used by the - * {@code TokenResolver} + * {@link TokenResolver} * @author Zihlu Wang * @version 1.0.0 * @since 1.0.0 @@ -37,18 +39,20 @@ import cn.org.codecrafters.simplejwt.constants.TokenAlgorithm; public interface TokenResolverConfig { /** - * Gets the algorithm function corresponding to the specified - * TokenAlgorithm. + * Gets the algorithm function corresponding to the specified {@link + * TokenAlgorithm}. *

            * This method returns the algorithm function associated with the given - * TokenAlgorithm. The provided TokenAlgorithm represents the specific - * algorithm for which the corresponding algorithm function is required. - * The returned AlgorithmFunction represents the function implementation - * that can be used by the TokenResolver to handle the specific algorithm. + * {@link TokenAlgorithm}. The provided TokenAlgorithm represents the + * specific algorithm for which the corresponding algorithm function is + * required. The returned {@code Algo} represents the function + * implementation that can be used by the {@link TokenResolver} to handle + * the specific algorithm. * - * @param algorithm the TokenAlgorithm for which the algorithm function is - * required - * @return the algorithm function associated with the given TokenAlgorithm + * @param algorithm the {@link TokenAlgorithm} for which the algorithm + * function is required + * @return the algorithm function associated with the given {@link + * TokenAlgorithm} */ Algo getAlgorithm(TokenAlgorithm algorithm); diff --git a/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/config/package-info.java b/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/config/package-info.java index 0fa35ff..97774c4 100644 --- a/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/config/package-info.java +++ b/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/config/package-info.java @@ -17,14 +17,15 @@ /** * The classes in this package provide configuration options and settings for - * the Simple JWT library. They are used to customize the behavior of the - * library and allow developers to fine-tune various aspects of JWT generation - * and validation. + * the {@code cn.org.codecrafters:simple-jwt-facade} library. They are used + * to customize the behavior of the library and allow developers to fine-tune + * various aspects of JWT generation and validation. *

            * Other configuration classes may be added in the future to support additional - * customisation options and features. Developers using the Simple JWT library - * should be familiar with the available configuration options to ensure proper - * integration and usage of the library. + * customisation options and features. Developers using the + * {@code cn.org.codecrafters:simple-jwt-facade} library should be familiar + * with the available configuration options to ensure proper integration and + * usage of the library. * * @since 1.0.0 */ diff --git a/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/constants/PredefinedKeys.java b/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/constants/PredefinedKeys.java index 467869b..3aee4db 100644 --- a/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/constants/PredefinedKeys.java +++ b/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/constants/PredefinedKeys.java @@ -87,11 +87,13 @@ public final class PredefinedKeys { public static final List KEYS = List.of(ISSUER, SUBJECT, AUDIENCE, EXPIRATION_TIME, NOT_BEFORE, ISSUED_AT, JWT_ID); /** - * Private constructor to prevent instantiation of the {@code PredefinedKeys} class. - * This class is intended to be used as a utility class with only static constants and methods. + * Private constructor to prevent instantiation of the + * {@code PredefinedKeys} class. + *

            + * This class is intended to be used as a utility class with only static + * constants and methods. */ private PredefinedKeys() { - // Private constructor to prevent instantiation } } diff --git a/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/constants/TokenAlgorithm.java b/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/constants/TokenAlgorithm.java index c790306..4725089 100644 --- a/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/constants/TokenAlgorithm.java +++ b/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/constants/TokenAlgorithm.java @@ -25,8 +25,8 @@ import lombok.Getter; * 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: - * This enum includes the following supported algorithms: + *

            + * Supported Algorithms: *

              *
            • {@link TokenAlgorithm#HS256}: HMAC SHA-256
            • *
            • {@link TokenAlgorithm#HS384}: HMAC SHA-384
            • diff --git a/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/exceptions/UnsupportedAlgorithmException.java b/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/exceptions/UnsupportedAlgorithmException.java index 1ddb111..020ea63 100644 --- a/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/exceptions/UnsupportedAlgorithmException.java +++ b/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/exceptions/UnsupportedAlgorithmException.java @@ -18,10 +18,15 @@ package cn.org.codecrafters.simplejwt.exceptions; /** - * This {@code UnsupportedAlgorithmException} is to indicates that the given - * algorithm is not supported by TokenResolver yet. + * This {@code UnsupportedAlgorithmException} represents the given + * algorithm is not supported by {@link + * cn.org.codecrafters.simplejwt.TokenResolver} yet. *

              - * To support a specified algorithm, you could + * 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 Zihlu Wang * @version 1.1.0 @@ -30,17 +35,17 @@ package cn.org.codecrafters.simplejwt.exceptions; public class UnsupportedAlgorithmException extends RuntimeException { /** - * Constructs a new runtime exception 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 runtime exception 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. @@ -50,12 +55,8 @@ public class UnsupportedAlgorithmException extends RuntimeException { } /** - * Constructs a new runtime exception 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. + * 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). @@ -70,11 +71,12 @@ public class UnsupportedAlgorithmException extends RuntimeException { } /** - * Constructs a new runtime exception 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 throwables. + * 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 @@ -87,9 +89,9 @@ public class UnsupportedAlgorithmException extends RuntimeException { } /** - * Constructs a new runtime exception 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, diff --git a/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/exceptions/WeakSecretException.java b/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/exceptions/WeakSecretException.java index bc46ec6..25126f9 100644 --- a/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/exceptions/WeakSecretException.java +++ b/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/exceptions/WeakSecretException.java @@ -18,8 +18,12 @@ package cn.org.codecrafters.simplejwt.exceptions; /** - * This Exception indicates 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}. * * @author Zihlu Wang * @version 1.1.0 @@ -28,17 +32,17 @@ package cn.org.codecrafters.simplejwt.exceptions; public class WeakSecretException extends RuntimeException { /** - * Constructs a new runtime exception with {@code null} as its - * detail message. The cause is not initialized, and may subsequently be + * 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 runtime exception 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 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. @@ -48,10 +52,11 @@ public class WeakSecretException extends RuntimeException { } /** - * Constructs a new runtime exception 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. + * 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). @@ -59,42 +64,41 @@ public class WeakSecretException extends RuntimeException { * {@link #getCause()} method). (A {@code null} value is * permitted, and indicates that the cause is nonexistent or * unknown.) - * @since 1.4 + * @since 1.0.0 */ public WeakSecretException(String message, Throwable cause) { super(message, cause); } /** - * Constructs a new runtime exception with the specified cause and a - * detail message of {@code (cause==null ? null : cause.toString())} + * 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 throwables. + * {@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 + * @since 1.0.0 */ public WeakSecretException(Throwable cause) { super(cause); } /** - * Constructs a new runtime exception with the specified detail + * 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 or not suppression is enabled - * or disabled - * @param writableStackTrace whether or not the stack trace should - * be writable - * @since 1.7 + * @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/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/exceptions/package-info.java b/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/exceptions/package-info.java index 470140c..b8f48f8 100644 --- a/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/exceptions/package-info.java +++ b/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/exceptions/package-info.java @@ -17,20 +17,22 @@ /** * The {@code cn.org.codecrafters.simplejwt.exceptions} package contains - * custom exception classes related to the Simple JWT library. These - * exceptions are thrown when there are issues or errors during the generation - * , validation, or processing of JSON Web Tokens (JWTs) in Java applications. + * custom exception classes related to the + * {@code cn.org.codecrafters:simple-jwt-facade} library. These exceptions are + * thrown when there are issues or errors during the generation , validation, + * or processing of JSON Web Tokens (JWTs) in Java applications. *

              * Custom exception classes in this package are designed to enhance the * robustness and reliability of the JWT handling process by providing clear * and meaningful error messages to the developers. They help developers * identify and troubleshoot issues related to JWT generation, validation, or - * extraction and ensure smooth operation and error handling in their - * applications. + * extraction and ensure smooth operation and error handling in + * their applications. *

              - * Developers using the Simple JWT library should be aware of the possible - * exceptions that can be thrown and handle them appropriately to ensure secure - * and reliable JWT handling in their Java applications. + * Developers using the {@code cn.org.codecrafters:simple-jwt-facade} library + * should be aware of the possible exceptions that can be thrown and handle + * them appropriately to ensure secure and reliable JWT handling in their + * Java applications. * * @since 1.0.0 */ diff --git a/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/package-info.java b/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/package-info.java index 490200b..791dae8 100644 --- a/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/package-info.java +++ b/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/package-info.java @@ -17,22 +17,22 @@ /** * The {@code cn.org.codecrafters.simplejwt} package is the core package of the - * Simple JWT project, which provides a lightweight and easy-to-use library for - * working with JSON Web Tokens (JWTs) in Java applications. JWT is a - * widely-used standard for representing claims between two parties, typically - * used to secure web and mobile applications. This library aims to simplify - * the JWT handling process and provide convenient abstractions for JWT - * generation, validation, and extraction. + * Simple JWT project, which provides a lightweight and easy-to-use + * library for working with JSON Web Tokens (JWTs) in Java applications. JWT is + * a widely-used standard for representing claims between two parties, + * typically used to secure web and mobile applications. This library aims to + * simplify the JWT handling process and provide convenient abstractions for + * JWT generation, validation, and extraction. *

              - * The Simple JWT library is designed to be flexible and customisable, allowing - * developers to use different algorithms, token resolvers, and token payload - * classes based on their specific application requirements. It aims to + * The Simple JWT library is designed to be flexible and customisable, + * allowing developers to use different algorithms, token resolvers, and token + * payload classes based on their specific application requirements. It aims to * simplify the JWT handling process while maintaining security and best * practices for working with JWTs. *

              * Developers should refer to the official documentation and examples for the - * Simple JWT project to understand how to use the library effectively and - * securely in their Java applications. + * Simple JWT project to understand how to use the library effectively + * and securely in their Java applications. * * * @since 1.0.0 diff --git a/simple-jwt-jjwt/src/main/java/cn/org/codecrafters/simplejwt/jjwt/JjwtTokenResolver.java b/simple-jwt-jjwt/src/main/java/cn/org/codecrafters/simplejwt/jjwt/JjwtTokenResolver.java index fc9f4e8..b8896ef 100644 --- a/simple-jwt-jjwt/src/main/java/cn/org/codecrafters/simplejwt/jjwt/JjwtTokenResolver.java +++ b/simple-jwt-jjwt/src/main/java/cn/org/codecrafters/simplejwt/jjwt/JjwtTokenResolver.java @@ -58,7 +58,7 @@ import java.util.UUID; * To use the {@code JjwtTokenResolver}, first, create an instance of this * class: *

              {@code
              - *   TokenResolver tokenResolver =
              + *   TokenResolver> tokenResolver =
                *       new JjwtTokenResolver(TokenAlgorithm.HS256,
                *                                 "Token Subject",
                *                                 "Token Issuer",
              @@ -119,7 +119,7 @@ public class JjwtTokenResolver implements TokenResolver> {
               
                       if (secret.length() <= 32) {
                           log.error("""
              -                            The provided secret which owns {} characters is too weak. Please replace it with a stronger one.""",
              +                      The provided secret which owns {} characters is too weak. Please replace it with a stronger one.""",
                                   secret.length());
                           throw new WeakSecretException("""
                                   The provided secret which owns %s characters is too weak. Please replace it with a stronger one."""
              @@ -256,7 +256,7 @@ public class JjwtTokenResolver implements TokenResolver> {
                   }
               
                   /**
              -     * Resolves the given token into a ResolvedTokenType object.
              +     * Resolves the given token into a {@link Jws} object.
                    *
                    * @param token the token to be resolved
                    * @return a ResolvedTokenType object
              @@ -287,7 +287,7 @@ public class JjwtTokenResolver implements TokenResolver> {
                       try {
                           return MapUtil.mapToObject(claims, targetType);
                       } catch (InvocationTargetException e) {
              -            log.info("An error occurs while invoking the constructor of type {}.", targetType.getCanonicalName());
              +            log.error("An error occurs while invoking the constructor of type {}.", targetType.getCanonicalName());
                       } catch (NoSuchMethodException e) {
                           log.error("The constructor of the required type {} is not found.", targetType.getCanonicalName());
                       } catch (InstantiationException e) {
              diff --git a/simple-jwt-jjwt/src/main/java/cn/org/codecrafters/simplejwt/jjwt/config/JjwtTokenResolverConfig.java b/simple-jwt-jjwt/src/main/java/cn/org/codecrafters/simplejwt/jjwt/config/JjwtTokenResolverConfig.java
              index adf118f..a174665 100644
              --- a/simple-jwt-jjwt/src/main/java/cn/org/codecrafters/simplejwt/jjwt/config/JjwtTokenResolverConfig.java
              +++ b/simple-jwt-jjwt/src/main/java/cn/org/codecrafters/simplejwt/jjwt/config/JjwtTokenResolverConfig.java
              @@ -17,6 +17,7 @@
               
               package cn.org.codecrafters.simplejwt.jjwt.config;
               
              +import cn.org.codecrafters.simplejwt.TokenResolver;
               import cn.org.codecrafters.simplejwt.config.TokenResolverConfig;
               import cn.org.codecrafters.simplejwt.constants.TokenAlgorithm;
               import cn.org.codecrafters.simplejwt.exceptions.UnsupportedAlgorithmException;
              @@ -27,23 +28,23 @@ import java.util.HashMap;
               import java.util.Map;
               
               /**
              - * The JjwtTokenResolverConfig class provides the configuration for the
              - * JjwtTokenResolverConfig.
              + * The {@code JjwtTokenResolverConfig} class provides the configuration for the
              + * {@link JjwtTokenResolver}.
                * 

              * This configuration class is used to establish the mapping between the - * standard TokenAlgorithm defined within the JjwtTokenResolverConfig and - * the specific algorithms used by the {@code io.jsonwebtoken:jjwt} library, - * which is the underlying library used by JjwtTokenResolverConfig to handle - * JSON Web Tokens (JWTs). + * standard {@link TokenAlgorithm} defined within the + * {@code JjwtTokenResolverConfig} and the specific algorithms used by the + * {@code io.jsonwebtoken:jjwt} library, which is the underlying library used + * by {@code JjwtTokenResolver} to handle JSON Web Tokens (JWTs). *

              * Algorithm Mapping: - * The JjwtTokenResolverConfig class allows specifying the relationship - * between the standard TokenAlgorithm instances supported by - * JjwtTokenResolverConfig and the corresponding algorithms used by the + * The {@code JjwtTokenResolverConfig} allows specifying the relationship + * between the standard {@link TokenAlgorithm} instances supported by {@link + * JjwtTokenResolver} and the corresponding algorithms used by the * {@code io.jsonwebtoken:jjwt} library. The mapping is achieved using a Map, - * where the keys are the standard TokenAlgorithm instances, and the values - * represent the algorithm functions used by {@code io.jsonwebtoken:jjwt} - * library for each corresponding key. + * where the keys are the standard {@link TokenAlgorithm} instances, and the + * values represent the algorithm functions used by + * {@code io.jsonwebtoken:jjwt} library for each corresponding key. *

              * Note: * The provided algorithm mapping should be consistent with the actual @@ -78,24 +79,25 @@ public final class JjwtTokenResolverConfig implements TokenResolverConfig * This method returns the algorithm function associated with the given - * TokenAlgorithm. The provided TokenAlgorithm represents the specific - * algorithm for which the corresponding algorithm function is required. - * The returned AlgorithmFunction represents the function implementation - * that can be used by the TokenResolver to handle the specific algorithm. + * {@link TokenAlgorithm}. The provided {@link TokenAlgorithm} represents + * the specific algorithm for which the corresponding algorithm function is + * required. The returned algorithm function represents the function + * implementation that can be used by the {@link TokenResolver} to handle + * the specific algorithm. * - * @param algorithm the TokenAlgorithm for which the algorithm function is - * required - * @return the algorithm function associated with the given TokenAlgorithm + * @param algorithm the {@link TokenAlgorithm} for which the algorithm + * function is required + * @return the algorithm function associated with the given {@link + * TokenAlgorithm} */ @Override public SignatureAlgorithm getAlgorithm(TokenAlgorithm algorithm) { if (!SUPPORTED_ALGORITHMS.containsKey(algorithm)) { throw new UnsupportedAlgorithmException(""" - The request algorithm is not supported by our system yet. Please change to supported ones. - """); + The request algorithm is not supported by our system yet. Please change to supported ones."""); } return SUPPORTED_ALGORITHMS.get(algorithm); } diff --git a/simple-jwt-jjwt/src/main/java/cn/org/codecrafters/simplejwt/jjwt/package-info.java b/simple-jwt-jjwt/src/main/java/cn/org/codecrafters/simplejwt/jjwt/package-info.java index 5a3eca5..1753d09 100644 --- a/simple-jwt-jjwt/src/main/java/cn/org/codecrafters/simplejwt/jjwt/package-info.java +++ b/simple-jwt-jjwt/src/main/java/cn/org/codecrafters/simplejwt/jjwt/package-info.java @@ -33,18 +33,20 @@ * this class as the main token resolver in the Simple JWT project when * integrating {@code io.jsonwebtoken:jjwt-api} as the JWT management library. *

              - * The {@code JjwtTokenResolver} relies on the {@code io.jsonwebtoken:jjwt-api} + * The {@link cn.org.codecrafters.simplejwt.jjwt.JjwtTokenResolver} relies on + * the {@code io.jsonwebtoken:jjwt-api} * library to handle the underlying JWT operations, including token creation, * validation, and extraction. It utilizes the {@code io.jsonwebtoken:jjwt-api} - * {@code Algorithm} class to define and use different algorithms for JWT - * signing and verification. + * {@link io.jsonwebtoken.SignatureAlgorithm} class to define and use different + * algorithms for JWT signing and verification. *

              - * To use the {@code JjwtTokenResolver}, developers must provide the necessary - * configurations and dependencies, such as the {@code GuidCreator} for - * generating unique JWT IDs (JTI), the supported algorithm function, the - * issuer name, and the secret key used for token signing and validation. The - * {@code JjwtTokenResolverConfig} class provides a convenient way to configure - * these dependencies. + * To use the {@link cn.org.codecrafters.simplejwt.jjwt.JjwtTokenResolver}, + * developers must provide the necessary configurations and dependencies, such + * as the {@link cn.org.codecrafters.guid.GuidCreator} for generating unique + * JWT IDs (JTI), the supported algorithm function, the issuer name, and the + * secret key used for token signing and validation. The + * {@link cn.org.codecrafters.simplejwt.jjwt.config.JjwtTokenResolverConfig} + * class provides a convenient way to configure these dependencies. *

              * Developers using the {@code io.jsonwebtoken:jjwt-api} integration should be * familiar with the concepts and usage of the {@code io.jsonwebtoken:jjwt-api} diff --git a/simple-jwt-spring-boot-starter/src/main/java/cn/org/codecrafters/simplejwt/autoconfiguration/AuthzeroTokenResolverAutoConfiguration.java b/simple-jwt-spring-boot-starter/src/main/java/cn/org/codecrafters/simplejwt/autoconfiguration/AuthzeroTokenResolverAutoConfiguration.java index a32a3e2..747b36a 100644 --- a/simple-jwt-spring-boot-starter/src/main/java/cn/org/codecrafters/simplejwt/autoconfiguration/AuthzeroTokenResolverAutoConfiguration.java +++ b/simple-jwt-spring-boot-starter/src/main/java/cn/org/codecrafters/simplejwt/autoconfiguration/AuthzeroTokenResolverAutoConfiguration.java @@ -34,20 +34,21 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.DependsOn; /** - * SimpleJwtAutoConfiguration 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. + * {@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 TokenResolver} bean based on the available options and - * properties. + * 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 customize the behavior of + * However, developers still have the flexibility to customise the behavior of * the library by providing their own configurations and properties. * * @author Zihlu Wang diff --git a/simple-jwt-spring-boot-starter/src/main/java/cn/org/codecrafters/simplejwt/autoconfiguration/GuidAutoConfiguration.java b/simple-jwt-spring-boot-starter/src/main/java/cn/org/codecrafters/simplejwt/autoconfiguration/GuidAutoConfiguration.java index fbc9017..a4d452c 100644 --- a/simple-jwt-spring-boot-starter/src/main/java/cn/org/codecrafters/simplejwt/autoconfiguration/GuidAutoConfiguration.java +++ b/simple-jwt-spring-boot-starter/src/main/java/cn/org/codecrafters/simplejwt/autoconfiguration/GuidAutoConfiguration.java @@ -29,7 +29,7 @@ import org.springframework.context.annotation.Conditional; import java.util.UUID; /** - * Autoconfiguration for injecting a {@code GuidCreator} for generating jwt id. + * Autoconfiguration for injecting a {@link GuidCreator} for generating jwt id. * * @author Zihlu Wang * @version 1.1.0 diff --git a/simple-jwt-spring-boot-starter/src/main/java/cn/org/codecrafters/simplejwt/autoconfiguration/JjwtTokenResolverAutoConfiguration.java b/simple-jwt-spring-boot-starter/src/main/java/cn/org/codecrafters/simplejwt/autoconfiguration/JjwtTokenResolverAutoConfiguration.java index 452254a..26cfc87 100644 --- a/simple-jwt-spring-boot-starter/src/main/java/cn/org/codecrafters/simplejwt/autoconfiguration/JjwtTokenResolverAutoConfiguration.java +++ b/simple-jwt-spring-boot-starter/src/main/java/cn/org/codecrafters/simplejwt/autoconfiguration/JjwtTokenResolverAutoConfiguration.java @@ -34,7 +34,7 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties import org.springframework.context.annotation.Bean; /** - * JjwtTokenResolverAutoConfiguration is responsible for automatically + * {@code JjwtTokenResolverAutoConfiguration} is responsible for automatically * configuring the Simple JWT library with {@code io.jsonwebtoken:jjwt-api} * when used in a Spring Boot application. It provides default settings and * configurations to ensure that the library works smoothly without requiring @@ -42,8 +42,8 @@ import org.springframework.context.annotation.Bean; *

              * This autoconfiguration class sets up the necessary beans and components * required for JWT generation and validation. It automatically creates and - * configures the {@link TokenResolver} bean based on the available options and - * properties. + * configures the {@link JjwtTokenResolver} 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 diff --git a/simple-jwt-spring-boot-starter/src/main/java/cn/org/codecrafters/simplejwt/autoconfiguration/conditions/GuidCreatorCondition.java b/simple-jwt-spring-boot-starter/src/main/java/cn/org/codecrafters/simplejwt/autoconfiguration/conditions/GuidCreatorCondition.java index 4c9ecf5..287b3cd 100644 --- a/simple-jwt-spring-boot-starter/src/main/java/cn/org/codecrafters/simplejwt/autoconfiguration/conditions/GuidCreatorCondition.java +++ b/simple-jwt-spring-boot-starter/src/main/java/cn/org/codecrafters/simplejwt/autoconfiguration/conditions/GuidCreatorCondition.java @@ -9,7 +9,7 @@ import org.springframework.core.type.AnnotatedTypeMetadata; import java.util.Objects; /** - * The condition to create bean {@code jtiCreator}. + * The conditions to create bean {@code jtiCreator}. * * @author Zihlu Wang * @version 1.1.0 diff --git a/simple-jwt-spring-boot-starter/src/main/java/cn/org/codecrafters/simplejwt/autoconfiguration/properties/SimpleJwtProperties.java b/simple-jwt-spring-boot-starter/src/main/java/cn/org/codecrafters/simplejwt/autoconfiguration/properties/SimpleJwtProperties.java index fab5669..8105cf3 100644 --- a/simple-jwt-spring-boot-starter/src/main/java/cn/org/codecrafters/simplejwt/autoconfiguration/properties/SimpleJwtProperties.java +++ b/simple-jwt-spring-boot-starter/src/main/java/cn/org/codecrafters/simplejwt/autoconfiguration/properties/SimpleJwtProperties.java @@ -25,20 +25,20 @@ import org.springframework.boot.context.properties.ConfigurationProperties; /** * {@code SimpleJwtProperties} is a configuration properties class used to - * store the properties related to Simple JWT library configuration. These + * 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 "code-crafters.simple-jwt". *

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

              - * Developers can customize the JWT algorithm, issuer, and secret by setting + * Developers can customise the JWT algorithm, issuer, and secret by setting * the corresponding properties in the application's properties file. The - * SimpleJwtAutoConfiguration class reads these properties and uses them to - * create the TokenResolver bean with the desired configuration. + * {@code SimpleJwtAutoConfiguration} class reads these properties and uses + * them to create the TokenResolver bean with the desired configuration. * * @author Zihlu Wang * @version 1.1.0 diff --git a/webcal/src/main/java/cn/org/codecrafters/webcal/WebCalendar.java b/webcal/src/main/java/cn/org/codecrafters/webcal/WebCalendar.java index 9174a2b..e16b581 100644 --- a/webcal/src/main/java/cn/org/codecrafters/webcal/WebCalendar.java +++ b/webcal/src/main/java/cn/org/codecrafters/webcal/WebCalendar.java @@ -21,11 +21,12 @@ import java.util.ArrayList; import java.util.List; /** - * The WebCalendar class represents a web calendar in iCalendar format. + * {@code WebCalendar} class represents a web calendar in iCalendar format. *

              - * It allows users to create and customize calendar components and events and - * generate an iCalendar string containing all the calendar information. - *

              Usage Example: + * It allows users to create and customise calendar components and events and + * generate an iCalendar string containing all the calendar information. + *

              + * Usage Example: *

                * WebCalendar calendar = new WebCalendar()
                *         .setName("My Web Calendar")
              @@ -38,9 +39,9 @@ import java.util.List;
                * String iCalendarString = calendar.resolve();
                * 
              *

              - * The WebCalendar class is designed to generate an iCalendar string conforming - * to the iCalendar specification, which can be used to share calendar data - * with other calendar applications or services. + * The {@code WebCalendar} class is designed to generate an iCalendar string + * conforming to the iCalendar specification, which can be used to share + * calendar data with other calendar applications or services. * * @author Zihlu Wang * @version 1.1.0 @@ -49,7 +50,7 @@ import java.util.List; public final class WebCalendar { /** - * The VCALENDAR tag for iCalendar format + * The {@code VCALENDAR} tag for iCalendar format */ private final static String TAG = "VCALENDAR"; @@ -60,7 +61,6 @@ public final class WebCalendar { /** * The company who produces this calendar. - * *

              * This property will be used in {@code PRODID}. */ @@ -68,7 +68,6 @@ public final class WebCalendar { /** * The product name. - * *

              * This property will be used in {@code PRODID} */ diff --git a/webcal/src/main/java/cn/org/codecrafters/webcal/WebCalendarEvent.java b/webcal/src/main/java/cn/org/codecrafters/webcal/WebCalendarEvent.java index 23ce851..c073d19 100644 --- a/webcal/src/main/java/cn/org/codecrafters/webcal/WebCalendarEvent.java +++ b/webcal/src/main/java/cn/org/codecrafters/webcal/WebCalendarEvent.java @@ -28,17 +28,16 @@ import java.util.Optional; import java.util.UUID; /** - * The WebCalendarEvent class represents an event in the web calendar. It - * extends the abstract class WebCalendarNode and provides additional methods - * to set properties specific to events. - * + * The {@code WebCalendarEvent} class represents an event in the web calendar. + * It extends the abstract class WebCalendarNode and provides additional + * methods to set properties specific to events. *

              * Users can use the methods in this class to add categories, set the - * classification, add comments, descriptions, locations, set percent complete - * , set priority, set summary, set start time, set end time, set duration, set - * URL, set UID, and set timezone for the event. After setting the properties, - * users can call the {@link #resolve()} method to generate the corresponding - * iCalendar content for the event. + * classification, add comments, descriptions, locations, set percent + * complete, set priority, set summary, set start time, set end time, set + * duration, set URL, set UID, and set timezone for the event. After setting + * the properties, users can call the {@link #resolve()} method to generate the + * corresponding iCalendar content for the event. * * @author Zihlu Wang * @version 1.1.0 @@ -275,7 +274,7 @@ public final class WebCalendarEvent extends WebCalendarNode { .map((item) -> "DTEND" + Optional.ofNullable(timezone).map(tz -> ";TZID=" + tz).orElse("") + ":" + end.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME) + "\n").orElse("") + Optional.ofNullable(classification) - .map((item) -> "CLASS:" + item.getClassification() + "\n").orElse("") + + .map((item) -> "CLASS:" + item.name() + "\n").orElse("") + Optional.ofNullable(comment).map((item) -> "COMMENT:" + item + "\n").orElse("") + Optional.ofNullable(description).map((item) -> "DESCRIPTION:" + item + "\n").orElse("") + Optional.ofNullable(location).map((item) -> "LOCATION:" + item + "\n").orElse("") + diff --git a/webcal/src/main/java/cn/org/codecrafters/webcal/WebCalendarNode.java b/webcal/src/main/java/cn/org/codecrafters/webcal/WebCalendarNode.java index ed85ab0..5f56b11 100644 --- a/webcal/src/main/java/cn/org/codecrafters/webcal/WebCalendarNode.java +++ b/webcal/src/main/java/cn/org/codecrafters/webcal/WebCalendarNode.java @@ -25,14 +25,13 @@ import java.util.ArrayList; import java.util.List; /** - * The abstract sealed class WebCalendarNode represents a node in the web - * calendar, such as an event, a to-do item, or an alarm. It provides common - * properties and methods for all calendar components and events. - * + * The abstract sealed class {@code WebCalendarNode} represents a node in the + * web calendar, such as an event, a to-do item, or an alarm. It provides + * common properties and methods for all calendar components and events. *

              - * Subclasses of WebCalendarNode should implement the {@link #resolve()} method - * to generate the corresponding iCalendar content for the specific calendar - * component or event. + * Subclasses of {@code WebCalendarNode} should implement the {@link + * #resolve()} method to generate the corresponding iCalendar content for the + * specific calendar component or event. * * @author Zihlu Wang * @version 1.1.0 diff --git a/webcal/src/main/java/cn/org/codecrafters/webcal/config/Classification.java b/webcal/src/main/java/cn/org/codecrafters/webcal/config/Classification.java index 79a8ff1..2f40751 100644 --- a/webcal/src/main/java/cn/org/codecrafters/webcal/config/Classification.java +++ b/webcal/src/main/java/cn/org/codecrafters/webcal/config/Classification.java @@ -20,8 +20,8 @@ package cn.org.codecrafters.webcal.config; import lombok.Getter; /** - * The Classification enum represents the classification levels of calendar - * content based on RFC 5545. + * The {@code Classification} enum represents the classification levels of + * calendar content based on RFC-5545. *

              * Calendar events or components can be classified as one of the following * levels: @@ -44,7 +44,6 @@ import lombok.Getter; * @version 1.1.0 * @since 1.0.0 */ -@Getter public enum Classification { /** @@ -53,7 +52,7 @@ public enum Classification { * Indicates that the calendar content is public and can be freely * distributed. */ - PUBLIC("PUBLIC"), + PUBLIC, /** * Private classification level. @@ -61,7 +60,7 @@ public enum Classification { * Indicates that the calendar content is private and should not be shared * with others. */ - PRIVATE("PRIVATE"), + PRIVATE, /** * Confidential classification level. @@ -69,22 +68,7 @@ public enum Classification { * Indicates that the calendar content is confidential and should be kept * strictly private. */ - CONFIDENTIAL("CONFIDENTIAL"), + CONFIDENTIAL, ; - /** - * -- GETTER -- - * Get the string representation of the classification level. - */ - private final String classification; - - /** - * Constructor for Classification enum. - * - * @param classification the classification level as a string representation - */ - Classification(String classification) { - this.classification = classification; - } - } diff --git a/webcal/src/main/java/cn/org/codecrafters/webcal/config/package-info.java b/webcal/src/main/java/cn/org/codecrafters/webcal/config/package-info.java index f0cf59d..fdfc842 100644 --- a/webcal/src/main/java/cn/org/codecrafters/webcal/config/package-info.java +++ b/webcal/src/main/java/cn/org/codecrafters/webcal/config/package-info.java @@ -16,10 +16,10 @@ */ /** - * The package cn.org.codecrafters.webcal.config contains classes related to - * the configuration and settings of the web calendar module. It provides - * various configurations and constants used in the generation and resolution - * of iCalendar content. + * The package {@code cn.org.codecrafters.webcal.config} contains classes + * related to the configuration and settings of the web calendar module. It + * provides various configurations and constants used in the generation and + * resolution of iCalendar content. *

              The classes in this package include:

              *
                *
              • From aa3213cbbee881ad13b21876be1cc7f6a7306870 Mon Sep 17 00:00:00 2001 From: Zihlu Wang Date: Tue, 19 Sep 2023 08:51:42 +0800 Subject: [PATCH 25/27] refactor(devkit-utils): Changed the location of some codes. --- .../codecrafters/devkit/utils/MapUtil.java | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/MapUtil.java b/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/MapUtil.java index ef54782..68ab6d4 100644 --- a/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/MapUtil.java +++ b/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/MapUtil.java @@ -178,6 +178,22 @@ public final class MapUtil { method.invoke(obj, fieldValue); } + /** + * Casts the specified value to the required type. + * + * @param value the value to be cast + * @param requiredType the type to which the value should be cast + * @param the type to which the value should be cast + * @return the cast value, or null if the value cannot be cast to the + * required type + */ + public static T cast(Object value, Class requiredType) { + if (requiredType.isInstance(value)) { + return requiredType.cast(value); + } + return null; + } + /** * Constructs a method name based on the given prefix and field name. * @@ -203,20 +219,4 @@ public final class MapUtil { return String.valueOf(obj); } } - - /** - * Casts the specified value to the required type. - * - * @param value the value to be cast - * @param requiredType the type to which the value should be cast - * @param the type to which the value should be cast - * @return the cast value, or null if the value cannot be cast to the - * required type - */ - public static T cast(Object value, Class requiredType) { - if (requiredType.isInstance(value)) { - return requiredType.cast(value); - } - return null; - } } From b3926d3f27f89337b86eeab995ee38e734e8567a Mon Sep 17 00:00:00 2001 From: Zihlu Wang Date: Tue, 19 Sep 2023 11:52:40 +0800 Subject: [PATCH 26/27] docs(simple-jwt): Added author to javadoc. --- .../main/java/cn/org/codecrafters/simplejwt/TokenPayload.java | 1 + .../cn/org/codecrafters/simplejwt/constants/PredefinedKeys.java | 1 + .../cn/org/codecrafters/simplejwt/constants/TokenAlgorithm.java | 1 + 3 files changed, 3 insertions(+) diff --git a/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/TokenPayload.java b/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/TokenPayload.java index 657e83c..02901f2 100644 --- a/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/TokenPayload.java +++ b/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/TokenPayload.java @@ -39,6 +39,7 @@ import java.util.Map; * } *
              * + * @author Zihlu Wang * @version 1.1.0 * @since 1.0.0 */ diff --git a/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/constants/PredefinedKeys.java b/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/constants/PredefinedKeys.java index 3aee4db..2df9309 100644 --- a/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/constants/PredefinedKeys.java +++ b/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/constants/PredefinedKeys.java @@ -41,6 +41,7 @@ import java.util.List; * Note: This class is final and cannot be instantiated. It only serves as a utility class to hold the standard JWT * claim constants. * + * @author Zihlu Wang * @version 1.1.0 * @since 1.0.0 */ diff --git a/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/constants/TokenAlgorithm.java b/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/constants/TokenAlgorithm.java index 4725089..3b831fd 100644 --- a/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/constants/TokenAlgorithm.java +++ b/simple-jwt-facade/src/main/java/cn/org/codecrafters/simplejwt/constants/TokenAlgorithm.java @@ -39,6 +39,7 @@ import lombok.Getter; *
            • {@link TokenAlgorithm#ES512}: ECDSA with SHA-512
            • *
            * + * @author Zihlu Wang * @version 1.1.0 * @since 1.0.0 */ From 1c3f6ac2ec0a43358dcc3868011f4fd7c7ad0187 Mon Sep 17 00:00:00 2001 From: Zihlu Wang Date: Tue, 19 Sep 2023 14:11:14 +0800 Subject: [PATCH 27/27] build(global): Upgrade to v1.1.0 Upgrade to v1.1.0 stable version, and the translation of SIMPLIFIED CHINESE will be published before 26 Sept, 2023. BREAKING CHANGE: The order of parametres in initialising SnowflakeGuidCreator, the original sequence is: "workerId, dataCentreId"; and the new sequence is "dataCentreId, workerId" --- devkit-core/pom.xml | 2 +- devkit-utils/pom.xml | 2 +- guid/pom.xml | 2 +- pom.xml | 2 +- property-guard-spring-boot-starter/pom.xml | 2 +- simple-jwt-authzero/pom.xml | 2 +- simple-jwt-facade/pom.xml | 2 +- simple-jwt-jjwt/pom.xml | 2 +- simple-jwt-spring-boot-starter/pom.xml | 2 +- webcal/pom.xml | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/devkit-core/pom.xml b/devkit-core/pom.xml index c1eb033..15f579a 100644 --- a/devkit-core/pom.xml +++ b/devkit-core/pom.xml @@ -23,7 +23,7 @@ cn.org.codecrafters jdevkit - 1.1.0-beta + 1.1.0 devkit-core diff --git a/devkit-utils/pom.xml b/devkit-utils/pom.xml index 59de641..f99e4f7 100644 --- a/devkit-utils/pom.xml +++ b/devkit-utils/pom.xml @@ -6,7 +6,7 @@ cn.org.codecrafters jdevkit - 1.1.0-beta + 1.1.0 devkit-utils diff --git a/guid/pom.xml b/guid/pom.xml index 6ef8761..26e83f1 100644 --- a/guid/pom.xml +++ b/guid/pom.xml @@ -23,7 +23,7 @@ cn.org.codecrafters jdevkit - 1.1.0-beta + 1.1.0 guid diff --git a/pom.xml b/pom.xml index 527ad26..77edffc 100644 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,7 @@ cn.org.codecrafters jdevkit - 1.1.0-beta + 1.1.0 2023 pom diff --git a/property-guard-spring-boot-starter/pom.xml b/property-guard-spring-boot-starter/pom.xml index 6abbc24..6595ca7 100644 --- a/property-guard-spring-boot-starter/pom.xml +++ b/property-guard-spring-boot-starter/pom.xml @@ -23,7 +23,7 @@ cn.org.codecrafters jdevkit - 1.1.0-beta + 1.1.0 property-guard-spring-boot-starter diff --git a/simple-jwt-authzero/pom.xml b/simple-jwt-authzero/pom.xml index abebd27..65e0e00 100644 --- a/simple-jwt-authzero/pom.xml +++ b/simple-jwt-authzero/pom.xml @@ -23,7 +23,7 @@ cn.org.codecrafters jdevkit - 1.1.0-beta + 1.1.0 simple-jwt-authzero diff --git a/simple-jwt-facade/pom.xml b/simple-jwt-facade/pom.xml index 12f9274..bd72ec4 100644 --- a/simple-jwt-facade/pom.xml +++ b/simple-jwt-facade/pom.xml @@ -23,7 +23,7 @@ cn.org.codecrafters jdevkit - 1.1.0-beta + 1.1.0 simple-jwt-facade diff --git a/simple-jwt-jjwt/pom.xml b/simple-jwt-jjwt/pom.xml index d766a70..e5acdeb 100644 --- a/simple-jwt-jjwt/pom.xml +++ b/simple-jwt-jjwt/pom.xml @@ -23,7 +23,7 @@ cn.org.codecrafters jdevkit - 1.1.0-beta + 1.1.0 simple-jwt-jjwt diff --git a/simple-jwt-spring-boot-starter/pom.xml b/simple-jwt-spring-boot-starter/pom.xml index 5bfb7ad..9e6a49c 100644 --- a/simple-jwt-spring-boot-starter/pom.xml +++ b/simple-jwt-spring-boot-starter/pom.xml @@ -23,7 +23,7 @@ cn.org.codecrafters jdevkit - 1.1.0-beta + 1.1.0 simple-jwt-spring-boot-starter diff --git a/webcal/pom.xml b/webcal/pom.xml index 4bb62a6..4419d64 100644 --- a/webcal/pom.xml +++ b/webcal/pom.xml @@ -23,7 +23,7 @@ cn.org.codecrafters jdevkit - 1.1.0-beta + 1.1.0 webcal