You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shenyu.apache.org by xi...@apache.org on 2022/12/16 01:44:43 UTC
[shenyu] branch master updated: [bugfix]fix #4253 issue in Cryptor-Request Plugin (#4267)
This is an automated email from the ASF dual-hosted git repository.
xiaoyu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shenyu.git
The following commit(s) were added to refs/heads/master by this push:
new 459d7af4c [bugfix]fix #4253 issue in Cryptor-Request Plugin (#4267)
459d7af4c is described below
commit 459d7af4c986c151b4107f23e0204c2edf310fda
Author: 愿凌飞 <ti...@foxmail.com>
AuthorDate: Fri Dec 16 09:44:36 2022 +0800
[bugfix]fix #4253 issue in Cryptor-Request Plugin (#4267)
Co-authored-by: xiaoyu <xi...@apache.org>
---
.../plugin/api/exception/ResponsiveException.java | 55 +++++++++++++++++++
.../plugin/api/utils/WebFluxResultUtils.java | 45 ++++++++++++----
.../cryptor/decorator/CryptorRequestDecorator.java | 56 --------------------
.../decorator/CryptorResponseDecorator.java | 2 +-
.../cryptor/request/CryptorRequestPlugin.java | 61 +++++++++-------------
.../shenyu/plugin/cryptor/utils/CryptorUtil.java | 17 +++---
.../org/apache/shenyu/plugin/sign/SignPlugin.java | 21 +++-----
.../plugin/sign/exception/SignPluginException.java | 35 -------------
8 files changed, 134 insertions(+), 158 deletions(-)
diff --git a/shenyu-plugin/shenyu-plugin-api/src/main/java/org/apache/shenyu/plugin/api/exception/ResponsiveException.java b/shenyu-plugin/shenyu-plugin-api/src/main/java/org/apache/shenyu/plugin/api/exception/ResponsiveException.java
new file mode 100644
index 000000000..ccb0da4f3
--- /dev/null
+++ b/shenyu-plugin/shenyu-plugin-api/src/main/java/org/apache/shenyu/plugin/api/exception/ResponsiveException.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
+package org.apache.shenyu.plugin.api.exception;
+
+import org.apache.shenyu.common.exception.ShenyuException;
+import org.apache.shenyu.plugin.api.result.ShenyuResultEnum;
+import org.springframework.web.server.ServerWebExchange;
+
+public class ResponsiveException extends ShenyuException {
+
+ private final int code;
+
+ private final ServerWebExchange webExchange;
+
+ public ResponsiveException(final int code, final String message, final ServerWebExchange webExchange) {
+ super(message);
+ this.code = code;
+ this.webExchange = webExchange;
+ }
+
+ public ResponsiveException(final ShenyuResultEnum shenyuResult, final ServerWebExchange webExchange) {
+ super(shenyuResult.getMsg());
+ this.code = shenyuResult.getCode();
+ this.webExchange = webExchange;
+ }
+
+ /** Gets code.
+ * @return code
+ */
+ public int getCode() {
+ return code;
+ }
+
+ /** Gets serverWebExchange.
+ * @return serverWebExchange
+ */
+ public ServerWebExchange getWebExchange() {
+ return webExchange;
+ }
+}
diff --git a/shenyu-plugin/shenyu-plugin-api/src/main/java/org/apache/shenyu/plugin/api/utils/WebFluxResultUtils.java b/shenyu-plugin/shenyu-plugin-api/src/main/java/org/apache/shenyu/plugin/api/utils/WebFluxResultUtils.java
index 158cee585..e9dad726f 100644
--- a/shenyu-plugin/shenyu-plugin-api/src/main/java/org/apache/shenyu/plugin/api/utils/WebFluxResultUtils.java
+++ b/shenyu-plugin/shenyu-plugin-api/src/main/java/org/apache/shenyu/plugin/api/utils/WebFluxResultUtils.java
@@ -18,6 +18,7 @@
package org.apache.shenyu.plugin.api.utils;
import org.apache.shenyu.common.utils.ObjectTypeUtils;
+import org.apache.shenyu.plugin.api.exception.ResponsiveException;
import org.apache.shenyu.plugin.api.result.ShenyuResult;
import org.apache.shenyu.plugin.api.result.ShenyuResultEnum;
import org.apache.shenyu.plugin.api.result.ShenyuResultWrap;
@@ -34,20 +35,20 @@ import java.util.Objects;
* The type Shenyu result utils.
*/
public final class WebFluxResultUtils {
-
+
/**
* result utils log.
*/
private static final Logger LOG = LoggerFactory.getLogger(WebFluxResultUtils.class);
-
+
private WebFluxResultUtils() {
}
-
+
/**
* Response result.
*
* @param exchange the exchange
- * @param result the result
+ * @param result the result
* @return the result
*/
public static Mono<Void> result(final ServerWebExchange exchange, final Object result) {
@@ -65,12 +66,12 @@ public final class WebFluxResultUtils {
final Object responseData = shenyuResult.result(exchange, resultData);
assert null != responseData;
final byte[] bytes = (responseData instanceof byte[])
- ? (byte[]) responseData : responseData.toString().getBytes(StandardCharsets.UTF_8);
+ ? (byte[]) responseData : responseData.toString().getBytes(StandardCharsets.UTF_8);
return exchange.getResponse().writeWith(Mono.just(exchange.getResponse()
- .bufferFactory().wrap(bytes))
- .doOnNext(data -> exchange.getResponse().getHeaders().setContentLength(data.readableByteCount())));
+ .bufferFactory().wrap(bytes))
+ .doOnNext(data -> exchange.getResponse().getHeaders().setContentLength(data.readableByteCount())));
}
-
+
/**
* get no selector result.
*
@@ -83,7 +84,7 @@ public final class WebFluxResultUtils {
Object error = ShenyuResultWrap.error(exchange, ShenyuResultEnum.SELECTOR_NOT_FOUND.getCode(), pluginName + ":" + ShenyuResultEnum.SELECTOR_NOT_FOUND.getMsg(), null);
return WebFluxResultUtils.result(exchange, error);
}
-
+
/**
* get no rule result.
*
@@ -96,4 +97,30 @@ public final class WebFluxResultUtils {
Object error = ShenyuResultWrap.error(exchange, ShenyuResultEnum.RULE_NOT_FOUND.getCode(), pluginName + ":" + ShenyuResultEnum.RULE_NOT_FOUND.getMsg(), null);
return WebFluxResultUtils.result(exchange, error);
}
+
+ /**
+ * get failed result.
+ *
+ * @param responsiveException responsiveException
+ * @return the mono.
+ */
+ public static Mono<Void> failedResult(final ResponsiveException responsiveException) {
+ return failedResult(responsiveException.getCode(),
+ responsiveException.getMessage(),
+ responsiveException.getWebExchange());
+ }
+
+ /**
+ * get failed result.
+ *
+ * @param code code
+ * @param reason reason
+ * @param exchange exchange
+ * @return the mono.
+ */
+ public static Mono<Void> failedResult(final int code, final String reason, final ServerWebExchange exchange) {
+ Object error = ShenyuResultWrap.error(exchange, code, reason, null);
+ return WebFluxResultUtils.result(exchange, error);
+ }
+
}
diff --git a/shenyu-plugin/shenyu-plugin-cryptor/src/main/java/org/apache/shenyu/plugin/cryptor/decorator/CryptorRequestDecorator.java b/shenyu-plugin/shenyu-plugin-cryptor/src/main/java/org/apache/shenyu/plugin/cryptor/decorator/CryptorRequestDecorator.java
deleted file mode 100644
index 53c1aa184..000000000
--- a/shenyu-plugin/shenyu-plugin-cryptor/src/main/java/org/apache/shenyu/plugin/cryptor/decorator/CryptorRequestDecorator.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-package org.apache.shenyu.plugin.cryptor.decorator;
-
-import org.apache.shenyu.plugin.base.support.CachedBodyOutputMessage;
-import org.apache.shenyu.plugin.base.utils.ResponseUtils;
-import org.springframework.core.io.buffer.DataBuffer;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.server.reactive.ServerHttpRequestDecorator;
-import org.springframework.web.server.ServerWebExchange;
-import reactor.core.publisher.Flux;
-import reactor.util.annotation.NonNull;
-
-/**
- * Build and modify the request class.
- */
-public class CryptorRequestDecorator extends ServerHttpRequestDecorator {
-
- private final CachedBodyOutputMessage cachedBodyOutputMessage;
-
- private final ServerWebExchange exchange;
-
- public CryptorRequestDecorator(final ServerWebExchange exchange,
- final CachedBodyOutputMessage cachedBodyOutputMessage) {
- super(exchange.getRequest());
- this.cachedBodyOutputMessage = cachedBodyOutputMessage;
- this.exchange = exchange;
- }
-
- @Override
- @NonNull
- public Flux<DataBuffer> getBody() {
- return cachedBodyOutputMessage.getBody();
- }
-
- @Override
- @NonNull
- public HttpHeaders getHeaders() {
- return ResponseUtils.chunkedHeader(this.exchange.getRequest().getHeaders());
- }
-}
diff --git a/shenyu-plugin/shenyu-plugin-cryptor/src/main/java/org/apache/shenyu/plugin/cryptor/decorator/CryptorResponseDecorator.java b/shenyu-plugin/shenyu-plugin-cryptor/src/main/java/org/apache/shenyu/plugin/cryptor/decorator/CryptorResponseDecorator.java
index f4ef2a7fb..8833e2313 100644
--- a/shenyu-plugin/shenyu-plugin-cryptor/src/main/java/org/apache/shenyu/plugin/cryptor/decorator/CryptorResponseDecorator.java
+++ b/shenyu-plugin/shenyu-plugin-cryptor/src/main/java/org/apache/shenyu/plugin/cryptor/decorator/CryptorResponseDecorator.java
@@ -68,6 +68,6 @@ public class CryptorResponseDecorator extends ServerHttpResponseDecorator {
if (Objects.isNull(modifiedBody)) {
return CryptorUtil.fail(ruleHandle.getWay(), exchange);
}
- return CryptorUtil.success(originalBody, modifiedBody, ruleHandle.getWay(), ruleHandle.getFieldNames());
+ return Mono.just(CryptorUtil.replace(originalBody, modifiedBody, ruleHandle.getWay(), ruleHandle.getFieldNames()));
}
}
diff --git a/shenyu-plugin/shenyu-plugin-cryptor/src/main/java/org/apache/shenyu/plugin/cryptor/request/CryptorRequestPlugin.java b/shenyu-plugin/shenyu-plugin-cryptor/src/main/java/org/apache/shenyu/plugin/cryptor/request/CryptorRequestPlugin.java
index f393fe321..03dd715ff 100644
--- a/shenyu-plugin/shenyu-plugin-cryptor/src/main/java/org/apache/shenyu/plugin/cryptor/request/CryptorRequestPlugin.java
+++ b/shenyu-plugin/shenyu-plugin-cryptor/src/main/java/org/apache/shenyu/plugin/cryptor/request/CryptorRequestPlugin.java
@@ -22,15 +22,12 @@ import org.apache.shenyu.common.dto.RuleData;
import org.apache.shenyu.common.dto.SelectorData;
import org.apache.shenyu.common.enums.PluginEnum;
import org.apache.shenyu.plugin.api.ShenyuPluginChain;
+import org.apache.shenyu.plugin.api.exception.ResponsiveException;
import org.apache.shenyu.plugin.api.result.ShenyuResultEnum;
-import org.apache.shenyu.plugin.api.result.ShenyuResultWrap;
import org.apache.shenyu.plugin.api.utils.WebFluxResultUtils;
import org.apache.shenyu.plugin.base.AbstractShenyuPlugin;
-import org.apache.shenyu.plugin.base.support.BodyInserterContext;
-import org.apache.shenyu.plugin.base.support.CachedBodyOutputMessage;
import org.apache.shenyu.plugin.base.utils.CacheKeyUtils;
-import org.apache.shenyu.plugin.base.utils.ResponseUtils;
-import org.apache.shenyu.plugin.cryptor.decorator.CryptorRequestDecorator;
+import org.apache.shenyu.plugin.base.utils.ServerWebExchangeUtils;
import org.apache.shenyu.plugin.cryptor.handler.CryptorRequestPluginDataHandler;
import org.apache.shenyu.plugin.cryptor.handler.CryptorRuleHandler;
import org.apache.shenyu.plugin.cryptor.strategy.CryptorStrategyFactory;
@@ -38,18 +35,13 @@ import org.apache.shenyu.plugin.cryptor.utils.CryptorUtil;
import org.apache.shenyu.plugin.cryptor.utils.JsonUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.http.ReactiveHttpOutputMessage;
import org.springframework.http.codec.HttpMessageReader;
-import org.springframework.http.server.reactive.ServerHttpRequestDecorator;
-import org.springframework.web.reactive.function.BodyInserter;
-import org.springframework.web.reactive.function.BodyInserters;
-import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;
import java.util.List;
import java.util.Objects;
-import java.util.function.Function;
+import java.util.Optional;
/**
* Cryptor request plugin.
@@ -70,33 +62,29 @@ public class CryptorRequestPlugin extends AbstractShenyuPlugin {
}
@Override
- @SuppressWarnings("unchecked")
protected Mono<Void> doExecute(final ServerWebExchange exchange, final ShenyuPluginChain chain, final SelectorData selector, final RuleData rule) {
CryptorRuleHandler ruleHandle = CryptorRequestPluginDataHandler.CACHED_HANDLE.get().obtainHandle(CacheKeyUtils.INST.getKey(rule));
if (Objects.isNull(ruleHandle)) {
LOG.error("Cryptor request rule configuration is null :{}", rule.getId());
return chain.execute(exchange);
}
+
Pair<Boolean, String> pair = JsonUtil.checkParam(ruleHandle);
if (Boolean.TRUE.equals(pair.getLeft())) {
- Object error = ShenyuResultWrap.error(exchange, ShenyuResultEnum.CRYPTOR_REQUEST_ERROR_CONFIGURATION.getCode(),
- ShenyuResultEnum.CRYPTOR_REQUEST_ERROR_CONFIGURATION.getMsg()
- + "[" + pair.getRight() + "]", null);
- return WebFluxResultUtils.result(exchange, error);
+ ShenyuResultEnum resultEnum = ShenyuResultEnum.CRYPTOR_REQUEST_ERROR_CONFIGURATION;
+ return WebFluxResultUtils.failedResult(resultEnum.getCode(),
+ resultEnum.getMsg() + "[" + pair.getRight() + "]", exchange);
}
- ServerRequest serverRequest = ServerRequest.create(exchange, messageReaders);
- Mono<String> mono = serverRequest.bodyToMono(String.class)
- .switchIfEmpty(Mono.defer(() -> Mono.just("")))
- .flatMap(originalBody -> strategyMatch(ruleHandle, originalBody, exchange));
-
- BodyInserter<Mono<String>, ReactiveHttpOutputMessage> bodyInserter = BodyInserters.fromPublisher(mono, String.class);
- CachedBodyOutputMessage outputMessage = ResponseUtils.newCachedBodyOutputMessage(exchange);
- return bodyInserter.insert(outputMessage, new BodyInserterContext())
- .then(Mono.defer(() -> {
- ServerHttpRequestDecorator decorator = new CryptorRequestDecorator(exchange, outputMessage);
- return chain.execute(exchange.mutate().request(decorator).build());
- })).onErrorResume((Function<Throwable, Mono<Void>>) throwable -> ResponseUtils.release(outputMessage, throwable));
+ return ServerWebExchangeUtils.rewriteRequestBody(exchange, messageReaders, originalBody ->
+ Mono.just(convert(ruleHandle, originalBody, exchange))
+ ).flatMap(chain::execute)
+ .onErrorResume(error -> {
+ if (error instanceof ResponsiveException) {
+ return WebFluxResultUtils.failedResult((ResponsiveException) error);
+ }
+ return Mono.error(error);
+ });
}
@Override
@@ -108,19 +96,20 @@ public class CryptorRequestPlugin extends AbstractShenyuPlugin {
public String named() {
return PluginEnum.CRYPTOR_REQUEST.getName();
}
-
- @SuppressWarnings("rawtypes")
- private Mono strategyMatch(final CryptorRuleHandler ruleHandle, final String originalBody, final ServerWebExchange exchange) {
+
+ private String convert(final CryptorRuleHandler ruleHandle, final String originalBody, final ServerWebExchange exchange) {
String parseBody = JsonUtil.parser(originalBody, ruleHandle.getFieldNames());
if (Objects.isNull(parseBody)) {
- Object error = ShenyuResultWrap.error(exchange, ShenyuResultEnum.CRYPTOR_REQUEST_ERROR_CONFIGURATION.getCode(),
- ShenyuResultEnum.CRYPTOR_REQUEST_ERROR_CONFIGURATION.getMsg() + "[fieldNames]", null);
- return WebFluxResultUtils.result(exchange, error);
+ throw new ResponsiveException(ShenyuResultEnum.CRYPTOR_REQUEST_ERROR_CONFIGURATION.getCode(), ShenyuResultEnum.CRYPTOR_REQUEST_ERROR_CONFIGURATION.getMsg() + "[fieldNames]", exchange);
}
+
String modifiedBody = CryptorStrategyFactory.match(ruleHandle, parseBody);
if (Objects.isNull(modifiedBody)) {
- return CryptorUtil.fail(ruleHandle.getWay(), exchange);
+ throw Optional.ofNullable(ruleHandle.getWay())
+ .filter(CryptorStrategyFactory.DECRYPT::equals)
+ .map(data -> new ResponsiveException(ShenyuResultEnum.DECRYPTION_ERROR, exchange))
+ .orElse(new ResponsiveException(ShenyuResultEnum.ENCRYPTION_ERROR, exchange));
}
- return CryptorUtil.success(originalBody, modifiedBody, ruleHandle.getWay(), ruleHandle.getFieldNames());
+ return CryptorUtil.replace(originalBody, modifiedBody, ruleHandle.getWay(), ruleHandle.getFieldNames());
}
}
diff --git a/shenyu-plugin/shenyu-plugin-cryptor/src/main/java/org/apache/shenyu/plugin/cryptor/utils/CryptorUtil.java b/shenyu-plugin/shenyu-plugin-cryptor/src/main/java/org/apache/shenyu/plugin/cryptor/utils/CryptorUtil.java
index 1bcf69231..b8bddd183 100644
--- a/shenyu-plugin/shenyu-plugin-cryptor/src/main/java/org/apache/shenyu/plugin/cryptor/utils/CryptorUtil.java
+++ b/shenyu-plugin/shenyu-plugin-cryptor/src/main/java/org/apache/shenyu/plugin/cryptor/utils/CryptorUtil.java
@@ -34,13 +34,14 @@ import java.util.concurrent.atomic.AtomicInteger;
* cryptor util.
*/
public final class CryptorUtil {
-
+
private CryptorUtil() {
}
/**
* error handling.
- * @param mode decrypt or encrypt
+ *
+ * @param mode decrypt or encrypt
* @param exchange exchange
* @return Mono
*/
@@ -58,13 +59,13 @@ public final class CryptorUtil {
*
* @param originalBody original Body of data.
* @param modifiedBody modified body
- * @param way mode decrypt or encrypt
- * @param fieldNames fieldNames
- * @return Mono
+ * @param way mode decrypt or encrypt
+ * @param fieldNames fieldNames
+ * @return new body
*/
- public static Mono<String> success(final String originalBody, final String modifiedBody, final String way, final String fieldNames) {
+ public static String replace(final String originalBody, final String modifiedBody, final String way, final String fieldNames) {
if (CryptorStrategyFactory.DECRYPT.equals(way)) {
- return Mono.just(modifiedBody);
+ return modifiedBody;
}
AtomicInteger initDeep = new AtomicInteger();
initDeep.set(0);
@@ -73,6 +74,6 @@ public final class CryptorUtil {
initDeep,
modifiedBody,
Arrays.asList(fieldNames.split("\\.")));
- return Mono.just(resultJe.toString());
+ return resultJe.toString();
}
}
diff --git a/shenyu-plugin/shenyu-plugin-sign/src/main/java/org/apache/shenyu/plugin/sign/SignPlugin.java b/shenyu-plugin/shenyu-plugin-sign/src/main/java/org/apache/shenyu/plugin/sign/SignPlugin.java
index 5c14b14d2..7957b8bd1 100644
--- a/shenyu-plugin/shenyu-plugin-sign/src/main/java/org/apache/shenyu/plugin/sign/SignPlugin.java
+++ b/shenyu-plugin/shenyu-plugin-sign/src/main/java/org/apache/shenyu/plugin/sign/SignPlugin.java
@@ -23,15 +23,14 @@ import org.apache.shenyu.common.dto.SelectorData;
import org.apache.shenyu.common.enums.PluginEnum;
import org.apache.shenyu.common.utils.JsonUtils;
import org.apache.shenyu.plugin.api.ShenyuPluginChain;
+import org.apache.shenyu.plugin.api.exception.ResponsiveException;
import org.apache.shenyu.plugin.api.result.ShenyuResultEnum;
-import org.apache.shenyu.plugin.api.result.ShenyuResultWrap;
import org.apache.shenyu.plugin.api.utils.WebFluxResultUtils;
import org.apache.shenyu.plugin.base.AbstractShenyuPlugin;
import org.apache.shenyu.plugin.base.utils.CacheKeyUtils;
import org.apache.shenyu.plugin.base.utils.ServerWebExchangeUtils;
import org.apache.shenyu.plugin.sign.api.SignService;
import org.apache.shenyu.plugin.sign.api.VerifyResult;
-import org.apache.shenyu.plugin.sign.exception.SignPluginException;
import org.apache.shenyu.plugin.sign.handler.SignPluginDataHandler;
import org.apache.shenyu.plugin.sign.handler.SignRuleHandler;
import org.springframework.http.codec.HttpMessageReader;
@@ -79,27 +78,28 @@ public class SignPlugin extends AbstractShenyuPlugin {
if (ObjectUtils.isEmpty(ruleHandler) || !ruleHandler.getSignRequestBody()) {
VerifyResult result = signService.signVerify(exchange);
if (result.isFailed()) {
- return handleSignFailed(exchange, result.getReason());
+ return WebFluxResultUtils.failedResult(ShenyuResultEnum.SIGN_IS_NOT_PASS.getCode(),
+ result.getReason(), exchange);
}
return chain.execute(exchange);
}
return ServerWebExchangeUtils.rewriteRequestBody(exchange, messageReaders, body -> {
- VerifyResult result = signBody(body, exchange);
+ VerifyResult result = signVerifyWithBody(body, exchange);
if (result.isSuccess()) {
return Mono.just(body);
}
- throw new SignPluginException(result.getReason());
+ throw new ResponsiveException(ShenyuResultEnum.SIGN_IS_NOT_PASS.getCode(), result.getReason(), exchange);
}).flatMap(chain::execute)
.onErrorResume(error -> {
- if (error instanceof SignPluginException) {
- return handleSignFailed(exchange, error.getMessage());
+ if (error instanceof ResponsiveException) {
+ return WebFluxResultUtils.failedResult((ResponsiveException) error);
}
return Mono.error(error);
});
}
- private VerifyResult signBody(final String originalBody, final ServerWebExchange exchange) {
+ private VerifyResult signVerifyWithBody(final String originalBody, final ServerWebExchange exchange) {
// get url params
MultiValueMap<String, String> queryParams = exchange.getRequest().getQueryParams();
// get post body
@@ -107,9 +107,4 @@ public class SignPlugin extends AbstractShenyuPlugin {
Map<String, String> queryParamsSingleValueMap = queryParams.toSingleValueMap();
return signService.signVerify(exchange, requestBody, queryParamsSingleValueMap);
}
-
- private Mono<Void> handleSignFailed(final ServerWebExchange exchange, final String reason) {
- Object error = ShenyuResultWrap.error(exchange, ShenyuResultEnum.SIGN_IS_NOT_PASS.getCode(), reason, null);
- return WebFluxResultUtils.result(exchange, error);
- }
}
diff --git a/shenyu-plugin/shenyu-plugin-sign/src/main/java/org/apache/shenyu/plugin/sign/exception/SignPluginException.java b/shenyu-plugin/shenyu-plugin-sign/src/main/java/org/apache/shenyu/plugin/sign/exception/SignPluginException.java
deleted file mode 100644
index 03f486fb7..000000000
--- a/shenyu-plugin/shenyu-plugin-sign/src/main/java/org/apache/shenyu/plugin/sign/exception/SignPluginException.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-package org.apache.shenyu.plugin.sign.exception;
-
-import org.apache.shenyu.common.exception.ShenyuException;
-
-public class SignPluginException extends ShenyuException {
-
- public SignPluginException(final Throwable e) {
- super(e);
- }
-
- public SignPluginException(final String message) {
- super(message);
- }
-
- public SignPluginException(final String message, final Throwable throwable) {
- super(message, throwable);
- }
-}