docs: added JavaDoc

This commit is contained in:
zihluwang
2024-06-30 13:10:38 +08:00
parent da23cf1a83
commit 23e9cc8109
15 changed files with 216 additions and 238 deletions
@@ -69,8 +69,9 @@ public class AuthzeroTokenResolverAutoConfiguration {
* Constructs a new {@code SimpleJwtAutoConfiguration} instance with the
* provided SimpleJwtProperties.
*
* @param simpleJwtProperties the SimpleJwtProperties instance
* @param objectMapper Jackson JSON Handler
* @param simpleJwtProperties a {@link SimpleJwtProperties} instance
* @param jtiCreator a creator to create ids for JSON Web Token
* @param objectMapper jackson JSON Handler
*/
@Autowired
public AuthzeroTokenResolverAutoConfiguration(SimpleJwtProperties simpleJwtProperties, @Qualifier("jtiCreator") GuidCreator<?> jtiCreator, ObjectMapper objectMapper) {
@@ -80,11 +81,10 @@ public class AuthzeroTokenResolverAutoConfiguration {
}
/**
* Creates a new {@link TokenResolver} bean using {@link
* AuthzeroTokenResolver} if no existing {@link TokenResolver} bean is
* found. The {@link AuthzeroTokenResolver} is configured with the
* provided {@link GuidCreator}, {@code algorithm}, {@code issuer}, and
* {@code secret} properties from {@link SimpleJwtProperties}.
* Creates a new {@link TokenResolver} bean using {@link AuthzeroTokenResolver} if no existing
* {@link TokenResolver} bean is found. The {@link AuthzeroTokenResolver} is configured with the
* provided {@link GuidCreator}, {@code algorithm}, {@code issuer}, and {@code secret}
* properties from {@link SimpleJwtProperties}.
*
* @return the {@link TokenResolver} instance
*/
@@ -99,15 +99,8 @@ public class AuthzeroTokenResolverAutoConfiguration {
);
}
/**
* The GuidCreator instance to be used for generating JWT IDs (JTI).
*/
private final GuidCreator<?> jtiCreator;
/**
* The {@code SimpleJwtProperties} instance containing the configuration
* properties for Simple JWT.
*/
private final SimpleJwtProperties simpleJwtProperties;
private final ObjectMapper objectMapper;
@@ -37,6 +37,12 @@ import java.util.UUID;
@AutoConfiguration
public class GuidAutoConfiguration {
/**
* Default constructor.
*/
public GuidAutoConfiguration() {
}
/**
* Create a default {@code jtiCreator} with UUID.
*
@@ -66,9 +66,10 @@ import org.springframework.context.annotation.Bean;
public class JjwtTokenResolverAutoConfiguration {
/**
* Constructs a new {@code SimpleJwtAutoConfiguration} instance with the
* provided SimpleJwtProperties.
* Constructs a new {@code SimpleJwtAutoConfiguration} instance with the provided
* {@link SimpleJwtProperties}.
*
* @param jtiCreator a creator to create JSON Web Token ids
* @param simpleJwtProperties the SimpleJwtProperties instance
*/
@Autowired
@@ -78,11 +79,10 @@ public class JjwtTokenResolverAutoConfiguration {
}
/**
* Creates a new {@link TokenResolver} bean using {@link
* JjwtTokenResolver} if no existing {@link TokenResolver} bean is
* found. The {@link JjwtTokenResolver} is configured with the
* provided {@link GuidCreator}, {@code algorithm}, {@code issuer}, and
* {@code secret} properties from {@link SimpleJwtProperties}.
* Creates a new {@link TokenResolver} bean using {@link JjwtTokenResolver} if no existing
* {@link TokenResolver} bean is found. The {@link JjwtTokenResolver} is configured with the
* provided {@link GuidCreator}, {@code algorithm}, {@code issuer}, and {@code secret}
* properties from {@link SimpleJwtProperties}.
*
* @return the {@link TokenResolver} instance
*/
@@ -102,8 +102,8 @@ public class JjwtTokenResolverAutoConfiguration {
private final GuidCreator<?> jtiCreator;
/**
* The {@code SimpleJwtProperties} instance containing the configuration
* properties for Simple JWT.
* The {@code SimpleJwtProperties} instance containing the configuration properties
* for Simple JWT.
*/
private final SimpleJwtProperties simpleJwtProperties;
@@ -35,16 +35,22 @@ import java.util.Objects;
@Slf4j
public class GuidCreatorCondition implements Condition {
/**
* Default constructor.
*/
public GuidCreatorCondition() {
}
/**
* The condition to create bean {@code jtiCreator}.
* <p>
* If Spring does not have a bean of type
* {@link GuidCreator} named {@code jtiCreator}
* in the application context, then create {@code jtiCreator}.
* If Spring does not have a bean of type {@link GuidCreator} named {@code jtiCreator} in the
* application context, then create {@code jtiCreator}.
*
* @param context the spring application context
* @param metadata the metadata of the {@link org.springframework.core.type.AnnotationMetadata class}
* or {@link org.springframework.core.type.MethodMetadata method} being checked
* @param metadata the metadata of the {@link org.springframework.core.type.AnnotationMetadata
* class} or {@link org.springframework.core.type.MethodMetadata method}
* being checked
*/
@Override
public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
@@ -25,21 +25,20 @@ import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
/**
* {@code SimpleJwtProperties} is a configuration properties class used to
* store the properties related to Simple JWT library configurations. These
* properties can be configured in the application's properties file (e.g.,
* application.properties) with the prefix "code-crafters.simple-jwt".
* {@code SimpleJwtProperties} is a configuration properties class used to store the properties
* related to Simple JWT library configurations. These properties can be configured in the
* application's properties file (e.g., application.properties) with the prefix
* "onixbyte.simple-jwt".
* <p>
* {@code SimpleJwtProperties} provides configuration options for the JWT
* algorithm, issuer, and secret. The properties are used by the {@link
* AuthzeroTokenResolverAutoConfiguration} and {@link
* JjwtTokenResolver} to set up the
* necessary configurations for JWT generation and validation.
* {@code SimpleJwtProperties} provides configuration options for the JWT algorithm, issuer,
* and secret. The properties are used by the {@link AuthzeroTokenResolverAutoConfiguration} and
* {@link JjwtTokenResolver} to set up the necessary configurations for JWT generation
* and validation.
* <p>
* Developers can customise the JWT algorithm, issuer, and secret by setting
* the corresponding properties in the application's properties file. The
* {@code SimpleJwtAutoConfiguration} class reads these properties and uses
* them to create the TokenResolver bean with the desired configuration.
* Developers can customise the JWT algorithm, issuer, and secret by setting the corresponding
* properties in the application's properties file. The {@code SimpleJwtAutoConfiguration} class
* reads these properties and uses them to create the TokenResolver bean with the
* desired configuration.
*
* @author Zihlu Wang
* @version 1.1.0
@@ -49,6 +48,12 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
@ConfigurationProperties(prefix = "onixbyte.simple-jwt")
public class SimpleJwtProperties {
/**
* Default constructor.
*/
public SimpleJwtProperties() {
}
/**
* The algorithm used for JWT generation and validation. Default value is
* {@link TokenAlgorithm#HS256}
@@ -56,15 +61,13 @@ public class SimpleJwtProperties {
private TokenAlgorithm algorithm = TokenAlgorithm.HS256;
/**
* The issuer value to be included in the generated JWT. Default value is
* an empty String.
* The issuer value to be included in the generated JWT. Default value is an empty String.
*/
private String issuer = "";
/**
* The secret key used for JWT generation and validation. Default value is
* the result of call to {@link
* SecretCreator#createSecret(int, boolean, boolean, boolean)}.
* The secret key used for JWT generation and validation. Default value is the result of call to
* {@link SecretCreator#createSecret(int, boolean, boolean, boolean)}.
*/
private String secret = SecretCreator.createSecret(32, true, true, true);