diff --git a/devkit-core/pom.xml b/devkit-core/pom.xml
index c38bc77..aa09102 100644
--- a/devkit-core/pom.xml
+++ b/devkit-core/pom.xml
@@ -23,7 +23,7 @@
cn.org.codecrafters
jdevkit
- 1.0.0
+ 1.0.1
devkit-core
diff --git a/devkit-utils/pom.xml b/devkit-utils/pom.xml
index 0433dba..348d4c8 100644
--- a/devkit-utils/pom.xml
+++ b/devkit-utils/pom.xml
@@ -6,7 +6,7 @@
cn.org.codecrafters
jdevkit
- 1.0.0
+ 1.0.1
devkit-utils
diff --git a/guid/pom.xml b/guid/pom.xml
index 1a36d42..314a524 100644
--- a/guid/pom.xml
+++ b/guid/pom.xml
@@ -23,7 +23,7 @@
cn.org.codecrafters
jdevkit
- 1.0.0
+ 1.0.1
guid
diff --git a/pom.xml b/pom.xml
index 744acd2..49b6f1b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -29,7 +29,7 @@
cn.org.codecrafters
jdevkit
- 1.0.0
+ 1.0.1
2023
pom
diff --git a/simple-jwt-authzero/pom.xml b/simple-jwt-authzero/pom.xml
index def81d6..d2b32ac 100644
--- a/simple-jwt-authzero/pom.xml
+++ b/simple-jwt-authzero/pom.xml
@@ -23,7 +23,7 @@
cn.org.codecrafters
jdevkit
- 1.0.0
+ 1.0.1
simple-jwt-authzero
diff --git a/simple-jwt-facade/pom.xml b/simple-jwt-facade/pom.xml
index 7deb2b0..b1130f4 100644
--- a/simple-jwt-facade/pom.xml
+++ b/simple-jwt-facade/pom.xml
@@ -23,7 +23,7 @@
cn.org.codecrafters
jdevkit
- 1.0.0
+ 1.0.1
simple-jwt-facade
diff --git a/simple-jwt-jjwt/pom.xml b/simple-jwt-jjwt/pom.xml
index 85c66e5..eaf8804 100644
--- a/simple-jwt-jjwt/pom.xml
+++ b/simple-jwt-jjwt/pom.xml
@@ -23,7 +23,7 @@
cn.org.codecrafters
jdevkit
- 1.0.0
+ 1.0.1
simple-jwt-jjwt
diff --git a/simple-jwt-spring-boot-starter/pom.xml b/simple-jwt-spring-boot-starter/pom.xml
index 95cd204..0a5575b 100644
--- a/simple-jwt-spring-boot-starter/pom.xml
+++ b/simple-jwt-spring-boot-starter/pom.xml
@@ -23,7 +23,7 @@
cn.org.codecrafters
jdevkit
- 1.0.0
+ 1.0.1
simple-jwt-spring-boot-starter
diff --git a/simple-jwt-spring-boot-starter/src/main/java/cn/org/codecrafters/simplejwt/autoconfiguration/AuthzeroTokenResolverAutoConfiguration.java b/simple-jwt-spring-boot-starter/src/main/java/cn/org/codecrafters/simplejwt/autoconfiguration/AuthzeroTokenResolverAutoConfiguration.java
index f08ef03..4a1907b 100644
--- a/simple-jwt-spring-boot-starter/src/main/java/cn/org/codecrafters/simplejwt/autoconfiguration/AuthzeroTokenResolverAutoConfiguration.java
+++ b/simple-jwt-spring-boot-starter/src/main/java/cn/org/codecrafters/simplejwt/autoconfiguration/AuthzeroTokenResolverAutoConfiguration.java
@@ -25,11 +25,13 @@ import com.auth0.jwt.interfaces.DecodedJWT;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfiguration;
+import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.DependsOn;
/**
*
@@ -61,6 +63,8 @@ import org.springframework.context.annotation.Bean;
@EnableConfigurationProperties(value = {SimpleJwtProperties.class})
@ConditionalOnClass({DecodedJWT.class, AuthzeroTokenResolver.class})
@ConditionalOnMissingBean({TokenResolver.class})
+@ConditionalOnBean(value = {GuidCreator.class}, name = "jtiCreator")
+@AutoConfigureAfter(value = GuidAutoConfiguration.class)
public class AuthzeroTokenResolverAutoConfiguration {
/**
@@ -96,7 +100,6 @@ public class AuthzeroTokenResolverAutoConfiguration {
* @return the {@link TokenResolver} instance
*/
@Bean
- @ConditionalOnBean(value = {GuidCreator.class}, name = "jtiCreator")
public TokenResolver tokenResolver() {
return new AuthzeroTokenResolver(
jtiCreator,
diff --git a/simple-jwt-spring-boot-starter/src/main/java/cn/org/codecrafters/simplejwt/autoconfiguration/GuidAutoConfiguration.java b/simple-jwt-spring-boot-starter/src/main/java/cn/org/codecrafters/simplejwt/autoconfiguration/GuidAutoConfiguration.java
index ffad4fb..77287e4 100644
--- a/simple-jwt-spring-boot-starter/src/main/java/cn/org/codecrafters/simplejwt/autoconfiguration/GuidAutoConfiguration.java
+++ b/simple-jwt-spring-boot-starter/src/main/java/cn/org/codecrafters/simplejwt/autoconfiguration/GuidAutoConfiguration.java
@@ -18,10 +18,13 @@
package cn.org.codecrafters.simplejwt.autoconfiguration;
import cn.org.codecrafters.guid.GuidCreator;
+import cn.org.codecrafters.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;
import java.util.UUID;
@@ -32,10 +35,10 @@ import java.util.UUID;
*/
@Slf4j
@AutoConfiguration
-@ConditionalOnMissingBean(value = GuidCreator.class, name = "jtiCreator")
public class GuidAutoConfiguration {
@Bean
+ @Conditional(GuidCreatorCondition.class)
public GuidCreator> jtiCreator() {
return UUID::randomUUID;
}
diff --git a/simple-jwt-spring-boot-starter/src/main/java/cn/org/codecrafters/simplejwt/autoconfiguration/JjwtTokenResolverAutoConfiguration.java b/simple-jwt-spring-boot-starter/src/main/java/cn/org/codecrafters/simplejwt/autoconfiguration/JjwtTokenResolverAutoConfiguration.java
index f0fbd12..29d5b09 100644
--- a/simple-jwt-spring-boot-starter/src/main/java/cn/org/codecrafters/simplejwt/autoconfiguration/JjwtTokenResolverAutoConfiguration.java
+++ b/simple-jwt-spring-boot-starter/src/main/java/cn/org/codecrafters/simplejwt/autoconfiguration/JjwtTokenResolverAutoConfiguration.java
@@ -19,7 +19,6 @@ package cn.org.codecrafters.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 cn.org.codecrafters.simplejwt.jjwt.JjwtTokenResolver;
import io.jsonwebtoken.Claims;
@@ -27,6 +26,7 @@ import io.jsonwebtoken.Jws;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfiguration;
+import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
@@ -63,6 +63,8 @@ import org.springframework.context.annotation.Bean;
@EnableConfigurationProperties(value = {SimpleJwtProperties.class})
@ConditionalOnClass({Jws.class, Claims.class, JjwtTokenResolver.class})
@ConditionalOnMissingBean({TokenResolver.class})
+@ConditionalOnBean(value = {GuidCreator.class}, name = "jtiCreator")
+@AutoConfigureAfter(value = GuidAutoConfiguration.class)
public class JjwtTokenResolverAutoConfiguration {
/**
@@ -98,7 +100,6 @@ public class JjwtTokenResolverAutoConfiguration {
* @return the {@link TokenResolver} instance
*/
@Bean
- @ConditionalOnBean(value = {GuidCreator.class}, name = "jtiCreator")
public TokenResolver> tokenResolver() {
return new JjwtTokenResolver(
jtiCreator,
diff --git a/simple-jwt-spring-boot-starter/src/main/java/cn/org/codecrafters/simplejwt/autoconfiguration/conditions/GuidCreatorCondition.java b/simple-jwt-spring-boot-starter/src/main/java/cn/org/codecrafters/simplejwt/autoconfiguration/conditions/GuidCreatorCondition.java
new file mode 100644
index 0000000..b83e2fa
--- /dev/null
+++ b/simple-jwt-spring-boot-starter/src/main/java/cn/org/codecrafters/simplejwt/autoconfiguration/conditions/GuidCreatorCondition.java
@@ -0,0 +1,29 @@
+package cn.org.codecrafters.simplejwt.autoconfiguration.conditions;
+
+import cn.org.codecrafters.guid.GuidCreator;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.context.annotation.Condition;
+import org.springframework.context.annotation.ConditionContext;
+import org.springframework.core.type.AnnotatedTypeMetadata;
+
+import java.util.Objects;
+
+/**
+ * GuidCreatorCondition
+ *
+ * Created on 28 Aug 2023
+ *
+ * @author Zihlu Wang
+ */
+@Slf4j
+public class GuidCreatorCondition implements Condition {
+ @Override
+ public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
+ final var beanFactory = Objects.requireNonNull(context.getBeanFactory());
+ var isContainJtiCreator = beanFactory.containsBean("jtiCreator");
+ if (isContainJtiCreator) {
+ return !(beanFactory.getBean("jtiCreator") instanceof GuidCreator>);
+ }
+ return true;
+ }
+}
diff --git a/webcal/pom.xml b/webcal/pom.xml
index a11b1ff..8e77cae 100644
--- a/webcal/pom.xml
+++ b/webcal/pom.xml
@@ -23,7 +23,7 @@
cn.org.codecrafters
jdevkit
- 1.0.0
+ 1.0.1
webcal