ソースを参照

Merge branch 'master' into 'main'

feature: jar包关闭许可证

See merge request dcuc-tjdsj/approve/approve-gateway!1
dongliang wang 10 ヶ月 前
コミット
c00f7da431
27 ファイル変更1427 行追加0 行削除
  1. 4 0
      .gitignore
  2. 6 0
      Dockerfile
  3. 9 0
      README.md
  4. 219 0
      pom.xml
  5. 63 0
      src/main/assembly/assembly.xml
  6. 11 0
      src/main/assembly/conf/application.yml
  7. 37 0
      src/main/assembly/conf/logback.xml
  8. 19 0
      src/main/java/com/dragonsoft/dcuc/approvegateway/ApproveGatewayApplication.java
  9. 39 0
      src/main/java/com/dragonsoft/dcuc/approvegateway/Constants.java
  10. 125 0
      src/main/java/com/dragonsoft/dcuc/approvegateway/business/BimBusiness.java
  11. 41 0
      src/main/java/com/dragonsoft/dcuc/approvegateway/controller/ApproveErrorController.java
  12. 60 0
      src/main/java/com/dragonsoft/dcuc/approvegateway/controller/ApproveLoginController.java
  13. 154 0
      src/main/java/com/dragonsoft/dcuc/approvegateway/filter/SecurityAccessTokenResolver.java
  14. 59 0
      src/main/java/com/dragonsoft/dcuc/approvegateway/filter/UserInfoForwardForFilter.java
  15. 15 0
      src/main/java/com/dragonsoft/dcuc/approvegateway/pojo/BimLoginReqVO.java
  16. 13 0
      src/main/java/com/dragonsoft/dcuc/approvegateway/pojo/BimLogoutReqVO.java
  17. 18 0
      src/main/java/com/dragonsoft/dcuc/approvegateway/pojo/BimRespExceptionVO.java
  18. 23 0
      src/main/java/com/dragonsoft/dcuc/approvegateway/pojo/BimRespVO.java
  19. 67 0
      src/main/java/com/dragonsoft/dcuc/approvegateway/pojo/BimUserInfoItemRespVO.java
  20. 26 0
      src/main/java/com/dragonsoft/dcuc/approvegateway/pojo/BimUserInfoReqVO.java
  21. 23 0
      src/main/java/com/dragonsoft/dcuc/approvegateway/pojo/BimUserInfoRespVO.java
  22. 45 0
      src/main/java/com/dragonsoft/dcuc/approvegateway/properties/DcucApproveProperties.java
  23. 205 0
      src/main/java/com/dragonsoft/dcuc/approvegateway/util/ApiGwUtils.java
  24. 39 0
      src/main/resources/META-INF/additional-spring-configuration-metadata.json
  25. 80 0
      src/main/resources/application-base.yml
  26. 14 0
      src/main/resources/application.yml
  27. 13 0
      src/test/java/com/dragonsoft/dcuc/approvegateway/ApproveGatewayApplicationTests.java

+ 4 - 0
.gitignore

@@ -0,0 +1,4 @@
+.idea
+target
+*.iml
+logs

+ 6 - 0
Dockerfile

@@ -0,0 +1,6 @@
+# 基础镜像为Jenkins构建时选择的镜像
+FROM bus.ga/base/dragon-java:jdk8-alpine-arm64
+# ${pomVersion}对应pom里的数字version,如:1.0.0
+ADD target/approve-gateway-${pomVersion}-SNAPSHOT.tar.gz /opt/docker/
+RUN mv /opt/docker/approve-gateway-${pomVersion}-SNAPSHOT /opt/docker/approve-gateway
+ENTRYPOINT ["/opt/docker/approve-gateway/bin/start.sh"]

+ 9 - 0
README.md

@@ -0,0 +1,9 @@
+# 审批网关服务组件
+## 简介
+1. 为审批服务提供转发请求
+2. 登陆用户处理
+## 更新日志
+### 1.0.2
+  - 修复无法获取真实用户iP
+### 1.0.3
+  - 新增对接华为认证

+ 219 - 0
pom.xml

