Merge branch 'master' into eureka

eureka
tanghc 5 years ago
commit 358d05aa34
  1. 21
      LICENSE
  2. 2
      README.md
  3. 1
      doc/docs/files/10088_自定义过滤器.md
  4. 2
      doc/docs/files/90100_常见问题.md
  5. 2
      sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/service/impl/RegistryServiceNacosImpl.java
  6. 64
      sop-test/src/test/java/com/gitee/sop/test/AlipayToolPKCS1Test.java
  7. 64
      sop-test/src/test/java/com/gitee/sop/test/AlipayToolPKCS8Test.java

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2019 tanghc
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

@ -24,7 +24,7 @@ SOP封装了开放平台大部分功能包括:签名验证、统一异常处
## 架构图
![架构图](https://images.gitee.com/uploads/images/2019/0821/201531_0f605f7c_332975.png "SOP架构图")
![架构图](https://images.gitee.com/uploads/images/2019/1227/145216_c9b45109_332975.png "sop3.png")
> 如上图所示,整个系统运行后,开发者只需关注微服务中的业务代码,接口变更后重新部署微服务应用即可

@ -7,7 +7,6 @@ zuul过滤器列表如下:
| 类型 | 顺序 | 过滤器 | 功能 |
| ----- | ---- | ----------------------- | ---------------------------- |
| pre | -1000 | PreValidateFilter (SOP自带) | 校验签名 |
| pre | -999 | PreRoutePermissionFilter (SOP自带) | 路由权限校验,有些接口需要配置权限才能访问 |
| pre | -998 | PreLimitFilter (SOP自带) | 限流拦截器 |
| pre | -3 | ServletDetectionFilter | 标记处理 Servlet 的类型 |
| pre | -2 | Servlet30WrapperFilter | 包装 HttpServletRequest 请求 |

@ -103,7 +103,7 @@ yml添加:
ribbon.ReadTimeout: 60000
```
## 指定了context-path
## 指定了context-path(拉取路由404)
微服务项目定义了`server.servlet.context-path=/story-service`,同时必须指定:

@ -33,7 +33,7 @@ public class RegistryServiceNacosImpl implements RegistryService {
private static HttpTool httpTool = new HttpTool();
@Value("${nacos.discovery.server-addr:${registry.nacos-server-addr:}}")
@Value("${nacos.discovery.server-addr:${spring.cloud.nacos.discovery.server-addr:}}")
private String nacosAddr;
private NamingService namingService;

@ -0,0 +1,64 @@
package com.gitee.sop.test;
import com.alibaba.fastjson.JSON;
import org.junit.Test;
import java.util.HashMap;
import java.util.Map;
/**
* 使用支付宝工具生成签名这里演示的是PKCS1非java
*/
public class AlipayToolPKCS1Test extends TestBase {
String url = "http://localhost:8081";
String appId = "201904035630907729292csharp";
// 平台提供的私钥
String privateKey = "MIIEowIBAAKCAQEA5+OvJxeSzf44NxQ/cl7Ii+BzPg2k6sRcvH4ffOtU5Dzq1/oEvg02nxIhmwOHBZmjbmuUu0aLsfglUTAwqfXftfAKZidshsgj9NNh0/kxk0avRZ1UoljWGz/FxVZA0ogbxxhohPZ9jWcD+eBQcIwF2DtHfAJqWWZrYFnCMeHD8mPzxo2kwXSvDzi0vf9I2tKiYvNG26a9FqeYtPOoi81sdS3+70HOMdxP8ejXtyfnKpKz7Dx506LCIRS5moWS3Q5eTLV3NGX/1CSJ8wpQA2DAQTjVhX5eVu7Yqz12t8W+sjWM/tHUR6cgwYYR10p7tSCeCPzkigjGxKm4cYXWtATQJQIDAQ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B2ZZE0kyKGDqk2Data1XYUY6vsPAU28yRLAaWr/D2H17iyLkxP80VLm6QhifxCadv90Q/Wl1DFfOJQMW6avyQ0so6G0wFq/LJxaFK4iLXQn1RJnmTp6BYiJMmK2BhFbRzw8ssMoF6ad2rr";
// 公共请求参数
Map<String, String> params = new HashMap<String, String>();
{
params.put("app_id", appId);
params.put("method", "alipay.story.get");
params.put("format", "json");
params.put("charset", "utf-8");
params.put("sign_type", "RSA2");
// 手动改下这里的时间,改成当前时间
params.put("timestamp", "2019-12-28 11:23:29");
params.put("version", "1.0");
// 业务参数
Map<String, String> bizContent = new HashMap<>();
bizContent.put("id", "1");
bizContent.put("name", "葫芦娃");
params.put("biz_content", JSON.toJSONString(bizContent));
}
/**
* 第一步生成请求参数
* 生成后的字符串放到支付宝工具请求参数将上面的privateKey放到商户应用私钥
* 点击开始签名
*/
@Test
public void testFirst() {
System.out.println("请求参数:");
System.out.println(buildParamQuery(params));
}
/**
* 第二步将生成到签名放到sign变量中然后运行本方法
*/
@Test
public void testSecond() {
String sign = "sOK1Kwoq6OmjFoneb6LRgUpX+/uQ9D9gsV1Cgi6aw/ErUWLYqMkESuJ148uV1rk5ms8ok9n4T4LpM7aJEYLo9IguW5eVCQ+ePe3ea6gjEQIZm2fiymfSdasSrrBDN/oLqhFwWRGzTQ5TWAgxpNCLH2zKMc+Z5ir7W6xeA0CcEmhZYXC3fB4MSnPcCbHj4V0LLAoQZZQ3voHpdh+6OYNzMKcrwJTTbukI6LbVPopO44ZanV11ehytKLJB71wGJlvFIMK+N3Gph01JKFvfzOlMmndGiDodOjgSz+aQBIjlcyCea/PXSzr2fa5efvWDX/5QayhWkWQ3/1ocBMj7/d4pMA==";
// 这里用支付宝工具生成
params.put("sign", sign);
System.out.println("----------- 返回结果 -----------");
String responseData = get(url, params);// 发送请求
System.out.println(responseData);
}
}

@ -0,0 +1,64 @@
package com.gitee.sop.test;
import com.alibaba.fastjson.JSON;
import org.junit.Test;
import java.util.HashMap;
import java.util.Map;
/**
* 使用支付宝工具生成签名这里演示的是PKCS8java
*/
public class AlipayToolPKCS8Test extends TestBase {
String url = "http://localhost:8081";
String appId = "2019032617262200001";
// 平台提供的私钥
String privateKey = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCXJv1pQFqWNA/++OYEV7WYXwexZK/J8LY1OWlP9X0T6wHFOvxNKRvMkJ5544SbgsJpVcvRDPrcxmhPbi/sAhdO4x2PiPKIz9Yni2OtYCCeaiE056B+e1O2jXoLeXbfi9fPivJZkxH/tb4xfLkH3bA8ZAQnQsoXA0SguykMRZntF0TndUfvDrLqwhlR8r5iRdZLB6F8o8qXH6UPDfNEnf/K8wX5T4EB1b8x8QJ7Ua4GcIUqeUxGHdQpzNbJdaQvoi06lgccmL+PHzminkFYON7alj1CjDN833j7QMHdPtS9l7B67fOU/p2LAAkPMtoVBfxQt9aFj7B8rEhGCz02iJIBAgMBAAECggEARqOuIpY0v6WtJBfmR3lGIOOokLrhfJrGTLF8CiZMQha+SRJ7/wOLPlsH9SbjPlopyViTXCuYwbzn2tdABigkBHYXxpDV6CJZjzmRZ+FY3S/0POlTFElGojYUJ3CooWiVfyUMhdg5vSuOq0oCny53woFrf32zPHYGiKdvU5Djku1onbDU0Lw8w+5tguuEZ76kZ/lUcccGy5978FFmYpzY/65RHCpvLiLqYyWTtaNT1aQ/9pw4jX9HO9NfdJ9gYFK8r/2f36ZE4hxluAfeOXQfRC/WhPmiw/ReUhxPznG/WgKaa/OaRtAx3inbQ+JuCND7uuKeRe4osP2jLPHPP6AUwQKBgQDUNu3BkLoKaimjGOjCTAwtp71g1oo+k5/uEInAo7lyEwpV0EuUMwLA/HCqUgR4K9pyYV+Oyb8d6f0+Hz0BMD92I2pqlXrD7xV2WzDvyXM3s63NvorRooKcyfd9i6ccMjAyTR2qfLkxv0hlbBbsPHz4BbU63xhTJp3Ghi0/ey/1HQKBgQC2VsgqC6ykfSidZUNLmQZe3J0p/Qf9VLkfrQ+xaHapOs6AzDU2H2osuysqXTLJHsGfrwVaTs00ER2z8ljTJPBUtNtOLrwNRlvgdnzyVAKHfOgDBGwJgiwpeE9voB1oAV/mXqSaUWNnuwlOIhvQEBwekqNyWvhLqC7nCAIhj3yvNQKBgQCqYbeec56LAhWP903Zwcj9VvG7sESqXUhIkUqoOkuIBTWFFIm54QLTA1tJxDQGb98heoCIWf5x/A3xNI98RsqNBX5JON6qNWjb7/dobitti3t99v/ptDp9u8JTMC7penoryLKK0Ty3bkan95Kn9SC42YxaSghzqkt+uvfVQgiNGQKBgGxU6P2aDAt6VNwWosHSe+d2WWXt8IZBhO9d6dn0f7ORvcjmCqNKTNGgrkewMZEuVcliueJquR47IROdY8qmwqcBAN7Vg2K7r7CPlTKAWTRYMJxCT1Hi5gwJb+CZF3+IeYqsJk2NF2s0w5WJTE70k1BSvQsfIzAIDz2yE1oPHvwVAoGAA6e+xQkVH4fMEph55RJIZ5goI4Y76BSvt2N5OKZKd4HtaV+eIhM3SDsVYRLIm9ZquJHMiZQGyUGnsvrKL6AAVNK7eQZCRDk9KQz+0GKOGqku0nOZjUbAu6A2/vtXAaAuFSFx1rUQVVjFulLexkXR3KcztL1Qu2k5pB6Si0K/uwQ=";
// 公共请求参数
Map<String, String> params = new HashMap<String, String>();
{
params.put("app_id", appId);
params.put("method", "alipay.story.get");
params.put("format", "json");
params.put("charset", "utf-8");
params.put("sign_type", "RSA2");
// 手动改下这里的时间,改成当前时间
params.put("timestamp", "2019-12-28 11:23:29");
params.put("version", "1.0");
// 业务参数
Map<String, String> bizContent = new HashMap<>();
bizContent.put("id", "1");
bizContent.put("name", "葫芦娃");
params.put("biz_content", JSON.toJSONString(bizContent));
}
/**
* 第一步生成请求参数
* 生成后的字符串放到支付宝工具请求参数将上面的privateKey放到商户应用私钥
* 点击开始签名
*/
@Test
public void testFirst() {
System.out.println("请求参数:");
System.out.println(buildParamQuery(params));
}
/**
* 第二步将生成到签名放到sign变量中然后运行本方法
*/
@Test
public void testSecond() {
String sign = "Wt80mV3ojQ4++19yUhG1pjElGc5rWRJ0udoPv6yHjDG9h0Ai8/sQx9XaWBfiPR3YU6ZzTznr1gEYeXpJg3X9ptLjkMG3xx5NRkCMTYi9eZ40c8RU13O/mQDDr8can59jYgG3PUCTBSpymBnZsTxAzCuho3p26vm64napu+XlKiWEU1yQz46Ga8hW9EBRFFBWvwSsXqp0ZUuddXIj4nhuRr/miSsGgtGXByRMgOh+FLivZnIZJmjP1fS3Veq4Qp2Pv/V+7r+3DBBclos2OF72O1lrALWA8qrHhyjWyFPuNJv6b7PA0vKUenthSPeKH1qJTmMIqlokRrrrD5Ubt1pDJg==";
// 这里用支付宝工具生成
params.put("sign", sign);
System.out.println("----------- 返回结果 -----------");
String responseData = get(url, params);// 发送请求
System.out.println(responseData);
}
}
Loading…
Cancel
Save