From 3cf055eaa398128ab9d484def295af864a8fd6c8 Mon Sep 17 00:00:00 2001 From: "jihuan.yin@ipiaoniu.com" Date: Mon, 15 Jun 2020 19:23:53 +0800 Subject: [PATCH 1/6] bugfix contextpath endwiths / --- .../cxytiandi/encrypt/springboot/init/ApiEncryptDataInit.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/monkey-api-encrypt-core/src/main/java/com/cxytiandi/encrypt/springboot/init/ApiEncryptDataInit.java b/monkey-api-encrypt-core/src/main/java/com/cxytiandi/encrypt/springboot/init/ApiEncryptDataInit.java index 9699e67..4846083 100644 --- a/monkey-api-encrypt-core/src/main/java/com/cxytiandi/encrypt/springboot/init/ApiEncryptDataInit.java +++ b/monkey-api-encrypt-core/src/main/java/com/cxytiandi/encrypt/springboot/init/ApiEncryptDataInit.java @@ -191,6 +191,9 @@ private String getApiUri(Class clz, Method method) { } if (StringUtils.hasText(this.contextPath) && !"/".equals(this.contextPath)) { + if (this.contextPath.endsWith("/")) { + this.contextPath = this.contextPath.substring(0, this.contextPath.length() - 1); + } return methodType + this.contextPath + uri.toString(); } From 898ac63695997237a17859f0b17296063466b636 Mon Sep 17 00:00:00 2001 From: "jihuan.yin@ipiaoniu.com" Date: Mon, 15 Jun 2020 19:30:04 +0800 Subject: [PATCH 2/6] bugfix issues 59 --- .../encrypt/springboot/init/ApiEncryptDataInit.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/monkey-api-encrypt-core/src/main/java/com/cxytiandi/encrypt/springboot/init/ApiEncryptDataInit.java b/monkey-api-encrypt-core/src/main/java/com/cxytiandi/encrypt/springboot/init/ApiEncryptDataInit.java index 4846083..5d8f613 100644 --- a/monkey-api-encrypt-core/src/main/java/com/cxytiandi/encrypt/springboot/init/ApiEncryptDataInit.java +++ b/monkey-api-encrypt-core/src/main/java/com/cxytiandi/encrypt/springboot/init/ApiEncryptDataInit.java @@ -184,8 +184,12 @@ private String getApiUri(Class clz, Method method) { uri.append(formatUri(deleteMapping.value()[0])); } else if (requestMapping != null) { - RequestMethod m = requestMapping.method()[0]; - methodType = m.name().toLowerCase() + ":"; + RequestMethod requestMethod = RequestMethod.GET; + if (requestMapping.method().length > 0) { + requestMethod = requestMapping.method()[0]; + } + + methodType = requestMethod.name().toLowerCase() + ":"; uri.append(formatUri(requestMapping.value()[0])); } From 203ec9630fa2afd4be3b27f940511b81caeeb33b Mon Sep 17 00:00:00 2001 From: "jihuan.yin@ipiaoniu.com" Date: Mon, 15 Jun 2020 20:00:27 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E5=B0=86=E6=B3=A8=E8=A7=A3=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E7=9A=84=E6=8E=A5=E5=8F=A3=E5=92=8C=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E9=85=8D=E7=BD=AE=E7=9A=84=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=20=E5=90=88=E5=B9=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../encrypt/core/EncryptionConfig.java | 29 ++++++------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/monkey-api-encrypt-core/src/main/java/com/cxytiandi/encrypt/core/EncryptionConfig.java b/monkey-api-encrypt-core/src/main/java/com/cxytiandi/encrypt/core/EncryptionConfig.java index 9d5ac81..5fa6b28 100644 --- a/monkey-api-encrypt-core/src/main/java/com/cxytiandi/encrypt/core/EncryptionConfig.java +++ b/monkey-api-encrypt-core/src/main/java/com/cxytiandi/encrypt/core/EncryptionConfig.java @@ -1,7 +1,10 @@ package com.cxytiandi.encrypt.core; import java.util.ArrayList; +import java.util.Collection; import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; import org.springframework.boot.context.properties.ConfigurationProperties; @@ -93,11 +96,7 @@ public void setKey(String key) { } public List getResponseEncryptUriList() { - // 配置了注解则用注解获取的URI - if (ApiEncryptDataInit.responseEncryptUriList.size() > 0) { - return ApiEncryptDataInit.responseEncryptUriList; - } - return responseEncryptUriList; + return Stream.of(responseEncryptUriList, ApiEncryptDataInit.responseEncryptUriList).flatMap(Collection::stream).collect(Collectors.toList()); } public void setResponseEncryptUriList(List responseEncryptUriList) { @@ -105,11 +104,7 @@ public void setResponseEncryptUriList(List responseEncryptUriList) { } public List getRequestDecryptUriList() { - // 配置了注解则用注解获取的URI - if (ApiEncryptDataInit.requestDecryptUriList.size() > 0) { - return ApiEncryptDataInit.requestDecryptUriList; - } - return requestDecryptUriList; + return Stream.of(requestDecryptUriList, ApiEncryptDataInit.requestDecryptUriList).flatMap(Collection::stream).collect(Collectors.toList()); } public void setRequestDecryptUriList(List requestDecryptUriList) { @@ -149,11 +144,8 @@ public int getOrder() { } public List getResponseEncryptUriIgnoreList() { - // 配置了注解则用注解获取的URI - if (ApiEncryptDataInit.responseEncryptUriIgnoreList.size() > 0) { - return ApiEncryptDataInit.responseEncryptUriIgnoreList; - } - return responseEncryptUriIgnoreList; + // 配置和注解两种方式合并 + return Stream.of(responseEncryptUriIgnoreList, ApiEncryptDataInit.responseEncryptUriIgnoreList).flatMap(Collection::stream).collect(Collectors.toList()); } public void setResponseEncryptUriIgnoreList(List responseEncryptUriIgnoreList) { @@ -161,11 +153,8 @@ public void setResponseEncryptUriIgnoreList(List responseEncryptUriIgnor } public List getRequestDecryptUriIgnoreList() { - // 配置了注解则用注解获取的URI - if (ApiEncryptDataInit.requestDecryptUriIgnoreList.size() > 0) { - return ApiEncryptDataInit.requestDecryptUriIgnoreList; - } - return requestDecryptUriIgnoreList; + // 配置和注解两种方式合并 + return Stream.of(requestDecryptUriIgnoreList, ApiEncryptDataInit.requestDecryptUriIgnoreList).flatMap(Collection::stream).collect(Collectors.toList()); } public void setRequestDecryptUriIgnoreList(List requestDecyptUriIgnoreList) { From 33f0d495d5933bb17bcde29d1c8a712424e8d649 Mon Sep 17 00:00:00 2001 From: "jihuan.yin@ipiaoniu.com" Date: Mon, 15 Jun 2020 20:20:32 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E5=8A=A0=E8=A7=A3=E5=AF=86=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E4=BF=A1=E6=81=AF=E7=AB=AF=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- monkey-api-encrypt-core/pom.xml | 6 ++++ .../EncryptAutoConfiguration.java | 6 ++++ .../springboot/endpoint/EncryptEndpoint.java | 32 +++++++++++++++++++ monkey-api-encrypt-springboot-example/pom.xml | 4 +++ .../src/main/resources/application.properties | 2 ++ 5 files changed, 50 insertions(+) create mode 100644 monkey-api-encrypt-core/src/main/java/com/cxytiandi/encrypt/springboot/endpoint/EncryptEndpoint.java diff --git a/monkey-api-encrypt-core/pom.xml b/monkey-api-encrypt-core/pom.xml index 75e1f0d..9fb4d88 100644 --- a/monkey-api-encrypt-core/pom.xml +++ b/monkey-api-encrypt-core/pom.xml @@ -103,6 +103,12 @@ 2.0.6.RELEASE provided + + org.springframework.boot + spring-boot-actuator + 2.0.6.RELEASE + provided + diff --git a/monkey-api-encrypt-core/src/main/java/com/cxytiandi/encrypt/springboot/autoconfigure/EncryptAutoConfiguration.java b/monkey-api-encrypt-core/src/main/java/com/cxytiandi/encrypt/springboot/autoconfigure/EncryptAutoConfiguration.java index 40c0eba..156a378 100644 --- a/monkey-api-encrypt-core/src/main/java/com/cxytiandi/encrypt/springboot/autoconfigure/EncryptAutoConfiguration.java +++ b/monkey-api-encrypt-core/src/main/java/com/cxytiandi/encrypt/springboot/autoconfigure/EncryptAutoConfiguration.java @@ -1,5 +1,6 @@ package com.cxytiandi.encrypt.springboot.autoconfigure; +import com.cxytiandi.encrypt.springboot.endpoint.EncryptEndpoint; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.context.properties.EnableConfigurationProperties; @@ -53,4 +54,9 @@ public FilterRegistrationBean filterRegistration() { public ApiEncryptDataInit apiEncryptDataInit() { return new ApiEncryptDataInit(); } + + @Bean + public EncryptEndpoint encryptEndpoint() { + return new EncryptEndpoint(); + } } diff --git a/monkey-api-encrypt-core/src/main/java/com/cxytiandi/encrypt/springboot/endpoint/EncryptEndpoint.java b/monkey-api-encrypt-core/src/main/java/com/cxytiandi/encrypt/springboot/endpoint/EncryptEndpoint.java new file mode 100644 index 0000000..73f34b1 --- /dev/null +++ b/monkey-api-encrypt-core/src/main/java/com/cxytiandi/encrypt/springboot/endpoint/EncryptEndpoint.java @@ -0,0 +1,32 @@ +package com.cxytiandi.encrypt.springboot.endpoint; + +import com.cxytiandi.encrypt.core.EncryptionConfig; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.actuate.endpoint.annotation.Endpoint; +import org.springframework.boot.actuate.endpoint.annotation.ReadOperation; + +import java.util.HashMap; +import java.util.Map; + +/** + * 加解密配置信息端点 + * + * @author yinjihuan http://cxytiandi.com/about + */ +@Endpoint(id = "encrypt-config") +public class EncryptEndpoint { + + @Autowired + private EncryptionConfig encryptionConfig; + + @ReadOperation + public Map encryptConfig() { + Map data = new HashMap<>(); + data.put("responseEncryptUriList", encryptionConfig.getResponseEncryptUriList()); + data.put("responseEncryptUriIgnoreList", encryptionConfig.getResponseEncryptUriIgnoreList()); + data.put("requestDecryptUriList", encryptionConfig.getRequestDecryptUriList()); + data.put("requestDecryptUriIgnoreList", encryptionConfig.getRequestDecryptUriIgnoreList()); + return data; + } + +} diff --git a/monkey-api-encrypt-springboot-example/pom.xml b/monkey-api-encrypt-springboot-example/pom.xml index f46e673..22f29c6 100644 --- a/monkey-api-encrypt-springboot-example/pom.xml +++ b/monkey-api-encrypt-springboot-example/pom.xml @@ -44,6 +44,10 @@ org.springframework.boot spring-boot-starter-aop + + org.springframework.boot + spring-boot-starter-actuator + diff --git a/monkey-api-encrypt-springboot-example/src/main/resources/application.properties b/monkey-api-encrypt-springboot-example/src/main/resources/application.properties index 6b32d05..ad8b206 100755 --- a/monkey-api-encrypt-springboot-example/src/main/resources/application.properties +++ b/monkey-api-encrypt-springboot-example/src/main/resources/application.properties @@ -2,6 +2,8 @@ server.port=8011 #server.servlet.context-path=/example #logging.level.com.cxytiandi.encrypt=DEBUG +management.endpoints.web.exposure.include=* + spring.freemarker.cache=true spring.freemarker.charset=UTF-8 spring.freemarker.check-template-location=true From 68684051c38ee4a1c451224eb48e0d122f3b968c Mon Sep 17 00:00:00 2001 From: "jihuan.yin@ipiaoniu.com" Date: Tue, 16 Jun 2020 19:40:35 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E5=8D=87=E7=BA=A7=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- monkey-api-encrypt-core/pom.xml | 2 +- monkey-api-encrypt-springboot-example/pom.xml | 2 +- monkey-api-encrypt-springmvc-example/pom.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/monkey-api-encrypt-core/pom.xml b/monkey-api-encrypt-core/pom.xml index 9fb4d88..171b458 100644 --- a/monkey-api-encrypt-core/pom.xml +++ b/monkey-api-encrypt-core/pom.xml @@ -5,7 +5,7 @@ com.cxytiandi monkey-api-encrypt-core - 1.2.RELEASE + 1.2.1.RELEASE jar monkey-api-encrypt-core diff --git a/monkey-api-encrypt-springboot-example/pom.xml b/monkey-api-encrypt-springboot-example/pom.xml index 22f29c6..132aafd 100644 --- a/monkey-api-encrypt-springboot-example/pom.xml +++ b/monkey-api-encrypt-springboot-example/pom.xml @@ -34,7 +34,7 @@ com.cxytiandi monkey-api-encrypt-core - 1.2.RELEASE + 1.2.1.RELEASE org.springframework.boot diff --git a/monkey-api-encrypt-springmvc-example/pom.xml b/monkey-api-encrypt-springmvc-example/pom.xml index 1141b23..48ee6e5 100644 --- a/monkey-api-encrypt-springmvc-example/pom.xml +++ b/monkey-api-encrypt-springmvc-example/pom.xml @@ -51,7 +51,7 @@ com.cxytiandi monkey-api-encrypt-core - 1.2.RELEASE + 1.2.1.RELEASE junit From 7ea03cf885f851155925edebe4770cbf7c3c5c7e Mon Sep 17 00:00:00 2001 From: "jihuan.yin@ipiaoniu.com" Date: Wed, 17 Jun 2020 12:43:42 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E5=A2=9E=E5=8A=A0javadoc=E6=8F=92=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- monkey-api-encrypt-core/pom.xml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/monkey-api-encrypt-core/pom.xml b/monkey-api-encrypt-core/pom.xml index 171b458..b62747b 100644 --- a/monkey-api-encrypt-core/pom.xml +++ b/monkey-api-encrypt-core/pom.xml @@ -166,6 +166,26 @@ + + + org.apache.maven.plugins + maven-javadoc-plugin + 3.0.0 + + false + none + + + + attach-javadocs + + jar + + package + + + +