@@ -0,0 +1,219 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>com.dragonsoft.dcuc</groupId>
+    <artifactId>approve-gateway</artifactId>
+    <version>1.3.0-tjdsj-SNAPSHOT</version>
+    <name>approve-gateway</name>
+    <description>approve-gateway</description>
+    <properties>
+        <!--revisions需写死,用于标识打包的版本号,不可删除-->
+        <revision>1.3.0-tjdsj-SNAPSHOT</revision>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <maven.compiler.source>1.8</maven.compiler.source>
+        <maven.compiler.target>1.8</maven.compiler.target>
+    </properties>
+
+    <dependencyManagement>
+        <dependencies>
+            <!-- 导入duceap-cloud 2.1 POM定义-->
+            <dependency>
+                <groupId>com.dragonsoft</groupId>
+                <artifactId>duceap-cloud-parent</artifactId>
+                <version>2.1.0-SNAPSHOT</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+        </dependencies>
+    </dependencyManagement>
+    <dependencies>
+        <dependency>
+            <artifactId>approve-common</artifactId>
+            <groupId>com.dragonsoft.dcuc</groupId>
+            <version>1.0.0-SNAPSHOT</version>
+            <exclusions>
+                <exclusion>
+                    <groupId>com.dragonsoft</groupId>
+                    <artifactId>duceap-boot-starter-web</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>com.dragonsoft</groupId>
+            <artifactId>duceap-cloud-starter</artifactId>
+            <exclusions>
+                <exclusion>
+                    <artifactId>HdrHistogram</artifactId>
+                    <groupId>org.hdrhistogram</groupId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-zuul</artifactId>
+            <version>2.0.0.M2</version>
+        </dependency>
+
+        <!--配置处理-->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-configuration-processor</artifactId>
+            <optional>true</optional>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.junit.platform</groupId>
+            <artifactId>junit-platform-launcher</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <!-- dcuc登陆 -->
+        <dependency>
+            <groupId>com.dragonsoft</groupId>
+            <artifactId>duceap-security-dcuc</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.dragonsoft</groupId>
+            <artifactId>duceap-security-dids</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <version>1.18.12</version>
+            <scope>provided</scope>
+        </dependency>
+    </dependencies>
+
+    <repositories>
+        <repository>
+            <id>duceap-releases</id>
+            <name>Team Nexus Release Repository</name>
+            <url>http://192.168.6.13:8081/nexus/content/groups/public</url>
+            <releases>
+                <enabled>true</enabled>
+                <updatePolicy>always</updatePolicy>
+            </releases>
+            <snapshots>
+                <enabled>true</enabled>
+                <updatePolicy>always</updatePolicy>
+            </snapshots>
+        </repository>
+    </repositories>
+
+    <distributionManagement>
+        <snapshotRepository>
+            <id>duceap-snapshots</id>
+            <name>Team Nexus Snapshot Repository</name>
+            <url>http://192.168.6.13:8081/nexus/content/repositories/duceap-snapshots</url>
+            <uniqueVersion>false</uniqueVersion>
+        </snapshotRepository>
+    </distributionManagement>
+    <profiles>
+        <profile>
+            <id>jar</id>
+            <activation>
+                <activeByDefault>true</activeByDefault>
+            </activation>
+            <properties>
+                <project.packaging>jar</project.packaging>
+            </properties>
+            <build>
+                <plugins>
+                    <plugin>
+                        <artifactId>maven-dependency-plugin</artifactId>
+                        <version>2.6</version>
+                        <executions>
+                            <execution>
+                                <id>copy-libs</id>
+                                <phase>package</phase>
+                                <goals>
+                                    <goal>copy-dependencies</goal>
+                                </goals>
+                                <configuration>
+                                    <!--<excludeScope>provided</excludeScope>-->
+                                    <outputDirectory>${project.build.directory}/lib</outputDirectory>
+                                    <!--取消依赖包的时间戳-->
+                                    <useBaseVersion>true</useBaseVersion>
+                                    <!--排除licenseignore包,用来禁用许可开关,防止生产环境通过关闭开关,绕过许可-->
+                                    <!-- <excludeArtifactIds>duceap-support-licenseignore</excludeArtifactIds>-->
+                                </configuration>
+                            </execution>
+                            <execution>
+                                <id>unpack</id>
+                                <phase>package</phase>
+                                <goals>
+                                    <goal>unpack</goal>
+                                </goals>
+                                <configuration>
+                                    <artifactItems>
+                                        <artifactItem>
+                                            <groupId>com.dragonsoft</groupId>
+                                            <artifactId>duceap-base</artifactId>
+                                            <!--根据框架版本修改-->
+                                            <version>2.1.0-SNAPSHOT</version>
+                                            <!--<version>2.1.0-SNAPSHOT</version>-->
+                                            <outputDirectory>${project.build.directory}/temp</outputDirectory>
+                                            <!--加入平台的启动脚本-->
+                                            <includes>META-INF/scripts/**</includes>
+                                        </artifactItem>
+                                    </artifactItems>
+                                </configuration>
+                            </execution>
+                        </executions>
+                    </plugin>
+                    <plugin>
+                        <artifactId>maven-assembly-plugin</artifactId>
+                        <version>2.5.5</version>
+                        <executions>
+                            <execution>
+                                <id>make-assembly</id>
+                                <phase>package</phase>
+                                <goals>
+                                    <goal>single</goal>
+                                </goals>
+                                <configuration>
+                                    <finalName>${project.name}-${project.version}</finalName>
+                                    <appendAssemblyId>false</appendAssemblyId>
+                                    <!--配置描述文件路径-->
+                                    <descriptor>src/main/assembly/assembly.xml</descriptor>
+                                </configuration>
+                            </execution>
+                        </executions>
+                    </plugin>
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-jar-plugin</artifactId>
+                        <version>2.4</version>
+                        <configuration>
+                            <archive>
+                                <manifest>
+                                    <!--运行jar包时运行的主类,要求类全名-->
+                                    <mainClass>com.dragonsoft.dcuc.approvegateway.ApproveGatewayApplication</mainClass>
+                                    <addClasspath>true</addClasspath>
+                                    <!--取消MANIFEST.MF中classpath下的时间戳-->
+                                    <useUniqueVersions>false</useUniqueVersions>
+                                </manifest>
+                            </archive>
+                        </configuration>
+                    </plugin>
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-compiler-plugin</artifactId>
+                        <version>3.6.0</version>
+                        <configuration>
+                            <source>8</source>
+                            <target>8</target>
+                        </configuration>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+    </profiles>
+</project>

+ 63 - 0
src/main/assembly/assembly.xml

@@ -0,0 +1,63 @@
+<!--
+ - Copyright 1999-2011 Alibaba Group.
+ -
+ - Licensed 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.
+-->
+<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
+          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+          xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
+    <id>assembly</id>
+    <formats>
+        <format>tar.gz</format>
+    </formats>
+    <includeBaseDirectory>true</includeBaseDirectory>
+    <fileSets>
+        <fileSet>
+            <directory>${project.build.directory}/temp/META-INF/scripts/</directory>
+            <outputDirectory>/bin</outputDirectory>
+            <includes>
+                <include>*.sh</include>
+                <include>*.bat</include>
+            </includes>
+            <fileMode>0755</fileMode>
+        </fileSet>
+        <fileSet>
+            <directory>src/main/webapp</directory>
+            <outputDirectory>web</outputDirectory>
+            <fileMode>0755</fileMode>
+        </fileSet>
+        <fileSet>
+            <directory>src/main/assembly/conf</directory>
+            <outputDirectory>conf</outputDirectory>
+            <fileMode>0755</fileMode>
+        </fileSet>
+        <fileSet>
+            <directory>src/main/assembly/libs</directory>
+            <outputDirectory>libs</outputDirectory>
+            <fileMode>0755</fileMode>
+        </fileSet>
+        <fileSet>
+            <directory>${project.build.directory}/lib</directory>
+            <outputDirectory>lib</outputDirectory>
+            <fileMode>0755</fileMode>
+        </fileSet>
+        <fileSet>
+            <directory>${project.build.directory}</directory>
+            <outputDirectory>lib</outputDirectory>
+            <includes>
+                <include>*.jar</include>
+            </includes>
+            <fileMode>0755</fileMode>
+        </fileSet>
+    </fileSets>
+</assembly>

+ 11 - 0
src/main/assembly/conf/application.yml

@@ -0,0 +1,11 @@
+spring:
+  profiles:
+    include: base
+#apollo配置
+apollo:
+  autoUpdateInjectedSpringProperties: false
+  bootstrap:
+    enabled: true
+    namespaces: application,dragonsoft.dcuc
+  cluster: default
+  meta: http://192.168.10.80:8081

+ 37 - 0
src/main/assembly/conf/logback.xml

@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration>
+    <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
+        <encoder>
+            <pattern>%date{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
+        </encoder>
+    </appender>
+
+    <appender name="rollingFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <file>logs/dcuc-approve.log</file>
+        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+            <fileNamePattern>logs/dcuc-approve.%d{yyyy-MM-dd}.log</fileNamePattern>
+        </rollingPolicy>
+        <encoder>
+            <pattern>%date{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
+        </encoder>
+    </appender>
+
+    <!-- project default level -->
+    <logger name="java.sql.Connection" level="${logback.level:-INFO}"/>
+    <logger name="java.sql.Statement" level="${logback.level:-INFO}"/>
+    <logger name="java.sql.PreparedStatement" level="${logback.level:-INFO}"/>
+    <logger name="com.baomidou.mybatisplus" level="${logback.level:-DEBUG}"/>
+    <logger name="com.dragonsoft" level="${logback.level:-DEBUG}"/>
+    <logger name="com.dragonsoft.kafka" level="${logback.level:-WARN}"/>
+    <logger name="org.apache.kafka" level="${logback.level:-WARN}"/>
+    <logger name="com.dragonsoft.duceap.security.dcuc.filter" level="${logback.level:-DEBUG}"/>
+
+
+    <!--log4jdbc -->
+    <logger name="jdbc.sqltiming" level="${logback.level:-INFO}"/>
+
+    <root level="${logback.level:-INFO}">
+        <appender-ref ref="console"/>
+        <appender-ref ref="rollingFile"/>
+    </root>
+</configuration>

+ 19 - 0
src/main/java/com/dragonsoft/dcuc/approvegateway/ApproveGatewayApplication.java

@@ -0,0 +1,19 @@
+package com.dragonsoft.dcuc.approvegateway;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.autoconfigure.domain.EntityScan;
+import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
+import org.springframework.cloud.netflix.zuul.EnableZuulServer;
+
+@SpringBootApplication(scanBasePackages = "com.dragonsoft.*")
+@EntityScan(basePackages = "com.dragonsoft.*")
+@EnableZuulProxy
+@EnableZuulServer
+public class ApproveGatewayApplication {
+
+    public static void main(String[] args) {
+        SpringApplication.run(ApproveGatewayApplication.class, args);
+    }
+
+}

+ 39 - 0
src/main/java/com/dragonsoft/dcuc/approvegateway/Constants.java

@@ -0,0 +1,39 @@
+package com.dragonsoft.dcuc.approvegateway;
+
+/**
+ * <p>
+ * 常量
+ * </p>
+ *
+ * @author huangzqa
+ * @date 2021/6/21
+ */
+public final class Constants {
+
+    /**
+     * 用户令牌
+     */
+    public static final String USER_TOKEN = "userToken";
+
+    /**
+     * 应用令牌
+     */
+    public static final String APP_TOKEN = "appToken";
+
+    /**
+     * BIM token
+     */
+    public static final String BIM_TOKEN = "bimToken";
+
+    /**
+     * 华为
+     */
+    public static final String HUAWEI = "huawei";
+
+    /**
+     * 获取用户信息路径
+     */
+    public static final String API_USER_INFO = "/api/user/info";
+
+
+}

