docs: Fix all docs from one <p> represents for a paragraph

This commit is contained in:
Zihlu Wang
2023-07-31 21:43:09 +08:00
parent 373fbf9083
commit 715ae6db3a
28 changed files with 627 additions and 133 deletions
@@ -17,7 +17,7 @@
package cn.org.codecrafters.simplejwt.authzero;
import cn.org.codecrafters.devkit.guid.GuidCreator;
import cn.org.codecrafters.guid.GuidCreator;
import cn.org.codecrafters.simplejwt.TokenPayload;
import cn.org.codecrafters.simplejwt.TokenResolver;
import cn.org.codecrafters.simplejwt.annotations.ExcludeFromPayload;
@@ -37,16 +37,19 @@ import java.time.ZoneId;
import java.util.*;
/**
* <p>
* The {@code AuthzeroTokenResolver} class is an implementation of the {@link
* cn.org.codecrafters.simplejwt.TokenResolver} interface. It uses the {@code
* com.auth0:java-jwt} library to handle JSON Web Token (JWT) resolution. This
* resolver provides functionality to create, extract, verify, and renew JWT
* tokens using various algorithms and custom payload data.
* </p>
* <p>
* <b>Dependencies:</b>
* This implementation relies on the {@code com.auth0:java-jwt} library. Please
* ensure you have added this library as a dependency to your project before
* using this resolver.
* </p>
* <p>
* <b>Usage:</b>
* To use the {@code AuthzeroTokenResolver}, first, create an instance of this
@@ -58,6 +61,7 @@ import java.util.*;
* "Token Issuer",
* "Token Secret");
* }</pre>
* </p>
* <p>
* Then, you can utilize the various methods provided by this resolver to
* handle JWT tokens:
@@ -78,12 +82,14 @@ import java.util.*;
* String renewedToken =
* tokenResolver.renew(token, Duration.ofMinutes(30), customPayloads);
* }</pre>
* </p>
* <p>
* <b>Note:</b>
* 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.
* </p>
*
* @author Zihlu Wang
* @version 1.0.0
@@ -232,13 +238,16 @@ public class AuthzeroTokenResolver implements TokenResolver<DecodedJWT> {
}
/**
* <p>
* Builds the custom claims of the JSON Web Token (JWT) using the provided
* Map of claims and adds them to the JWTCreator.Builder.
* <p>
* <p>
* 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.
* <p>
*
* @param claims a Map containing the custom claims to be added to the JWT
* @param builder the JWTCreator.Builder instance to which the custom
@@ -253,9 +262,12 @@ public class AuthzeroTokenResolver implements TokenResolver<DecodedJWT> {
}
/**
* <p>
* Finish creating a token.
* </p>
* <p>
* This is the final step of create a token, to sign this token.
* </p>
*
* @param builder the builder to build this JWT
* @return the generated token as a {@code String}
@@ -62,27 +62,35 @@ import java.util.function.Function;
public final class AuthzeroTokenResolverConfig implements TokenResolverConfig<Function<String, Algorithm>> {
/**
* <p>
* Constructs a new instance of AuthzeroTokenResolverConfig.
* </p>
* <p>
* The constructor is set as private to enforce the singleton pattern for
* this configuration class. Instances of AuthzeroTokenResolverConfig
* should be obtained through the {@link #getInstance()} method.
* </p>
*/
private AuthzeroTokenResolverConfig() {
}
/**
* <p>
* The singleton instance of AuthzeroTokenResolverConfig.
* </p>
* <p>
* This instance is used to ensure that only one instance of
* AuthzeroTokenResolverConfig is created and shared throughout the
* application. The singleton pattern is implemented to provide centralized
* configuration and avoid redundant object creation.
* </p>
*/
private static AuthzeroTokenResolverConfig instance;
/**
* <p>
* The supported algorithms and their corresponding algorithm functions.
* </p>
* <p>
* This map stores the supported algorithms as keys and their corresponding
* algorithm functions as values. The algorithm functions represent the
@@ -115,14 +123,17 @@ public final class AuthzeroTokenResolverConfig implements TokenResolverConfig<Fu
}
/**
* <p>
* Gets the algorithm function corresponding to the specified
* TokenAlgorithm.
* </p>
* <p>
* This method returns the algorithm function associated with the given
* TokenAlgorithm. The provided TokenAlgorithm represents the specific
* algorithm for which the corresponding algorithm function is required.
* The returned AlgorithmFunction represents the function implementation
* that can be used by the TokenResolver to handle the specific algorithm.
* </p>
*
* @param algorithm the TokenAlgorithm for which the algorithm function is
* required
@@ -0,0 +1,64 @@
/*
* Copyright (C) 2023 CodeCraftersCN.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* <p>
* The package {@code cn.org.codecrafters.simplejwt.authzero.config} contains
* configuration classes related to the {@link
* cn.org.codecrafters.simplejwt.authzero.AuthzeroTokenResolver}
* implementation.
* </p>
*
* <p>
* The classes in this package provide configuration options and settings for
* the {@link cn.org.codecrafters.simplejwt.authzero.AuthzeroTokenResolver},
* which is used for resolving JSON Web Tokens (JWT) using the Auth0 library.
* </p>
*
* <p>
* The {@link
* cn.org.codecrafters.simplejwt.authzero.config.AuthzeroTokenResolverConfig}
* class is a configuration class that defines the mapping between standard
* {@link cn.org.codecrafters.simplejwt.constants.TokenAlgorithm} and the
* corresponding function implementation used by {@link
* cn.org.codecrafters.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>
*
* <p>
* The configuration options in this package help developers integrate and
* configure the {@link
* cn.org.codecrafters.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>
*
* <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
* in the Spring Boot environment to handle JWT authentication and
* authorization securely and efficiently.
* </p>
*
* @since 1.0.0
*/
package cn.org.codecrafters.simplejwt.authzero.config;
@@ -0,0 +1,69 @@
/*
* Copyright (C) 2023 CodeCraftersCN.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* <h3>cn.org.codecrafters.simplejwt.authzero</h3>
*
* <p>
* This package contains classes related to the integration of the {@code
* com.auth0:java-jwt} library in the Simple JWT project. {@code
* com.auth0:java-jwt} is a powerful and widely-used Identity as a Service
* (IDaaS) platform that provides secure authentication and authorization
* solutions for web and mobile applications. The classes in this package
* provide the necessary functionality to handle JSON Web Tokens (JWTs) using
* the {@code com.auth0:java-jwt} library.
* </p>
*
* <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
* 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>
*
* <p>
* The {@code AuthzeroTokenResolver} relies on the {@code com.auth0:java-jwt}
* library to handle the underlying JWT operations, including token creation,
* validation, and extraction. It utilizes the {@code com.auth0:java-jwt}
* {@code Algorithm} class to define and use different algorithms for JWT
* signing and verification.
* </p>
*
* <p>
* To use the {@code AuthzeroTokenResolver}, developers must provide the
* necessary configurations and dependencies, such as the {@code GuidCreator}
* for generating unique JWT IDs (JTI), the supported algorithm function, the
* issuer name, and the secret key used for token signing and validation. The
* {@code AuthzeroTokenResolverConfig} class provides a convenient way to
* configure these dependencies.
* </p>
*
* <p>
* Developers using the {@code com.auth0:java-jwt} integration should be
* familiar with the concepts and usage of the {@code com.auth0:java-jwt}
* library and follow the official {@code com.auth0:java-jwt} documentation for
* best practices and security considerations.
* </p>
*
* @since 1.0.0
*/
package cn.org.codecrafters.simplejwt.authzero;