├── LICENSE
├── README.md
├── dubbo-gateway-api
├── pom.xml
└── src
│ └── main
│ └── java
│ └── com
│ └── atommiddleware
│ └── cloud
│ └── api
│ └── annotation
│ ├── FromAttribute.java
│ ├── FromBody.java
│ ├── FromCookie.java
│ ├── FromHeader.java
│ ├── FromPath.java
│ ├── FromQueryParams.java
│ ├── GateWayDubbo.java
│ ├── ParamAttribute.java
│ ├── ParamFormatConstants.java
│ └── PathMapping.java
├── dubbo-gateway-core
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── com
│ │ └── atommiddleware
│ │ └── cloud
│ │ └── core
│ │ ├── annotation
│ │ ├── AbstractBaseApiWrapper.java
│ │ ├── AbstractDubboApiServletWrapper.java
│ │ ├── AbstractDubboApiWrapper.java
│ │ ├── AbstractDubboApiWrapperFactory.java
│ │ ├── BaseApiWrapper.java
│ │ ├── DefaultDubboApiWrapperFactory.java
│ │ ├── DefaultResponseResult.java
│ │ ├── DefaultResponseServletResult.java
│ │ ├── DefaultResponseZuulServletResult.java
│ │ ├── DubboApiServletWrapper.java
│ │ ├── DubboApiWrapper.java
│ │ ├── DubboApiWrapperFactory.java
│ │ ├── DubboGateWayApplicationListener.java
│ │ ├── DubboGatewayImportBeanDefinitionRegistrar.java
│ │ ├── DubboGatewayPostProcessor.java
│ │ ├── DubboGatewayScanner.java
│ │ ├── ParamInfo.java
│ │ ├── ParamMeta.java
│ │ ├── PathMappingMethodInfo.java
│ │ ├── ResponseReactiveResult.java
│ │ ├── ResponseServletResult.java
│ │ └── ResponseZuulServletResult.java
│ │ ├── cas
│ │ └── CasAjaxAuthenticationEntryPoint.java
│ │ ├── config
│ │ ├── DubboReferenceConfig.java
│ │ ├── DubboReferenceConfigProperties.java
│ │ └── ReferenceMethodConfig.java
│ │ ├── context
│ │ └── DubboApiContext.java
│ │ ├── controller
│ │ └── ForwardingServiceController.java
│ │ ├── dubbo
│ │ └── filter
│ │ │ └── UserFilter.java
│ │ ├── exception
│ │ └── JsonExceptionHandler.java
│ │ ├── filter
│ │ ├── DubboGlobalFilter.java
│ │ ├── DubboServletFilter.java
│ │ ├── DubboServletZuulFilter.java
│ │ ├── ServletErrorFilter.java
│ │ └── ZuulErrorFilter.java
│ │ ├── security
│ │ ├── DefaultPrincipalObtain.java
│ │ ├── DefaultXssSecurity.java
│ │ ├── EncodeHtmlXssSecurity.java
│ │ ├── EsapiEncodeHtmlXssSecurity.java
│ │ └── XssSecurity.java
│ │ ├── serialize
│ │ ├── CustomXssObjectMapper.java
│ │ ├── JacksonSerialization.java
│ │ └── Serialization.java
│ │ └── utils
│ │ └── HttpUtils.java
│ └── resources
│ ├── META-INF
│ └── dubbo
│ │ └── org.apache.dubbo.rpc.Filter
│ └── esapi
│ ├── ESAPI.properties
│ └── validation.properties
├── dubbo-gateway-parent
└── pom.xml
├── dubbo-gateway-sample-api
├── pom.xml
└── src
│ └── main
│ └── java
│ └── com
│ └── atommiddleware
│ └── cloud
│ └── sample
│ └── api
│ ├── Result.java
│ ├── order
│ ├── OrderQuery.java
│ ├── OrderService.java
│ └── domain
│ │ └── Order.java
│ └── user
│ ├── UserService.java
│ └── domain
│ └── User.java
├── dubbo-gateway-sample-provider
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── com
│ │ └── atommiddleware
│ │ └── cloud
│ │ └── sample
│ │ └── provider
│ │ ├── App.java
│ │ ├── order
│ │ ├── OrderQueryImpl.java
│ │ └── OrderServiceImpl.java
│ │ └── user
│ │ └── UserServiceImpl.java
│ └── resources
│ └── bootstrap.yml
├── dubbo-gateway-sample-web-consumer
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── com
│ │ └── atommiddleware
│ │ └── sample
│ │ └── web
│ │ └── consumer
│ │ └── App.java
│ └── resources
│ └── application.yml
├── dubbo-gateway-sample-web-provider
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── com
│ │ └── atommiddleware
│ │ └── sample
│ │ └── web
│ │ └── provider
│ │ ├── App.java
│ │ ├── controller
│ │ └── HelloWorldController.java
│ │ ├── order
│ │ ├── OrderQueryImpl.java
│ │ └── OrderServiceImpl.java
│ │ └── user
│ │ └── UserServiceImpl.java
│ └── resources
│ └── application.yml
├── dubbo-gateway-sample-zuul
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── com
│ │ └── atommiddleware
│ │ └── cloud
│ │ └── zuul
│ │ └── App.java
│ └── resources
│ ├── bootstrap.yml
│ └── static
│ └── favicon.ico
├── dubbo-gateway-sample
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── com
│ │ └── atommiddleware
│ │ └── cloud
│ │ └── sample
│ │ └── App.java
│ └── resources
│ └── bootstrap.yml
├── dubbo-gateway-security
├── pom.xml
└── src
│ └── main
│ └── java
│ └── com
│ └── atommiddleware
│ └── cloud
│ └── security
│ ├── cas
│ ├── BasedVoter.java
│ ├── CustomUserDetailsService.java
│ ├── PathPatternGrantedAuthority.java
│ └── PrincipalObtain.java
│ ├── utils
│ └── ValidatorUtils.java
│ └── validation
│ ├── DefaultParamValidator.java
│ └── ParamValidator.java
├── dubbo-gateway-spring-boot-autoconfigure
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── com
│ │ └── atommiddleware
│ │ └── cloud
│ │ └── autoconfigure
│ │ ├── CasSecurityAutoConfiguration.java
│ │ ├── CasSecurityWebSecurityConfigurerAdapterAutoConfiguration.java
│ │ ├── DubboGateWayApplicationContextInitializer.java
│ │ ├── DubboGatewayAutoConfiguration.java
│ │ ├── DubboGatewayBootstrapConfiguration.java
│ │ ├── DubboGatewayCommonAutoConfiguration.java
│ │ ├── DubboGatewayServletAutoConfiguration.java
│ │ ├── DubboGatewayZuulServletAutoConfiguration.java
│ │ ├── ExceptionHandlerConfiguration.java
│ │ ├── RedisHttpSessionAutoConfiguration.java
│ │ └── SevlertImportBeanDefinitionRegistrar.java
│ └── resources
│ └── META-INF
│ ├── spring-autoconfigure-metadata.properties
│ └── spring.factories
├── dubbo-gateway-spring-boot-starter
└── pom.xml
├── dubboGateWay.postman_collection.json
└── dubboGateWay_XSS.postman_collection.json
/dubbo-gateway-api/pom.xml:
--------------------------------------------------------------------------------
1 |
4 | 4.0.0
5 |
6 | com.atommiddleware
7 | dubbo-gateway-parent
8 | ${revision}
9 | ../dubbo-gateway-parent/pom.xml
10 |
11 | jar
12 | dubbo-gateway-api
13 | ${project.artifactId}
14 | The api module of dubbo gateway
15 |
16 |
17 |
18 | org.springframework
19 | spring-core
20 | true
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/dubbo-gateway-api/src/main/java/com/atommiddleware/cloud/api/annotation/FromAttribute.java:
--------------------------------------------------------------------------------
1 | package com.atommiddleware.cloud.api.annotation;
2 |
3 | import java.lang.annotation.Documented;
4 | import java.lang.annotation.ElementType;
5 | import java.lang.annotation.Retention;
6 | import java.lang.annotation.RetentionPolicy;
7 | import java.lang.annotation.Target;
8 |
9 | import org.springframework.core.annotation.AliasFor;
10 |
11 | import com.atommiddleware.cloud.api.annotation.ParamAttribute.ParamFromType;
12 |
13 | @Target(ElementType.PARAMETER)
14 | @Retention(RetentionPolicy.RUNTIME)
15 | @Documented
16 | @ParamAttribute(paramFromType = ParamFromType.FROM_ATTRIBUTE)
17 | public @interface FromAttribute {
18 |
19 | @AliasFor(annotation = ParamAttribute.class)
20 | String value() default "";
21 |
22 | @AliasFor(annotation = ParamAttribute.class)
23 | String name() default "";
24 |
25 | @AliasFor(annotation = ParamAttribute.class)
26 | boolean required() default true;
27 | }
28 |
--------------------------------------------------------------------------------
/dubbo-gateway-api/src/main/java/com/atommiddleware/cloud/api/annotation/FromBody.java:
--------------------------------------------------------------------------------
1 | package com.atommiddleware.cloud.api.annotation;
2 |
3 | import java.lang.annotation.Documented;
4 | import java.lang.annotation.ElementType;
5 | import java.lang.annotation.Retention;
6 | import java.lang.annotation.RetentionPolicy;
7 | import java.lang.annotation.Target;
8 |
9 | import org.springframework.core.annotation.AliasFor;
10 |
11 | import com.atommiddleware.cloud.api.annotation.ParamAttribute.ParamFromType;
12 |
13 | @Target(ElementType.PARAMETER)
14 | @Retention(RetentionPolicy.RUNTIME)
15 | @Documented
16 | @ParamAttribute(paramFromType = ParamFromType.FROM_BODY)
17 | public @interface FromBody {
18 |
19 | @AliasFor(annotation = ParamAttribute.class)
20 | boolean required() default true;
21 | }
22 |
--------------------------------------------------------------------------------
/dubbo-gateway-api/src/main/java/com/atommiddleware/cloud/api/annotation/FromCookie.java:
--------------------------------------------------------------------------------
1 | package com.atommiddleware.cloud.api.annotation;
2 |
3 | import java.lang.annotation.Documented;
4 | import java.lang.annotation.ElementType;
5 | import java.lang.annotation.Retention;
6 | import java.lang.annotation.RetentionPolicy;
7 | import java.lang.annotation.Target;
8 |
9 | import org.springframework.core.annotation.AliasFor;
10 |
11 | import com.atommiddleware.cloud.api.annotation.ParamAttribute.ParamFormat;
12 | import com.atommiddleware.cloud.api.annotation.ParamAttribute.ParamFromType;
13 |
14 | @Target(ElementType.PARAMETER)
15 | @Retention(RetentionPolicy.RUNTIME)
16 | @Documented
17 | @ParamAttribute(paramFromType = ParamFromType.FROM_COOKIE)
18 | public @interface FromCookie {
19 |
20 | @AliasFor(annotation = ParamAttribute.class)
21 | String value() default "";
22 |
23 | @AliasFor(annotation = ParamAttribute.class)
24 | String name() default "";
25 |
26 | @AliasFor(annotation = ParamAttribute.class)
27 | boolean required() default true;
28 |
29 | @AliasFor(annotation = ParamAttribute.class)
30 | ParamFormat paramFormat() default ParamFormat.MAP;
31 | }
32 |
--------------------------------------------------------------------------------
/dubbo-gateway-api/src/main/java/com/atommiddleware/cloud/api/annotation/FromHeader.java:
--------------------------------------------------------------------------------
1 | package com.atommiddleware.cloud.api.annotation;
2 |
3 | import java.lang.annotation.Documented;
4 | import java.lang.annotation.ElementType;
5 | import java.lang.annotation.Retention;
6 | import java.lang.annotation.RetentionPolicy;
7 | import java.lang.annotation.Target;
8 |
9 | import org.springframework.core.annotation.AliasFor;
10 |
11 | import com.atommiddleware.cloud.api.annotation.ParamAttribute.ParamFormat;
12 | import com.atommiddleware.cloud.api.annotation.ParamAttribute.ParamFromType;
13 |
14 | @Target(ElementType.PARAMETER)
15 | @Retention(RetentionPolicy.RUNTIME)
16 | @Documented
17 | @ParamAttribute(paramFromType = ParamFromType.FROM_HEADER)
18 | public @interface FromHeader {
19 |
20 | @AliasFor(annotation = ParamAttribute.class)
21 | String value() default "";
22 |
23 | @AliasFor(annotation = ParamAttribute.class)
24 | String name() default "";
25 |
26 | @AliasFor(annotation = ParamAttribute.class)
27 | boolean required() default true;
28 |
29 | @AliasFor(annotation = ParamAttribute.class)
30 | ParamFormat paramFormat() default ParamFormat.MAP;
31 | }
32 |
--------------------------------------------------------------------------------
/dubbo-gateway-api/src/main/java/com/atommiddleware/cloud/api/annotation/FromPath.java:
--------------------------------------------------------------------------------
1 | package com.atommiddleware.cloud.api.annotation;
2 |
3 | import java.lang.annotation.Documented;
4 | import java.lang.annotation.ElementType;
5 | import java.lang.annotation.Retention;
6 | import java.lang.annotation.RetentionPolicy;
7 | import java.lang.annotation.Target;
8 |
9 | import org.springframework.core.annotation.AliasFor;
10 |
11 | import com.atommiddleware.cloud.api.annotation.ParamAttribute.ParamFormat;
12 | import com.atommiddleware.cloud.api.annotation.ParamAttribute.ParamFromType;
13 |
14 | @Target(ElementType.PARAMETER)
15 | @Retention(RetentionPolicy.RUNTIME)
16 | @Documented
17 | @ParamAttribute(paramFromType = ParamFromType.FROM_PATH)
18 | public @interface FromPath {
19 |
20 | @AliasFor(annotation = ParamAttribute.class)
21 | String value() default "";
22 |
23 | @AliasFor(annotation = ParamAttribute.class)
24 | String name() default "";
25 |
26 | @AliasFor(annotation = ParamAttribute.class)
27 | boolean required() default true;
28 |
29 | @AliasFor(annotation = ParamAttribute.class)
30 | ParamFormat paramFormat() default ParamFormat.MAP;
31 | }
32 |
--------------------------------------------------------------------------------
/dubbo-gateway-api/src/main/java/com/atommiddleware/cloud/api/annotation/FromQueryParams.java:
--------------------------------------------------------------------------------
1 | package com.atommiddleware.cloud.api.annotation;
2 |
3 | import java.lang.annotation.Documented;
4 | import java.lang.annotation.ElementType;
5 | import java.lang.annotation.Retention;
6 | import java.lang.annotation.RetentionPolicy;
7 | import java.lang.annotation.Target;
8 |
9 | import org.springframework.core.annotation.AliasFor;
10 |
11 | import com.atommiddleware.cloud.api.annotation.ParamAttribute.ParamFormat;
12 | import com.atommiddleware.cloud.api.annotation.ParamAttribute.ParamFromType;
13 |
14 | @Target(ElementType.PARAMETER)
15 | @Retention(RetentionPolicy.RUNTIME)
16 | @Documented
17 | @ParamAttribute(paramFromType = ParamFromType.FROM_QUERYPARAMS)
18 | public @interface FromQueryParams {
19 |
20 | @AliasFor(annotation = ParamAttribute.class)
21 | String value() default "";
22 |
23 | @AliasFor(annotation = ParamAttribute.class)
24 | String name() default "";
25 |
26 | @AliasFor(annotation = ParamAttribute.class)
27 | boolean required() default true;
28 |
29 | @AliasFor(annotation = ParamAttribute.class)
30 | ParamFormat paramFormat() default ParamFormat.MAP;
31 | }
32 |
--------------------------------------------------------------------------------
/dubbo-gateway-api/src/main/java/com/atommiddleware/cloud/api/annotation/GateWayDubbo.java:
--------------------------------------------------------------------------------
1 | package com.atommiddleware.cloud.api.annotation;
2 |
3 | import java.lang.annotation.Documented;
4 | import java.lang.annotation.ElementType;
5 | import java.lang.annotation.Retention;
6 | import java.lang.annotation.RetentionPolicy;
7 | import java.lang.annotation.Target;
8 |
9 | import org.springframework.core.annotation.AliasFor;
10 |
11 | @Target(ElementType.TYPE)
12 | @Retention(RetentionPolicy.RUNTIME)
13 | @Documented
14 | public @interface GateWayDubbo {
15 |
16 | @AliasFor("id")
17 | String value() default "";
18 |
19 | @AliasFor("value")
20 | String id() default "";
21 | }
22 |
--------------------------------------------------------------------------------
/dubbo-gateway-api/src/main/java/com/atommiddleware/cloud/api/annotation/ParamAttribute.java:
--------------------------------------------------------------------------------
1 | package com.atommiddleware.cloud.api.annotation;
2 |
3 | import java.lang.annotation.Documented;
4 | import java.lang.annotation.ElementType;
5 | import java.lang.annotation.Retention;
6 | import java.lang.annotation.RetentionPolicy;
7 | import java.lang.annotation.Target;
8 |
9 | import org.springframework.core.annotation.AliasFor;
10 |
11 | @Target(ElementType.ANNOTATION_TYPE)
12 | @Retention(RetentionPolicy.RUNTIME)
13 | @Documented
14 | public @interface ParamAttribute {
15 |
16 | @AliasFor("name")
17 | String value() default "";
18 |
19 | @AliasFor("value")
20 | String name() default "";
21 |
22 | boolean required() default true;
23 |
24 | ParamFromType paramFromType();
25 |
26 | ParamFormat paramFormat() default ParamFormat.MAP;
27 |
28 | public enum ParamFormat {
29 | MAP, JSON
30 | }
31 | public enum ParamFromType {
32 | FROM_BODY, FROM_COOKIE, FROM_HEADER, FROM_PATH, FROM_ATTRIBUTE, FROM_QUERYPARAMS;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/dubbo-gateway-api/src/main/java/com/atommiddleware/cloud/api/annotation/ParamFormatConstants.java:
--------------------------------------------------------------------------------
1 | //package com.atommiddleware.cloud.api.annotation;
2 | //
3 | //public class ParamFormatConstants {
4 | //
5 | // public static final int MAP=0;
6 | //
7 | // public static final int JSON=1;
8 | //}
9 |
--------------------------------------------------------------------------------
/dubbo-gateway-api/src/main/java/com/atommiddleware/cloud/api/annotation/PathMapping.java:
--------------------------------------------------------------------------------
1 | package com.atommiddleware.cloud.api.annotation;
2 |
3 | import java.lang.annotation.Documented;
4 | import java.lang.annotation.ElementType;
5 | import java.lang.annotation.Retention;
6 | import java.lang.annotation.RetentionPolicy;
7 | import java.lang.annotation.Target;
8 |
9 | import org.springframework.core.annotation.AliasFor;
10 |
11 | @Target(ElementType.METHOD)
12 | @Retention(RetentionPolicy.RUNTIME)
13 | @Documented
14 | public @interface PathMapping {
15 |
16 | @AliasFor("path")
17 | String value() default "";
18 |
19 | @AliasFor("value")
20 | String path() default "";
21 |
22 | RequestMethod requestMethod() default RequestMethod.POST;
23 |
24 | public enum RequestMethod {
25 | GET, POST
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/dubbo-gateway-core/pom.xml:
--------------------------------------------------------------------------------
1 |
4 | 4.0.0
5 |
6 |
7 | com.atommiddleware
8 | dubbo-gateway-parent
9 | ${revision}
10 | ../dubbo-gateway-parent/pom.xml
11 |
12 | jar
13 | dubbo-gateway-core
14 | ${project.artifactId}
15 | The core module of dubbo gateway
16 |
17 |
18 |
19 | org.springframework.boot
20 | spring-boot-starter-webflux
21 | true
22 |
23 |
24 | com.alibaba.cloud
25 | spring-cloud-starter-dubbo
26 | true
27 |
28 |
29 | com.atommiddleware
30 | dubbo-gateway-api
31 | ${project.parent.version}
32 |
33 |
34 | com.atommiddleware
35 | dubbo-gateway-security
36 | ${project.parent.version}
37 |
38 |
39 | org.projectlombok
40 | lombok
41 | provided
42 |
43 |
44 | javax.servlet
45 | javax.servlet-api
46 | provided
47 |
48 |
49 | org.springframework.cloud
50 | spring-cloud-starter-gateway
51 | true
52 |
53 |
54 | org.springframework.cloud
55 | spring-cloud-starter-netflix-zuul
56 | true
57 |
58 |
59 | org.owasp.antisamy
60 | antisamy
61 |
62 |
63 | org.owasp.encoder
64 | encoder-esapi
65 |
66 |
67 | org.owasp.esapi
68 | esapi
69 |
70 |
71 | org.springframework.boot
72 | spring-boot-starter-security
73 | true
74 |
75 |
76 | org.springframework.security
77 | spring-security-cas
78 | true
79 |
80 |
81 |
82 |
--------------------------------------------------------------------------------
/dubbo-gateway-core/src/main/java/com/atommiddleware/cloud/core/annotation/AbstractBaseApiWrapper.java:
--------------------------------------------------------------------------------
1 | package com.atommiddleware.cloud.core.annotation;
2 |
3 | import java.lang.reflect.InvocationTargetException;
4 | import java.util.HashMap;
5 | import java.util.HashSet;
6 | import java.util.List;
7 | import java.util.Map;
8 | import java.util.Set;
9 |
10 | import org.apache.dubbo.common.utils.ClassUtils;
11 | import org.springframework.beans.factory.InitializingBean;
12 | import org.springframework.beans.factory.annotation.Autowired;
13 | import org.springframework.util.MultiValueMap;
14 | import org.springframework.util.PathMatcher;
15 | import org.springframework.util.StringUtils;
16 |
17 | import com.atommiddleware.cloud.api.annotation.ParamAttribute.ParamFormat;
18 | import com.atommiddleware.cloud.core.config.DubboReferenceConfigProperties;
19 | import com.atommiddleware.cloud.core.config.DubboReferenceConfigProperties.XssConfig;
20 | import com.atommiddleware.cloud.core.context.DubboApiContext;
21 | import com.atommiddleware.cloud.core.security.XssSecurity;
22 | import com.atommiddleware.cloud.core.security.XssSecurity.XssFilterStrategy;
23 | import com.atommiddleware.cloud.core.serialize.Serialization;
24 | @SuppressWarnings("unchecked")
25 | public abstract class AbstractBaseApiWrapper implements BaseApiWrapper, InitializingBean {
26 |
27 | protected Set patterns = new HashSet();
28 |
29 | @Autowired
30 | private Serialization serialization;
31 | @Autowired
32 | protected PathMatcher pathMatcher;
33 | @Autowired
34 | private DubboReferenceConfigProperties dubboReferenceConfigProperties;
35 | @Autowired(required = false)
36 | private XssSecurity xssSecurity;
37 | private boolean xssFilterEnable = true;
38 | // 0 response 1 request 2 all
39 | private XssFilterStrategy xssFilterStrategy;
40 |
41 | @Override
42 | public Set getPathPatterns() {
43 | return patterns;
44 | }
45 |
46 | protected void convertAttriToParam(ParamInfo paramInfo, Object obj, Object[] params) {
47 | if (paramInfo.isRequired() && null == obj) {
48 | throw new IllegalArgumentException("attribute Parameter verification exception");
49 | }
50 | params[paramInfo.getIndex()] = obj;
51 | }
52 |
53 | protected void convertBodyToParam(ParamInfo paramInfo, Object body, Object[] params)
54 | throws IllegalAccessException, InvocationTargetException, InstantiationException {
55 | if (paramInfo.isRequired() && StringUtils.isEmpty(body)) {
56 | throw new IllegalArgumentException("body Parameter verification exception");
57 | }
58 | final Map> mapClasses = DubboApiContext.MAP_CLASSES;
59 | Object param = null;
60 | if (null != body) {
61 | Class> paramTypeClass = mapClasses.get(paramInfo.getParamType());
62 | if (paramInfo.isSimpleType()) {
63 | String bodyString = null;
64 | if (body instanceof String) {
65 | bodyString = (String) body;
66 | } else {
67 | if (body instanceof MultiValueMap) {
68 | MultiValueMap multiValueMap = (MultiValueMap) body;
69 | bodyString = multiValueMap.getFirst(paramInfo.getParamName());
70 | multiValueMap.clear();
71 | } else {
72 | Map mapValue = (Map) body;
73 | String[] strValues = mapValue.get(paramInfo.getParamName());
74 | if (null != strValues && strValues.length > 0) {
75 | bodyString = strValues[0];
76 | }
77 | mapValue.clear();
78 | }
79 | }
80 | if (!StringUtils.isEmpty(bodyString)) {
81 | if (checkRequestXssStrategy(paramTypeClass)) {
82 | bodyString = xssSecurity.xssClean(bodyString);
83 | }
84 | param = ClassUtils.convertPrimitive(paramTypeClass, bodyString);
85 | }
86 | } else {
87 | if (body instanceof String) {
88 | param = serialization.deserialize((String) body, paramTypeClass);
89 | } else {
90 | if (body instanceof MultiValueMap) {
91 | MultiValueMap multiValueMap = (MultiValueMap) body;
92 | param = serialization.convertValue(multiValueMap.toSingleValueMap(), paramTypeClass);
93 | multiValueMap.clear();
94 | } else {
95 | Map multiValueMap = (Map) body;
96 | Map mapValues = new HashMap();
97 | multiValueMap.forEach((key, v) -> {
98 | if (null != v && v.length > 0) {
99 | mapValues.put(key, v[0]);
100 | }
101 | });
102 | param = serialization.convertValue(mapValues, paramTypeClass);
103 | mapValues.clear();
104 | }
105 | }
106 | }
107 | }
108 | if (paramInfo.isRequired() && null == param) {
109 | throw new IllegalArgumentException(
110 | "paramName:[" + paramInfo.getParamName() + "] Parameter verification exception");
111 | }
112 | params[paramInfo.getIndex()] = param;
113 | }
114 |
115 | private boolean checkRequestXssStrategy(Class> paramTypeClass) {
116 | return paramTypeClass == String.class && xssFilterEnable && xssFilterStrategy == XssFilterStrategy.REQUEST;
117 | }
118 |
119 | protected void convertParam(List listParams, Map mapPathParams, Object[] params) {
120 | String paramValue = null;
121 | Object param = null;
122 | final Map> mapClasses = DubboApiContext.MAP_CLASSES;
123 | Class> paramTypeClass;
124 | for (ParamInfo paramInfo : listParams) {
125 | param = null;
126 | paramTypeClass = mapClasses.get(paramInfo.getParamType());
127 | if (ClassUtils.isSimpleType(paramTypeClass)) {
128 | paramValue = mapPathParams.get(paramInfo.getParamName());
129 | if (!StringUtils.isEmpty(paramValue)) {
130 | if (checkRequestXssStrategy(paramTypeClass)) {
131 | paramValue = xssSecurity.xssClean(paramValue);
132 | }
133 | param = ClassUtils.convertPrimitive(paramTypeClass, paramValue);
134 | }
135 | } else {
136 | if (paramInfo.getParamFormat() == ParamFormat.MAP) {
137 | param = serialization.convertValue(mapPathParams, paramTypeClass);
138 | } else {
139 | paramValue = mapPathParams.get(paramInfo.getParamName());
140 | param = serialization.deserialize(paramValue, paramTypeClass);
141 | }
142 | }
143 | if (paramInfo.isRequired() && null == param) {
144 | throw new IllegalArgumentException(
145 | "paramName:[" + paramInfo.getParamName() + "] Parameter verification exception");
146 | }
147 | params[paramInfo.getIndex()] = param;
148 | }
149 | mapPathParams.clear();
150 | }
151 |
152 | @Override
153 | public void afterPropertiesSet() throws Exception {
154 | XssConfig xssConfig=dubboReferenceConfigProperties.getSecurity().getXss();
155 | xssFilterEnable = xssConfig.isEnable();
156 | xssFilterStrategy = XssFilterStrategy.values()[xssConfig.getFilterStrategy()];
157 |
158 | }
159 | }
160 |
--------------------------------------------------------------------------------
/dubbo-gateway-core/src/main/java/com/atommiddleware/cloud/core/annotation/AbstractDubboApiServletWrapper.java:
--------------------------------------------------------------------------------
1 | package com.atommiddleware.cloud.core.annotation;
2 |
3 | import java.io.UnsupportedEncodingException;
4 | import java.lang.reflect.InvocationTargetException;
5 | import java.util.Arrays;
6 | import java.util.Enumeration;
7 | import java.util.List;
8 | import java.util.Map;
9 | import java.util.TreeMap;
10 | import java.util.concurrent.CompletableFuture;
11 | import java.util.concurrent.ExecutionException;
12 |
13 | import javax.servlet.http.Cookie;
14 | import javax.servlet.http.HttpServletRequest;
15 |
16 | import org.springframework.util.CollectionUtils;
17 | import org.springframework.util.StringUtils;
18 |
19 | import com.atommiddleware.cloud.api.annotation.ParamAttribute.ParamFromType;
20 | import com.atommiddleware.cloud.core.context.DubboApiContext;
21 | import com.atommiddleware.cloud.core.utils.HttpUtils;
22 |
23 | import lombok.extern.slf4j.Slf4j;
24 | @Slf4j
25 | public abstract class AbstractDubboApiServletWrapper extends AbstractBaseApiWrapper implements DubboApiServletWrapper{
26 |
27 | @Override
28 | public CompletableFuture