+ 125 - 0
src/main/java/com/dragonsoft/dcuc/approvegateway/business/BimBusiness.java

@@ -0,0 +1,125 @@
+package com.dragonsoft.dcuc.approvegateway.business;
+
+import cn.hutool.core.util.StrUtil;
+import cn.hutool.http.HttpRequest;
+import com.dragonsoft.dcuc.approvegateway.pojo.*;
+import com.dragonsoft.dcuc.approvegateway.properties.DcucApproveProperties;
+import com.dragonsoft.duceap.commons.util.UUIDUtils;
+import com.dragonsoft.duceap.commons.util.json.JsonUtils;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ * 竹云认证相关业务
+ * </p>
+ *
+ * @author huangzqa
+ * @date 2021/6/21
+ */
+@Slf4j
+@Service
+public class BimBusiness {
+
+    @Autowired
+    private DcucApproveProperties dcucApproveProperties;
+
+    /**
+     * 获取 token
+     *
+     * @return token
+     */
+    public String getToken() {
+        String url = dcucApproveProperties.getBimIdentityUrl() + "/api/rest/management/ExtApiMgmtAuthService/login";
+
+        BimLoginReqVO bimLoginReqVo = new BimLoginReqVO();
+        bimLoginReqVo.setLoginId(dcucApproveProperties.getBimLoginId());
+        bimLoginReqVo.setSecretKey(dcucApproveProperties.getBimSecretKey());
+
+        String requestJson = JsonUtils.toJSONString(bimLoginReqVo);
+        log.debug("Bim login request:{}", requestJson);
+        String respJson = HttpRequest.post(url)
+                .body(requestJson)
+                .execute()
+                .body();
+        log.debug("Bim login respJson:{}", respJson);
+
+        BimRespVO bimRespVo = JsonUtils.parseObject(respJson, BimRespVO.class);
+        if (!bimRespVo.getSuccess()) {
+            log.error("Bim login token error :{}", respJson);
+            return "";
+        }
+
+        Object data = bimRespVo.getData();
+        return (String) data;
+    }
+
+    /**
+     * 退出 token
+     *
+     * @param token token
+     */
+    public void logoutToken(String token) {
+
+        String url = dcucApproveProperties.getBimIdentityUrl() + "/api/rest/management/ExtApiMgmtAuthService/logout";
+
+        BimLogoutReqVO bimLogoutReqVo = new BimLogoutReqVO();
+        bimLogoutReqVo.setToken(token);
+
+        String requestJson = JsonUtils.toJSONString(bimLogoutReqVo);
+        log.debug("Bim logout requestJson:{}", requestJson);
+        String respJson = HttpRequest.post(url)
+                .body(requestJson)
+                .execute()
+                .body();
+        log.debug("Bim logout respJson:{}", respJson);
+
+        BimRespVO bimRespVo = JsonUtils.parseObject(respJson, BimRespVO.class);
+        if (!bimRespVo.getSuccess()) {
+            log.error("Bim logout token error :{}", respJson);
+        }
+    }
+
+
+    /**
+     * 获取用户信息
+     *
+     * @param userToken 用户令牌
+     * @param token     token
+     * @return 用户信息
+     */
+    public BimUserInfoItemRespVO getUserInfoByUserToken(String userToken, String token) {
+
+        if (StrUtil.isBlank(userToken)) {
+            throw new IllegalArgumentException("UserToken is blank.");
+        }
+
+        String messageId = UUIDUtils.getUUID();
+
+        BimUserInfoReqVO bimUserInfoReqVO = new BimUserInfoReqVO();
+        bimUserInfoReqVO.setToken(token);
+        bimUserInfoReqVO.setMessageId(messageId);
+        bimUserInfoReqVO.setUserToken(userToken);
+
+        String reqJson = JsonUtils.toJSONString(bimUserInfoReqVO);
+
+
+        String url = dcucApproveProperties.getBimIdentityUrl() + "/api/rest/customization/ExpApiCustomDragonitService/getUserInfoByUserToken";
+
+        log.info("向认证服务获取用户信息请求url:{}:请求内容 {}", url, reqJson);
+        String postResp = HttpRequest.post(url)
+                .body(reqJson)
+                .execute()
+                .body();
+        log.info("向认证服务获取用户信息请求返回内容 :{}", postResp);
+
+        BimUserInfoRespVO bimRespVo = JsonUtils.parseObject(postResp, BimUserInfoRespVO.class);
+
+        if (!bimRespVo.getSuccess()) {
+            log.error("向认证服务获取用户信息请求 error:{}", postResp);
+        }
+
+        return bimRespVo.getData();
+    }
+}

