union-ark-web 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/PROJECT_OVERVIEW.md +405 -0
- package/README.md +177 -0
- package/ark-control/pom.xml +142 -0
- package/ark-control/src/local-mock/java/com/epcc/commons/securityproxy/api/SecurityResult.java +14 -0
- package/ark-control/src/local-mock/java/com/epcc/commons/securityproxy/api/SymmetricalSecurityService.java +11 -0
- package/ark-control/src/local-mock/java/com/epcc/dubbo/result/Result.java +29 -0
- package/ark-control/src/local-mock/java/com/nucc/channel/ark/common/annotation/EnDecryptField.java +16 -0
- package/ark-control/src/local-mock/java/com/nucc/channel/ark/common/annotation/EnDecryptFieldLong.java +17 -0
- package/ark-control/src/local-mock/java/com/nucc/channel/ark/common/annotation/EnDecryptFieldWithTag.java +16 -0
- package/ark-control/src/local-mock/java/com/nucc/channel/ark/common/exception/BaseDataErrorCode.java +26 -0
- package/ark-control/src/local-mock/java/com/nucc/channel/ark/common/exception/CheckException.java +33 -0
- package/ark-control/src/local-mock/java/com/nucc/channel/ark/common/exception/ErrorCode.java +9 -0
- package/ark-control/src/local-mock/java/com/nucc/channel/ark/common/redis/RedisCacheService.java +131 -0
- package/ark-control/src/local-mock/java/com/nucc/channel/ark/common/util/Constant.java +24 -0
- package/ark-control/src/local-mock/java/com/nucc/channel/ark/common/util/ResultUtil.java +9 -0
- package/ark-control/src/local-mock/java/com/union/control/local/sensitive/LocalMockSensitiveProxy.java +40 -0
- package/ark-control/src/local-mock/java/com/union/control/local/sensitive/LocalRedisCacheService.java +45 -0
- package/ark-control/src/local-mock/java/com/union/control/local/sensitive/LocalSensitiveHostConfiguration.java +27 -0
- package/ark-control/src/local-mock/java/com/union/control/local/sensitive/LocalSensitiveProxyConfiguration.java +16 -0
- package/ark-control/src/main/java/com/union/control/ArkControlApplication.java +17 -0
- package/ark-control/src/main/java/com/union/control/dubbo/ProviderAccessLogFilter.java +45 -0
- package/ark-control/src/main/java/com/union/control/mapper/AgentExecutionMapper.java +35 -0
- package/ark-control/src/main/java/com/union/control/mapper/ConversationMapper.java +44 -0
- package/ark-control/src/main/java/com/union/control/mapper/MemoryStoreMapper.java +41 -0
- package/ark-control/src/main/java/com/union/control/mapper/ScheduledTaskMapper.java +96 -0
- package/ark-control/src/main/java/com/union/control/mapper/SensitiveAddressBookDemo.java +31 -0
- package/ark-control/src/main/java/com/union/control/mapper/SensitiveDataDemoMapper.java +24 -0
- package/ark-control/src/main/java/com/union/control/mapper/interceptor/AESInterceptor.java +265 -0
- package/ark-control/src/main/java/com/union/control/mapper/interceptor/AddressBookHandler.java +105 -0
- package/ark-control/src/main/java/com/union/control/schedule/ScheduledExecutionToken.java +55 -0
- package/ark-control/src/main/java/com/union/control/schedule/ScheduledTaskScheduler.java +206 -0
- package/ark-control/src/main/java/com/union/control/service/impl/AgentExecutionServiceImpl.java +212 -0
- package/ark-control/src/main/java/com/union/control/service/impl/AgentProxyServiceImpl.java +143 -0
- package/ark-control/src/main/java/com/union/control/service/impl/ConversationServiceImpl.java +245 -0
- package/ark-control/src/main/java/com/union/control/service/impl/MemoryStoreServiceImpl.java +252 -0
- package/ark-control/src/main/java/com/union/control/service/impl/RunningAnalysisMockServiceImpl.java +301 -0
- package/ark-control/src/main/java/com/union/control/service/impl/ScheduledTaskServiceImpl.java +576 -0
- package/ark-control/src/main/java/com/union/control/service/impl/SensitiveDataDemoServiceImpl.java +144 -0
- package/ark-control/src/main/java/com/union/control/service/sensitive/RedisRevealTokenStore.java +90 -0
- package/ark-control/src/main/java/com/union/control/service/sensitive/SensitiveRevealProcessor.java +319 -0
- package/ark-control/src/main/java/com/union/control/service/sensitive/SensitiveRevealServiceImpl.java +72 -0
- package/ark-control/src/main/java/com/union/control/utils/AgentSupport.java +103 -0
- package/ark-control/src/main/java/com/union/control/utils/security/SymmetricalSecurityUtils.java +160 -0
- package/ark-control/src/main/resources/META-INF/dubbo/com.alibaba.dubbo.rpc.Filter +1 -0
- package/ark-control/src/main/resources/application.properties +4 -0
- package/ark-control/src/main/resources/application.yml +32 -0
- package/ark-control/src/main/resources/dubbo-provider.xml +20 -0
- package/ark-control/src/main/resources/mapper/AgentExecutionMapper.xml +75 -0
- package/ark-control/src/main/resources/mapper/ConversationMapper.xml +110 -0
- package/ark-control/src/main/resources/mapper/MemoryStoreMapper.xml +74 -0
- package/ark-control/src/main/resources/mapper/ScheduledTaskMapper.xml +286 -0
- package/ark-control/src/main/resources/mapper/SensitiveDataDemoMapper.xml +55 -0
- package/ark-control/src/main/resources/schema.sql +146 -0
- package/ark-control/src/test/java/com/union/control/AgentExecutionServiceTest.java +170 -0
- package/ark-control/src/test/java/com/union/control/ArkControlStructureContractTest.java +107 -0
- package/ark-control/src/test/java/com/union/control/ConversationServiceTest.java +89 -0
- package/ark-control/src/test/java/com/union/control/MemoryStoreServiceTest.java +26 -0
- package/ark-control/src/test/java/com/union/control/PydanticAiControlContractTest.java +52 -0
- package/ark-control/src/test/java/com/union/control/TestJson.java +45 -0
- package/ark-control/src/test/java/com/union/control/dubbo/ProviderAccessLogFilterTest.java +53 -0
- package/ark-control/src/test/java/com/union/control/local/sensitive/LocalSensitiveProxyConfigurationTest.java +23 -0
- package/ark-control/src/test/java/com/union/control/mapper/interceptor/AESInterceptorCompatibilityTest.java +505 -0
- package/ark-control/src/test/java/com/union/control/schedule/ScheduledExecutionTokenTest.java +27 -0
- package/ark-control/src/test/java/com/union/control/schedule/ScheduledTaskSchedulerTest.java +51 -0
- package/ark-control/src/test/java/com/union/control/service/AgentProxyServiceTest.java +111 -0
- package/ark-control/src/test/java/com/union/control/service/ScheduledTaskServiceTest.java +483 -0
- package/ark-control/src/test/java/com/union/control/service/impl/SensitiveDataDemoServiceImplTest.java +104 -0
- package/ark-control/src/test/java/com/union/control/service/sensitive/RedisRevealTokenStoreTest.java +65 -0
- package/ark-control/src/test/java/com/union/control/service/sensitive/SensitiveRevealBoundaryTest.java +99 -0
- package/ark-control/src/test/java/com/union/control/service/sensitive/SensitiveRevealProcessorCodecTest.java +111 -0
- package/ark-control/src/test/java/com/union/control/service/sensitive/SensitiveRevealProcessorTest.java +111 -0
- package/ark-control/src/test/java/com/union/control/utils/security/SymmetricalSecurityUtilsCompatibilityTest.java +87 -0
- package/ark-control-facade/pom.xml +16 -0
- package/ark-control-facade/src/main/java/com/union/control/service/AgentExecutionService.java +8 -0
- package/ark-control-facade/src/main/java/com/union/control/service/AgentProxyService.java +7 -0
- package/ark-control-facade/src/main/java/com/union/control/service/AgentResponse.java +22 -0
- package/ark-control-facade/src/main/java/com/union/control/service/ConversationService.java +12 -0
- package/ark-control-facade/src/main/java/com/union/control/service/MemoryStoreService.java +12 -0
- package/ark-control-facade/src/main/java/com/union/control/service/RunningAnalysisMockService.java +10 -0
- package/ark-control-facade/src/main/java/com/union/control/service/ScheduledTaskService.java +40 -0
- package/ark-control-facade/src/main/java/com/union/control/service/SensitiveDataDemoService.java +13 -0
- package/ark-control-facade/src/main/java/com/union/control/service/sensitive/SensitiveRevealService.java +18 -0
- package/ark-web/README.md +80 -0
- package/ark-web/pom.xml +105 -0
- package/ark-web/src/local-mock/java/com/epcc/arkweb/mock/ArkAuthServiceMock.java +105 -0
- package/ark-web/src/local-mock/java/com/epcc/arkweb/mock/LocalKaptchaConfiguration.java +26 -0
- package/ark-web/src/main/java/com/epcc/arkweb/Application.java +13 -0
- package/ark-web/src/main/java/com/epcc/arkweb/config/InterceptorConfig.java +20 -0
- package/ark-web/src/main/java/com/epcc/arkweb/config/Realm.java +64 -0
- package/ark-web/src/main/java/com/epcc/arkweb/config/ShiroConfig.java +129 -0
- package/ark-web/src/main/java/com/epcc/arkweb/filter/LoginFormFilter.java +43 -0
- package/ark-web/src/main/java/com/epcc/arkweb/helper/AuthContextHolder.java +39 -0
- package/ark-web/src/main/java/com/epcc/arkweb/helper/AuthenticatedRequest.java +91 -0
- package/ark-web/src/main/java/com/epcc/arkweb/model/ShiroUser.java +21 -0
- package/ark-web/src/main/java/com/epcc/arkweb/utils/ResultMsg.java +19 -0
- package/ark-web/src/main/java/com/epcc/arkweb/vo/llm/ScheduledTaskCommandVO.java +30 -0
- package/ark-web/src/main/java/com/epcc/arkweb/vo/llm/ScheduledTaskQueryVO.java +20 -0
- package/ark-web/src/main/java/com/epcc/arkweb/web/CommonController.java +25 -0
- package/ark-web/src/main/java/com/epcc/arkweb/web/llm/AgentAuthorizationInterceptor.java +229 -0
- package/ark-web/src/main/java/com/epcc/arkweb/web/llm/AgentController.java +165 -0
- package/ark-web/src/main/java/com/epcc/arkweb/web/llm/AgentPermission.java +13 -0
- package/ark-web/src/main/java/com/epcc/arkweb/web/llm/LlmController.java +209 -0
- package/ark-web/src/main/java/com/epcc/arkweb/web/llm/ScheduledTaskController.java +160 -0
- package/ark-web/src/main/java/com/epcc/arkweb/web/sensitive/reveal/SensitiveCaptchaService.java +146 -0
- package/ark-web/src/main/java/com/epcc/arkweb/web/sensitive/reveal/SensitiveRevealController.java +163 -0
- package/ark-web/src/main/resources/application.properties +1 -0
- package/ark-web/src/main/resources/application.yml +23 -0
- package/ark-web/src/main/resources/dubbo-consumer.xml +19 -0
- package/ark-web/src/production-overlay/java/com/epcc/arkweb/config/CasShiroConfig.java +229 -0
- package/ark-web/src/production-overlay/java/com/epcc/arkweb/config/InterceptorConfig.java +35 -0
- package/ark-web/src/production-overlay/java/com/epcc/arkweb/config/ShiroConfig.java +161 -0
- package/ark-web/src/test/java/com/epcc/arkweb/ArkWebStructureContractTest.java +290 -0
- package/ark-web/src/test/java/com/epcc/arkweb/ShiroTestSupport.java +32 -0
- package/ark-web/src/test/java/com/epcc/arkweb/config/LocalShiroIntegrationTest.java +121 -0
- package/ark-web/src/test/java/com/epcc/arkweb/helper/AuthenticatedRequestTest.java +131 -0
- package/ark-web/src/test/java/com/epcc/arkweb/local/LocalArkAuthServiceMockTest.java +17 -0
- package/ark-web/src/test/java/com/epcc/arkweb/web/llm/AgentAuthorizationInterceptorTest.java +134 -0
- package/ark-web/src/test/java/com/epcc/arkweb/web/llm/AgentControllerAuthorizationTest.java +97 -0
- package/ark-web/src/test/java/com/epcc/arkweb/web/llm/LlmControllerTest.java +113 -0
- package/ark-web/src/test/java/com/epcc/arkweb/web/sensitive/reveal/SensitiveRevealControllerTest.java +273 -0
- package/package.json +18 -0
- package/pom.xml +16 -0
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
3
|
+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
4
|
+
<modelVersion>4.0.0</modelVersion>
|
|
5
|
+
|
|
6
|
+
<parent>
|
|
7
|
+
<groupId>org.springframework.boot</groupId>
|
|
8
|
+
<artifactId>spring-boot-starter-parent</artifactId>
|
|
9
|
+
<version>1.5.22.RELEASE</version>
|
|
10
|
+
<relativePath/>
|
|
11
|
+
</parent>
|
|
12
|
+
|
|
13
|
+
<groupId>com.union</groupId>
|
|
14
|
+
<artifactId>ark-control</artifactId>
|
|
15
|
+
<version>1.0.0</version>
|
|
16
|
+
<name>ark-control Dubbo provider</name>
|
|
17
|
+
|
|
18
|
+
<properties>
|
|
19
|
+
<java.version>1.8</java.version>
|
|
20
|
+
<mysql.version>8.0.33</mysql.version>
|
|
21
|
+
</properties>
|
|
22
|
+
|
|
23
|
+
<dependencies>
|
|
24
|
+
<dependency>
|
|
25
|
+
<groupId>com.union</groupId>
|
|
26
|
+
<artifactId>ark-control-facade</artifactId>
|
|
27
|
+
<version>1.0.0</version>
|
|
28
|
+
</dependency>
|
|
29
|
+
<dependency>
|
|
30
|
+
<groupId>com.alibaba</groupId>
|
|
31
|
+
<artifactId>dubbo</artifactId>
|
|
32
|
+
<version>2.6.9</version>
|
|
33
|
+
<exclusions>
|
|
34
|
+
<exclusion><groupId>org.jboss.netty</groupId><artifactId>netty</artifactId></exclusion>
|
|
35
|
+
<exclusion><groupId>org.springframework</groupId><artifactId>spring</artifactId></exclusion>
|
|
36
|
+
<exclusion><groupId>org.slf4j</groupId><artifactId>slf4j-log4j12</artifactId></exclusion>
|
|
37
|
+
</exclusions>
|
|
38
|
+
</dependency>
|
|
39
|
+
<dependency>
|
|
40
|
+
<groupId>io.netty</groupId><artifactId>netty-all</artifactId><version>4.1.25.Final</version>
|
|
41
|
+
</dependency>
|
|
42
|
+
<dependency>
|
|
43
|
+
<groupId>org.apache.curator</groupId><artifactId>curator-framework</artifactId><version>2.12.0</version>
|
|
44
|
+
</dependency>
|
|
45
|
+
<dependency>
|
|
46
|
+
<groupId>org.apache.zookeeper</groupId><artifactId>zookeeper</artifactId><version>3.4.13</version>
|
|
47
|
+
<exclusions>
|
|
48
|
+
<exclusion><groupId>io.netty</groupId><artifactId>netty</artifactId></exclusion>
|
|
49
|
+
<exclusion><groupId>org.slf4j</groupId><artifactId>slf4j-log4j12</artifactId></exclusion>
|
|
50
|
+
<exclusion><groupId>log4j</groupId><artifactId>log4j</artifactId></exclusion>
|
|
51
|
+
</exclusions>
|
|
52
|
+
</dependency>
|
|
53
|
+
<dependency>
|
|
54
|
+
<groupId>org.springframework.boot</groupId>
|
|
55
|
+
<artifactId>spring-boot-starter-web</artifactId>
|
|
56
|
+
</dependency>
|
|
57
|
+
<dependency>
|
|
58
|
+
<groupId>org.springframework.boot</groupId>
|
|
59
|
+
<artifactId>spring-boot-starter-jdbc</artifactId>
|
|
60
|
+
</dependency>
|
|
61
|
+
<dependency>
|
|
62
|
+
<groupId>org.springframework.boot</groupId>
|
|
63
|
+
<artifactId>spring-boot-starter-data-redis</artifactId>
|
|
64
|
+
</dependency>
|
|
65
|
+
<dependency>
|
|
66
|
+
<groupId>org.mybatis.spring.boot</groupId>
|
|
67
|
+
<artifactId>mybatis-spring-boot-starter</artifactId>
|
|
68
|
+
<version>1.3.2</version>
|
|
69
|
+
</dependency>
|
|
70
|
+
<dependency>
|
|
71
|
+
<groupId>com.mysql</groupId>
|
|
72
|
+
<artifactId>mysql-connector-j</artifactId>
|
|
73
|
+
<version>${mysql.version}</version>
|
|
74
|
+
<scope>runtime</scope>
|
|
75
|
+
</dependency>
|
|
76
|
+
<dependency>
|
|
77
|
+
<groupId>org.springframework.boot</groupId>
|
|
78
|
+
<artifactId>spring-boot-starter-test</artifactId>
|
|
79
|
+
<scope>test</scope>
|
|
80
|
+
</dependency>
|
|
81
|
+
</dependencies>
|
|
82
|
+
|
|
83
|
+
<build>
|
|
84
|
+
<plugins>
|
|
85
|
+
<plugin>
|
|
86
|
+
<groupId>org.springframework.boot</groupId>
|
|
87
|
+
<artifactId>spring-boot-maven-plugin</artifactId>
|
|
88
|
+
<configuration>
|
|
89
|
+
<mainClass>com.union.control.ArkControlApplication</mainClass>
|
|
90
|
+
</configuration>
|
|
91
|
+
</plugin>
|
|
92
|
+
</plugins>
|
|
93
|
+
</build>
|
|
94
|
+
|
|
95
|
+
<profiles>
|
|
96
|
+
<profile>
|
|
97
|
+
<id>local-sensitive-compat</id>
|
|
98
|
+
<activation>
|
|
99
|
+
<activeByDefault>true</activeByDefault>
|
|
100
|
+
</activation>
|
|
101
|
+
<dependencies>
|
|
102
|
+
<dependency>
|
|
103
|
+
<groupId>org.projectlombok</groupId>
|
|
104
|
+
<artifactId>lombok</artifactId>
|
|
105
|
+
<version>1.18.8</version>
|
|
106
|
+
<scope>provided</scope>
|
|
107
|
+
</dependency>
|
|
108
|
+
<dependency>
|
|
109
|
+
<groupId>commons-codec</groupId>
|
|
110
|
+
<artifactId>commons-codec</artifactId>
|
|
111
|
+
</dependency>
|
|
112
|
+
<dependency>
|
|
113
|
+
<groupId>com.alibaba</groupId>
|
|
114
|
+
<artifactId>fastjson</artifactId>
|
|
115
|
+
<version>1.2.83</version>
|
|
116
|
+
</dependency>
|
|
117
|
+
</dependencies>
|
|
118
|
+
<build>
|
|
119
|
+
<plugins>
|
|
120
|
+
<plugin>
|
|
121
|
+
<groupId>org.codehaus.mojo</groupId>
|
|
122
|
+
<artifactId>build-helper-maven-plugin</artifactId>
|
|
123
|
+
<version>3.5.0</version>
|
|
124
|
+
<executions>
|
|
125
|
+
<execution>
|
|
126
|
+
<id>add-local-sensitive-compat</id>
|
|
127
|
+
<phase>generate-sources</phase>
|
|
128
|
+
<goals><goal>add-source</goal></goals>
|
|
129
|
+
<configuration>
|
|
130
|
+
<sources>
|
|
131
|
+
<source>src/local-mock/java</source>
|
|
132
|
+
</sources>
|
|
133
|
+
</configuration>
|
|
134
|
+
</execution>
|
|
135
|
+
</executions>
|
|
136
|
+
</plugin>
|
|
137
|
+
</plugins>
|
|
138
|
+
</build>
|
|
139
|
+
</profile>
|
|
140
|
+
</profiles>
|
|
141
|
+
|
|
142
|
+
</project>
|
package/ark-control/src/local-mock/java/com/epcc/commons/securityproxy/api/SecurityResult.java
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
package com.epcc.commons.securityproxy.api;
|
|
2
|
+
|
|
3
|
+
/** Local compile-time compatibility stub. Production supplies this class. */
|
|
4
|
+
public final class SecurityResult {
|
|
5
|
+
private final byte[] content;
|
|
6
|
+
|
|
7
|
+
public SecurityResult(byte[] content) {
|
|
8
|
+
this.content = content;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
public byte[] getContent() {
|
|
12
|
+
return content;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
package com.epcc.commons.securityproxy.api;
|
|
2
|
+
|
|
3
|
+
import com.epcc.dubbo.result.Result;
|
|
4
|
+
|
|
5
|
+
/** Local compile-time compatibility stub. Production supplies this interface. */
|
|
6
|
+
public interface SymmetricalSecurityService {
|
|
7
|
+
enum Algorithm { AES256 }
|
|
8
|
+
|
|
9
|
+
Result<SecurityResult> encryptByFixedKey(Algorithm algorithm, byte[] plaintext);
|
|
10
|
+
Result<SecurityResult> decryptByFixedKey(Algorithm algorithm, byte[] ciphertext);
|
|
11
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
package com.epcc.dubbo.result;
|
|
2
|
+
|
|
3
|
+
/** Local compile-time compatibility stub. Production supplies this class. */
|
|
4
|
+
public final class Result<T> {
|
|
5
|
+
private final boolean success;
|
|
6
|
+
private final T result;
|
|
7
|
+
private final String errorCode;
|
|
8
|
+
private final String errorMsg;
|
|
9
|
+
|
|
10
|
+
private Result(boolean success, T result, String errorCode, String errorMsg) {
|
|
11
|
+
this.success = success;
|
|
12
|
+
this.result = result;
|
|
13
|
+
this.errorCode = errorCode;
|
|
14
|
+
this.errorMsg = errorMsg;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
public static <T> Result<T> success(T result) {
|
|
18
|
+
return new Result<>(true, result, null, null);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public static <T> Result<T> failure(String errorCode, String errorMsg) {
|
|
22
|
+
return new Result<>(false, null, errorCode, errorMsg);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
public boolean isSuccess() { return success; }
|
|
26
|
+
public T getResult() { return result; }
|
|
27
|
+
public String getErrorCode() { return errorCode; }
|
|
28
|
+
public String getErrorMsg() { return errorMsg; }
|
|
29
|
+
}
|
package/ark-control/src/local-mock/java/com/nucc/channel/ark/common/annotation/EnDecryptField.java
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
package com.nucc.channel.ark.common.annotation;
|
|
2
|
+
|
|
3
|
+
import org.springframework.stereotype.Component;
|
|
4
|
+
|
|
5
|
+
import java.lang.annotation.ElementType;
|
|
6
|
+
import java.lang.annotation.Retention;
|
|
7
|
+
import java.lang.annotation.RetentionPolicy;
|
|
8
|
+
import java.lang.annotation.Target;
|
|
9
|
+
|
|
10
|
+
/** Local compatibility copy. Production keeps its existing annotation unchanged. */
|
|
11
|
+
@Component
|
|
12
|
+
@Retention(RetentionPolicy.RUNTIME)
|
|
13
|
+
@Target(ElementType.FIELD)
|
|
14
|
+
public @interface EnDecryptField {
|
|
15
|
+
String value() default "";
|
|
16
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
package com.nucc.channel.ark.common.annotation;
|
|
2
|
+
|
|
3
|
+
import org.springframework.stereotype.Component;
|
|
4
|
+
|
|
5
|
+
import java.lang.annotation.ElementType;
|
|
6
|
+
import java.lang.annotation.Retention;
|
|
7
|
+
import java.lang.annotation.RetentionPolicy;
|
|
8
|
+
import java.lang.annotation.Target;
|
|
9
|
+
|
|
10
|
+
/** Local compatibility copy. Production keeps its existing annotation unchanged. */
|
|
11
|
+
@Component
|
|
12
|
+
@Retention(RetentionPolicy.RUNTIME)
|
|
13
|
+
@Target(ElementType.FIELD)
|
|
14
|
+
public @interface EnDecryptFieldLong {
|
|
15
|
+
String value() default "";
|
|
16
|
+
int chunkSize() default 0;
|
|
17
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
package com.nucc.channel.ark.common.annotation;
|
|
2
|
+
|
|
3
|
+
import org.springframework.stereotype.Component;
|
|
4
|
+
|
|
5
|
+
import java.lang.annotation.ElementType;
|
|
6
|
+
import java.lang.annotation.Retention;
|
|
7
|
+
import java.lang.annotation.RetentionPolicy;
|
|
8
|
+
import java.lang.annotation.Target;
|
|
9
|
+
|
|
10
|
+
/** Local compatibility copy. Production keeps its existing annotation unchanged. */
|
|
11
|
+
@Component
|
|
12
|
+
@Retention(RetentionPolicy.RUNTIME)
|
|
13
|
+
@Target(ElementType.FIELD)
|
|
14
|
+
public @interface EnDecryptFieldWithTag {
|
|
15
|
+
String value() default "";
|
|
16
|
+
}
|
package/ark-control/src/local-mock/java/com/nucc/channel/ark/common/exception/BaseDataErrorCode.java
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
package com.nucc.channel.ark.common.exception;
|
|
2
|
+
|
|
3
|
+
/** Local compatibility subset. Production uses its existing enum unchanged. */
|
|
4
|
+
public enum BaseDataErrorCode implements ErrorCode {
|
|
5
|
+
SYSTEM_INNER_ERROR("SYSTEM_INNER_ERROR", "系统内部错误");
|
|
6
|
+
|
|
7
|
+
private final String code;
|
|
8
|
+
private final String desc;
|
|
9
|
+
|
|
10
|
+
BaseDataErrorCode(String code, String desc) {
|
|
11
|
+
this.code = code;
|
|
12
|
+
this.desc = desc;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
@Override
|
|
16
|
+
public String getCode() { return code; }
|
|
17
|
+
|
|
18
|
+
@Override
|
|
19
|
+
public String getDesc() { return desc; }
|
|
20
|
+
|
|
21
|
+
@Override
|
|
22
|
+
public ErrorCode getErrorCode() { return this; }
|
|
23
|
+
|
|
24
|
+
@Override
|
|
25
|
+
public Throwable getThrowable() { return null; }
|
|
26
|
+
}
|
package/ark-control/src/local-mock/java/com/nucc/channel/ark/common/exception/CheckException.java
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
package com.nucc.channel.ark.common.exception;
|
|
2
|
+
|
|
3
|
+
/** Local compatibility copy of the production checked exception contract. */
|
|
4
|
+
public class CheckException extends Exception implements ErrorCode {
|
|
5
|
+
private final ErrorCode errorCode;
|
|
6
|
+
private final String extraMsg;
|
|
7
|
+
|
|
8
|
+
public CheckException(ErrorCode errorCode, String message) {
|
|
9
|
+
super(errorCode.getCode() + "|" + message);
|
|
10
|
+
this.errorCode = errorCode;
|
|
11
|
+
this.extraMsg = message;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
@Override
|
|
15
|
+
public String getCode() {
|
|
16
|
+
return errorCode.getCode();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@Override
|
|
20
|
+
public String getDesc() {
|
|
21
|
+
return extraMsg;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@Override
|
|
25
|
+
public ErrorCode getErrorCode() {
|
|
26
|
+
return errorCode;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@Override
|
|
30
|
+
public Throwable getThrowable() {
|
|
31
|
+
return getCause();
|
|
32
|
+
}
|
|
33
|
+
}
|
package/ark-control/src/local-mock/java/com/nucc/channel/ark/common/redis/RedisCacheService.java
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
package com.nucc.channel.ark.common.redis;
|
|
2
|
+
|
|
3
|
+
import com.nucc.channel.ark.common.util.ResultUtil;
|
|
4
|
+
import lombok.extern.slf4j.Slf4j;
|
|
5
|
+
import org.springframework.stereotype.Service;
|
|
6
|
+
import redis.clients.jedis.Jedis;
|
|
7
|
+
import redis.clients.jedis.JedisSentinelPool;
|
|
8
|
+
import redis.clients.jedis.Pipeline;
|
|
9
|
+
import redis.clients.jedis.Response;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* 使用Jedis原生连接redis哨兵
|
|
13
|
+
*
|
|
14
|
+
*/
|
|
15
|
+
@Slf4j
|
|
16
|
+
@Service
|
|
17
|
+
public class RedisCacheService {
|
|
18
|
+
|
|
19
|
+
//模拟redis是否可用。 true:redis可用;false:redis不可用。
|
|
20
|
+
private static boolean redisFlag = true;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* 用于xml注入
|
|
24
|
+
*/
|
|
25
|
+
private JedisSentinelPool jedisSentinelPool;
|
|
26
|
+
|
|
27
|
+
public void setJedisSentinelPool(JedisSentinelPool jedisSentinelPool) {
|
|
28
|
+
this.jedisSentinelPool = jedisSentinelPool;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* 设置redis指定过期时间
|
|
33
|
+
* @param key
|
|
34
|
+
* @param time
|
|
35
|
+
* @param value
|
|
36
|
+
* @return
|
|
37
|
+
*/
|
|
38
|
+
public String setex(String key, int time, String value) {
|
|
39
|
+
try {
|
|
40
|
+
Jedis jedis = jedisSentinelPool.getResource();
|
|
41
|
+
String ret = jedis.setex(key,time,value);
|
|
42
|
+
log.info("setex result={}", ret);
|
|
43
|
+
jedis.close();
|
|
44
|
+
return ResultUtil.SUCCESS_RESULT;
|
|
45
|
+
} catch (Exception e) {
|
|
46
|
+
log.error("setex to redis error,key={},e={} ",key,e);
|
|
47
|
+
}
|
|
48
|
+
return ResultUtil.FAIL_RESULT;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public String get(String key) {
|
|
52
|
+
try {
|
|
53
|
+
if (!redisFlag){
|
|
54
|
+
log.info("mock get redis is not ok");
|
|
55
|
+
return ResultUtil.FAIL_RESULT;
|
|
56
|
+
}
|
|
57
|
+
Jedis jedis = jedisSentinelPool.getResource();
|
|
58
|
+
String ret = jedis.get(key);
|
|
59
|
+
jedis.close();
|
|
60
|
+
return ret;
|
|
61
|
+
} catch (Exception e) {
|
|
62
|
+
log.error("get from redis error,{} ", e);
|
|
63
|
+
}
|
|
64
|
+
return ResultUtil.FAIL_RESULT;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
public String del(String key){
|
|
68
|
+
try {
|
|
69
|
+
Jedis jedis = jedisSentinelPool.getResource();
|
|
70
|
+
jedis.del(key);
|
|
71
|
+
jedis.close();
|
|
72
|
+
return ResultUtil.SUCCESS_RESULT;
|
|
73
|
+
} catch (Exception e) {
|
|
74
|
+
log.error("del to redis error,key={},e={} ",key,e);
|
|
75
|
+
}
|
|
76
|
+
return ResultUtil.FAIL_RESULT;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* 设置redis 存储值+increment
|
|
81
|
+
* @param key
|
|
82
|
+
* @param increment
|
|
83
|
+
* @return
|
|
84
|
+
*/
|
|
85
|
+
public Long incrBy(String key, Long increment) {
|
|
86
|
+
Long ret=Long.valueOf(-1L);
|
|
87
|
+
try {
|
|
88
|
+
Jedis jedis = jedisSentinelPool.getResource();
|
|
89
|
+
|
|
90
|
+
if(increment==null){
|
|
91
|
+
ret = jedis.incr(key);
|
|
92
|
+
}else{
|
|
93
|
+
ret = jedis.incrBy(key,increment);
|
|
94
|
+
}
|
|
95
|
+
log.info("incrBy result={}", ret);
|
|
96
|
+
jedis.close();
|
|
97
|
+
return ret;
|
|
98
|
+
} catch (Exception e) {
|
|
99
|
+
log.error("incrBy to redis error,key={},e={} ",key,e);
|
|
100
|
+
}
|
|
101
|
+
return ret;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* 此方法大并发时不生效,system本地时间有误差,此方法兼容redis出现故障,故障时直接返回true
|
|
106
|
+
* @param key
|
|
107
|
+
* @param circle 周期 单位秒
|
|
108
|
+
* @param count 计数
|
|
109
|
+
* @return
|
|
110
|
+
*/
|
|
111
|
+
public boolean ratelimit(String key, Long circle,Long count) {
|
|
112
|
+
Long now=System.currentTimeMillis();
|
|
113
|
+
Response<Long> exsitCnt=null;
|
|
114
|
+
try {
|
|
115
|
+
Jedis jedis = jedisSentinelPool.getResource();
|
|
116
|
+
Pipeline pipeline=jedis.pipelined();
|
|
117
|
+
pipeline.zadd(key,now,String.valueOf(now));
|
|
118
|
+
pipeline.zremrangeByScore(key,0,now-circle*1000);
|
|
119
|
+
exsitCnt=pipeline.zcard(key);
|
|
120
|
+
pipeline.expire(key,circle.intValue());
|
|
121
|
+
pipeline.sync();
|
|
122
|
+
log.info("exsitCnt result={}", exsitCnt.get());
|
|
123
|
+
jedis.close();
|
|
124
|
+
return exsitCnt==null?true:exsitCnt.get()<=count;
|
|
125
|
+
} catch (Exception e) {
|
|
126
|
+
log.error("ratelimit redis error,key={} ",key,e);
|
|
127
|
+
}
|
|
128
|
+
return true;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
package com.nucc.channel.ark.common.util;
|
|
2
|
+
|
|
3
|
+
import java.util.HashMap;
|
|
4
|
+
import java.util.Map;
|
|
5
|
+
|
|
6
|
+
/** Local compatibility subset. Production keeps its existing Constant class unchanged. */
|
|
7
|
+
public final class Constant {
|
|
8
|
+
private Constant() {}
|
|
9
|
+
|
|
10
|
+
@SuppressWarnings("rawtypes")
|
|
11
|
+
public static final Map flagMap = new HashMap();
|
|
12
|
+
|
|
13
|
+
public static final String REGEX_MOBILE = "(?<!\\d)1[3-9]\\d{9}(?!\\d)";
|
|
14
|
+
public static final String REGEX_EMAIL = "[a-zA-Z0-9.%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}";
|
|
15
|
+
public static final String REGEX_TELEPHONE = "(?<!\\d)0\\d{2,3}-?\\d{7,8}(?!\\d)";
|
|
16
|
+
public static final String ENCRYPT_START = "#[";
|
|
17
|
+
public static final String ENCRYPT_END = "]";
|
|
18
|
+
public static final String REGEX_DECRYPT_TAG = "#\\[([^#\\]]*)\\]";
|
|
19
|
+
public static final String INTERCEPTOR_ITEMS =
|
|
20
|
+
"SensitiveDataDemoMapper,AnnounceAddressBookRecordMapper,ReformTrackMapper,"
|
|
21
|
+
+ "QuestionnaireMapper,"
|
|
22
|
+
+ "AnnounceMailSendMapper,AnnounceMailMapper,AppealMapper,TicketMapper,"
|
|
23
|
+
+ "NotifyMapper,MailDetailMapper";
|
|
24
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
package com.nucc.channel.ark.common.util;
|
|
2
|
+
|
|
3
|
+
/** Local compatibility copy of the production Redis result constants. */
|
|
4
|
+
public final class ResultUtil {
|
|
5
|
+
public static final String SUCCESS_RESULT = "OK";
|
|
6
|
+
public static final String FAIL_RESULT = "FAIL_RESULT";
|
|
7
|
+
|
|
8
|
+
private ResultUtil() {}
|
|
9
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
package com.union.control.local.sensitive;
|
|
2
|
+
|
|
3
|
+
import com.epcc.commons.securityproxy.api.SecurityResult;
|
|
4
|
+
import com.epcc.commons.securityproxy.api.SymmetricalSecurityService;
|
|
5
|
+
import com.epcc.dubbo.result.Result;
|
|
6
|
+
import com.nucc.channel.ark.common.exception.BaseDataErrorCode;
|
|
7
|
+
import com.nucc.channel.ark.common.exception.CheckException;
|
|
8
|
+
|
|
9
|
+
import java.nio.charset.StandardCharsets;
|
|
10
|
+
import java.util.Arrays;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Local-only stand-in for the unavailable sensitiveProxy AES256 service.
|
|
14
|
+
* It is intentionally recognizable and must never be used as production cryptography.
|
|
15
|
+
*/
|
|
16
|
+
public final class LocalMockSensitiveProxy implements SymmetricalSecurityService {
|
|
17
|
+
private static final byte[] PREFIX = "LOCAL_MOCK_ONLY:".getBytes(StandardCharsets.US_ASCII);
|
|
18
|
+
|
|
19
|
+
@Override
|
|
20
|
+
public Result<SecurityResult> encryptByFixedKey(Algorithm algorithm, byte[] plaintext) {
|
|
21
|
+
byte[] result = Arrays.copyOf(PREFIX, PREFIX.length + plaintext.length);
|
|
22
|
+
System.arraycopy(plaintext, 0, result, PREFIX.length, plaintext.length);
|
|
23
|
+
return Result.success(new SecurityResult(result));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@Override
|
|
27
|
+
public Result<SecurityResult> decryptByFixedKey(Algorithm algorithm, byte[] ciphertext) {
|
|
28
|
+
if (ciphertext.length < PREFIX.length) return invalid();
|
|
29
|
+
for (int i = 0; i < PREFIX.length; i++) {
|
|
30
|
+
if (ciphertext[i] != PREFIX[i]) return invalid();
|
|
31
|
+
}
|
|
32
|
+
return Result.success(new SecurityResult(
|
|
33
|
+
Arrays.copyOfRange(ciphertext, PREFIX.length, ciphertext.length)));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
private static Result<SecurityResult> invalid() {
|
|
37
|
+
return Result.failure(BaseDataErrorCode.SYSTEM_INNER_ERROR.getCode(),
|
|
38
|
+
"Local mock ciphertext rejected");
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
package com.union.control.local.sensitive;
|
|
2
|
+
|
|
3
|
+
import com.nucc.channel.ark.common.redis.RedisCacheService;
|
|
4
|
+
import com.nucc.channel.ark.common.util.ResultUtil;
|
|
5
|
+
|
|
6
|
+
import java.util.Map;
|
|
7
|
+
import java.util.concurrent.ConcurrentHashMap;
|
|
8
|
+
|
|
9
|
+
/** Local-only in-memory boundary for the production RedisCacheService contract. */
|
|
10
|
+
public final class LocalRedisCacheService extends RedisCacheService {
|
|
11
|
+
private final Map<String, Value> values = new ConcurrentHashMap<>();
|
|
12
|
+
|
|
13
|
+
@Override
|
|
14
|
+
public String setex(String key, int time, String value) {
|
|
15
|
+
values.put(key, new Value(value, System.currentTimeMillis() + time * 1000L));
|
|
16
|
+
return ResultUtil.SUCCESS_RESULT;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@Override
|
|
20
|
+
public String get(String key) {
|
|
21
|
+
Value value = values.get(key);
|
|
22
|
+
if (value == null) return null;
|
|
23
|
+
if (value.expiresAt <= System.currentTimeMillis()) {
|
|
24
|
+
values.remove(key, value);
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
return value.text;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@Override
|
|
31
|
+
public String del(String key) {
|
|
32
|
+
values.remove(key);
|
|
33
|
+
return ResultUtil.SUCCESS_RESULT;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
private static final class Value {
|
|
37
|
+
final String text;
|
|
38
|
+
final long expiresAt;
|
|
39
|
+
|
|
40
|
+
Value(String text, long expiresAt) {
|
|
41
|
+
this.text = text;
|
|
42
|
+
this.expiresAt = expiresAt;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
package com.union.control.local.sensitive;
|
|
2
|
+
|
|
3
|
+
import com.nucc.channel.ark.common.redis.RedisCacheService;
|
|
4
|
+
import com.union.control.mapper.interceptor.AESInterceptor;
|
|
5
|
+
import org.mybatis.spring.boot.autoconfigure.ConfigurationCustomizer;
|
|
6
|
+
import org.springframework.context.annotation.Bean;
|
|
7
|
+
import org.springframework.context.annotation.Configuration;
|
|
8
|
+
|
|
9
|
+
/** Bridges this mock application's narrow component scan to production-compatible components. */
|
|
10
|
+
@Configuration
|
|
11
|
+
public class LocalSensitiveHostConfiguration {
|
|
12
|
+
@Bean
|
|
13
|
+
public RedisCacheService redisCacheService() {
|
|
14
|
+
return new LocalRedisCacheService();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
@Bean
|
|
18
|
+
public AESInterceptor aesInterceptor() {
|
|
19
|
+
return new AESInterceptor();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@Bean
|
|
23
|
+
public ConfigurationCustomizer sensitiveInterceptorRegistration(
|
|
24
|
+
AESInterceptor interceptor) {
|
|
25
|
+
return configuration -> configuration.addInterceptor(interceptor);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
package com.union.control.local.sensitive;
|
|
2
|
+
|
|
3
|
+
import com.epcc.commons.securityproxy.api.SymmetricalSecurityService;
|
|
4
|
+
import org.springframework.context.annotation.Bean;
|
|
5
|
+
import org.springframework.context.annotation.Configuration;
|
|
6
|
+
import org.springframework.context.annotation.Profile;
|
|
7
|
+
|
|
8
|
+
/** Explicit local-only replacement for the unavailable production sensitiveProxy bean. */
|
|
9
|
+
@Configuration
|
|
10
|
+
@Profile({"default", "local-sensitive-mock"})
|
|
11
|
+
public class LocalSensitiveProxyConfiguration {
|
|
12
|
+
@Bean(name = "sensitiveProxy")
|
|
13
|
+
public SymmetricalSecurityService localSensitiveProxy() {
|
|
14
|
+
return new LocalMockSensitiveProxy();
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
package com.union.control;
|
|
2
|
+
|
|
3
|
+
import org.mybatis.spring.annotation.MapperScan;
|
|
4
|
+
import org.springframework.boot.SpringApplication;
|
|
5
|
+
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
6
|
+
import org.springframework.context.annotation.ImportResource;
|
|
7
|
+
import org.springframework.scheduling.annotation.EnableScheduling;
|
|
8
|
+
|
|
9
|
+
@SpringBootApplication
|
|
10
|
+
@MapperScan("com.union.control.mapper")
|
|
11
|
+
@EnableScheduling
|
|
12
|
+
@ImportResource("classpath:dubbo-provider.xml")
|
|
13
|
+
public class ArkControlApplication {
|
|
14
|
+
public static void main(String[] args) {
|
|
15
|
+
SpringApplication.run(ArkControlApplication.class, args);
|
|
16
|
+
}
|
|
17
|
+
}
|