docs(global): Optimised javadoc, changed the spelling to British English.
This commit is contained in:
+4
-4
@@ -58,7 +58,7 @@ import java.util.UUID;
|
||||
* To use the {@code JjwtTokenResolver}, first, create an instance of this
|
||||
* class:
|
||||
* <pre>{@code
|
||||
* TokenResolver<DecodedJWT> tokenResolver =
|
||||
* TokenResolver<Jws<Claims>> tokenResolver =
|
||||
* new JjwtTokenResolver(TokenAlgorithm.HS256,
|
||||
* "Token Subject",
|
||||
* "Token Issuer",
|
||||
@@ -119,7 +119,7 @@ public class JjwtTokenResolver implements TokenResolver<Jws<Claims>> {
|
||||
|
||||
if (secret.length() <= 32) {
|
||||
log.error("""
|
||||
The provided secret which owns {} characters is too weak. Please replace it with a stronger one.""",
|
||||
The provided secret which owns {} characters is too weak. Please replace it with a stronger one.""",
|
||||
secret.length());
|
||||
throw new WeakSecretException("""
|
||||
The provided secret which owns %s characters is too weak. Please replace it with a stronger one."""
|
||||
@@ -256,7 +256,7 @@ public class JjwtTokenResolver implements TokenResolver<Jws<Claims>> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves the given token into a ResolvedTokenType object.
|
||||
* Resolves the given token into a {@link Jws<Claims>} object.
|
||||
*
|
||||
* @param token the token to be resolved
|
||||
* @return a ResolvedTokenType object
|
||||
@@ -287,7 +287,7 @@ public class JjwtTokenResolver implements TokenResolver<Jws<Claims>> {
|
||||
try {
|
||||
return MapUtil.mapToObject(claims, targetType);
|
||||
} catch (InvocationTargetException e) {
|
||||
log.info("An error occurs while invoking the constructor of type {}.", targetType.getCanonicalName());
|
||||
log.error("An error occurs while invoking the constructor of type {}.", targetType.getCanonicalName());
|
||||
} catch (NoSuchMethodException e) {
|
||||
log.error("The constructor of the required type {} is not found.", targetType.getCanonicalName());
|
||||
} catch (InstantiationException e) {
|
||||
|
||||
+24
-22
@@ -17,6 +17,7 @@
|
||||
|
||||
package cn.org.codecrafters.simplejwt.jjwt.config;
|
||||
|
||||
import cn.org.codecrafters.simplejwt.TokenResolver;
|
||||
import cn.org.codecrafters.simplejwt.config.TokenResolverConfig;
|
||||
import cn.org.codecrafters.simplejwt.constants.TokenAlgorithm;
|
||||
import cn.org.codecrafters.simplejwt.exceptions.UnsupportedAlgorithmException;
|
||||
@@ -27,23 +28,23 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* The JjwtTokenResolverConfig class provides the configuration for the
|
||||
* JjwtTokenResolverConfig.
|
||||
* The {@code JjwtTokenResolverConfig} class provides the configuration for the
|
||||
* {@link JjwtTokenResolver}.
|
||||
* <p>
|
||||
* This configuration class is used to establish the mapping between the
|
||||
* standard TokenAlgorithm defined within the JjwtTokenResolverConfig and
|
||||
* the specific algorithms used by the {@code io.jsonwebtoken:jjwt} library,
|
||||
* which is the underlying library used by JjwtTokenResolverConfig to handle
|
||||
* JSON Web Tokens (JWTs).
|
||||
* standard {@link TokenAlgorithm} defined within the
|
||||
* {@code JjwtTokenResolverConfig} and the specific algorithms used by the
|
||||
* {@code io.jsonwebtoken:jjwt} library, which is the underlying library used
|
||||
* by {@code JjwtTokenResolver} to handle JSON Web Tokens (JWTs).
|
||||
* <p>
|
||||
* <b>Algorithm Mapping:</b>
|
||||
* The JjwtTokenResolverConfig class allows specifying the relationship
|
||||
* between the standard TokenAlgorithm instances supported by
|
||||
* JjwtTokenResolverConfig and the corresponding algorithms used by the
|
||||
* The {@code JjwtTokenResolverConfig} allows specifying the relationship
|
||||
* between the standard {@link TokenAlgorithm} instances supported by {@link
|
||||
* JjwtTokenResolver} and the corresponding algorithms used by the
|
||||
* {@code io.jsonwebtoken:jjwt} library. The mapping is achieved using a Map,
|
||||
* where the keys are the standard TokenAlgorithm instances, and the values
|
||||
* represent the algorithm functions used by {@code io.jsonwebtoken:jjwt}
|
||||
* library for each corresponding key.
|
||||
* where the keys are the standard {@link TokenAlgorithm} instances, and the
|
||||
* values represent the algorithm functions used by
|
||||
* {@code io.jsonwebtoken:jjwt} library for each corresponding key.
|
||||
* <p>
|
||||
* <b>Note:</b>
|
||||
* The provided algorithm mapping should be consistent with the actual
|
||||
@@ -78,24 +79,25 @@ public final class JjwtTokenResolverConfig implements TokenResolverConfig<Signat
|
||||
|
||||
/**
|
||||
* Gets the algorithm function corresponding to the specified
|
||||
* TokenAlgorithm.
|
||||
* {@link TokenAlgorithm}.
|
||||
* <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.
|
||||
* {@link TokenAlgorithm}. The provided {@link TokenAlgorithm} represents
|
||||
* the specific algorithm for which the corresponding algorithm function is
|
||||
* required. The returned algorithm function represents the function
|
||||
* implementation that can be used by the {@link TokenResolver} to handle
|
||||
* the specific algorithm.
|
||||
*
|
||||
* @param algorithm the TokenAlgorithm for which the algorithm function is
|
||||
* required
|
||||
* @return the algorithm function associated with the given TokenAlgorithm
|
||||
* @param algorithm the {@link TokenAlgorithm} for which the algorithm
|
||||
* function is required
|
||||
* @return the algorithm function associated with the given {@link
|
||||
* TokenAlgorithm}
|
||||
*/
|
||||
@Override
|
||||
public SignatureAlgorithm getAlgorithm(TokenAlgorithm algorithm) {
|
||||
if (!SUPPORTED_ALGORITHMS.containsKey(algorithm)) {
|
||||
throw new UnsupportedAlgorithmException("""
|
||||
The request algorithm is not supported by our system yet. Please change to supported ones.
|
||||
""");
|
||||
The request algorithm is not supported by our system yet. Please change to supported ones.""");
|
||||
}
|
||||
return SUPPORTED_ALGORITHMS.get(algorithm);
|
||||
}
|
||||
|
||||
@@ -33,18 +33,20 @@
|
||||
* this class as the main token resolver in the Simple JWT project when
|
||||
* integrating {@code io.jsonwebtoken:jjwt-api} as the JWT management library.
|
||||
* <p>
|
||||
* The {@code JjwtTokenResolver} relies on the {@code io.jsonwebtoken:jjwt-api}
|
||||
* The {@link cn.org.codecrafters.simplejwt.jjwt.JjwtTokenResolver} relies on
|
||||
* the {@code io.jsonwebtoken:jjwt-api}
|
||||
* library to handle the underlying JWT operations, including token creation,
|
||||
* validation, and extraction. It utilizes the {@code io.jsonwebtoken:jjwt-api}
|
||||
* {@code Algorithm} class to define and use different algorithms for JWT
|
||||
* signing and verification.
|
||||
* {@link io.jsonwebtoken.SignatureAlgorithm} class to define and use different
|
||||
* algorithms for JWT signing and verification.
|
||||
* <p>
|
||||
* To use the {@code JjwtTokenResolver}, developers must provide the necessary
|
||||
* configurations and dependencies, such as the {@code GuidCreator} for
|
||||
* generating unique JWT IDs (JTI), the supported algorithm function, the
|
||||
* issuer name, and the secret key used for token signing and validation. The
|
||||
* {@code JjwtTokenResolverConfig} class provides a convenient way to configure
|
||||
* these dependencies.
|
||||
* To use the {@link cn.org.codecrafters.simplejwt.jjwt.JjwtTokenResolver},
|
||||
* developers must provide the necessary configurations and dependencies, such
|
||||
* as the {@link cn.org.codecrafters.guid.GuidCreator} for generating unique
|
||||
* JWT IDs (JTI), the supported algorithm function, the issuer name, and the
|
||||
* secret key used for token signing and validation. The
|
||||
* {@link cn.org.codecrafters.simplejwt.jjwt.config.JjwtTokenResolverConfig}
|
||||
* class provides a convenient way to configure these dependencies.
|
||||
* <p>
|
||||
* Developers using the {@code io.jsonwebtoken:jjwt-api} integration should be
|
||||
* familiar with the concepts and usage of the {@code io.jsonwebtoken:jjwt-api}
|
||||
|
||||
Reference in New Issue
Block a user