+ 41 - 0
src/main/java/com/dragonsoft/dcuc/approvegateway/controller/ApproveErrorController.java

@@ -0,0 +1,41 @@
+package com.dragonsoft.dcuc.approvegateway.controller;
+
+import com.dragonsoft.approve.common.HttpCode;
+import com.dragonsoft.duceap.base.entity.http.ResponseStatus;
+import com.dragonsoft.duceap.base.exception.ApplicationException;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * @Author: qiuyu
+ * @Date: 2021/1/15 14:15
+ * @Description:
+ */
+@RestController
+public class ApproveErrorController {
+
+    @GetMapping(value = "/error")
+    public ResponseEntity<ResponseStatus> error(HttpServletRequest request) {
+        Object attribute = request.getAttribute("javax.servlet.error.exception");
+        Throwable throwable = (Throwable) attribute;
+
+        if (throwable != null) {
+            if (throwable.getCause() instanceof ApplicationException) {
+                ApplicationException ex = (ApplicationException) throwable.getCause();
+                int status = ex.getStatusCode() == 0 ? 500 : ex.getStatusCode();
+                assert HttpStatus.resolve(HttpCode.PARAM_VERIFY_ERROR.getCode()) != null;
+                return new ResponseEntity<>(new ResponseStatus(String.valueOf(status), ex.getMessage()), HttpStatus.resolve(HttpCode.PARAM_VERIFY_ERROR.getCode()));
+            } else {
+                return new ResponseEntity<>(ResponseStatus.fail("500", "未知异常[" + throwable.getMessage() + "]"), HttpStatus.BAD_GATEWAY);
+            }
+        } else {
+            return new ResponseEntity<>(ResponseStatus.fail("500", "未知异常"), HttpStatus.BAD_GATEWAY);
+        }
+
+
+    }
+}

+ 60 - 0
src/main/java/com/dragonsoft/dcuc/approvegateway/controller/ApproveLoginController.java

@@ -0,0 +1,60 @@
+package com.dragonsoft.dcuc.approvegateway.controller;
+
+import com.dragonsoft.dcuc.client.logout.DcucLogoutHandler;
+import com.dragonsoft.dids.client.utils.PropUtils;
+import com.dragonsoft.duceap.base.entity.http.ResponseLink;
+import com.dragonsoft.duceap.commons.util.string.StringUtils;
+import com.dragonsoft.duceap.security.dcuc.DcucProperties;
+import com.dragonsoft.duceap.security.dids.DidsProperties;
+import com.dragonsoft.duceap.web.SecurityProperties;
+import com.dragonsoft.duceap.web.utils.RequestUtils;
+import com.dragonsoft.duceap.web.utils.ResponseUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.net.URLEncoder;
+
+/**
+ * @author lidr
+ * @date 2021/2/24
+ */
+@RestController
+public class ApproveLoginController {
+    @Autowired(required = false)
+    private DidsProperties didsProperties;
+    @Autowired(required = false)
+    private DcucProperties dcucProperties;
+    @Autowired
+    SecurityProperties securityProperties;
+
+    @RequestMapping({"/gateway/logout"})
+    public void logout(HttpServletRequest request, HttpServletResponse response) throws Exception {
+        String type = securityProperties.getType();
+        if (type.equalsIgnoreCase("dcuc")) {
+            String redirectUrl = request.getParameter("redirectUrl") != null ? request.getParameter("redirectUrl") : this.dcucProperties.getServerName();
+            String logoutUrl = this.dcucProperties.getCasServerUrlPrefix() + "/logout?service=" + URLEncoder.encode(redirectUrl, "UTF-8");
+            ResponseLink responseLink = ResponseLink.logout(logoutUrl);
+            if (RequestUtils.isXmlHttpRequest(request)) {
+                request.getSession().invalidate();
+                ResponseUtils.outJson(responseLink, response);
+            } else {
+                DcucLogoutHandler.logout(request, response, redirectUrl);
+            }
+        } else {
+            String ssoUrl = PropUtils.getInstance().getConfigItem("dids2.SSOLoginUrl").replace("/login", "");
+            String redirectUrl = StringUtils.defaultIfEmpty(request.getParameter("redirectUrl"), StringUtils.substringBeforeLast(this.didsProperties.getSSOServiceUrl(), "/login"));
+            String logoutUrl = ssoUrl + "/logout?service=" + redirectUrl;
+            ResponseLink responseLink = ResponseLink.logout(logoutUrl);
+            if (RequestUtils.isXmlHttpRequest(request)) {
+                request.getSession().invalidate();
+                ResponseUtils.outJson(responseLink, response);
+            } else {
+                request.getSession().invalidate();
+                response.sendRedirect(logoutUrl);
+            }
+        }
+    }
+}

+ 154 - 0
src/main/java/com/dragonsoft/dcuc/approvegateway/filter/SecurityAccessTokenResolver.java

