diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index d13e3e2..b18c455 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -2,7 +2,10 @@ ## Our Pledge -We as members, contributors, and leaders pledge to make participation in our project a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. +We as members, contributors, and leaders pledge to make participation in our project +a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, +gender identity and expression, level of experience, nationality, personal appearance, race, +religion, or sexual identity and orientation. ## Our Standards @@ -20,26 +23,40 @@ Examples of unacceptable behaviour by participants include: - Trolling, insulting, or derogatory comments - Personal or political attacks - Public or private harassment -- Publishing others’ private information, such as a physical or electronic address, without explicit permission +- Publishing others’ private information, such as a physical or electronic address, without + explicit permission - Other conduct which could reasonably be considered inappropriate in a professional setting ## Enforcement Responsibilities -Project maintainers are responsible for clarifying the standards of acceptable behaviour and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behaviour. +Project maintainers are responsible for clarifying the standards of acceptable behaviour and are +expected to take appropriate and fair corrective action in response to any instances of +unacceptable behaviour. -Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that do not align with this Code of Conduct, and will communicate reasons for moderation decisions when appropriate. +Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, +code, wiki edits, issues, and other contributions that do not align with this Code of Conduct, and +will communicate reasons for moderation decisions when appropriate. ## Scope -This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project email address, posting via an official social media account, or acting as an appointed representative at an online or offline event. +This Code of Conduct applies both within project spaces and in public spaces when an individual is +representing the project or its community. Examples of representing a project or community include +using an official project email address, posting via an official social media account, or acting as +an appointed representative at an online or offline event. ## Enforcement -Instances of abusive, harassing, or unacceptable behaviour may be reported by contacting the project team at [your-email@example.com]. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. +Instances of abusive, harassing, or unacceptable behaviour may be reported by contacting the +project team at [opensource@onixbyte.com](mailto:opensource@onixbyte.com). All complaints will be +reviewed and investigated and will result in a response that is deemed necessary and appropriate to +the circumstances. The project team is obligated to maintain confidentiality with regard to the +reporter of an incident. -Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. +Project maintainers who do not follow or enforce the Code of Conduct in good faith may face +temporary or permanent repercussions as determined by other members of the project's leadership. ## Attribution -This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org/), version 1.4, available at https://www.contributor-covenant.org/version/1/4/ +This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org/), +version 1.4, available at https://www.contributor-covenant.org/version/1/4/ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2fd937c..5ed8874 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,18 +1,18 @@ -# Contributing to Java Dev Kit +# Contributing to OnixByte Toolbox -We appreciate your interest in contributing to our Java Enterprise Utility Library. Contributions are welcome in various -forms such as code, documentation, bug reports, and test cases. To ensure a smooth collaboration, please follow the -guidelines outlined below. +We appreciate your interest in contributing to our Java Enterprise Utility Library. Contributions +are welcome in various forms such as code, documentation, bug reports, and test cases. To ensure a +smooth collaboration, please follow the guidelines outlined below. ## Getting Started -The Java Dev Kit is an open-source Java library designed to ease Java enterprise application development. It is built -with Java 17, and we require contributors to use OpenJDK 17. +The OnixByte Toolbox is an open-source Java library designed to ease Java enterprise +application development. It is built with Java 17, and we require contributors to use OpenJDK 17. ## Development Setup -There is no need for manual setup beyond ensuring you have JDK 17 and a stable internet connection. Our project uses -Gradle Wrapper for building, simplifying the setup process. +There is no need for manual setup beyond ensuring you have JDK 17 and a stable internet connection. +Our project uses Gradle Wrapper for building, simplifying the setup process. ```shell ./gradlew build @@ -20,13 +20,13 @@ Gradle Wrapper for building, simplifying the setup process. ## Branching Strategy -We follow the `git-flow` branching model. Contributors should fork this repository and create their work on separate -branches prefixed with `feature/` or `hotfix/` as appropriate. +We follow the `git-flow` branching model. Contributors should fork this repository and create their +work on separate branches prefixed with `feature/` or `hotfix/` as appropriate. ## Code Style -Please adhere to the coding standards specified in our `.editorconfig` file in the root of the repository. Consistent -style helps in maintaining readability and uniformity across the codebase. +Please adhere to the coding standards specified in our `.editorconfig` file in the root of +the repository. Consistent style helps in maintaining readability and uniformity across the codebase. ## Commit Messages @@ -52,8 +52,10 @@ This format helps in auto-generating changelogs and understanding the purpose be ## Testing -We encourage using JUnit Jupiter for unit and integration tests. Pull Requests with accompanying test reports are prioritised for review and merging. +We encourage using JUnit Jupiter for unit and integration tests. Pull Requests with accompanying +test reports are prioritised for review and merging. ## License -By contributing to the Java Dev Kit, you agree that your contributions will be licensed under the Apache 2.0 license. If you do not agree to this, please refrain from contributing. \ No newline at end of file +By contributing to the OnixByte Toolbox, you agree that your contributions will be licensed under the +MIT license. If you do not agree to this, please refrain from contributing. diff --git a/LICENSE b/LICENSE index 5548015..8c2f4a4 100644 --- a/LICENSE +++ b/LICENSE @@ -1,202 +1,21 @@ +MIT License - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ +Copyright (c) 2024-2025 OnixByte - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: - 1. Definitions. +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright 2024-2025 OnixByte - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. \ No newline at end of file +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/build.gradle.kts b/build.gradle.kts index b76a169..533233b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,16 +1,21 @@ /* - * Copyright (C) 2024-2025 OnixByte. + * Copyright (c) 2024-2025 OnixByte * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * http://www.apache.org/licenses/LICENSE-2.0 + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - */ \ No newline at end of file + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ diff --git a/common-toolbox/build.gradle.kts b/common-toolbox/build.gradle.kts index 37b5e9d..12d83a9 100644 --- a/common-toolbox/build.gradle.kts +++ b/common-toolbox/build.gradle.kts @@ -1,19 +1,25 @@ /* - * Copyright (C) 2024-2025 OnixByte. + * Copyright (c) 2024-2025 OnixByte * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * http://www.apache.org/licenses/LICENSE-2.0 + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ + import java.net.URI plugins { @@ -82,8 +88,8 @@ publishing { } scm { - connection = "scm:git:git://github.com:OnixByte/JDevKit.git" - developerConnection = "scm:git:git://github.com:OnixByte/JDevKit.git" + connection = "scm:git:git://github.com:onixbyte/onixbyte-toolbox.git" + developerConnection = "scm:git:git://github.com:onixbyte/onixbyte-toolbox.git" url = projectGithubUrl } @@ -122,4 +128,4 @@ publishing { } } } -} \ No newline at end of file +} diff --git a/common-toolbox/src/main/java/com/onixbyte/common/util/AesUtil.java b/common-toolbox/src/main/java/com/onixbyte/common/util/AesUtil.java index 65b02a9..74da677 100644 --- a/common-toolbox/src/main/java/com/onixbyte/common/util/AesUtil.java +++ b/common-toolbox/src/main/java/com/onixbyte/common/util/AesUtil.java @@ -1,18 +1,23 @@ /* - * Copyright (C) 2024-2025 OnixByte. + * Copyright (c) 2024-2025 OnixByte * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * http://www.apache.org/licenses/LICENSE-2.0 + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ package com.onixbyte.common.util; @@ -54,12 +59,27 @@ import java.util.UUID; * System.out.println(randomSecret); // Output: A randomly generated 16-character long secret * } * - * @author hubin@baomidou - * @version 1.1.0 - * @since 1.1.0 + * @author hubin + * @version 3.0.0 */ public final class AesUtil { + /** + * The algorithm AES. + */ + private static final String AES = "AES"; + + /** + * The algorithm AES/CBC/PKCS5Padding. + */ + private static final String AES_CBC_CIPHER = "AES/CBC/PKCS5Padding"; + + /** + * Private constructor to prevent instantiation of this utility class. + */ + private AesUtil() { + } + /** * Encrypts the specified data using the AES algorithm with the provided secret key. * @@ -125,21 +145,4 @@ public final class AesUtil { public static String generateRandomSecret() { return UUID.randomUUID().toString().replaceAll("-", "").substring(0, 16); } - - /** - * Private constructor to prevent instantiation of this utility class. - */ - private AesUtil() { - } - - /** - * The algorithm AES. - */ - private static final String AES = "AES"; - - /** - * The algorithm AES/CBC/PKCS5Padding. - */ - private static final String AES_CBC_CIPHER = "AES/CBC/PKCS5Padding"; - } diff --git a/common-toolbox/src/main/java/com/onixbyte/common/util/Base64Util.java b/common-toolbox/src/main/java/com/onixbyte/common/util/Base64Util.java index 51084d9..18214b0 100644 --- a/common-toolbox/src/main/java/com/onixbyte/common/util/Base64Util.java +++ b/common-toolbox/src/main/java/com/onixbyte/common/util/Base64Util.java @@ -1,18 +1,23 @@ /* - * Copyright (C) 2024-2025 OnixByte. + * Copyright (c) 2024-2025 OnixByte * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * http://www.apache.org/licenses/LICENSE-2.0 + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ package com.onixbyte.common.util; @@ -50,11 +55,21 @@ import java.util.Objects; * encoding and decoding. * * @author zihluwang - * @version 1.1.0 - * @since 1.0.0 + * @version 3.0.0 */ public final class Base64Util { + /** + * Private constructor to prevent instantiation of this utility class. + */ + private Base64Util() { + } + + private static Base64.Encoder encoder; + private static Base64.Decoder decoder; + private static Base64.Encoder urlEncoder; + private static Base64.Decoder urlDecoder; + /** * Ensure that there is only one Base64 Encoder. * @@ -103,12 +118,6 @@ public final class Base64Util { return urlDecoder; } - /** - * Private constructor to prevent instantiation of this utility class. - */ - private Base64Util() { - } - /** * Encodes the given string using the specified charset. * @@ -200,13 +209,4 @@ public final class Base64Util { public static String decodeUrlComponents(String value) { return decodeUrlComponents(value, StandardCharsets.UTF_8); } - - private static Base64.Encoder encoder; - - private static Base64.Decoder decoder; - - private static Base64.Encoder urlEncoder; - - private static Base64.Decoder urlDecoder; - } diff --git a/common-toolbox/src/main/java/com/onixbyte/common/util/BoolUtil.java b/common-toolbox/src/main/java/com/onixbyte/common/util/BoolUtil.java index 858b750..35600ae 100644 --- a/common-toolbox/src/main/java/com/onixbyte/common/util/BoolUtil.java +++ b/common-toolbox/src/main/java/com/onixbyte/common/util/BoolUtil.java @@ -1,18 +1,23 @@ /* - * Copyright (C) 2024-2025 OnixByte. + * Copyright (c) 2024-2025 OnixByte * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * http://www.apache.org/licenses/LICENSE-2.0 + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ package com.onixbyte.common.util; @@ -30,20 +35,23 @@ import java.util.function.BooleanSupplier; *
* *Example usage:
- *
- * {@code
+ * {@code
* boolean result1 = BoolUtil.and(true, true, false); // false
* boolean result2 = BoolUtil.or(true, false, false); // true
* boolean result3 = BoolUtil.not(false); // true
- * }
- *
+ * }
*
* @author zihluwang
- * @version 1.6.2
- * @since 1.6.2
+ * @version 3.0.0
*/
public final class BoolUtil {
+ /**
+ * Private constructor to prevent instantiation of this utility class.
+ */
+ private BoolUtil() {
+ }
+
/**
* Logical and calculation.
*
@@ -91,10 +99,4 @@ public final class BoolUtil {
.filter(Objects::nonNull)
.anyMatch(BooleanSupplier::getAsBoolean);
}
-
- /**
- * Private constructor to prevent instantiation of this utility class.
- */
- private BoolUtil() {}
-
}
diff --git a/common-toolbox/src/main/java/com/onixbyte/common/util/BranchUtil.java b/common-toolbox/src/main/java/com/onixbyte/common/util/BranchUtil.java
index a2c9ca8..c3e5dc1 100644
--- a/common-toolbox/src/main/java/com/onixbyte/common/util/BranchUtil.java
+++ b/common-toolbox/src/main/java/com/onixbyte/common/util/BranchUtil.java
@@ -1,18 +1,23 @@
/*
- * Copyright (C) 2024-2025 OnixByte.
+ * Copyright (c) 2024-2025 OnixByte
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
*/
package com.onixbyte.common.util;
@@ -64,11 +69,10 @@ import java.util.function.Supplier;
* expressions.
*
* @author zihluwang
- * @version 2.1.3
+ * @version 3.0.0
* @see java.util.function.Supplier
* @see java.util.function.BooleanSupplier
* @see java.lang.Runnable
- * @since 1.0.0
*/
public final class BranchUtil {
@@ -167,7 +171,8 @@ public final class BranchUtil {
*
* @param Example usage:
- *
- * {@code
+ * {@code
+ * // User.java
* public class User {
* private String name;
* private int age;
*
* // getters and setters
* }
- *
+ *
+ * // UserMapAdapter.java
* public class UserMapAdapter implements ObjectMapAdapter {
* @Override
* public Map toMap(User user) {
@@ -73,15 +79,19 @@ import java.util.Map;
* System.out.println(newUser.getAge()); // Output: 30
* }
* }
- * }
- *
+ * }
*
* @author zihluwang
- * @version 1.7.0
- * @since 1.0.0
+ * @version 3.0.0
*/
public final class MapUtil {
+ /**
+ * Private constructor to prevent instantiation of this utility class.
+ */
+ private MapUtil() {
+ }
+
/**
* Converts an object to a map by mapping the field names to their corresponding values.
*
@@ -106,10 +116,4 @@ public final class MapUtil {
public static Example usage:
- *
- * {@code
+ * {@code
* public class User {
* private String name;
* private int age;
@@ -54,13 +58,11 @@ import java.util.Map;
* return user;
* }
* }
- * }
- *
+ * }
*
* @param * If {@code start} is less than {@code end}, an ascending range (exclusive of {@code end}) - * is generated. If {@code start} is greater than {@code end}, a descending range (exclusive of {@code end}) - * is generated. If {@code start} equals {@code end}, an empty stream is returned. + * is generated. If {@code start} is greater than {@code end}, a descending range (exclusive + * of {@code end}) is generated. If {@code start} equals {@code end}, an empty stream + * is returned. *
* Example Usage: *
{@code
@@ -103,7 +110,8 @@ public final class RangeUtil {
*
* @param start the starting value of the range (inclusive)
* @param end upper-bound of the range (exclusive)
- * @return an {@code IntStream} of integers in ascending or descending order, exclusive of {@code end}
+ * @return an {@code IntStream} of integers in ascending or descending order, exclusive
+ * of {@code end}
* @see IntStream
*/
public static IntStream range(int start, int end) {
@@ -150,8 +158,8 @@ public final class RangeUtil {
}
/**
- * Generates a stream of integers starting from the specified {@code start} value, incremented by
- * the specified {@code step}, up to the specified {@code end} value.
+ * Generates a stream of integers starting from the specified {@code start} value, incremented
+ * by the specified {@code step}, up to the specified {@code end} value.
*
* It creates a sequential, ordered {@code IntStream} that can be used for iteration or
* further processing.
@@ -180,9 +188,10 @@ public final class RangeUtil {
* @param start the starting value of the range (inclusive)
* @param end upper-bound of the range (exclusive)
* @param step the increment or decrement between each value (non-zero)
- * @return an {@code IntStream} of integers from {@code start} to {@code end} exclusive stepping by {@code step}
- * @throws IllegalArgumentException if {@code step} is zero or if {@code start} and {@code end} are inconsistent
- * with the direction imposed by {@code step}
+ * @return an {@code IntStream} of integers from {@code start} to {@code end} exclusive stepping
+ * by {@code step}
+ * @throws IllegalArgumentException if {@code step} is zero or if {@code start} and {@code end}
+ * are inconsistent with the direction imposed by {@code step}
* @see IntStream
*/
public static IntStream range(int start, int end, int step) {
diff --git a/common-toolbox/src/main/resources/logback.xml b/common-toolbox/src/main/resources/logback.xml
index 56cd5b7..288ac4a 100644
--- a/common-toolbox/src/main/resources/logback.xml
+++ b/common-toolbox/src/main/resources/logback.xml
@@ -1,19 +1,24 @@
@@ -22,7 +27,7 @@
-
+
${COLOURFUL_OUTPUT}
@@ -31,4 +36,4 @@
-
\ No newline at end of file
+
diff --git a/crypto-toolbox/build.gradle.kts b/crypto-toolbox/build.gradle.kts
index e980f8d..81139e1 100644
--- a/crypto-toolbox/build.gradle.kts
+++ b/crypto-toolbox/build.gradle.kts
@@ -1,19 +1,25 @@
/*
- * Copyright (C) 2024-2025 OnixByte.
+ * Copyright (c) 2024-2025 OnixByte
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
*/
+
import java.net.URI
plugins {
@@ -87,8 +93,8 @@ publishing {
}
scm {
- connection = "scm:git:git://github.com:OnixByte/JDevKit.git"
- developerConnection = "scm:git:git://github.com:OnixByte/JDevKit.git"
+ connection = "scm:git:git://github.com:onixbyte/onixbyte-toolbox.git"
+ developerConnection = "scm:git:git://github.com:onixbyte/onixbyte-toolbox.git"
url = projectGithubUrl
}
@@ -127,4 +133,4 @@ publishing {
}
}
}
-}
\ No newline at end of file
+}
diff --git a/crypto-toolbox/src/main/java/com/onixbyte/crypto/PrivateKeyLoader.java b/crypto-toolbox/src/main/java/com/onixbyte/crypto/PrivateKeyLoader.java
index 228e3cd..e1b7876 100644
--- a/crypto-toolbox/src/main/java/com/onixbyte/crypto/PrivateKeyLoader.java
+++ b/crypto-toolbox/src/main/java/com/onixbyte/crypto/PrivateKeyLoader.java
@@ -1,18 +1,23 @@
/*
- * Copyright (C) 2024-2025 OnixByte.
+ * Copyright (c) 2024-2025 OnixByte
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
*/
package com.onixbyte.crypto;
@@ -25,8 +30,7 @@ import java.security.PrivateKey;
*
* @author zihluwang
* @author siujamo
- * @version 2.0.0
- * @since 1.6.0
+ * @version 3.0.0
*/
public interface PrivateKeyLoader {
diff --git a/crypto-toolbox/src/main/java/com/onixbyte/crypto/PublicKeyLoader.java b/crypto-toolbox/src/main/java/com/onixbyte/crypto/PublicKeyLoader.java
index ecfb3e3..e4dff60 100644
--- a/crypto-toolbox/src/main/java/com/onixbyte/crypto/PublicKeyLoader.java
+++ b/crypto-toolbox/src/main/java/com/onixbyte/crypto/PublicKeyLoader.java
@@ -1,18 +1,23 @@
/*
- * Copyright (C) 2024-2025 OnixByte.
+ * Copyright (c) 2024-2025 OnixByte
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
*/
package com.onixbyte.crypto;
diff --git a/crypto-toolbox/src/main/java/com/onixbyte/crypto/algorithm/ecdsa/ECPrivateKeyLoader.java b/crypto-toolbox/src/main/java/com/onixbyte/crypto/algorithm/ecdsa/ECPrivateKeyLoader.java
index 672c65f..fa527ec 100644
--- a/crypto-toolbox/src/main/java/com/onixbyte/crypto/algorithm/ecdsa/ECPrivateKeyLoader.java
+++ b/crypto-toolbox/src/main/java/com/onixbyte/crypto/algorithm/ecdsa/ECPrivateKeyLoader.java
@@ -1,18 +1,23 @@
/*
- * Copyright (C) 2024-2025 OnixByte.
+ * Copyright (c) 2024-2025 OnixByte
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
*/
package com.onixbyte.crypto.algorithm.ecdsa;
@@ -35,26 +40,18 @@ import java.util.Set;
/**
* Key pair loader for loading key pairs for ECDSA-based algorithms.
*
- *
- * Example usage for ECDSA:
+ * Example usage:
*
{@code
- * PrivateKeyLoader keyLoader = new EcKeyLoader();
+ * PrivateKeyLoader keyLoader = new ECPrivateKeyLoader();
* String pemPrivateKey = """
* -----BEGIN EC PRIVATE KEY-----
* ...
* -----END EC PRIVATE KEY-----""";
* ECPrivateKey privateKey = PrivateKeyLoader.loadEcdsaPrivateKey(pemPrivateKey);
- *
- * String pemPublicKey = """
- * -----BEGIN EC PUBLIC KEY-----
- * ...
- * -----END EC PUBLIC KEY-----""";
- * ECPublicKey publicKey = PrivateKeyLoader.loadPublicKey(pemPublicKey);
* }
*
* @author zihluwang
- * @version 2.0.0
- * @since 2.0.0
+ * @version 3.0.0
*/
public class ECPrivateKeyLoader implements PrivateKeyLoader {
diff --git a/crypto-toolbox/src/main/java/com/onixbyte/crypto/algorithm/ecdsa/ECPublicKeyLoader.java b/crypto-toolbox/src/main/java/com/onixbyte/crypto/algorithm/ecdsa/ECPublicKeyLoader.java
index a31f98a..de14870 100644
--- a/crypto-toolbox/src/main/java/com/onixbyte/crypto/algorithm/ecdsa/ECPublicKeyLoader.java
+++ b/crypto-toolbox/src/main/java/com/onixbyte/crypto/algorithm/ecdsa/ECPublicKeyLoader.java
@@ -1,18 +1,23 @@
/*
- * Copyright (C) 2024-2025 OnixByte.
+ * Copyright (c) 2024-2025 OnixByte
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
*/
package com.onixbyte.crypto.algorithm.ecdsa;
@@ -32,6 +37,9 @@ import java.util.Base64;
import java.util.HashSet;
import java.util.Set;
+/**
+ *
+ */
public class ECPublicKeyLoader implements PublicKeyLoader {
/**
diff --git a/crypto-toolbox/src/main/java/com/onixbyte/crypto/algorithm/rsa/RSAPrivateKeyLoader.java b/crypto-toolbox/src/main/java/com/onixbyte/crypto/algorithm/rsa/RSAPrivateKeyLoader.java
index 1f8c357..8cd6eb9 100644
--- a/crypto-toolbox/src/main/java/com/onixbyte/crypto/algorithm/rsa/RSAPrivateKeyLoader.java
+++ b/crypto-toolbox/src/main/java/com/onixbyte/crypto/algorithm/rsa/RSAPrivateKeyLoader.java
@@ -1,18 +1,23 @@
/*
- * Copyright (C) 2024-2025 OnixByte.
+ * Copyright (c) 2024-2025 OnixByte
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
*/
package com.onixbyte.crypto.algorithm.rsa;
@@ -32,14 +37,15 @@ import java.util.Base64;
/**
* A class responsible for loading RSA keys from PEM formatted text.
*
- * This class implements the {@link PrivateKeyLoader} interface and provides methods to load both private
- * and public RSA keys. The keys are expected to be in the standard PEM format, which includes
- * Base64-encoded key content surrounded by header and footer lines. The class handles the decoding
- * of Base64 content and the generation of keys using the RSA key factory.
+ * This class implements the {@link PrivateKeyLoader} interface and provides methods to load both
+ * private and public RSA keys. The keys are expected to be in the standard PEM format, which
+ * includes Base64-encoded key content surrounded by header and footer lines. The class handles
+ * the decoding of Base64 content and the generation of keys using the RSA key factory.
*
* Any exceptions encountered during the loading process are encapsulated in a
* {@link KeyLoadingException}, allowing for flexible error handling.
*
+ * @author zihluwang
* @author siujamo
* @see PrivateKeyLoader
* @see KeyLoadingException
diff --git a/crypto-toolbox/src/main/java/com/onixbyte/crypto/algorithm/rsa/RSAPublicKeyLoader.java b/crypto-toolbox/src/main/java/com/onixbyte/crypto/algorithm/rsa/RSAPublicKeyLoader.java
index 2e14518..f1a5c7b 100644
--- a/crypto-toolbox/src/main/java/com/onixbyte/crypto/algorithm/rsa/RSAPublicKeyLoader.java
+++ b/crypto-toolbox/src/main/java/com/onixbyte/crypto/algorithm/rsa/RSAPublicKeyLoader.java
@@ -1,18 +1,23 @@
/*
- * Copyright (C) 2024-2025 OnixByte.
+ * Copyright (c) 2024-2025 OnixByte
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
*/
package com.onixbyte.crypto.algorithm.rsa;
@@ -31,6 +36,9 @@ import java.security.spec.RSAPublicKeySpec;
import java.security.spec.X509EncodedKeySpec;
import java.util.Base64;
+/**
+ *
+ */
public class RSAPublicKeyLoader implements PublicKeyLoader {
private final Base64.Decoder decoder;
diff --git a/crypto-toolbox/src/main/java/com/onixbyte/crypto/exception/KeyLoadingException.java b/crypto-toolbox/src/main/java/com/onixbyte/crypto/exception/KeyLoadingException.java
index 9ae5b7f..648182c 100644
--- a/crypto-toolbox/src/main/java/com/onixbyte/crypto/exception/KeyLoadingException.java
+++ b/crypto-toolbox/src/main/java/com/onixbyte/crypto/exception/KeyLoadingException.java
@@ -1,18 +1,23 @@
/*
- * Copyright (C) 2024-2025 OnixByte.
+ * Copyright (c) 2024-2025 OnixByte
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
*/
package com.onixbyte.crypto.exception;
@@ -39,7 +44,6 @@ package com.onixbyte.crypto.exception;
*
* @author zihluwang
* @version 3.0.0
- * @since 1.6.0
*/
public class KeyLoadingException extends RuntimeException {
diff --git a/crypto-toolbox/src/main/java/com/onixbyte/crypto/util/CryptoUtil.java b/crypto-toolbox/src/main/java/com/onixbyte/crypto/util/CryptoUtil.java
index 3cb66d0..9432a27 100644
--- a/crypto-toolbox/src/main/java/com/onixbyte/crypto/util/CryptoUtil.java
+++ b/crypto-toolbox/src/main/java/com/onixbyte/crypto/util/CryptoUtil.java
@@ -1,24 +1,35 @@
/*
- * Copyright (C) 2024-2025 OnixByte.
+ * Copyright (c) 2024-2025 OnixByte
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
*/
package com.onixbyte.crypto.util;
+/**
+ *
+ */
public final class CryptoUtil {
+ /**
+ * Private constructor to prevent instantiation of this utility class.
+ */
private CryptoUtil() {
}
diff --git a/crypto-toolbox/src/main/resources/logback.xml b/crypto-toolbox/src/main/resources/logback.xml
index 1cf5a50..288ac4a 100644
--- a/crypto-toolbox/src/main/resources/logback.xml
+++ b/crypto-toolbox/src/main/resources/logback.xml
@@ -1,26 +1,33 @@
-
-
+
+
-
+
${COLOURFUL_OUTPUT}
@@ -29,4 +36,4 @@
-
\ No newline at end of file
+
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
index d64cd49..e69de29 100644
Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradlew b/gradlew
index 1aa94a4..447618b 100755
--- a/gradlew
+++ b/gradlew
@@ -1,19 +1,25 @@
#!/bin/sh
#
-# Copyright © 2015-2021 the original authors.
+# Copyright (c) 2024-2025 OnixByte
#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
#
-# https://www.apache.org/licenses/LICENSE-2.0
+# The above copyright notice and this permission notice shall be included in all
+# copies or substantial portions of the Software.
#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
#
##############################################################################
diff --git a/identity-generator/build.gradle.kts b/identity-generator/build.gradle.kts
index 8821412..d3c7471 100644
--- a/identity-generator/build.gradle.kts
+++ b/identity-generator/build.gradle.kts
@@ -1,19 +1,25 @@
/*
- * Copyright (C) 2024-2025 OnixByte.
+ * Copyright (c) 2024-2025 OnixByte
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
*/
+
import java.net.URI
plugins {
diff --git a/identity-generator/src/main/java/com/onixbyte/identitygenerator/IdentityGenerator.java b/identity-generator/src/main/java/com/onixbyte/identitygenerator/IdentityGenerator.java
index 823d85b..2232c43 100644
--- a/identity-generator/src/main/java/com/onixbyte/identitygenerator/IdentityGenerator.java
+++ b/identity-generator/src/main/java/com/onixbyte/identitygenerator/IdentityGenerator.java
@@ -1,25 +1,30 @@
/*
- * Copyright (C) 2024-2025 OnixByte.
+ * Copyright (c) 2024-2025 OnixByte
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
*/
package com.onixbyte.identitygenerator;
/**
- * The {@code IdentityGenerator} is a generic interface for generating globally unique identifiers (GUIDs)
- * of a specific type.
+ * The {@code IdentityGenerator} is a generic interface for generating globally unique identifiers
+ * (GUIDs) of a specific type.
*
* The type of ID is determined by the class implementing this interface.
*
@@ -45,9 +50,8 @@ package com.onixbyte.identitygenerator;
* }
*
* @param - * This implementation utilises a cryptographically strong {@link SecureRandom} instance to produce the random - * component of the UUID. The first 6 bytes of the UUID encode the current timestamp in milliseconds, ensuring that - * generated UUIDs are roughly ordered by creation time. + * This implementation utilises a cryptographically strong {@link SecureRandom} instance to produce + * the random component of the UUID. The first 6 bytes of the UUID encode the current timestamp in + * milliseconds, ensuring that generated UUIDs are roughly ordered by creation time. *
- * The generated UUID adheres strictly to the layout and variant bits of UUID version 7 as defined in the specification. - *
+ * The generated UUID adheres strictly to the layout and variant bits of UUID version 7 as defined + * in the specification. + * + * @author zihluwang + * @author siujamo + * @version 3.0.0 */ public class SequentialUuidGenerator implements IdentityGenerator
- * When initializing a {@link SnowflakeIdentityGenerator}, you must provide the worker ID and data centre
- * ID, ensuring they are within the valid range defined by the bit size. The generator maintains an
- * internal sequence number that increments for IDs generated within the same millisecond. If the
- * system clock moves backward, an exception is thrown to prevent generating IDs with
- * repeated timestamps.
+ * When initializing a {@link SnowflakeIdentityGenerator}, you must provide the worker ID and data
+ * centre ID, ensuring they are within the valid range defined by the bit size. The generator
+ * maintains an internal sequence number that increments for IDs generated within the
+ * same millisecond. If the system clock moves backward, an exception is thrown to prevent
+ * generating IDs with repeated timestamps.
*
- * @author Zihlu Wang
- * @version 1.1.0
- * @since 1.0.0
+ * @author zihluwang
+ * @version 3.0.0
*/
public final class SnowflakeIdentityGenerator implements IdentityGenerator
- * Usage:
- * To use the {@code AuthzeroTokenResolver}, first, create an instance of this class:
- *
- * Then, you can utilize the various methods provided by this resolver to handle JWT tokens:
- *
- * Note:
- * It is essential to configure the appropriate algorithms, secret, and issuer according to your
- * specific use case when using this resolver. Additionally, ensure that the
- * {@code com.auth0:java-jwt} library is correctly configured in your project's dependencies.
- *
- * @author Zihlu Wang
- * @version 1.1.1
- * @see IdentityGenerator
- * @see Algorithm
- * @see JWTVerifier
- * @see JWTCreator
- * @see JWTCreator.Builder
- * @since 1.0.0
- */
-public class AuthzeroTokenResolver implements TokenResolver
- * A secret required by HMAC-based algorithms, or key pair required by ECDSA-based
- * algorithms need to be set before initialise an algorithm.
- *
- * @param algorithm an {@link TokenAlgorithm} value
- * @return the builder instance
- */
- public Builder algorithm(TokenAlgorithm algorithm) {
- // check the secret or key pair before algorithm initialised
- if (HMAC_ALGORITHMS.containsKey(algorithm)) {
- if (Objects.isNull(secret) || secret.isBlank()) {
- throw new IllegalSecretException("""
- Please specify a secret before define an algorithm.""");
- }
- } else if (ECDSA_ALGORITHMS.containsKey(algorithm)) {
- if (Objects.isNull(publicKey) || Objects.isNull(privateKey)) {
- throw new IllegalKeyPairException("""
- Please specify a ECDSA key pair before define an algorithm.""");
- }
- }
-
- // initialise algorithm
- this.algorithm = switch (algorithm) {
- case HS256, HS384, HS512 -> HMAC_ALGORITHMS.get(algorithm).apply(secret);
- case ES256, ES384, ES512 -> ECDSA_ALGORITHMS.get(algorithm)
- .apply(publicKey, privateKey);
- default -> throw new UnsupportedAlgorithmException("""
- This algorithm is not supported yet.""");
- };
- return this;
- }
-
- /**
- * Set the object mapper.
- *
- * @param objectMapper an object mapper
- * @return the builder instance
- */
- public Builder objectMapper(ObjectMapper objectMapper) {
- this.objectMapper = objectMapper;
- return this;
- }
-
- /**
- * Set the creator of JWT id.
- *
- * @param jtiCreator a creator to create JWT id
- * @return the builder instance
- */
- public Builder jtiCreator(IdentityGenerator> jtiCreator) {
- this.jtiCreator = jtiCreator;
- return this;
- }
-
- /**
- * Set the issuer of created JWT.
- *
- * @param issuer the person or organisation issued this JWT
- * @return the builder instance
- */
- public Builder issuer(String issuer) {
- this.issuer = issuer;
- return this;
- }
-
- /**
- * Create an {@link AuthzeroTokenResolver} instance
- *
- * @return created instance
- */
- public AuthzeroTokenResolver build() {
- return new AuthzeroTokenResolver(jtiCreator, algorithm, issuer, objectMapper);
- }
- }
-
- /**
- * Creates a new token with the specified expiration duration, subject, and
- * audience.
- *
- * @param expireAfter the duration after which the token will expire
- * @param subject the subject of the token
- * @param audience the audience for which the token is intended
- * @return the generated token as a {@code String}
- */
- @Override
- public String createToken(Duration expireAfter, String audience, String subject) {
- final var builder = JWT.create();
- buildBasicInfo(builder, expireAfter, subject, audience);
- return buildToken(builder);
- }
-
- /**
- * Creates a new token with the specified expiration time, subject,
- * audience, and custom payload data.
- *
- * @param expireAfter the duration after which the token will expire
- * @param subject the subject of the token
- * @param audience the audience for which the token is intended
- * @param payloads the custom payload data to be included in the token
- * @return the generated token as a {@code String}
- */
- @Override
- public String createToken(Duration expireAfter, String audience, String subject, Map
- * This method is used to add custom claims to the JWT. It takes a Map of
- * claims, where each entry represents a custom claim name (key) and its
- * corresponding value (value). The custom claims will be added to the JWT
- * using the JWTCreator.Builder.
- *
- * @param claims a Map containing the custom claims to be added to the JWT
- * @param builder the JWTCreator.Builder instance to which the custom
- * claims will be added
- */
- private void buildMapClaims(JWTCreator.Builder builder, Map
- * This is the final step of create a token, to sign this token.
- *
- * @param builder the builder to build this JWT
- * @return the generated token as a {@code String}
- */
- private String buildToken(JWTCreator.Builder builder) {
- return builder.sign(algorithm);
- }
-
- /**
- * Default type reference for Map.
- */
- public static class MapTypeReference extends TypeReference{@code
- * TokenResolver
- * {@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);
- * }
- *