feat: Moved package name from cn.org.codecrafters to com.onixbyte

This commit is contained in:
Zihlu Wang
2024-04-26 01:50:46 +08:00
parent 65287d0b24
commit 8dd0dad8d9
66 changed files with 180 additions and 188 deletions
+2 -2
View File
@@ -58,8 +58,8 @@ publishing {
}
scm {
connection = "scm:git:git://github.com:CodeCraftersCN/JDevKit.git"
developerConnection = "scm:git:git://github.com:CodeCraftersCN/JDevKit.git"
connection = "scm:git:git://github.com:OnixByte/JDevKit.git"
developerConnection = "scm:git:git://github.com:OnixByte/JDevKit.git"
url = projectGithubUrl
}
@@ -15,7 +15,7 @@
* limitations under the License.
*/
package cn.org.codecrafters.devkit.core.exceptions;
package com.onixbyte.devkit.core.exceptions;
/**
* The {@code NotImplementedException} class is a custom runtime exception
@@ -21,4 +21,4 @@
* @author Zihlu Wang
* @since 1.0.0
*/
package cn.org.codecrafters.devkit.core.exceptions;
package com.onixbyte.devkit.core.exceptions;
@@ -40,4 +40,4 @@
*
* @since 1.0.0
*/
package cn.org.codecrafters.devkit.core;
package com.onixbyte.devkit.core;
@@ -39,4 +39,4 @@
*
* @since 1.0.0
*/
package cn.org.codecrafters.devkit;
package com.onixbyte.devkit;
+5 -5
View File
@@ -51,7 +51,7 @@ implementation 'cn.org.codecrafters:devkit-utils:${devkit-utils.version}'
If you are trying to encode a string to Base64 string or decode a Base64 string to normal string, then you can try this:
```java
import cn.org.codecrafters.devkit.utils.Base64Util;
import utils.com.onixbyte.devkit.Base64Util;
// To reduce sample codes, let me use the simplified main method that is upcoming in Java 21
void main(String... args) {
@@ -68,7 +68,7 @@ void main(String... args) {
I believe those `if...else...` blocks make you headache, and Java imported lambda since Java 8, why not try to replace those `if...else` with lambda expressions?
```java
import cn.org.codecrafters.devkit.utils.BranchUtil;
import utils.com.onixbyte.devkit.BranchUtil;
void main(String... args) {
var a = 1;
@@ -106,7 +106,7 @@ If you have faced high-precision mathematical calculation in Java, you might kno
In Java, we usually do high-precision mathematical calculation with `BigDecimal` which is quite tricky when using it.
```java
import cn.org.codecrafters.devkit.utils.ChainedCalcUtil;
import utils.com.onixbyte.devkit.ChainedCalcUtil;
void main(String... args) {
// If you are trying to calculate the expression of 1 * 2 / 2 - 3 + 4
@@ -133,7 +133,7 @@ This `HashUtil` supports these following hash or message digest algorithms:
If you want to run a hash calculation to a string, you can use the following codes:
```java
import cn.org.codecrafters.devkit.utils.HashUtil;
import utils.com.onixbyte.devkit.HashUtil;
void main(String... args) {
var plaintext = "This is a plain text";
@@ -156,7 +156,7 @@ Imagine you are developing a website where users can register an account and sto
In order to store the Map in a database, you need to convert the Map to an Object. An Object is a generic data type that can store any type of data.
```java
import cn.org.codecrafters.devkit.utils.MapUtil;
import utils.com.onixbyte.devkit.MapUtil;
class Data {
private String name;
@@ -15,7 +15,7 @@
* limitations under the License.
*/
package cn.org.codecrafters.devkit.utils;
package com.onixbyte.devkit.utils;
import lombok.extern.slf4j.Slf4j;
@@ -15,7 +15,7 @@
* limitations under the License.
*/
package cn.org.codecrafters.devkit.utils;
package com.onixbyte.devkit.utils;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
@@ -15,7 +15,7 @@
* limitations under the License.
*/
package cn.org.codecrafters.devkit.utils;
package com.onixbyte.devkit.utils;
import java.util.Arrays;
import java.util.Objects;
@@ -15,7 +15,7 @@
* limitations under the License.
*/
package cn.org.codecrafters.devkit.utils;
package com.onixbyte.devkit.utils;
import lombok.Getter;
@@ -15,7 +15,7 @@
* limitations under the License.
*/
package cn.org.codecrafters.devkit.utils;
package com.onixbyte.devkit.utils;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
@@ -15,7 +15,7 @@
* limitations under the License.
*/
package cn.org.codecrafters.devkit.utils;
package com.onixbyte.devkit.utils;
import lombok.extern.slf4j.Slf4j;
@@ -25,4 +25,4 @@
* @author Zihlu Wang
* @since 1.0.0
*/
package cn.org.codecrafters.devkit.utils;
package com.onixbyte.devkit.utils;
+3 -3
View File
@@ -26,9 +26,9 @@ okhttpVersion=4.12.0
springVersion=6.1.3
springBootVersion=3.2.3
buildGroupId=cn.org.codecrafters
buildGroupId=com.onixbyte
buildVersion=1.4.0
projectUrl=https://codecrafters.org.cn/JDevKit
projectGithubUrl=https://github.com/CodeCraftersCN/JDevKit
projectUrl=https://onixbyte.com/JDevKit
projectGithubUrl=https://github.com/OnixByte/JDevKit
licenseName=The Apache License, Version 2.0
licenseUrl=https://www.apache.org/licenses/LICENSE-2.0.txt
@@ -15,7 +15,7 @@
* limitations under the License.
*/
package cn.org.codecrafters.guid;
package com.onixbyte.guid;
/**
* The {@code GuidCreator} is a generic interface for generating globally unique
@@ -15,7 +15,7 @@
* limitations under the License.
*/
package cn.org.codecrafters.guid.exceptions;
package com.onixbyte.guid.exceptions;
/**
* The {@code TimingException} class represents an exception that is thrown
@@ -21,7 +21,7 @@
* during the generation or processing of global unique identifiers (GUIDs).
* <p>
* The main exception class in this package is {@link
* cn.org.codecrafters.guid.exceptions.TimingException}, which is a runtime
* com.onixbyte.guid.exceptions.TimingException}, which is a runtime
* exception and serves as the base exception for all other custom exceptions
* related to GUID generation.
* <p>
@@ -38,4 +38,4 @@
*
* @since 1.0.0
*/
package cn.org.codecrafters.guid.exceptions;
package com.onixbyte.guid.exceptions;
@@ -15,10 +15,10 @@
* limitations under the License.
*/
package cn.org.codecrafters.guid.impl;
package com.onixbyte.guid.impl;
import cn.org.codecrafters.guid.GuidCreator;
import cn.org.codecrafters.guid.exceptions.TimingException;
import com.onixbyte.guid.GuidCreator;
import com.onixbyte.guid.exceptions.TimingException;
import java.time.LocalDateTime;
import java.time.ZoneId;
@@ -32,4 +32,4 @@
*
* @since 1.0.0
*/
package cn.org.codecrafters.guid;
package com.onixbyte.guid;
+4 -4
View File
@@ -48,12 +48,12 @@ implementation 'cn.org.codecrafters:property-guard-spring-boot-starter:${propert
## 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.
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 `utils.com.onixbyte.devkit.AesUtil` or `com.onixbyte.simplejwt.SecretCreator` to create a secret.
For example:
```java
import cn.org.codecrafters.devkit.utils.AesUtil;
import cn.org.codecrafters.simplejwt.SecretCreator;
import utils.com.onixbyte.devkit.AesUtil;
import com.onixbyte.simplejwt.SecretCreator;
class GenerateRandomKeySample {
public static void main(String[] args) {
@@ -66,7 +66,7 @@ class GenerateRandomKeySample {
Then, remember this secret and encrypt the configuration properties that are required high security. For example:
```java
import cn.org.codecrafters.devkit.utils.AesUtil;
import utils.com.onixbyte.devkit.AesUtil;
class EncryptSample {
public static void main(String[] args) {
@@ -15,9 +15,9 @@
* limitations under the License.
*/
package cn.org.codecrafters.propertyguard.autoconfiguration;
package com.onixbyte.propertyguard.autoconfiguration;
import cn.org.codecrafters.devkit.utils.AesUtil;
import com.onixbyte.devkit.utils.AesUtil;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.env.EnvironmentPostProcessor;
import org.springframework.boot.env.OriginTrackedMapPropertySource;
@@ -1 +1 @@
org.springframework.boot.env.EnvironmentPostProcessor=cn.org.codecrafters.propertyguard.autoconfiguration.PropertyGuard
org.springframework.boot.env.EnvironmentPostProcessor=com.onixbyte.propertyguard.autoconfiguration.PropertyGuard
+1 -1
View File
@@ -50,7 +50,7 @@ implementation 'cn.org.codecrafters:simple-jwt-authzero:${simple-jwt-authzero.ve
## Use the `AuthzeroTokenResolver`
We have implemented `TokenResolver` to make sure you can add JWT to your Java application as soon as possible. All you need to do is to create an instance of `cn.org.codecrafters.simplejwt.authzero.AuthzeroTokenResolver` and other operations to JWT could follow our instruction in [`simple-jwt-facade`](../simple-jwt-facade/README.md).
We have implemented `TokenResolver` to make sure you can add JWT to your Java application as soon as possible. All you need to do is to create an instance of `com.onixbyte.simplejwt.authzero.AuthzeroTokenResolver` and other operations to JWT could follow our instruction in [`simple-jwt-facade`](../simple-jwt-facade/README.md).
## Contact
@@ -15,34 +15,29 @@
* limitations under the License.
*/
package cn.org.codecrafters.simplejwt.authzero;
package com.onixbyte.simplejwt.authzero;
import cn.org.codecrafters.devkit.utils.Base64Util;
import cn.org.codecrafters.guid.GuidCreator;
import cn.org.codecrafters.simplejwt.SecretCreator;
import cn.org.codecrafters.simplejwt.TokenPayload;
import cn.org.codecrafters.simplejwt.TokenResolver;
import cn.org.codecrafters.simplejwt.annotations.ExcludeFromPayload;
import cn.org.codecrafters.simplejwt.annotations.TokenEnum;
import cn.org.codecrafters.simplejwt.authzero.config.AuthzeroTokenResolverConfig;
import cn.org.codecrafters.simplejwt.config.TokenResolverConfig;
import cn.org.codecrafters.simplejwt.constants.PredefinedKeys;
import cn.org.codecrafters.simplejwt.constants.TokenAlgorithm;
import com.onixbyte.devkit.utils.Base64Util;
import com.onixbyte.guid.GuidCreator;
import com.onixbyte.simplejwt.SecretCreator;
import com.onixbyte.simplejwt.TokenPayload;
import com.onixbyte.simplejwt.TokenResolver;
import com.onixbyte.simplejwt.annotations.ExcludeFromPayload;
import com.onixbyte.simplejwt.annotations.TokenEnum;
import com.onixbyte.simplejwt.authzero.config.AuthzeroTokenResolverConfig;
import com.onixbyte.simplejwt.constants.PredefinedKeys;
import com.onixbyte.simplejwt.constants.TokenAlgorithm;
import com.auth0.jwt.JWT;
import com.auth0.jwt.JWTCreator;
import com.auth0.jwt.algorithms.Algorithm;
import com.auth0.jwt.interfaces.Claim;
import com.auth0.jwt.interfaces.DecodedJWT;
import com.auth0.jwt.interfaces.JWTVerifier;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import lombok.extern.slf4j.Slf4j;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.time.Duration;
import java.time.LocalDateTime;
@@ -51,7 +46,7 @@ import java.util.*;
/**
* The {@code AuthzeroTokenResolver} class is an implementation of the {@link
* cn.org.codecrafters.simplejwt.TokenResolver} interface. It uses the {@code
* 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.
@@ -15,13 +15,13 @@
* limitations under the License.
*/
package cn.org.codecrafters.simplejwt.authzero.config;
package com.onixbyte.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;
import com.onixbyte.simplejwt.TokenResolver;
import com.onixbyte.simplejwt.authzero.AuthzeroTokenResolver;
import com.onixbyte.simplejwt.config.TokenResolverConfig;
import com.onixbyte.simplejwt.constants.TokenAlgorithm;
import com.onixbyte.simplejwt.exceptions.UnsupportedAlgorithmException;
import com.auth0.jwt.algorithms.Algorithm;
import java.util.HashMap;
@@ -18,37 +18,37 @@
/**
* The package {@code cn.org.codecrafters.simplejwt.authzero.config} contains
* configuration classes related to the {@link
* cn.org.codecrafters.simplejwt.authzero.AuthzeroTokenResolver}
* com.onixbyte.simplejwt.authzero.AuthzeroTokenResolver}
* implementation.
* <p>
* The classes in this package provide configuration options and settings for
* the {@link cn.org.codecrafters.simplejwt.authzero.AuthzeroTokenResolver},
* the {@link com.onixbyte.simplejwt.authzero.AuthzeroTokenResolver},
* which is used for resolving JSON Web Tokens (JWT) using the Auth0 library.
* <p>
* The {@link
* cn.org.codecrafters.simplejwt.authzero.config.AuthzeroTokenResolverConfig}
* com.onixbyte.simplejwt.authzero.config.AuthzeroTokenResolverConfig}
* class is a configuration class that defines the mapping between standard
* {@link cn.org.codecrafters.simplejwt.constants.TokenAlgorithm} and the
* {@link com.onixbyte.simplejwt.constants.TokenAlgorithm} and the
* corresponding function implementation used by {@link
* cn.org.codecrafters.simplejwt.authzero.AuthzeroTokenResolver} for handling
* com.onixbyte.simplejwt.authzero.AuthzeroTokenResolver} for handling
* JWT algorithms. It enables developers to specify and customize the
* algorithm functions according to the chosen JWT algorithm and the library
* being used.
* <p>
* The configuration options in this package help developers integrate and
* configure the {@link
* cn.org.codecrafters.simplejwt.authzero.AuthzeroTokenResolver} seamlessly
* com.onixbyte.simplejwt.authzero.AuthzeroTokenResolver} seamlessly
* 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.
* <p>
* It is recommended to explore the classes in this package to understand how
* to configure and use the {@link
* cn.org.codecrafters.simplejwt.authzero.AuthzeroTokenResolver} effectively
* com.onixbyte.simplejwt.authzero.AuthzeroTokenResolver} effectively
* in the Spring Boot environment to handle JWT authentication and
* authorisation securely and efficiently.
*
* @since 1.0.0
*/
package cn.org.codecrafters.simplejwt.authzero.config;
package com.onixbyte.simplejwt.authzero.config;
@@ -25,15 +25,15 @@
* the {@code com.auth0:java-jwt} library.
* <p>
* The main class in this package is the {@link
* cn.org.codecrafters.simplejwt.authzero.AuthzeroTokenResolver}, which
* implements the {@link cn.org.codecrafters.simplejwt.TokenResolver} interface
* com.onixbyte.simplejwt.authzero.AuthzeroTokenResolver}, which
* implements the {@link com.onixbyte.simplejwt.TokenResolver} interface
* and uses the {@code com.auth0:java-jwt} library to handle JWT operations. It
* provides the functionality to create, validate, and extract JWTs using the
* {@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.
* <p>
* The {@link cn.org.codecrafters.simplejwt.authzero.AuthzeroTokenResolver}
* The {@link com.onixbyte.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
@@ -41,12 +41,12 @@
* algorithms for JWT signing and verification.
* <p>
* To use the {@link
* cn.org.codecrafters.simplejwt.authzero.AuthzeroTokenResolver}, developers
* com.onixbyte.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
* {@link com.onixbyte.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}
* com.onixbyte.simplejwt.authzero.config.AuthzeroTokenResolverConfig}
* class provides a convenient way to configure these dependencies.
* <p>
* Developers using the {@code com.auth0:java-jwt} integration should be
@@ -56,4 +56,4 @@
*
* @since 1.0.0
*/
package cn.org.codecrafters.simplejwt.authzero;
package com.onixbyte.simplejwt.authzero;
@@ -15,10 +15,10 @@
* limitations under the License.
*/
package cn.org.codecrafters.simplejwt.authzero.test;
package com.onixbyte.simplejwt.authzero.test;
import cn.org.codecrafters.simplejwt.authzero.AuthzeroTokenResolver;
import cn.org.codecrafters.simplejwt.constants.TokenAlgorithm;
import com.onixbyte.simplejwt.authzero.AuthzeroTokenResolver;
import com.onixbyte.simplejwt.constants.TokenAlgorithm;
import org.junit.jupiter.api.Test;
import java.time.Duration;
@@ -15,9 +15,9 @@
* limitations under the License.
*/
package cn.org.codecrafters.simplejwt;
package com.onixbyte.simplejwt;
import cn.org.codecrafters.simplejwt.exceptions.WeakSecretException;
import com.onixbyte.simplejwt.exceptions.WeakSecretException;
import java.util.Random;
@@ -15,7 +15,7 @@
* limitations under the License.
*/
package cn.org.codecrafters.simplejwt;
package com.onixbyte.simplejwt;
import java.util.Map;
@@ -15,9 +15,8 @@
* limitations under the License.
*/
package cn.org.codecrafters.simplejwt;
package com.onixbyte.simplejwt;
import java.lang.reflect.InvocationTargetException;
import java.time.Duration;
import java.util.Map;
@@ -15,7 +15,7 @@
* limitations under the License.
*/
package cn.org.codecrafters.simplejwt.annotations;
package com.onixbyte.simplejwt.annotations;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
@@ -15,9 +15,9 @@
* limitations under the License.
*/
package cn.org.codecrafters.simplejwt.annotations;
package com.onixbyte.simplejwt.annotations;
import cn.org.codecrafters.simplejwt.constants.TokenDataType;
import com.onixbyte.simplejwt.constants.TokenDataType;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
@@ -24,4 +24,4 @@
*
* @since 1.0.0
*/
package cn.org.codecrafters.simplejwt.annotations;
package com.onixbyte.simplejwt.annotations;
@@ -15,10 +15,10 @@
* limitations under the License.
*/
package cn.org.codecrafters.simplejwt.config;
package com.onixbyte.simplejwt.config;
import cn.org.codecrafters.simplejwt.TokenResolver;
import cn.org.codecrafters.simplejwt.constants.TokenAlgorithm;
import com.onixbyte.simplejwt.TokenResolver;
import com.onixbyte.simplejwt.constants.TokenAlgorithm;
/**
* The {@code TokenResolverConfig} provides a mechanism to configure an
@@ -29,4 +29,4 @@
*
* @since 1.0.0
*/
package cn.org.codecrafters.simplejwt.config;
package com.onixbyte.simplejwt.config;
@@ -15,7 +15,7 @@
* limitations under the License.
*/
package cn.org.codecrafters.simplejwt.constants;
package com.onixbyte.simplejwt.constants;
import java.util.List;
@@ -15,7 +15,7 @@
* limitations under the License.
*/
package cn.org.codecrafters.simplejwt.constants;
package com.onixbyte.simplejwt.constants;
import lombok.Getter;
@@ -15,7 +15,7 @@
* limitations under the License.
*/
package cn.org.codecrafters.simplejwt.constants;
package com.onixbyte.simplejwt.constants;
import lombok.Getter;
@@ -23,4 +23,4 @@
*
* @since 1.0.0
*/
package cn.org.codecrafters.simplejwt.constants;
package com.onixbyte.simplejwt.constants;
@@ -15,12 +15,14 @@
* limitations under the License.
*/
package cn.org.codecrafters.simplejwt.exceptions;
package com.onixbyte.simplejwt.exceptions;
import com.onixbyte.simplejwt.TokenResolver;
/**
* This {@code UnsupportedAlgorithmException} represents the given
* algorithm is not supported by {@link
* cn.org.codecrafters.simplejwt.TokenResolver} yet.
* TokenResolver} yet.
* <p>
* If you want the supports to an unsupported algorithm, you could
* <ul>
@@ -15,7 +15,7 @@
* limitations under the License.
*/
package cn.org.codecrafters.simplejwt.exceptions;
package com.onixbyte.simplejwt.exceptions;
/**
* {@code WeakSecretException} represents that your secret is too weak to be
@@ -36,4 +36,4 @@
*
* @since 1.0.0
*/
package cn.org.codecrafters.simplejwt.exceptions;
package com.onixbyte.simplejwt.exceptions;
@@ -37,4 +37,4 @@
*
* @since 1.0.0
*/
package cn.org.codecrafters.simplejwt;
package com.onixbyte.simplejwt;
+1 -1
View File
@@ -45,7 +45,7 @@ implementation 'cn.org.codecrafters:simple-jwt-authzero:${simple-jwt-authzero.ve
## Use the `JjwtTokenResolver`
We have implemented `TokenResolver` to make sure you can add JWT to your Java application as soon as possible. All you need to do is to create an instance of `cn.org.codecrafters.simplejwt.jjwt.JjwtTokenResolver` and other operations to JWT could follow our instruction in [`simple-jwt-facade`](../simple-jwt-facade/README.md).
We have implemented `TokenResolver` to make sure you can add JWT to your Java application as soon as possible. All you need to do is to create an instance of `jjwt.com.onixbyte.simplejwt.JjwtTokenResolver` and other operations to JWT could follow our instruction in [`simple-jwt-facade`](../simple-jwt-facade/README.md).
## Contact
@@ -15,19 +15,19 @@
* limitations under the License.
*/
package cn.org.codecrafters.simplejwt.jjwt;
package com.onixbyte.simplejwt.jjwt;
import cn.org.codecrafters.devkit.utils.MapUtil;
import cn.org.codecrafters.guid.GuidCreator;
import cn.org.codecrafters.simplejwt.SecretCreator;
import cn.org.codecrafters.simplejwt.TokenPayload;
import cn.org.codecrafters.simplejwt.TokenResolver;
import cn.org.codecrafters.simplejwt.annotations.ExcludeFromPayload;
import cn.org.codecrafters.simplejwt.annotations.TokenEnum;
import cn.org.codecrafters.simplejwt.constants.PredefinedKeys;
import cn.org.codecrafters.simplejwt.constants.TokenAlgorithm;
import cn.org.codecrafters.simplejwt.exceptions.WeakSecretException;
import cn.org.codecrafters.simplejwt.jjwt.config.JjwtTokenResolverConfig;
import com.onixbyte.devkit.utils.MapUtil;
import com.onixbyte.guid.GuidCreator;
import com.onixbyte.simplejwt.SecretCreator;
import com.onixbyte.simplejwt.TokenPayload;
import com.onixbyte.simplejwt.TokenResolver;
import com.onixbyte.simplejwt.annotations.ExcludeFromPayload;
import com.onixbyte.simplejwt.annotations.TokenEnum;
import com.onixbyte.simplejwt.constants.PredefinedKeys;
import com.onixbyte.simplejwt.constants.TokenAlgorithm;
import com.onixbyte.simplejwt.exceptions.WeakSecretException;
import com.onixbyte.simplejwt.jjwt.config.JjwtTokenResolverConfig;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jws;
import io.jsonwebtoken.Jwts;
@@ -15,16 +15,14 @@
* limitations under the License.
*/
package cn.org.codecrafters.simplejwt.jjwt.config;
package com.onixbyte.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;
import cn.org.codecrafters.simplejwt.jjwt.JjwtTokenResolver;
import com.onixbyte.simplejwt.TokenResolver;
import com.onixbyte.simplejwt.config.TokenResolverConfig;
import com.onixbyte.simplejwt.constants.TokenAlgorithm;
import com.onixbyte.simplejwt.exceptions.UnsupportedAlgorithmException;
import com.onixbyte.simplejwt.jjwt.JjwtTokenResolver;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
import io.jsonwebtoken.security.MacAlgorithm;
import io.jsonwebtoken.security.SecureDigestAlgorithm;
import javax.crypto.SecretKey;
@@ -18,36 +18,36 @@
/**
* The package {@code cn.org.codecrafters.simplejwt.jjwt.config} contains
* configuration classes related to the {@link
* cn.org.codecrafters.simplejwt.jjwt.JjwtTokenResolver}
* com.onixbyte.simplejwt.jjwt.JjwtTokenResolver}
* implementation.
* <p>
* The classes in this package provide configuration options and settings for
* the {@link cn.org.codecrafters.simplejwt.jjwt.JjwtTokenResolver},
* the {@link com.onixbyte.simplejwt.jjwt.JjwtTokenResolver},
* which is used for resolving JSON Web Tokens (JWT) using the Auth0 library.
* <p>
* The {@link
* cn.org.codecrafters.simplejwt.jjwt.config.JjwtTokenResolverConfig}
* com.onixbyte.simplejwt.jjwt.config.JjwtTokenResolverConfig}
* class is a configuration class that defines the mapping between standard
* {@link cn.org.codecrafters.simplejwt.constants.TokenAlgorithm} and the
* {@link com.onixbyte.simplejwt.constants.TokenAlgorithm} and the
* corresponding function implementation used by {@link
* cn.org.codecrafters.simplejwt.jjwt.JjwtTokenResolver} for handling
* com.onixbyte.simplejwt.jjwt.JjwtTokenResolver} for handling
* JWT algorithms. It enables developers to specify and customize the
* algorithm functions according to the chosen JWT algorithm and the library
* being used.
* <p>
* The configuration options in this package help developers integrate and
* configure the {@link
* cn.org.codecrafters.simplejwt.jjwt.JjwtTokenResolver} seamlessly
* com.onixbyte.simplejwt.jjwt.JjwtTokenResolver} seamlessly
* 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.
* <p>
* It is recommended to explore the classes in this package to understand how
* to configure and use the {@link
* cn.org.codecrafters.simplejwt.jjwt.JjwtTokenResolver} effectively
* com.onixbyte.simplejwt.jjwt.JjwtTokenResolver} effectively
* in the Spring Boot environment to handle JWT authentication and
* authorisation securely and efficiently.
*
* @since 1.0.0
*/
package cn.org.codecrafters.simplejwt.jjwt.config;
package com.onixbyte.simplejwt.jjwt.config;
@@ -25,27 +25,27 @@
* the {@code io.jsonwebtoken:jjwt-api} library.
* <p>
* The main class in this package is the {@link
* cn.org.codecrafters.simplejwt.jjwt.JjwtTokenResolver}, which
* implements the {@link cn.org.codecrafters.simplejwt.TokenResolver} interface
* com.onixbyte.simplejwt.jjwt.JjwtTokenResolver}, which
* implements the {@link com.onixbyte.simplejwt.TokenResolver} interface
* and uses the {@code io.jsonwebtoken:jjwt-api} library to handle JWT
* operations. It provides the functionality to create, validate, and extract
* 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.
* <p>
* The {@link cn.org.codecrafters.simplejwt.jjwt.JjwtTokenResolver} relies on
* The {@link com.onixbyte.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}
* {@link io.jsonwebtoken.SignatureAlgorithm} class to define and use different
* algorithms for JWT signing and verification.
* <p>
* To use the {@link cn.org.codecrafters.simplejwt.jjwt.JjwtTokenResolver},
* To use the {@link com.onixbyte.simplejwt.jjwt.JjwtTokenResolver},
* developers must provide the necessary configurations and dependencies, such
* as the {@link cn.org.codecrafters.guid.GuidCreator} for generating unique
* as the {@link com.onixbyte.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}
* {@link com.onixbyte.simplejwt.jjwt.config.JjwtTokenResolverConfig}
* class provides a convenient way to configure these dependencies.
* <p>
* Developers using the {@code io.jsonwebtoken:jjwt-api} integration should be
@@ -55,4 +55,4 @@
*
* @since 1.0.0
*/
package cn.org.codecrafters.simplejwt.jjwt;
package com.onixbyte.simplejwt.jjwt;
+1 -1
View File
@@ -66,7 +66,7 @@ implementation 'cn.org.codecrafters:simple-jwt-spring-boot-starter:${simple-jwt-
We need a `GuidCreator` instance to create JWT ID, though we did implemented a simple `GuidCreator`, but you can still customize it.
First, please implement the `cn.org.codecrafters.guid.GuidCreator` interface based on your own rules for generating JWT IDs.
First, please implement the `com.onixbyte.guid.GuidCreator` interface based on your own rules for generating JWT IDs.
Then, add the instance of your own guid creator to spring container, whose name is `jtiCreator`.
@@ -15,12 +15,12 @@
* limitations under the License.
*/
package cn.org.codecrafters.simplejwt.autoconfiguration;
package com.onixbyte.simplejwt.autoconfiguration;
import cn.org.codecrafters.guid.GuidCreator;
import cn.org.codecrafters.simplejwt.TokenResolver;
import cn.org.codecrafters.simplejwt.authzero.AuthzeroTokenResolver;
import cn.org.codecrafters.simplejwt.autoconfiguration.properties.SimpleJwtProperties;
import com.onixbyte.guid.GuidCreator;
import com.onixbyte.simplejwt.TokenResolver;
import com.onixbyte.simplejwt.authzero.AuthzeroTokenResolver;
import com.onixbyte.simplejwt.autoconfiguration.properties.SimpleJwtProperties;
import com.auth0.jwt.interfaces.DecodedJWT;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
@@ -15,14 +15,12 @@
* limitations under the License.
*/
package cn.org.codecrafters.simplejwt.autoconfiguration;
package com.onixbyte.simplejwt.autoconfiguration;
import cn.org.codecrafters.guid.GuidCreator;
import cn.org.codecrafters.simplejwt.autoconfiguration.conditions.GuidCreatorCondition;
import com.onixbyte.guid.GuidCreator;
import com.onixbyte.simplejwt.autoconfiguration.conditions.GuidCreatorCondition;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.SearchStrategy;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
@@ -15,12 +15,12 @@
* limitations under the License.
*/
package cn.org.codecrafters.simplejwt.autoconfiguration;
package com.onixbyte.simplejwt.autoconfiguration;
import cn.org.codecrafters.guid.GuidCreator;
import cn.org.codecrafters.simplejwt.TokenResolver;
import cn.org.codecrafters.simplejwt.autoconfiguration.properties.SimpleJwtProperties;
import cn.org.codecrafters.simplejwt.jjwt.JjwtTokenResolver;
import com.onixbyte.guid.GuidCreator;
import com.onixbyte.simplejwt.TokenResolver;
import com.onixbyte.simplejwt.autoconfiguration.properties.SimpleJwtProperties;
import com.onixbyte.simplejwt.jjwt.JjwtTokenResolver;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jws;
import lombok.extern.slf4j.Slf4j;
@@ -1,6 +1,6 @@
package cn.org.codecrafters.simplejwt.autoconfiguration.conditions;
package com.onixbyte.simplejwt.autoconfiguration.conditions;
import cn.org.codecrafters.guid.GuidCreator;
import com.onixbyte.guid.GuidCreator;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
@@ -22,7 +22,7 @@ public class GuidCreatorCondition implements Condition {
* The condition to create bean {@code jtiCreator}.
* <p>
* If Spring does not have a bean of type
* {@link cn.org.codecrafters.guid.GuidCreator} named {@code jtiCreator}
* {@link GuidCreator} named {@code jtiCreator}
* in the application context, then create {@code jtiCreator}.
*
* @param context the spring application context
@@ -35,4 +35,4 @@
*
* @since 1.0.0
*/
package cn.org.codecrafters.simplejwt.autoconfiguration;
package com.onixbyte.simplejwt.autoconfiguration;
@@ -15,11 +15,12 @@
* limitations under the License.
*/
package cn.org.codecrafters.simplejwt.autoconfiguration.properties;
package com.onixbyte.simplejwt.autoconfiguration.properties;
import cn.org.codecrafters.simplejwt.SecretCreator;
import cn.org.codecrafters.simplejwt.autoconfiguration.AuthzeroTokenResolverAutoConfiguration;
import cn.org.codecrafters.simplejwt.constants.TokenAlgorithm;
import com.onixbyte.simplejwt.SecretCreator;
import com.onixbyte.simplejwt.autoconfiguration.AuthzeroTokenResolverAutoConfiguration;
import com.onixbyte.simplejwt.constants.TokenAlgorithm;
import com.onixbyte.simplejwt.jjwt.JjwtTokenResolver;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
@@ -32,7 +33,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
* {@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
* JjwtTokenResolver} to set up the
* necessary configurations for JWT generation and validation.
* <p>
* Developers can customise the JWT algorithm, issuer, and secret by setting
@@ -45,7 +46,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
* @since 1.0.0
*/
@Data
@ConfigurationProperties(prefix = "code-crafters.simple-jwt")
@ConfigurationProperties(prefix = "onixbyte.simple-jwt")
public class SimpleJwtProperties {
/**
@@ -27,9 +27,9 @@
* the corresponding properties in the application's properties file with the
* prefix "code-crafters.simple-jwt". The SimpleJwtAutoConfiguration class
* reads these properties and uses them to create the {@link
* cn.org.codecrafters.simplejwt.TokenResolver} bean with the desired
* com.onixbyte.simplejwt.TokenResolver} bean with the desired
* configuration.
*
* @since 1.0.0
*/
package cn.org.codecrafters.simplejwt.autoconfiguration.properties;
package com.onixbyte.simplejwt.autoconfiguration.properties;
@@ -1,3 +1,3 @@
cn.org.codecrafters.simplejwt.autoconfiguration.GuidAutoConfiguration
cn.org.codecrafters.simplejwt.autoconfiguration.AuthzeroTokenResolverAutoConfiguration
cn.org.codecrafters.simplejwt.autoconfiguration.JjwtTokenResolverAutoConfiguration
com.onixbyte.simplejwt.autoconfiguration.GuidAutoConfiguration
com.onixbyte.simplejwt.autoconfiguration.AuthzeroTokenResolverAutoConfiguration
com.onixbyte.simplejwt.autoconfiguration.JjwtTokenResolverAutoConfiguration
@@ -15,9 +15,9 @@
* limitations under the License.
*/
package cn.org.codecrafters.webcal;
package com.onixbyte.webcal;
import cn.org.codecrafters.webcal.impl.WebCalendarEvent;
import com.onixbyte.webcal.impl.WebCalendarEvent;
import java.util.ArrayList;
import java.util.List;
@@ -15,10 +15,9 @@
* limitations under the License.
*/
package cn.org.codecrafters.webcal;
package com.onixbyte.webcal;
import cn.org.codecrafters.webcal.config.Classification;
import cn.org.codecrafters.webcal.impl.WebCalendarEvent;
import com.onixbyte.webcal.config.Classification;
import java.time.Duration;
import java.time.LocalDateTime;
@@ -15,7 +15,7 @@
* limitations under the License.
*/
package cn.org.codecrafters.webcal.config;
package com.onixbyte.webcal.config;
import lombok.Getter;
@@ -15,7 +15,7 @@
* limitations under the License.
*/
package cn.org.codecrafters.webcal.config;
package com.onixbyte.webcal.config;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
@@ -23,11 +23,11 @@
* <p>The classes in this package include:</p>
* <ul>
* <li>
* {@link cn.org.codecrafters.webcal.config.Classification}: An enum
* {@link com.onixbyte.webcal.config.Classification}: An enum
* representing the classification of events in the web calendar.
* </li>
* </ul>
*
* @since 1.0.0
*/
package cn.org.codecrafters.webcal.config;
package com.onixbyte.webcal.config;
@@ -15,11 +15,11 @@
* limitations under the License.
*/
package cn.org.codecrafters.webcal.impl;
package com.onixbyte.webcal.impl;
import cn.org.codecrafters.webcal.WebCalendarNode;
import cn.org.codecrafters.webcal.config.Classification;
import cn.org.codecrafters.webcal.config.DateAndTimeFormatter;
import com.onixbyte.webcal.WebCalendarNode;
import com.onixbyte.webcal.config.Classification;
import com.onixbyte.webcal.config.DateAndTimeFormatter;
import java.text.MessageFormat;
import java.time.Duration;
@@ -23,16 +23,16 @@
* The main classes and modules in this package include:
* <ul>
* <li>
* {@link cn.org.codecrafters.webcal.WebCalendar}: A class for
* {@link com.onixbyte.webcal.WebCalendar}: A class for
* generating web calendars with customisable settings and events.
* </li>
* <li>
* {@link cn.org.codecrafters.webcal.impl.WebCalendarEvent}: A class
* {@link com.onixbyte.webcal.impl.WebCalendarEvent}: A class
* representing a single event in a web calendar with various
* attributes and options.
* </li>
* <li>
* {@link cn.org.codecrafters.webcal.WebCalendarNode}: An abstract
* {@link com.onixbyte.webcal.WebCalendarNode}: An abstract
* class serving as the base class for web calendar nodes, providing
* common attributes and functionality for events.
* </li>
@@ -40,4 +40,4 @@
*
* @since 1.0.0
*/
package cn.org.codecrafters.webcal;
package com.onixbyte.webcal;
@@ -15,11 +15,11 @@
* limitations under the License.
*/
package cn.org.codecrafters.webcal.test;
package com.onixbyte.webcal.test;
import cn.org.codecrafters.webcal.WebCalendar;
import cn.org.codecrafters.webcal.impl.WebCalendarEvent;
import cn.org.codecrafters.webcal.config.Classification;
import com.onixbyte.webcal.WebCalendar;
import com.onixbyte.webcal.impl.WebCalendarEvent;
import com.onixbyte.webcal.config.Classification;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;