@@ -0,0 +1,154 @@
+package com.dragonsoft.dcuc.approvegateway.filter;
+
+import cn.hutool.core.util.StrUtil;
+import com.alibaba.fastjson.JSON;
+import com.dragonsoft.approve.component.TokenOperate;
+import com.dragonsoft.approve.model.TokenInfo;
+import com.dragonsoft.dcuc.approvegateway.Constants;
+import com.dragonsoft.dcuc.approvegateway.business.BimBusiness;
+import com.dragonsoft.dcuc.approvegateway.pojo.BimUserInfoItemRespVO;
+import com.dragonsoft.dcuc.approvegateway.properties.DcucApproveProperties;
+import com.dragonsoft.duceap.base.api.security.ISecurityAccessTokenResolver;
+import com.dragonsoft.duceap.base.entity.security.BaseSecurityUser;
+import com.dragonsoft.duceap.base.entity.security.SecurityUser;
+import com.dragonsoft.duceap.commons.util.UrlMatcher;
+import com.dragonsoft.duceap.commons.util.json.JsonUtils;
+import com.dragonsoft.duceap.security.jwt.SecurityUserCacheResolver;
+import com.dragonsoft.duceap.security.jwt.securityaccess.SecurityAccessTokenProperties;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang.time.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.web.ServerProperties;
+import org.springframework.stereotype.Component;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.Date;
+
+/**
+ * @author huangzqa
+ * @date 2021/4/15
+ **/
+@Slf4j
+@Component
+public class SecurityAccessTokenResolver implements ISecurityAccessTokenResolver {
+
+    @Autowired
+    private SecurityAccessTokenProperties secAccessProp;
+
+    @Autowired(required = false)
+    private SecurityUserCacheResolver cacheResolver;
+
+    @Autowired
+    private ServerProperties serverProperties;
+
+    @Autowired
+    private BimBusiness bimBusiness;
+
+    @Autowired
+    private DcucApproveProperties dcucApproveProperties;
+
+    @Autowired
+    private TokenOperate tokenComponent;
+
+
+    @Override
+    public BaseSecurityUser resolve(HttpServletRequest request) {
+        String contextPath = serverProperties.getServlet().getContextPath();
+        String requestUri = request.getRequestURI();
+        log.debug("Security filter origin uri:{}", requestUri);
+
+        // 去除上下文
+        requestUri = requestUri.substring(contextPath.length());
+
+        log.debug("Security filter not context uri:{}", requestUri);
+        String huaweiLoginFilterUrl = dcucApproveProperties.getHuaweiLoginFilterUrl();
+        String[] splitUrls = huaweiLoginFilterUrl.split("\\|");
+        log.debug("splitUrls:{} .", JsonUtils.toJSONString(splitUrls));
+
+        if (!requestUri.equalsIgnoreCase(Constants.API_USER_INFO)) {
+            if (UrlMatcher.matches(requestUri, splitUrls)) {
+                log.debug("URI:{} Not need get user info.", requestUri);
+                return null;
+            }
+        }
+
+
+        String userToken = request.getHeader(secAccessProp.getUserTokenHeaderName());
+        String appToken = request.getHeader(Constants.APP_TOKEN);
+
+        log.debug("userToken:{},appToken:{}", userToken, appToken);
+
+        if (cacheResolver != null) {
+            //从缓存中取
+            SecurityUser securityUserCache = cacheResolver.getIfPresent(userToken);
+
+            if (securityUserCache != null) {
+                log.info("Cache securityUserCache:{}", JsonUtils.toJSONString(securityUserCache));
+
+                return securityUserCache;
+            }
+        }
+
+        if (StrUtil.isBlank(userToken)) {
+            return null;
+        }
+        TokenInfo tokenOauth = getTokenOauth();
+        String token = tokenOauth.getAccessToken();
+        BimUserInfoItemRespVO userInfoItemRespVO = bimBusiness.getUserInfoByUserToken(userToken, token);
+        String sfzh = userInfoItemRespVO.getSfzh();
+
+        log.info("idcard:{}, userInfo :{}", sfzh, JsonUtils.toJSONString(userInfoItemRespVO));
+
+        SecurityUser securityUser = new SecurityUser();
+        // 这里使用的是华为认证的id不是用户中心的id
+        securityUser.setId(userInfoItemRespVO.getYhId());
+        securityUser.setName(userInfoItemRespVO.getXm());
+        securityUser.setUserName(userInfoItemRespVO.getSfzh());
+        securityUser.setPoliceNo(userInfoItemRespVO.getJh());
+        securityUser.setIdcard(userInfoItemRespVO.getSfzh());
+        securityUser.setSecurityOrg(userInfoItemRespVO.getDwdm());
+        securityUser.setSecurityOrgName(userInfoItemRespVO.getDwmc());
+
+        //放入缓存
+        if (cacheResolver != null) {
+            cacheResolver.put(userToken, securityUser);
+        }
+
+        log.info("return idcard:{}, securityUser :{}", sfzh, JsonUtils.toJSONString(securityUser));
+
+        return securityUser;
+    }
+
+    /**
+     * 获取token信息
+     *
+     * @return token信息
+     */
+    public TokenInfo getTokenOauth() {
+        TokenInfo tokenInfo = tokenComponent.fetchTokenInfo();
+
+        Date currentDate = new Date();
+        //token正常直接返回
+        if (null != tokenInfo && currentDate.before(tokenInfo.getOverdueTime())) {
+            log.debug("HwTokenInfo=【{}】", JSON.toJSONString(tokenInfo));
+            return tokenInfo;
+        }
+
+        if (tokenInfo != null) {
+            String accessToken = tokenInfo.getAccessToken();
+            bimBusiness.logoutToken(accessToken);
+        }
+
+        //调用竹云认证获取 token
+        String token = bimBusiness.getToken();
+        tokenInfo = new TokenInfo();
+        tokenInfo.setAccessToken(token);
+
+        //设置缓存
+        Integer bimTokenExpireSecond = dcucApproveProperties.getBimTokenExpireSecond();
+        tokenInfo.setOverdueTime(DateUtils.addSeconds(currentDate, bimTokenExpireSecond));
+        tokenComponent.pushHwTokenInfo(tokenInfo);
+        return tokenInfo;
+    }
+
+}

+ 59 - 0
src/main/java/com/dragonsoft/dcuc/approvegateway/filter/UserInfoForwardForFilter.java

@@ -0,0 +1,59 @@
+package com.dragonsoft.dcuc.approvegateway.filter;
+
+import com.dragonsoft.duceap.base.entity.security.BaseSecurityUser;
+import com.dragonsoft.duceap.base.utils.UserContextUtils;
+import com.dragonsoft.duceap.commons.util.ip.IpUtils;
+import com.dragonsoft.duceap.security.jwt.JwtTokenUtils;
+import com.dragonsoft.duceap.security.jwt.algorithm.AlgorithmType;
+import com.netflix.zuul.ZuulFilter;
+import com.netflix.zuul.context.RequestContext;
+import com.netflix.zuul.exception.ZuulException;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.cloud.netflix.zuul.filters.support.FilterConstants;
+import org.springframework.stereotype.Component;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.Map;
+
+/**
+ * <p>
+ * 设置用户信息,获取请求者真实IP
+ * </p>
+ *
+ * @author huangzqa
+ * @date 2021/6/29
+ */
+@Slf4j
+@Component
+public class UserInfoForwardForFilter extends ZuulFilter {
+    @Override
+    public String filterType() {
+        return FilterConstants.PRE_TYPE;
+    }
+
+    @Override
+    public int filterOrder() {
+        return 0;
+    }
+
+    @Override
+    public boolean shouldFilter() {
+        return true;
+    }
+
+    @Override
+    public Object run() throws ZuulException {
+        RequestContext currentContext = RequestContext.getCurrentContext();
+        HttpServletRequest request = currentContext.getRequest();
+        String realIpAdrress = IpUtils.getRealIpAdrress(request);
+        Map<String, String> zuulRequestHeaders = currentContext.getZuulRequestHeaders();
+        zuulRequestHeaders.put("HTTP_X_FORWARDED_FOR", realIpAdrress);
+        BaseSecurityUser currentUser = UserContextUtils.getCurrentUser();
+        if (currentUser != null) {
+            String jwtToken = JwtTokenUtils.getAlgorithmGen(AlgorithmType.HS256.name()).sign(currentUser);
+            currentContext.addZuulRequestHeader(JwtTokenUtils.AUTHORIZATION_HEADER, JwtTokenUtils.TOKEN_PREFIX + jwtToken);
+            log.info("登录jwtToken:{}", jwtToken);
+        }
+        return null;
+    }
+}

+ 15 - 0
src/main/java/com/dragonsoft/dcuc/approvegateway/pojo/BimLoginReqVO.java

@@ -0,0 +1,15 @@
+package com.dragonsoft.dcuc.approvegateway.pojo;
+
+import lombok.Data;
+
+/**
+ * @author huangzqa
+ * @date 2021/4/9
+ **/
+@Data
+public class BimLoginReqVO {
+
+    private String loginId;
+
+    private String secretKey;
+}

+ 13 - 0
src/main/java/com/dragonsoft/dcuc/approvegateway/pojo/BimLogoutReqVO.java

@@ -0,0 +1,13 @@
+package com.dragonsoft.dcuc.approvegateway.pojo;
+
+import lombok.Data;
+
+/**
+ * @author huangzqa
+ * @date 2021/4/9
+ **/
+@Data
+public class BimLogoutReqVO {
+
+    private String token;
+}

+ 18 - 0
src/main/java/com/dragonsoft/dcuc/approvegateway/pojo/BimRespExceptionVO.java

@@ -0,0 +1,18 @@
+package com.dragonsoft.dcuc.approvegateway.pojo;
+
+import lombok.Data;
+
+/**
+ * @author huangzqa
+ * @date 2021/4/9
+ **/
+@Data
+public class BimRespExceptionVO {
+
+    private String name;
+
+    private String message;
+
+    private String trace;
+
+}

+ 23 - 0
src/main/java/com/dragonsoft/dcuc/approvegateway/pojo/BimRespVO.java

@@ -0,0 +1,23 @@
+package com.dragonsoft.dcuc.approvegateway.pojo;
+
+import lombok.Data;
+
+/**
+ * @author huangzqa
+ * @date 2021/4/9
+ **/
+@Data
+public class BimRespVO {
+
+    private Boolean success;
+
+    private Object data;
+
+    private String errorCode;
+
+    private String errorMessage;
+
+    private BimRespExceptionVO errorException;
+
+
+}

+ 67 - 0
src/main/java/com/dragonsoft/dcuc/approvegateway/pojo/BimUserInfoItemRespVO.java

@@ -0,0 +1,67 @@
+package com.dragonsoft.dcuc.approvegateway.pojo;
+
+import lombok.Data;
+
+/**
+ * @author huangzqa
+ * @date 2021/4/9
+ **/
+@Data
+public class BimUserInfoItemRespVO {
+
+    /**
+     * 消息id
+     */
+    private String messageId;
+
+    /**
+     * true表示查询成功
+     */
+    private String result;
+
+    /**
+     * 结果描述
+     */
+    private String resultDescription;
+
+    /**
+     * 用户id
+     */
+    private String yhId;
+
+    /**
+     * 姓名
+     */
+    private String xm;
+
+    /**
+     * 警号
+     */
+    private String jh;
+
+    /***
+     * 身份证号
+     */
+    private String sfzh;
+
+    /**
+     * 单位代码
+     */
+    private String dwdm;
+
+    /**
+     * 单位名称
+     */
+    private String dwmc;
+
+    /**
+     * 职位
+     */
+    private String zw;
+
+    /**
+     * 用户名
+     */
+    private String yhm;
+
+}

+ 26 - 0
src/main/java/com/dragonsoft/dcuc/approvegateway/pojo/BimUserInfoReqVO.java

@@ -0,0 +1,26 @@
+package com.dragonsoft.dcuc.approvegateway.pojo;
+
+import lombok.Data;
+
+/**
+ * @author huangzqa
+ * @date 2021/4/9
+ **/
+@Data
+public class BimUserInfoReqVO {
+
+    /**
+     * token
+     */
+    private String token;
+
+    /**
+     * 消息ID
+     */
+    private String messageId;
+
+    /**
+     * 用户令牌
+     */
+    private String userToken;
+}

+ 23 - 0
src/main/java/com/dragonsoft/dcuc/approvegateway/pojo/BimUserInfoRespVO.java

@@ -0,0 +1,23 @@
+package com.dragonsoft.dcuc.approvegateway.pojo;
+
+import lombok.Data;
+
+/**
+ * @author huangzqa
+ * @date 2021/4/9
+ **/
+@Data
+public class BimUserInfoRespVO {
+
+    private Boolean success;
+
+    private BimUserInfoItemRespVO data;
+
+    private String errorCode;
+
+    private String errorMessage;
+
+    private BimRespExceptionVO errorException;
+
+
+}

+ 45 - 0
src/main/java/com/dragonsoft/dcuc/approvegateway/properties/DcucApproveProperties.java

@@ -0,0 +1,45 @@
+package com.dragonsoft.dcuc.approvegateway.properties;
+
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+/**
+ * <p>
+ * 审批配置
+ * </p>
+ *
+ * @author huangzqa
+ * @date 2021/6/21
+ */
+@Data
+@ConfigurationProperties(prefix = "dcuc.approve")
+@Component
+public class DcucApproveProperties {
+
+    /**
+     * 竹云认证地址
+     */
+    private String bimIdentityUrl;
+
+    /**
+     * 竹云应用方标识
+     */
+    private String bimLoginId;
+
+    /**
+     * 竹云应用方秘钥
+     */
+    private String bimSecretKey;
+
+    /**
+     * 竹云 token 失效时间(单位秒)
+     */
+    private Integer bimTokenExpireSecond = 9 * 60;
+
+    /**
+     * 华为登陆过滤路径
+     */
+    private String huaweiLoginFilterUrl = "";
+
+}

+ 205 - 0
src/main/java/com/dragonsoft/dcuc/approvegateway/util/ApiGwUtils.java

@@ -0,0 +1,205 @@
+package com.dragonsoft.dcuc.approvegateway.util;
+
+
+import com.alibaba.fastjson.JSON;
+import com.dragonsoft.approve.common.ErrorCode;
+import com.dragonsoft.approve.model.TokenInfo;
+import com.dragonsoft.duceap.base.exception.ApplicationException;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import org.apache.http.HttpException;
+import org.apache.http.HttpResponse;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.ClientProtocolException;
+import org.apache.http.client.entity.UrlEncodedFormEntity;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.utils.URIBuilder;
+import org.apache.http.conn.ssl.AllowAllHostnameVerifier;
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.message.BasicNameValuePair;
+import org.apache.http.protocol.HTTP;
+import org.apache.http.util.EntityUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.X509TrustManager;
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.security.KeyManagementException;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 代码千万行,注释第一行,编码不规范,同事两行泪
+ *
+ * @author huang(jy)
+ * @version 1.0
+ * @date 2020/12/16 19:25
+ */
+public class ApiGwUtils {
+    private static final Logger logger = LoggerFactory.getLogger(ApiGwUtils.class);
+    private final static String GRANT_TYPE = "client_credentials";
+    private final static String SCOPE = "default";
+
+    private static final String DATA_FORMAT = "yyyy-MM-dd HH:mm:ss";
+
+
+    /**
+     * 返回完整的值
+     *
+     * @param clientId
+     * @param clientSecret
+     * @return
+     */
+    public static TokenInfo getHuaweiTokenObj2(String clientId, String clientSecret, String requestUrl) {
+        TokenInfo hwTokenInfo = new TokenInfo();
+        try {
+            hwTokenInfo = getToken(clientId, clientSecret, requestUrl);
+        } catch (HttpException e) {
+            e.printStackTrace();
+        }
+        return hwTokenInfo;
+    }
+
+    /**
+     * 获取Token信息
+     *
+     * @param appKey    用户凭证中的 AppKey
+     * @param secretKey 用户凭证中的 SecretKey
+     * @return HwTokenInfo Token信息
+     */
+    public static TokenInfo getToken(String appKey, String secretKey, String requestUrl) throws HttpException {
+        // 添加请求体内容
+        List<NameValuePair> pairs = new ArrayList<NameValuePair>();
+        pairs.add(new BasicNameValuePair("grant_type", GRANT_TYPE));
+        pairs.add(new BasicNameValuePair("client_id", appKey));
+        pairs.add(new BasicNameValuePair("client_secret", secretKey));
+        pairs.add(new BasicNameValuePair("scope", SCOPE));
+
+        String result = httpsForPostRequest(pairs, requestUrl);
+        return toObject(result, TokenInfo.class);
+    }
+
+
+    /**
+     * 获取token
+     *
+     * @return
+     */
+    public static TokenInfo getAccessToken(String requestUrl, String clientId, String clientSecret) {
+        logger.info("【verifyIdCard】:apigwUrl:{},clientId:{},clientSecret:{}", requestUrl, clientId, clientSecret);
+        TokenInfo tokenInfo = null;
+        try {
+            tokenInfo = ApiGwUtils.getHuaweiTokenObj2(clientId, clientSecret, requestUrl);
+            logger.info("【getAccessToken】获取token接口返回的信息:{}", JSON.toJSONString(tokenInfo));
+        } catch (Exception e) {
+            logger.error("【getAccessToken】获取token接口失败", e);
+            throw new ApplicationException(ErrorCode.HW_ACCESS_TOKEN_FAIL.getCode(), ErrorCode.HW_ACCESS_TOKEN_FAIL.getMsg());
+        }
+        return tokenInfo;
+    }
+
+
+    /**
+     * 刷新AccessToken有效期
+     *
+     * @param appKey       用户凭证中的 AppKey
+     * @param secretKey    用户凭证中的 SecretKey
+     * @param refreshToken Token信息中用于刷新有效期的 refresh_token
+     * @return HwTokenInfo Token信息
+     */
+    public static TokenInfo refreshToken(String appKey, String secretKey, String huaweiUrl, String refreshToken) throws HttpException {
+        // 添加请求体内容
+        List<NameValuePair> pairs = new ArrayList<NameValuePair>();
+        pairs.add(new BasicNameValuePair("grant_type", "refresh_token"));
+        pairs.add(new BasicNameValuePair("client_id", appKey));
+        pairs.add(new BasicNameValuePair("client_secret", secretKey));
+        pairs.add(new BasicNameValuePair("refresh_token", refreshToken));
+
+        String result = httpsForPostRequest(pairs, huaweiUrl);
+        return toObject(result, TokenInfo.class);
+    }
+
+
+    /**
+     * https的POST请求
+     *
+     * @param data
+     * @return
+     * @throws HttpException
+     */
+    public static String httpsForPostRequest(List<NameValuePair> data, String requestUrl) throws HttpException {
+
+        SSLContext sslContext;
+        CloseableHttpClient client;
+        String result = "";
+        try {
+            // 创建Http客户端,设置信任自签名证书
+            sslContext = SSLContext.getInstance("TLSv1.2");
+            sslContext.init(null, new TrustManager[]{TRUST_ALL}, null);
+            SSLConnectionSocketFactory sslSocketFactory = new SSLConnectionSocketFactory(sslContext,
+                    new AllowAllHostnameVerifier());
+            client = HttpClients.custom().setSSLSocketFactory(sslSocketFactory).build();
+
+            // 创建POST请求,添加URL
+            URIBuilder uriBuilder = new URIBuilder(requestUrl);
+            HttpPost httpPost = new HttpPost(uriBuilder.build());
+
+            httpPost.setEntity(new UrlEncodedFormEntity(data, "UTF-8"));
+            // 添加请求头
+            httpPost.setHeader(HTTP.CONTENT_TYPE, "application/x-www-form-urlencoded");
+
+            // 发送请求
+            HttpResponse response = client.execute(httpPost);
+
+
+            // 解析响应内容
+            if (response.getStatusLine().getStatusCode() == 200) {
+                result = EntityUtils.toString((response).getEntity());
+            } else {
+                throw new HttpException(response.getStatusLine() + EntityUtils.toString((response).getEntity()));
+            }
+        } catch (NoSuchAlgorithmException e) {
+            e.printStackTrace();
+        } catch (KeyManagementException e) {
+            e.printStackTrace();
+        } catch (URISyntaxException e) {
+            e.printStackTrace();
+        } catch (ClientProtocolException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return result;
+    }
+
+    private static X509TrustManager TRUST_ALL = new X509TrustManager() {
+        public void checkClientTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException {
+        }
+
+        public void checkServerTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException {
+        }
+
+        public X509Certificate[] getAcceptedIssuers() {
+            return new X509Certificate[0];
+        }
+    };
+
+    public static <T> T toObject(String json, Class<T> valueType) {
+        Gson gson = new GsonBuilder().setDateFormat(DATA_FORMAT).serializeNulls().create();
+        return gson.fromJson(json, valueType);
+    }
+
+    public static void main(String[] args) {
+        String a = "{\"access_token\":\"12\"}";
+        getAccessToken("", "", "");
+        System.out.println();
+    }
+}

+ 39 - 0
src/main/resources/META-INF/additional-spring-configuration-metadata.json

@@ -0,0 +1,39 @@
+{
+  "properties": [
+    {
+      "name": "apollo.meta",
+      "type": "java.lang.String",
+      "description": "apollo配置中心地址(服务端)."
+    },
+    {
+      "name": "app.id",
+      "type": "java.lang.String",
+      "description": "apollo appid,当app.id没有配置情况下将读取spring.application.name值."
+    },
+    {
+      "name": "apollo.bootstrap.namespaces",
+      "type": "java.lang.String",
+      "description": "apollo 命名空间,支持多个逗号隔开。按命名空间顺序依次加载,可用于公共配置."
+    },
+    {
+      "name": "apollo.bootstrap.enabled",
+      "type": "java.lang.String",
+      "description": "apollo 是否启用apollo."
+    },
+    {
+      "name": "apollo.cluster",
+      "type": "java.lang.String",
+      "description": "apollo 集群,默认default."
+    },
+    {
+      "name": "apollo.autoUpdateInjectedSpringProperties",
+      "type": "java.lang.String",
+      "description": "apollo 取消placeholder的自动更新功能(默认true)."
+    },
+    {
+      "name": "duceap.license.enabled",
+      "type": "java.lang.String",
+      "description": "License认证开关,默认开启."
+    }
+  ]
+}

+ 80 - 0
src/main/resources/application-base.yml

@@ -0,0 +1,80 @@
+server:
+  port: 8866
+  servlet:
+    context-path: /approve-gateway
+spring:
+  application:
+    name: approve-gateway
+  cloud:
+    nacos:
+      discovery:
+        server-addr: 127.0.0.1:8848
+
+zuul:
+  retryable: true
+  # 这个配置必须保留,才会传递Authorization,cookie等
+  sensitive-headers:
+  host:
+    connect-timeout-millis: 60000
+    socket-timeout-millis: 60000
+
+ribbon:
+  ConnectTimeout: 60000 # 连接超时时间(ms)
+  ReadTimeout: 60000 # 通信超时时间(ms)
+  OkToRetryOnAllOperations: true # 是否对所有操作重试
+  MaxAutoRetriesNextServer: 2 # 同一服务不同实例的重试次数
+  MaxAutoRetries: 1 # 同一实例的重试次数
+hystrix:
+  command:
+    default:
+      execution:
+        isolation:
+          thread:
+            timeoutInMillisecond: 60000 # 熔断超时时长:6000ms
+
+duceap:
+  license:
+    dataCacheMethod: apollo
+    #配置用来指定license对接的后端项目地址(格式:ip:port/context,如http://10.10.10.10:8080/ctx),默认使用HttpServletRequest.getLocalAddr()方法获取ip地址,应用在docker部署环境中无法获取机子的真实ip地址 考虑以配置参数的形式传入
+    #address: http://10.10.10.10:8080/ctx
+    enabled: false
+  apollo:
+    client:
+      host: http://192.168.10.27:8070 #配置中心地址(portal端)
+  security:
+    ##配置登陆方式,dids、dssoac、dcuc、huawei
+    type: dcuc
+    ##dids登录配置#
+    dids2:
+      ##应用代码
+      appCode: YHZX0000000000000001
+      useSSO: true
+      ##单点登录服务器地址
+      SSOLoginUrl: http://10.201.7.30:9090/didsserver/login
+      ##单点登录服务接口地址
+      SSOValidateUrl: http://10.201.7.30:9090/didsserver/serviceValidate
+      ##对接系统地址(ip:端口/上下文/login) 开发环境中, ip端口需要配置成代理的前端地址(请全程使用真实的ip 而不是localhost或者127.0.0.1,否则会导致登录失败)
+      SSOServiceUrl: http://10.11.0.240:1645/approve-gateway/login
+      accessType: 1
+      ##单点登录服务接口地址
+      webServiceUrl: http://10.201.7.30:9090/didsserver/webservices/
+      jndi: JDBC/DIDS
+      filterType: 1
+      ##若匹配该地址,则无须过滤
+      noFilterUrl: /api/v1/,/v1/,/v2/api-docs,services,hessian,commons,install.action,.xml,/install,/widgets-src/,/authorizationPage.html,/importAuthorizationFile.html,/license/LicenseManagerServlet,/authorizationFile/
+    dcuc:
+      casServerUrlPrefix: http://10.201.1.50:8877/sso
+      serverName: 10.11.0.83:1645 10.11.0.240:1645 10.254.11.185:1645 10.11.0.200:1645 10.11.1.25:1645
+      ignorePattern: '/approve-core/api/*|/approve-core/v1/api/*|/approve-core/v2/*|/js/*|/img/*|/css/*|/*.png|/rest/*|/webSocket/*|/authorizationPage.html|/importAuthorizationFile.html|/license/LicenseManagerServlet|/authorizationFile/|/swagger-ui.html'
+      appCode: YHZX0000000000000001
+      api-url: http://10.201.1.50:8870/dcuc
+  security-access:
+    jwt:
+      enabled: false
+      user-token-header-name: userToken
+dcuc:
+  approve:
+    bim-identity-url: https://127.0.0.1:8443/bim-server
+    bim-login-id: app1
+    bim-secret-key: app1@123
+    huawei-login-filter-url: '/approve-core/api/*|/approve-core/v1/api/*|/approve-core/v2/api/*|/js/*|/img/*|/css/*|/*.png|/rest/*|/webSocket/*|/authorizationPage.html|/importAuthorizationFile.html|/license/LicenseManagerServlet|/authorizationFile/|/swagger-ui.html'

+ 14 - 0
src/main/resources/application.yml

@@ -0,0 +1,14 @@
+spring:
+  profiles:
+    include: base
+#apollo配置
+apollo:
+  autoUpdateInjectedSpringProperties: false
+  bootstrap:
+    enabled: false
+    namespaces: application,dragonsoft.dcuc
+  cluster: default
+  meta: http://192.168.10.80:8081
+duceap:
+  license:
+    enabled: false

+ 13 - 0
src/test/java/com/dragonsoft/dcuc/approvegateway/ApproveGatewayApplicationTests.java

@@ -0,0 +1,13 @@
+package com.dragonsoft.dcuc.approvegateway;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@SpringBootTest
+class ApproveGatewayApplicationTests {
+
+    @Test
+    void contextLoads() {
+    }
+
+}