diff --git a/.circleci/config.yml b/.circleci/config.yml
new file mode 100644
index 0000000..32b1c33
--- /dev/null
+++ b/.circleci/config.yml
@@ -0,0 +1,67 @@
+# Copyright 2024 Ant Group Co., Ltd.
+#
+# 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.
+
+version: 2.1
+
+parameters:
+ GHA_Actor:
+ type: string
+ default: ""
+ GHA_Action:
+ type: string
+ default: ""
+ GHA_Event:
+ type: string
+ default: ""
+ GHA_Meta:
+ type: string
+ default: ""
+
+jobs:
+ build-and-push:
+ docker:
+ - image: cimg/openjdk:17.0
+ steps:
+ - checkout
+ - setup_remote_docker
+ - run:
+ name: Build Docker image
+ command: make image
+ - run:
+ name: Push to Docker Hub
+ command: |
+ # login easypsi dockerhub registry
+ docker login -u ${DOCKER_DEPLOY_USERNAME} -p ${DOCKER_DEPLOY_TOKEN}
+ # login easypsi aliyun registry
+ docker login -u ${ALIYUN_DOCKER_USERNAME} -p ${ALIYUN_DOCKER_PASSWORD} secretflow-registry.cn-hangzhou.cr.aliyuncs.com
+ CIRCLETAG=$(echo ${CIRCLE_TAG} | sed 's/v//')
+
+ docker tag $(docker images --format "{{.Repository}}:{{.Tag}}" | sed -n '1p') secretflow-registry.cn-hangzhou.cr.aliyuncs.com/secretflow/easy-psi:latest
+ docker tag $(docker images --format "{{.Repository}}:{{.Tag}}" | sed -n '1p') secretflow/easy-psi:latest
+ docker tag $(docker images --format "{{.Repository}}:{{.Tag}}" | sed -n '1p') secretflow-registry.cn-hangzhou.cr.aliyuncs.com/secretflow/easy-psi:${CIRCLETAG}
+ docker tag $(docker images --format "{{.Repository}}:{{.Tag}}" | sed -n '1p') secretflow/easy-psi:${CIRCLETAG}
+ docker push secretflow/easy-psi:${CIRCLETAG}
+ docker push secretflow-registry.cn-hangzhou.cr.aliyuncs.com/secretflow/easy-psi:${CIRCLETAG}
+ docker push secretflow-registry.cn-hangzhou.cr.aliyuncs.com/secretflow/easy-psi:latest
+ docker push secretflow/easy-psi:latest
+
+workflows:
+ build-deploy:
+ jobs:
+ - build-and-push:
+ filters:
+ tags:
+ only: /^v.*/
+ branches:
+ ignore: /.*/
\ No newline at end of file
diff --git a/.github/workflows/cla.yml b/.github/workflows/cla.yml
index 926e495..e34f360 100644
--- a/.github/workflows/cla.yml
+++ b/.github/workflows/cla.yml
@@ -1,3 +1,16 @@
+# Copyright 2024 Ant Group Co., Ltd.
+#
+# 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.
---
name: CLA Assistant
on:
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
new file mode 100644
index 0000000..e89ef56
--- /dev/null
+++ b/.github/workflows/test.yml
@@ -0,0 +1,51 @@
+# Copyright 2024 Ant Group Co., Ltd.
+#
+# 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.
+
+name: Test
+
+on:
+ pull_request:
+ branches: [ main ]
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v3
+ - name: Set up JDK 17
+ uses: actions/setup-java@v3
+ with:
+ java-version: '17'
+ distribution: 'temurin'
+
+ - name: Cache Maven packages
+ uses: actions/cache@v3
+ with:
+ path: ~/.m2
+ key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
+ restore-keys: |
+ ${{ runner.os }}-m2
+
+ - name: Build with Maven
+ run: mvn clean test
+
+ - name: Add coverage to PR
+ uses: madrapps/jacoco-report@v1.6.1
+ with:
+ token: ${{ secrets.GITHUB_TOKEN }}
+ min-coverage-overall: 40
+ min-coverage-changed-files: 40
+ paths: |
+ ${{ github.workspace }}/test/target/site/jacoco.xml
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index 1c286c9..3e1e22c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -29,11 +29,11 @@ target/
!**/src/main/**/build/
!**/src/test/**/build/
!**/src/test/resources/certs/
-secretpad-api/client-java-kusciaapi/**/kusciaapi/
-secretpad-api/client-java-kusciaapi/**/common/
-secretpad-service/**/org/secretflow/proto/
-secretpad-service/**/com/opensecretflow/spec/v1/
-secretpad-web/config
+easypsi-api/client-java-kusciaapi/**/kusciaapi/
+easypsi-api/client-java-kusciaapi/**/common/
+easypsi-service/**/org/secretflow/proto/
+easypsi-service/**/com/opensecretflow/spec/v1/
+easypsi-web/config
### VS Code ###
.vscode/
@@ -48,3 +48,7 @@ build/**/settings.xml
docs/_build
.java-version
+/easypsi-test/surefire-report/
+/easypsi-test/jacoco.xml
+/surefire-report/
+/easypsi-test/TEST-all.xml
diff --git a/Makefile b/Makefile
index fb6d217..4dba901 100644
--- a/Makefile
+++ b/Makefile
@@ -30,12 +30,12 @@ test: ## Run tests.
mvn clean test
.PHONY: build
-build: ## Build SecretPad binary whether to integrate frontend.
+build: ## Build EasyPsi binary whether to integrate frontend.
./scripts/build.sh true
.PHONY: image
image: build ## Build docker image with the manager.
- ./scripts/build_image.sh
+ ./scripts/fatimage.sh
.PHONY: docs
docs: ## Build docs.
diff --git a/README.md b/README.md
index 1d0e4e1..22fd01c 100644
--- a/README.md
+++ b/README.md
@@ -1,10 +1,10 @@
-# Easy-PSI
+# EasyPsi
简体中文 |English
-SecretPad is a **privacy-preserving computing** web platform based on the [Kuscia](https://github.com/secretflow/kuscia) framework, designed to provide easy access to privacy-preserving data intelligence and machine learning functions. With SecretPad:
+EasyPsi is a **privacy-preserving computing** web platform based on the [Kuscia](https://github.com/secretflow/kuscia) framework, designed to provide easy access to privacy-preserving data intelligence and machine learning functions. With EasyPsi:
* You can create node, register data, create project, create authorization between cooperative nodes.
* You can use the ability of data preprocessing, analysis and modeling to meet diverse business scenarios
@@ -14,10 +14,10 @@ SecretPad is a **privacy-preserving computing** web platform based on the [Kusci
Currently, we only provide detailed documentations in Chinese.
-- [Development](./docs/development/build_secretpad_cn.md)
+- [Development](./docs/development/build_easypsi_cn.md)
## Disclaimer
-Non-release version of SecretPad is only for demonstration and should not be used in production environments.
-Although this version of SecretPad covers the basic abilities, there may be some security issues and functional defects due to insufficient functionality and unfinished items in the project.
-We welcome your active suggestions and look forward to the official release.
+Non-release version of EasyPsi is only for demonstration and should not be used in production environments.
+Although this version of EasyPsi covers the basic abilities, there may be some security issues and functional defects due to insufficient functionality and unfinished items in the project.
+We welcome your active suggestions and look forward to the official release.
\ No newline at end of file
diff --git a/README.zh-CN.md b/README.zh-CN.md
index b5b2710..aeeddc8 100644
--- a/README.zh-CN.md
+++ b/README.zh-CN.md
@@ -1,10 +1,10 @@
-# SecretPad
+# EasyPsi
简体中文 |English
-SecretPad 是一个基于 [Kuscia](https://github.com/secretflow/kuscia) 的隐私计算的 web 框架,能够方便的使用基于保护隐私的数据智能和机器学习的能力。通过 SecretPad:
+EasyPsi 是一个基于 [Kuscia](https://github.com/secretflow/kuscia) 的隐私计算的 web 框架,能够方便的使用基于保护隐私的数据智能和机器学习的能力。通过 EasyPsi:
* 你可以快速创建节点、注册数据、创建项目、进行合作节点间的授权
* 你可以使用丰富的数据预处理,数据分析、数据建模能力,满足多样化的业务场景。
@@ -12,8 +12,8 @@ SecretPad 是一个基于 [Kuscia](https://github.com/secretflow/kuscia) 的隐
## Documentation
-- [Development](./docs/development/build_secretpad_cn.md)
+- [Development](./docs/development/build_easypsi_cn.md)
## 声明
-非正式发布的 SecretPad 版本仅用于演示,请勿在生产环境中使用。尽管此版本已涵盖 SecretPad 的基础功能,但由于项目存在功能不足和待完善项,可能存在部分安全问题和功能缺陷。因此,我们欢迎你积极提出建议,并期待正式版本的发布。
\ No newline at end of file
+非正式发布的 EasyPsi 版本仅用于演示,请勿在生产环境中使用。尽管此版本已涵盖 EasyPsi 的基础功能,但由于项目存在功能不足和待完善项,可能存在部分安全问题和功能缺陷。因此,我们欢迎你积极提出建议,并期待正式版本的发布。
\ No newline at end of file
diff --git a/build/Dockerfiles/anolis.Dockerfile b/build/Dockerfiles/anolis.Dockerfile
index fd5ad8a..77f4027 100644
--- a/build/Dockerfiles/anolis.Dockerfile
+++ b/build/Dockerfiles/anolis.Dockerfile
@@ -1,16 +1,31 @@
+#
+# Copyright 2024 Ant Group Co., Ltd.
+#
+# 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.
+#
FROM secretflow-registry.cn-hangzhou.cr.aliyuncs.com/secretflow/secretpad-base-lite:0.2
ENV LANG=C.UTF-8
WORKDIR /app
-RUN mkdir -p /var/log/secretpad && mkdir -p /app/db && mkdir -p /app/config/certs && yum install -y sqlite
+RUN mkdir -p /var/log/easypsi && mkdir -p /app/db && mkdir -p /app/config/certs && yum install -y sqlite
COPY config /app/config
COPY scripts /app/scripts
COPY demo/data /app/data
-COPY target/*.jar secretpad.jar
+COPY target/*.jar easypsi.jar
EXPOSE 80
EXPOSE 8080
EXPOSE 9001
-ENTRYPOINT ["java","-jar", "-Dsun.net.http.allowRestrictedHeaders=true", "secretpad.jar"]
\ No newline at end of file
+ENTRYPOINT ["java","-jar", "-Dsun.net.http.allowRestrictedHeaders=true", "easypsi.jar"]
\ No newline at end of file
diff --git a/build/Dockerfiles/fatimage.Dockerfile b/build/Dockerfiles/fatimage.Dockerfile
new file mode 100644
index 0000000..9eb33bb
--- /dev/null
+++ b/build/Dockerfiles/fatimage.Dockerfile
@@ -0,0 +1,67 @@
+#
+# Copyright 2024 Ant Group Co., Ltd.
+#
+# 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.
+#
+
+ARG KUSCIA_IMAGE_NAME
+FROM secretflow-registry.cn-hangzhou.cr.aliyuncs.com/secretflow/secretpad-base-lite:0.2 as base_pad
+FROM ${KUSCIA_IMAGE_NAME}
+ARG KUSCIA_IMAGE_NAME
+ARG EASYPSI_IMAGE_NAME
+ARG SECRETFLOW_IMAGE_NAME
+RUN echo "arg kuscia=${KUSCIA_IMAGE_NAME}"
+RUN echo "arg easypsi=${EASYPSI_IMAGE_NAME}"
+RUN echo "arg sf=${SECRETFLOW_IMAGE_NAME}"
+
+## install openjdk 17
+ARG JDK_VERSION=17.0.6+10
+ARG JDK_DIR=/usr/local/openjdk-17
+RUN mkdir -p ${JDK_DIR}
+COPY --from=base_pad ${JDK_DIR} ${JDK_DIR}
+ENV JAVA_HOME=${JDK_DIR}
+ENV PATH=${JAVA_HOME}/bin:${PATH}
+
+## set timezone and charset
+ENV TZ=Asia/Shanghai
+ENV LANG=C.UTF-8
+
+# set image version
+ENV KUSCIA_IMAGE=${KUSCIA_IMAGE_NAME}
+ENV EASYPSI_IMAGE=${EASYPSI_IMAGE_NAME}
+ENV SECRETFLOW_IMAGE=${SECRETFLOW_IMAGE_NAME}
+WORKDIR /app
+
+RUN #mkdir -p /var/log/easypsi && mkdir -p /app/db && mkdir -p /app/config/certs && mkdir -p /app/tmp/scripts
+RUN yum install -y sqlite && yum clean all
+COPY config /app/bak/config
+COPY scripts /app/bak/scripts
+COPY demo/data /app/bak/data
+COPY target/*.jar easypsi.jar
+COPY scripts/fatimage/entrypoint_command.sh /app/entrypoint_command.sh
+RUN mkdir -p /home/kuscia/image_libs
+COPY target/secretflow.tar /home/kuscia/image_libs/secretflow.tar
+
+WORKDIR /home/kuscia
+RUN echo "env kuscia=${KUSCIA_IMAGE}"
+RUN echo "env easypsi=${EASYPSI_IMAGE}"
+RUN echo "env sf=${SECRETFLOW_IMAGE}"
+
+# Other defatul env
+ENV KUSCIA_API_ADDRESS=127.0.0.1:8083
+ENV KUSCIA_GW_ADDRESS=127.0.0.1:80
+ENV KUSCIA_PROTOCOL="mtls"
+ENV SPRING_PROFILES_ACTIVE="p2p"
+
+
+CMD ["bash", "/app/entrypoint_command.sh"]
diff --git a/build/Dockerfiles/lite.Dockerfile b/build/Dockerfiles/lite.Dockerfile
index 912fced..aec730b 100644
--- a/build/Dockerfiles/lite.Dockerfile
+++ b/build/Dockerfiles/lite.Dockerfile
@@ -1,3 +1,19 @@
+#
+# Copyright 2024 Ant Group Co., Ltd.
+#
+# 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.
+#
+
FROM openanolis/anolisos:8.4-x86_64
## install openjdk 17
diff --git a/config/application-dev.yaml b/config/application-dev.yaml
index 12c3466..1b162d4 100644
--- a/config/application-dev.yaml
+++ b/config/application-dev.yaml
@@ -2,15 +2,15 @@ server:
tomcat:
accesslog:
enabled: true
- directory: /var/log/secretpad
+ directory: /var/log/easypsi
http-port: 8080
port: 443
ssl:
enabled: true
key-store: "file:./config/server.jks"
- key-store-password: secretpad
- key-alias: secretpad-server
- key-password: secretpad
+ key-store-password: easypsi
+ key-alias: easypsi-server
+ key-password: easypsi
key-store-type: JKS
spring:
@@ -19,7 +19,7 @@ spring:
pool:
size: 10
application:
- name: secretpad
+ name: easypsi
jpa:
database-platform: org.hibernate.community.dialect.SQLiteDialect
show-sql: true
@@ -29,7 +29,7 @@ spring:
datasource:
hibernate.dialect: org.hibernate.dialect.SQLiteDialect
driver-class-name: org.sqlite.JDBC
- url: jdbc:sqlite:./db/secretpad.sqlite
+ url: jdbc:sqlite:./db/easypsi.sqlite
hikari:
idle-timeout: 60000
maximum-pool-size: 1
@@ -84,7 +84,7 @@ fabric:
keystore-path: config/fabric/keystore.pem
tls-cert-path: config/fabric/tls.pem
-secretpad:
+easypsi:
auth:
enabled: false
response:
@@ -96,17 +96,6 @@ secretpad:
data:
dir-path: ../tmp/data/
-tee:
- capsule-mana: capsule-manager.#.svc # tee capsule-manager service
-
-sfclusterDesc:
- deviceConfig:
- spu: "{\"runtime_config\":{\"protocol\":\"REF2K\",\"field\":\"FM64\"},\"link_desc\":{\"connect_retry_times\":60,\"connect_retry_interval_ms\":1000,\"brpc_channel_protocol\":\"http\",\"brpc_channel_connection_type\":\"pooled\",\"recv_timeout_ms\":1200000,\"http_timeout_ms\":1200000}}"
- heu: "{\"mode\": \"PHEU\", \"schema\": \"paillier\", \"key_size\": 2048}"
- rayFedConfig:
- crossSiloCommBackend: "brpc_link"
-
-
springdoc:
api-docs:
enabled: true
diff --git a/config/application-p2p.yaml b/config/application-p2p.yaml
index cfaa885..43dcaa2 100644
--- a/config/application-p2p.yaml
+++ b/config/application-p2p.yaml
@@ -2,15 +2,15 @@ server:
tomcat:
accesslog:
enabled: true
- directory: /var/log/secretpad
+ directory: /var/log/easypsi
http-port: 8080
port: 443
ssl:
enabled: true
key-store: "file:./config/server.jks"
- key-store-password: secretpad
- key-alias: secretpad-server
- key-password: secretpad
+ key-store-password: easypsi
+ key-alias: easypsi-server
+ key-password: easypsi
key-store-type: JKS
spring:
@@ -19,7 +19,7 @@ spring:
pool:
size: 10
application:
- name: secretpad
+ name: easypsi
jpa:
database-platform: org.hibernate.community.dialect.SQLiteDialect
show-sql: false
@@ -29,7 +29,7 @@ spring:
datasource:
hibernate.dialect: org.hibernate.dialect.SQLiteDialect
driver-class-name: org.sqlite.JDBC
- url: jdbc:sqlite:./db/secretpad.sqlite
+ url: jdbc:sqlite:./db/easypsi.sqlite
hikari:
idle-timeout: 60000
maximum-pool-size: 1
@@ -50,7 +50,7 @@ logging:
org:
hibernate:
type: info
- path: /app/log/secretpad
+ path: /app/log/easypsi
kusciaapi:
address: ${KUSCIA_API_ADDRESS}
@@ -75,11 +75,11 @@ fabric:
job:
max-parallelism: 1
-secretpad:
+easypsi:
platform-type: P2P
node-id: ${NODE_ID}
- center-platform-service: secretpad.master.svc
- p2p-platform-service: secretpad
+ center-platform-service: easypsi.master.svc
+ p2p-platform-service: easypsi
gateway: ${KUSCIA_GW_ADDRESS}
auth:
enabled: true
@@ -92,14 +92,10 @@ secretpad:
data:
host-path: ${HOST_PATH}
dir-path: /app/data/
+ job:
+ audit: true
version:
- secretpad-image: ${SECRETPAD_IMAGE}
+ easypsi-image: ${EASYPSI_IMAGE}
kuscia-image: ${KUSCIA_IMAGE}
secretflow-image: ${SECRETFLOW_IMAGE}
-sfclusterDesc:
- deviceConfig:
- spu: "{\"runtime_config\":{\"protocol\":\"REF2K\",\"field\":\"FM64\"},\"link_desc\":{\"connect_retry_times\":60,\"connect_retry_interval_ms\":1000,\"brpc_channel_protocol\":\"http\",\"brpc_channel_connection_type\":\"pooled\",\"recv_timeout_ms\":1200000,\"http_timeout_ms\":1200000}}"
- heu: "{\"mode\": \"PHEU\", \"schema\": \"paillier\", \"key_size\": 2048}"
- rayFedConfig:
- crossSiloCommBackend: "brpc_link"
\ No newline at end of file
diff --git a/config/application-test.yaml b/config/application-test.yaml
index 8346403..921f1d1 100644
--- a/config/application-test.yaml
+++ b/config/application-test.yaml
@@ -2,15 +2,15 @@ server:
tomcat:
accesslog:
enabled: true
- directory: /var/log/secretpad
+ directory: /var/log/easypsi
http-port: 8080
port: 443
ssl:
enabled: true
key-store: "file:./config/server.jks"
- key-store-password: secretpad
- key-alias: secretpad-server
- key-password: secretpad
+ key-store-password: easypsi
+ key-alias: easypsi-server
+ key-password: easypsi
key-store-type: JKS
spring:
@@ -19,7 +19,7 @@ spring:
pool:
size: 10
application:
- name: secretpad
+ name: easypsi
jpa:
database-platform: org.hibernate.community.dialect.SQLiteDialect
show-sql: false
@@ -29,7 +29,7 @@ spring:
datasource:
hibernate.dialect: org.hibernate.dialect.SQLiteDialect
driver-class-name: org.sqlite.JDBC
- url: jdbc:sqlite:./db/secretpad.sqlite
+ url: jdbc:sqlite:./db/easypsi.sqlite
hikari:
idle-timeout: 60000
maximum-pool-size: 1
@@ -59,7 +59,7 @@ logging:
org:
hibernate:
type: info
- path: /app/log/secretpad
+ path: logs
job:
sync:
@@ -86,7 +86,7 @@ fabric:
keystore-path: config/fabric/keystore.pem
tls-cert-path: config/fabric/tls.pem
-secretpad:
+easypsi:
auth:
enabled: false
response:
@@ -96,14 +96,4 @@ secretpad:
max-file-size: -1 # -1 means not limit, e.g. 200MB, 1GB
max-request-size: -1 # -1 means not limit, e.g. 200MB, 1GB
data:
- dir-path: ../tmp/data/
-
-tee:
- capsule-mana: capsule-manager.#.svc # tee capsule-manager service
-
-sfclusterDesc:
- deviceConfig:
- spu: "{\"runtime_config\":{\"protocol\":\"REF2K\",\"field\":\"FM64\"},\"link_desc\":{\"connect_retry_times\":60,\"connect_retry_interval_ms\":1000,\"brpc_channel_protocol\":\"http\",\"brpc_channel_connection_type\":\"pooled\",\"recv_timeout_ms\":1200000,\"http_timeout_ms\":1200000}}"
- heu: "{\"mode\": \"PHEU\", \"schema\": \"paillier\", \"key_size\": 2048}"
- rayFedConfig:
- crossSiloCommBackend: "brpc_link"
\ No newline at end of file
+ dir-path: ../tmp/data/
\ No newline at end of file
diff --git a/config/application.yaml b/config/application.yaml
index 254f62b..9799658 100644
--- a/config/application.yaml
+++ b/config/application.yaml
@@ -2,16 +2,16 @@ server:
tomcat:
accesslog:
enabled: true
- directory: /var/log/secretpad
+ directory: /var/log/easypsi
http-port: 8080
http-port-inner: 9001
port: 443
ssl:
enabled: true
key-store: "file:./config/server.jks"
- key-store-password: secretpad
- key-alias: secretpad-server
- key-password: secretpad
+ key-store-password: easypsi
+ key-alias: easypsi-server
+ key-password: easypsi
key-store-type: JKS
spring:
@@ -20,7 +20,7 @@ spring:
pool:
size: 10
application:
- name: secretpad
+ name: easypsi
jpa:
database-platform: org.hibernate.community.dialect.SQLiteDialect
show-sql: false
@@ -30,7 +30,7 @@ spring:
datasource:
hibernate.dialect: org.hibernate.dialect.SQLiteDialect
driver-class-name: org.sqlite.JDBC
- url: jdbc:sqlite:./db/secretpad.sqlite
+ url: jdbc:sqlite:./db/easypsi.sqlite
hikari:
idle-timeout: 60000
maximum-pool-size: 1
@@ -54,6 +54,7 @@ logging:
kusciaapi:
address: root-kuscia-master:8083
+ protocol: ${KUSCIA_PROTOCOL:mtls} # notls tls mtls
tls:
cert-file: config/certs/client.crt
key-file: config/certs/client.pem
@@ -63,10 +64,10 @@ kusciaapi:
job:
max-parallelism: 1
-secretpad:
+easypsi:
platform-type: CENTER
node-id: kuscia-system
- center-platform-service: secretpad.master.svc
+ center-platform-service: easypsi.master.svc
gateway: http://localhost:8090
auth:
enabled: true
@@ -80,20 +81,13 @@ secretpad:
host-path: /home/kuscia/p2p/
dir-path: /app/data/
version:
- secretpad: secretpadTag
+ easypsi: easypsiTag
kuscia: kusciaTag
secretflow: secretflowTag
tee:
capsule-mana: capsule-manager.#.svc # tee capsule-manager service
-sfclusterDesc:
- deviceConfig:
- spu: "{\"runtime_config\":{\"protocol\":\"REF2K\",\"field\":\"FM64\"},\"link_desc\":{\"connect_retry_times\":60,\"connect_retry_interval_ms\":1000,\"brpc_channel_protocol\":\"http\",\"brpc_channel_connection_type\":\"pooled\",\"recv_timeout_ms\":1200000,\"http_timeout_ms\":1200000}}"
- heu: "{\"mode\": \"PHEU\", \"schema\": \"paillier\", \"key_size\": 2048}"
- rayFedConfig:
- crossSiloCommBackend: "brpc_link"
-
springdoc:
api-docs:
enabled: false
diff --git a/config/components/TrustedFlow.json b/config/components/TrustedFlow.json
deleted file mode 100644
index 5366536..0000000
--- a/config/components/TrustedFlow.json
+++ /dev/null
@@ -1,1135 +0,0 @@
-{
- "name": "TrustedFlow",
- "desc": "First-party TrustedFlow components.",
- "version": "0.0.1",
- "comps": [
- {
- "domain": "preprocessing",
- "name": "psi",
- "desc": "PSI between two parties.",
- "version": "0.0.1",
- "inputs": [
- {
- "name": "input1",
- "desc": "Individual table for party 1",
- "types": [
- "sf.table.individual"
- ],
- "attrs": [
- {
- "name": "key",
- "desc": "Column(s) used to join. If not provided, ids of the dataset will be used."
- }
- ]
- },
- {
- "name": "input2",
- "desc": "Individual table for party 2",
- "types": [
- "sf.table.individual"
- ],
- "attrs": [
- {
- "name": "key",
- "desc": "Column(s) used to join. If not provided, ids of the dataset will be used."
- }
- ]
- }
- ],
- "outputs": [
- {
- "name": "psi_output",
- "desc": "Output table",
- "types": [
- "sf.table.individual"
- ]
- }
- ]
- },
- {
- "domain": "preprocessing",
- "name": "feature_filter",
- "desc": "Drop features from the dataset.",
- "version": "0.0.1",
- "inputs": [
- {
- "name": "in_ds",
- "desc": "Input table.",
- "types": [
- "sf.table.individual"
- ],
- "attrs": [
- {
- "name": "drop_features",
- "desc": "Features to drop.",
- "col_min_cnt_inclusive": "1"
- }
- ]
- }
- ],
- "outputs": [
- {
- "name": "out_ds",
- "desc": "Output table.",
- "types": [
- "sf.table.individual"
- ]
- }
- ]
- },
- {
- "domain": "preprocessing",
- "name": "train_test_split",
- "desc": "Split datasets into random train and test subsets.\n- Please check: https://scikit-learn.org/stable/modules/generated/sklearn.model_selection.train_test_split.html",
- "version": "0.0.1",
- "attrs": [
- {
- "name": "train_size",
- "desc": "Proportion of the dataset to include in the train subset.",
- "type": "AT_FLOAT",
- "atomic": {
- "is_optional": true,
- "default_value": {
- "f": 0.75
- },
- "lower_bound_enabled": true,
- "lower_bound": {},
- "lower_bound_inclusive": true,
- "upper_bound_enabled": true,
- "upper_bound": {
- "f": 1
- },
- "upper_bound_inclusive": true
- }
- },
- {
- "name": "fix_random",
- "desc": "Whether to fix random.",
- "type": "AT_BOOL",
- "atomic": {
- "is_optional": true,
- "default_value": {
- "b": true
- }
- }
- },
- {
- "name": "random_state",
- "desc": "Specify the random seed of the shuffling.",
- "type": "AT_INT",
- "atomic": {
- "is_optional": true,
- "default_value": {
- "i64": "1024"
- },
- "lower_bound_enabled": true,
- "lower_bound": {}
- }
- },
- {
- "name": "shuffle",
- "desc": "Whether to shuffle the data before splitting.",
- "type": "AT_BOOL",
- "atomic": {
- "is_optional": true,
- "default_value": {
- "b": true
- }
- }
- }
- ],
- "inputs": [
- {
- "name": "input_data",
- "desc": "Input table.",
- "types": [
- "sf.table.individual"
- ]
- }
- ],
- "outputs": [
- {
- "name": "train",
- "desc": "Output train dataset.",
- "types": [
- "sf.table.individual"
- ]
- },
- {
- "name": "test",
- "desc": "Output test dataset.",
- "types": [
- "sf.table.individual"
- ]
- }
- ]
- },
- {
- "domain": "stats",
- "name": "pearsonr",
- "desc": "Calculate Pearson's product-moment correlation coefficient for individual dataset.",
- "version": "0.0.1",
- "inputs": [
- {
- "name": "input_data",
- "desc": "Input table.",
- "types": [
- "sf.table.individual"
- ],
- "attrs": [
- {
- "name": "feature_selects",
- "desc": "Specify which features to calculate correlation coefficient with. If empty, all features will be used"
- }
- ]
- }
- ],
- "outputs": [
- {
- "name": "report",
- "desc": "Output Pearson's product-moment correlation coefficient report.",
- "types": [
- "sf.report"
- ]
- }
- ]
- },
- {
- "domain": "stats",
- "name": "table_statistics",
- "desc": "Get a table of statistics,\nincluding each column's\n1. datatype\n2. total_count\n3. count\n4. count_na\n5. min\n6. max\n7. var\n8. std\n9. sem\n10. skewness\n11. kurtosis\n12. q1\n13. q2\n14. q3\n15. moment_2\n16. moment_3\n17. moment_4\n18. central_moment_2\n19. central_moment_3\n20. central_moment_4\n21. sum\n22. sum_2\n23. sum_3\n24. sum_4\n- moment_2 means E[X^2].\n- central_moment_2 means E[(X - mean(X))^2].\n- sum_2 means sum(X^2).",
- "version": "0.0.1",
- "inputs": [
- {
- "name": "input_data",
- "desc": "Input table.",
- "types": [
- "sf.table.individual"
- ]
- }
- ],
- "outputs": [
- {
- "name": "report",
- "desc": "Output table statistics report.",
- "types": [
- "sf.report"
- ]
- }
- ]
- },
- {
- "domain": "stats",
- "name": "vif",
- "desc": "Calculate Variance Inflation Factor(VIF) for individual dataset",
- "version": "0.0.1",
- "inputs": [
- {
- "name": "input_data",
- "desc": "Input table.",
- "types": [
- "sf.table.individual"
- ],
- "attrs": [
- {
- "name": "feature_selects",
- "desc": "Column(s) used to join. If not provided, ids of the Specify which features to calculate VIF with. If empty, all features will be used."
- }
- ]
- }
- ],
- "outputs": [
- {
- "name": "report",
- "desc": "Output Variance Inflation Factor(VIF) report.",
- "types": [
- "sf.report"
- ]
- }
- ]
- },
- {
- "domain": "feature",
- "name": "vert_woe_binning",
- "desc": "Generate Weight of Evidence (WOE) binning rules for individual datasets.",
- "version": "0.0.1",
- "attrs": [
- {
- "name": "binning_method",
- "desc": "How to bin features with numeric types: quantile\"(equal frequency)/\"bucket\"(equal width)",
- "type": "AT_STRING",
- "atomic": {
- "is_optional": true,
- "default_value": {
- "s": "quantile"
- },
- "allowed_values": {
- "ss": [
- "quantile",
- "bucket"
- ]
- }
- }
- },
- {
- "name": "positive_label",
- "desc": "Which value represent positive value in label.",
- "type": "AT_STRING",
- "atomic": {
- "is_optional": true,
- "default_value": {
- "s": "1"
- }
- }
- },
- {
- "name": "bin_num",
- "desc": "Max bin counts for one features.",
- "type": "AT_INT",
- "atomic": {
- "is_optional": true,
- "default_value": {
- "i64": "10"
- },
- "lower_bound_enabled": true,
- "lower_bound": {}
- }
- }
- ],
- "inputs": [
- {
- "name": "input_data",
- "desc": "Input table.",
- "types": [
- "sf.table.individual"
- ],
- "attrs": [
- {
- "name": "feature_selects",
- "desc": "which features should be binned.",
- "col_min_cnt_inclusive": "1"
- }
- ]
- }
- ],
- "outputs": [
- {
- "name": "woe_rule",
- "desc": "Output WOE rule.",
- "types": [
- "sf.rule.woe_binning"
- ]
- }
- ]
- },
- {
- "domain": "feature",
- "name": "vert_woe_substitution",
- "desc": "Substitute datasets' value by WOE substitution rules.",
- "version": "0.0.1",
- "inputs": [
- {
- "name": "input_data",
- "desc": "Dataset to be substituted.",
- "types": [
- "sf.table.individual"
- ]
- },
- {
- "name": "woe_rule",
- "desc": "WOE substitution rule.",
- "types": [
- "sf.rule.woe_binning"
- ]
- }
- ],
- "outputs": [
- {
- "name": "output_data",
- "desc": "Output substituted dataset.",
- "types": [
- "sf.table.individual"
- ]
- }
- ]
- },
- {
- "domain": "ml.eval",
- "name": "biclassification_eval",
- "desc": "Statistics evaluation for a bi-classification model on a dataset.\n1. summary_report: SummaryReport\n2. eq_frequent_bin_report: List[EqBinReport]\n3. eq_range_bin_report: List[EqBinReport]\n4. head_report: List[PrReport]\nreports for fpr = 0.001, 0.005, 0.01, 0.05, 0.1, 0.2",
- "version": "0.0.1",
- "attrs": [
- {
- "name": "bucket_num",
- "desc": "Number of buckets.",
- "type": "AT_INT",
- "atomic": {
- "is_optional": true,
- "default_value": {
- "i64": "10"
- },
- "lower_bound_enabled": true,
- "lower_bound": {
- "i64": "1"
- },
- "lower_bound_inclusive": true
- }
- },
- {
- "name": "min_item_cnt_per_bucket",
- "desc": "Min item cnt per bucket. If any bucket doesn't meet the requirement, error raises. For security reasons, we require this parameter to be at least 2.",
- "type": "AT_INT",
- "atomic": {
- "is_optional": true,
- "default_value": {
- "i64": "2"
- },
- "lower_bound_enabled": true,
- "lower_bound": {
- "i64": "2"
- },
- "lower_bound_inclusive": true
- }
- }
- ],
- "inputs": [
- {
- "name": "predictions",
- "desc": "Input table with predictions",
- "types": [
- "sf.table.individual"
- ],
- "attrs": [
- {
- "name": "label",
- "desc": "The real value column name",
- "col_min_cnt_inclusive": "1",
- "col_max_cnt_inclusive": "1"
- },
- {
- "name": "score",
- "desc": "The score value column name",
- "col_min_cnt_inclusive": "1",
- "col_max_cnt_inclusive": "1"
- }
- ]
- }
- ],
- "outputs": [
- {
- "name": "reports",
- "desc": "Output report.",
- "types": [
- "sf.report"
- ]
- }
- ]
- },
- {
- "domain": "ml.eval",
- "name": "prediction_bias_eval",
- "desc": "Calculate prediction bias, ie. average of predictions - average of labels.",
- "version": "0.0.1",
- "attrs": [
- {
- "name": "bucket_num",
- "desc": "Num of bucket.",
- "type": "AT_INT",
- "atomic": {
- "is_optional": true,
- "default_value": {
- "i64": "10"
- },
- "lower_bound_enabled": true,
- "lower_bound": {
- "i64": "1"
- },
- "lower_bound_inclusive": true
- }
- },
- {
- "name": "min_item_cnt_per_bucket",
- "desc": "Min item cnt per bucket. If any bucket doesn't meet the requirement, error raises. For security reasons, we require this parameter to be at least 2.",
- "type": "AT_INT",
- "atomic": {
- "is_optional": true,
- "default_value": {
- "i64": "2"
- },
- "lower_bound_enabled": true,
- "lower_bound": {
- "i64": "2"
- },
- "lower_bound_inclusive": true
- }
- },
- {
- "name": "bucket_method",
- "desc": "Bucket method.",
- "type": "AT_STRING",
- "atomic": {
- "is_optional": true,
- "default_value": {
- "s": "equal_width"
- },
- "allowed_values": {
- "ss": [
- "equal_width",
- "equal_frequency"
- ]
- }
- }
- }
- ],
- "inputs": [
- {
- "name": "predictions",
- "desc": "Input table with predictions.",
- "types": [
- "sf.table.individual"
- ],
- "attrs": [
- {
- "name": "label",
- "desc": "The real value column name",
- "col_min_cnt_inclusive": "1",
- "col_max_cnt_inclusive": "1"
- },
- {
- "name": "score",
- "desc": "The score value column name",
- "col_min_cnt_inclusive": "1",
- "col_max_cnt_inclusive": "1"
- }
- ]
- }
- ],
- "outputs": [
- {
- "name": "reports",
- "desc": "Output report.",
- "types": [
- "sf.report"
- ]
- }
- ]
- },
- {
- "domain": "ml.predict",
- "name": "xgb_predict",
- "desc": "Predict using the XGB model.",
- "version": "0.0.1",
- "attrs": [
- {
- "name": "pred_name",
- "desc": "Column name for predictions.",
- "type": "AT_STRING",
- "atomic": {
- "is_optional": true,
- "default_value": {
- "s": "pred"
- }
- }
- },
- {
- "name": "save_label",
- "desc": "Whether or not to save real label column into output pred table. If true, input feature_dataset must contain label column.",
- "type": "AT_BOOL",
- "atomic": {
- "is_optional": true,
- "default_value": {}
- }
- },
- {
- "name": "label_name",
- "desc": "Column name for label.",
- "type": "AT_STRING",
- "atomic": {
- "is_optional": true,
- "default_value": {
- "s": "label"
- }
- }
- },
- {
- "name": "save_id",
- "desc": "Whether to save id column into output pred table. If true, input feature_dataset must contain id column.",
- "type": "AT_BOOL",
- "atomic": {
- "is_optional": true,
- "default_value": {}
- }
- },
- {
- "name": "id_name",
- "desc": "Column name for id.",
- "type": "AT_STRING",
- "atomic": {
- "is_optional": true,
- "default_value": {
- "s": "id"
- }
- }
- },
- {
- "name": "col_names",
- "desc": "Extra column names into output pred table.",
- "type": "AT_STRINGS",
- "atomic": {
- "list_max_length_inclusive": "-1",
- "is_optional": true
- }
- }
- ],
- "inputs": [
- {
- "name": "feature_dataset",
- "desc": "Input feature dataset.",
- "types": [
- "sf.table.individual"
- ]
- },
- {
- "name": "model",
- "desc": "Input model.",
- "types": [
- "sf.model.xgb"
- ]
- }
- ],
- "outputs": [
- {
- "name": "pred",
- "desc": "Output prediction.",
- "types": [
- "sf.table.individual"
- ]
- }
- ]
- },
- {
- "domain": "ml.predict",
- "name": "lr_predict",
- "desc": "Predict using the lr model.",
- "version": "0.0.1",
- "attrs": [
- {
- "name": "pred_name",
- "desc": "Column name for predictions.",
- "type": "AT_STRING",
- "atomic": {
- "is_optional": true,
- "default_value": {
- "s": "pred"
- }
- }
- },
- {
- "name": "save_label",
- "desc": "Whether or not to save real label column into output pred table. If true, input feature_dataset must contain label column.",
- "type": "AT_BOOL",
- "atomic": {
- "is_optional": true,
- "default_value": {}
- }
- },
- {
- "name": "label_name",
- "desc": "Column name for label.",
- "type": "AT_STRING",
- "atomic": {
- "is_optional": true,
- "default_value": {
- "s": "label"
- }
- }
- },
- {
- "name": "save_id",
- "desc": "Whether to save id column into output pred table. If true, input feature_dataset must contain id column.",
- "type": "AT_BOOL",
- "atomic": {
- "is_optional": true,
- "default_value": {}
- }
- },
- {
- "name": "id_name",
- "desc": "Column name for id.",
- "type": "AT_STRING",
- "atomic": {
- "is_optional": true,
- "default_value": {
- "s": "id"
- }
- }
- },
- {
- "name": "col_names",
- "desc": "Column names into output pred table.",
- "type": "AT_STRINGS",
- "atomic": {
- "list_max_length_inclusive": "-1",
- "is_optional": true
- }
- }
- ],
- "inputs": [
- {
- "name": "feature_dataset",
- "desc": "Input feature dataset.",
- "types": [
- "sf.table.individual"
- ]
- },
- {
- "name": "model",
- "desc": "Input model.",
- "types": [
- "sf.model.lr"
- ]
- }
- ],
- "outputs": [
- {
- "name": "pred",
- "desc": "Output prediction.",
- "types": [
- "sf.table.individual"
- ]
- }
- ]
- },
- {
- "domain": "ml.train",
- "name": "xgb_train",
- "desc": "Provides both classification and regression tree boosting (also known as GBDT, GBM) for individual dataset.",
- "version": "0.0.1",
- "attrs": [
- {
- "name": "num_boost_round",
- "desc": "Number of boosting iterations.",
- "type": "AT_INT",
- "atomic": {
- "is_optional": true,
- "default_value": {
- "i64": "10"
- },
- "lower_bound_enabled": true,
- "lower_bound": {
- "i64": "1"
- },
- "lower_bound_inclusive": true,
- "upper_bound_enabled": true,
- "upper_bound": {
- "i64": "1024"
- },
- "upper_bound_inclusive": true
- }
- },
- {
- "name": "max_depth",
- "desc": "Maximum depth of a tree.",
- "type": "AT_INT",
- "atomic": {
- "is_optional": true,
- "default_value": {
- "i64": "6"
- },
- "lower_bound_enabled": true,
- "lower_bound": {
- "i64": "1"
- },
- "lower_bound_inclusive": true,
- "upper_bound_enabled": true,
- "upper_bound": {
- "i64": "16"
- },
- "upper_bound_inclusive": true
- }
- },
- {
- "name": "max_leaves",
- "desc": "Maximum leaf of a tree. 0 indicates no limit.",
- "type": "AT_INT",
- "atomic": {
- "is_optional": true,
- "default_value": {},
- "lower_bound_enabled": true,
- "lower_bound": {},
- "lower_bound_inclusive": true,
- "upper_bound_enabled": true,
- "upper_bound": {
- "i64": "32768"
- },
- "upper_bound_inclusive": true
- }
- },
- {
- "name": "seed",
- "desc": "Pseudorandom number generator seed.",
- "type": "AT_INT",
- "atomic": {
- "is_optional": true,
- "default_value": {
- "i64": "42"
- },
- "lower_bound_enabled": true,
- "lower_bound": {},
- "lower_bound_inclusive": true
- }
- },
- {
- "name": "learning_rate",
- "desc": "Step size shrinkage used in update to prevent overfitting.",
- "type": "AT_FLOAT",
- "atomic": {
- "is_optional": true,
- "default_value": {
- "f": 0.3
- },
- "lower_bound_enabled": true,
- "lower_bound": {},
- "upper_bound_enabled": true,
- "upper_bound": {
- "f": 1
- },
- "upper_bound_inclusive": true
- }
- },
- {
- "name": "lambda",
- "desc": "L2 regularization term on weights.",
- "type": "AT_FLOAT",
- "atomic": {
- "is_optional": true,
- "default_value": {
- "f": 1
- },
- "lower_bound_enabled": true,
- "lower_bound": {},
- "lower_bound_inclusive": true,
- "upper_bound_enabled": true,
- "upper_bound": {
- "f": 10000
- },
- "upper_bound_inclusive": true
- }
- },
- {
- "name": "gamma",
- "desc": "Greater than 0 means pre-pruning enabled. If gain of a node is less than this value, it would be pruned.",
- "type": "AT_FLOAT",
- "atomic": {
- "is_optional": true,
- "default_value": {},
- "lower_bound_enabled": true,
- "lower_bound": {},
- "lower_bound_inclusive": true,
- "upper_bound_enabled": true,
- "upper_bound": {
- "f": 10000
- },
- "upper_bound_inclusive": true
- }
- },
- {
- "name": "colsample_bytree",
- "desc": "Subsample ratio of columns when constructing each tree.",
- "type": "AT_FLOAT",
- "atomic": {
- "is_optional": true,
- "default_value": {
- "f": 1
- },
- "lower_bound_enabled": true,
- "lower_bound": {},
- "upper_bound_enabled": true,
- "upper_bound": {
- "f": 1
- },
- "upper_bound_inclusive": true
- }
- },
- {
- "name": "base_score",
- "desc": "The initial prediction score of all instances, global bias.",
- "type": "AT_FLOAT",
- "atomic": {
- "is_optional": true,
- "default_value": {
- "f": 0.5
- },
- "lower_bound_enabled": true,
- "lower_bound": {},
- "upper_bound_enabled": true,
- "upper_bound": {
- "f": 1
- }
- }
- },
- {
- "name": "min_child_weight",
- "desc": "Minimum sum of instance weight (hessian) needed in a child. If the tree partition step results in a leaf node with the sum of instance weight less than min_child_weight, then the building process will give up further partitioning",
- "type": "AT_FLOAT",
- "atomic": {
- "is_optional": true,
- "default_value": {
- "f": 1
- },
- "lower_bound_enabled": true,
- "lower_bound": {},
- "lower_bound_inclusive": true,
- "upper_bound_enabled": true,
- "upper_bound": {
- "f": 1000
- },
- "upper_bound_inclusive": true
- }
- },
- {
- "name": "objective",
- "desc": "Specify the learning objective.",
- "type": "AT_STRING",
- "atomic": {
- "is_optional": true,
- "default_value": {
- "s": "binary:logistic"
- },
- "allowed_values": {
- "ss": [
- "reg:squarederror",
- "binary:logistic"
- ]
- }
- }
- },
- {
- "name": "alpha",
- "desc": "L1 regularization term on weights. Increasing this value will make model more conservative",
- "type": "AT_FLOAT",
- "atomic": {
- "is_optional": true,
- "default_value": {},
- "lower_bound_enabled": true,
- "lower_bound": {},
- "lower_bound_inclusive": true,
- "upper_bound_enabled": true,
- "upper_bound": {
- "f": 10000
- },
- "upper_bound_inclusive": true
- }
- },
- {
- "name": "subsample",
- "desc": "Subsample ratio of the training instance.",
- "type": "AT_FLOAT",
- "atomic": {
- "is_optional": true,
- "default_value": {
- "f": 1
- },
- "lower_bound_enabled": true,
- "lower_bound": {},
- "upper_bound_enabled": true,
- "upper_bound": {
- "f": 1
- },
- "upper_bound_inclusive": true
- }
- },
- {
- "name": "max_bin",
- "desc": "Maximum number of discrete bins to bucket continuous features. Only used if tree_method is set to hist, approx or gpu_hist.",
- "type": "AT_INT",
- "atomic": {
- "is_optional": true,
- "default_value": {
- "i64": "10"
- },
- "lower_bound_enabled": true,
- "lower_bound": {},
- "upper_bound_enabled": true,
- "upper_bound": {
- "i64": "254"
- }
- }
- },
- {
- "name": "tree_method",
- "desc": "The tree construction algorithm used in XGBoost.",
- "type": "AT_STRING",
- "atomic": {
- "is_optional": true,
- "default_value": {
- "s": "auto"
- },
- "allowed_values": {
- "ss": [
- "auto",
- "exact",
- "approx",
- "hist"
- ]
- }
- }
- },
- {
- "name": "booster",
- "desc": "Which booster to use",
- "type": "AT_STRING",
- "atomic": {
- "is_optional": true,
- "default_value": {
- "s": "gbtree"
- },
- "allowed_values": {
- "ss": [
- "gbtree",
- "gblinear",
- "dart"
- ]
- }
- }
- }
- ],
- "inputs": [
- {
- "name": "train_dataset",
- "desc": "Input table.",
- "types": [
- "sf.table.individual"
- ]
- }
- ],
- "outputs": [
- {
- "name": "output_model",
- "desc": "Output model.",
- "types": [
- "sf.model.xgb"
- ]
- }
- ]
- },
- {
- "domain": "ml.train",
- "name": "lr_train",
- "desc": "linear or logistic regression training.",
- "version": "0.0.1",
- "attrs": [
- {
- "name": "max_iter",
- "desc": "Maximum number of iterations taken for the solvers to converge.",
- "type": "AT_INT",
- "atomic": {
- "is_optional": true,
- "default_value": {
- "i64": "10"
- },
- "lower_bound_enabled": true,
- "lower_bound": {
- "i64": "1"
- },
- "lower_bound_inclusive": true,
- "upper_bound_enabled": true,
- "upper_bound": {
- "i64": "10000"
- },
- "upper_bound_inclusive": true
- }
- },
- {
- "name": "reg_type",
- "desc": "Regression type",
- "type": "AT_STRING",
- "atomic": {
- "is_optional": true,
- "default_value": {
- "s": "logistic"
- },
- "allowed_values": {
- "ss": [
- "linear",
- "logistic"
- ]
- }
- }
- },
- {
- "name": "l2_norm",
- "desc": "L2 regularization term.",
- "type": "AT_FLOAT",
- "atomic": {
- "is_optional": true,
- "default_value": {
- "f": 1
- },
- "lower_bound_enabled": true,
- "lower_bound": {},
- "lower_bound_inclusive": true,
- "upper_bound_enabled": true,
- "upper_bound": {
- "f": 10000
- }
- }
- },
- {
- "name": "tol",
- "desc": "Tolerance for stopping criteria.",
- "type": "AT_FLOAT",
- "atomic": {
- "is_optional": true,
- "default_value": {
- "f": 0.0001
- },
- "lower_bound_enabled": true,
- "lower_bound": {},
- "upper_bound_enabled": true,
- "upper_bound": {
- "f": 1
- }
- }
- },
- {
- "name": "penalty",
- "desc": "The penalty(aka regularization term) to be used.",
- "type": "AT_STRING",
- "atomic": {
- "is_optional": true,
- "default_value": {
- "s": "l2"
- },
- "allowed_values": {
- "ss": [
- "l1",
- "l2",
- "elasticnet",
- "None"
- ]
- }
- }
- }
- ],
- "inputs": [
- {
- "name": "train_dataset",
- "desc": "Input train dataset.",
- "types": [
- "sf.table.individual"
- ]
- }
- ],
- "outputs": [
- {
- "name": "output_model",
- "desc": "Output model.",
- "types": [
- "sf.model.lr"
- ]
- }
- ]
- }
- ]
-}
\ No newline at end of file
diff --git a/config/components/secretflow.json b/config/components/secretflow.json
deleted file mode 100644
index cc0fdf2..0000000
--- a/config/components/secretflow.json
+++ /dev/null
@@ -1,1945 +0,0 @@
-{
- "name": "secretflow",
- "desc": "First-party SecretFlow components.",
- "version": "0.0.1",
- "comps": [
- {
- "domain": "feature",
- "name": "vert_woe_binning",
- "desc": "Generate Weight of Evidence (WOE) binning rules for vertical partitioning datasets.",
- "version": "0.0.1",
- "attrs": [
- {
- "name": "secure_device_type",
- "desc": "Use SPU(Secure multi-party computation or MPC) or HEU(Homomorphic encryption or HE) to secure bucket summation.",
- "type": "AT_STRING",
- "atomic": {
- "isOptional": true,
- "defaultValue": {
- "s": "spu"
- },
- "allowedValues": {
- "ss": [
- "spu",
- "heu"
- ]
- }
- }
- },
- {
- "name": "binning_method",
- "desc": "How to bin features with numeric types: \"quantile\"(equal frequency)/\"chimerge\"(ChiMerge from AAAI92-019: https://www.aaai.org/Papers/AAAI/1992/AAAI92-019.pdf)",
- "type": "AT_STRING",
- "atomic": {
- "isOptional": true,
- "defaultValue": {
- "s": "quantile"
- },
- "allowedValues": {
- "ss": [
- "quantile",
- "chimerge"
- ]
- }
- }
- },
- {
- "name": "bin_num",
- "desc": "Max bin counts for one features.",
- "type": "AT_INT",
- "atomic": {
- "isOptional": true,
- "defaultValue": {
- "i64": "10"
- },
- "hasLowerBound": true,
- "lowerBound": {}
- }
- },
- {
- "name": "positive_label",
- "desc": "Which value represent positive value in label.",
- "type": "AT_STRING",
- "atomic": {
- "isOptional": true,
- "defaultValue": {
- "s": "1"
- }
- }
- },
- {
- "name": "chimerge_init_bins",
- "desc": "Max bin counts for initialization binning in ChiMerge.",
- "type": "AT_INT",
- "atomic": {
- "isOptional": true,
- "defaultValue": {
- "i64": "100"
- },
- "hasLowerBound": true,
- "lowerBound": {
- "i64": "2"
- }
- }
- },
- {
- "name": "chimerge_target_bins",
- "desc": "Stop merging if remaining bin counts is less than or equal to this value.",
- "type": "AT_INT",
- "atomic": {
- "isOptional": true,
- "defaultValue": {
- "i64": "10"
- },
- "hasLowerBound": true,
- "lowerBound": {
- "i64": "2"
- },
- "lowerBoundInclusive": true
- }
- },
- {
- "name": "chimerge_target_pvalue",
- "desc": "Stop merging if biggest pvalue of remaining bins is greater than this value.",
- "type": "AT_FLOAT",
- "atomic": {
- "isOptional": true,
- "defaultValue": {
- "f": 0.1
- },
- "hasLowerBound": true,
- "lowerBound": {},
- "hasUpperBound": true,
- "upperBound": {
- "f": 1.0
- },
- "upperBoundInclusive": true
- }
- }
- ],
- "inputs": [
- {
- "name": "input_data",
- "desc": "Input vertical table.",
- "types": [
- "sf.table.vertical_table"
- ],
- "attrs": [
- {
- "name": "feature_selects",
- "desc": "which features should be binned.",
- "colMinCntInclusive": "1"
- }
- ]
- }
- ],
- "outputs": [
- {
- "name": "woe_rule",
- "desc": "Output WOE rule.",
- "types": [
- "sf.rule.woe_binning"
- ]
- }
- ]
- },
- {
- "domain": "feature",
- "name": "vert_woe_substitution",
- "desc": "Substitute datasets' value by WOE substitution rules.",
- "version": "0.0.1",
- "inputs": [
- {
- "name": "input_data",
- "desc": "Vertical partitioning dataset to be substituted.",
- "types": [
- "sf.table.vertical_table"
- ]
- },
- {
- "name": "woe_rule",
- "desc": "Input WOE substitution rule.",
- "types": [
- "sf.rule.woe_binning"
- ]
- }
- ],
- "outputs": [
- {
- "name": "output_data",
- "desc": "Output vertical table.",
- "types": [
- "sf.table.vertical_table"
- ]
- }
- ]
- },
- {
- "domain": "ml.eval",
- "name": "biclassification_eval",
- "desc": "Statistics evaluation for a bi-classification model on a dataset.\n1. summary_report: SummaryReport\n2. group_reports: List[GroupReport]\n3. eq_frequent_bin_report: List[EqBinReport]\n4. eq_range_bin_report: List[EqBinReport]\n5. head_report: List[PrReport]\nreports for fpr = 0.001, 0.005, 0.01, 0.05, 0.1, 0.2",
- "version": "0.0.1",
- "attrs": [
- {
- "name": "bucket_size",
- "desc": "Number of buckets.",
- "type": "AT_INT",
- "atomic": {
- "isOptional": true,
- "defaultValue": {
- "i64": "10"
- },
- "hasLowerBound": true,
- "lowerBound": {
- "i64": "1"
- },
- "lowerBoundInclusive": true
- }
- },
- {
- "name": "min_item_cnt_per_bucket",
- "desc": "Min item cnt per bucket. If any bucket doesn't meet the requirement, error raises. For security reasons, we require this parameter to be at least 5.",
- "type": "AT_INT",
- "atomic": {
- "isOptional": true,
- "defaultValue": {
- "i64": "5"
- },
- "hasLowerBound": true,
- "lowerBound": {
- "i64": "5"
- },
- "lowerBoundInclusive": true
- }
- }
- ],
- "inputs": [
- {
- "name": "labels",
- "desc": "Input table with labels",
- "types": [
- "sf.table.vertical_table",
- "sf.table.individual"
- ],
- "attrs": [
- {
- "name": "col",
- "desc": "The column name to use in the dataset. If not provided, the label of dataset will be used by default.",
- "colMaxCntInclusive": "1"
- }
- ]
- },
- {
- "name": "predictions",
- "desc": "Input table with predictions",
- "types": [
- "sf.table.vertical_table",
- "sf.table.individual"
- ],
- "attrs": [
- {
- "name": "col",
- "desc": "The column name to use in the dataset. If not provided, the label of dataset will be used by default.",
- "colMaxCntInclusive": "1"
- }
- ]
- }
- ],
- "outputs": [
- {
- "name": "reports",
- "desc": "Output report.",
- "types": [
- "sf.report"
- ]
- }
- ]
- },
- {
- "domain": "ml.eval",
- "name": "prediction_bias_eval",
- "desc": "Calculate prediction bias, ie. average of predictions - average of labels.",
- "version": "0.0.1",
- "attrs": [
- {
- "name": "bucket_num",
- "desc": "Num of bucket.",
- "type": "AT_INT",
- "atomic": {
- "isOptional": true,
- "defaultValue": {
- "i64": "10"
- },
- "hasLowerBound": true,
- "lowerBound": {
- "i64": "1"
- },
- "lowerBoundInclusive": true
- }
- },
- {
- "name": "min_item_cnt_per_bucket",
- "desc": "Min item cnt per bucket. If any bucket doesn't meet the requirement, error raises. For security reasons, we require this parameter to be at least 2.",
- "type": "AT_INT",
- "atomic": {
- "isOptional": true,
- "defaultValue": {
- "i64": "2"
- },
- "hasLowerBound": true,
- "lowerBound": {
- "i64": "2"
- },
- "lowerBoundInclusive": true
- }
- },
- {
- "name": "bucket_method",
- "desc": "Bucket method.",
- "type": "AT_STRING",
- "atomic": {
- "isOptional": true,
- "defaultValue": {
- "s": "equal_width"
- },
- "allowedValues": {
- "ss": [
- "equal_width",
- "equal_frequency"
- ]
- }
- }
- }
- ],
- "inputs": [
- {
- "name": "labels",
- "desc": "Input table with labels.",
- "types": [
- "sf.table.vertical_table",
- "sf.table.individual"
- ],
- "attrs": [
- {
- "name": "col",
- "desc": "The column name to use in the dataset. If not provided, the label of dataset will be used by default.",
- "colMaxCntInclusive": "1"
- }
- ]
- },
- {
- "name": "predictions",
- "desc": "Input table with predictions.",
- "types": [
- "sf.table.vertical_table",
- "sf.table.individual"
- ],
- "attrs": [
- {
- "name": "col",
- "desc": "The column name to use in the dataset. If not provided, the label of dataset will be used by default.",
- "colMaxCntInclusive": "1"
- }
- ]
- }
- ],
- "outputs": [
- {
- "name": "result",
- "desc": "Output report.",
- "types": [
- "sf.report"
- ]
- }
- ]
- },
- {
- "domain": "ml.eval",
- "name": "ss_pvalue",
- "desc": "Calculate P-Value for LR model training on vertical partitioning dataset by using secret sharing.\nFor large dataset(large than 10w samples & 200 features),\nrecommend to use [Ring size: 128, Fxp: 40] options for SPU device.",
- "version": "0.0.1",
- "inputs": [
- {
- "name": "model",
- "desc": "Input model.",
- "types": [
- "sf.model.ss_sgd"
- ]
- },
- {
- "name": "input_data",
- "desc": "Input vertical table.",
- "types": [
- "sf.table.vertical_table"
- ]
- }
- ],
- "outputs": [
- {
- "name": "report",
- "desc": "Output P-Value report.",
- "types": [
- "sf.report"
- ]
- }
- ]
- },
- {
- "domain": "ml.predict",
- "name": "sgb_predict",
- "desc": "Predict using SGB model.",
- "version": "0.0.1",
- "attrs": [
- {
- "name": "receiver",
- "desc": "Party of receiver.",
- "type": "AT_STRING",
- "atomic": {}
- },
- {
- "name": "pred_name",
- "desc": "Name for prediction column",
- "type": "AT_STRING",
- "atomic": {
- "isOptional": true,
- "defaultValue": {
- "s": "pred"
- }
- }
- },
- {
- "name": "save_ids",
- "desc": "Whether to save ids columns into output prediction table. If true, input feature_dataset must contain id columns, and receiver party must be id owner.",
- "type": "AT_BOOL",
- "atomic": {
- "isOptional": true,
- "defaultValue": {}
- }
- },
- {
- "name": "save_label",
- "desc": "Whether or not to save real label columns into output pred file. If true, input feature_dataset must contain label columns and receiver party must be label owner.",
- "type": "AT_BOOL",
- "atomic": {
- "isOptional": true,
- "defaultValue": {}
- }
- }
- ],
- "inputs": [
- {
- "name": "model",
- "desc": "model",
- "types": [
- "sf.model.sgb"
- ]
- },
- {
- "name": "feature_dataset",
- "desc": "Input vertical table.",
- "types": [
- "sf.table.vertical_table"
- ]
- }
- ],
- "outputs": [
- {
- "name": "pred",
- "desc": "Output prediction.",
- "types": [
- "sf.table.individual"
- ]
- }
- ]
- },
- {
- "domain": "ml.predict",
- "name": "ss_glm_predict",
- "desc": "Predict using the SSGLM model.",
- "version": "0.0.1",
- "attrs": [
- {
- "name": "receiver",
- "desc": "Party of receiver.",
- "type": "AT_STRING",
- "atomic": {}
- },
- {
- "name": "pred_name",
- "desc": "Column name for predictions.",
- "type": "AT_STRING",
- "atomic": {
- "isOptional": true,
- "defaultValue": {
- "s": "pred"
- }
- }
- },
- {
- "name": "save_ids",
- "desc": "Whether to save ids columns into output prediction table. If true, input feature_dataset must contain id columns, and receiver party must be id owner.",
- "type": "AT_BOOL",
- "atomic": {
- "isOptional": true,
- "defaultValue": {}
- }
- },
- {
- "name": "save_label",
- "desc": "Whether or not to save real label columns into output pred file. If true, input feature_dataset must contain label columns and receiver party must be label owner.",
- "type": "AT_BOOL",
- "atomic": {
- "isOptional": true,
- "defaultValue": {}
- }
- },
- {
- "name": "offset_col",
- "desc": "Specify a column to use as the offset",
- "type": "AT_STRING",
- "atomic": {
- "isOptional": true,
- "defaultValue": {}
- }
- }
- ],
- "inputs": [
- {
- "name": "model",
- "desc": "Input model.",
- "types": [
- "sf.model.ss_glm"
- ]
- },
- {
- "name": "feature_dataset",
- "desc": "Input vertical table.",
- "types": [
- "sf.table.vertical_table"
- ]
- }
- ],
- "outputs": [
- {
- "name": "pred",
- "desc": "Output prediction.",
- "types": [
- "sf.table.individual"
- ]
- }
- ]
- },
- {
- "domain": "ml.predict",
- "name": "ss_sgd_predict",
- "desc": "Predict using the SS-SGD model.",
- "version": "0.0.1",
- "attrs": [
- {
- "name": "batch_size",
- "desc": "The number of training examples utilized in one iteration.",
- "type": "AT_INT",
- "atomic": {
- "isOptional": true,
- "defaultValue": {
- "i64": "1024"
- },
- "hasLowerBound": true,
- "lowerBound": {}
- }
- },
- {
- "name": "receiver",
- "desc": "Party of receiver.",
- "type": "AT_STRING",
- "atomic": {}
- },
- {
- "name": "pred_name",
- "desc": "Column name for predictions.",
- "type": "AT_STRING",
- "atomic": {
- "isOptional": true,
- "defaultValue": {
- "s": "pred"
- }
- }
- },
- {
- "name": "save_ids",
- "desc": "Whether to save ids columns into output prediction table. If true, input feature_dataset must contain id columns, and receiver party must be id owner.",
- "type": "AT_BOOL",
- "atomic": {
- "isOptional": true,
- "defaultValue": {}
- }
- },
- {
- "name": "save_label",
- "desc": "Whether or not to save real label columns into output pred file. If true, input feature_dataset must contain label columns and receiver party must be label owner.",
- "type": "AT_BOOL",
- "atomic": {
- "isOptional": true,
- "defaultValue": {}
- }
- }
- ],
- "inputs": [
- {
- "name": "model",
- "desc": "Input model.",
- "types": [
- "sf.model.ss_sgd"
- ]
- },
- {
- "name": "feature_dataset",
- "desc": "Input vertical table.",
- "types": [
- "sf.table.vertical_table"
- ]
- }
- ],
- "outputs": [
- {
- "name": "pred",
- "desc": "Output prediction.",
- "types": [
- "sf.table.individual"
- ]
- }
- ]
- },
- {
- "domain": "ml.predict",
- "name": "ss_xgb_predict",
- "desc": "Predict using the SS-XGB model.",
- "version": "0.0.1",
- "attrs": [
- {
- "name": "receiver",
- "desc": "Party of receiver.",
- "type": "AT_STRING",
- "atomic": {}
- },
- {
- "name": "pred_name",
- "desc": "Column name for predictions.",
- "type": "AT_STRING",
- "atomic": {
- "isOptional": true,
- "defaultValue": {
- "s": "pred"
- }
- }
- },
- {
- "name": "save_ids",
- "desc": "Whether to save ids columns into output prediction table. If true, input feature_dataset must contain id columns, and receiver party must be id owner.",
- "type": "AT_BOOL",
- "atomic": {
- "isOptional": true,
- "defaultValue": {}
- }
- },
- {
- "name": "save_label",
- "desc": "Whether or not to save real label columns into output pred file. If true, input feature_dataset must contain label columns and receiver party must be label owner.",
- "type": "AT_BOOL",
- "atomic": {
- "isOptional": true,
- "defaultValue": {}
- }
- }
- ],
- "inputs": [
- {
- "name": "model",
- "desc": "Input model.",
- "types": [
- "sf.model.ss_xgb"
- ]
- },
- {
- "name": "feature_dataset",
- "desc": "Input vertical table.",
- "types": [
- "sf.table.vertical_table"
- ]
- }
- ],
- "outputs": [
- {
- "name": "pred",
- "desc": "Output prediction.",
- "types": [
- "sf.table.individual"
- ]
- }
- ]
- },
- {
- "domain": "ml.train",
- "name": "sgb_train",
- "desc": "Provides both classification and regression tree boosting (also known as GBDT, GBM)\nfor vertical split dataset setting by using secure boost.\n- SGB is short for SecureBoost. Compared to its safer counterpart SS-XGB, SecureBoost focused on protecting label holder.\n- Check https://arxiv.org/abs/1901.08755.",
- "version": "0.0.1",
- "attrs": [
- {
- "name": "num_boost_round",
- "desc": "Number of boosting iterations.",
- "type": "AT_INT",
- "atomic": {
- "isOptional": true,
- "defaultValue": {
- "i64": "10"
- },
- "hasLowerBound": true,
- "lowerBound": {
- "i64": "1"
- },
- "lowerBoundInclusive": true
- }
- },
- {
- "name": "max_depth",
- "desc": "Maximum depth of a tree.",
- "type": "AT_INT",
- "atomic": {
- "isOptional": true,
- "defaultValue": {
- "i64": "5"
- },
- "hasLowerBound": true,
- "lowerBound": {
- "i64": "1"
- },
- "lowerBoundInclusive": true,
- "hasUpperBound": true,
- "upperBound": {
- "i64": "16"
- },
- "upperBoundInclusive": true
- }
- },
- {
- "name": "learning_rate",
- "desc": "Step size shrinkage used in update to prevent overfitting.",
- "type": "AT_FLOAT",
- "atomic": {
- "isOptional": true,
- "defaultValue": {
- "f": 0.1
- },
- "hasLowerBound": true,
- "lowerBound": {},
- "hasUpperBound": true,
- "upperBound": {
- "f": 1.0
- },
- "upperBoundInclusive": true
- }
- },
- {
- "name": "objective",
- "desc": "Specify the learning objective.",
- "type": "AT_STRING",
- "atomic": {
- "isOptional": true,
- "defaultValue": {
- "s": "logistic"
- },
- "allowedValues": {
- "ss": [
- "linear",
- "logistic"
- ]
- }
- }
- },
- {
- "name": "reg_lambda",
- "desc": "L2 regularization term on weights.",
- "type": "AT_FLOAT",
- "atomic": {
- "isOptional": true,
- "defaultValue": {
- "f": 0.1
- },
- "hasLowerBound": true,
- "lowerBound": {},
- "lowerBoundInclusive": true,
- "hasUpperBound": true,
- "upperBound": {
- "f": 10000.0
- },
- "upperBoundInclusive": true
- }
- },
- {
- "name": "gamma",
- "desc": "Greater than 0 means pre-pruning enabled. If gain of a node is less than this value, it would be pruned.",
- "type": "AT_FLOAT",
- "atomic": {
- "isOptional": true,
- "defaultValue": {
- "f": 0.1
- },
- "hasLowerBound": true,
- "lowerBound": {},
- "lowerBoundInclusive": true,
- "hasUpperBound": true,
- "upperBound": {
- "f": 10000.0
- },
- "upperBoundInclusive": true
- }
- },
- {
- "name": "colsample_by_tree",
- "desc": "Subsample ratio of columns when constructing each tree.",
- "type": "AT_FLOAT",
- "atomic": {
- "isOptional": true,
- "defaultValue": {
- "f": 1.0
- },
- "hasLowerBound": true,
- "lowerBound": {},
- "hasUpperBound": true,
- "upperBound": {
- "f": 1.0
- },
- "upperBoundInclusive": true
- }
- },
- {
- "name": "sketch_eps",
- "desc": "This roughly translates into O(1 / sketch_eps) number of bins.",
- "type": "AT_FLOAT",
- "atomic": {
- "isOptional": true,
- "defaultValue": {
- "f": 0.1
- },
- "hasLowerBound": true,
- "lowerBound": {},
- "hasUpperBound": true,
- "upperBound": {
- "f": 1.0
- },
- "upperBoundInclusive": true
- }
- },
- {
- "name": "base_score",
- "desc": "The initial prediction score of all instances, global bias.",
- "type": "AT_FLOAT",
- "atomic": {
- "isOptional": true,
- "defaultValue": {},
- "hasLowerBound": true,
- "lowerBound": {},
- "lowerBoundInclusive": true
- }
- },
- {
- "name": "seed",
- "desc": "Pseudorandom number generator seed.",
- "type": "AT_INT",
- "atomic": {
- "isOptional": true,
- "defaultValue": {
- "i64": "42"
- },
- "hasLowerBound": true,
- "lowerBound": {},
- "lowerBoundInclusive": true
- }
- },
- {
- "name": "fixed_point_parameter",
- "desc": "Any floating point number encoded by heu, will multiply a scale and take the round, scale = 2 ** fixed_point_parameter. larger value may mean more numerical accuracy, but too large will lead to overflow problem.",
- "type": "AT_INT",
- "atomic": {
- "isOptional": true,
- "defaultValue": {
- "i64": "20"
- },
- "hasLowerBound": true,
- "lowerBound": {
- "i64": "1"
- },
- "lowerBoundInclusive": true,
- "hasUpperBound": true,
- "upperBound": {
- "i64": "100"
- },
- "upperBoundInclusive": true
- }
- },
- {
- "name": "first_tree_with_label_holder_feature",
- "desc": "Whether to train the first tree with label holder's own features.",
- "type": "AT_BOOL",
- "atomic": {
- "isOptional": true,
- "defaultValue": {}
- }
- },
- {
- "name": "batch_encoding_enabled",
- "desc": "If use batch encoding optimization.",
- "type": "AT_BOOL",
- "atomic": {
- "isOptional": true,
- "defaultValue": {
- "b": true
- }
- }
- },
- {
- "name": "enable_quantization",
- "desc": "Whether enable quantization of g and h.",
- "type": "AT_BOOL",
- "atomic": {
- "isOptional": true,
- "defaultValue": {}
- }
- },
- {
- "name": "quantization_scale",
- "desc": "Scale the sum of g to the specified value.",
- "type": "AT_FLOAT",
- "atomic": {
- "isOptional": true,
- "defaultValue": {
- "f": 10000.0
- },
- "hasLowerBound": true,
- "lowerBound": {},
- "lowerBoundInclusive": true,
- "hasUpperBound": true,
- "upperBound": {
- "f": 10000000.0
- },
- "upperBoundInclusive": true
- }
- },
- {
- "name": "max_leaf",
- "desc": "Maximum leaf of a tree. Only effective if train leaf wise.",
- "type": "AT_INT",
- "atomic": {
- "isOptional": true,
- "defaultValue": {
- "i64": "15"
- },
- "hasLowerBound": true,
- "lowerBound": {
- "i64": "1"
- },
- "lowerBoundInclusive": true,
- "hasUpperBound": true,
- "upperBound": {
- "i64": "32768"
- },
- "upperBoundInclusive": true
- }
- },
- {
- "name": "rowsample_by_tree",
- "desc": "Row sub sample ratio of the training instances.",
- "type": "AT_FLOAT",
- "atomic": {
- "isOptional": true,
- "defaultValue": {
- "f": 1.0
- },
- "hasLowerBound": true,
- "lowerBound": {},
- "hasUpperBound": true,
- "upperBound": {
- "f": 1.0
- },
- "upperBoundInclusive": true
- }
- },
- {
- "name": "enable_goss",
- "desc": "Whether to enable GOSS.",
- "type": "AT_BOOL",
- "atomic": {
- "isOptional": true,
- "defaultValue": {}
- }
- },
- {
- "name": "top_rate",
- "desc": "GOSS-specific parameter. The fraction of large gradients to sample.",
- "type": "AT_FLOAT",
- "atomic": {
- "isOptional": true,
- "defaultValue": {
- "f": 0.3
- },
- "hasLowerBound": true,
- "lowerBound": {},
- "hasUpperBound": true,
- "upperBound": {
- "f": 1.0
- },
- "upperBoundInclusive": true
- }
- },
- {
- "name": "bottom_rate",
- "desc": "GOSS-specific parameter. The fraction of small gradients to sample.",
- "type": "AT_FLOAT",
- "atomic": {
- "isOptional": true,
- "defaultValue": {
- "f": 0.5
- },
- "hasLowerBound": true,
- "lowerBound": {},
- "hasUpperBound": true,
- "upperBound": {
- "f": 1.0
- },
- "upperBoundInclusive": true
- }
- },
- {
- "name": "early_stop_criterion_g_abs_sum",
- "desc": "If sum(abs(g)) is lower than or equal to this threshold, training will stop.",
- "type": "AT_FLOAT",
- "atomic": {
- "isOptional": true,
- "defaultValue": {},
- "hasLowerBound": true,
- "lowerBound": {},
- "lowerBoundInclusive": true
- }
- },
- {
- "name": "early_stop_criterion_g_abs_sum_change_ratio",
- "desc": "If absolute g sum change ratio is lower than or equal to this threshold, training will stop.",
- "type": "AT_FLOAT",
- "atomic": {
- "isOptional": true,
- "defaultValue": {},
- "hasLowerBound": true,
- "lowerBound": {},
- "lowerBoundInclusive": true,
- "hasUpperBound": true,
- "upperBound": {
- "f": 1.0
- },
- "upperBoundInclusive": true
- }
- },
- {
- "name": "tree_growing_method",
- "desc": "How to grow tree?",
- "type": "AT_STRING",
- "atomic": {
- "isOptional": true,
- "defaultValue": {
- "s": "level"
- }
- }
- }
- ],
- "inputs": [
- {
- "name": "train_dataset",
- "desc": "Input vertical table.",
- "types": [
- "sf.table.vertical_table"
- ]
- }
- ],
- "outputs": [
- {
- "name": "output_model",
- "desc": "Output model.",
- "types": [
- "sf.model.sgb"
- ]
- }
- ]
- },
- {
- "domain": "ml.train",
- "name": "ss_glm_train",
- "desc": "generalized linear model (GLM) is a flexible generalization of ordinary linear regression.\nThe GLM generalizes linear regression by allowing the linear model to be related to the response\nvariable via a link function and by allowing the magnitude of the variance of each measurement to\nbe a function of its predicted value.",
- "version": "0.0.1",
- "attrs": [
- {
- "name": "epochs",
- "desc": "The number of complete pass through the training data.",
- "type": "AT_INT",
- "atomic": {
- "isOptional": true,
- "defaultValue": {
- "i64": "10"
- },
- "hasLowerBound": true,
- "lowerBound": {
- "i64": "1"
- },
- "lowerBoundInclusive": true
- }
- },
- {
- "name": "learning_rate",
- "desc": "The step size at each iteration in one iteration.",
- "type": "AT_FLOAT",
- "atomic": {
- "isOptional": true,
- "defaultValue": {
- "f": 0.1
- },
- "hasLowerBound": true,
- "lowerBound": {}
- }
- },
- {
- "name": "batch_size",
- "desc": "The number of training examples utilized in one iteration.",
- "type": "AT_INT",
- "atomic": {
- "isOptional": true,
- "defaultValue": {
- "i64": "1024"
- },
- "hasLowerBound": true,
- "lowerBound": {}
- }
- },
- {
- "name": "link_type",
- "desc": "link function type",
- "type": "AT_STRING",
- "atomic": {
- "allowedValues": {
- "ss": [
- "Logit",
- "Log",
- "Reciprocal",
- "Indentity"
- ]
- }
- }
- },
- {
- "name": "label_dist_type",
- "desc": "label distribution type",
- "type": "AT_STRING",
- "atomic": {
- "allowedValues": {
- "ss": [
- "Bernoulli",
- "Poisson",
- "Gamma",
- "Tweedie"
- ]
- }
- }
- },
- {
- "name": "tweedie_power",
- "desc": "Tweedie distribution power parameter",
- "type": "AT_FLOAT",
- "atomic": {
- "isOptional": true,
- "defaultValue": {
- "f": 1.0
- },
- "hasLowerBound": true,
- "lowerBound": {},
- "lowerBoundInclusive": true,
- "hasUpperBound": true,
- "upperBound": {
- "f": 2.0
- },
- "upperBoundInclusive": true
- }
- },
- {
- "name": "dist_scale",
- "desc": "A guess value for distribution's scale",
- "type": "AT_FLOAT",
- "atomic": {
- "isOptional": true,
- "defaultValue": {
- "f": 1.0
- },
- "hasLowerBound": true,
- "lowerBound": {
- "f": 1.0
- },
- "lowerBoundInclusive": true
- }
- },
- {
- "name": "eps",
- "desc": "If the change rate of weights is less than this threshold, the model is considered to be converged, and the training stops early. 0 to disable.",
- "type": "AT_FLOAT",
- "atomic": {
- "isOptional": true,
- "defaultValue": {
- "f": 0.0001
- },
- "hasLowerBound": true,
- "lowerBound": {},
- "lowerBoundInclusive": true
- }
- },
- {
- "name": "iter_start_irls",
- "desc": "run a few rounds of IRLS training as the initialization of w, 0 disable",
- "type": "AT_INT",
- "atomic": {
- "isOptional": true,
- "defaultValue": {},
- "hasLowerBound": true,
- "lowerBound": {},
- "lowerBoundInclusive": true
- }
- },
- {
- "name": "decay_epoch",
- "desc": "decay learning interval",
- "type": "AT_INT",
- "atomic": {
- "isOptional": true,
- "defaultValue": {},
- "hasLowerBound": true,
- "lowerBound": {},
- "lowerBoundInclusive": true
- }
- },
- {
- "name": "decay_rate",
- "desc": "decay learning rate",
- "type": "AT_FLOAT",
- "atomic": {
- "isOptional": true,
- "defaultValue": {},
- "hasLowerBound": true,
- "lowerBound": {},
- "lowerBoundInclusive": true,
- "hasUpperBound": true,
- "upperBound": {
- "f": 1.0
- }
- }
- },
- {
- "name": "optimizer",
- "desc": "which optimizer to use: IRLS(Iteratively Reweighted Least Squares) or SGD(Stochastic Gradient Descent)",
- "type": "AT_STRING",
- "atomic": {
- "allowedValues": {
- "ss": [
- "SGD",
- "IRLS"
- ]
- }
- }
- },
- {
- "name": "offset_col",
- "desc": "Specify a column to use as the offset",
- "type": "AT_STRING",
- "atomic": {
- "isOptional": true,
- "defaultValue": {}
- }
- },
- {
- "name": "weight_col",
- "desc": "Specify a column to use for the observation weights",
- "type": "AT_STRING",
- "atomic": {
- "isOptional": true,
- "defaultValue": {}
- }
- }
- ],
- "inputs": [
- {
- "name": "train_dataset",
- "desc": "Input vertical table.",
- "types": [
- "sf.table.vertical_table"
- ]
- }
- ],
- "outputs": [
- {
- "name": "output_model",
- "desc": "Output model.",
- "types": [
- "sf.model.ss_glm"
- ]
- }
- ]
- },
- {
- "domain": "ml.train",
- "name": "ss_sgd_train",
- "desc": "Train both linear and logistic regression\nlinear models for vertical partitioning dataset with mini batch SGD training solver by using secret sharing.\n- SS-SGD is short for secret sharing SGD training.",
- "version": "0.0.1",
- "attrs": [
- {
- "name": "epochs",
- "desc": "The number of complete pass through the training data.",
- "type": "AT_INT",
- "atomic": {
- "isOptional": true,
- "defaultValue": {
- "i64": "10"
- },
- "hasLowerBound": true,
- "lowerBound": {
- "i64": "1"
- },
- "lowerBoundInclusive": true
- }
- },
- {
- "name": "learning_rate",
- "desc": "The step size at each iteration in one iteration.",
- "type": "AT_FLOAT",
- "atomic": {
- "isOptional": true,
- "defaultValue": {
- "f": 0.1
- },
- "hasLowerBound": true,
- "lowerBound": {}
- }
- },
- {
- "name": "batch_size",
- "desc": "The number of training examples utilized in one iteration.",
- "type": "AT_INT",
- "atomic": {
- "isOptional": true,
- "defaultValue": {
- "i64": "1024"
- },
- "hasLowerBound": true,
- "lowerBound": {}
- }
- },
- {
- "name": "sig_type",
- "desc": "Sigmoid approximation type.",
- "type": "AT_STRING",
- "atomic": {
- "isOptional": true,
- "defaultValue": {
- "s": "t1"
- },
- "allowedValues": {
- "ss": [
- "real",
- "t1",
- "t3",
- "t5",
- "df",
- "sr",
- "mix"
- ]
- }
- }
- },
- {
- "name": "reg_type",
- "desc": "Regression type",
- "type": "AT_STRING",
- "atomic": {
- "isOptional": true,
- "defaultValue": {
- "s": "logistic"
- },
- "allowedValues": {
- "ss": [
- "linear",
- "logistic"
- ]
- }
- }
- },
- {
- "name": "penalty",
- "desc": "The penalty(aka regularization term) to be used.",
- "type": "AT_STRING",
- "atomic": {
- "isOptional": true,
- "defaultValue": {
- "s": "None"
- },
- "allowedValues": {
- "ss": [
- "None",
- "l1",
- "l2"
- ]
- }
- }
- },
- {
- "name": "l2_norm",
- "desc": "L2 regularization term.",
- "type": "AT_FLOAT",
- "atomic": {
- "isOptional": true,
- "defaultValue": {
- "f": 0.5
- },
- "hasLowerBound": true,
- "lowerBound": {},
- "lowerBoundInclusive": true
- }
- },
- {
- "name": "eps",
- "desc": "If the change rate of weights is less than this threshold, the model is considered to be converged, and the training stops early. 0 to disable.",
- "type": "AT_FLOAT",
- "atomic": {
- "isOptional": true,
- "defaultValue": {
- "f": 0.001
- },
- "hasLowerBound": true,
- "lowerBound": {}
- }
- }
- ],
- "inputs": [
- {
- "name": "train_dataset",
- "desc": "Input vertical table.",
- "types": [
- "sf.table.vertical_table"
- ]
- }
- ],
- "outputs": [
- {
- "name": "output_model",
- "desc": "Output model.",
- "types": [
- "sf.model.ss_sgd"
- ]
- }
- ]
- },
- {
- "domain": "ml.train",
- "name": "ss_xgb_train",
- "desc": "This method provides both classification and regression tree boosting (also known as GBDT, GBM)\nfor vertical partitioning dataset setting by using secret sharing.\n- SS-XGB is short for secret sharing XGB.\n- More details: https://arxiv.org/pdf/2005.08479.pdf",
- "version": "0.0.1",
- "attrs": [
- {
- "name": "num_boost_round",
- "desc": "Number of boosting iterations.",
- "type": "AT_INT",
- "atomic": {
- "isOptional": true,
- "defaultValue": {
- "i64": "10"
- },
- "hasLowerBound": true,
- "lowerBound": {
- "i64": "1"
- },
- "lowerBoundInclusive": true
- }
- },
- {
- "name": "max_depth",
- "desc": "Maximum depth of a tree.",
- "type": "AT_INT",
- "atomic": {
- "isOptional": true,
- "defaultValue": {
- "i64": "5"
- },
- "hasLowerBound": true,
- "lowerBound": {
- "i64": "1"
- },
- "lowerBoundInclusive": true,
- "hasUpperBound": true,
- "upperBound": {
- "i64": "16"
- },
- "upperBoundInclusive": true
- }
- },
- {
- "name": "learning_rate",
- "desc": "Step size shrinkage used in updates to prevent overfitting.",
- "type": "AT_FLOAT",
- "atomic": {
- "isOptional": true,
- "defaultValue": {
- "f": 0.1
- },
- "hasLowerBound": true,
- "lowerBound": {},
- "hasUpperBound": true,
- "upperBound": {
- "f": 1.0
- },
- "upperBoundInclusive": true
- }
- },
- {
- "name": "objective",
- "desc": "Specify the learning objective.",
- "type": "AT_STRING",
- "atomic": {
- "isOptional": true,
- "defaultValue": {
- "s": "logistic"
- },
- "allowedValues": {
- "ss": [
- "linear",
- "logistic"
- ]
- }
- }
- },
- {
- "name": "reg_lambda",
- "desc": "L2 regularization term on weights.",
- "type": "AT_FLOAT",
- "atomic": {
- "isOptional": true,
- "defaultValue": {
- "f": 0.1
- },
- "hasLowerBound": true,
- "lowerBound": {},
- "lowerBoundInclusive": true,
- "hasUpperBound": true,
- "upperBound": {
- "f": 10000.0
- },
- "upperBoundInclusive": true
- }
- },
- {
- "name": "subsample",
- "desc": "Subsample ratio of the training instances.",
- "type": "AT_FLOAT",
- "atomic": {
- "isOptional": true,
- "defaultValue": {
- "f": 0.1
- },
- "hasLowerBound": true,
- "lowerBound": {},
- "hasUpperBound": true,
- "upperBound": {
- "f": 1.0
- },
- "upperBoundInclusive": true
- }
- },
- {
- "name": "colsample_by_tree",
- "desc": "Subsample ratio of columns when constructing each tree.",
- "type": "AT_FLOAT",
- "atomic": {
- "isOptional": true,
- "defaultValue": {
- "f": 0.1
- },
- "hasLowerBound": true,
- "lowerBound": {},
- "hasUpperBound": true,
- "upperBound": {
- "f": 1.0
- },
- "upperBoundInclusive": true
- }
- },
- {
- "name": "sketch_eps",
- "desc": "This roughly translates into O(1 / sketch_eps) number of bins.",
- "type": "AT_FLOAT",
- "atomic": {
- "isOptional": true,
- "defaultValue": {
- "f": 0.1
- },
- "hasLowerBound": true,
- "lowerBound": {},
- "hasUpperBound": true,
- "upperBound": {
- "f": 1.0
- },
- "upperBoundInclusive": true
- }
- },
- {
- "name": "base_score",
- "desc": "The initial prediction score of all instances, global bias.",
- "type": "AT_FLOAT",
- "atomic": {
- "isOptional": true,
- "defaultValue": {},
- "hasLowerBound": true,
- "lowerBound": {},
- "lowerBoundInclusive": true
- }
- },
- {
- "name": "seed",
- "desc": "Pseudorandom number generator seed.",
- "type": "AT_INT",
- "atomic": {
- "isOptional": true,
- "defaultValue": {
- "i64": "42"
- },
- "hasLowerBound": true,
- "lowerBound": {},
- "lowerBoundInclusive": true
- }
- }
- ],
- "inputs": [
- {
- "name": "train_dataset",
- "desc": "Input vertical table.",
- "types": [
- "sf.table.vertical_table"
- ]
- }
- ],
- "outputs": [
- {
- "name": "output_model",
- "desc": "Output model.",
- "types": [
- "sf.model.ss_xgb"
- ]
- }
- ]
- },
- {
- "domain": "preprocessing",
- "name": "feature_filter",
- "desc": "Drop features from the dataset.",
- "version": "0.0.1",
- "inputs": [
- {
- "name": "in_ds",
- "desc": "Input vertical table.",
- "types": [
- "sf.table.vertical_table"
- ],
- "attrs": [
- {
- "name": "drop_features",
- "desc": "Features to drop."
- }
- ]
- }
- ],
- "outputs": [
- {
- "name": "out_ds",
- "desc": "Output vertical table.",
- "types": [
- "sf.table.vertical_table"
- ]
- }
- ]
- },
- {
- "domain": "preprocessing",
- "name": "psi",
- "desc": "PSI between two parties.",
- "version": "0.0.1",
- "attrs": [
- {
- "name": "protocol",
- "desc": "PSI protocol.",
- "type": "AT_STRING",
- "atomic": {
- "isOptional": true,
- "defaultValue": {
- "s": "ECDH_PSI_2PC"
- },
- "allowedValues": {
- "ss": [
- "ECDH_PSI_2PC",
- "KKRT_PSI_2PC",
- "BC22_PSI_2PC"
- ]
- }
- }
- },
- {
- "name": "bucket_size",
- "desc": "Specify the hash bucket size used in PSI. Larger values consume more memory.",
- "type": "AT_INT",
- "atomic": {
- "isOptional": true,
- "defaultValue": {
- "i64": "1048576"
- },
- "hasLowerBound": true,
- "lowerBound": {}
- }
- },
- {
- "name": "ecdh_curve_type",
- "desc": "Curve type for ECDH PSI.",
- "type": "AT_STRING",
- "atomic": {
- "isOptional": true,
- "defaultValue": {
- "s": "CURVE_FOURQ"
- },
- "allowedValues": {
- "ss": [
- "CURVE_25519",
- "CURVE_FOURQ",
- "CURVE_SM2",
- "CURVE_SECP256K1"
- ]
- }
- }
- }
- ],
- "inputs": [
- {
- "name": "receiver_input",
- "desc": "Individual table for receiver",
- "types": [
- "sf.table.individual"
- ],
- "attrs": [
- {
- "name": "key",
- "desc": "Column(s) used to join. If not provided, ids of the dataset will be used."
- }
- ]
- },
- {
- "name": "sender_input",
- "desc": "Individual table for sender",
- "types": [
- "sf.table.individual"
- ],
- "attrs": [
- {
- "name": "key",
- "desc": "Column(s) used to join. If not provided, ids of the dataset will be used."
- }
- ]
- }
- ],
- "outputs": [
- {
- "name": "psi_output",
- "desc": "Output vertical table",
- "types": [
- "sf.table.vertical_table"
- ]
- }
- ]
- },
- {
- "domain": "preprocessing",
- "name": "train_test_split",
- "desc": "Split datasets into random train and test subsets.\n- Please check: https://scikit-learn.org/stable/modules/generated/sklearn.model_selection.train_test_split.html",
- "version": "0.0.1",
- "attrs": [
- {
- "name": "train_size",
- "desc": "Proportion of the dataset to include in the train subset.",
- "type": "AT_FLOAT",
- "atomic": {
- "isOptional": true,
- "defaultValue": {
- "f": 0.75
- },
- "hasLowerBound": true,
- "lowerBound": {},
- "lowerBoundInclusive": true,
- "hasUpperBound": true,
- "upperBound": {
- "f": 1.0
- },
- "upperBoundInclusive": true
- }
- },
- {
- "name": "test_size",
- "desc": "Proportion of the dataset to include in the test subset.",
- "type": "AT_FLOAT",
- "atomic": {
- "isOptional": true,
- "defaultValue": {
- "f": 0.25
- },
- "hasLowerBound": true,
- "lowerBound": {},
- "lowerBoundInclusive": true,
- "hasUpperBound": true,
- "upperBound": {
- "f": 1.0
- },
- "upperBoundInclusive": true
- }
- },
- {
- "name": "random_state",
- "desc": "Specify the random seed of the shuffling.",
- "type": "AT_INT",
- "atomic": {
- "isOptional": true,
- "defaultValue": {
- "i64": "1024"
- },
- "hasLowerBound": true,
- "lowerBound": {}
- }
- },
- {
- "name": "shuffle",
- "desc": "Whether to shuffle the data before splitting.",
- "type": "AT_BOOL",
- "atomic": {
- "isOptional": true,
- "defaultValue": {
- "b": true
- }
- }
- }
- ],
- "inputs": [
- {
- "name": "input_data",
- "desc": "Input vertical table.",
- "types": [
- "sf.table.vertical_table"
- ]
- }
- ],
- "outputs": [
- {
- "name": "train",
- "desc": "Output train dataset.",
- "types": [
- "sf.table.vertical_table"
- ]
- },
- {
- "name": "test",
- "desc": "Output test dataset.",
- "types": [
- "sf.table.vertical_table"
- ]
- }
- ]
- },
- {
- "domain": "stats",
- "name": "ss_pearsonr",
- "desc": "Calculate Pearson's product-moment correlation coefficient for vertical partitioning dataset\nby using secret sharing.\n- For large dataset(large than 10w samples & 200 features), recommend to use [Ring size: 128, Fxp: 40] options for SPU device.",
- "version": "0.0.1",
- "inputs": [
- {
- "name": "input_data",
- "desc": "Input vertical table.",
- "types": [
- "sf.table.vertical_table"
- ],
- "attrs": [
- {
- "name": "feature_selects",
- "desc": "Specify which features to calculate correlation coefficient with. If empty, all features will be used"
- }
- ]
- }
- ],
- "outputs": [
- {
- "name": "report",
- "desc": "Output Pearson's product-moment correlation coefficient report.",
- "types": [
- "sf.report"
- ]
- }
- ]
- },
- {
- "domain": "stats",
- "name": "ss_vif",
- "desc": "Calculate Variance Inflation Factor(VIF) for vertical partitioning dataset\nby using secret sharing.\n- For large dataset(large than 10w samples & 200 features), recommend to use [Ring size: 128, Fxp: 40] options for SPU device.",
- "version": "0.0.1",
- "inputs": [
- {
- "name": "input_data",
- "desc": "Input vertical table.",
- "types": [
- "sf.table.vertical_table"
- ],
- "attrs": [
- {
- "name": "feature_selects",
- "desc": "Specify which features to calculate VIF with. If empty, all features will be used."
- }
- ]
- }
- ],
- "outputs": [
- {
- "name": "report",
- "desc": "Output Variance Inflation Factor(VIF) report.",
- "types": [
- "sf.report"
- ]
- }
- ]
- },
- {
- "domain": "stats",
- "name": "table_statistics",
- "desc": "Get a table of statistics,\nincluding each column's\n1. datatype\n2. total_count\n3. count\n4. count_na\n5. min\n6. max\n7. var\n8. std\n9. sem\n10. skewness\n11. kurtosis\n12. q1\n13. q2\n14. q3\n15. moment_2\n16. moment_3\n17. moment_4\n18. central_moment_2\n19. central_moment_3\n20. central_moment_4\n21. sum\n22. sum_2\n23. sum_3\n24. sum_4\n- moment_2 means E[X^2].\n- central_moment_2 means E[(X - mean(X))^2].\n- sum_2 means sum(X^2).",
- "version": "0.0.1",
- "inputs": [
- {
- "name": "input_data",
- "desc": "Input table.",
- "types": [
- "sf.table.vertical_table",
- "sf.table.individual"
- ]
- }
- ],
- "outputs": [
- {
- "name": "report",
- "desc": "Output table statistics report.",
- "types": [
- "sf.report"
- ]
- }
- ]
- }
- ]
-}
\ No newline at end of file
diff --git a/config/components/secretpad.json b/config/components/secretpad.json
deleted file mode 100644
index c414fea..0000000
--- a/config/components/secretpad.json
+++ /dev/null
@@ -1,33 +0,0 @@
-{
- "name": "secretpad",
- "version": "0.0.1",
- "comps": [
- {
- "domain": "read_data",
- "name": "datatable",
- "desc": "Datatable",
- "version": "0.0.1",
- "attrs": [
- {
- "name": "datatable_selected",
- "desc": "Datatable selected.",
- "type": "AT_STRING",
- "atomic": {
- "isOptional": false
- }
- }
- ],
- "inputs": [
- ],
- "outputs": [
- {
- "name": "datatable_output",
- "desc": "output for datatable",
- "types": [
- "sf.table.individual"
- ]
- }
- ]
- }
- ]
-}
\ No newline at end of file
diff --git a/config/i18n/TrustedFlow.json b/config/i18n/TrustedFlow.json
deleted file mode 100644
index c2cba9f..0000000
--- a/config/i18n/TrustedFlow.json
+++ /dev/null
@@ -1,264 +0,0 @@
-{
- ".": {
- "TrustedFlow": "TrustedFlow",
- "First-party TrustedFlow components.": "官方TrustedFlow组件"
- },
- "feature/vert_woe_binning:0.0.1": {
- "feature": "特征工程",
- "vert_woe_binning": "WOE分箱",
- "Generate Weight of Evidence (WOE) binning rules for individual datasets.": "为数据集生成 Weight of Evidence (WOE) 分箱规则",
- "0.0.1": "0.0.1",
- "binning_method": "分箱方式",
- "How to bin features with numeric types: quantile\"(equal frequency)/\"bucket\"(equal width)": "如何使用数值类型对特征进行分箱:quantile(等频)/bucket(等宽)",
- "bin_num": "分箱个数",
- "Max bin counts for one features.": "一个特征的最大分箱数",
- "positive_label": "正值标签",
- "Which value represent positive value in label.": "哪个值表示标签中的正值",
- "input_data": "输入数据集",
- "Input table.": "输入表",
- "feature_selects": "选择特征",
- "which features should be binned.": "应对哪些特征进行分组",
- "woe_rule": "WOE 规则",
- "Output WOE rule.": "输出 WOE 规则"
- },
- "feature/vert_woe_substitution:0.0.1": {
- "feature": "特征工程",
- "vert_woe_substitution": "WOE转换",
- "Substitute datasets' value by WOE substitution rules.": "根据WOE分箱规则替换数据集的值",
- "0.0.1": "0.0.1",
- "input_data": "输入数据",
- "Dataset to be substituted.": "要替换的数据集",
- "woe_rule": "WOE 规则",
- "WOE substitution rule.": "输入WOE分箱规则",
- "output_data": "输出数据",
- "Output substituted dataset.": "输出表"
- },
- "ml.eval/biclassification_eval:0.0.1": {
- "ml.eval": "模型评估",
- "biclassification_eval": "二分类评估",
- "Statistics evaluation for a bi-classification model on a dataset.\n1. summary_report: SummaryReport\n2. eq_frequent_bin_report: List[EqBinReport]\n3. eq_range_bin_report: List[EqBinReport]\n4. head_report: List[PrReport]\nreports for fpr = 0.001, 0.005, 0.01, 0.05, 0.1, 0.2": "数据集上二分类模型的统计评估\n1. summary_report: 总结报告\n2. eq_frequent_bin_report: 等频分箱报告\n3. eq_range_bin_report: 等距分箱报告\n4. head_report: \nFPR = 0.001, 0.005, 0.01, 0.05, 0.1, 0.2 的精度报告",
- "0.0.1": "0.0.1",
- "bucket_num": "分桶数",
- "Number of buckets.": "分桶数",
- "min_item_cnt_per_bucket": "每个桶的最小项目数",
- "Min item cnt per bucket. If any bucket doesn't meet the requirement, error raises. For security reasons, we require this parameter to be at least 2.": "每个桶的最小项目数量;如果任何一个分桶不符合要求,则会引发错误出于安全原因,我们要求此参数至少为 2",
- "predictions": "预测值",
- "Input table with predictions": "输入预测表",
- "label": "标签",
- "The real value column name": "标签值列名",
- "score": "预测得分",
- "The score value column name": "预测得分列名",
- "reports": "报告",
- "Output report.": "输出报告"
- },
- "ml.eval/prediction_bias_eval:0.0.1": {
- "ml.eval": "模型评估",
- "prediction_bias_eval": "预测偏差评估",
- "Calculate prediction bias, ie. average of predictions - average of labels.": "计算预测偏差,即 预测平均值 - 标签平均值",
- "0.0.1": "0.0.1",
- "bucket_num": "分桶数",
- "Num of bucket.": "分桶数",
- "min_item_cnt_per_bucket": "每个桶的最小项目数",
- "Min item cnt per bucket. If any bucket doesn't meet the requirement, error raises. For security reasons, we require this parameter to be at least 2.": "每个桶的最小项目数量;如果任何一个分桶不符合要求,则会引发错误出于安全原因,我们要求此参数至少为 2",
- "bucket_method": "分桶方法",
- "Bucket method.": "分桶方法",
- "predictions": "预测值",
- "Input table with predictions.": "输入预测表",
- "label": "标签",
- "The real value column name": "标签值列名",
- "score": "预测得分",
- "The score value column name": "预测得分列名",
- "reports": "报告",
- "Output report.": "输出报告"
- },
- "ml.predict/lr_predict:0.0.1": {
- "ml.predict": "模型预测",
- "lr_predict": "LR预测",
- "Predict using the lr model.": "使用 LR 模型进行预测",
- "0.0.1": "0.0.1",
- "pred_name": "预测结果列名",
- "Column name for predictions.": "预测结果列名",
- "save_label": "保存标签列",
- "Whether or not to save real label column into output pred table. If true, input feature_dataset must contain label column.": "是否将真实的标签列保存到输出预测文件中;如果为 true,则输入feature_dataset必须包含标签列",
- "label_name": "标签列名",
- "Column name for label.": "需要保存的标签列名",
- "save_id": "保存id列",
- "Whether to save id column into output pred table. If true, input feature_dataset must contain id column.": "是否将 id 列保存到输出预测表中;如果为 true,则输入feature_dataset必须包含 id 列",
- "id_name": "id列名",
- "Column name for id.": "需要保存的id列名",
- "col_names": "额外列名",
- "Column names into output pred table.": "需要额外输出到预测表的列名",
- "model": "模型",
- "Input model.": "输入模型",
- "feature_dataset": "特征数据集",
- "Input feature dataset.": "输入数据表",
- "pred": "预测",
- "Output prediction.": "输出预测结果表"
- },
- "ml.predict/xgb_predict:0.0.1": {
- "ml.predict": "模型预测",
- "xgb_predict": "XGB预测",
- "Predict using the XGB model.": "使用 XGB 模型进行预测",
- "0.0.1": "0.0.1",
- "pred_name": "预测结果列名",
- "Column name for predictions.": "预测结果列名",
- "save_label": "保存标签列",
- "Whether or not to save real label column into output pred table. If true, input feature_dataset must contain label column.": "是否将真实的标签列保存到输出预测文件中;如果为 true,则输入feature_dataset必须包含标签列",
- "label_name": "标签列名",
- "Column name for label.": "需要保存的标签列名",
- "save_id": "保存id列",
- "Whether to save id column into output pred table. If true, input feature_dataset must contain id column.": "是否将 id 列保存到输出预测表中;如果为 true,则输入feature_dataset必须包含 id 列",
- "id_name": "id列名",
- "Column name for id.": "需要保存的id列名",
- "col_names": "额外列名",
- "Column names into output pred table.": "需要额外输出到预测表的列名",
- "model": "模型",
- "Input model.": "输入模型",
- "feature_dataset": "特征数据集",
- "Input feature dataset.": "输入数据表",
- "pred": "预测",
- "Output prediction.": "输出预测结果表"
- },
- "ml.train/lr_train:0.0.1": {
- "ml.train": "模型训练",
- "lr_train": "LR训练",
- "linear or logistic regression training.": "训练线性回归或逻辑回归",
- "0.0.1": "0.0.1",
- "max_iter": "最大迭代次数",
- "Maximum number of iterations taken for the solvers to converge.": "最大迭代次数",
- "reg_type": "回归类型",
- "Regression type": "回归类型",
- "l2_norm": "L2正则系数",
- "L2 regularization term.": "L2正则系数",
- "tol": "容忍值",
- "Tolerance for stopping criteria.": "损失函数变化的最小容忍值",
- "penalty": "正则化项类型",
- "The penalty(aka regularization term) to be used.": "要使用的penalty(又名正则化项)",
- "train_dataset": "训练数据集",
- "Input train dataset.": "输入训练集表",
- "output_model": "输出模型",
- "Output model.": "输出模型"
- },
- "ml.train/xgb_train:0.0.1": {
- "ml.train": "模型训练",
- "xgb_train": "XGB训练",
- "Provides both classification and regression tree boosting (also known as GBDT, GBM) for individual dataset.": "为独立数据集提供二分类和回归的树模型训练",
- "0.0.1": "0.0.1",
- "num_boost_round": "训练轮数",
- "Number of boosting iterations.": "Boosting迭代次数",
- "max_depth": "最大深度",
- "Maximum depth of a tree.": "树的最大深度",
- "max_leaves": "最大叶子节点数",
- "Maximum leaf of a tree. 0 indicates no limit.": "最大叶子节点数,0代表不限制",
- "seed": "种子",
- "Pseudorandom number generator seed.": "伪随机数生成器种子",
- "lambda": "叶子节点权重L2正则项",
- "L2 regularization term on weights.": "权重的 L2 正则化项",
- "learning_rate": "学习率",
- "Step size shrinkage used in updates to prevent overfitting.": "更新中使用的步长收缩以防止过度拟合",
- "gamma": "节点分裂最小增益",
- "Greater than 0 means pre-pruning enabled. If gain of a node is less than this value, it would be pruned.": "大于0表示启用了预剪枝。如果一个节点的增益小于该值,则该节点将被剪枝",
- "colsample_bytree": "每棵树子样本比率",
- "Subsample ratio of columns when constructing each tree.": "构造每棵树时列的子样本比率",
- "base_score": "初始预测分数",
- "The initial prediction score of all instances, global bias.": "所有实例的初始预测分数,全局偏差",
- "min_child_weight": "最小叶子节点权重和",
- "Minimum sum of instance weight (hessian) needed in a child. If the tree partition step results in a leaf node with the sum of instance weight less than min_child_weight, then the building process will give up further partitioning": "如果某个叶子节点的实例权重之和小于min_child_weight,则停止进一步的分裂,终止树的构建过程",
- "objective": "学习目标",
- "Specify the learning objective.": "指定学习目标(二分类或回归)",
- "alpha": "L1正则项",
- "L1 regularization term on weights. Increasing this value will make model more conservative": "L1正则化项对权重的影响。增大该值将使模型更加保守",
- "subsample": "子样本比率",
- "Subsample ratio of the training instances.": "训练实例的子样本比率",
- "max_bin": "最大分桶数",
- "Maximum number of discrete bins to bucket continuous features. Only used if tree_method is set to hist, approx or gpu_hist.": "最大分桶数。仅当tree_method被设为hist, approx或gpu_hist时有效",
- "tree_method": "树构建算法",
- "The tree construction algorithm used in XGBoost.": "XGBoost中使用的树构建算法",
- "booster": "基学习器",
- "Which booster to use": "选择使用的基学习器",
- "train_dataset": "训练数据集",
- "Input table.": "输入训练表",
- "output_model": "输出模型",
- "Output model.": "输出模型"
- },
- "preprocessing/feature_filter:0.0.1": {
- "preprocessing": "预处理",
- "feature_filter": "特征过滤",
- "Drop features from the dataset.": "从数据集中删除特征",
- "0.0.1": "0.0.1",
- "in_ds": "输入数据集",
- "Input table.": "输入表",
- "drop_features": "删除的特征",
- "Features to drop.": "删除的特征",
- "out_ds": "输出数据集",
- "Output table.": "输出表"
- },
- "preprocessing/psi:0.0.1": {
- "preprocessing": "预处理",
- "psi": "隐私求交",
- "PSI between two parties.": "双方之间的PSI",
- "0.0.1": "0.0.1",
- "input1": "第一张表",
- "Individual table for party 1": "第一个参与方的表",
- "key": "主键",
- "Column(s) used to join. If not provided, ids of the dataset will be used.": "用于求交的主键列;如果未提供,将使用数据集的 ID 列",
- "input2": "第二张表",
- "Individual table for party 2": "第二个参与方的表",
- "psi_output": "PSI输出",
- "Output table": "输出表"
- },
- "preprocessing/train_test_split:0.0.1": {
- "preprocessing": "预处理",
- "train_test_split": "随机分割",
- "Split datasets into random train and test subsets.\n- Please check: https://scikit-learn.org/stable/modules/generated/sklearn.model_selection.train_test_split.html": "将数据集拆分为随机的训练子集和测试子集\n- 请参考:https://scikit-learn.org/stable/modules/generated/sklearn.model_selection.train_test_split.html",
- "0.0.1": "0.0.1",
- "train_size": "训练子集大小",
- "Proportion of the dataset to include in the train subset.": "包含在训练子集中的输入数据集的比例",
- "fix_random": "是否用固定随机种子",
- "Whether to fix random.": "是否用固定随机种子",
- "random_state": "数据打乱的随机种子",
- "Specify the random seed of the shuffling.": "指定数据打乱的随机种子",
- "shuffle": "数据打乱",
- "Whether to shuffle the data before splitting.": "拆分前是否对数据进行数据打乱",
- "input_data": "输入数据集",
- "Input table.": "输入数据表",
- "train": "训练数据子集",
- "Output train dataset.": "输出训练数据子集",
- "test": "测试数据子集",
- "Output test dataset.": "输出测试数据子集"
- },
- "stats/pearsonr:0.0.1": {
- "stats": "统计",
- "pearsonr": "相关系数矩阵",
- "Calculate Pearson's product-moment correlation coefficient for individual dataset.": "计算独立数据集的皮尔逊乘积矩相关系数",
- "0.0.1": "0.0.1",
- "input_data": "输入数据集",
- "Input table.": "输入表",
- "feature_selects": "特征列",
- "Specify which features to calculate correlation coefficient with. If empty, all features will be used": "指定要计算相关系数的特征;如果为空,则将使用所有特征",
- "report": "报告",
- "Output Pearson's product-moment correlation coefficient report.": "输出相关系数矩阵表"
- },
- "stats/vif:0.0.1": {
- "stats": "统计",
- "vif": "VIF指标计算",
- "Calculate Variance Inflation Factor(VIF) for individual dataset": "计算独立数据集的方差膨胀因子VIF",
- "0.0.1": "0.0.1",
- "input_data": "输入数据集",
- "Input table.": "输入表",
- "feature_selects": "特征列",
- "Specify which features to calculate VIF with. If empty, all features will be used.": "指定要用于计算 VIF 的特征;如果为空,则将使用所有特征",
- "report": "报告",
- "Output Variance Inflation Factor(VIF) report.": "输出VIF指标计算结果表"
- },
- "stats/table_statistics:0.0.1": {
- "stats": "统计",
- "table_statistics": "全表统计",
- "Get a table of statistics,\nincluding each column's\n1. datatype\n2. total_count\n3. count\n4. count_na\n5. min\n6. max\n7. var\n8. std\n9. sem\n10. skewness\n11. kurtosis\n12. q1\n13. q2\n14. q3\n15. moment_2\n16. moment_3\n17. moment_4\n18. central_moment_2\n19. central_moment_3\n20. central_moment_4\n21. sum\n22. sum_2\n23. sum_3\n24. sum_4\n- moment_2 means E[X^2].\n- central_moment_2 means E[(X - mean(X))^2].\n- sum_2 means sum(X^2).": "获取统计信息表,\n包括每列的\n1. datatype(数据类型)\n2. total_count(总数)\n3. count(非nan总数)\n4. count_na(nan总数)\n5. min\n6.max\n7. var\n8. std\n9. sem(standard error of the mean)\n10. skewness(偏度)\n11. kurtosis(峰度)\n12. q1(分位数)\n13. q2\n14. q3\n15. moment_2\n16. moment_3\n17. moment_4\n18. central_moment_2\n19. central_moment_3\n20. central_moment_4\n21. sum\n22. sum_2\n23. sum_3\n24. sum_4\n \n- moment_2 表示 E[X^2]\n- central_moment_2 表示 E[(X - mean(X))^2]\n- sum_2 表示 sum(X^2)",
- "0.0.1": "0.0.1",
- "input_data": "输入数据",
- "Input table.": "输入表",
- "report": "报告",
- "Output table statistics report.": "输出全表统计结果表"
- }
-}
\ No newline at end of file
diff --git a/config/i18n/secretflow.json b/config/i18n/secretflow.json
deleted file mode 100644
index e812fb5..0000000
--- a/config/i18n/secretflow.json
+++ /dev/null
@@ -1,413 +0,0 @@
-{
- ".": {
- "secretflow": "secretflow",
- "First-party SecretFlow components.": "官方SecretFlow组件"
- },
- "feature/vert_woe_binning:0.0.1": {
- "feature": "特征工程",
- "vert_woe_binning": "WOE分箱",
- "Generate Weight of Evidence (WOE) binning rules for vertical partitioning datasets.": "为垂直分割数据集生成 Weight of Evidence (WOE) 分箱规则",
- "0.0.1": "0.0.1",
- "secure_device_type": "安全设备类型",
- "Use SPU(Secure multi-party computation or MPC) or HEU(Homomorphic encryption or HE) to secure bucket summation.": "使用 SPU(安全多方计算, MPC)或 HEU(同态加密, HE)来保护桶求和",
- "binning_method": "分箱方式",
- "How to bin features with numeric types: \"quantile\"(equal frequency)/\"chimerge\"(ChiMerge from AAAI92-019: https://www.aaai.org/Papers/AAAI/1992/AAAI92-019.pdf)": "如何使用数值类型对特征进行分箱:“quantile”(等频)/“chimerge”(来自 AAAI92-019 的 ChiMerge:https://www.aaai.org/Papers/AAAI/1992/AAAI92-019.pdf)",
- "bin_num": "分箱个数",
- "Max bin counts for one features.": "一个特征的最大分箱数",
- "positive_label": "正值标签",
- "Which value represent positive value in label.": "哪个值表示标签中的正值",
- "chimerge_init_bins": "chimerge初始分箱数",
- "Max bin counts for initialization binning in ChiMerge.": "在 ChiMerge 中初始化分箱的最大分箱数",
- "chimerge_target_bins": "chimerge目标分箱数",
- "Stop merging if remaining bin counts is less than or equal to this value.": "在 ChiMerge 中如果剩余箱计数小于或等于此值,则停止合并",
- "chimerge_target_pvalue": "chimerge目标 p-value 值",
- "Stop merging if biggest pvalue of remaining bins is greater than this value.": "在 ChiMerge 中如果剩余分箱的最大 p-value 大于此值,则停止合并",
- "input_data": "输入数据集",
- "Input vertical table.": "输入联合表",
- "feature_selects": "选择特征",
- "which features should be binned.": "应对哪些特征进行分组",
- "woe_rule": "WOE 规则",
- "Output WOE rule.": "输出 WOE 规则"
- },
- "feature/vert_woe_substitution:0.0.1": {
- "feature": "特征工程",
- "vert_woe_substitution": "WOE转换",
- "Substitute datasets' value by WOE substitution rules.": "根据WOE分箱规则替换数据集的值",
- "0.0.1": "0.0.1",
- "input_data": "输入数据",
- "Vertical partitioning dataset to be substituted.": "要替换的垂直分割数据集",
- "woe_rule": "WOE 规则",
- "Input WOE substitution rule.": "输入WOE分箱规则",
- "output_data": "输出数据",
- "Output vertical table.": "输出联合表"
- },
- "ml.eval/biclassification_eval:0.0.1": {
- "ml.eval": "模型评估",
- "biclassification_eval": "二分类评估",
- "Statistics evaluation for a bi-classification model on a dataset.\n1. summary_report: SummaryReport\n2. group_reports: List[GroupReport]\n3. eq_frequent_bin_report: List[EqBinReport]\n4. eq_range_bin_report: List[EqBinReport]\n5. head_report: List[PrReport]\nreports for fpr = 0.001, 0.005, 0.01, 0.05, 0.1, 0.2": "数据集上二分类模型的统计评估\n1. summary_report: 总结报告\n2. group_reports: 分组报告\n3. eq_frequent_bin_report: 等频分箱报告\n4. eq_range_bin_report: 等距分箱报告\n5. head_report: \nFPR = 0.001, 0.005, 0.01, 0.05, 0.1, 0.2 的精度报告",
- "0.0.1": "0.0.1",
- "bucket_size": "分桶数",
- "Number of buckets.": "分桶数",
- "min_item_cnt_per_bucket": "每个桶的最小项目数",
- "Min item cnt per bucket. If any bucket doesn't meet the requirement, error raises. For security reasons, we require this parameter to be at least 5.": "每个桶的最小项目数量;如果任何一个分桶不符合要求,则会引发错误出于安全原因,我们要求此参数至少为 5",
- "labels": "标签值",
- "Input table with labels": "输入标签表",
- "col": "列名",
- "The column name to use in the dataset. If not provided, the label of dataset will be used by default.": "要在数据集中使用的列名;如果未提供,则默认使用数据集的标签",
- "predictions": "预测值",
- "Input table with predictions": "输入预测表",
- "reports": "报告",
- "Output report.": "输出报告"
- },
- "ml.eval/prediction_bias_eval:0.0.1": {
- "ml.eval": "模型评估",
- "prediction_bias_eval": "预测偏差评估",
- "Calculate prediction bias, ie. average of predictions - average of labels.": "计算预测偏差,即 预测平均值 - 标签平均值",
- "0.0.1": "0.0.1",
- "bucket_num": "分桶数",
- "Num of bucket.": "分桶数",
- "min_item_cnt_per_bucket": "每个桶的最小项目数",
- "Min item cnt per bucket. If any bucket doesn't meet the requirement, error raises. For security reasons, we require this parameter to be at least 2.": "每个桶的最小项目数量;如果任何一个分桶不符合要求,则会引发错误出于安全原因,我们要求此参数至少为 2",
- "bucket_method": "分桶方法",
- "Bucket method.": "分桶方法",
- "labels": "标签值",
- "Input table with labels.": "输入标签表",
- "col": "列名",
- "The column name to use in the dataset. If not provided, the label of dataset will be used by default.": "要在数据集中使用的列名;如果未提供,则默认使用数据集的标签",
- "predictions": "预测值",
- "Input table with predictions.": "输入预测表",
- "result": "结果",
- "Output report.": "输出报告"
- },
- "ml.eval/ss_pvalue:0.0.1": {
- "ml.eval": "模型评估",
- "ss_pvalue": "P-VALUE评估",
- "Calculate P-Value for LR model training on vertical partitioning dataset by using secret sharing.\nFor large dataset(large than 10w samples & 200 features),\nrecommend to use [Ring size: 128, Fxp: 40] options for SPU device.": "使用秘密共享计算垂直分区数据集上 LR 模型训练的 P 值\n对于大型数据集(大于10w样本和200个特征),\n建议对 SPU 设备使用 [Ring size: 128, Fxp: 40] 的选项",
- "0.0.1": "0.0.1",
- "model": "模型",
- "Input model.": "输入模型",
- "input_data": "输入数据集",
- "Input vertical table.": "输入联合表",
- "report": "报告",
- "Output P-Value report.": "输出P-VALUE结果表"
- },
- "ml.predict/sgb_predict:0.0.1": {
- "ml.predict": "模型预测",
- "sgb_predict": "SecureBoost预测",
- "Predict using SGB model.": "使用 SGB 模型进行预测",
- "0.0.1": "0.0.1",
- "receiver": "结果接收方",
- "Party of receiver.": "结果接收方",
- "pred_name": "预测结果列名",
- "Name for prediction column": "预测结果列名",
- "save_ids": "保存id列",
- "Whether to save ids columns into output prediction table. If true, input feature_dataset must contain id columns, and receiver party must be id owner.": "是否将 id 列保存到输出预测表中;如果为 true,则输入feature_dataset必须包含 id 列,并且接收方必须是 id 所有者",
- "save_label": "保存标签列",
- "Whether or not to save real label columns into output pred file. If true, input feature_dataset must contain label columns and receiver party must be label owner.": "是否将真实的标签列保存到输出预测文件中;如果为 true,则输入feature_dataset必须包含标签列,并且接收方必须是标签所有者",
- "model": "模型",
- "feature_dataset": "特征数据集",
- "Input vertical table.": "输入联合表",
- "pred": "预测",
- "Output prediction.": "输出预测结果表"
- },
- "ml.predict/ss_glm_predict:0.0.1": {
- "ml.predict": "模型预测",
- "ss_glm_predict": "SSGLM预测",
- "Predict using the SSGLM model.": "使用 SSGLM 模型进行预测",
- "0.0.1": "0.0.1",
- "receiver": "结果接收方",
- "Party of receiver.": "结果接收方",
- "pred_name": "预测结果列名",
- "Column name for predictions.": "预测结果列名",
- "save_ids": "保存id列",
- "Whether to save ids columns into output prediction table. If true, input feature_dataset must contain id columns, and receiver party must be id owner.": "是否将 id 列保存到输出预测表中;如果为 true,则输入feature_dataset必须包含 id 列,并且接收方必须是 id 所有者",
- "save_label": "保存标签列",
- "Whether or not to save real label columns into output pred file. If true, input feature_dataset must contain label columns and receiver party must be label owner.": "是否将真实的标签列保存到输出 pred 文件中;如果为 true,则输入feature_dataset必须包含标签列,并且接收方必须是标签所有者",
- "offset_col": "样本偏移列",
- "Specify a column to use as the offset": "指定要用作偏移量的列",
- "model": "模型",
- "Input model.": "输入模型",
- "feature_dataset": "特征数据集",
- "Input vertical table.": "输入联合表",
- "pred": "预测",
- "Output prediction.": "输出预测结果表"
- },
- "ml.predict/ss_sgd_predict:0.0.1": {
- "ml.predict": "模型预测",
- "ss_sgd_predict": "逻辑回归预测",
- "Predict using the SS-SGD model.": "使用 SS-SGD 模型进行预测",
- "0.0.1": "0.0.1",
- "batch_size": "训练批数据量",
- "The number of training examples utilized in one iteration.": "一次迭代中使用的训练示例数",
- "receiver": "结果接收方",
- "Party of receiver.": "接收结果接收方",
- "pred_name": "预测结果列名",
- "Column name for predictions.": "预测结果列名",
- "save_ids": "保存id列",
- "Whether to save ids columns into output prediction table. If true, input feature_dataset must contain id columns, and receiver party must be id owner.": "是否将 id 列保存到输出预测表中;如果为 true,则输入feature_dataset必须包含 id 列,并且接收方必须是 id 所有者",
- "save_label": "保存标签列",
- "Whether or not to save real label columns into output pred file. If true, input feature_dataset must contain label columns and receiver party must be label owner.": "是否将真实的标签列保存到输出预测文件中;如果为 true,则输入feature_dataset必须包含标签列,并且接收方必须是标签所有者",
- "model": "模型",
- "Input model.": "输入模型",
- "feature_dataset": "特征数据集",
- "Input vertical table.": "输入联合表",
- "pred": "预测",
- "Output prediction.": "输出预测结果表"
- },
- "ml.predict/ss_xgb_predict:0.0.1": {
- "ml.predict": "模型预测",
- "ss_xgb_predict": "SS-XGB预测",
- "Predict using the SS-XGB model.": "使用 SS-XGB 模型进行预测",
- "0.0.1": "0.0.1",
- "receiver": "结果接收方",
- "Party of receiver.": "结果接收方",
- "pred_name": "预测结果列名",
- "Column name for predictions.": "预测结果列名",
- "save_ids": "保存id列",
- "Whether to save ids columns into output prediction table. If true, input feature_dataset must contain id columns, and receiver party must be id owner.": "是否将 id 列保存到输出预测表中;如果为 true,则输入feature_dataset必须包含 id 列,并且接收方必须是 id 所有者",
- "save_label": "保存标签列",
- "Whether or not to save real label columns into output pred file. If true, input feature_dataset must contain label columns and receiver party must be label owner.": "是否将真实的标签列保存到输出预测文件中;如果为 true,则输入feature_dataset必须包含标签列,并且接收方必须是标签所有者",
- "model": "模型",
- "Input model.": "输入模型",
- "feature_dataset": "特征数据集",
- "Input vertical table.": "输入联合表",
- "pred": "预测",
- "Output prediction.": "输出预测结果表"
- },
- "ml.train/sgb_train:0.0.1": {
- "ml.train": "模型训练",
- "sgb_train": "SecureBoost训练",
- "Provides both classification and regression tree boosting (also known as GBDT, GBM)\nfor vertical split dataset setting by using secure boost.\n- SGB is short for SecureBoost. Compared to its safer counterpart SS-XGB, SecureBoost focused on protecting label holder.\n- Check https://arxiv.org/abs/1901.08755.": "使用Secure Boosting为垂直拆分数据集设置提供分类和回归树Boosting(也称为 GBDT、GBM)SGB是SecureBoost的缩写与更安全的SS-XGB相比, SecureBoost专注于保护标签持有人\n - 详细信息请参阅: https: //arxiv.org/abs/1901.08755",
- "0.0.1": "0.0.1",
- "num_boost_round": "训练轮数",
- "Number of boosting iterations.": "Boosting迭代次数",
- "max_depth": "最大深度",
- "Maximum depth of a tree.": "树的最大深度",
- "learning_rate": "学习率",
- "Step size shrinkage used in update to prevent overfitting.": "更新中使用的步长收缩以防止过度拟合",
- "objective": "目标",
- "Specify the learning objective.": "指定学习目标",
- "reg_lambda": "叶子节点权重L2正则项",
- "L2 regularization term on weights.": "权重的 L2 正则化项",
- "gamma": "最小分裂阈值",
- "Greater than 0 means pre-pruning enabled. If gain of a node is less than this value, it would be pruned.": "大于 0 表示已启用预修剪;如果节点的增益小于此值,则将其修剪",
- "colsample_by_tree": "每棵树子样本比率",
- "Subsample ratio of columns when constructing each tree.": "构造每棵树时列的子样本比率",
- "sketch_eps": "分裂系数",
- "This roughly translates into O(1 / sketch_eps) number of bins.": "大致相当于 O(1 / 分裂系数) 个箱",
- "base_score": "初始预测分数",
- "The initial prediction score of all instances, global bias.": "所有实例的初始预测分数,全局偏差",
- "seed": "种子",
- "Pseudorandom number generator seed.": "伪随机数生成器种子",
- "fixed_point_parameter": "HEU定点参数",
- "Any floating point number encoded by heu, will multiply a scale and take the round, scale = 2 ** fixed_point_parameter. larger value may mean more numerical accuracy, but too large will lead to overflow problem.": "由heu编码的任何浮点数将乘以一个刻度并四舍五入, 刻度 = 2 ** HEU定点参数; 较大的值可能意味着更高的数值精度, 但太大会导致溢出问题",
- "first_tree_with_label_holder_feature": "第一棵树是否使用标签持有人自己的特征",
- "Whether to train the first tree with label holder's own features.": "是否使用标签持有人自己的特征训练第一棵树",
- "batch_encoding_enabled": "批量编码是否启用",
- "If use batch encoding optimization.": "是否使用批量编码优化",
- "enable_quantization": "启用量化",
- "Whether enable quantization of g and h.": "是否启用g和h的量化",
- "quantization_scale": "量化刻度",
- "Scale the sum of g to the specified value.": "将g的总和缩放到指定的值",
- "max_leaf": "最大叶子",
- "Maximum leaf of a tree. Only effective if train leaf wise.": "树的最大叶子;仅在叶子-wise训练时有效",
- "rowsample_by_tree": "行采样比率",
- "Row sub sample ratio of the training instances.": "训练实例的行子采样比率",
- "enable_goss": "启用GOSS",
- "Whether to enable GOSS.": "是否启用GOSS",
- "top_rate": "顶部比例",
- "GOSS-specific parameter. The fraction of large gradients to sample.": "GOSS特定参数;采样的大梯度的比例",
- "bottom_rate": "底部比例",
- "GOSS-specific parameter. The fraction of small gradients to sample.": "GOSS特定参数;采样的小梯度的比例",
- "early_stop_criterion_g_abs_sum": "早停止条件g绝对值总和",
- "If sum(abs(g)) is lower than or equal to this threshold, training will stop.": "如果sum(abs(g))小于或等于此阈值,则训练将停止",
- "early_stop_criterion_g_abs_sum_change_ratio": "早停止条件g绝对值总和变化比率",
- "If absolute g sum change ratio is lower than or equal to this threshold, training will stop.": "如果绝对g总和变化比率小于或等于此阈值, 则训练将停止",
- "tree_growing_method": "树生长方法",
- "How to grow tree?": "如何生长树",
- "train_dataset": "训练数据集",
- "Input vertical table.": "输入联合表",
- "output_model": "输出模型",
- "Output model.": "输出模型"
- },
- "ml.train/ss_glm_train:0.0.1": {
- "ml.train": "模型训练",
- "ss_glm_train": "SSGLM训练",
- "generalized linear model (GLM) is a flexible generalization of ordinary linear regression.\nThe GLM generalizes linear regression by allowing the linear model to be related to the response\nvariable via a link function and by allowing the magnitude of the variance of each measurement to\nbe a function of its predicted value.": "广义线性模型(GLM)是普通线性回归的一种灵活的推广;该模型允许因变量的偏差分布有除了正态分布之外的其它分布;此模型假设实验者所量测的随机变量的分布函数与实验中系统性效应(即非随机的效应)可经由一链接函数(link function)建立可解释其相关性的函数",
- "0.0.1": "0.0.1",
- "epochs": "训练轮数",
- "The number of complete pass through the training data.": "通过完整训练数据的次数",
- "learning_rate": "学习率",
- "The step size at each iteration in one iteration.": "一次迭代中每次迭代的步长",
- "batch_size": "训练批数据量",
- "The number of training examples utilized in one iteration.": "一次迭代中使用的训练样本数",
- "link_type": "链接函数类型",
- "link function type": "链接函数类型",
- "label_dist_type": "样本分布类型",
- "label distribution type": "样本分布类型",
- "tweedie_power": "tweedie_power",
- "Tweedie distribution power parameter": "Tweedie分布的power参数",
- "dist_scale": "样本分布尺度的猜测值",
- "A guess value for distribution's scale": "样本分布尺度的猜测值",
- "eps": "eps",
- "If the change rate of weights is less than this threshold, the model is considered to be converged, and the training stops early. 0 to disable.": "如果权重的变化率小于此阈值,则认为模型已收敛,训练提前停止;0 表示禁用",
- "iter_start_irls": "IRLS初始化轮数",
- "run a few rounds of IRLS training as the initialization of w, 0 disable": "运行几轮IRLS训练作为SGD训练的初始化w,0禁用",
- "decay_epoch": "decay_epoch",
- "decay learning interval": "衰减学习区间",
- "decay_rate": "decay_rate",
- "decay learning rate": "衰减学习率",
- "optimizer": "优化器",
- "which optimizer to use: IRLS(Iteratively Reweighted Least Squares) or SGD(Stochastic Gradient Descent)": "使用哪个优化器:IRLS(迭代加权最小二乘法)或SGD(随机梯度下降法)",
- "offset_col": "偏移列",
- "Specify a column to use as the offset": "指定要用作偏移量的列",
- "weight_col": "权重列",
- "Specify a column to use for the observation weights": "指定用于观测权重的列",
- "train_dataset": "训练数据集",
- "Input vertical table.": "输入联合表",
- "output_model": "输出模型",
- "Output model.": "输出模型"
- },
- "ml.train/ss_sgd_train:0.0.1": {
- "ml.train": "模型训练",
- "ss_sgd_train": "逻辑回归训练",
- "Train both linear and logistic regression\nlinear models for vertical partitioning dataset with mini batch SGD training solver by using secret sharing.\n- SS-SGD is short for secret sharing SGD training.": "训练线性回归和逻辑回归\n使用秘密共享的具有 mini batch SGD 垂直分区数据集的线性模型\n- SS-SGD是秘密共享SGD训练的缩写",
- "0.0.1": "0.0.1",
- "epochs": "迭代次数",
- "The number of complete pass through the training data.": "通过完整训练数据的次数",
- "learning_rate": "学习率",
- "The step size at each iteration in one iteration.": "一次迭代中每次迭代的步长",
- "batch_size": "训练批数据量",
- "The number of training examples utilized in one iteration.": "一次迭代中使用的训练示例数",
- "sig_type": "sigmoid 函数拟合方法",
- "Sigmoid approximation type.": "sigmoid 函数拟合方法",
- "reg_type": "回归类型",
- "Regression type": "回归类型",
- "penalty": "正则化项类型",
- "The penalty(aka regularization term) to be used.": "要使用的penalty(又名正则化项)",
- "l2_norm": "L2正则系数",
- "L2 regularization term.": "L2正则系数",
- "eps": "eps",
- "If the change rate of weights is less than this threshold, the model is considered to be converged, and the training stops early. 0 to disable.": "如果权重的变化率小于此阈值,则认为模型已收敛,训练提前停止;0 表示禁用",
- "train_dataset": "训练数据集",
- "Input vertical table.": "输入联合表",
- "output_model": "输出模型",
- "Output model.": "输出模型"
- },
- "ml.train/ss_xgb_train:0.0.1": {
- "ml.train": "模型训练",
- "ss_xgb_train": "SS-XGB训练",
- "This method provides both classification and regression tree boosting (also known as GBDT, GBM)\nfor vertical partitioning dataset setting by using secret sharing.\n- SS-XGB is short for secret sharing XGB.\n- More details: https://arxiv.org/pdf/2005.08479.pdf": "该方法通过使用秘密共享为垂直分割数据集设置提供分类和回归树提升(也称为 GBDT、GBM)\n- SS-XGB是秘密共享XGB的缩写\n- 更多详情: https://arxiv.org/pdf/2005.08479.pdf",
- "0.0.1": "0.0.1",
- "num_boost_round": "训练轮数",
- "Number of boosting iterations.": "Boosting迭代次数",
- "max_depth": "最大深度",
- "Maximum depth of a tree.": "树的最大深度",
- "learning_rate": "学习率",
- "Step size shrinkage used in updates to prevent overfitting.": "更新中使用的步长收缩以防止过度拟合",
- "objective": "目的",
- "Specify the learning objective.": "指定学习目标",
- "reg_lambda": "叶子节点权重L2正则项",
- "L2 regularization term on weights.": "权重的 L2 正则化项",
- "subsample": "子样本比率",
- "Subsample ratio of the training instances.": "训练实例的子样本比率",
- "colsample_by_tree": "每棵树子样本比率",
- "Subsample ratio of columns when constructing each tree.": "构造每棵树时列的子样本比率",
- "sketch_eps": "分裂系数",
- "This roughly translates into O(1 / sketch_eps) number of bins.": "箱数大致为 O(1 / sketch_eps) 个",
- "base_score": "初始预测分数",
- "The initial prediction score of all instances, global bias.": "所有实例的初始预测分数,全局偏差",
- "seed": "种子",
- "Pseudorandom number generator seed.": "伪随机数生成器种子",
- "train_dataset": "训练数据集",
- "Input vertical table.": "输入联合表",
- "output_model": "输出模型",
- "Output model.": "输出模型"
- },
- "preprocessing/feature_filter:0.0.1": {
- "preprocessing": "预处理",
- "feature_filter": "特征过滤",
- "Drop features from the dataset.": "从数据集中删除特征",
- "0.0.1": "0.0.1",
- "in_ds": "输入数据集",
- "Input vertical table.": "输入联合表",
- "drop_features": "删除的特征",
- "Features to drop.": "删除的特征",
- "out_ds": "输出数据集",
- "Output vertical table.": "输出联合表"
- },
- "preprocessing/psi:0.0.1": {
- "preprocessing": "预处理",
- "psi": "隐私求交",
- "PSI between two parties.": "双方之间的PSI",
- "0.0.1": "0.0.1",
- "protocol": "协议",
- "PSI protocol.": "PSI 协议",
- "bucket_size": "分桶数",
- "Specify the hash bucket size used in PSI. Larger values consume more memory.": "指定 PSI 中使用的哈希桶大小;值越大,占用的内存越多",
- "ecdh_curve_type": "ECDH 曲线类型",
- "Curve type for ECDH PSI.": "ECDH PSI 的曲线类型",
- "receiver_input": "接收方的输入",
- "Individual table for receiver": "接收方的样本表",
- "key": "主键",
- "Column(s) used to join. If not provided, ids of the dataset will be used.": "用于求交的主键列;如果未提供,将使用数据集的 ID 列",
- "sender_input": "发送方的输入",
- "Individual table for sender": "发送方的样本表",
- "psi_output": "PSI输出",
- "Output vertical table": "输出联合表"
- },
- "preprocessing/train_test_split:0.0.1": {
- "preprocessing": "预处理",
- "train_test_split": "随机分割",
- "Split datasets into random train and test subsets.\n- Please check: https://scikit-learn.org/stable/modules/generated/sklearn.model_selection.train_test_split.html": "将数据集拆分为随机的训练子集和测试子集\n- 请检查:https://scikit-learn.org/stable/modules/generated/sklearn.model_selection.train_test_split.html",
- "0.0.1": "0.0.1",
- "train_size": "训练子集大小",
- "Proportion of the dataset to include in the train subset.": "包含在训练子集中的输入数据集的比例",
- "test_size": "测试子集大小",
- "Proportion of the dataset to include in the test subset.": "包含在测试子集中的输入数据集的比例",
- "random_state": "数据打乱的随机种子",
- "Specify the random seed of the shuffling.": "指定数据打乱的随机种子",
- "shuffle": "数据打乱",
- "Whether to shuffle the data before splitting.": "拆分前是否对数据进行数据打乱",
- "input_data": "输入数据集",
- "Input vertical table.": "输入联合表",
- "train": "训练数据子集",
- "Output train dataset.": "输出训练数据子集",
- "test": "测试数据子集",
- "Output test dataset.": "输出测试数据子集"
- },
- "stats/ss_pearsonr:0.0.1": {
- "stats": "统计",
- "ss_pearsonr": "相关系数矩阵",
- "Calculate Pearson's product-moment correlation coefficient for vertical partitioning dataset\nby using secret sharing.\n- For large dataset(large than 10w samples & 200 features), recommend to use [Ring size: 128, Fxp: 40] options for SPU device.": "通过使用秘密共享计算垂直分区数据集的皮尔逊乘积矩相关系数\n- 对于大型数据集(大于10w样本和200个特征),建议使用SPU设备的[Ring size:128,Fxp:40]选项",
- "0.0.1": "0.0.1",
- "input_data": "输入数据集",
- "Input vertical table.": "输入联合表",
- "feature_selects": "特征列",
- "Specify which features to calculate correlation coefficient with. If empty, all features will be used": "指定要计算相关系数的特征;如果为空,则将使用所有特征",
- "report": "报告",
- "Output Pearson's product-moment correlation coefficient report.": "输出相关系数矩阵表"
- },
- "stats/ss_vif:0.0.1": {
- "stats": "统计",
- "ss_vif": "VIF指标计算",
- "Calculate Variance Inflation Factor(VIF) for vertical partitioning dataset\nby using secret sharing.\n- For large dataset(large than 10w samples & 200 features), recommend to use [Ring size: 128, Fxp: 40] options for SPU device.": "通过使用秘密共享计算垂直分区数据集的方差膨胀因子 (VIF)\n- 对于大型数据集(大于10w样本和200个特征),建议使用SPU设备的[Ring size:128,Fxp:40]选项",
- "0.0.1": "0.0.1",
- "input_data": "输入数据集",
- "Input vertical table.": "输入联合表",
- "feature_selects": "特征列",
- "Specify which features to calculate VIF with. If empty, all features will be used.": "指定要用于计算 VIF 的特征;如果为空,则将使用所有特征",
- "report": "报告",
- "Output Variance Inflation Factor(VIF) report.": "输出VIF指标计算结果表"
- },
- "stats/table_statistics:0.0.1": {
- "stats": "统计",
- "table_statistics": "全表统计",
- "Get a table of statistics,\nincluding each column's\n1. datatype\n2. total_count\n3. count\n4. count_na\n5. min\n6. max\n7. var\n8. std\n9. sem\n10. skewness\n11. kurtosis\n12. q1\n13. q2\n14. q3\n15. moment_2\n16. moment_3\n17. moment_4\n18. central_moment_2\n19. central_moment_3\n20. central_moment_4\n21. sum\n22. sum_2\n23. sum_3\n24. sum_4\n- moment_2 means E[X^2].\n- central_moment_2 means E[(X - mean(X))^2].\n- sum_2 means sum(X^2).": "获取统计信息表,\n包括每列的\n1. datatype(数据类型)\n2. total_count(总数)\n3. count(非nan总数)\n4. count_na(nan总数)\n5. min\n6.max\n7. var\n8. std\n9. sem(standard error of the mean)\n10. skewness(偏度)\n11. kurtosis(峰度)\n12. q1(分位数)\n13. q2\n14. q3\n15. moment_2\n16. moment_3\n17. moment_4\n18. central_moment_2\n19. central_moment_3\n20. central_moment_4\n21. sum\n22. sum_2\n23. sum_3\n24. sum_4\n \n- moment_2 表示 E[X^2]\n- central_moment_2 表示 E[(X - mean(X))^2]\n- sum_2 表示 sum(X^2)",
- "0.0.1": "0.0.1",
- "input_data": "输入数据",
- "Input table.": "输入表",
- "report": "报告",
- "Output table statistics report.": "输出全表统计结果表"
- }
-}
\ No newline at end of file
diff --git a/config/i18n/secretpad.json b/config/i18n/secretpad.json
deleted file mode 100644
index 221e45c..0000000
--- a/config/i18n/secretpad.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "read_data/datatable:0.0.1": {
- "read_data": "读样本表",
- "Datatable": "样本表",
- "datatable": "样本表",
- "datatable_selected": "样本表选择",
- "Datatable selected.": "样本表选择",
- "datatable_output": "样本表输出",
- "0.0.1": "0.0.1",
- "output for datatable": "样本表输出"
- }
-}
\ No newline at end of file
diff --git a/config/schema/init.sql b/config/schema/init.sql
index b6ae469..08a416b 100644
--- a/config/schema/init.sql
+++ b/config/schema/init.sql
@@ -51,9 +51,10 @@ create table if not exists 'user_accounts'
failed_attempts integer default null, -- failed attempts
locked_invalid_time datetime default null, -- invalid time
passwd_reset_failed_attempts integer default null, -- passwd reset failed attempts
- gmt_passwd_reset_release datetime default null, -- passwd reset invalid time
+ gmt_passwd_reset_release datetime default null, -- passwd reset invalid time
owner_type varchar(16) default 'CENTER' not null, -- owner type
- owner_id varchar(64) default 'kuscia-system' not null -- owner id
+ owner_id varchar(64) default 'kuscia-system' not null, -- owner id
+ `initial` tinyint(1) default '1' not null -- initial
);
create table if not exists 'user_tokens'
@@ -77,14 +78,15 @@ create table if not exists `node`
node_id varchar(64) not null,
name varchar(256) not null,
auth text, -- ca
- description text default '', -- description
+ description text default '', -- description
control_node_id varchar(64) not null, -- node control id
net_address varchar(100), -- node net address
- is_deleted tinyint(1) default '0' not null, -- delete flag
- gmt_create datetime default CURRENT_TIMESTAMP not null, -- create time
- gmt_modified datetime default CURRENT_TIMESTAMP not null, -- modified time
- cert_text TEXT default '' not null, -- cert text
- node_remark varchar(256) -- node remark
+ is_deleted tinyint(1) default '0' not null, -- delete flag
+ gmt_create datetime default CURRENT_TIMESTAMP not null,-- create time
+ gmt_modified datetime default CURRENT_TIMESTAMP not null,-- modified time
+ cert_text TEXT default '' not null, -- cert text
+ node_remark varchar(256), -- node remark
+ trust tinyint(1) default '1' not null -- trust
);
create unique index `upk_node_id` on node (`node_id`);
create index `key_node_name` on node (`name`);
@@ -98,7 +100,7 @@ create table if not exists `node_route`
dst_net_address varchar(100), -- cooperate node net address
is_deleted tinyint(1) default '0' not null, -- delete flag
gmt_create datetime default CURRENT_TIMESTAMP not null, -- create time
- gmt_modified datetime default CURRENT_TIMESTAMP not null -- modified time
+ gmt_modified datetime default CURRENT_TIMESTAMP not null -- modified time
);
create unique index `upk_route_src_dst` on node_route (`src_node_id`, `dst_node_id`);
create index `key_router_src` on node_route (`src_node_id`);
@@ -165,6 +167,17 @@ create table if not exists 'fabric_log'
gmt_modified datetime default CURRENT_TIMESTAMP not null -- modified time
);
+create table if not exists 'rsa_encryption_key'
+(
+ id integer primary key autoincrement,
+ public_key varchar(1000) not null, -- public key
+ private_key varchar(128) not null, -- private key
+ key_invalid_time datetime default null, -- invalid time
+ is_deleted tinyint(1) default '0' not null, -- delete flag
+ gmt_create datetime default CURRENT_TIMESTAMP not null, -- create time
+ gmt_modified datetime default CURRENT_TIMESTAMP not null -- modified time
+);
+
--------------------------------------------------------------------------------------------------------------------------------
-- resource
diff --git a/config/template/application.yaml.tmpl b/config/template/application.yaml.tmpl
index c76a15b..6de3303 100644
--- a/config/template/application.yaml.tmpl
+++ b/config/template/application.yaml.tmpl
@@ -2,7 +2,7 @@ server:
tomcat:
accesslog:
enabled: true
- directory: /var/log/secretpad
+ directory: /var/log/easypsi
http-port: 8080
http-port-inner: 9001
port: 443
@@ -10,7 +10,7 @@ server:
enabled: true
key-store: "file:./config/server.jks"
key-store-password: {{.PASSWORD}}
- key-alias: secretpad-server
+ key-alias: easypsi-server
key-password: {{.PASSWORD}}
key-store-type: JKS
@@ -20,7 +20,7 @@ spring:
pool:
size: 10
application:
- name: secretpad
+ name: easypsi
jpa:
show-sql: false
properties:
@@ -29,7 +29,7 @@ spring:
datasource:
hibernate.dialect: org.hibernate.dialect.SQLiteDialect
driver-class-name: org.sqlite.JDBC
- url: jdbc:sqlite:./db/secretpad.sqlite
+ url: jdbc:sqlite:./db/easypsi.sqlite
hikari:
idle-timeout: 60000
maximum-pool-size: 1
@@ -53,6 +53,7 @@ logging:
kusciaapi:
address: {{.KUSCIA_API_ADDRESS}}:8083
+ protocol: ${KUSCIA_PROTOCOL:mtls} # notls tls mtls
tls:
cert-file: config/certs/client.crt
key-file: config/certs/client.pem
@@ -62,10 +63,10 @@ kusciaapi:
job:
max-parallelism: 1
-secretpad:
+easypsi:
platform-type: CENTER
node-id: kuscia-system
- center-platform-service: secretpad.master.svc
+ center-platform-service: easypsi.master.svc
gateway: http://localhost:8090
auth:
enabled: true
@@ -78,14 +79,6 @@ secretpad:
data:
dir-path: /app/data/
-sfclusterDesc:
- deviceConfig:
- spu: "{\"runtime_config\":{\"protocol\":\"REF2K\",\"field\":\"FM64\"},\"link_desc\":{\"connect_retry_times\":60,\"connect_retry_interval_ms\":1000,\"brpc_channel_protocol\":\"http\",\"brpc_channel_connection_type\":\"pooled\",\"recv_timeout_ms\":1200000,\"http_timeout_ms\":1200000}}"
- heu: "{\"mode\": \"PHEU\", \"schema\": \"paillier\", \"key_size\": 2048}"
- rayFedConfig:
- crossSiloCommBackend: "brpc_link"
-
-
springdoc:
api-docs:
enabled: false
diff --git a/docs/conf.py b/docs/conf.py
index 05b8783..ef47530 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -33,9 +33,9 @@
# -- Project information -----------------------------------------------------
-project = 'SecretPad'
+project = 'EasyPsi'
copyright = '2023 Ant Group Co., Ltd.'
-author = 'SecretPad authors'
+author = 'EasyPsi authors'
# -- General configuration ---------------------------------------------------
@@ -107,7 +107,7 @@
},
],
"logo": {
- "text": "SecretPad",
+ "text": "EasyPsi",
},
}
diff --git a/docs/development/build_secretpad_cn.md b/docs/development/build_easypsi_cn.md
similarity index 54%
rename from docs/development/build_secretpad_cn.md
rename to docs/development/build_easypsi_cn.md
index 0cbef48..9a86e79 100644
--- a/docs/development/build_secretpad_cn.md
+++ b/docs/development/build_easypsi_cn.md
@@ -8,9 +8,9 @@
* Maven: 3.5+
* Docker
-## 构建 SecretPad
+## 构建 EasyPsi
-SecrtPad 提供了 Makefile 来构建项目,你可以通过`make help`命令查看命令帮助,其中 Development 部分提供了构建能力:
+EasyPsi 提供了 Makefile 来构建项目,你可以通过`make help`命令查看命令帮助,其中 Development 部分提供了构建能力:
```shell
Usage:
@@ -29,46 +29,46 @@ Development
### 测试
-在 SecretPad 项目根目录下:
+在 EasyPsi 项目根目录下:
执行`make test`命令,该命令将会执行项目中所有的测试
### 构建可执行JAR文件
-在 SecretPad 项目根目录下:
+在 EasyPsi 项目根目录下:
-执行`make build`命令,该命令将会构建出 SecretPad 的可执行JAR,构建产物会生成在 ./target/ 目录下。
+执行`make build`命令,该命令将会构建出 EasyPsi 的可执行JAR,构建产物会生成在 ./target/ 目录下。
-### 构建 SecretPad Image
+### 构建 EasyPsi Image
-在 SecretPad 项目根目录下:
+在 EasyPsi 项目根目录下:
-执行`make image`命令,该命令将会使用 Docker 命令构建出 SecretPad 镜像。目前 SecretPad 暂时仅支持构建 linux/amd64 的 Anolis 镜像。
+执行`make image`命令,该命令将会使用 Docker 命令构建出 EasyPsi 镜像。目前 EasyPsi 暂时仅支持构建 linux/amd64 的 Anolis 镜像。
### 编译文档
-在 SecretPad 项目根目录下:
+在 EasyPsi 项目根目录下:
-执行`make docs`命令,该命令会生成 SecretPad 文档,生成的文档会放在 `docs/_build/html` 目录,用浏览器打开 `docs/_build/html/index.html` 就可以查看文档。
+执行`make docs`命令,该命令会生成 EasyPsi 文档,生成的文档会放在 `docs/_build/html` 目录,用浏览器打开 `docs/_build/html/index.html` 就可以查看文档。
该命令依赖于 python 环境,并且已经安装了 pip 工具;编译文档前请提前安装,否则会执行错误。
### 构建 allinone-package
-在 SecretPad 项目根目录下:
+在 EasyPsi 项目根目录下:
执行`make pack`命令,该命令会生成 secretflow-allinone-package-{github-tag}.tar.gz
-包含kuscia镜像、secretflow镜像、secretpad镜像、一键安装脚本、一键卸载脚本。
+包含kuscia镜像、secretflow镜像、easypsi镜像、一键安装脚本、一键卸载脚本。
该命令执行结果依赖 环境变量配置,不配置默认使用最新的镜像
```shell
KUSCIA_IMAGE=""
-SECRETPAD_IMAGE=""
+EASYPSI_IMAGE=""
SECRETFLOW_IMAGE=""
# 默认
KUSCIA_IMAGE=secretflow-registry.cn-hangzhou.cr.aliyuncs.com/secretflow/kuscia:latest
-SECRETPAD_IMAGE=secretflow-registry.cn-hangzhou.cr.aliyuncs.com/secretflow/secretpad:latest
+EASYPSI_IMAGE=secretflow-registry.cn-hangzhou.cr.aliyuncs.com/secretflow/easypsi:latest
SECRETFLOW_IMAGE=secretflow-registry.cn-hangzhou.cr.aliyuncs.com/secretflow/secretflow-lite-anolis8:latest
```
diff --git a/docs/development/index.rst b/docs/development/index.rst
index 17c1de5..b07f79d 100644
--- a/docs/development/index.rst
+++ b/docs/development/index.rst
@@ -5,4 +5,4 @@
.. toctree::
:maxdepth: 2
- build_secretpad_cn
\ No newline at end of file
+ build_easypsi_cn
\ No newline at end of file
diff --git a/docs/index.rst b/docs/index.rst
index 156e5b4..cdee64d 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -1,13 +1,13 @@
-.. SecretPad documentation master file, created by
+.. EasyPsi documentation master file, created by
sphinx-quickstart on Fri Aug 10 10:10:10 2023.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
-SecretPad
+EasyPsi
==================
-SecretPad 是一个基于 [Kuscia](https://github.com/secretflow/kuscia) 的隐私计算的 web 框架,能够方便的使用基于保护隐私的数据智能和机器学习的能力。通过 SecretPad:
+EasyPsi 是一个基于 [Kuscia](https://github.com/secretflow/kuscia) 的隐私计算的 web 框架,能够方便的使用基于保护隐私的数据智能和机器学习的能力。通过 EasyPsi:
* 你可以快速创建节点、注册数据、创建项目、进行合作节点间的授权
* 你可以使用丰富的数据预处理,数据分析、数据建模能力,满足多样化的业务场景。
diff --git a/secretpad-api/client-java-secretpad/pom.xml b/easypsi-api/client-java-easypsi/pom.xml
similarity index 91%
rename from secretpad-api/client-java-secretpad/pom.xml
rename to easypsi-api/client-java-easypsi/pom.xml
index cff34d7..9609b62 100644
--- a/secretpad-api/client-java-secretpad/pom.xml
+++ b/easypsi-api/client-java-easypsi/pom.xml
@@ -19,11 +19,11 @@
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- secretpad-api
+ easypsi-api
org.secretflow
0.0.1-SNAPSHOT
4.0.0
- client-java-secretpad
+ client-java-easypsi
\ No newline at end of file
diff --git a/secretpad-api/client-java-kusciaapi/pom.xml b/easypsi-api/client-java-kusciaapi/pom.xml
similarity index 80%
rename from secretpad-api/client-java-kusciaapi/pom.xml
rename to easypsi-api/client-java-kusciaapi/pom.xml
index eddcd86..712f7ce 100644
--- a/secretpad-api/client-java-kusciaapi/pom.xml
+++ b/easypsi-api/client-java-kusciaapi/pom.xml
@@ -19,7 +19,7 @@
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- secretpad-api
+ easypsi-api
org.secretflow
0.0.1-SNAPSHOT
@@ -68,7 +68,7 @@
org.secretflow
- secretpad-common
+ easypsi-common
@@ -84,6 +84,23 @@
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+
+ org.jacoco
+ jacoco-maven-plugin
+
+
+ report-aggregate
+ test
+
+ report-aggregate
+
+
+
+
diff --git a/secretpad-api/client-java-kusciaapi/src/main/java/org/secretflow/v1alpha1/constant/KusciaAPIConstants.java b/easypsi-api/client-java-kusciaapi/src/main/java/org/secretflow/v1alpha1/constant/KusciaAPIConstants.java
similarity index 100%
rename from secretpad-api/client-java-kusciaapi/src/main/java/org/secretflow/v1alpha1/constant/KusciaAPIConstants.java
rename to easypsi-api/client-java-kusciaapi/src/main/java/org/secretflow/v1alpha1/constant/KusciaAPIConstants.java
diff --git a/secretpad-api/client-java-kusciaapi/src/main/java/org/secretflow/v1alpha1/factory/KusciaAPIChannelFactory.java b/easypsi-api/client-java-kusciaapi/src/main/java/org/secretflow/v1alpha1/factory/KusciaAPIChannelFactory.java
similarity index 65%
rename from secretpad-api/client-java-kusciaapi/src/main/java/org/secretflow/v1alpha1/factory/KusciaAPIChannelFactory.java
rename to easypsi-api/client-java-kusciaapi/src/main/java/org/secretflow/v1alpha1/factory/KusciaAPIChannelFactory.java
index 5e106de..d29fbf6 100644
--- a/secretpad-api/client-java-kusciaapi/src/main/java/org/secretflow/v1alpha1/factory/KusciaAPIChannelFactory.java
+++ b/easypsi-api/client-java-kusciaapi/src/main/java/org/secretflow/v1alpha1/factory/KusciaAPIChannelFactory.java
@@ -16,9 +16,6 @@
package org.secretflow.v1alpha1.factory;
-import org.secretflow.secretpad.common.util.CertUtils;
-import org.secretflow.secretpad.common.util.FileUtils;
-
import io.grpc.ClientInterceptor;
import io.grpc.ManagedChannel;
import io.grpc.Metadata;
@@ -30,7 +27,10 @@
import io.grpc.netty.shaded.io.netty.handler.ssl.SslContextBuilder;
import io.grpc.netty.shaded.io.netty.handler.ssl.SslProvider;
import io.grpc.stub.MetadataUtils;
+import org.secretflow.easypsi.common.util.CertUtils;
+import org.secretflow.easypsi.common.util.FileUtils;
import org.secretflow.v1alpha1.constant.KusciaAPIConstants;
+import org.springframework.util.ObjectUtils;
import java.io.File;
import java.io.IOException;
@@ -38,13 +38,19 @@
import java.security.cert.X509Certificate;
import java.util.concurrent.TimeUnit;
+import static org.secretflow.easypsi.common.constant.KusciaConstants.KUSCIA_PROTOCOL_NOTLS;
+import static org.secretflow.easypsi.common.constant.KusciaConstants.KUSCIA_PROTOCOL_TLS;
+
/**
* ApiLite channel factory
*
* @author yansi
* @date 2023/5/8
*/
+
public class KusciaAPIChannelFactory {
+
+ private final String protocol;
/**
* ApiLite address
*/
@@ -59,10 +65,11 @@ public class KusciaAPIChannelFactory {
private final TlsConfig tlsConfig;
private final static int MAX_INBOUND_MESSAGE_SIZE = 256 * 1024 * 1024;
- public KusciaAPIChannelFactory(String address, String tokenFile, TlsConfig tlsConfig) {
+ public KusciaAPIChannelFactory(String address, String tokenFile, TlsConfig tlsConfig, String protocol) {
this.address = address;
this.tokenFile = tokenFile;
this.tlsConfig = tlsConfig;
+ this.protocol = protocol;
}
/**
@@ -71,18 +78,17 @@ public KusciaAPIChannelFactory(String address, String tokenFile, TlsConfig tlsCo
* @return a new client
*/
public ManagedChannel newClientChannel() {
- // init ssl context
- SslContextBuilder clientContextBuilder = SslContextBuilder.forClient();
- GrpcSslContexts.configure(clientContextBuilder, SslProvider.OPENSSL);
// load client certs
try {
- File certFile = FileUtils.readFile(tlsConfig.getCertFile());
- File keyFile = FileUtils.readFile(tlsConfig.getKeyFile());
- X509Certificate[] clientTrustedCaCerts = {CertUtils.loadX509Cert(tlsConfig.getCaFile())};
- SslContext sslContext = clientContextBuilder
- .keyManager(certFile, keyFile)
- .trustManager(clientTrustedCaCerts)
- .build();
+ //notls
+ if (KUSCIA_PROTOCOL_NOTLS.equals(protocol) || ObjectUtils.isEmpty(protocol)) {
+ return NettyChannelBuilder.forTarget(address)
+ .maxRetryAttempts(5)
+ .negotiationType(NegotiationType.PLAINTEXT)
+ .maxInboundMessageSize(MAX_INBOUND_MESSAGE_SIZE)
+ .withOption(ChannelOption.CONNECT_TIMEOUT_MILLIS, (int) TimeUnit.SECONDS.toMillis(10))
+ .build();
+ }
String token = FileUtils.readFile2String(tokenFile);
@@ -90,14 +96,41 @@ public ManagedChannel newClientChannel() {
Metadata.Key key = Metadata.Key.of(KusciaAPIConstants.TOKEN_HEADER, Metadata.ASCII_STRING_MARSHALLER);
metadata.put(key, token);
ClientInterceptor tokenInterceptor = MetadataUtils.newAttachHeadersInterceptor(metadata);
+ // init ssl context
+ SslContextBuilder clientContextBuilder = SslContextBuilder.forClient();
+ GrpcSslContexts.configure(clientContextBuilder, SslProvider.OPENSSL);
+
+ X509Certificate[] clientTrustedCaCerts = {CertUtils.loadX509Cert(tlsConfig.getCaFile())};
+ //tls
+ if (KUSCIA_PROTOCOL_TLS.equals(protocol)) {
+ SslContext sslContext = clientContextBuilder
+ .trustManager(clientTrustedCaCerts)
+ .build();
+ return NettyChannelBuilder.forTarget(address)
+ .maxRetryAttempts(5)
+ .intercept(tokenInterceptor)
+ .negotiationType(NegotiationType.TLS)
+ .sslContext(sslContext)
+ .maxInboundMessageSize(MAX_INBOUND_MESSAGE_SIZE)
+ .withOption(ChannelOption.CONNECT_TIMEOUT_MILLIS, (int) TimeUnit.SECONDS.toMillis(10))
+ .build();
+ }
+
+ //mtls
+ File certFile = FileUtils.readFile(tlsConfig.getCertFile());
+ File keyFile = FileUtils.readFile(tlsConfig.getKeyFile());
+ SslContext sslContext = clientContextBuilder
+ .keyManager(certFile, keyFile)
+ .trustManager(clientTrustedCaCerts)
+ .build();
// new client channel
return NettyChannelBuilder.forTarget(address)
.maxRetryAttempts(5)
.intercept(tokenInterceptor)
.negotiationType(NegotiationType.TLS)
- .maxInboundMessageSize(MAX_INBOUND_MESSAGE_SIZE)
.sslContext(sslContext)
+ .maxInboundMessageSize(MAX_INBOUND_MESSAGE_SIZE)
.withOption(ChannelOption.CONNECT_TIMEOUT_MILLIS, (int) TimeUnit.SECONDS.toMillis(10))
.build();
} catch (CertificateException | IOException e) {
diff --git a/secretpad-api/client-java-kusciaapi/src/main/java/org/secretflow/v1alpha1/factory/TlsConfig.java b/easypsi-api/client-java-kusciaapi/src/main/java/org/secretflow/v1alpha1/factory/TlsConfig.java
similarity index 100%
rename from secretpad-api/client-java-kusciaapi/src/main/java/org/secretflow/v1alpha1/factory/TlsConfig.java
rename to easypsi-api/client-java-kusciaapi/src/main/java/org/secretflow/v1alpha1/factory/TlsConfig.java
diff --git a/secretpad-api/client-java-kusciaapi/src/main/java/org/secretflow/v1alpha1/interceptor/TokenAuthServerInterceptor.java b/easypsi-api/client-java-kusciaapi/src/main/java/org/secretflow/v1alpha1/interceptor/TokenAuthServerInterceptor.java
similarity index 100%
rename from secretpad-api/client-java-kusciaapi/src/main/java/org/secretflow/v1alpha1/interceptor/TokenAuthServerInterceptor.java
rename to easypsi-api/client-java-kusciaapi/src/main/java/org/secretflow/v1alpha1/interceptor/TokenAuthServerInterceptor.java
diff --git a/secretpad-api/client-java-kusciaapi/src/test/java/org/secretflow/secretpad/api/DomainServiceTests.java b/easypsi-api/client-java-kusciaapi/src/test/java/org/secretflow/easypsi/api/DomainServiceTests.java
similarity index 96%
rename from secretpad-api/client-java-kusciaapi/src/test/java/org/secretflow/secretpad/api/DomainServiceTests.java
rename to easypsi-api/client-java-kusciaapi/src/test/java/org/secretflow/easypsi/api/DomainServiceTests.java
index 3b4a7be..bec091f 100644
--- a/secretpad-api/client-java-kusciaapi/src/test/java/org/secretflow/secretpad/api/DomainServiceTests.java
+++ b/easypsi-api/client-java-kusciaapi/src/test/java/org/secretflow/easypsi/api/DomainServiceTests.java
@@ -14,10 +14,10 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.api;
+package org.secretflow.easypsi.api;
-import org.secretflow.secretpad.common.util.CertUtils;
-import org.secretflow.secretpad.common.util.FileUtils;
+import org.secretflow.easypsi.common.util.CertUtils;
+import org.secretflow.easypsi.common.util.FileUtils;
import io.grpc.Server;
import io.grpc.ServerBuilder;
@@ -94,7 +94,7 @@ private void initStub() {
tlsConfig.setKeyFile("classpath:certs/client.pem");
tlsConfig.setCaFile("classpath:certs/ca.crt");
- KusciaAPIChannelFactory channelFactory = new KusciaAPIChannelFactory(address, tokenFile, tlsConfig);
+ KusciaAPIChannelFactory channelFactory = new KusciaAPIChannelFactory(address, tokenFile, tlsConfig,"mtls");
domainServiceStub = DomainServiceGrpc.newBlockingStub(channelFactory.newClientChannel());
}
diff --git a/secretpad-api/client-java-kusciaapi/src/test/resources/scripts/init_kusciaapi_certs.sh b/easypsi-api/client-java-kusciaapi/src/test/resources/scripts/init_kusciaapi_certs.sh
similarity index 100%
rename from secretpad-api/client-java-kusciaapi/src/test/resources/scripts/init_kusciaapi_certs.sh
rename to easypsi-api/client-java-kusciaapi/src/test/resources/scripts/init_kusciaapi_certs.sh
diff --git a/secretpad-api/pom.xml b/easypsi-api/pom.xml
similarity index 53%
rename from secretpad-api/pom.xml
rename to easypsi-api/pom.xml
index 1142ec4..49aeadf 100644
--- a/secretpad-api/pom.xml
+++ b/easypsi-api/pom.xml
@@ -19,17 +19,41 @@
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- secretpad-parent
+ easypsi-parent
org.secretflow
0.0.1-SNAPSHOT
4.0.0
pom
- secretpad-api
+ easypsi-api
client-java-kusciaapi
- client-java-secretpad
+ client-java-easypsi
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+ true
+
+
+
+ org.jacoco
+ jacoco-maven-plugin
+
+
+ report-aggregate
+ test
+
+ report-aggregate
+
+
+
+
+
+
\ No newline at end of file
diff --git a/secretpad-common/pom.xml b/easypsi-common/pom.xml
similarity index 71%
rename from secretpad-common/pom.xml
rename to easypsi-common/pom.xml
index 75a6146..03458a5 100644
--- a/secretpad-common/pom.xml
+++ b/easypsi-common/pom.xml
@@ -19,13 +19,13 @@
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- secretpad-parent
+ easypsi-parent
org.secretflow
0.0.1-SNAPSHOT
4.0.0
- secretpad-common
+ easypsi-common
org.projectlombok
@@ -64,4 +64,29 @@
spring-web
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+ true
+
+
+
+ org.jacoco
+ jacoco-maven-plugin
+
+
+ report-aggregate
+ test
+
+ report-aggregate
+
+
+
+
+
+
\ No newline at end of file
diff --git a/secretpad-common/src/main/java/org/secretflow/secretpad/common/annotation/resource/DataResource.java b/easypsi-common/src/main/java/org/secretflow/easypsi/common/annotation/resource/DataResource.java
similarity index 87%
rename from secretpad-common/src/main/java/org/secretflow/secretpad/common/annotation/resource/DataResource.java
rename to easypsi-common/src/main/java/org/secretflow/easypsi/common/annotation/resource/DataResource.java
index 2a6bbbb..5a412bc 100644
--- a/secretpad-common/src/main/java/org/secretflow/secretpad/common/annotation/resource/DataResource.java
+++ b/easypsi-common/src/main/java/org/secretflow/easypsi/common/annotation/resource/DataResource.java
@@ -14,9 +14,9 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.common.annotation.resource;
+package org.secretflow.easypsi.common.annotation.resource;
-import org.secretflow.secretpad.common.constant.resource.DataResourceType;
+import org.secretflow.easypsi.common.constant.resource.DataResourceType;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
diff --git a/secretpad-common/src/main/java/org/secretflow/secretpad/common/annotation/resource/InterfaceResource.java b/easypsi-common/src/main/java/org/secretflow/easypsi/common/annotation/resource/InterfaceResource.java
similarity index 94%
rename from secretpad-common/src/main/java/org/secretflow/secretpad/common/annotation/resource/InterfaceResource.java
rename to easypsi-common/src/main/java/org/secretflow/easypsi/common/annotation/resource/InterfaceResource.java
index fd98b29..1af6ce7 100644
--- a/secretpad-common/src/main/java/org/secretflow/secretpad/common/annotation/resource/InterfaceResource.java
+++ b/easypsi-common/src/main/java/org/secretflow/easypsi/common/annotation/resource/InterfaceResource.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.common.annotation.resource;
+package org.secretflow.easypsi.common.annotation.resource;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
diff --git a/easypsi-common/src/main/java/org/secretflow/easypsi/common/constant/CacheConstants.java b/easypsi-common/src/main/java/org/secretflow/easypsi/common/constant/CacheConstants.java
new file mode 100644
index 0000000..cc1be0a
--- /dev/null
+++ b/easypsi-common/src/main/java/org/secretflow/easypsi/common/constant/CacheConstants.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2024 Ant Group Co., Ltd.
+ *
+ * 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.
+ */
+
+package org.secretflow.easypsi.common.constant;
+
+/**
+ * cache
+ *
+ * @author yutu
+ * @date 2024/01/24
+ */
+public class CacheConstants {
+ public static final String USER_LOCK_CACHE = "user_lock";
+
+}
\ No newline at end of file
diff --git a/secretpad-common/src/main/java/org/secretflow/secretpad/common/constant/DatabaseConstants.java b/easypsi-common/src/main/java/org/secretflow/easypsi/common/constant/DatabaseConstants.java
similarity index 94%
rename from secretpad-common/src/main/java/org/secretflow/secretpad/common/constant/DatabaseConstants.java
rename to easypsi-common/src/main/java/org/secretflow/easypsi/common/constant/DatabaseConstants.java
index a53652a..7e1f835 100644
--- a/secretpad-common/src/main/java/org/secretflow/secretpad/common/constant/DatabaseConstants.java
+++ b/easypsi-common/src/main/java/org/secretflow/easypsi/common/constant/DatabaseConstants.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.common.constant;
+package org.secretflow.easypsi.common.constant;
/**
* Database Constants
diff --git a/secretpad-common/src/main/java/org/secretflow/secretpad/common/constant/DomainConstants.java b/easypsi-common/src/main/java/org/secretflow/easypsi/common/constant/DomainConstants.java
similarity index 96%
rename from secretpad-common/src/main/java/org/secretflow/secretpad/common/constant/DomainConstants.java
rename to easypsi-common/src/main/java/org/secretflow/easypsi/common/constant/DomainConstants.java
index 93e6d84..daba4ae 100644
--- a/secretpad-common/src/main/java/org/secretflow/secretpad/common/constant/DomainConstants.java
+++ b/easypsi-common/src/main/java/org/secretflow/easypsi/common/constant/DomainConstants.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.common.constant;
+package org.secretflow.easypsi.common.constant;
/**
* @author yutu
diff --git a/secretpad-common/src/main/java/org/secretflow/secretpad/common/constant/DomainRouterConstants.java b/easypsi-common/src/main/java/org/secretflow/easypsi/common/constant/DomainRouterConstants.java
similarity index 95%
rename from secretpad-common/src/main/java/org/secretflow/secretpad/common/constant/DomainRouterConstants.java
rename to easypsi-common/src/main/java/org/secretflow/easypsi/common/constant/DomainRouterConstants.java
index 0b7b97f..4b6b454 100644
--- a/secretpad-common/src/main/java/org/secretflow/secretpad/common/constant/DomainRouterConstants.java
+++ b/easypsi-common/src/main/java/org/secretflow/easypsi/common/constant/DomainRouterConstants.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.common.constant;
+package org.secretflow.easypsi.common.constant;
/**
* @author yutu
diff --git a/secretpad-common/src/main/java/org/secretflow/secretpad/common/constant/JobConstants.java b/easypsi-common/src/main/java/org/secretflow/easypsi/common/constant/JobConstants.java
similarity index 89%
rename from secretpad-common/src/main/java/org/secretflow/secretpad/common/constant/JobConstants.java
rename to easypsi-common/src/main/java/org/secretflow/easypsi/common/constant/JobConstants.java
index 16490ce..db58a19 100644
--- a/secretpad-common/src/main/java/org/secretflow/secretpad/common/constant/JobConstants.java
+++ b/easypsi-common/src/main/java/org/secretflow/easypsi/common/constant/JobConstants.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.common.constant;
+package org.secretflow.easypsi.common.constant;
/**
* @author guyu
@@ -34,6 +34,9 @@ public enum RoleEnum {
public enum AdvancedJoinTypeEnum {
ADVANCED_JOIN_TYPE_UNSPECIFIED,
ADVANCED_JOIN_TYPE_INNER_JOIN,
+ ADVANCED_JOIN_TYPE_LEFT_JOIN,
+ ADVANCED_JOIN_TYPE_RIGHT_JOIN,
+ ADVANCED_JOIN_TYPE_FULL_JOIN,
ADVANCED_JOIN_TYPE_DIFFERENCE
}
@@ -54,6 +57,4 @@ public enum CurveType {
public static final String BUCKET_SIZE = "1048576";
public static final String RECV_TIMEOUT_MS = "30";
public static final String HTTP_TIMEOUT_MS = "30";
-
- public static final String LEFT_SIDE = "ROLE_RECEIVER";
}
\ No newline at end of file
diff --git a/easypsi-common/src/main/java/org/secretflow/easypsi/common/constant/KusciaConstants.java b/easypsi-common/src/main/java/org/secretflow/easypsi/common/constant/KusciaConstants.java
new file mode 100644
index 0000000..bc9f648
--- /dev/null
+++ b/easypsi-common/src/main/java/org/secretflow/easypsi/common/constant/KusciaConstants.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2024 Ant Group Co., Ltd.
+ *
+ * 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.
+ */
+
+package org.secretflow.easypsi.common.constant;
+
+/**
+ * cache
+ *
+ * @author chixian
+ * @date 2024/02/20
+ */
+public class KusciaConstants {
+ public static final String KUSCIA_PROTOCOL_NOTLS = "notls";
+
+ public static final String KUSCIA_PROTOCOL_TLS = "tls";
+
+ public static final String KUSCIA_PROTOCOL_MTLS = "mtls";
+}
\ No newline at end of file
diff --git a/secretpad-common/src/main/java/org/secretflow/secretpad/common/constant/PermissionTargetType.java b/easypsi-common/src/main/java/org/secretflow/easypsi/common/constant/PermissionTargetType.java
similarity index 93%
rename from secretpad-common/src/main/java/org/secretflow/secretpad/common/constant/PermissionTargetType.java
rename to easypsi-common/src/main/java/org/secretflow/easypsi/common/constant/PermissionTargetType.java
index dc53581..8d3be55 100644
--- a/secretpad-common/src/main/java/org/secretflow/secretpad/common/constant/PermissionTargetType.java
+++ b/easypsi-common/src/main/java/org/secretflow/easypsi/common/constant/PermissionTargetType.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.common.constant;
+package org.secretflow.easypsi.common.constant;
/**
* @author beiwei
diff --git a/secretpad-common/src/main/java/org/secretflow/secretpad/common/constant/PermissionUserType.java b/easypsi-common/src/main/java/org/secretflow/easypsi/common/constant/PermissionUserType.java
similarity index 93%
rename from secretpad-common/src/main/java/org/secretflow/secretpad/common/constant/PermissionUserType.java
rename to easypsi-common/src/main/java/org/secretflow/easypsi/common/constant/PermissionUserType.java
index 56087cc..b519a26 100644
--- a/secretpad-common/src/main/java/org/secretflow/secretpad/common/constant/PermissionUserType.java
+++ b/easypsi-common/src/main/java/org/secretflow/easypsi/common/constant/PermissionUserType.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.common.constant;
+package org.secretflow.easypsi.common.constant;
/**
* @author beiwei
diff --git a/secretpad-common/src/main/java/org/secretflow/secretpad/common/constant/PlatformType.java b/easypsi-common/src/main/java/org/secretflow/easypsi/common/constant/PlatformType.java
similarity index 93%
rename from secretpad-common/src/main/java/org/secretflow/secretpad/common/constant/PlatformType.java
rename to easypsi-common/src/main/java/org/secretflow/easypsi/common/constant/PlatformType.java
index f7b5052..20b124a 100644
--- a/secretpad-common/src/main/java/org/secretflow/secretpad/common/constant/PlatformType.java
+++ b/easypsi-common/src/main/java/org/secretflow/easypsi/common/constant/PlatformType.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.common.constant;
+package org.secretflow.easypsi.common.constant;
/**
* @author beiwei
diff --git a/secretpad-common/src/main/java/org/secretflow/secretpad/common/constant/ResourceType.java b/easypsi-common/src/main/java/org/secretflow/easypsi/common/constant/ResourceType.java
similarity index 93%
rename from secretpad-common/src/main/java/org/secretflow/secretpad/common/constant/ResourceType.java
rename to easypsi-common/src/main/java/org/secretflow/easypsi/common/constant/ResourceType.java
index 862cef5..51fd925 100644
--- a/secretpad-common/src/main/java/org/secretflow/secretpad/common/constant/ResourceType.java
+++ b/easypsi-common/src/main/java/org/secretflow/easypsi/common/constant/ResourceType.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.common.constant;
+package org.secretflow.easypsi.common.constant;
/**
* @author beiwei
diff --git a/secretpad-common/src/main/java/org/secretflow/secretpad/common/constant/UserOwnerType.java b/easypsi-common/src/main/java/org/secretflow/easypsi/common/constant/UserOwnerType.java
similarity index 77%
rename from secretpad-common/src/main/java/org/secretflow/secretpad/common/constant/UserOwnerType.java
rename to easypsi-common/src/main/java/org/secretflow/easypsi/common/constant/UserOwnerType.java
index 6f793dc..3b4220c 100644
--- a/secretpad-common/src/main/java/org/secretflow/secretpad/common/constant/UserOwnerType.java
+++ b/easypsi-common/src/main/java/org/secretflow/easypsi/common/constant/UserOwnerType.java
@@ -14,10 +14,10 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.common.constant;
+package org.secretflow.easypsi.common.constant;
-import org.secretflow.secretpad.common.errorcode.SystemErrorCode;
-import org.secretflow.secretpad.common.exception.SecretpadException;
+import org.secretflow.easypsi.common.errorcode.SystemErrorCode;
+import org.secretflow.easypsi.common.exception.EasyPsiException;
/**
* @author beiwei
@@ -39,6 +39,6 @@ public PermissionUserType toPermissionUserType() {
if (P2P.equals(this)) {
return PermissionUserType.NODE;
}
- throw SecretpadException.of(SystemErrorCode.VALIDATION_ERROR, "Invalidate user owner type: " + this.toString());
+ throw EasyPsiException.of(SystemErrorCode.VALIDATION_ERROR, "Invalidate user owner type: " + this.toString());
}
}
diff --git a/secretpad-common/src/main/java/org/secretflow/secretpad/common/constant/resource/DataResourceType.java b/easypsi-common/src/main/java/org/secretflow/easypsi/common/constant/resource/DataResourceType.java
similarity index 92%
rename from secretpad-common/src/main/java/org/secretflow/secretpad/common/constant/resource/DataResourceType.java
rename to easypsi-common/src/main/java/org/secretflow/easypsi/common/constant/resource/DataResourceType.java
index c467c08..238ef54 100644
--- a/secretpad-common/src/main/java/org/secretflow/secretpad/common/constant/resource/DataResourceType.java
+++ b/easypsi-common/src/main/java/org/secretflow/easypsi/common/constant/resource/DataResourceType.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.common.constant.resource;
+package org.secretflow.easypsi.common.constant.resource;
/**
* @author beiwei
diff --git a/secretpad-common/src/main/java/org/secretflow/secretpad/common/constant/resource/InterfaceResourceCode.java b/easypsi-common/src/main/java/org/secretflow/easypsi/common/constant/resource/InterfaceResourceCode.java
similarity index 97%
rename from secretpad-common/src/main/java/org/secretflow/secretpad/common/constant/resource/InterfaceResourceCode.java
rename to easypsi-common/src/main/java/org/secretflow/easypsi/common/constant/resource/InterfaceResourceCode.java
index 8a072e3..44ccc4a 100644
--- a/secretpad-common/src/main/java/org/secretflow/secretpad/common/constant/resource/InterfaceResourceCode.java
+++ b/easypsi-common/src/main/java/org/secretflow/easypsi/common/constant/resource/InterfaceResourceCode.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.common.constant.resource;
+package org.secretflow.easypsi.common.constant.resource;
/**
* @author beiwei
diff --git a/secretpad-common/src/main/java/org/secretflow/secretpad/common/constant/role/RoleCodeConstants.java b/easypsi-common/src/main/java/org/secretflow/easypsi/common/constant/role/RoleCodeConstants.java
similarity index 57%
rename from secretpad-common/src/main/java/org/secretflow/secretpad/common/constant/role/RoleCodeConstants.java
rename to easypsi-common/src/main/java/org/secretflow/easypsi/common/constant/role/RoleCodeConstants.java
index 3ef08de..459f2dc 100644
--- a/secretpad-common/src/main/java/org/secretflow/secretpad/common/constant/role/RoleCodeConstants.java
+++ b/easypsi-common/src/main/java/org/secretflow/easypsi/common/constant/role/RoleCodeConstants.java
@@ -1,4 +1,4 @@
-package org.secretflow.secretpad.common.constant.role;
+package org.secretflow.easypsi.common.constant.role;
public interface RoleCodeConstants {
diff --git a/secretpad-common/src/main/java/org/secretflow/secretpad/common/dto/DownloadInfo.java b/easypsi-common/src/main/java/org/secretflow/easypsi/common/dto/DownloadInfo.java
similarity index 95%
rename from secretpad-common/src/main/java/org/secretflow/secretpad/common/dto/DownloadInfo.java
rename to easypsi-common/src/main/java/org/secretflow/easypsi/common/dto/DownloadInfo.java
index af01aa9..c0b81a3 100644
--- a/secretpad-common/src/main/java/org/secretflow/secretpad/common/dto/DownloadInfo.java
+++ b/easypsi-common/src/main/java/org/secretflow/easypsi/common/dto/DownloadInfo.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.common.dto;
+package org.secretflow.easypsi.common.dto;
import lombok.Builder;
import lombok.Getter;
diff --git a/secretpad-common/src/main/java/org/secretflow/secretpad/common/dto/EnvDTO.java b/easypsi-common/src/main/java/org/secretflow/easypsi/common/dto/EnvDTO.java
similarity index 65%
rename from secretpad-common/src/main/java/org/secretflow/secretpad/common/dto/EnvDTO.java
rename to easypsi-common/src/main/java/org/secretflow/easypsi/common/dto/EnvDTO.java
index 8550769..3eb95d7 100644
--- a/secretpad-common/src/main/java/org/secretflow/secretpad/common/dto/EnvDTO.java
+++ b/easypsi-common/src/main/java/org/secretflow/easypsi/common/dto/EnvDTO.java
@@ -1,9 +1,9 @@
-package org.secretflow.secretpad.common.dto;
+package org.secretflow.easypsi.common.dto;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
-import org.secretflow.secretpad.common.constant.PlatformType;
+import org.secretflow.easypsi.common.constant.PlatformType;
/**
* environment dto
diff --git a/secretpad-common/src/main/java/org/secretflow/secretpad/common/dto/UserContextDTO.java b/easypsi-common/src/main/java/org/secretflow/easypsi/common/dto/UserContextDTO.java
similarity index 88%
rename from secretpad-common/src/main/java/org/secretflow/secretpad/common/dto/UserContextDTO.java
rename to easypsi-common/src/main/java/org/secretflow/easypsi/common/dto/UserContextDTO.java
index 75f63b4..148c808 100644
--- a/secretpad-common/src/main/java/org/secretflow/secretpad/common/dto/UserContextDTO.java
+++ b/easypsi-common/src/main/java/org/secretflow/easypsi/common/dto/UserContextDTO.java
@@ -14,11 +14,11 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.common.dto;
+package org.secretflow.easypsi.common.dto;
-import org.secretflow.secretpad.common.constant.PlatformType;
-import org.secretflow.secretpad.common.constant.UserOwnerType;
-import org.secretflow.secretpad.common.util.JsonUtils;
+import org.secretflow.easypsi.common.constant.PlatformType;
+import org.secretflow.easypsi.common.constant.UserOwnerType;
+import org.secretflow.easypsi.common.util.JsonUtils;
import lombok.Getter;
import lombok.NoArgsConstructor;
@@ -55,6 +55,9 @@ public class UserContextDTO {
private boolean noviceUser;
+ private boolean initial;
+
+
public boolean containInterfaceResource(String resourceCode) {
if (StringUtils.isBlank(resourceCode)) {
diff --git a/secretpad-common/src/main/java/org/secretflow/secretpad/common/errorcode/AuthErrorCode.java b/easypsi-common/src/main/java/org/secretflow/easypsi/common/errorcode/AuthErrorCode.java
similarity index 90%
rename from secretpad-common/src/main/java/org/secretflow/secretpad/common/errorcode/AuthErrorCode.java
rename to easypsi-common/src/main/java/org/secretflow/easypsi/common/errorcode/AuthErrorCode.java
index fc03a75..cefcbe5 100644
--- a/secretpad-common/src/main/java/org/secretflow/secretpad/common/errorcode/AuthErrorCode.java
+++ b/easypsi-common/src/main/java/org/secretflow/easypsi/common/errorcode/AuthErrorCode.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.common.errorcode;
+package org.secretflow.easypsi.common.errorcode;
/**
* Authorization errorCode
@@ -47,6 +47,11 @@ public enum AuthErrorCode implements ErrorCode {
* Reset password is locked
*/
RESET_PASSWORD_IS_LOCKED(202011604),
+
+ /**
+ * Password not initialized
+ */
+ PASSWORD_NOT_INITIALIZED(202011605),
;
private final int code;
diff --git a/secretpad-common/src/main/java/org/secretflow/secretpad/common/errorcode/DataErrorCode.java b/easypsi-common/src/main/java/org/secretflow/easypsi/common/errorcode/DataErrorCode.java
similarity index 97%
rename from secretpad-common/src/main/java/org/secretflow/secretpad/common/errorcode/DataErrorCode.java
rename to easypsi-common/src/main/java/org/secretflow/easypsi/common/errorcode/DataErrorCode.java
index 2387e95..2d18bfe 100644
--- a/secretpad-common/src/main/java/org/secretflow/secretpad/common/errorcode/DataErrorCode.java
+++ b/easypsi-common/src/main/java/org/secretflow/easypsi/common/errorcode/DataErrorCode.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.common.errorcode;
+package org.secretflow.easypsi.common.errorcode;
/**
* Data errorCode
diff --git a/secretpad-common/src/main/java/org/secretflow/secretpad/common/errorcode/ErrorCode.java b/easypsi-common/src/main/java/org/secretflow/easypsi/common/errorcode/ErrorCode.java
similarity index 94%
rename from secretpad-common/src/main/java/org/secretflow/secretpad/common/errorcode/ErrorCode.java
rename to easypsi-common/src/main/java/org/secretflow/easypsi/common/errorcode/ErrorCode.java
index dc6dbe4..e5b1305 100644
--- a/secretpad-common/src/main/java/org/secretflow/secretpad/common/errorcode/ErrorCode.java
+++ b/easypsi-common/src/main/java/org/secretflow/easypsi/common/errorcode/ErrorCode.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.common.errorcode;
+package org.secretflow.easypsi.common.errorcode;
/**
* Basic errorCode
diff --git a/secretpad-common/src/main/java/org/secretflow/secretpad/common/errorcode/JobErrorCode.java b/easypsi-common/src/main/java/org/secretflow/easypsi/common/errorcode/JobErrorCode.java
similarity index 93%
rename from secretpad-common/src/main/java/org/secretflow/secretpad/common/errorcode/JobErrorCode.java
rename to easypsi-common/src/main/java/org/secretflow/easypsi/common/errorcode/JobErrorCode.java
index 6eb51ec..914b7a5 100644
--- a/secretpad-common/src/main/java/org/secretflow/secretpad/common/errorcode/JobErrorCode.java
+++ b/easypsi-common/src/main/java/org/secretflow/easypsi/common/errorcode/JobErrorCode.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.common.errorcode;
+package org.secretflow.easypsi.common.errorcode;
/**
* Job errorCode
@@ -63,9 +63,10 @@ public enum JobErrorCode implements ErrorCode {
* project job result expired
*/
PROJECT_JOB_RESULT_HASH_EXPIRED_ERROR(202011914),
-
-
-
+ /**
+ * project job config error
+ */
+ PROJECT_JOB_Config_ERROR(202011915),
;
diff --git a/secretpad-common/src/main/java/org/secretflow/secretpad/common/errorcode/KusciaGrpcErrorCode.java b/easypsi-common/src/main/java/org/secretflow/easypsi/common/errorcode/KusciaGrpcErrorCode.java
similarity index 95%
rename from secretpad-common/src/main/java/org/secretflow/secretpad/common/errorcode/KusciaGrpcErrorCode.java
rename to easypsi-common/src/main/java/org/secretflow/easypsi/common/errorcode/KusciaGrpcErrorCode.java
index 6d0e0e4..06d63ed 100644
--- a/secretpad-common/src/main/java/org/secretflow/secretpad/common/errorcode/KusciaGrpcErrorCode.java
+++ b/easypsi-common/src/main/java/org/secretflow/easypsi/common/errorcode/KusciaGrpcErrorCode.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.common.errorcode;
+package org.secretflow.easypsi.common.errorcode;
/**
* @author yutu
diff --git a/secretpad-common/src/main/java/org/secretflow/secretpad/common/errorcode/NodeErrorCode.java b/easypsi-common/src/main/java/org/secretflow/easypsi/common/errorcode/NodeErrorCode.java
similarity index 96%
rename from secretpad-common/src/main/java/org/secretflow/secretpad/common/errorcode/NodeErrorCode.java
rename to easypsi-common/src/main/java/org/secretflow/easypsi/common/errorcode/NodeErrorCode.java
index 5c8257b..6018719 100644
--- a/secretpad-common/src/main/java/org/secretflow/secretpad/common/errorcode/NodeErrorCode.java
+++ b/easypsi-common/src/main/java/org/secretflow/easypsi/common/errorcode/NodeErrorCode.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.common.errorcode;
+package org.secretflow.easypsi.common.errorcode;
/**
* Node errorCode
diff --git a/secretpad-common/src/main/java/org/secretflow/secretpad/common/errorcode/NodeRouteErrorCode.java b/easypsi-common/src/main/java/org/secretflow/easypsi/common/errorcode/NodeRouteErrorCode.java
similarity index 97%
rename from secretpad-common/src/main/java/org/secretflow/secretpad/common/errorcode/NodeRouteErrorCode.java
rename to easypsi-common/src/main/java/org/secretflow/easypsi/common/errorcode/NodeRouteErrorCode.java
index 22e469a..94b220a 100644
--- a/secretpad-common/src/main/java/org/secretflow/secretpad/common/errorcode/NodeRouteErrorCode.java
+++ b/easypsi-common/src/main/java/org/secretflow/easypsi/common/errorcode/NodeRouteErrorCode.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.common.errorcode;
+package org.secretflow.easypsi.common.errorcode;
/**
* @author yutu
diff --git a/secretpad-common/src/main/java/org/secretflow/secretpad/common/errorcode/ProjectErrorCode.java b/easypsi-common/src/main/java/org/secretflow/easypsi/common/errorcode/ProjectErrorCode.java
similarity index 95%
rename from secretpad-common/src/main/java/org/secretflow/secretpad/common/errorcode/ProjectErrorCode.java
rename to easypsi-common/src/main/java/org/secretflow/easypsi/common/errorcode/ProjectErrorCode.java
index eff2871..211fd6c 100644
--- a/secretpad-common/src/main/java/org/secretflow/secretpad/common/errorcode/ProjectErrorCode.java
+++ b/easypsi-common/src/main/java/org/secretflow/easypsi/common/errorcode/ProjectErrorCode.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.common.errorcode;
+package org.secretflow.easypsi.common.errorcode;
/**
* Project errorCode
diff --git a/secretpad-common/src/main/java/org/secretflow/secretpad/common/errorcode/SystemErrorCode.java b/easypsi-common/src/main/java/org/secretflow/easypsi/common/errorcode/SystemErrorCode.java
similarity index 96%
rename from secretpad-common/src/main/java/org/secretflow/secretpad/common/errorcode/SystemErrorCode.java
rename to easypsi-common/src/main/java/org/secretflow/easypsi/common/errorcode/SystemErrorCode.java
index 170b6cc..5fb2fb2 100644
--- a/secretpad-common/src/main/java/org/secretflow/secretpad/common/errorcode/SystemErrorCode.java
+++ b/easypsi-common/src/main/java/org/secretflow/easypsi/common/errorcode/SystemErrorCode.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.common.errorcode;
+package org.secretflow.easypsi.common.errorcode;
/**
* System errorCode
diff --git a/secretpad-common/src/main/java/org/secretflow/secretpad/common/errorcode/UserErrorCode.java b/easypsi-common/src/main/java/org/secretflow/easypsi/common/errorcode/UserErrorCode.java
similarity index 96%
rename from secretpad-common/src/main/java/org/secretflow/secretpad/common/errorcode/UserErrorCode.java
rename to easypsi-common/src/main/java/org/secretflow/easypsi/common/errorcode/UserErrorCode.java
index d68554f..1df11ad 100644
--- a/secretpad-common/src/main/java/org/secretflow/secretpad/common/errorcode/UserErrorCode.java
+++ b/easypsi-common/src/main/java/org/secretflow/easypsi/common/errorcode/UserErrorCode.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.common.errorcode;
+package org.secretflow.easypsi.common.errorcode;
/**
* UserErrorCode
diff --git a/secretpad-common/src/main/java/org/secretflow/secretpad/common/exception/SecretpadException.java b/easypsi-common/src/main/java/org/secretflow/easypsi/common/exception/EasyPsiException.java
similarity index 64%
rename from secretpad-common/src/main/java/org/secretflow/secretpad/common/exception/SecretpadException.java
rename to easypsi-common/src/main/java/org/secretflow/easypsi/common/exception/EasyPsiException.java
index 2924930..8cec584 100644
--- a/secretpad-common/src/main/java/org/secretflow/secretpad/common/exception/SecretpadException.java
+++ b/easypsi-common/src/main/java/org/secretflow/easypsi/common/exception/EasyPsiException.java
@@ -14,17 +14,17 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.common.exception;
+package org.secretflow.easypsi.common.exception;
-import org.secretflow.secretpad.common.errorcode.ErrorCode;
+import org.secretflow.easypsi.common.errorcode.ErrorCode;
/**
- * SecretPad Exception
+ * EasyPsi Exception
*
* @author yansi
* @date 2023/5/10
*/
-public final class SecretpadException extends RuntimeException {
+public final class EasyPsiException extends RuntimeException {
/**
* error code
*/
@@ -35,38 +35,38 @@ public final class SecretpadException extends RuntimeException {
private final String[] args;
/**
- * Fill SecretPad Exception
+ * Fill EasyPsi Exception
*
* @param errorCode
* @param cause
* @param args
*/
- private SecretpadException(ErrorCode errorCode, Throwable cause, String... args) {
+ private EasyPsiException(ErrorCode errorCode, Throwable cause, String... args) {
super(args != null && args.length > 0 ? args[0] : "", cause);
this.errorCode = errorCode;
this.args = args;
}
/**
- * Build SecretPad Exception with args
+ * Build EasyPsi Exception with args
*
* @param errorCode
* @param args
- * @return SecretPad exception
+ * @return EasyPsi exception
*/
- public static SecretpadException of(ErrorCode errorCode, String... args) {
- return new SecretpadException(errorCode, null, args);
+ public static EasyPsiException of(ErrorCode errorCode, String... args) {
+ return new EasyPsiException(errorCode, null, args);
}
/**
- * Build SecretPad Exception with cause
+ * Build EasyPsi Exception with cause
*
* @param errorCode
* @param cause
- * @return SecretPad exception
+ * @return EasyPsi exception
*/
- public static SecretpadException of(ErrorCode errorCode, Throwable cause) {
- return new SecretpadException(errorCode, cause, cause.getMessage());
+ public static EasyPsiException of(ErrorCode errorCode, Throwable cause) {
+ return new EasyPsiException(errorCode, cause, cause.getMessage());
}
/**
diff --git a/secretpad-common/src/main/java/org/secretflow/secretpad/common/factory/YamlPropertySourceFactory.java b/easypsi-common/src/main/java/org/secretflow/easypsi/common/factory/YamlPropertySourceFactory.java
similarity index 97%
rename from secretpad-common/src/main/java/org/secretflow/secretpad/common/factory/YamlPropertySourceFactory.java
rename to easypsi-common/src/main/java/org/secretflow/easypsi/common/factory/YamlPropertySourceFactory.java
index 9b43bb7..2960268 100644
--- a/secretpad-common/src/main/java/org/secretflow/secretpad/common/factory/YamlPropertySourceFactory.java
+++ b/easypsi-common/src/main/java/org/secretflow/easypsi/common/factory/YamlPropertySourceFactory.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.common.factory;
+package org.secretflow.easypsi.common.factory;
import org.springframework.beans.factory.config.YamlPropertiesFactoryBean;
import org.springframework.core.env.PropertiesPropertySource;
diff --git a/secretpad-common/src/main/java/org/secretflow/secretpad/common/i18n/LocaleMessageResolver.java b/easypsi-common/src/main/java/org/secretflow/easypsi/common/i18n/LocaleMessageResolver.java
similarity index 96%
rename from secretpad-common/src/main/java/org/secretflow/secretpad/common/i18n/LocaleMessageResolver.java
rename to easypsi-common/src/main/java/org/secretflow/easypsi/common/i18n/LocaleMessageResolver.java
index e3a46ab..e4e9c8c 100644
--- a/secretpad-common/src/main/java/org/secretflow/secretpad/common/i18n/LocaleMessageResolver.java
+++ b/easypsi-common/src/main/java/org/secretflow/easypsi/common/i18n/LocaleMessageResolver.java
@@ -14,9 +14,9 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.common.i18n;
+package org.secretflow.easypsi.common.i18n;
-import org.secretflow.secretpad.common.errorcode.ErrorCode;
+import org.secretflow.easypsi.common.errorcode.ErrorCode;
import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;
diff --git a/secretpad-common/src/main/java/org/secretflow/secretpad/common/i18n/MessageResolver.java b/easypsi-common/src/main/java/org/secretflow/easypsi/common/i18n/MessageResolver.java
similarity index 94%
rename from secretpad-common/src/main/java/org/secretflow/secretpad/common/i18n/MessageResolver.java
rename to easypsi-common/src/main/java/org/secretflow/easypsi/common/i18n/MessageResolver.java
index 532535a..9e877bf 100644
--- a/secretpad-common/src/main/java/org/secretflow/secretpad/common/i18n/MessageResolver.java
+++ b/easypsi-common/src/main/java/org/secretflow/easypsi/common/i18n/MessageResolver.java
@@ -14,9 +14,9 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.common.i18n;
+package org.secretflow.easypsi.common.i18n;
-import org.secretflow.secretpad.common.errorcode.ErrorCode;
+import org.secretflow.easypsi.common.errorcode.ErrorCode;
import java.util.Locale;
diff --git a/secretpad-common/src/main/java/org/secretflow/secretpad/common/util/CertUtils.java b/easypsi-common/src/main/java/org/secretflow/easypsi/common/util/CertUtils.java
similarity index 97%
rename from secretpad-common/src/main/java/org/secretflow/secretpad/common/util/CertUtils.java
rename to easypsi-common/src/main/java/org/secretflow/easypsi/common/util/CertUtils.java
index b6a977e..b9371c0 100644
--- a/secretpad-common/src/main/java/org/secretflow/secretpad/common/util/CertUtils.java
+++ b/easypsi-common/src/main/java/org/secretflow/easypsi/common/util/CertUtils.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.common.util;
+package org.secretflow.easypsi.common.util;
import java.io.File;
import java.io.FileInputStream;
diff --git a/secretpad-common/src/main/java/org/secretflow/secretpad/common/util/CompressUtils.java b/easypsi-common/src/main/java/org/secretflow/easypsi/common/util/CompressUtils.java
similarity index 99%
rename from secretpad-common/src/main/java/org/secretflow/secretpad/common/util/CompressUtils.java
rename to easypsi-common/src/main/java/org/secretflow/easypsi/common/util/CompressUtils.java
index c0552bc..63f5633 100644
--- a/secretpad-common/src/main/java/org/secretflow/secretpad/common/util/CompressUtils.java
+++ b/easypsi-common/src/main/java/org/secretflow/easypsi/common/util/CompressUtils.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.common.util;
+package org.secretflow.easypsi.common.util;
import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
diff --git a/secretpad-common/src/main/java/org/secretflow/secretpad/common/util/DateTimes.java b/easypsi-common/src/main/java/org/secretflow/easypsi/common/util/DateTimes.java
similarity index 98%
rename from secretpad-common/src/main/java/org/secretflow/secretpad/common/util/DateTimes.java
rename to easypsi-common/src/main/java/org/secretflow/easypsi/common/util/DateTimes.java
index 68bd715..b5dcf13 100644
--- a/secretpad-common/src/main/java/org/secretflow/secretpad/common/util/DateTimes.java
+++ b/easypsi-common/src/main/java/org/secretflow/easypsi/common/util/DateTimes.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.common.util;
+package org.secretflow.easypsi.common.util;
import org.apache.commons.lang3.ObjectUtils;
diff --git a/secretpad-common/src/main/java/org/secretflow/secretpad/common/util/FileUtils.java b/easypsi-common/src/main/java/org/secretflow/easypsi/common/util/FileUtils.java
similarity index 88%
rename from secretpad-common/src/main/java/org/secretflow/secretpad/common/util/FileUtils.java
rename to easypsi-common/src/main/java/org/secretflow/easypsi/common/util/FileUtils.java
index 7365f13..451c560 100644
--- a/secretpad-common/src/main/java/org/secretflow/secretpad/common/util/FileUtils.java
+++ b/easypsi-common/src/main/java/org/secretflow/easypsi/common/util/FileUtils.java
@@ -14,12 +14,12 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.common.util;
+package org.secretflow.easypsi.common.util;
-import org.secretflow.secretpad.common.dto.DownloadInfo;
-import org.secretflow.secretpad.common.errorcode.DataErrorCode;
-import org.secretflow.secretpad.common.errorcode.SystemErrorCode;
-import org.secretflow.secretpad.common.exception.SecretpadException;
+import org.secretflow.easypsi.common.dto.DownloadInfo;
+import org.secretflow.easypsi.common.errorcode.DataErrorCode;
+import org.secretflow.easypsi.common.errorcode.SystemErrorCode;
+import org.secretflow.easypsi.common.exception.EasyPsiException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -115,11 +115,9 @@ public static boolean deleteAllFile(String dir) {
File dirFile = new File(dir);
// If the file corresponding to dir does not exist or is not a directory, exit
if ((!dirFile.exists()) || (!dirFile.isDirectory())) {
-// LOGGER.info("Delete the directory failed:{} not exists", dir);
return false;
}
boolean flag = true;
- // Delete all files in the directory, including subDirectories
File[] files = dirFile.listFiles();
if (files != null) {
for (File file : files) {
@@ -140,12 +138,9 @@ else if (file.isDirectory()) {
}
}
if (!flag) {
-// LOGGER.info("Delete the directory failed!");
return false;
}
- // Delete current folder
if (dirFile.delete()) {
-// LOGGER.info("Delete the directory:{} Successfully!", dir);
return true;
} else {
return false;
@@ -225,7 +220,7 @@ public static DownloadInfo download(String filePath, String dir, String relative
}
if (!f.createNewFile()) {
LOGGER.error("failed to create empty file.");
- throw SecretpadException.of(SystemErrorCode.UNKNOWN_ERROR, "failed to create empty file for return.");
+ throw EasyPsiException.of(SystemErrorCode.UNKNOWN_ERROR, "failed to create empty file for return.");
}
}
String downloadFilePath = null;
@@ -250,10 +245,10 @@ public static DownloadInfo download(String filePath, String dir, String relative
.build();
} catch (IOException e) {
LOGGER.error("IO exception: {}", e.getMessage());
- throw SecretpadException.of(SystemErrorCode.UNKNOWN_ERROR, e);
+ throw EasyPsiException.of(SystemErrorCode.UNKNOWN_ERROR, e);
} catch (Exception e) {
LOGGER.error("got Exception: {}", e.getMessage());
- throw SecretpadException.of(SystemErrorCode.UNKNOWN_ERROR, e);
+ throw EasyPsiException.of(SystemErrorCode.UNKNOWN_ERROR, e);
}
}
@@ -264,14 +259,14 @@ public static void fileNameCheck(String fileName) {
public static void fileNameCheck(String fileName, String regex) {
if (ObjectUtils.isEmpty(fileName)) {
LOGGER.error("The user input fileName {} is empty!", fileName);
- throw SecretpadException.of(DataErrorCode.FILE_NAME_EMPTY);
+ throw EasyPsiException.of(DataErrorCode.FILE_NAME_EMPTY);
}
Pattern pattern = Pattern.compile(ObjectUtils.isEmpty(regex) ? FILE_NAME_REGEX : regex);
String prefixName = fileName.contains(".") ? fileName.substring(0, fileName.lastIndexOf('.')) : fileName;
if (!pattern.matcher(prefixName).matches()) {
LOGGER.error("The user input filName {} contains dangerous characters", fileName);
- throw SecretpadException.of(DataErrorCode.ILLEGAL_PARAMS_ERROR, fileName);
+ throw EasyPsiException.of(DataErrorCode.ILLEGAL_PARAMS_ERROR, fileName);
}
if (!fileName.contains(".")) {
@@ -281,18 +276,18 @@ public static void fileNameCheck(String fileName, String regex) {
String suffixName = fileName.substring(fileName.lastIndexOf('.'));
if (!SUPPORT_FILE_TYPE.contains(suffixName)) {
LOGGER.error("The user input fileName {} type {} not support yet.", fileName, suffixName);
- throw SecretpadException.of(DataErrorCode.FILE_TYPE_NOT_SUPPORT, suffixName);
+ throw EasyPsiException.of(DataErrorCode.FILE_TYPE_NOT_SUPPORT, suffixName);
}
}
public static void filePathCheck(String filePath) {
if (ObjectUtils.isEmpty(filePath)) {
LOGGER.error("The user input filePath {} is empty!", filePath);
- throw SecretpadException.of(DataErrorCode.FILE_PATH_EMPTY);
+ throw EasyPsiException.of(DataErrorCode.FILE_PATH_EMPTY);
}
if (!SUPPORT_FILE_PATH.contains(filePath)) {
LOGGER.error("The user input filPath {} not in whitelist ", filePath);
- throw SecretpadException.of(DataErrorCode.FILE_PATH_ERROR, filePath);
+ throw EasyPsiException.of(DataErrorCode.FILE_PATH_ERROR, filePath);
}
}
diff --git a/secretpad-common/src/main/java/org/secretflow/secretpad/common/util/JsonUtils.java b/easypsi-common/src/main/java/org/secretflow/easypsi/common/util/JsonUtils.java
similarity index 99%
rename from secretpad-common/src/main/java/org/secretflow/secretpad/common/util/JsonUtils.java
rename to easypsi-common/src/main/java/org/secretflow/easypsi/common/util/JsonUtils.java
index 5dada61..8b7037b 100644
--- a/secretpad-common/src/main/java/org/secretflow/secretpad/common/util/JsonUtils.java
+++ b/easypsi-common/src/main/java/org/secretflow/easypsi/common/util/JsonUtils.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.common.util;
+package org.secretflow.easypsi.common.util;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.JsonParser;
diff --git a/secretpad-common/src/main/java/org/secretflow/secretpad/common/util/KusciaRFC1123IdUtils.java b/easypsi-common/src/main/java/org/secretflow/easypsi/common/util/KusciaRFC1123IdUtils.java
similarity index 94%
rename from secretpad-common/src/main/java/org/secretflow/secretpad/common/util/KusciaRFC1123IdUtils.java
rename to easypsi-common/src/main/java/org/secretflow/easypsi/common/util/KusciaRFC1123IdUtils.java
index deee723..fa7d5dc 100644
--- a/secretpad-common/src/main/java/org/secretflow/secretpad/common/util/KusciaRFC1123IdUtils.java
+++ b/easypsi-common/src/main/java/org/secretflow/easypsi/common/util/KusciaRFC1123IdUtils.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.common.util;
+package org.secretflow.easypsi.common.util;
/**
* kuscia domainId domainDataId gen
diff --git a/secretpad-common/src/main/java/org/secretflow/secretpad/common/util/ProtoUtils.java b/easypsi-common/src/main/java/org/secretflow/easypsi/common/util/ProtoUtils.java
similarity index 99%
rename from secretpad-common/src/main/java/org/secretflow/secretpad/common/util/ProtoUtils.java
rename to easypsi-common/src/main/java/org/secretflow/easypsi/common/util/ProtoUtils.java
index 63e2b9f..4f38c5c 100644
--- a/secretpad-common/src/main/java/org/secretflow/secretpad/common/util/ProtoUtils.java
+++ b/easypsi-common/src/main/java/org/secretflow/easypsi/common/util/ProtoUtils.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.common.util;
+package org.secretflow.easypsi.common.util;
import com.google.protobuf.Descriptors;
import com.google.protobuf.InvalidProtocolBufferException;
diff --git a/secretpad-common/src/main/java/org/secretflow/secretpad/common/util/RestTemplateUtil.java b/easypsi-common/src/main/java/org/secretflow/easypsi/common/util/RestTemplateUtil.java
similarity index 97%
rename from secretpad-common/src/main/java/org/secretflow/secretpad/common/util/RestTemplateUtil.java
rename to easypsi-common/src/main/java/org/secretflow/easypsi/common/util/RestTemplateUtil.java
index e58b60e..2db99e6 100644
--- a/secretpad-common/src/main/java/org/secretflow/secretpad/common/util/RestTemplateUtil.java
+++ b/easypsi-common/src/main/java/org/secretflow/easypsi/common/util/RestTemplateUtil.java
@@ -1,4 +1,4 @@
-package org.secretflow.secretpad.common.util;
+package org.secretflow.easypsi.common.util;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpEntity;
diff --git a/easypsi-common/src/main/java/org/secretflow/easypsi/common/util/RsaUtils.java b/easypsi-common/src/main/java/org/secretflow/easypsi/common/util/RsaUtils.java
new file mode 100644
index 0000000..5da7229
--- /dev/null
+++ b/easypsi-common/src/main/java/org/secretflow/easypsi/common/util/RsaUtils.java
@@ -0,0 +1,107 @@
+/*
+ * Copyright 2023 Ant Group Co., Ltd.
+ *
+ * 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.
+ */
+
+package org.secretflow.easypsi.common.util;
+
+import javax.crypto.Cipher;
+import java.nio.charset.StandardCharsets;
+import java.security.KeyFactory;
+import java.security.KeyPair;
+import java.security.KeyPairGenerator;
+import java.security.interfaces.RSAPrivateKey;
+import java.security.interfaces.RSAPublicKey;
+import java.security.spec.PKCS8EncodedKeySpec;
+import java.security.spec.X509EncodedKeySpec;
+import java.util.Base64;
+import java.util.Map;
+
+/**
+ * Rsa utils
+ *
+ * @author lihaixin
+ * @date 2024/02/04
+ */
+public class RsaUtils {
+
+ private final static String ALGORITHM = "RSA";
+
+ private final static Integer KET_SIZE = 2048;
+
+
+ public final static String PUBLIC_KEY_NAME = "publicKey";
+
+ public final static String PRIVATE_KEY_NAME = "privateKey";
+
+ /**
+ * Generates a new RSA key pair.
+ *
+ * @return {@link Map }<{@link String }, {@link Object }>
+ */
+ public static Map generateRSAKeys() {
+ try {
+ KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance(ALGORITHM);
+ keyPairGenerator.initialize(KET_SIZE);
+ KeyPair keyPair = keyPairGenerator.generateKeyPair();
+ RSAPublicKey publicKey = (RSAPublicKey) keyPair.getPublic();
+ RSAPrivateKey privateKey = (RSAPrivateKey) keyPair.getPrivate();
+ return Map.of(PUBLIC_KEY_NAME, Base64.getEncoder().encodeToString(publicKey.getEncoded()), PRIVATE_KEY_NAME, Base64.getEncoder().encodeToString(privateKey.getEncoded()));
+ } catch (Exception e) {
+ throw new RuntimeException("Failed to generate RSA key pair", e);
+ }
+ }
+
+
+ /**
+ * RSA decrypt data
+ *
+ * @param encryptData
+ * @param privateKey
+ * @return {@link String }
+ */
+
+ public static String decrypt(String encryptData, String privateKey) {
+ try {
+ byte[] inputByte = Base64.getDecoder().decode(encryptData.getBytes(StandardCharsets.UTF_8));
+ byte[] decoded = Base64.getDecoder().decode(privateKey);
+ RSAPrivateKey priKey = (RSAPrivateKey) KeyFactory.getInstance(ALGORITHM).generatePrivate(new PKCS8EncodedKeySpec(decoded));
+ Cipher cipher = Cipher.getInstance(ALGORITHM);
+ cipher.init(Cipher.DECRYPT_MODE, priKey);
+ return new String(cipher.doFinal(inputByte));
+ } catch (Exception e) {
+ throw new RuntimeException("Failed to RSA decrypt", e);
+ }
+ }
+
+ /**
+ * RSA encrypt data
+ *
+ * @param sourceData
+ * @param publicKey
+ * @return {@link String }
+ */
+
+ public static String encrypt(String sourceData, String publicKey) {
+ try {
+ byte[] decoded = Base64.getDecoder().decode(publicKey);
+ RSAPublicKey pubKey = (RSAPublicKey) KeyFactory.getInstance(ALGORITHM).generatePublic(new X509EncodedKeySpec(decoded));
+ Cipher cipher = Cipher.getInstance(ALGORITHM);
+ cipher.init(Cipher.ENCRYPT_MODE, pubKey);
+ return Base64.getEncoder().encodeToString(cipher.doFinal(sourceData.getBytes(StandardCharsets.UTF_8)));
+ } catch (Exception e) {
+ throw new RuntimeException("Failed to RSA encrypt", e);
+ }
+ }
+}
\ No newline at end of file
diff --git a/secretpad-common/src/main/java/org/secretflow/secretpad/common/util/Sha256Utils.java b/easypsi-common/src/main/java/org/secretflow/easypsi/common/util/Sha256Utils.java
similarity index 98%
rename from secretpad-common/src/main/java/org/secretflow/secretpad/common/util/Sha256Utils.java
rename to easypsi-common/src/main/java/org/secretflow/easypsi/common/util/Sha256Utils.java
index 80f94ff..0155cab 100644
--- a/secretpad-common/src/main/java/org/secretflow/secretpad/common/util/Sha256Utils.java
+++ b/easypsi-common/src/main/java/org/secretflow/easypsi/common/util/Sha256Utils.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.common.util;
+package org.secretflow.easypsi.common.util;
import java.io.FileInputStream;
import java.io.IOException;
diff --git a/secretpad-common/src/main/java/org/secretflow/secretpad/common/util/UUIDUtils.java b/easypsi-common/src/main/java/org/secretflow/easypsi/common/util/UUIDUtils.java
similarity index 96%
rename from secretpad-common/src/main/java/org/secretflow/secretpad/common/util/UUIDUtils.java
rename to easypsi-common/src/main/java/org/secretflow/easypsi/common/util/UUIDUtils.java
index 9ead064..75f382e 100644
--- a/secretpad-common/src/main/java/org/secretflow/secretpad/common/util/UUIDUtils.java
+++ b/easypsi-common/src/main/java/org/secretflow/easypsi/common/util/UUIDUtils.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.common.util;
+package org.secretflow.easypsi.common.util;
import org.apache.commons.lang3.RandomStringUtils;
diff --git a/secretpad-common/src/main/java/org/secretflow/secretpad/common/util/UserContext.java b/easypsi-common/src/main/java/org/secretflow/easypsi/common/util/UserContext.java
similarity index 80%
rename from secretpad-common/src/main/java/org/secretflow/secretpad/common/util/UserContext.java
rename to easypsi-common/src/main/java/org/secretflow/easypsi/common/util/UserContext.java
index 4f17740..e0c1a2e 100644
--- a/secretpad-common/src/main/java/org/secretflow/secretpad/common/util/UserContext.java
+++ b/easypsi-common/src/main/java/org/secretflow/easypsi/common/util/UserContext.java
@@ -14,14 +14,14 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.common.util;
+package org.secretflow.easypsi.common.util;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
-import org.secretflow.secretpad.common.dto.UserContextDTO;
-import org.secretflow.secretpad.common.errorcode.AuthErrorCode;
-import org.secretflow.secretpad.common.exception.SecretpadException;
+import org.secretflow.easypsi.common.dto.UserContextDTO;
+import org.secretflow.easypsi.common.errorcode.AuthErrorCode;
+import org.secretflow.easypsi.common.exception.EasyPsiException;
/**
* @author yutu
@@ -43,7 +43,7 @@ public static String getUserName() {
public static UserContextDTO getUser() {
UserContextDTO userContextDTO = USER.get();
if (userContextDTO == null) {
- throw SecretpadException.of(AuthErrorCode.AUTH_FAILED, "auth failed");
+ throw EasyPsiException.of(AuthErrorCode.AUTH_FAILED, "auth failed");
}
return userContextDTO;
}
diff --git a/secretpad-common/src/main/resources/i18n/messages_en_US.properties b/easypsi-common/src/main/resources/i18n/messages_en_US.properties
similarity index 96%
rename from secretpad-common/src/main/resources/i18n/messages_en_US.properties
rename to easypsi-common/src/main/resources/i18n/messages_en_US.properties
index d6bef4e..d1512f6 100644
--- a/secretpad-common/src/main/resources/i18n/messages_en_US.properties
+++ b/easypsi-common/src/main/resources/i18n/messages_en_US.properties
@@ -48,6 +48,7 @@ auth.USER_PASSWORD_ERROR=Username or password error,remaining retry {0} attempts
auth.USER_IS_LOCKED=Login is locked, Please try again in {0} minutes
auth.RESET_PASSWORD_IS_LOCKED=The reset password function has been locked, please try again in {0} minutes
auth.AUTH_FAILED=Authentication user failed: {0}
+auth.PASSWORD_NOT_INITIALIZED=Please modify the initialization password
#user
user.USER_UPDATE_PASSWORD_ERROR_INCONSISTENT=The passwords entered twice are inconsistent
user.USER_UPDATE_PASSWORD_ERROR_SAME=The new and old passwords cannot be the same
@@ -64,6 +65,7 @@ project_job.PROJECT_JOB_ACTION_NOT_ALLOWED=The current status of the task is {0}
project_job.PROJECT_DATA_PATH_NOT_EXISTS_ERROR=The data table path does not exist
project_job.PROJECT_LOG_PATH_NOT_EXISTS_ERROR=The log path does not exist
project_job.PROJECT_JOB_RESULT_HASH_EXPIRED_ERROR=Download link has expired
+project_job.PROJECT_JOB_Config_ERROR=job config error: {0}
# data
data.FILE_NAME_EMPTY=File name is empty
data.FILE_TYPE_NOT_SUPPORT=File type is not support: {0}
diff --git a/secretpad-common/src/main/resources/i18n/messages_zh_CN.properties b/easypsi-common/src/main/resources/i18n/messages_zh_CN.properties
similarity index 97%
rename from secretpad-common/src/main/resources/i18n/messages_zh_CN.properties
rename to easypsi-common/src/main/resources/i18n/messages_zh_CN.properties
index 960ce60..3ed28e2 100644
--- a/secretpad-common/src/main/resources/i18n/messages_zh_CN.properties
+++ b/easypsi-common/src/main/resources/i18n/messages_zh_CN.properties
@@ -48,6 +48,7 @@ auth.USER_PASSWORD_ERROR=用户名或密码错误,剩余重试次数{0}次
auth.USER_IS_LOCKED=登录已被锁定,请{0}分钟后再试
auth.RESET_PASSWORD_IS_LOCKED=重置密码功能被锁定,请{0}分钟后再试
auth.AUTH_FAILED=用户认证失败: {0}
+auth.PASSWORD_NOT_INITIALIZED=请修改初始化密码
#user
user.USER_UPDATE_PASSWORD_ERROR_INCONSISTENT=两次输入的密码不一致
user.USER_UPDATE_PASSWORD_ERROR_SAME=新密码和旧密码不能相同
@@ -64,6 +65,7 @@ project_job.PROJECT_JOB_ACTION_NOT_ALLOWED=当前任务{0},不允许{1}操作
project_job.PROJECT_DATA_PATH_NOT_EXISTS_ERROR=数据表路径不存在
project_job.PROJECT_LOG_PATH_NOT_EXISTS_ERROR=日志路径不存在
project_job.PROJECT_JOB_RESULT_HASH_EXPIRED_ERROR=下载链接已失效
+project_job.PROJECT_JOB_Config_ERROR=job配置错误: {0}
# data
data.FILE_NAME_EMPTY=文件名为空
data.FILE_TYPE_NOT_SUPPORT=文件类型不支持: {0}
diff --git a/easypsi-common/src/test/java/org/secretflow/easypsi/common/util/CompressUtilsTest.java b/easypsi-common/src/test/java/org/secretflow/easypsi/common/util/CompressUtilsTest.java
new file mode 100644
index 0000000..f34d5f9
--- /dev/null
+++ b/easypsi-common/src/test/java/org/secretflow/easypsi/common/util/CompressUtilsTest.java
@@ -0,0 +1,167 @@
+/*
+ * Copyright 2024 Ant Group Co., Ltd.
+ *
+ * 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.
+ */
+
+package org.secretflow.easypsi.common.util;
+
+import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
+import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream;
+import org.apache.commons.compress.compressors.bzip2.BZip2CompressorOutputStream;
+import org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+import org.secretflow.easypsi.common.exception.EasyPsiException;
+import org.secretflow.easypsi.common.util.CompressUtils;
+
+import java.io.*;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.List;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+/**
+ * Compress Utils Test
+ *
+ * @author lihaixin
+ * @date 2024/03/07
+ */
+public class CompressUtilsTest {
+
+ @TempDir
+ Path tempDir;
+
+ private static final String FILE_CONTENT = "Hello, World!";
+
+ @BeforeEach
+ void setUp() throws IOException {
+
+ }
+
+ @Test
+ public void getFilesTest() throws Exception {
+ Files.createDirectories(tempDir.resolve("dir1/dir2"));
+ Files.writeString(tempDir.resolve("file1.txt"), FILE_CONTENT);
+ Files.writeString(tempDir.resolve("dir1/file2.txt"), FILE_CONTENT);
+ Files.writeString(tempDir.resolve("dir1/dir2/file3.txt"), FILE_CONTENT);
+ CompressUtils.getFiles(tempDir.toString());
+ }
+
+ @Test
+ public void packTest() throws IOException {
+ Files.createDirectories(tempDir.resolve("dir1/dir2"));
+ Files.writeString(tempDir.resolve("file1.txt"), FILE_CONTENT);
+ Files.writeString(tempDir.resolve("dir1/file2.txt"), FILE_CONTENT);
+ Files.writeString(tempDir.resolve("dir1/dir2/file3.txt"), FILE_CONTENT);
+ List fileList = CompressUtils.getFiles(tempDir.toAbsolutePath().toString());
+ File targetArchive = new File(tempDir.toString() + "/test_archive.tar"); //new File(tempDirPath).toPath().resolve("test_archive.tar").toFile()
+ CompressUtils.pack(fileList, tempDir.toString(), targetArchive);
+ }
+
+
+ @Test
+ public void compressTest() throws Exception {
+ Files.createDirectories(tempDir.resolve("dir1/dir2"));
+ Files.writeString(tempDir.resolve("file1.txt"), FILE_CONTENT);
+ Files.writeString(tempDir.resolve("dir1/file2.txt"), FILE_CONTENT);
+ Files.writeString(tempDir.resolve("dir1/dir2/file3.txt"), FILE_CONTENT);
+ CompressUtils.compress(tempDir.toString(), tempDir.toString(), "test.tar");
+ }
+
+ @Test
+ public void compressTarTest() throws Exception {
+ Files.createDirectories(tempDir.resolve("dir1/dir2"));
+ Files.writeString(tempDir.resolve("file1.txt"), FILE_CONTENT);
+ Files.writeString(tempDir.resolve("dir1/file2.txt"), FILE_CONTENT);
+ Files.writeString(tempDir.resolve("dir1/dir2/file3.txt"), FILE_CONTENT);
+ List fileList = CompressUtils.getFiles(tempDir.toAbsolutePath().toString());
+ CompressUtils.compressTar(fileList, tempDir.toString(), tempDir.toString(), "test.tar");
+ }
+
+ @Test
+ public void decompressTest() throws Exception {
+ Files.createDirectories(tempDir.resolve("dir1/dir2"));
+ Files.writeString(tempDir.resolve("file1.txt"), FILE_CONTENT);
+ Files.writeString(tempDir.resolve("dir1/file2.txt"), FILE_CONTENT);
+ Files.writeString(tempDir.resolve("dir1/dir2/file3.txt"), FILE_CONTENT);
+ Assertions.assertThrows(EasyPsiException.class, () -> CompressUtils.decompress(tempDir.toString(), tempDir.toString()));
+ }
+
+ @Test
+ public void unZipTest() throws Exception {
+ Files.writeString(tempDir.resolve("file1.txt"), FILE_CONTENT);
+ Path tempZipFile = tempDir.resolve("mocked.zip");
+ try (ZipOutputStream zos = new ZipOutputStream(Files.newOutputStream(tempZipFile))) {
+ ZipEntry entry1 = new ZipEntry("file1.txt");
+ zos.putNextEntry(entry1);
+ zos.write("This is file 1 in the ZIP".getBytes());
+ zos.closeEntry();
+ }
+ File mockZipFile = tempZipFile.toFile();
+ CompressUtils.unZip(mockZipFile, tempDir.toString());
+ }
+
+ @Test
+ public void decompressTarGzhTest() throws Exception {
+ File compressedTarFile = new File(tempDir.toFile(), "test.tar.gz");
+ try (FileOutputStream fos = new FileOutputStream(compressedTarFile);
+ GzipCompressorOutputStream gzos = new GzipCompressorOutputStream(fos);
+ TarArchiveOutputStream tao = new TarArchiveOutputStream(gzos)) {
+ TarArchiveEntry dirEntry = new TarArchiveEntry("dir1");
+ dirEntry.setSize(0);
+ dirEntry.setMode(TarArchiveEntry.DEFAULT_DIR_MODE);
+ tao.putArchiveEntry(dirEntry);
+ tao.closeArchiveEntry();
+ tao.finish();
+ }
+ String outputDirStr = tempDir.resolve("output").toString();
+ CompressUtils.decompressTarGz(compressedTarFile, outputDirStr);
+ }
+
+
+ @Test
+ public void decompressTarBz2Test() throws Exception {
+ File compressedTarFile = new File(tempDir.toFile(), "test.tar.bz2");
+ try (FileOutputStream fos = new FileOutputStream(compressedTarFile);
+ BZip2CompressorOutputStream bz2os = new BZip2CompressorOutputStream(fos);
+ TarArchiveOutputStream tao = new TarArchiveOutputStream(bz2os)) {
+ TarArchiveEntry dirEntry = new TarArchiveEntry("dir1");
+ dirEntry.setSize(0);
+ dirEntry.setMode(TarArchiveEntry.DEFAULT_DIR_MODE);
+ tao.putArchiveEntry(dirEntry);
+ tao.closeArchiveEntry();
+ tao.finish();
+ }
+ String outputDirStr = tempDir.resolve("output").toString();
+ CompressUtils.decompressTarBz2(compressedTarFile, outputDirStr);
+ }
+
+ @Test
+ public void writeFileTest() throws Exception {
+ InputStream in = new ByteArrayInputStream(FILE_CONTENT.getBytes());
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ CompressUtils.writeFile(in, out);
+ }
+
+
+ @Test
+ public void createDirectoryTest() throws Exception {
+ String outputDir = tempDir + "/directory1";
+ CompressUtils.createDirectory(outputDir, null);
+ }
+
+}
\ No newline at end of file
diff --git a/easypsi-common/src/test/java/org/secretflow/easypsi/common/util/ConstantsTest.java b/easypsi-common/src/test/java/org/secretflow/easypsi/common/util/ConstantsTest.java
new file mode 100644
index 0000000..cc72f4b
--- /dev/null
+++ b/easypsi-common/src/test/java/org/secretflow/easypsi/common/util/ConstantsTest.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2024 Ant Group Co., Ltd.
+ *
+ * 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.
+ */
+
+package org.secretflow.easypsi.common.util;
+
+import org.junit.jupiter.api.Test;
+import org.secretflow.easypsi.common.constant.CacheConstants;
+import org.secretflow.easypsi.common.constant.KusciaConstants;
+import org.secretflow.easypsi.common.constant.UserOwnerType;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+/**
+ * @author chenmingliang
+ * @date 2024/03/12
+ */
+public class ConstantsTest {
+
+ @Test
+ public void test() {
+ assertEquals("notls", KusciaConstants.KUSCIA_PROTOCOL_NOTLS);
+ assertEquals("tls", KusciaConstants.KUSCIA_PROTOCOL_TLS);
+ assertEquals("mtls", KusciaConstants.KUSCIA_PROTOCOL_MTLS);
+ assertEquals("user_lock", CacheConstants.USER_LOCK_CACHE);
+ }
+
+ @Test
+ public void testUserType() {
+ assertEquals("P2P", UserOwnerType.P2P.name());
+ assertEquals("CENTER", UserOwnerType.CENTER.name());
+ assertEquals("EDGE", UserOwnerType.EDGE.name());
+
+ }
+}
diff --git a/secretpad-common/src/test/java/org/secretflow/secretpad/common/util/DateTimesTest.java b/easypsi-common/src/test/java/org/secretflow/easypsi/common/util/DateTimesTest.java
similarity index 95%
rename from secretpad-common/src/test/java/org/secretflow/secretpad/common/util/DateTimesTest.java
rename to easypsi-common/src/test/java/org/secretflow/easypsi/common/util/DateTimesTest.java
index 53afc68..9a08bad 100644
--- a/secretpad-common/src/test/java/org/secretflow/secretpad/common/util/DateTimesTest.java
+++ b/easypsi-common/src/test/java/org/secretflow/easypsi/common/util/DateTimesTest.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.common.util;
+package org.secretflow.easypsi.common.util;
import org.junit.jupiter.api.Test;
diff --git a/secretpad-common/src/test/java/org/secretflow/secretpad/common/util/ErrorCodeTest.java b/easypsi-common/src/test/java/org/secretflow/easypsi/common/util/ErrorCodeTest.java
similarity index 94%
rename from secretpad-common/src/test/java/org/secretflow/secretpad/common/util/ErrorCodeTest.java
rename to easypsi-common/src/test/java/org/secretflow/easypsi/common/util/ErrorCodeTest.java
index 18e55fd..93427d2 100644
--- a/secretpad-common/src/test/java/org/secretflow/secretpad/common/util/ErrorCodeTest.java
+++ b/easypsi-common/src/test/java/org/secretflow/easypsi/common/util/ErrorCodeTest.java
@@ -1,6 +1,6 @@
-package org.secretflow.secretpad.common.util;
+package org.secretflow.easypsi.common.util;
-import org.secretflow.secretpad.common.errorcode.ErrorCode;
+import org.secretflow.easypsi.common.errorcode.ErrorCode;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.config.BeanDefinition;
@@ -34,7 +34,7 @@ public void checkErrorCodeIfRepeated() throws Exception {
ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(false);
provider.addIncludeFilter(new AssignableTypeFilter(ErrorCode.class));
// scan in error code package
- Set components = provider.findCandidateComponents("org.secretflow.secretpad.common.errorcode");
+ Set components = provider.findCandidateComponents("org.secretflow.easypsi.common.errorcode");
for (BeanDefinition component : components) {
Class> cls = Class.forName(component.getBeanClassName());
// class enum constants
@@ -60,7 +60,7 @@ public void checkErrorCodeIfExistInI18nFile() throws Exception {
ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(false);
provider.addIncludeFilter(new AssignableTypeFilter(ErrorCode.class));
// scan in error code package
- Set components = provider.findCandidateComponents("org.secretflow.secretpad.common.errorcode");
+ Set components = provider.findCandidateComponents("org.secretflow.easypsi.common.errorcode");
// US i18n file
ResourceBundle resourceBundleUS = ResourceBundle.getBundle("i18n.messages", Locale.US);
// CN i18n file
diff --git a/easypsi-common/src/test/java/org/secretflow/easypsi/common/util/FileUtilsTest.java b/easypsi-common/src/test/java/org/secretflow/easypsi/common/util/FileUtilsTest.java
new file mode 100644
index 0000000..200f6fd
--- /dev/null
+++ b/easypsi-common/src/test/java/org/secretflow/easypsi/common/util/FileUtilsTest.java
@@ -0,0 +1,112 @@
+/*
+ * Copyright 2024 Ant Group Co., Ltd.
+ *
+ * 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.
+ */
+
+package org.secretflow.easypsi.common.util;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+import org.secretflow.easypsi.common.exception.EasyPsiException;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.List;
+
+/**
+ * File Utils Test
+ *
+ * @author lihaixin
+ * @date 2024/03/08
+ */
+public class FileUtilsTest {
+
+ @TempDir
+ Path tempDir;
+
+ private static final String FILE_CONTENT = "Hello, World!";
+
+ @Test
+ public void readFileTest() throws IOException {
+ Path path = Files.writeString(tempDir.resolve("test.txt"), FILE_CONTENT);
+ FileUtils.readFile(path.toFile().getPath());
+ FileUtils.readFile2String(path.toFile().getPath());
+ FileUtils.readFile2String(path.toFile());
+ Assertions.assertThrows(FileNotFoundException.class, () -> FileUtils.readFile("invalid_path.txt"), "File not found ");
+ Assertions.assertThrows(FileNotFoundException.class, () -> FileUtils.readFile2String("invalid_path.txt"), "File not found ");
+ Assertions.assertThrows(FileNotFoundException.class, () -> FileUtils.readFile2String(new File("invalid_path.txt")), "File not found ");
+ }
+
+ @Test
+ public void deleteFileTest() throws IOException {
+ Files.writeString(tempDir.resolve("test.txt"), FILE_CONTENT);
+ FileUtils.deleteFile(tempDir.toString());
+ Files.writeString(tempDir.resolve("test.txt"), FILE_CONTENT);
+ FileUtils.deleteAllFile(tempDir.toString());
+ }
+
+ @Test
+ public void traverseDirectoriesTest() throws IOException {
+ Files.writeString(tempDir.resolve("test.txt"), FILE_CONTENT);
+ File directory = tempDir.toFile();
+ Assertions.assertTrue(directory.exists() && directory.isDirectory());
+ List filePaths = FileUtils.traverseDirectories(directory, ".txt", FileUtils.FILE_PATH);
+ Assertions.assertNotNull(filePaths);
+ Assertions.assertFalse(filePaths.isEmpty());
+ }
+
+ @Test
+ public void downloadTest() throws IOException {
+ String filePath = tempDir.resolve("test.csv").toString();
+ File realFile = new File(filePath);
+ realFile.createNewFile();
+ String dir = tempDir.toString();
+ String relativeUri = "data.csv";
+ FileUtils.download(filePath, dir, relativeUri);
+
+ }
+
+ @Test
+ public void fileNameCheckTest() {
+ // Valid case
+ FileUtils.fileNameCheck("valid_filename.csv");
+
+ // Empty filename check
+ Assertions.assertThrows(EasyPsiException.class, () -> FileUtils.fileNameCheck(""), "Expected exception for empty filename");
+
+ // Dangerous character check
+ Assertions.assertThrows(EasyPsiException.class, () -> FileUtils.fileNameCheck("invalid!filename.csv"), "Expected exception for dangerous characters");
+
+ // Unsupported file type check
+ Assertions.assertThrows(EasyPsiException.class, () -> FileUtils.fileNameCheck("file.name.xls"), "Expected exception for unsupported file type");
+
+ Assertions.assertThrows(EasyPsiException.class, () -> FileUtils.fileNameCheck("valid_filename.csv1"), "Expected exception for unsupported file type");
+
+ }
+ @Test
+ public void testFilePathCheck() {
+ // Valid case
+ FileUtils.filePathCheck("/app/data");
+
+ // Empty filepath check
+ Assertions.assertThrows(EasyPsiException.class, () -> FileUtils.filePathCheck(""), "Expected exception for empty filepath");
+
+ // Invalid filepath check
+ Assertions.assertThrows(EasyPsiException.class, () -> FileUtils.filePathCheck("/invalid/path"), "Expected exception for invalid filepath");
+ }
+}
diff --git a/secretpad-common/src/test/java/org/secretflow/secretpad/common/util/I18nTest.java b/easypsi-common/src/test/java/org/secretflow/easypsi/common/util/I18nTest.java
similarity index 95%
rename from secretpad-common/src/test/java/org/secretflow/secretpad/common/util/I18nTest.java
rename to easypsi-common/src/test/java/org/secretflow/easypsi/common/util/I18nTest.java
index ea6b435..48e11ed 100644
--- a/secretpad-common/src/test/java/org/secretflow/secretpad/common/util/I18nTest.java
+++ b/easypsi-common/src/test/java/org/secretflow/easypsi/common/util/I18nTest.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.common.util;
+package org.secretflow.easypsi.common.util;
import org.junit.jupiter.api.Test;
import org.springframework.context.support.ResourceBundleMessageSource;
diff --git a/secretpad-common/src/test/java/org/secretflow/secretpad/common/util/KusciaRFC1123IdUtilsTest.java b/easypsi-common/src/test/java/org/secretflow/easypsi/common/util/KusciaRFC1123IdUtilsTest.java
similarity index 94%
rename from secretpad-common/src/test/java/org/secretflow/secretpad/common/util/KusciaRFC1123IdUtilsTest.java
rename to easypsi-common/src/test/java/org/secretflow/easypsi/common/util/KusciaRFC1123IdUtilsTest.java
index 08d9c7a..50a9768 100644
--- a/secretpad-common/src/test/java/org/secretflow/secretpad/common/util/KusciaRFC1123IdUtilsTest.java
+++ b/easypsi-common/src/test/java/org/secretflow/easypsi/common/util/KusciaRFC1123IdUtilsTest.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.common.util;
+package org.secretflow.easypsi.common.util;
import org.junit.jupiter.api.Test;
diff --git a/secretpad-common/src/test/java/org/secretflow/secretpad/common/util/ProtoUtilsTest.java b/easypsi-common/src/test/java/org/secretflow/easypsi/common/util/ProtoUtilsTest.java
similarity index 96%
rename from secretpad-common/src/test/java/org/secretflow/secretpad/common/util/ProtoUtilsTest.java
rename to easypsi-common/src/test/java/org/secretflow/easypsi/common/util/ProtoUtilsTest.java
index 23fabc2..f7bab2d 100644
--- a/secretpad-common/src/test/java/org/secretflow/secretpad/common/util/ProtoUtilsTest.java
+++ b/easypsi-common/src/test/java/org/secretflow/easypsi/common/util/ProtoUtilsTest.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.common.util;
+package org.secretflow.easypsi.common.util;
import com.google.protobuf.Message;
import org.junit.jupiter.api.Test;
diff --git a/easypsi-common/src/test/java/org/secretflow/easypsi/common/util/RsaUtilsTest.java b/easypsi-common/src/test/java/org/secretflow/easypsi/common/util/RsaUtilsTest.java
new file mode 100644
index 0000000..e40b5fc
--- /dev/null
+++ b/easypsi-common/src/test/java/org/secretflow/easypsi/common/util/RsaUtilsTest.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2024 Ant Group Co., Ltd.
+ *
+ * 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.
+ */
+
+package org.secretflow.easypsi.common.util;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+import java.util.Map;
+
+class RsaUtilsTest {
+
+ @Test
+ public void testGenerateRSAKeys() {
+ Map keys = Assertions.assertDoesNotThrow(() -> RsaUtils.generateRSAKeys());
+ Assertions.assertNotNull(keys.get(RsaUtils.PUBLIC_KEY_NAME));
+ Assertions.assertNotNull(keys.get(RsaUtils.PRIVATE_KEY_NAME));
+
+ }
+
+ @Test
+ public void testEncryptAndDecrypt() throws Exception {
+ Map keys = RsaUtils.generateRSAKeys();
+ String publicKey = keys.get(RsaUtils.PUBLIC_KEY_NAME);
+ String privateKey = keys.get(RsaUtils.PRIVATE_KEY_NAME);
+ String sourceData = "This is a test message";
+ String encryptedData = RsaUtils.encrypt(sourceData, publicKey);
+ String decryptedData = RsaUtils.decrypt(encryptedData, privateKey);
+ Assertions.assertEquals(sourceData, decryptedData);
+ Assertions.assertThrows(RuntimeException.class, () -> RsaUtils.encrypt(sourceData, "invalid public key"), "Failed to RSA decrypt ");
+ Assertions.assertThrows(RuntimeException.class, () -> RsaUtils.decrypt("invalid enc data", privateKey), "Failed to RSA decrypt ");
+ }
+
+ @Test
+ public void testDecryptWithInvalidPrivateKey() {
+ String invalidPrivateKey = "invalid_private_key";
+ String encryptedData = "some_encrypted_data";
+ Throwable thrown = Assertions.assertThrows(RuntimeException.class, () -> RsaUtils.decrypt(encryptedData, invalidPrivateKey));
+ String expectedMessage = "Failed to RSA decrypt";
+ Assertions.assertTrue(thrown.getMessage().contains(expectedMessage));
+ }
+}
\ No newline at end of file
diff --git a/easypsi-common/src/test/java/org/secretflow/easypsi/common/util/UserContextTest.java b/easypsi-common/src/test/java/org/secretflow/easypsi/common/util/UserContextTest.java
new file mode 100644
index 0000000..b538211
--- /dev/null
+++ b/easypsi-common/src/test/java/org/secretflow/easypsi/common/util/UserContextTest.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2024 Ant Group Co., Ltd.
+ *
+ * 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.
+ */
+
+package org.secretflow.easypsi.common.util;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.secretflow.easypsi.common.dto.UserContextDTO;
+import org.secretflow.easypsi.common.errorcode.AuthErrorCode;
+import org.secretflow.easypsi.common.exception.EasyPsiException;
+
+/**
+ * User Context Test
+ *
+ * @author lihaixin
+ * @date 2024/03/08
+ */
+public class UserContextTest {
+
+ private UserContextDTO testUser;
+
+ @BeforeEach
+ public void setUp() {
+ testUser = new UserContextDTO();
+ testUser.setName("TestUser");
+ }
+
+ @AfterEach
+ public void tearDown() {
+ UserContext.remove();
+ }
+
+ @Test
+ public void testGetUserNameWhenSet() {
+ UserContext.setBaseUser(testUser);
+ Assertions.assertEquals("TestUser", UserContext.getUserName());
+ }
+
+ @Test
+ public void testGetUserNameWhenNotSet() {
+ Assertions.assertThrows(EasyPsiException.class, UserContext::getUserName, AuthErrorCode.AUTH_FAILED.toString());
+ }
+
+ @Test
+ public void testSetAndGetUser() {
+ UserContext.setBaseUser(testUser);
+ UserContextDTO retrievedUser = UserContext.getUser();
+ Assertions.assertEquals(testUser.getName(), retrievedUser.getName());
+ }
+
+ @Test
+ public void testRemoveUser() {
+ UserContext.setBaseUser(testUser);
+ UserContext.remove();
+ Assertions.assertThrows(EasyPsiException.class, UserContext::getUser, AuthErrorCode.AUTH_FAILED.toString());
+ }
+}
\ No newline at end of file
diff --git a/secretpad-manager/pom.xml b/easypsi-manager/pom.xml
similarity index 64%
rename from secretpad-manager/pom.xml
rename to easypsi-manager/pom.xml
index e59ac17..e698e8b 100644
--- a/secretpad-manager/pom.xml
+++ b/easypsi-manager/pom.xml
@@ -19,19 +19,19 @@
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- secretpad-parent
+ easypsi-parent
org.secretflow
0.0.1-SNAPSHOT
../pom.xml
4.0.0
- secretpad-manager
+ easypsi-manager
org.secretflow
- secretpad-common
+ easypsi-common
org.secretflow
@@ -43,7 +43,7 @@
org.secretflow
- secretpad-persistence
+ easypsi-persistence
org.apache.commons
@@ -54,4 +54,29 @@
fabric-gateway
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+ true
+
+
+
+ org.jacoco
+ jacoco-maven-plugin
+
+
+ report-aggregate
+ test
+
+ report-aggregate
+
+
+
+
+
+
\ No newline at end of file
diff --git a/easypsi-manager/src/main/java/org/secretflow/easypsi/manager/configuration/AsyncConfig.java b/easypsi-manager/src/main/java/org/secretflow/easypsi/manager/configuration/AsyncConfig.java
new file mode 100644
index 0000000..f6f85e3
--- /dev/null
+++ b/easypsi-manager/src/main/java/org/secretflow/easypsi/manager/configuration/AsyncConfig.java
@@ -0,0 +1,28 @@
+package org.secretflow.easypsi.manager.configuration;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.annotation.EnableAsync;
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
+
+import java.util.concurrent.Executor;
+/**
+ * Async config
+ *
+ * @author chixian
+ * @date 2024/1/31
+ */
+@Configuration
+@EnableAsync
+public class AsyncConfig {
+
+ @Bean(name = "asyncExecutor")
+ public Executor asyncExecutor() {
+ ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
+ executor.setCorePoolSize(5);
+ executor.setMaxPoolSize(10);
+ executor.setQueueCapacity(10);
+ executor.initialize();
+ return executor;
+ }
+}
\ No newline at end of file
diff --git a/secretpad-manager/src/main/java/org/secretflow/secretpad/manager/configuration/KusciaAPIConfiguration.java b/easypsi-manager/src/main/java/org/secretflow/easypsi/manager/configuration/KusciaAPIConfiguration.java
similarity index 71%
rename from secretpad-manager/src/main/java/org/secretflow/secretpad/manager/configuration/KusciaAPIConfiguration.java
rename to easypsi-manager/src/main/java/org/secretflow/easypsi/manager/configuration/KusciaAPIConfiguration.java
index 3ee8780..6cfc970 100644
--- a/secretpad-manager/src/main/java/org/secretflow/secretpad/manager/configuration/KusciaAPIConfiguration.java
+++ b/easypsi-manager/src/main/java/org/secretflow/easypsi/manager/configuration/KusciaAPIConfiguration.java
@@ -14,9 +14,9 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.manager.configuration;
+package org.secretflow.easypsi.manager.configuration;
-import org.secretflow.secretpad.manager.properties.KusciaAPIProperties;
+import org.secretflow.easypsi.manager.properties.KusciaAPIProperties;
import org.secretflow.v1alpha1.factory.KusciaAPIChannelFactory;
import org.secretflow.v1alpha1.kusciaapi.*;
@@ -42,7 +42,7 @@ public class KusciaAPIConfiguration {
*/
@Bean
KusciaAPIChannelFactory apiLiteChannelFactory(KusciaAPIProperties properties) {
- return new KusciaAPIChannelFactory(properties.getAddress(), properties.getTokenFile(), properties.getTls());
+ return new KusciaAPIChannelFactory(properties.getAddress(), properties.getTokenFile(), properties.getTls(), properties.getProtocol());
}
/**
@@ -80,24 +80,5 @@ DomainRouteServiceGrpc.DomainRouteServiceBlockingStub domainRouteServiceStub(Kus
return DomainRouteServiceGrpc.newBlockingStub(channelFactory.newClientChannel());
}
- /**
- * Create a new domain data service blocking stub via apiLite channel factory
- *
- * @param channelFactory
- * @return a new domain data service blocking stub
- */
- @Bean
- DomainDataServiceGrpc.DomainDataServiceBlockingStub domainDataServiceStub(KusciaAPIChannelFactory channelFactory) {
- return DomainDataServiceGrpc.newBlockingStub(channelFactory.newClientChannel())
- .withMaxInboundMessageSize(Integer.MAX_VALUE)
- .withMaxOutboundMessageSize(Integer.MAX_VALUE);
- }
-
- @Bean
- DomainDataGrantServiceGrpc.DomainDataGrantServiceBlockingStub dataGrantStub(KusciaAPIChannelFactory channelFactory) {
- return DomainDataGrantServiceGrpc.newBlockingStub(channelFactory.newClientChannel())
- .withMaxInboundMessageSize(Integer.MAX_VALUE)
- .withMaxOutboundMessageSize(Integer.MAX_VALUE);
- }
}
diff --git a/secretpad-manager/src/main/java/org/secretflow/secretpad/manager/configuration/ManagerConfiguration.java b/easypsi-manager/src/main/java/org/secretflow/easypsi/manager/configuration/ManagerConfiguration.java
similarity index 82%
rename from secretpad-manager/src/main/java/org/secretflow/secretpad/manager/configuration/ManagerConfiguration.java
rename to easypsi-manager/src/main/java/org/secretflow/easypsi/manager/configuration/ManagerConfiguration.java
index 8def997..b47092d 100644
--- a/secretpad-manager/src/main/java/org/secretflow/secretpad/manager/configuration/ManagerConfiguration.java
+++ b/easypsi-manager/src/main/java/org/secretflow/easypsi/manager/configuration/ManagerConfiguration.java
@@ -14,11 +14,11 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.manager.configuration;
+package org.secretflow.easypsi.manager.configuration;
-import org.secretflow.secretpad.manager.integration.job.AbstractJobManager;
-import org.secretflow.secretpad.manager.integration.job.JobManager;
-import org.secretflow.secretpad.persistence.repository.ProjectJobRepository;
+import org.secretflow.easypsi.manager.integration.job.AbstractJobManager;
+import org.secretflow.easypsi.manager.integration.job.JobManager;
+import org.secretflow.easypsi.persistence.repository.ProjectJobRepository;
import org.secretflow.v1alpha1.kusciaapi.JobServiceGrpc;
import org.springframework.context.annotation.Bean;
diff --git a/easypsi-manager/src/main/java/org/secretflow/easypsi/manager/integration/data/AbstractDataManager.java b/easypsi-manager/src/main/java/org/secretflow/easypsi/manager/integration/data/AbstractDataManager.java
new file mode 100644
index 0000000..61bf961
--- /dev/null
+++ b/easypsi-manager/src/main/java/org/secretflow/easypsi/manager/integration/data/AbstractDataManager.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2023 Ant Group Co., Ltd.
+ *
+ * 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.
+ */
+package org.secretflow.easypsi.manager.integration.data;
+
+import java.util.concurrent.Future;
+
+/**
+ * @author liujunhao
+ * @date 2024/01/30
+ */
+public abstract class AbstractDataManager {
+
+ /**
+ * calculate the number of file lines
+ * @param filePath
+ * @param fileName
+ * @return
+ */
+ public abstract Future countLinesByCommand(String filePath, String fileName);
+}
diff --git a/easypsi-manager/src/main/java/org/secretflow/easypsi/manager/integration/data/DataManager.java b/easypsi-manager/src/main/java/org/secretflow/easypsi/manager/integration/data/DataManager.java
new file mode 100644
index 0000000..74b84f9
--- /dev/null
+++ b/easypsi-manager/src/main/java/org/secretflow/easypsi/manager/integration/data/DataManager.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2023 Ant Group Co., Ltd.
+ *
+ * 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.
+ */
+package org.secretflow.easypsi.manager.integration.data;
+
+import org.apache.commons.lang3.ObjectUtils;
+import org.secretflow.easypsi.common.errorcode.DataErrorCode;
+import org.secretflow.easypsi.common.exception.EasyPsiException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.scheduling.annotation.AsyncResult;
+import org.springframework.stereotype.Service;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.concurrent.Future;
+
+/**
+ * @author liujunhao
+ * @date 2024/01/30
+ */
+@Service
+public class DataManager extends AbstractDataManager {
+
+ private final static Logger LOGGER = LoggerFactory.getLogger(DataManager.class);
+
+ @Override
+ @Async("asyncExecutor")
+ public Future countLinesByCommand(String filePath, String fileName) {
+ BufferedReader reader = null;
+ try {
+ Process process = new ProcessBuilder("awk", "NR == 100000001 { print \"100000001\"; exit } END { if (NR < 100000001) print NR } ", filePath).start();
+
+ reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
+ return new AsyncResult<>(reader.readLine());
+
+ } catch (IOException e) {
+ LOGGER.error("data table read error, data table: {}", fileName);
+ throw EasyPsiException.of(DataErrorCode.QUERY_DATA_ERROR, fileName);
+ } finally {
+ if (!ObjectUtils.isEmpty(reader)) {
+ try {
+ reader.close();
+ } catch (IOException e) {
+ LOGGER.error("Close stream error", e);
+ }
+ }
+ }
+ }
+}
diff --git a/secretpad-manager/src/main/java/org/secretflow/secretpad/manager/integration/fabric/FabricManager.java b/easypsi-manager/src/main/java/org/secretflow/easypsi/manager/integration/fabric/FabricManager.java
similarity index 90%
rename from secretpad-manager/src/main/java/org/secretflow/secretpad/manager/integration/fabric/FabricManager.java
rename to easypsi-manager/src/main/java/org/secretflow/easypsi/manager/integration/fabric/FabricManager.java
index 851a037..54bbead 100644
--- a/secretpad-manager/src/main/java/org/secretflow/secretpad/manager/integration/fabric/FabricManager.java
+++ b/easypsi-manager/src/main/java/org/secretflow/easypsi/manager/integration/fabric/FabricManager.java
@@ -14,20 +14,19 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.manager.integration.fabric;
-
-import org.secretflow.secretpad.manager.properties.FabricAPIProperties;
-import org.secretflow.secretpad.persistence.entity.FabricLogDO;
+package org.secretflow.easypsi.manager.integration.fabric;
import io.grpc.Grpc;
import io.grpc.ManagedChannel;
import io.grpc.TlsChannelCredentials;
+import jakarta.annotation.PostConstruct;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.hyperledger.fabric.client.*;
import org.hyperledger.fabric.client.identity.*;
-import org.springframework.beans.factory.annotation.Autowired;
+import org.secretflow.easypsi.manager.properties.FabricAPIProperties;
+import org.secretflow.easypsi.persistence.entity.FabricLogDO;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
@@ -55,11 +54,22 @@
public class FabricManager {
- public final String READ_ASSET = "ReadAsset";
+ public String READ_ASSET = "ReadAsset";
+
+
+ private final FabricAPIProperties fabricAPIProperties;
- @Autowired
- private FabricAPIProperties fabricAPIProperties;
+ @PostConstruct
+ public void validateFile() {
+ try {
+ if (fabricAPIProperties.getIsOpen()) {
+ newContract();
+ }
+ } catch (Exception e) {
+ throw new IllegalStateException(e.getMessage());
+ }
+ }
/**
diff --git a/secretpad-manager/src/main/java/org/secretflow/secretpad/manager/integration/job/AbstractJobManager.java b/easypsi-manager/src/main/java/org/secretflow/easypsi/manager/integration/job/AbstractJobManager.java
similarity index 89%
rename from secretpad-manager/src/main/java/org/secretflow/secretpad/manager/integration/job/AbstractJobManager.java
rename to easypsi-manager/src/main/java/org/secretflow/easypsi/manager/integration/job/AbstractJobManager.java
index ffbd3ff..b48baa9 100644
--- a/secretpad-manager/src/main/java/org/secretflow/secretpad/manager/integration/job/AbstractJobManager.java
+++ b/easypsi-manager/src/main/java/org/secretflow/easypsi/manager/integration/job/AbstractJobManager.java
@@ -14,10 +14,10 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.manager.integration.job;
+package org.secretflow.easypsi.manager.integration.job;
-import org.secretflow.secretpad.persistence.entity.ProjectJobDO;
+import org.secretflow.easypsi.persistence.entity.ProjectJobDO;
import org.secretflow.v1alpha1.kusciaapi.Job;
diff --git a/secretpad-manager/src/main/java/org/secretflow/secretpad/manager/integration/job/JobManager.java b/easypsi-manager/src/main/java/org/secretflow/easypsi/manager/integration/job/JobManager.java
similarity index 79%
rename from secretpad-manager/src/main/java/org/secretflow/secretpad/manager/integration/job/JobManager.java
rename to easypsi-manager/src/main/java/org/secretflow/easypsi/manager/integration/job/JobManager.java
index 560ee2e..ad89814 100644
--- a/secretpad-manager/src/main/java/org/secretflow/secretpad/manager/integration/job/JobManager.java
+++ b/easypsi-manager/src/main/java/org/secretflow/easypsi/manager/integration/job/JobManager.java
@@ -14,26 +14,24 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.manager.integration.job;
-
-import org.secretflow.secretpad.common.errorcode.JobErrorCode;
-import org.secretflow.secretpad.common.exception.SecretpadException;
-import org.secretflow.secretpad.common.util.DateTimes;
-import org.secretflow.secretpad.common.util.FileUtils;
-import org.secretflow.secretpad.common.util.JsonUtils;
-import org.secretflow.secretpad.common.util.Sha256Utils;
-import org.secretflow.secretpad.manager.integration.fabric.FabricManager;
-import org.secretflow.secretpad.persistence.entity.FabricLogDO;
-import org.secretflow.secretpad.persistence.entity.ProjectJobDO;
-import org.secretflow.secretpad.persistence.model.GraphJobStatus;
-import org.secretflow.secretpad.persistence.repository.FabricLogRepository;
-import org.secretflow.secretpad.persistence.repository.ProjectJobRepository;
+package org.secretflow.easypsi.manager.integration.job;
import com.google.common.base.Strings;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
-import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import org.secretflow.easypsi.common.errorcode.JobErrorCode;
+import org.secretflow.easypsi.common.exception.EasyPsiException;
+import org.secretflow.easypsi.common.util.DateTimes;
+import org.secretflow.easypsi.common.util.FileUtils;
+import org.secretflow.easypsi.common.util.JsonUtils;
+import org.secretflow.easypsi.common.util.Sha256Utils;
+import org.secretflow.easypsi.manager.integration.fabric.FabricManager;
+import org.secretflow.easypsi.persistence.entity.FabricLogDO;
+import org.secretflow.easypsi.persistence.entity.ProjectJobDO;
+import org.secretflow.easypsi.persistence.model.GraphJobStatus;
+import org.secretflow.easypsi.persistence.repository.FabricLogRepository;
+import org.secretflow.easypsi.persistence.repository.ProjectJobRepository;
import org.secretflow.v1alpha1.common.Common;
import org.secretflow.v1alpha1.kusciaapi.Job;
import org.secretflow.v1alpha1.kusciaapi.JobServiceGrpc;
@@ -46,7 +44,6 @@
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
-import javax.annotation.Nonnull;
import java.io.File;
import java.io.FilenameFilter;
import java.util.Iterator;
@@ -56,7 +53,7 @@
import java.util.concurrent.Future;
import java.util.stream.Collectors;
-import static org.secretflow.secretpad.manager.integration.model.Constants.SUCCESS_STATUS_MESSAGE;
+import static org.secretflow.easypsi.manager.integration.model.Constants.SUCCESS_STATUS_MESSAGE;
/**
* Manager job operation
@@ -67,7 +64,6 @@
@Slf4j
public class JobManager extends AbstractJobManager {
- private final static String PARTY_STATUS_FAILED = "Failed";
private final static Logger LOGGER = LoggerFactory.getLogger(JobManager.class);
private final ProjectJobRepository projectJobRepository;
@@ -83,7 +79,7 @@ public class JobManager extends AbstractJobManager {
@Autowired
private FabricLogRepository fabricLogRepository;
- @Value("${secretpad.node-id}")
+ @Value("${easypsi.node-id}")
private String nodeId;
public JobManager(ProjectJobRepository projectJobRepository,
@@ -92,7 +88,7 @@ public JobManager(ProjectJobRepository projectJobRepository,
this.jobStub = jobStub;
}
- @Value("${secretpad.data.dir-path:/app/data/}")
+ @Value("${easypsi.data.dir-path:/app/data/}")
private String storeDir;
public static final String CSV_DATA_PATH = File.separator + "app" + File.separator + "data";
@@ -123,7 +119,7 @@ public JobManager(ProjectJobRepository projectJobRepository,
@Override
public void startSync() {
try {
- Iterator responses = jobStub.watchJob(Job.WatchJobRequest.newBuilder().build());
+ Iterator responses = jobStub.watchJob(Job.WatchJobRequest.newBuilder().setTimeoutSeconds(30).build());
LOGGER.info("starter jobEvent ... ");
responses.forEachRemaining(this::syncJob);
} catch (Exception e) {
@@ -253,12 +249,6 @@ private String buildTmpDirPath(String jobId) {
*/
public ProjectJobDO updateJob(Job.WatchJobEventResponse it, ProjectJobDO projectJob) {
switch (it.getType()) {
-// case DELETED:
-// // if projectJob status is not PAUSED, stop the job
-// if (!projectJob.getStatus().equals(GraphJobStatus.PAUSED) && !projectJob.getStatus().equals(GraphJobStatus.FAILED)) {
-// projectJob.stop(it.getObject().getStatus().getErrMsg());
-// }
-// return projectJob;
case ADDED:
case MODIFIED:
Job.JobStatusDetail kusciaJobStatus = it.getObject().getStatus();
@@ -287,43 +277,18 @@ private boolean isFinishedState(String state) {
return "Succeeded".equals(state);
}
- /**
- * Catch task failed party reason via task status
- *
- * @param kusciaTaskStatus
- * @return task failed party reasons
- */
- @NotNull
- private List catchTaskFailedPartyReason(@NotNull Job.TaskStatus kusciaTaskStatus) {
- return kusciaTaskStatus.getPartiesList().stream().filter(pt -> PARTY_STATUS_FAILED.equals(pt.getState())).map(
- pt -> String.format("party %s failed msg: %s", pt.getDomainId(), pt.getErrMsg())
- ).collect(Collectors.toList());
- }
-
- /**
- * Catch task failed party reason via task status
- *
- * @param kusciaTaskStatus
- * @return task failed party reasons
- */
- private List taskFailedReason(@Nonnull Job.TaskStatus kusciaTaskStatus) {
- List reasons = catchTaskFailedPartyReason(kusciaTaskStatus);
- reasons.add(kusciaTaskStatus.getErrMsg());
- return reasons;
- }
-
@Override
public void createJob(Job.CreateJobRequest request) {
LOGGER.info("create kuscia job request ={}", request);
Job.CreateJobResponse response = jobStub.createJob(request);
if (!response.hasStatus()) {
- throw SecretpadException.of(JobErrorCode.PROJECT_JOB_CREATE_ERROR);
+ throw EasyPsiException.of(JobErrorCode.PROJECT_JOB_CREATE_ERROR);
}
Common.Status status = response.getStatus();
String message = status.getMessage();
LOGGER.info("create kuscia job response ={}", response);
if (status.getCode() != 0 || (!StringUtils.isEmpty(message) && !SUCCESS_STATUS_MESSAGE.equalsIgnoreCase(message))) {
- throw SecretpadException.of(JobErrorCode.PROJECT_JOB_CREATE_ERROR, status.getMessage());
+ throw EasyPsiException.of(JobErrorCode.PROJECT_JOB_CREATE_ERROR, status.getMessage());
}
}
@@ -333,4 +298,5 @@ public Future openProjectJob(String jobId) {
Optional jobOpt = projectJobRepository.findByJobId(jobId);
return new AsyncResult<>(jobOpt.get());
}
-}
+
+}
\ No newline at end of file
diff --git a/secretpad-manager/src/main/java/org/secretflow/secretpad/manager/integration/model/Constants.java b/easypsi-manager/src/main/java/org/secretflow/easypsi/manager/integration/model/Constants.java
similarity index 92%
rename from secretpad-manager/src/main/java/org/secretflow/secretpad/manager/integration/model/Constants.java
rename to easypsi-manager/src/main/java/org/secretflow/easypsi/manager/integration/model/Constants.java
index 29c8d61..4aa1f27 100644
--- a/secretpad-manager/src/main/java/org/secretflow/secretpad/manager/integration/model/Constants.java
+++ b/easypsi-manager/src/main/java/org/secretflow/easypsi/manager/integration/model/Constants.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.manager.integration.model;
+package org.secretflow.easypsi.manager.integration.model;
/**
* Constants
diff --git a/secretpad-manager/src/main/java/org/secretflow/secretpad/manager/integration/model/CreateNodeParam.java b/easypsi-manager/src/main/java/org/secretflow/easypsi/manager/integration/model/CreateNodeParam.java
similarity index 92%
rename from secretpad-manager/src/main/java/org/secretflow/secretpad/manager/integration/model/CreateNodeParam.java
rename to easypsi-manager/src/main/java/org/secretflow/easypsi/manager/integration/model/CreateNodeParam.java
index daef31f..aa53a56 100644
--- a/secretpad-manager/src/main/java/org/secretflow/secretpad/manager/integration/model/CreateNodeParam.java
+++ b/easypsi-manager/src/main/java/org/secretflow/easypsi/manager/integration/model/CreateNodeParam.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.manager.integration.model;
+package org.secretflow.easypsi.manager.integration.model;
import lombok.Builder;
import lombok.Data;
@@ -68,4 +68,9 @@ public class CreateNodeParam {
* node Remark
*/
private String nodeRemark;
+
+ /**
+ * trust
+ */
+ private Boolean trust;
}
diff --git a/secretpad-manager/src/main/java/org/secretflow/secretpad/manager/integration/model/CreateNodeRouteParam.java b/easypsi-manager/src/main/java/org/secretflow/easypsi/manager/integration/model/CreateNodeRouteParam.java
similarity index 85%
rename from secretpad-manager/src/main/java/org/secretflow/secretpad/manager/integration/model/CreateNodeRouteParam.java
rename to easypsi-manager/src/main/java/org/secretflow/easypsi/manager/integration/model/CreateNodeRouteParam.java
index e032827..23530bf 100644
--- a/secretpad-manager/src/main/java/org/secretflow/secretpad/manager/integration/model/CreateNodeRouteParam.java
+++ b/easypsi-manager/src/main/java/org/secretflow/easypsi/manager/integration/model/CreateNodeRouteParam.java
@@ -14,12 +14,12 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.manager.integration.model;
+package org.secretflow.easypsi.manager.integration.model;
import lombok.Builder;
import lombok.Data;
-import static org.secretflow.secretpad.common.constant.DomainRouterConstants.DomainRouterTypeEnum;
+import static org.secretflow.easypsi.common.constant.DomainRouterConstants.DomainRouterTypeEnum;
/**
* @author yutu
diff --git a/secretpad-manager/src/main/java/org/secretflow/secretpad/manager/integration/model/NodeCertificateDTO.java b/easypsi-manager/src/main/java/org/secretflow/easypsi/manager/integration/model/NodeCertificateDTO.java
similarity index 93%
rename from secretpad-manager/src/main/java/org/secretflow/secretpad/manager/integration/model/NodeCertificateDTO.java
rename to easypsi-manager/src/main/java/org/secretflow/easypsi/manager/integration/model/NodeCertificateDTO.java
index 2c20de4..7413b3e 100644
--- a/secretpad-manager/src/main/java/org/secretflow/secretpad/manager/integration/model/NodeCertificateDTO.java
+++ b/easypsi-manager/src/main/java/org/secretflow/easypsi/manager/integration/model/NodeCertificateDTO.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.manager.integration.model;
+package org.secretflow.easypsi.manager.integration.model;
import lombok.*;
diff --git a/secretpad-manager/src/main/java/org/secretflow/secretpad/manager/integration/model/NodeDTO.java b/easypsi-manager/src/main/java/org/secretflow/easypsi/manager/integration/model/NodeDTO.java
similarity index 90%
rename from secretpad-manager/src/main/java/org/secretflow/secretpad/manager/integration/model/NodeDTO.java
rename to easypsi-manager/src/main/java/org/secretflow/easypsi/manager/integration/model/NodeDTO.java
index d3562d2..37da5c0 100644
--- a/secretpad-manager/src/main/java/org/secretflow/secretpad/manager/integration/model/NodeDTO.java
+++ b/easypsi-manager/src/main/java/org/secretflow/easypsi/manager/integration/model/NodeDTO.java
@@ -14,10 +14,10 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.manager.integration.model;
+package org.secretflow.easypsi.manager.integration.model;
-import org.secretflow.secretpad.common.util.DateTimes;
-import org.secretflow.secretpad.persistence.entity.NodeDO;
+import org.secretflow.easypsi.common.util.DateTimes;
+import org.secretflow.easypsi.persistence.entity.NodeDO;
import lombok.*;
@@ -61,6 +61,7 @@ public class NodeDTO {
private String gmtModified;
private String certText;
private String nodeRemark;
+ private Boolean trust;
/**
* Convert NodeDO to NodeDTO
@@ -83,6 +84,7 @@ public static NodeDTO fromDo(NodeDO nodeDO) {
nodeDTO.setNodeName(nodeDO.getName());
nodeDTO.setCertText(nodeDO.getCertText());
nodeDTO.setNodeRemark(nodeDO.getNodeRemark());
+ nodeDTO.setTrust(nodeDO.getTrust());
return nodeDTO;
}
diff --git a/secretpad-manager/src/main/java/org/secretflow/secretpad/manager/integration/model/NodeRouteDTO.java b/easypsi-manager/src/main/java/org/secretflow/easypsi/manager/integration/model/NodeRouteDTO.java
similarity index 89%
rename from secretpad-manager/src/main/java/org/secretflow/secretpad/manager/integration/model/NodeRouteDTO.java
rename to easypsi-manager/src/main/java/org/secretflow/easypsi/manager/integration/model/NodeRouteDTO.java
index d91249c..03bd3de 100644
--- a/secretpad-manager/src/main/java/org/secretflow/secretpad/manager/integration/model/NodeRouteDTO.java
+++ b/easypsi-manager/src/main/java/org/secretflow/easypsi/manager/integration/model/NodeRouteDTO.java
@@ -14,10 +14,10 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.manager.integration.model;
+package org.secretflow.easypsi.manager.integration.model;
-import org.secretflow.secretpad.common.constant.DomainRouterConstants;
-import org.secretflow.secretpad.persistence.entity.NodeRouteDO;
+import org.secretflow.easypsi.common.constant.DomainRouterConstants;
+import org.secretflow.easypsi.persistence.entity.NodeRouteDO;
import lombok.Builder;
import lombok.Getter;
diff --git a/easypsi-manager/src/main/java/org/secretflow/easypsi/manager/integration/model/UpdateNodeParam.java b/easypsi-manager/src/main/java/org/secretflow/easypsi/manager/integration/model/UpdateNodeParam.java
new file mode 100644
index 0000000..34e62f7
--- /dev/null
+++ b/easypsi-manager/src/main/java/org/secretflow/easypsi/manager/integration/model/UpdateNodeParam.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2023 Ant Group Co., Ltd.
+ *
+ * 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.
+ */
+package org.secretflow.easypsi.manager.integration.model;
+
+import lombok.*;
+
+/**
+ * @author chixian
+ * @date 2024/02/27
+ */
+@Builder
+@Setter
+@Getter
+@NoArgsConstructor
+@AllArgsConstructor
+public class UpdateNodeParam {
+ private String nodeId;
+ private Boolean trust;
+}
diff --git a/secretpad-manager/src/main/java/org/secretflow/secretpad/manager/integration/model/UpdateNodeRouteParam.java b/easypsi-manager/src/main/java/org/secretflow/easypsi/manager/integration/model/UpdateNodeRouteParam.java
similarity index 93%
rename from secretpad-manager/src/main/java/org/secretflow/secretpad/manager/integration/model/UpdateNodeRouteParam.java
rename to easypsi-manager/src/main/java/org/secretflow/easypsi/manager/integration/model/UpdateNodeRouteParam.java
index c0aba90..696f1e5 100644
--- a/secretpad-manager/src/main/java/org/secretflow/secretpad/manager/integration/model/UpdateNodeRouteParam.java
+++ b/easypsi-manager/src/main/java/org/secretflow/easypsi/manager/integration/model/UpdateNodeRouteParam.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.manager.integration.model;
+package org.secretflow.easypsi.manager.integration.model;
import lombok.Builder;
import lombok.Data;
diff --git a/secretpad-manager/src/main/java/org/secretflow/secretpad/manager/integration/node/AbstractNodeManager.java b/easypsi-manager/src/main/java/org/secretflow/easypsi/manager/integration/node/AbstractNodeManager.java
similarity index 73%
rename from secretpad-manager/src/main/java/org/secretflow/secretpad/manager/integration/node/AbstractNodeManager.java
rename to easypsi-manager/src/main/java/org/secretflow/easypsi/manager/integration/node/AbstractNodeManager.java
index 570ca3a..cd8e45c 100644
--- a/secretpad-manager/src/main/java/org/secretflow/secretpad/manager/integration/node/AbstractNodeManager.java
+++ b/easypsi-manager/src/main/java/org/secretflow/easypsi/manager/integration/node/AbstractNodeManager.java
@@ -14,12 +14,13 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.manager.integration.node;
-
-import org.secretflow.secretpad.manager.integration.model.CreateNodeParam;
-import org.secretflow.secretpad.manager.integration.model.NodeCertificateDTO;
-import org.secretflow.secretpad.manager.integration.model.NodeDTO;
+package org.secretflow.easypsi.manager.integration.node;
+import org.secretflow.easypsi.manager.integration.model.CreateNodeParam;
+import org.secretflow.easypsi.manager.integration.model.NodeCertificateDTO;
+import org.secretflow.easypsi.manager.integration.model.NodeDTO;
+import org.secretflow.easypsi.manager.integration.model.UpdateNodeParam;
+import org.secretflow.easypsi.persistence.entity.NodeDO;
import org.secretflow.v1alpha1.kusciaapi.Domain;
/**
@@ -36,6 +37,14 @@ public abstract class AbstractNodeManager {
*/
public abstract String createNode(CreateNodeParam param);
+ /**
+ * Update node
+ *
+ * @param param update parma
+ * @return nodeId
+ */
+ public abstract NodeDO updateNode(UpdateNodeParam param);
+
/**
* Delete node
*
@@ -82,7 +91,12 @@ public abstract class AbstractNodeManager {
/**
* check node cert
*/
- public abstract void checkNodeCert(String nodeId,CreateNodeParam request);
+ public abstract void checkNodeCert(String cert);
+
+ /**
+ * check node id
+ */
+ public abstract void checkNodeId(String srcNodeId,String dstNodeId);
/**
* check node status
diff --git a/secretpad-manager/src/main/java/org/secretflow/secretpad/manager/integration/node/NodeManager.java b/easypsi-manager/src/main/java/org/secretflow/easypsi/manager/integration/node/NodeManager.java
similarity index 76%
rename from secretpad-manager/src/main/java/org/secretflow/secretpad/manager/integration/node/NodeManager.java
rename to easypsi-manager/src/main/java/org/secretflow/easypsi/manager/integration/node/NodeManager.java
index 659eeba..9ff4303 100644
--- a/secretpad-manager/src/main/java/org/secretflow/secretpad/manager/integration/node/NodeManager.java
+++ b/easypsi-manager/src/main/java/org/secretflow/easypsi/manager/integration/node/NodeManager.java
@@ -14,21 +14,22 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.manager.integration.node;
-
-import org.secretflow.secretpad.common.constant.DomainConstants;
-import org.secretflow.secretpad.common.dto.UserContextDTO;
-import org.secretflow.secretpad.common.errorcode.NodeErrorCode;
-import org.secretflow.secretpad.common.exception.SecretpadException;
-import org.secretflow.secretpad.common.util.UUIDUtils;
-import org.secretflow.secretpad.common.util.UserContext;
-import org.secretflow.secretpad.manager.integration.model.CreateNodeParam;
-import org.secretflow.secretpad.manager.integration.model.NodeCertificateDTO;
-import org.secretflow.secretpad.manager.integration.model.NodeDTO;
-import org.secretflow.secretpad.manager.kuscia.grpc.KusciaDomainRpc;
-import org.secretflow.secretpad.persistence.entity.NodeDO;
-import org.secretflow.secretpad.persistence.model.GraphJobStatus;
-import org.secretflow.secretpad.persistence.repository.NodeRepository;
+package org.secretflow.easypsi.manager.integration.node;
+
+import org.secretflow.easypsi.common.constant.DomainConstants;
+import org.secretflow.easypsi.common.dto.UserContextDTO;
+import org.secretflow.easypsi.common.errorcode.NodeErrorCode;
+import org.secretflow.easypsi.common.exception.EasyPsiException;
+import org.secretflow.easypsi.common.util.UUIDUtils;
+import org.secretflow.easypsi.common.util.UserContext;
+import org.secretflow.easypsi.manager.integration.model.CreateNodeParam;
+import org.secretflow.easypsi.manager.integration.model.NodeCertificateDTO;
+import org.secretflow.easypsi.manager.integration.model.NodeDTO;
+import org.secretflow.easypsi.manager.integration.model.UpdateNodeParam;
+import org.secretflow.easypsi.manager.kuscia.grpc.KusciaDomainRpc;
+import org.secretflow.easypsi.persistence.entity.NodeDO;
+import org.secretflow.easypsi.persistence.model.GraphJobStatus;
+import org.secretflow.easypsi.persistence.repository.NodeRepository;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@@ -72,10 +73,17 @@ public boolean checkNodeStatus(String nodeId) {
}
@Override
- public void checkNodeCert(String nodeId, CreateNodeParam request) {
- boolean exists = nodeRepository.existsById(request.getNodeId());
- if (exists || ObjectUtils.isEmpty(request.getCertText()) || getCert(nodeId).equals(request.getCertText()) || nodeId.equals(request.getNodeId())) {
- throw SecretpadException.of(NodeErrorCode.NODE_CERT_CONFIG_ERROR, "");
+ public void checkNodeCert(String certText) {
+ if (ObjectUtils.isEmpty(certText)) {
+ throw EasyPsiException.of(NodeErrorCode.NODE_CERT_CONFIG_ERROR, "");
+ }
+ }
+
+ @Override
+ public void checkNodeId(String srcNodeId, String dstNodeId) {
+ boolean exists = nodeRepository.existsById(dstNodeId);
+ if (ObjectUtils.isEmpty(dstNodeId) || exists || getCert(srcNodeId).equals(dstNodeId) || srcNodeId.equals(dstNodeId)) {
+ throw EasyPsiException.of(NodeErrorCode.NODE_CERT_CONFIG_ERROR, "");
}
}
@@ -94,7 +102,8 @@ public String createNode(CreateNodeParam param) {
.netAddress(param.getNetAddress())
.certText(param.getCertText())
.nodeRemark(param.getNodeRemark())
- .name(param.getName()).build();
+ .name(param.getName())
+ .trust(param.getTrust()).build();
nodeRepository.save(nodeDO);
Domain.CreateDomainRequest request = Domain.CreateDomainRequest.newBuilder().setDomainId(nodeId)
@@ -110,11 +119,18 @@ public String createNode(CreateNodeParam param) {
domain = kusciaDomainRpc.createDomain(request);
} catch (Exception e) {
LOGGER.error(nodeId + " node create fail in kuscia :" + domain.getStatus().getMessage());
- throw SecretpadException.of(NodeErrorCode.NODE_CREATE_ERROR, nodeId + " node create fail in kuscia :" + domain.getStatus().getMessage());
+ throw EasyPsiException.of(NodeErrorCode.NODE_CREATE_ERROR, nodeId + " node create fail in kuscia :" + domain.getStatus().getMessage());
}
return nodeId;
}
+ @Override
+ public NodeDO updateNode(UpdateNodeParam param) {
+ NodeDO byNodeId = nodeRepository.findByNodeId(param.getNodeId());
+ byNodeId.setTrust(param.getTrust());
+ return nodeRepository.save(byNodeId);
+ }
+
@Override
public void deleteNode(String nodeId) {
log.info("check node exits running tasks");
@@ -131,7 +147,7 @@ public void deleteNode(String nodeId) {
try {
deleteDomainResponse = kusciaDomainRpc.deleteDomain(request);
} catch (Exception e) {
- throw SecretpadException.of(NodeErrorCode.NODE_DELETE_ERROR, nodeId + " kuscia delete node fail :" + deleteDomainResponse.getStatus().getMessage());
+ throw EasyPsiException.of(NodeErrorCode.NODE_DELETE_ERROR, nodeId + " kuscia delete node fail :" + deleteDomainResponse.getStatus().getMessage());
}
}
@@ -140,7 +156,7 @@ public NodeDTO getNode(String nodeId) {
NodeDO nodeDO = nodeRepository.findByNodeId(nodeId);
if (ObjectUtils.isEmpty(nodeDO)) {
LOGGER.error("Cannot find node by nodeId {}.", nodeId);
- throw SecretpadException.of(NodeErrorCode.NODE_NOT_EXIST_ERROR);
+ throw EasyPsiException.of(NodeErrorCode.NODE_NOT_EXIST_ERROR);
}
Domain.QueryDomainRequest request = Domain.QueryDomainRequest.newBuilder().setDomainId(nodeId).build();
Domain.QueryDomainResponse response = null;
@@ -195,7 +211,7 @@ public NodeCertificateDTO getNodeCertificate(String nodeId) {
NodeDO nodeDO = nodeRepository.findByNodeId(nodeId);
if (ObjectUtils.isEmpty(nodeDO)) {
LOGGER.error("Cannot find node by nodeId {}.", nodeId);
- throw SecretpadException.of(NodeErrorCode.NODE_NOT_EXIST_ERROR);
+ throw EasyPsiException.of(NodeErrorCode.NODE_NOT_EXIST_ERROR);
}
NodeCertificateDTO nodeCertificateDTO = new NodeCertificateDTO();
nodeCertificateDTO.setNodeId(nodeDO.getNodeId());
@@ -218,15 +234,14 @@ public void initialNode(String nodeId) {
}
-
- private Domain.QueryDomainResponse queryNode(String nodeId) {
+ public Domain.QueryDomainResponse queryNode(String nodeId) {
Domain.QueryDomainRequest request = Domain.QueryDomainRequest.newBuilder()
.setDomainId(nodeId)
.build();
Domain.QueryDomainResponse response =
domainServiceBlockingStub.queryDomain(request);
if (ObjectUtils.isEmpty(response)) {
- throw SecretpadException.of(NodeErrorCode.NODE_NOT_EXIST_ERROR, nodeId + ":query node error,node not exits");
+ throw EasyPsiException.of(NodeErrorCode.NODE_NOT_EXIST_ERROR, nodeId + ":query node error,node not exits");
}
return response;
}
@@ -235,7 +250,7 @@ protected String genDomainId() {
return UUIDUtils.random(8);
}
- private boolean getNodeStatus(Domain.QueryDomainResponse response){
+ private boolean getNodeStatus(Domain.QueryDomainResponse response) {
return (ObjectUtils.isEmpty(response) || response.getStatus().getCode() != 0);
}
diff --git a/secretpad-manager/src/main/java/org/secretflow/secretpad/manager/integration/noderoute/AbstractNodeRouteManager.java b/easypsi-manager/src/main/java/org/secretflow/easypsi/manager/integration/noderoute/AbstractNodeRouteManager.java
similarity index 82%
rename from secretpad-manager/src/main/java/org/secretflow/secretpad/manager/integration/noderoute/AbstractNodeRouteManager.java
rename to easypsi-manager/src/main/java/org/secretflow/easypsi/manager/integration/noderoute/AbstractNodeRouteManager.java
index 0488890..6672a0d 100644
--- a/secretpad-manager/src/main/java/org/secretflow/secretpad/manager/integration/noderoute/AbstractNodeRouteManager.java
+++ b/easypsi-manager/src/main/java/org/secretflow/easypsi/manager/integration/noderoute/AbstractNodeRouteManager.java
@@ -14,11 +14,11 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.manager.integration.noderoute;
+package org.secretflow.easypsi.manager.integration.noderoute;
-import org.secretflow.secretpad.manager.integration.model.CreateNodeRouteParam;
-import org.secretflow.secretpad.manager.integration.model.UpdateNodeRouteParam;
-import org.secretflow.secretpad.persistence.entity.NodeDO;
+import org.secretflow.easypsi.manager.integration.model.CreateNodeRouteParam;
+import org.secretflow.easypsi.manager.integration.model.UpdateNodeRouteParam;
+import org.secretflow.easypsi.persistence.entity.NodeDO;
import org.secretflow.v1alpha1.kusciaapi.DomainRoute;
/**
diff --git a/secretpad-manager/src/main/java/org/secretflow/secretpad/manager/integration/noderoute/NodeRouteManager.java b/easypsi-manager/src/main/java/org/secretflow/easypsi/manager/integration/noderoute/NodeRouteManager.java
similarity index 82%
rename from secretpad-manager/src/main/java/org/secretflow/secretpad/manager/integration/noderoute/NodeRouteManager.java
rename to easypsi-manager/src/main/java/org/secretflow/easypsi/manager/integration/noderoute/NodeRouteManager.java
index b06b2f2..4b5cbf6 100644
--- a/secretpad-manager/src/main/java/org/secretflow/secretpad/manager/integration/noderoute/NodeRouteManager.java
+++ b/easypsi-manager/src/main/java/org/secretflow/easypsi/manager/integration/noderoute/NodeRouteManager.java
@@ -14,24 +14,23 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.manager.integration.noderoute;
-
-import org.secretflow.secretpad.common.constant.DomainRouterConstants;
-import org.secretflow.secretpad.common.errorcode.NodeRouteErrorCode;
-import org.secretflow.secretpad.common.exception.SecretpadException;
-import org.secretflow.secretpad.manager.integration.model.CreateNodeRouteParam;
-import org.secretflow.secretpad.manager.integration.model.UpdateNodeRouteParam;
-import org.secretflow.secretpad.persistence.entity.NodeDO;
-import org.secretflow.secretpad.persistence.entity.NodeRouteDO;
-import org.secretflow.secretpad.persistence.repository.NodeRepository;
-import org.secretflow.secretpad.persistence.repository.NodeRouteRepository;
+package org.secretflow.easypsi.manager.integration.noderoute;
+import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
+import org.secretflow.easypsi.common.constant.DomainRouterConstants;
+import org.secretflow.easypsi.common.errorcode.NodeRouteErrorCode;
+import org.secretflow.easypsi.common.exception.EasyPsiException;
+import org.secretflow.easypsi.manager.integration.model.CreateNodeRouteParam;
+import org.secretflow.easypsi.manager.integration.model.UpdateNodeRouteParam;
+import org.secretflow.easypsi.persistence.entity.NodeDO;
+import org.secretflow.easypsi.persistence.entity.NodeRouteDO;
+import org.secretflow.easypsi.persistence.repository.NodeRepository;
+import org.secretflow.easypsi.persistence.repository.NodeRouteRepository;
import org.secretflow.v1alpha1.kusciaapi.DomainRoute;
import org.secretflow.v1alpha1.kusciaapi.DomainRouteServiceGrpc;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -45,15 +44,15 @@
* @date 2023/08/07
*/
@Slf4j
+@RequiredArgsConstructor
@Service
public class NodeRouteManager extends AbstractNodeRouteManager {
- @Autowired
- private NodeRouteRepository nodeRouteRepository;
- @Autowired
- private NodeRepository nodeRepository;
- @Autowired
- private DomainRouteServiceGrpc.DomainRouteServiceBlockingStub routeServiceBlockingStub;
+ private final NodeRouteRepository nodeRouteRepository;
+
+ private final NodeRepository nodeRepository;
+
+ private final DomainRouteServiceGrpc.DomainRouteServiceBlockingStub routeServiceBlockingStub;
@Override
@Transactional(rollbackFor = Exception.class)
@@ -94,7 +93,7 @@ private void createNodeRouteNotInDb(NodeDO srcNode, NodeDO dstNode) {
if (createDomainRouteResponse.getStatus().getCode() != 0) {
log.error("Create node router failed, code = {}, msg = {}", createDomainRouteResponse.getStatus().getCode(),
createDomainRouteResponse.getStatus().getMessage());
- throw SecretpadException.of(NodeRouteErrorCode.NODE_ROUTE_CREATE_ERROR, srcNode.getNodeId() + "->" + dstNode.getNodeId() + " create node router failed in kuscia :" + createDomainRouteResponse.getStatus().getMessage());
+ throw EasyPsiException.of(NodeRouteErrorCode.NODE_ROUTE_CREATE_ERROR, srcNode.getNodeId() + "->" + dstNode.getNodeId() + " create node router failed in kuscia :" + createDomainRouteResponse.getStatus().getMessage());
}
}
@@ -111,7 +110,7 @@ public Long createNodeRoute(CreateNodeRouteParam param, NodeDO srcNode, NodeDO d
nodeRouteDO = NodeRouteDO.builder().srcNodeId(srcNode.getNodeId()).dstNodeId(dstNode.getNodeId()).build();
} else {
nodeRouteDO = optionalNodeRouteDO.get();
- nodeRouteRepository.updateGmtModified(nodeRouteDO.getSrcNodeId(),nodeRouteDO.getDstNodeId());
+ nodeRouteRepository.updateGmtModified(nodeRouteDO.getSrcNodeId(), nodeRouteDO.getDstNodeId());
}
nodeRouteDO.setSrcNetAddress(param.getSrcNetAddress());
nodeRouteDO.setDstNetAddress(param.getDstNetAddress());
@@ -127,10 +126,10 @@ public void deleteNodeRoute(Long nodeRouteId) {
@Transactional(rollbackFor = Exception.class)
public void deleteNodeRoute(NodeRouteDO nodeRouteDO) {
- deleteDomainRouter(nodeRouteDO);
if (ObjectUtils.isEmpty(nodeRouteDO)) {
- throw SecretpadException.of(NodeRouteErrorCode.NODE_ROUTE_NOT_EXIST_ERROR, "node router do not exit ");
+ throw EasyPsiException.of(NodeRouteErrorCode.NODE_ROUTE_NOT_EXIST_ERROR, "node router do not exit ");
}
+ deleteDomainRouter(nodeRouteDO);
nodeRouteRepository.deleteById(nodeRouteDO.getId());
}
@@ -138,7 +137,7 @@ public void deleteNodeRoute(NodeRouteDO nodeRouteDO) {
public void updateNodeRoute(UpdateNodeRouteParam param) {
NodeRouteDO nodeRouteDO = nodeRouteRepository.findByRouteId(param.getNodeRouteId());
if (ObjectUtils.isEmpty(nodeRouteDO)) {
- throw SecretpadException.of(NodeRouteErrorCode.NODE_ROUTE_NOT_EXIST_ERROR,
+ throw EasyPsiException.of(NodeRouteErrorCode.NODE_ROUTE_NOT_EXIST_ERROR,
"route not exist " + param.getNodeRouteId());
}
if (nodeRouteDO.getDstNetAddress().equals(param.getDstNetAddress())) {
@@ -156,14 +155,14 @@ public void updateNodeRoute(UpdateNodeRouteParam param) {
public DomainRoute.RouteStatus getRouteStatus(String srcNodeId, String dstNodeId) {
DomainRoute.RouteStatus status = null;
DomainRoute.QueryDomainRouteResponse response = queryDomainRouter(srcNodeId, dstNodeId);
+ if (ObjectUtils.isEmpty(response)) {
+ throw EasyPsiException.of(NodeRouteErrorCode.NODE_ROUTE_NOT_EXIST_ERROR,
+ "route not exist in kuscia" + srcNodeId + "->" + dstNodeId);
+ }
log.info("DomainRoute.RouteStatus response {}", response);
if (response.getStatus().getCode() == 0) {
status = response.getData().getStatus();
}
- if (ObjectUtils.isEmpty(response)) {
- throw SecretpadException.of(NodeRouteErrorCode.NODE_ROUTE_NOT_EXIST_ERROR,
- "route not exist in kuscia" + srcNodeId + "->" + dstNodeId);
- }
return status;
}
@@ -204,9 +203,9 @@ private DomainRoute.RouteEndpoint buildRouteEndpoint(NodeDO dstNode) {
return DomainRoute.RouteEndpoint.newBuilder().setHost(host).addPorts(endpointPort).build();
}
- private void checkNode(NodeDO node) {
+ public void checkNode(NodeDO node) {
if (ObjectUtils.isEmpty(node)) {
- throw SecretpadException.of(NodeRouteErrorCode.NODE_ROUTE_CREATE_ERROR, "node do not exit");
+ throw EasyPsiException.of(NodeRouteErrorCode.NODE_ROUTE_CREATE_ERROR, "node do not exit");
}
}
@@ -237,7 +236,7 @@ private void deleteDomainRouter(NodeRouteDO nodeRouteDO) {
return;
}
if (response.getStatus().getCode() != 0) {
- throw SecretpadException.of(NodeRouteErrorCode.NODE_ROUTE_DELETE_ERROR, nodeRouteDO.getSrcNodeId() + "->" + nodeRouteDO.getDstNodeId() + " node route delete fail in kuscia :" + response.getStatus().getMessage());
+ throw EasyPsiException.of(NodeRouteErrorCode.NODE_ROUTE_DELETE_ERROR, nodeRouteDO.getSrcNodeId() + "->" + nodeRouteDO.getDstNodeId() + " node route delete fail in kuscia :" + response.getStatus().getMessage());
}
}
@@ -249,7 +248,7 @@ private boolean routeExist(String srcNodeId, String dstNodeId) {
private void checkRouteExist(String srcNodeId, String dstNodeId) {
if (routeExist(srcNodeId, dstNodeId)) {
- throw SecretpadException.of(NodeRouteErrorCode.NODE_ROUTE_ALREADY_EXISTS,
+ throw EasyPsiException.of(NodeRouteErrorCode.NODE_ROUTE_ALREADY_EXISTS,
"route exist " + srcNodeId + "->" + dstNodeId);
}
}
@@ -257,7 +256,7 @@ private void checkRouteExist(String srcNodeId, String dstNodeId) {
@Override
public void checkRouteNotExist(String srcNodeId, String dstNodeId) {
if (!routeExist(srcNodeId, dstNodeId)) {
- throw SecretpadException.of(NodeRouteErrorCode.NODE_ROUTE_NOT_EXIST_ERROR,
+ throw EasyPsiException.of(NodeRouteErrorCode.NODE_ROUTE_NOT_EXIST_ERROR,
"route not exist " + srcNodeId + "->" + dstNodeId);
}
}
diff --git a/secretpad-manager/src/main/java/org/secretflow/secretpad/manager/kuscia/grpc/KusciaDomainRpc.java b/easypsi-manager/src/main/java/org/secretflow/easypsi/manager/kuscia/grpc/KusciaDomainRpc.java
similarity index 94%
rename from secretpad-manager/src/main/java/org/secretflow/secretpad/manager/kuscia/grpc/KusciaDomainRpc.java
rename to easypsi-manager/src/main/java/org/secretflow/easypsi/manager/kuscia/grpc/KusciaDomainRpc.java
index 3501fe8..73cc772 100644
--- a/secretpad-manager/src/main/java/org/secretflow/secretpad/manager/kuscia/grpc/KusciaDomainRpc.java
+++ b/easypsi-manager/src/main/java/org/secretflow/easypsi/manager/kuscia/grpc/KusciaDomainRpc.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.manager.kuscia.grpc;
+package org.secretflow.easypsi.manager.kuscia.grpc;
import org.secretflow.v1alpha1.kusciaapi.Domain;
diff --git a/easypsi-manager/src/main/java/org/secretflow/easypsi/manager/kuscia/grpc/KusciaJobRpc.java b/easypsi-manager/src/main/java/org/secretflow/easypsi/manager/kuscia/grpc/KusciaJobRpc.java
new file mode 100644
index 0000000..3903152
--- /dev/null
+++ b/easypsi-manager/src/main/java/org/secretflow/easypsi/manager/kuscia/grpc/KusciaJobRpc.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2023 Ant Group Co., Ltd.
+ *
+ * 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.
+ */
+package org.secretflow.easypsi.manager.kuscia.grpc;
+
+import org.secretflow.v1alpha1.kusciaapi.Job;
+
+/**
+ * @author chixian
+ * @date 2024/02/19
+ */
+public interface KusciaJobRpc {
+
+ Job.QueryJobResponse queryJob(Job.QueryJobRequest request);
+
+ Job.ApproveJobResponse approveJob(Job.ApproveJobRequest request);
+}
diff --git a/secretpad-manager/src/main/java/org/secretflow/secretpad/manager/kuscia/grpc/KusciaRpc.java b/easypsi-manager/src/main/java/org/secretflow/easypsi/manager/kuscia/grpc/KusciaRpc.java
similarity index 74%
rename from secretpad-manager/src/main/java/org/secretflow/secretpad/manager/kuscia/grpc/KusciaRpc.java
rename to easypsi-manager/src/main/java/org/secretflow/easypsi/manager/kuscia/grpc/KusciaRpc.java
index 42d6b69..f3db1ca 100644
--- a/secretpad-manager/src/main/java/org/secretflow/secretpad/manager/kuscia/grpc/KusciaRpc.java
+++ b/easypsi-manager/src/main/java/org/secretflow/easypsi/manager/kuscia/grpc/KusciaRpc.java
@@ -14,10 +14,10 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.manager.kuscia.grpc;
+package org.secretflow.easypsi.manager.kuscia.grpc;
-import org.secretflow.secretpad.common.errorcode.KusciaGrpcErrorCode;
-import org.secretflow.secretpad.common.exception.SecretpadException;
+import org.secretflow.easypsi.common.errorcode.KusciaGrpcErrorCode;
+import org.secretflow.easypsi.common.exception.EasyPsiException;
import org.secretflow.v1alpha1.common.Common;
@@ -28,7 +28,7 @@
public interface KusciaRpc {
default void checkResponse(Common.Status status) {
if (status.getCode() != 0) {
- throw SecretpadException.of(KusciaGrpcErrorCode.RPC_ERROR, status.getMessage());
+ throw EasyPsiException.of(KusciaGrpcErrorCode.RPC_ERROR, status.getMessage());
}
}
diff --git a/secretpad-manager/src/main/java/org/secretflow/secretpad/manager/kuscia/grpc/impl/KusciaDomainRpcImpl.java b/easypsi-manager/src/main/java/org/secretflow/easypsi/manager/kuscia/grpc/impl/KusciaDomainRpcImpl.java
similarity index 94%
rename from secretpad-manager/src/main/java/org/secretflow/secretpad/manager/kuscia/grpc/impl/KusciaDomainRpcImpl.java
rename to easypsi-manager/src/main/java/org/secretflow/easypsi/manager/kuscia/grpc/impl/KusciaDomainRpcImpl.java
index cf758b5..d5f44ad 100644
--- a/secretpad-manager/src/main/java/org/secretflow/secretpad/manager/kuscia/grpc/impl/KusciaDomainRpcImpl.java
+++ b/easypsi-manager/src/main/java/org/secretflow/easypsi/manager/kuscia/grpc/impl/KusciaDomainRpcImpl.java
@@ -14,9 +14,9 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.manager.kuscia.grpc.impl;
+package org.secretflow.easypsi.manager.kuscia.grpc.impl;
-import org.secretflow.secretpad.manager.kuscia.grpc.KusciaDomainRpc;
+import org.secretflow.easypsi.manager.kuscia.grpc.KusciaDomainRpc;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
diff --git a/easypsi-manager/src/main/java/org/secretflow/easypsi/manager/kuscia/grpc/impl/KusciaJobRpcImpl.java b/easypsi-manager/src/main/java/org/secretflow/easypsi/manager/kuscia/grpc/impl/KusciaJobRpcImpl.java
new file mode 100644
index 0000000..a3f64e7
--- /dev/null
+++ b/easypsi-manager/src/main/java/org/secretflow/easypsi/manager/kuscia/grpc/impl/KusciaJobRpcImpl.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2023 Ant Group Co., Ltd.
+ *
+ * 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.
+ */
+package org.secretflow.easypsi.manager.kuscia.grpc.impl;
+
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.secretflow.easypsi.manager.kuscia.grpc.KusciaJobRpc;
+import org.secretflow.v1alpha1.kusciaapi.Job;
+import org.secretflow.v1alpha1.kusciaapi.JobServiceGrpc;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author chixian
+ * @date 2024/02/19
+ */
+@Slf4j
+@Service
+@RequiredArgsConstructor
+public class KusciaJobRpcImpl implements KusciaJobRpc {
+
+ private final JobServiceGrpc.JobServiceBlockingStub jobServiceStub;
+
+ @Override
+ public Job.QueryJobResponse queryJob(Job.QueryJobRequest request) {
+ log.info("JobServiceGrpc queryJob request {}", request);
+ Job.QueryJobResponse response = jobServiceStub.queryJob(request);
+ log.info("JobServiceGrpc queryJob response {}", response);
+ return response;
+ }
+
+ @Override
+ public Job.ApproveJobResponse approveJob(Job.ApproveJobRequest request) {
+ log.info("JobServiceGrpc approveJob request {}", request);
+ Job.ApproveJobResponse response = jobServiceStub.approveJob(request);
+ log.info("JobServiceGrpc approveJob response {}", response);
+ return response;
+ }
+
+}
diff --git a/secretpad-manager/src/main/java/org/secretflow/secretpad/manager/properties/FabricAPIProperties.java b/easypsi-manager/src/main/java/org/secretflow/easypsi/manager/properties/FabricAPIProperties.java
similarity index 97%
rename from secretpad-manager/src/main/java/org/secretflow/secretpad/manager/properties/FabricAPIProperties.java
rename to easypsi-manager/src/main/java/org/secretflow/easypsi/manager/properties/FabricAPIProperties.java
index fc1f458..0ac5521 100644
--- a/secretpad-manager/src/main/java/org/secretflow/secretpad/manager/properties/FabricAPIProperties.java
+++ b/easypsi-manager/src/main/java/org/secretflow/easypsi/manager/properties/FabricAPIProperties.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.manager.properties;
+package org.secretflow.easypsi.manager.properties;
import lombok.Data;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
diff --git a/secretpad-manager/src/main/java/org/secretflow/secretpad/manager/properties/KusciaAPIProperties.java b/easypsi-manager/src/main/java/org/secretflow/easypsi/manager/properties/KusciaAPIProperties.java
similarity index 90%
rename from secretpad-manager/src/main/java/org/secretflow/secretpad/manager/properties/KusciaAPIProperties.java
rename to easypsi-manager/src/main/java/org/secretflow/easypsi/manager/properties/KusciaAPIProperties.java
index f86e283..fdd9401 100644
--- a/secretpad-manager/src/main/java/org/secretflow/secretpad/manager/properties/KusciaAPIProperties.java
+++ b/easypsi-manager/src/main/java/org/secretflow/easypsi/manager/properties/KusciaAPIProperties.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.manager.properties;
+package org.secretflow.easypsi.manager.properties;
import lombok.Data;
import org.secretflow.v1alpha1.factory.TlsConfig;
@@ -37,6 +37,10 @@ public class KusciaAPIProperties {
* ApiLite token file
*/
private String tokenFile;
+ /**
+ * ApiLite protocol
+ */
+ private String protocol;
/**
* ApiLite tls config
*/
diff --git a/easypsi-manager/src/test/java/org/secretflow/easypsi/manager/integration/data/DataManagerTest.java b/easypsi-manager/src/test/java/org/secretflow/easypsi/manager/integration/data/DataManagerTest.java
new file mode 100644
index 0000000..e669114
--- /dev/null
+++ b/easypsi-manager/src/test/java/org/secretflow/easypsi/manager/integration/data/DataManagerTest.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2024 Ant Group Co., Ltd.
+ *
+ * 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.
+ */
+
+package org.secretflow.easypsi.manager.integration.data;
+
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.junit.jupiter.api.io.TempDir;
+import org.mockito.InjectMocks;
+import org.mockito.junit.jupiter.MockitoExtension;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+
+/**
+ * Data Manager Test
+ *
+ * @author lihaixin
+ * @date 2024/03/08
+ */
+@ExtendWith(MockitoExtension.class)
+public class DataManagerTest {
+
+
+ @InjectMocks
+ private DataManager dataManager;
+
+ @TempDir
+ Path tempDir;
+
+ private static final String FILE_CONTENT = "Hello, World!";
+
+
+ @Test
+ public void countLinesByCommandTest() throws IOException {
+ Path path = Files.writeString(tempDir.resolve("test.txt"), FILE_CONTENT);
+ dataManager.countLinesByCommand(path.toFile().getParentFile().getPath(), path.getFileName().toString());
+ }
+
+}
\ No newline at end of file
diff --git a/easypsi-manager/src/test/java/org/secretflow/easypsi/manager/integration/fabric/FabricManagerTest.java b/easypsi-manager/src/test/java/org/secretflow/easypsi/manager/integration/fabric/FabricManagerTest.java
new file mode 100644
index 0000000..8824266
--- /dev/null
+++ b/easypsi-manager/src/test/java/org/secretflow/easypsi/manager/integration/fabric/FabricManagerTest.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2024 Ant Group Co., Ltd.
+ *
+ * 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.
+ */
+
+package org.secretflow.easypsi.manager.integration.fabric;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.secretflow.easypsi.manager.properties.FabricAPIProperties;
+
+/**
+ * @author chenmingliang
+ * @date 2024/03/12
+ */
+public class FabricManagerTest {
+
+ @Test
+ public void testValidateFile() {
+ FabricAPIProperties fabricAPIProperties = new FabricAPIProperties();
+ fabricAPIProperties.setIsOpen(true);
+ FabricManager fabricManager = new FabricManager(fabricAPIProperties);
+
+ Assertions.assertThrows(IllegalStateException.class,()->fabricManager.validateFile());
+ }
+}
diff --git a/easypsi-manager/src/test/java/org/secretflow/easypsi/manager/integration/job/JobManagerTest.java b/easypsi-manager/src/test/java/org/secretflow/easypsi/manager/integration/job/JobManagerTest.java
new file mode 100644
index 0000000..4fecb81
--- /dev/null
+++ b/easypsi-manager/src/test/java/org/secretflow/easypsi/manager/integration/job/JobManagerTest.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2024 Ant Group Co., Ltd.
+ *
+ * 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.
+ */
+
+package org.secretflow.easypsi.manager.integration.job;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.secretflow.easypsi.common.exception.EasyPsiException;
+import org.secretflow.v1alpha1.common.Common;
+import org.secretflow.v1alpha1.kusciaapi.Job;
+import org.secretflow.v1alpha1.kusciaapi.JobServiceGrpc;
+
+
+/**
+ * @author chenmingliang
+ * @date 2024/03/12
+ */
+@ExtendWith(MockitoExtension.class)
+public class JobManagerTest {
+
+ @Mock
+ JobServiceGrpc.JobServiceBlockingStub jobStub;
+
+ @Test
+ public void startSyncTest() {
+ JobManager jobManager = new JobManager(null,jobStub);
+ jobManager.startSync();
+ }
+
+ @Test
+ public void createJob() {
+ JobManager jobManager = new JobManager(null,jobStub);
+ Job.CreateJobRequest createJobRequest = Job.CreateJobRequest.newBuilder().build();
+ Job.CreateJobResponse createJobResponse = Job.CreateJobResponse.newBuilder().build();
+ Mockito.when(jobStub.createJob(createJobRequest)).thenReturn(createJobResponse);
+ Assertions.assertThrows(EasyPsiException.class,()->jobManager.createJob(createJobRequest));
+
+ Job.CreateJobRequest createJobRequestA = Job.CreateJobRequest.newBuilder().build();
+ Job.CreateJobResponse createJobResponseA = Job.CreateJobResponse.newBuilder().setStatus(Common.Status.newBuilder().setCode(400).build()).build();
+
+ Mockito.when(jobStub.createJob(createJobRequestA)).thenReturn(createJobResponseA);
+ Assertions.assertThrows(EasyPsiException.class,()->jobManager.createJob(createJobRequestA));
+ }
+}
diff --git a/easypsi-manager/src/test/java/org/secretflow/easypsi/manager/integration/node/NodeManagerTest.java b/easypsi-manager/src/test/java/org/secretflow/easypsi/manager/integration/node/NodeManagerTest.java
new file mode 100644
index 0000000..a6e7c02
--- /dev/null
+++ b/easypsi-manager/src/test/java/org/secretflow/easypsi/manager/integration/node/NodeManagerTest.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2023 Ant Group Co., Ltd.
+ *
+ * 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.
+ */
+
+package org.secretflow.easypsi.manager.integration.node;
+
+import org.assertj.core.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.secretflow.easypsi.common.exception.EasyPsiException;
+import org.secretflow.easypsi.manager.integration.model.UpdateNodeParam;
+import org.secretflow.easypsi.persistence.entity.NodeDO;
+import org.secretflow.easypsi.persistence.repository.NodeRepository;
+import org.secretflow.v1alpha1.kusciaapi.DomainServiceGrpc;
+
+/**
+ * @author beiwei
+ * @date 2023/9/11
+ */
+@ExtendWith(MockitoExtension.class)
+class NodeManagerTest {
+
+ @Mock
+ NodeRepository nodeRepository;
+
+ @Mock
+ DomainServiceGrpc.DomainServiceBlockingStub domainServiceBlockingStub;
+
+ @Test
+ void genDomainId() {
+ NodeManager nodeManager = new NodeManager(null, null, null);
+ String s = nodeManager.genDomainId();
+ Assertions.assertThat(s).hasSize(8);
+ }
+
+ @Test
+ public void testCheckNodeCert() {
+ NodeManager nodeManager = new NodeManager(null, null, null);
+ org.junit.jupiter.api.Assertions.assertThrows(EasyPsiException.class,()->nodeManager.checkNodeCert(null));
+ }
+
+ @Test
+ public void testUpdateNode() {
+ NodeManager nodeManager = new NodeManager(nodeRepository, null, null);
+ NodeDO nodeDO = new NodeDO();
+ nodeDO.setTrust(true);
+ Mockito.when(nodeRepository.findByNodeId("alice")).thenReturn(nodeDO);
+ nodeManager.updateNode(UpdateNodeParam.builder().nodeId("alice").build());
+ }
+
+ @Test
+ public void testGetNodeCertificate() {
+ NodeManager nodeManager = new NodeManager(nodeRepository, domainServiceBlockingStub, null);
+ Mockito.when(nodeRepository.findByNodeId("alice")).thenReturn(null);
+ org.junit.jupiter.api.Assertions.assertThrows(EasyPsiException.class,()->nodeManager.getNodeCertificate("alice"));
+ }
+
+ @Test
+ public void testQueryNode() {
+ NodeManager nodeManager = new NodeManager(nodeRepository, domainServiceBlockingStub, null);
+ Mockito.when(domainServiceBlockingStub.queryDomain(Mockito.any())).thenReturn(null);
+ org.junit.jupiter.api.Assertions.assertThrows(EasyPsiException.class,()->nodeManager.queryNode("alice"));
+
+ }
+}
\ No newline at end of file
diff --git a/easypsi-manager/src/test/java/org/secretflow/easypsi/manager/integration/noderoute/NodeRouteManagerTest.java b/easypsi-manager/src/test/java/org/secretflow/easypsi/manager/integration/noderoute/NodeRouteManagerTest.java
new file mode 100644
index 0000000..3d449c0
--- /dev/null
+++ b/easypsi-manager/src/test/java/org/secretflow/easypsi/manager/integration/noderoute/NodeRouteManagerTest.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2024 Ant Group Co., Ltd.
+ *
+ * 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.
+ */
+
+package org.secretflow.easypsi.manager.integration.noderoute;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.secretflow.easypsi.common.exception.EasyPsiException;
+import org.secretflow.easypsi.persistence.entity.NodeRouteDO;
+import org.secretflow.easypsi.persistence.repository.NodeRepository;
+import org.secretflow.easypsi.persistence.repository.NodeRouteRepository;
+import org.secretflow.v1alpha1.common.Common;
+import org.secretflow.v1alpha1.kusciaapi.DomainRoute;
+import org.secretflow.v1alpha1.kusciaapi.DomainRouteServiceGrpc;
+
+import java.util.Optional;
+
+/**
+ * @author chenmingliang
+ * @date 2024/03/12
+ */
+@ExtendWith(MockitoExtension.class)
+public class NodeRouteManagerTest {
+
+ @Mock
+ private NodeRouteRepository nodeRouteRepository;
+ @Mock
+ private NodeRepository nodeRepository;
+ @Mock
+ private DomainRouteServiceGrpc.DomainRouteServiceBlockingStub routeServiceBlockingStub;
+
+ @Test
+ public void deleteNodeRoute() {
+ NodeRouteManager nodeRouteManager = new NodeRouteManager(nodeRouteRepository,nodeRepository,routeServiceBlockingStub);
+ DomainRoute.DeleteDomainRouteResponse deleteDomainRouteResponse = DomainRoute.DeleteDomainRouteResponse.newBuilder().setStatus(Common.Status.newBuilder().setCode(400).build()).build();
+ Mockito.when(routeServiceBlockingStub.deleteDomainRoute(Mockito.any())).thenReturn(deleteDomainRouteResponse);
+ NodeRouteDO nodeRouteDO = new NodeRouteDO();
+ nodeRouteDO.setSrcNodeId("aaa");
+ nodeRouteDO.setDstNodeId("aaa");
+ Assertions.assertThrows(EasyPsiException.class,()->nodeRouteManager.deleteNodeRoute(nodeRouteDO));
+ Mockito.when(nodeRouteRepository.findByRouteId(1L)).thenReturn(null);
+ Assertions.assertThrows(EasyPsiException.class,()->nodeRouteManager.deleteNodeRoute(1L));
+
+ }
+
+ @Test
+ public void testGetRouteStatus() {
+ Mockito.when(routeServiceBlockingStub.queryDomainRoute(Mockito.any())).thenReturn(null);
+ NodeRouteManager nodeRouteManager = new NodeRouteManager(nodeRouteRepository,nodeRepository,routeServiceBlockingStub);
+ Assertions.assertThrows(EasyPsiException.class,()->nodeRouteManager.getRouteStatus("alice","bob"));
+
+ }
+
+ @Test
+ public void testCheckNode() {
+ NodeRouteManager nodeRouteManager = new NodeRouteManager(nodeRouteRepository,nodeRepository,routeServiceBlockingStub);
+ Assertions.assertThrows(EasyPsiException.class,()->nodeRouteManager.checkNode(null));
+ }
+
+ @Test
+ public void testCheckRouteExist() {
+ NodeRouteManager nodeRouteManager = new NodeRouteManager(nodeRouteRepository,nodeRepository,routeServiceBlockingStub);
+ Mockito.when(nodeRouteRepository.findBySrcNodeIdAndDstNodeId("alice","bob")).thenReturn(Optional.ofNullable(null));
+ Assertions.assertThrows(EasyPsiException.class,()->nodeRouteManager.checkRouteNotExist("alice","bob"));
+ }
+
+}
diff --git a/easypsi-manager/src/test/java/org/secretflow/easypsi/manager/kuscia/grpc/impl/KusciaJobRpcImplTest.java b/easypsi-manager/src/test/java/org/secretflow/easypsi/manager/kuscia/grpc/impl/KusciaJobRpcImplTest.java
new file mode 100644
index 0000000..9f8133e
--- /dev/null
+++ b/easypsi-manager/src/test/java/org/secretflow/easypsi/manager/kuscia/grpc/impl/KusciaJobRpcImplTest.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2024 Ant Group Co., Ltd.
+ *
+ * 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.
+ */
+
+package org.secretflow.easypsi.manager.kuscia.grpc.impl;
+
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.secretflow.easypsi.manager.kuscia.grpc.KusciaJobRpc;
+import org.secretflow.v1alpha1.kusciaapi.Job;
+import org.secretflow.v1alpha1.kusciaapi.JobServiceGrpc;
+
+/**
+ * @author chenmingliang
+ * @date 2024/03/12
+ */
+@ExtendWith(MockitoExtension.class)
+public class KusciaJobRpcImplTest {
+
+ @Mock
+ JobServiceGrpc.JobServiceBlockingStub jobServiceStub;
+ @Test
+ public void testQueryJob() {
+ KusciaJobRpc kusciaJobRpc = new KusciaJobRpcImpl(jobServiceStub);
+ Mockito.when(jobServiceStub.queryJob(Mockito.any())).thenReturn(Job.QueryJobResponse.newBuilder().build());
+ kusciaJobRpc.queryJob(Job.QueryJobRequest.newBuilder().build());
+ }
+
+ @Test
+ public void approveJob() {
+ KusciaJobRpc kusciaJobRpc = new KusciaJobRpcImpl(jobServiceStub);
+ Mockito.when(jobServiceStub.approveJob(Mockito.any())).thenReturn(Job.ApproveJobResponse.newBuilder().build());
+ kusciaJobRpc.approveJob(Job.ApproveJobRequest.newBuilder().build());
+ }
+}
diff --git a/secretpad-persistence/pom.xml b/easypsi-persistence/pom.xml
similarity index 66%
rename from secretpad-persistence/pom.xml
rename to easypsi-persistence/pom.xml
index 80b4251..56fafa2 100644
--- a/secretpad-persistence/pom.xml
+++ b/easypsi-persistence/pom.xml
@@ -19,13 +19,13 @@
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- secretpad-parent
+ easypsi-parent
org.secretflow
0.0.1-SNAPSHOT
4.0.0
- secretpad-persistence
+ easypsi-persistence
@@ -38,7 +38,7 @@
org.secretflow
- secretpad-common
+ easypsi-common
@@ -55,4 +55,28 @@
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+ true
+
+
+
+ org.jacoco
+ jacoco-maven-plugin
+
+
+ report-aggregate
+ test
+
+ report-aggregate
+
+
+
+
+
+
\ No newline at end of file
diff --git a/secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/configuration/PersistenceConfiguration.java b/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/configuration/PersistenceConfiguration.java
similarity index 81%
rename from secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/configuration/PersistenceConfiguration.java
rename to easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/configuration/PersistenceConfiguration.java
index bd9d6bb..43b3a41 100644
--- a/secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/configuration/PersistenceConfiguration.java
+++ b/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/configuration/PersistenceConfiguration.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.persistence.configuration;
+package org.secretflow.easypsi.persistence.configuration;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.context.annotation.Configuration;
@@ -26,8 +26,8 @@
* @author yansi
* @date 2023/5/9
*/
-@EntityScan(basePackages = "org.secretflow.secretpad.persistence.*")
-@EnableJpaRepositories(basePackages = {"org.secretflow.secretpad.persistence.*"})
+@EntityScan(basePackages = "org.secretflow.easypsi.persistence.*")
+@EnableJpaRepositories(basePackages = {"org.secretflow.easypsi.persistence.*"})
@Configuration
public class PersistenceConfiguration {
}
diff --git a/secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/converter/Boolean2IntConverter.java b/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/converter/Boolean2IntConverter.java
similarity index 96%
rename from secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/converter/Boolean2IntConverter.java
rename to easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/converter/Boolean2IntConverter.java
index e257a96..56d4c53 100644
--- a/secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/converter/Boolean2IntConverter.java
+++ b/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/converter/Boolean2IntConverter.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.persistence.converter;
+package org.secretflow.easypsi.persistence.converter;
import jakarta.persistence.AttributeConverter;
import jakarta.persistence.Converter;
diff --git a/secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/converter/LocalDateTimeConverter.java b/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/converter/LocalDateTimeConverter.java
similarity index 96%
rename from secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/converter/LocalDateTimeConverter.java
rename to easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/converter/LocalDateTimeConverter.java
index 872185c..618cc93 100644
--- a/secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/converter/LocalDateTimeConverter.java
+++ b/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/converter/LocalDateTimeConverter.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.persistence.converter;
+package org.secretflow.easypsi.persistence.converter;
import jakarta.persistence.AttributeConverter;
import jakarta.persistence.Converter;
diff --git a/secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/converter/SqliteLocalDateTimeConverter.java b/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/converter/SqliteLocalDateTimeConverter.java
similarity index 97%
rename from secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/converter/SqliteLocalDateTimeConverter.java
rename to easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/converter/SqliteLocalDateTimeConverter.java
index 6b7f1b5..aa660d9 100644
--- a/secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/converter/SqliteLocalDateTimeConverter.java
+++ b/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/converter/SqliteLocalDateTimeConverter.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.persistence.converter;
+package org.secretflow.easypsi.persistence.converter;
import com.google.common.base.Strings;
import jakarta.persistence.AttributeConverter;
diff --git a/secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/entity/AccountsDO.java b/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/entity/AccountsDO.java
similarity index 84%
rename from secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/entity/AccountsDO.java
rename to easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/entity/AccountsDO.java
index 59cd757..fcfc683 100644
--- a/secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/entity/AccountsDO.java
+++ b/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/entity/AccountsDO.java
@@ -14,10 +14,11 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.persistence.entity;
+package org.secretflow.easypsi.persistence.entity;
-import org.secretflow.secretpad.common.constant.UserOwnerType;
-import org.secretflow.secretpad.persistence.converter.SqliteLocalDateTimeConverter;
+import org.secretflow.easypsi.common.constant.UserOwnerType;
+import org.secretflow.easypsi.persistence.converter.Boolean2IntConverter;
+import org.secretflow.easypsi.persistence.converter.SqliteLocalDateTimeConverter;
import com.fasterxml.jackson.annotation.JsonFormat;
import jakarta.persistence.*;
@@ -97,4 +98,11 @@ public class AccountsDO extends BaseAggregationRoot {
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Convert(converter = SqliteLocalDateTimeConverter.class)
private LocalDateTime gmtPasswdResetRelease;
+
+ /**
+ * Node remark
+ */
+ @Column(name = "initial", nullable = false, length = 1)
+ @Convert(converter = Boolean2IntConverter.class)
+ private Boolean initial;
}
diff --git a/secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/entity/BaseAggregationRoot.java b/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/entity/BaseAggregationRoot.java
similarity index 90%
rename from secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/entity/BaseAggregationRoot.java
rename to easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/entity/BaseAggregationRoot.java
index 1a0245f..888fde4 100644
--- a/secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/entity/BaseAggregationRoot.java
+++ b/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/entity/BaseAggregationRoot.java
@@ -14,14 +14,14 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.persistence.entity;
+package org.secretflow.easypsi.persistence.entity;
import jakarta.persistence.Column;
import jakarta.persistence.Convert;
import jakarta.persistence.MappedSuperclass;
import lombok.Getter;
import lombok.Setter;
-import org.secretflow.secretpad.persistence.converter.Boolean2IntConverter;
+import org.secretflow.easypsi.persistence.converter.Boolean2IntConverter;
/**
* Base aggregate root
diff --git a/secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/entity/FabricLogDO.java b/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/entity/FabricLogDO.java
similarity index 97%
rename from secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/entity/FabricLogDO.java
rename to easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/entity/FabricLogDO.java
index 150c3bf..a8d3c02 100644
--- a/secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/entity/FabricLogDO.java
+++ b/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/entity/FabricLogDO.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.persistence.entity;
+package org.secretflow.easypsi.persistence.entity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
diff --git a/secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/entity/NodeDO.java b/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/entity/NodeDO.java
similarity index 76%
rename from secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/entity/NodeDO.java
rename to easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/entity/NodeDO.java
index bf1e29e..0898bf4 100644
--- a/secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/entity/NodeDO.java
+++ b/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/entity/NodeDO.java
@@ -14,14 +14,12 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.persistence.entity;
+package org.secretflow.easypsi.persistence.entity;
-import jakarta.persistence.Column;
-import jakarta.persistence.Entity;
-import jakarta.persistence.Id;
-import jakarta.persistence.Table;
+import jakarta.persistence.*;
import lombok.*;
import org.hibernate.annotations.Where;
+import org.secretflow.easypsi.persistence.converter.Boolean2IntConverter;
/**
* Node data object
@@ -77,7 +75,23 @@ public class NodeDO extends BaseAggregationRoot {
@Column(name = "node_remark", columnDefinition = "text")
private String nodeRemark;
+ /**
+ * Node remark
+ */
+ @Column(name = "control_node_id", columnDefinition = "text")
private String controlNodeId;
+
+ /**
+ * Node remark
+ */
+ @Column(name = "net_address", columnDefinition = "text")
private String netAddress;
+ /**
+ * Node remark
+ */
+ @Column(name = "trust", nullable = false, length = 1)
+ @Convert(converter = Boolean2IntConverter.class)
+ private Boolean trust;
+
}
diff --git a/secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/entity/NodeRouteDO.java b/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/entity/NodeRouteDO.java
similarity index 93%
rename from secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/entity/NodeRouteDO.java
rename to easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/entity/NodeRouteDO.java
index 12b154c..4cf51aa 100644
--- a/secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/entity/NodeRouteDO.java
+++ b/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/entity/NodeRouteDO.java
@@ -14,12 +14,12 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.persistence.entity;
+package org.secretflow.easypsi.persistence.entity;
import jakarta.persistence.*;
import lombok.*;
import org.hibernate.annotations.Where;
-import org.secretflow.secretpad.persistence.converter.Boolean2IntConverter;
+import org.secretflow.easypsi.persistence.converter.Boolean2IntConverter;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
diff --git a/secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/entity/ProjectJobDO.java b/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/entity/ProjectJobDO.java
similarity index 58%
rename from secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/entity/ProjectJobDO.java
rename to easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/entity/ProjectJobDO.java
index 3613db0..11ec576 100644
--- a/secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/entity/ProjectJobDO.java
+++ b/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/entity/ProjectJobDO.java
@@ -14,20 +14,17 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.persistence.entity;
+package org.secretflow.easypsi.persistence.entity;
-import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.persistence.*;
import lombok.*;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;
-import org.secretflow.secretpad.persistence.converter.SqliteLocalDateTimeConverter;
-import org.secretflow.secretpad.persistence.model.GraphJobStatus;
-import org.secretflow.secretpad.persistence.model.GraphNodeTaskStatus;
+import org.secretflow.easypsi.persistence.converter.SqliteLocalDateTimeConverter;
+import org.secretflow.easypsi.persistence.model.GraphJobStatus;
import java.io.Serializable;
import java.time.LocalDateTime;
-import java.util.List;
/**
* Project job data object
@@ -170,94 +167,4 @@ public static class UPK implements Serializable {
private String jobId;
}
- /**
- * Abstract event class
- */
- @AllArgsConstructor
- @Getter
- public static abstract class AbstractEvent {
- @JsonIgnore
- private ProjectJobDO source;
-
- /**
- * Get projectId from source, avoid pmd error
- *
- * @param source target ProjectJobDO
- * @return projectId
- */
- public abstract String getProjectId(ProjectJobDO source);
- }
-
- /**
- * Edge project job status sync event class
- */
- @Getter
- public static class EdgeProjectJobStatusSyncEvent extends AbstractEvent {
- /**
- * Task id
- */
- private String taskId;
-
- private EdgeProjectJobStatusSyncEvent(ProjectJobDO source) {
- super(source);
- }
-
- @Override
- public String getProjectId(ProjectJobDO source) {
- return source.getUpk().getProjectId();
- }
- }
-
- /**
- * Transform task status event class
- */
- @Getter
- public static class TaskStatusTransformEvent extends AbstractEvent {
- /**
- * Task id
- */
- private String taskId;
- /**
- * Graph node task status of source
- */
- private GraphNodeTaskStatus fromStatus;
- /**
- * Graph node task status of destination
- */
- private GraphNodeTaskStatus toStatus;
- /**
- * Task failed reasons from apiLite
- */
- private List reasons;
-
- private TaskStatusTransformEvent(ProjectJobDO source) {
- super(source);
- }
-
- /**
- * Transform task status from graph node task status of source to graph node task status of destination
- * Fill failed reasons if graph node task status of source is failed
- *
- * @param source
- * @param taskId
- * @param fromStatus
- * @param toStatus
- * @param reasons
- * @return transform task status event
- */
- public static TaskStatusTransformEvent of(ProjectJobDO source, String taskId, GraphNodeTaskStatus fromStatus,
- GraphNodeTaskStatus toStatus, List reasons) {
- TaskStatusTransformEvent event = new TaskStatusTransformEvent(source);
- event.taskId = taskId;
- event.fromStatus = fromStatus;
- event.toStatus = toStatus;
- event.reasons = reasons;
- return event;
- }
-
- @Override
- public String getProjectId(ProjectJobDO source) {
- return source.getUpk().getProjectId();
- }
- }
}
diff --git a/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/entity/RsaEncryptionKeyDO.java b/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/entity/RsaEncryptionKeyDO.java
new file mode 100644
index 0000000..f9f57df
--- /dev/null
+++ b/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/entity/RsaEncryptionKeyDO.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2023 Ant Group Co., Ltd.
+ *
+ * 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.
+ */
+
+package org.secretflow.easypsi.persistence.entity;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import jakarta.persistence.*;
+import lombok.*;
+import org.hibernate.annotations.SQLDelete;
+import org.hibernate.annotations.Where;
+import org.secretflow.easypsi.persistence.converter.SqliteLocalDateTimeConverter;
+
+import java.time.LocalDateTime;
+
+/**
+ * Rsa encryption key object
+ *
+ * @author lihaixin
+ * @date 2024/02/04
+ */
+@Builder
+@Entity
+@NoArgsConstructor
+@AllArgsConstructor
+@Table(name = "rsa_encryption_key")
+@ToString
+@Getter
+@Setter
+@SQLDelete(sql = "update rsa_encryption_key set is_deleted = 1 where inst_id = ?")
+@Where(clause = "is_deleted = 0")
+public class RsaEncryptionKeyDO extends BaseAggregationRoot {
+
+ /**
+ * Public key
+ */
+ @Column(name = "public_key", nullable = false)
+ private String publicKey;
+
+ /**
+ * Private key
+ */
+ @Column(name = "private_key", nullable = false)
+ @Id
+ private String privateKey;
+
+
+ /**
+ * key invalid time
+ */
+ @Column(name = "key_invalid_time")
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ @Convert(converter = SqliteLocalDateTimeConverter.class)
+ private LocalDateTime keyInvalidTime;
+
+}
diff --git a/secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/entity/SuperBaseAggregationRoot.java b/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/entity/SuperBaseAggregationRoot.java
similarity index 96%
rename from secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/entity/SuperBaseAggregationRoot.java
rename to easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/entity/SuperBaseAggregationRoot.java
index a463abd..467880a 100644
--- a/secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/entity/SuperBaseAggregationRoot.java
+++ b/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/entity/SuperBaseAggregationRoot.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.persistence.entity;
+package org.secretflow.easypsi.persistence.entity;
import jakarta.persistence.Column;
import jakarta.persistence.MappedSuperclass;
diff --git a/secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/entity/SysResourceDO.java b/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/entity/SysResourceDO.java
similarity index 93%
rename from secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/entity/SysResourceDO.java
rename to easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/entity/SysResourceDO.java
index e27273a..203fd58 100644
--- a/secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/entity/SysResourceDO.java
+++ b/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/entity/SysResourceDO.java
@@ -14,14 +14,14 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.persistence.entity;
+package org.secretflow.easypsi.persistence.entity;
import jakarta.persistence.*;
import lombok.*;
import org.checkerframework.common.aliasing.qual.Unique;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;
-import org.secretflow.secretpad.common.constant.ResourceType;
+import org.secretflow.easypsi.common.constant.ResourceType;
/**
* @author beiwei
diff --git a/secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/entity/SysRoleDO.java b/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/entity/SysRoleDO.java
similarity index 96%
rename from secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/entity/SysRoleDO.java
rename to easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/entity/SysRoleDO.java
index 15c8c2e..3ac407d 100644
--- a/secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/entity/SysRoleDO.java
+++ b/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/entity/SysRoleDO.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.persistence.entity;
+package org.secretflow.easypsi.persistence.entity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
diff --git a/secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/entity/SysRoleResourceRelDO.java b/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/entity/SysRoleResourceRelDO.java
similarity index 96%
rename from secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/entity/SysRoleResourceRelDO.java
rename to easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/entity/SysRoleResourceRelDO.java
index 3a4a667..ed5934d 100644
--- a/secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/entity/SysRoleResourceRelDO.java
+++ b/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/entity/SysRoleResourceRelDO.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.persistence.entity;
+package org.secretflow.easypsi.persistence.entity;
import jakarta.persistence.*;
import lombok.*;
diff --git a/secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/entity/SysUserPermissionRelDO.java b/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/entity/SysUserPermissionRelDO.java
similarity index 90%
rename from secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/entity/SysUserPermissionRelDO.java
rename to easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/entity/SysUserPermissionRelDO.java
index b0ace4b..53019b9 100644
--- a/secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/entity/SysUserPermissionRelDO.java
+++ b/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/entity/SysUserPermissionRelDO.java
@@ -14,10 +14,10 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.persistence.entity;
+package org.secretflow.easypsi.persistence.entity;
-import org.secretflow.secretpad.common.constant.PermissionTargetType;
-import org.secretflow.secretpad.common.constant.PermissionUserType;
+import org.secretflow.easypsi.common.constant.PermissionTargetType;
+import org.secretflow.easypsi.common.constant.PermissionUserType;
import jakarta.persistence.*;
import lombok.*;
diff --git a/secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/entity/TokensDO.java b/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/entity/TokensDO.java
similarity index 97%
rename from secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/entity/TokensDO.java
rename to easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/entity/TokensDO.java
index 543bef5..43d7d01 100644
--- a/secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/entity/TokensDO.java
+++ b/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/entity/TokensDO.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.persistence.entity;
+package org.secretflow.easypsi.persistence.entity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
diff --git a/secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/model/GraphJobOperation.java b/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/model/GraphJobOperation.java
similarity index 96%
rename from secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/model/GraphJobOperation.java
rename to easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/model/GraphJobOperation.java
index e72e074..27a3916 100644
--- a/secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/model/GraphJobOperation.java
+++ b/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/model/GraphJobOperation.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.persistence.model;
+package org.secretflow.easypsi.persistence.model;
/**
* Graph job operation enum
diff --git a/secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/model/GraphJobStatus.java b/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/model/GraphJobStatus.java
similarity index 91%
rename from secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/model/GraphJobStatus.java
rename to easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/model/GraphJobStatus.java
index 659cdce..e4cf19c 100644
--- a/secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/model/GraphJobStatus.java
+++ b/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/model/GraphJobStatus.java
@@ -14,11 +14,11 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.persistence.model;
+package org.secretflow.easypsi.persistence.model;
-import org.secretflow.secretpad.common.constant.JobConstants;
-import org.secretflow.secretpad.common.util.JsonUtils;
-import org.secretflow.secretpad.persistence.entity.ProjectJobDO;
+import org.secretflow.easypsi.common.constant.JobConstants;
+import org.secretflow.easypsi.common.util.JsonUtils;
+import org.secretflow.easypsi.persistence.entity.ProjectJobDO;
import org.apache.commons.lang3.StringUtils;
@@ -95,28 +95,22 @@ public static GraphJobStatus formKusciaJobStatus(String status) {
return SUCCEEDED;
case "Failed":
return FAILED;
+ case "Cancelled":
+ return CANCELED;
+ case "Running":
+ return RUNNING;
+ case "AwaitingApproval":
+ return PENDING_REVIEW;
+ case "ApprovalReject":
+ return REJECTED;
default:
return RUNNING;
}
}
- /**
- * Convert graph job status from apiLite job status
- *
- * @param status
- * @return graph job status class
- */
- public static GraphJobStatus fromDbJobStatus(String status) {
- return switch (status) {
- case "SUCCEED" -> SUCCEEDED;
- case "FAILED" -> FAILED;
- case "STOPPED" -> PAUSED;
- default -> RUNNING;
- };
- }
-
public static boolean checkJobFinalStatus(String status) {
- return !RUNNING.name().equals(status) && !PENDING_CERT.name().equals(status) && !PENDING_REVIEW.name().equals(status) && !PAUSED.name().equals(status) && !FAILED.name().equals(status);
+ return !(RUNNING.name().equals(status) || PENDING_CERT.name().equals(status) || PENDING_REVIEW.name().equals(status)
+ || PAUSED.name().equals(status) || FAILED.name().equals(status));
}
public static List getUnFinalStatus() {
diff --git a/secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/model/GraphNodeTaskStatus.java b/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/model/GraphNodeTaskStatus.java
similarity index 97%
rename from secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/model/GraphNodeTaskStatus.java
rename to easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/model/GraphNodeTaskStatus.java
index 450eb28..4450a9e 100644
--- a/secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/model/GraphNodeTaskStatus.java
+++ b/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/model/GraphNodeTaskStatus.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.persistence.model;
+package org.secretflow.easypsi.persistence.model;
import lombok.Getter;
diff --git a/secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/model/PsiConfigDO.java b/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/model/PsiConfigDO.java
similarity index 92%
rename from secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/model/PsiConfigDO.java
rename to easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/model/PsiConfigDO.java
index 83f6644..66a914e 100644
--- a/secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/model/PsiConfigDO.java
+++ b/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/model/PsiConfigDO.java
@@ -14,9 +14,9 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.persistence.model;
+package org.secretflow.easypsi.persistence.model;
-import org.secretflow.secretpad.common.constant.JobConstants;
+import org.secretflow.easypsi.common.constant.JobConstants;
import lombok.*;
@@ -54,9 +54,11 @@ public class PsiConfigDO {
private JobConstants.AdvancedJoinTypeEnum advancedJoinType;
- private Boolean outputDifference;
+ private String leftSide;
- private String datatableCount;
+ private Boolean dataTableConfirmation;
+
+ private String dataTableCount;
@Getter
diff --git a/secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/repository/FabricLogRepository.java b/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/repository/FabricLogRepository.java
similarity index 85%
rename from secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/repository/FabricLogRepository.java
rename to easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/repository/FabricLogRepository.java
index a80aa5f..58f8d2b 100644
--- a/secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/repository/FabricLogRepository.java
+++ b/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/repository/FabricLogRepository.java
@@ -14,10 +14,10 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.persistence.repository;
+package org.secretflow.easypsi.persistence.repository;
-import org.secretflow.secretpad.persistence.entity.FabricLogDO;
-import org.secretflow.secretpad.persistence.entity.NodeDO;
+import org.secretflow.easypsi.persistence.entity.FabricLogDO;
+import org.secretflow.easypsi.persistence.entity.NodeDO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
diff --git a/secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/repository/NodeRepository.java b/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/repository/NodeRepository.java
similarity index 93%
rename from secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/repository/NodeRepository.java
rename to easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/repository/NodeRepository.java
index 55e4c91..3afbd67 100644
--- a/secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/repository/NodeRepository.java
+++ b/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/repository/NodeRepository.java
@@ -15,9 +15,9 @@
*/
-package org.secretflow.secretpad.persistence.repository;
+package org.secretflow.easypsi.persistence.repository;
-import org.secretflow.secretpad.persistence.entity.NodeDO;
+import org.secretflow.easypsi.persistence.entity.NodeDO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
diff --git a/secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/repository/NodeRouteRepository.java b/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/repository/NodeRouteRepository.java
similarity index 96%
rename from secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/repository/NodeRouteRepository.java
rename to easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/repository/NodeRouteRepository.java
index 67cf2e9..a8c16eb 100644
--- a/secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/repository/NodeRouteRepository.java
+++ b/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/repository/NodeRouteRepository.java
@@ -14,9 +14,9 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.persistence.repository;
+package org.secretflow.easypsi.persistence.repository;
-import org.secretflow.secretpad.persistence.entity.NodeRouteDO;
+import org.secretflow.easypsi.persistence.entity.NodeRouteDO;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
diff --git a/secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/repository/ProjectJobRepository.java b/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/repository/ProjectJobRepository.java
similarity index 96%
rename from secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/repository/ProjectJobRepository.java
rename to easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/repository/ProjectJobRepository.java
index fb135c0..5f5aeb8 100644
--- a/secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/repository/ProjectJobRepository.java
+++ b/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/repository/ProjectJobRepository.java
@@ -14,9 +14,9 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.persistence.repository;
+package org.secretflow.easypsi.persistence.repository;
-import org.secretflow.secretpad.persistence.entity.ProjectJobDO;
+import org.secretflow.easypsi.persistence.entity.ProjectJobDO;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
diff --git a/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/repository/RsaEncryptionKeyRepository.java b/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/repository/RsaEncryptionKeyRepository.java
new file mode 100644
index 0000000..70fc1e5
--- /dev/null
+++ b/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/repository/RsaEncryptionKeyRepository.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2023 Ant Group Co., Ltd.
+ *
+ * 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.
+ */
+
+package org.secretflow.easypsi.persistence.repository;
+
+import org.secretflow.easypsi.persistence.entity.FabricLogDO;
+import org.secretflow.easypsi.persistence.entity.RsaEncryptionKeyDO;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Query;
+
+/**
+ * Rsa encryption key repository
+ *
+ * @author lihaixin
+ * @date 2024/02/04
+ */
+public interface RsaEncryptionKeyRepository extends JpaRepository {
+
+ /**
+ * Find by public key
+ *
+ * @param publicKey
+ * @return {@link FabricLogDO }
+ */
+
+ @Query("from RsaEncryptionKeyDO where publicKey=:publicKey")
+ RsaEncryptionKeyDO findByPublicKey(String publicKey);
+
+
+ /**
+ * Find last key
+ *
+ * @return {@link RsaEncryptionKeyDO }
+ */
+
+ @Query("from RsaEncryptionKeyDO order by keyInvalidTime desc limit 1")
+ RsaEncryptionKeyDO findLastKey();
+
+}
diff --git a/secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/repository/SysResourceRepository.java b/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/repository/SysResourceRepository.java
similarity index 89%
rename from secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/repository/SysResourceRepository.java
rename to easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/repository/SysResourceRepository.java
index db5ad64..0603571 100644
--- a/secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/repository/SysResourceRepository.java
+++ b/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/repository/SysResourceRepository.java
@@ -14,9 +14,9 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.persistence.repository;
+package org.secretflow.easypsi.persistence.repository;
-import org.secretflow.secretpad.persistence.entity.SysResourceDO;
+import org.secretflow.easypsi.persistence.entity.SysResourceDO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
diff --git a/secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/repository/SysRoleRepository.java b/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/repository/SysRoleRepository.java
similarity index 86%
rename from secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/repository/SysRoleRepository.java
rename to easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/repository/SysRoleRepository.java
index a2f5f41..26df643 100644
--- a/secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/repository/SysRoleRepository.java
+++ b/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/repository/SysRoleRepository.java
@@ -14,9 +14,9 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.persistence.repository;
+package org.secretflow.easypsi.persistence.repository;
-import org.secretflow.secretpad.persistence.entity.SysRoleDO;
+import org.secretflow.easypsi.persistence.entity.SysRoleDO;
import org.springframework.data.jpa.repository.JpaRepository;
/**
diff --git a/secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/repository/SysRoleResourceRelRepository.java b/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/repository/SysRoleResourceRelRepository.java
similarity index 89%
rename from secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/repository/SysRoleResourceRelRepository.java
rename to easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/repository/SysRoleResourceRelRepository.java
index 55360af..8667cfa 100644
--- a/secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/repository/SysRoleResourceRelRepository.java
+++ b/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/repository/SysRoleResourceRelRepository.java
@@ -14,9 +14,9 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.persistence.repository;
+package org.secretflow.easypsi.persistence.repository;
-import org.secretflow.secretpad.persistence.entity.SysRoleResourceRelDO;
+import org.secretflow.easypsi.persistence.entity.SysRoleResourceRelDO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
diff --git a/secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/repository/SysUserPermissionRelRepository.java b/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/repository/SysUserPermissionRelRepository.java
similarity index 91%
rename from secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/repository/SysUserPermissionRelRepository.java
rename to easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/repository/SysUserPermissionRelRepository.java
index f3cec2f..e892772 100644
--- a/secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/repository/SysUserPermissionRelRepository.java
+++ b/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/repository/SysUserPermissionRelRepository.java
@@ -14,9 +14,9 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.persistence.repository;
+package org.secretflow.easypsi.persistence.repository;
-import org.secretflow.secretpad.persistence.entity.SysUserPermissionRelDO;
+import org.secretflow.easypsi.persistence.entity.SysUserPermissionRelDO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
diff --git a/secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/repository/UserAccountsRepository.java b/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/repository/UserAccountsRepository.java
similarity index 93%
rename from secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/repository/UserAccountsRepository.java
rename to easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/repository/UserAccountsRepository.java
index 5edcbee..bbd0ad2 100644
--- a/secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/repository/UserAccountsRepository.java
+++ b/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/repository/UserAccountsRepository.java
@@ -14,9 +14,9 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.persistence.repository;
+package org.secretflow.easypsi.persistence.repository;
-import org.secretflow.secretpad.persistence.entity.AccountsDO;
+import org.secretflow.easypsi.persistence.entity.AccountsDO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
diff --git a/secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/repository/UserTokensRepository.java b/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/repository/UserTokensRepository.java
similarity index 93%
rename from secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/repository/UserTokensRepository.java
rename to easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/repository/UserTokensRepository.java
index 0fcffdf..79ae92f 100644
--- a/secretpad-persistence/src/main/java/org/secretflow/secretpad/persistence/repository/UserTokensRepository.java
+++ b/easypsi-persistence/src/main/java/org/secretflow/easypsi/persistence/repository/UserTokensRepository.java
@@ -14,9 +14,9 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.persistence.repository;
+package org.secretflow.easypsi.persistence.repository;
-import org.secretflow.secretpad.persistence.entity.TokensDO;
+import org.secretflow.easypsi.persistence.entity.TokensDO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
diff --git a/easypsi-persistence/src/test/java/org/secretflow/easypsi/persistence/constant/GraphJobStatusTest.java b/easypsi-persistence/src/test/java/org/secretflow/easypsi/persistence/constant/GraphJobStatusTest.java
new file mode 100644
index 0000000..35340db
--- /dev/null
+++ b/easypsi-persistence/src/test/java/org/secretflow/easypsi/persistence/constant/GraphJobStatusTest.java
@@ -0,0 +1,90 @@
+/*
+ * Copyright 2023 Ant Group Co., Ltd.
+ *
+ * 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.
+ */
+
+package org.secretflow.easypsi.persistence.constant;
+
+import org.junit.jupiter.api.Test;
+import org.secretflow.easypsi.persistence.model.GraphJobOperation;
+import org.secretflow.easypsi.persistence.model.GraphJobStatus;
+
+import java.util.List;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+/**
+ * Graph Job Status Test
+ *
+ * @author lihaixin
+ * @date 2024/03/13
+ */
+public class GraphJobStatusTest {
+
+
+ @Test
+ public void testFormKusciaJobStatus() {
+ assertEquals(GraphJobStatus.SUCCEEDED, GraphJobStatus.formKusciaJobStatus("Succeeded"));
+ assertEquals(GraphJobStatus.FAILED, GraphJobStatus.formKusciaJobStatus("Failed"));
+ assertEquals(GraphJobStatus.CANCELED, GraphJobStatus.formKusciaJobStatus("Cancelled"));
+ assertEquals(GraphJobStatus.RUNNING, GraphJobStatus.formKusciaJobStatus("Running"));
+ assertEquals(GraphJobStatus.PENDING_REVIEW, GraphJobStatus.formKusciaJobStatus("AwaitingApproval"));
+ assertEquals(GraphJobStatus.REJECTED, GraphJobStatus.formKusciaJobStatus("ApprovalReject"));
+ assertEquals(GraphJobStatus.RUNNING, GraphJobStatus.formKusciaJobStatus("UnknownStatus"));
+ }
+
+ @Test
+ public void testCheckJobFinalStatus() {
+ assertTrue(GraphJobStatus.checkJobFinalStatus("Succeeded"));
+ assertTrue(GraphJobStatus.checkJobFinalStatus("Failed"));
+ assertTrue(GraphJobStatus.checkJobFinalStatus("Running"));
+ assertTrue(GraphJobStatus.checkJobFinalStatus("PendingCert"));
+ assertTrue(GraphJobStatus.checkJobFinalStatus("PendingReview"));
+ assertTrue(GraphJobStatus.checkJobFinalStatus("Paused"));
+ assertTrue(GraphJobStatus.checkJobFinalStatus("Timeout"));
+ assertTrue(GraphJobStatus.checkJobFinalStatus("Canceled"));
+ }
+
+ @Test
+ public void testGetUnFinalStatus() {
+ List unFinalStatuses = GraphJobStatus.getUnFinalStatus();
+ assertTrue(unFinalStatuses.containsAll(List.of("RUNNING", "PENDING_CERT", "PENDING_REVIEW", "PAUSED", "TIMEOUT", "FAILED")));
+ assertFalse(unFinalStatuses.contains("SUCCEEDED"));
+ }
+
+
+ @Test
+ public void testCheckOperation() {
+ assertTrue(GraphJobStatus.checkOperation(GraphJobStatus.PENDING_REVIEW, GraphJobOperation.AGREE));
+ assertFalse(GraphJobStatus.checkOperation(GraphJobStatus.RUNNING, GraphJobOperation.AGREE));
+
+ assertTrue(GraphJobStatus.checkOperation(GraphJobStatus.PENDING_REVIEW, GraphJobOperation.REJECT));
+ assertFalse(GraphJobStatus.checkOperation(GraphJobStatus.RUNNING, GraphJobOperation.REJECT));
+
+ assertTrue(GraphJobStatus.checkOperation(GraphJobStatus.RUNNING, GraphJobOperation.PAUSE));
+ assertFalse(GraphJobStatus.checkOperation(GraphJobStatus.SUCCEEDED, GraphJobOperation.PAUSE));
+
+ assertTrue(GraphJobStatus.checkOperation(GraphJobStatus.PAUSED, GraphJobOperation.CONTINUE));
+ assertFalse(GraphJobStatus.checkOperation(GraphJobStatus.RUNNING, GraphJobOperation.CONTINUE));
+
+ assertTrue(GraphJobStatus.checkOperation(GraphJobStatus.RUNNING, GraphJobOperation.CANCEL));
+ assertFalse(GraphJobStatus.checkOperation(GraphJobStatus.SUCCEEDED, GraphJobOperation.CANCEL));
+
+ assertTrue(GraphJobStatus.checkOperation(GraphJobStatus.TIMEOUT, GraphJobOperation.DELETE));
+ assertFalse(GraphJobStatus.checkOperation(GraphJobStatus.RUNNING, GraphJobOperation.DELETE));
+
+ assertTrue(GraphJobStatus.checkOperation(GraphJobStatus.SUCCEEDED, GraphJobOperation.DOWNLOAD_RESULT));
+ assertFalse(GraphJobStatus.checkOperation(GraphJobStatus.RUNNING, GraphJobOperation.DOWNLOAD_RESULT));
+ }
+}
\ No newline at end of file
diff --git a/secretpad-service/pom.xml b/easypsi-service/pom.xml
similarity index 66%
rename from secretpad-service/pom.xml
rename to easypsi-service/pom.xml
index bcf57be..0cea098 100644
--- a/secretpad-service/pom.xml
+++ b/easypsi-service/pom.xml
@@ -21,24 +21,24 @@
4.0.0
org.secretflow
- secretpad-parent
+ easypsi-parent
0.0.1-SNAPSHOT
- secretpad-service
+ easypsi-service
org.secretflow
- secretpad-manager
+ easypsi-manager
org.secretflow
- secretpad-common
+ easypsi-common
org.secretflow
- secretpad-persistence
+ easypsi-persistence
org.springdoc
@@ -71,6 +71,30 @@
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+ true
+
+ **/opensecretflow/spec/**
+ **/secretflow/proto/**
+
+
+
+
+ org.jacoco
+ jacoco-maven-plugin
+
+
+ report-aggregate
+ test
+
+ report-aggregate
+
+
+
+
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/AuthService.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/AuthService.java
similarity index 78%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/AuthService.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/AuthService.java
index eb7cb82..58b60c9 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/AuthService.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/AuthService.java
@@ -14,9 +14,10 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.service;
+package org.secretflow.easypsi.service;
-import org.secretflow.secretpad.common.dto.UserContextDTO;
+import org.secretflow.easypsi.common.dto.UserContextDTO;
+import org.secretflow.easypsi.service.model.auth.LoginRequest;
/**
* User auth service interface
@@ -29,11 +30,11 @@ public interface AuthService {
/**
* User login and save user token data
*
- * @param name userName
- * @param passwd user password
- * @return provisional token
+ * @param request
+ * @return {@link UserContextDTO }
*/
- UserContextDTO login(String name, String passwd);
+
+ UserContextDTO login(LoginRequest request);
/**
* User logout and delete user token data
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/DataService.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/DataService.java
similarity index 78%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/DataService.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/DataService.java
index d94ae78..6dcf1ff 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/DataService.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/DataService.java
@@ -14,12 +14,12 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.service;
+package org.secretflow.easypsi.service;
-import org.secretflow.secretpad.service.model.data.DataSourceVO;
-import org.secretflow.secretpad.service.model.data.DataTableInformationVo;
-import org.secretflow.secretpad.service.model.data.DataVersionVO;
-import org.secretflow.secretpad.service.model.data.GetDataTableInformatinoRequest;
+import org.secretflow.easypsi.service.model.data.DataSourceVO;
+import org.secretflow.easypsi.service.model.data.DataTableInformationVo;
+import org.secretflow.easypsi.service.model.data.DataVersionVO;
+import org.secretflow.easypsi.service.model.data.GetDataTableInformatinoRequest;
/**
* Data service interface
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/EnvService.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/EnvService.java
similarity index 83%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/EnvService.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/EnvService.java
index 3024da5..fdc617e 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/EnvService.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/EnvService.java
@@ -14,10 +14,10 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.service;
+package org.secretflow.easypsi.service;
-import org.secretflow.secretpad.common.constant.PlatformType;
-import org.secretflow.secretpad.common.dto.EnvDTO;
+import org.secretflow.easypsi.common.constant.PlatformType;
+import org.secretflow.easypsi.common.dto.EnvDTO;
/**
* @author beiwei
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/auth/DataResourceAuth.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/JobLogService.java
similarity index 71%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/auth/DataResourceAuth.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/JobLogService.java
index 0098c53..a2f79ec 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/auth/DataResourceAuth.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/JobLogService.java
@@ -13,15 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+package org.secretflow.easypsi.service;
-package org.secretflow.secretpad.service.auth;
-
-import org.secretflow.secretpad.common.constant.resource.DataResourceType;
+import java.util.List;
/**
* @author beiwei
- * @date 2023/9/11
+ * @date 2024/03/01
*/
-public interface DataResourceAuth {
- boolean check(DataResourceType resourceType, String resourceId);
+public interface JobLogService {
+ List queryJobLog(String jobId);
}
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/NodeRouterService.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/NodeRouterService.java
similarity index 79%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/NodeRouterService.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/NodeRouterService.java
index 801fff9..ca11e32 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/NodeRouterService.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/NodeRouterService.java
@@ -14,11 +14,11 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.service;
+package org.secretflow.easypsi.service;
-import org.secretflow.secretpad.service.model.noderoute.CreateNodeRouterRequest;
-import org.secretflow.secretpad.service.model.noderoute.NodeRouterVO;
-import org.secretflow.secretpad.service.model.noderoute.UpdateNodeRouterRequest;
+import org.secretflow.easypsi.service.model.noderoute.CreateNodeRouterRequest;
+import org.secretflow.easypsi.service.model.noderoute.NodeRouterVO;
+import org.secretflow.easypsi.service.model.noderoute.UpdateNodeRouterRequest;
import java.util.List;
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/NodeService.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/NodeService.java
similarity index 86%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/NodeService.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/NodeService.java
index 3350422..db9b8ad 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/NodeService.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/NodeService.java
@@ -14,10 +14,9 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.service;
-
-import org.secretflow.secretpad.service.model.node.*;
+package org.secretflow.easypsi.service;
+import org.secretflow.easypsi.service.model.node.*;
import org.secretflow.v1alpha1.kusciaapi.Domain;
import org.springframework.web.multipart.MultipartFile;
@@ -37,6 +36,14 @@ public interface NodeService {
*/
String createNode(CreateNodeRequest request);
+ /**
+ * update node
+ *
+ * @param request update node request
+ * @return nodeId
+ */
+ NodeVO updateNode(UpdateNodeRequest request);
+
/**
* Delete a node
*
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/ProjectService.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/ProjectService.java
similarity index 87%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/ProjectService.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/ProjectService.java
index 78197f3..8a678d0 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/ProjectService.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/ProjectService.java
@@ -14,14 +14,14 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.service;
+package org.secretflow.easypsi.service;
-import org.secretflow.secretpad.common.dto.DownloadInfo;
-import org.secretflow.secretpad.service.model.common.SecretPadPageResponse;
-import org.secretflow.secretpad.service.model.graph.GrapDataHeaderVO;
-import org.secretflow.secretpad.service.model.graph.GrapDataTableVO;
-import org.secretflow.secretpad.service.model.graph.GraphNodeJobLogsVO;
-import org.secretflow.secretpad.service.model.project.*;
+import org.secretflow.easypsi.common.dto.DownloadInfo;
+import org.secretflow.easypsi.service.model.common.EasyPsiPageResponse;
+import org.secretflow.easypsi.service.model.graph.GrapDataHeaderVO;
+import org.secretflow.easypsi.service.model.graph.GrapDataTableVO;
+import org.secretflow.easypsi.service.model.graph.GraphNodeJobLogsVO;
+import org.secretflow.easypsi.service.model.project.*;
import java.util.List;
@@ -39,7 +39,7 @@ public interface ProjectService {
* @param projectId list project job request
* @return page response of project job view object
*/
- SecretPadPageResponse listProjectJob(ListProjectJobRequest projectId);
+ EasyPsiPageResponse listProjectJob(ListProjectJobRequest projectId);
/**
* Query project job by projectId and jobId
@@ -121,12 +121,6 @@ public interface ProjectService {
*/
void createKusciaJob(CreateProjectJobTaskRequest request);
- /**
- * Reject the project job by reject project job task request
- *
- * @param request
- */
- void rejectJob(RejectProjectJobTaskRequest request);
/**
* Synchronize host node project jobs
@@ -135,6 +129,21 @@ public interface ProjectService {
*/
void syncHostNodeProjectJobs(List jobs);
+ /**
+ * Query edge project jobs by request node id
+ *
+ * @param requestNodeId target request node id
+ * @return project job data object list
+ */
+ List queryEdgeProjectJobs(String requestNodeId);
+
+ /**
+ * Reject the project job by reject project job task request
+ *
+ * @param request
+ */
+ void rejectJob(RejectProjectJobTaskRequest request);
+
/**
* Download project result
*
@@ -149,14 +158,6 @@ public interface ProjectService {
*/
DownloadInfo getloadProjectResult(String hash);
- /**
- * Query edge project jobs by request node id
- *
- * @param requestNodeId target request node id
- * @return project job data object list
- */
- List queryEdgeProjectJobs(String requestNodeId);
-
/**
* Stop the project job by stop project job task request
*
@@ -178,4 +179,6 @@ public interface ProjectService {
*/
void pauseJob(StopProjectJobTaskRequest request);
+ List listProjectJobByBlackScreen(ListProjectJobRequest request);
+
}
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/RemoteRequestService.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/RemoteRequestService.java
similarity index 68%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/RemoteRequestService.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/RemoteRequestService.java
index 9d5a72a..5143aab 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/RemoteRequestService.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/RemoteRequestService.java
@@ -13,9 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.secretflow.secretpad.service;
+package org.secretflow.easypsi.service;
-import org.secretflow.secretpad.service.model.common.SecretPadResponse;
+import org.secretflow.easypsi.service.model.common.EasyPsiResponse;
import java.util.concurrent.Future;
@@ -26,7 +26,9 @@
public interface RemoteRequestService {
boolean checkBothSidesNodeRouteIsReady(String srcNodeId, String dstNodeId);
- SecretPadResponse sendPostJson(Object request, String partnerNodeId, String url);
+ EasyPsiResponse sendPostJson(Object request, String partnerNodeId, String url);
- Future asyncSendPostJson(Object request, String partnerNodeId, String url);
+ Future asyncSendPostJson(Object request, String partnerNodeId, String url);
+
+ Future asynCheckBothSidesNodeRouteIsReady(String srcNodeId, String dstNodeId);
}
diff --git a/secretpad-manager/src/test/java/org/secretflow/secretpad/manager/integration/node/NodeManagerTest.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/RsaEncryptionKeyService.java
similarity index 60%
rename from secretpad-manager/src/test/java/org/secretflow/secretpad/manager/integration/node/NodeManagerTest.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/RsaEncryptionKeyService.java
index f29d3d3..bfb9523 100644
--- a/secretpad-manager/src/test/java/org/secretflow/secretpad/manager/integration/node/NodeManagerTest.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/RsaEncryptionKeyService.java
@@ -14,21 +14,27 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.manager.integration.node;
+package org.secretflow.easypsi.service;
-import org.assertj.core.api.Assertions;
-import org.junit.jupiter.api.Test;
+import org.secretflow.easypsi.persistence.entity.RsaEncryptionKeyDO;
/**
- * @author beiwei
- * @date 2023/9/11
+ * Rsa encryption key service
+ *
+ * @author lihaixin
+ * @date 2024/02/04
*/
-class NodeManagerTest {
-
- @Test
- void genDomainId() {
- NodeManager nodeManager = new NodeManager(null, null, null);
- String s = nodeManager.genDomainId();
- Assertions.assertThat(s).hasSize(8);
- }
+public interface RsaEncryptionKeyService {
+
+
+
+ /**
+ * Find by public key
+ *
+ * @param publicKey
+ * @return {@link RsaEncryptionKeyDO }
+ */
+
+ RsaEncryptionKeyDO findByPublicKey(String publicKey);
+
}
\ No newline at end of file
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/SysResourcesBizService.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/SysResourcesBizService.java
similarity index 80%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/SysResourcesBizService.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/SysResourcesBizService.java
index 5fb057e..71f3c08 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/SysResourcesBizService.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/SysResourcesBizService.java
@@ -14,11 +14,11 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.service;
+package org.secretflow.easypsi.service;
-import org.secretflow.secretpad.common.constant.PermissionUserType;
-import org.secretflow.secretpad.common.constant.ResourceType;
-import org.secretflow.secretpad.persistence.entity.SysResourceDO;
+import org.secretflow.easypsi.common.constant.PermissionUserType;
+import org.secretflow.easypsi.common.constant.ResourceType;
+import org.secretflow.easypsi.persistence.entity.SysResourceDO;
import java.util.List;
import java.util.Set;
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/UserService.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/UserService.java
similarity index 77%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/UserService.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/UserService.java
index 8812dcd..b6a7a27 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/UserService.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/UserService.java
@@ -14,10 +14,10 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.service;
+package org.secretflow.easypsi.service;
-import org.secretflow.secretpad.persistence.entity.AccountsDO;
-import org.secretflow.secretpad.service.model.auth.UserUpdatePwdRequest;
+import org.secretflow.easypsi.persistence.entity.AccountsDO;
+import org.secretflow.easypsi.service.model.auth.UserUpdatePwdRequest;
/**
* User service interface
@@ -44,28 +44,21 @@ public interface UserService {
AccountsDO getUserByName(String userName);
-
/**
- * user lock
+ * Get user by userName
*
- * @param accountsDO
+ * @param userName
+ * @return {@link AccountsDO }
*/
-
- void userLock(AccountsDO accountsDO);
+ AccountsDO queryUserByName(String userName);
/**
- * user unlock
+ * user lock
*
* @param accountsDO
*/
- void userUnlock(AccountsDO accountsDO);
-
- /**
- * Get locked user
- * @return {@link AccountsDO }
- */
+ void userLock(AccountsDO accountsDO);
- AccountsDO findLockedUser();
}
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/auth/InterfaceResourceAuth.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/auth/InterfaceResourceAuth.java
similarity index 93%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/auth/InterfaceResourceAuth.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/auth/InterfaceResourceAuth.java
index abf1354..9b179d0 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/auth/InterfaceResourceAuth.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/auth/InterfaceResourceAuth.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.service.auth;
+package org.secretflow.easypsi.service.auth;
/**
* @author beiwei
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/auth/impl/DefaultInterfaceResourceAuth.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/auth/impl/DefaultInterfaceResourceAuth.java
similarity index 82%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/auth/impl/DefaultInterfaceResourceAuth.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/auth/impl/DefaultInterfaceResourceAuth.java
index 1003688..451883a 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/auth/impl/DefaultInterfaceResourceAuth.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/auth/impl/DefaultInterfaceResourceAuth.java
@@ -14,12 +14,12 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.service.auth.impl;
+package org.secretflow.easypsi.service.auth.impl;
-import org.secretflow.secretpad.common.constant.resource.InterfaceResourceCode;
-import org.secretflow.secretpad.common.util.UserContext;
-import org.secretflow.secretpad.service.EnvService;
-import org.secretflow.secretpad.service.auth.InterfaceResourceAuth;
+import org.secretflow.easypsi.common.constant.resource.InterfaceResourceCode;
+import org.secretflow.easypsi.common.util.UserContext;
+import org.secretflow.easypsi.service.EnvService;
+import org.secretflow.easypsi.service.auth.InterfaceResourceAuth;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/configuration/ServiceConfiguration.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/configuration/ServiceConfiguration.java
similarity index 60%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/configuration/ServiceConfiguration.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/configuration/ServiceConfiguration.java
index 8e82f30..d6e814e 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/configuration/ServiceConfiguration.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/configuration/ServiceConfiguration.java
@@ -14,19 +14,14 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.service.configuration;
+package org.secretflow.easypsi.service.configuration;
-import org.secretflow.secretpad.service.factory.JsonProtobufSourceFactory;
-import org.secretflow.secretpad.service.graph.JobChain;
-import org.secretflow.secretpad.service.graph.chain.AbstractJobHandler;
-
-import org.secretflow.proto.component.Comp;
-import org.springframework.beans.factory.annotation.Value;
+import org.secretflow.easypsi.service.graph.JobChain;
+import org.secretflow.easypsi.service.graph.chain.AbstractJobHandler;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
-import java.io.IOException;
import java.util.List;
/**
@@ -38,17 +33,6 @@
@EnableScheduling
@Configuration
public class ServiceConfiguration {
- /**
- * Load components from locations
- *
- * @return component list
- * @throws IOException
- */
- @Bean
- List components(@Value("${component.spec.location:./config/components}") String componentLocation) throws IOException {
- JsonProtobufSourceFactory factory = new JsonProtobufSourceFactory(new String[]{componentLocation});
- return factory.load();
- }
/**
* Job chain for all job handlers
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/constant/ComponentConstants.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/constant/ComponentConstants.java
similarity index 86%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/constant/ComponentConstants.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/constant/ComponentConstants.java
index 7c58a95..c84d6a7 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/constant/ComponentConstants.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/constant/ComponentConstants.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.service.constant;
+package org.secretflow.easypsi.service.constant;
/**
* Component Constants
@@ -24,5 +24,5 @@
*/
public class ComponentConstants {
- public static final String SECRETPAD = "secretpad";
+ public static final String EASYPSI = "easypsi";
}
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/constant/Constants.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/constant/Constants.java
similarity index 94%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/constant/Constants.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/constant/Constants.java
index 2d9c742..669fa4a 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/constant/Constants.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/constant/Constants.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.service.constant;
+package org.secretflow.easypsi.service.constant;
/**
* Constants
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/constant/JobConstants.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/constant/JobConstants.java
similarity index 93%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/constant/JobConstants.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/constant/JobConstants.java
index 74a702d..34f955e 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/constant/JobConstants.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/constant/JobConstants.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.service.constant;
+package org.secretflow.easypsi.service.constant;
/**
* Job Constants
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/graph/JobChain.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/graph/JobChain.java
similarity index 91%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/graph/JobChain.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/graph/JobChain.java
index 14bc650..e9077f3 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/graph/JobChain.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/graph/JobChain.java
@@ -14,9 +14,9 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.service.graph;
+package org.secretflow.easypsi.service.graph;
-import org.secretflow.secretpad.service.graph.chain.AbstractJobHandler;
+import org.secretflow.easypsi.service.graph.chain.AbstractJobHandler;
import java.util.List;
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/graph/chain/AbstractJobHandler.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/graph/chain/AbstractJobHandler.java
similarity index 97%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/graph/chain/AbstractJobHandler.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/graph/chain/AbstractJobHandler.java
index c8f1941..eb84b47 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/graph/chain/AbstractJobHandler.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/graph/chain/AbstractJobHandler.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.service.graph.chain;
+package org.secretflow.easypsi.service.graph.chain;
import org.springframework.core.Ordered;
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/graph/chain/JobPersistentHandler.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/graph/chain/JobPersistentHandler.java
similarity index 84%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/graph/chain/JobPersistentHandler.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/graph/chain/JobPersistentHandler.java
index b91a69d..2596b73 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/graph/chain/JobPersistentHandler.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/graph/chain/JobPersistentHandler.java
@@ -14,11 +14,11 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.service.graph.chain;
+package org.secretflow.easypsi.service.graph.chain;
-import org.secretflow.secretpad.manager.integration.job.JobManager;
-import org.secretflow.secretpad.persistence.repository.ProjectJobRepository;
-import org.secretflow.secretpad.service.model.graph.ProjectPsiJob;
+import org.secretflow.easypsi.manager.integration.job.JobManager;
+import org.secretflow.easypsi.persistence.repository.ProjectJobRepository;
+import org.secretflow.easypsi.service.model.graph.ProjectPsiJob;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/graph/chain/JobRenderHandler.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/graph/chain/JobRenderHandler.java
similarity index 85%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/graph/chain/JobRenderHandler.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/graph/chain/JobRenderHandler.java
index 670e309..8ec3c6f 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/graph/chain/JobRenderHandler.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/graph/chain/JobRenderHandler.java
@@ -14,9 +14,9 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.service.graph.chain;
+package org.secretflow.easypsi.service.graph.chain;
-import org.secretflow.secretpad.service.model.graph.ProjectPsiJob;
+import org.secretflow.easypsi.service.model.graph.ProjectPsiJob;
import org.springframework.stereotype.Component;
@@ -29,7 +29,7 @@
@Component
public class JobRenderHandler extends AbstractJobHandler {
/**
- * Render job inputs, outputs and prune the secretpad component job
+ * Render job inputs, outputs and prune the easypsi component job
*
* @param job target job
*/
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/graph/chain/JobSubmittedHandler.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/graph/chain/JobSubmittedHandler.java
similarity index 84%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/graph/chain/JobSubmittedHandler.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/graph/chain/JobSubmittedHandler.java
index beb1f41..699f7db 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/graph/chain/JobSubmittedHandler.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/graph/chain/JobSubmittedHandler.java
@@ -14,11 +14,11 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.service.graph.chain;
+package org.secretflow.easypsi.service.graph.chain;
-import org.secretflow.secretpad.manager.integration.job.AbstractJobManager;
-import org.secretflow.secretpad.service.graph.converter.KusciaJobConverter;
-import org.secretflow.secretpad.service.model.graph.ProjectPsiJob;
+import org.secretflow.easypsi.manager.integration.job.AbstractJobManager;
+import org.secretflow.easypsi.service.graph.converter.KusciaJobConverter;
+import org.secretflow.easypsi.service.model.graph.ProjectPsiJob;
import org.secretflow.v1alpha1.kusciaapi.Job;
import org.springframework.beans.factory.annotation.Autowired;
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/graph/converter/JobConverter.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/graph/converter/JobConverter.java
similarity index 95%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/graph/converter/JobConverter.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/graph/converter/JobConverter.java
index 18974b2..087abdd 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/graph/converter/JobConverter.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/graph/converter/JobConverter.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.service.graph.converter;
+package org.secretflow.easypsi.service.graph.converter;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/graph/converter/KusciaJobConverter.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/graph/converter/KusciaJobConverter.java
similarity index 84%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/graph/converter/KusciaJobConverter.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/graph/converter/KusciaJobConverter.java
index ee2aa67..9506f5d 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/graph/converter/KusciaJobConverter.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/graph/converter/KusciaJobConverter.java
@@ -14,12 +14,13 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.service.graph.converter;
+package org.secretflow.easypsi.service.graph.converter;
-import org.secretflow.secretpad.common.util.ProtoUtils;
-import org.secretflow.secretpad.service.constant.JobConstants;
-import org.secretflow.secretpad.service.model.graph.ProjectPsiJob;
-import org.secretflow.secretpad.service.model.project.CreateProjectJobTaskRequest;
+import org.secretflow.easypsi.common.util.ProtoUtils;
+import org.secretflow.easypsi.service.EnvService;
+import org.secretflow.easypsi.service.constant.JobConstants;
+import org.secretflow.easypsi.service.model.graph.ProjectPsiJob;
+import org.secretflow.easypsi.service.model.project.CreateProjectJobTaskRequest;
import com.google.protobuf.util.JsonFormat;
import lombok.extern.slf4j.Slf4j;
@@ -29,6 +30,7 @@
import org.secretflow.proto.kuscia.PsiConfig;
import org.secretflow.proto.kuscia.PsiTaskConfig;
import org.secretflow.v1alpha1.kusciaapi.Job;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@@ -54,6 +56,9 @@ public class KusciaJobConverter implements JobConverter {
@Value("${job.max-parallelism:1}")
private int maxParallelism;
+ @Autowired
+ private EnvService envService;
+
/**
* Converter create job request from project job
@@ -98,8 +103,15 @@ private String renderPsiTaskInputConfig(ProjectPsiJob job) {
CreateProjectJobTaskRequest.PsiConfig partnerConfig = job.getPartnerConfig();
CreateProjectJobTaskRequest.PsiConfig initiatorConfig = job.getInitiatorConfig();
- PsiTaskConfig.PsiConfig partnerInputConfig = getInputConfig(partnerConfig);
- PsiTaskConfig.PsiConfig initiatorInputConfig = getInputConfig(initiatorConfig);
+
+
+ org.secretflow.easypsi.common.constant.JobConstants.RoleEnum role =
+ initiatorConfig.getLeftSide().equals(initiatorConfig.getNodeId()) ? initiatorConfig.getProtocolConfig().getRole() : partnerConfig.getProtocolConfig().getRole() ;
+
+ PsiTaskConfig.PsiConfig partnerInputConfig = getInputConfig(partnerConfig,role);
+ PsiTaskConfig.PsiConfig initiatorInputConfig = getInputConfig(initiatorConfig,role);
+
+
PsiTaskConfig.ContextDescProto PartcontextDescProto = PsiTaskConfig.ContextDescProto.newBuilder()
.setRecvTimeoutMs(Long.parseLong(partnerConfig.getLinkConfig().getRecvTimeoutMs()) * 1000)
@@ -129,21 +141,21 @@ private String renderPsiTaskInputConfig(ProjectPsiJob job) {
}
@NotNull
- private static PsiTaskConfig.PsiConfig getInputConfig(CreateProjectJobTaskRequest.PsiConfig psiConfig) {
+ private PsiTaskConfig.PsiConfig getInputConfig(CreateProjectJobTaskRequest.PsiConfig psiConfig, org.secretflow.easypsi.common.constant.JobConstants.RoleEnum role) {
CreateProjectJobTaskRequest.PsiConfig.ProtocolConfig psiProtocolConfig = psiConfig.getProtocolConfig();
PsiTaskConfig.ProtocolConfig protocolConfig = PsiTaskConfig.ProtocolConfig.newBuilder()
.setProtocol(PsiTaskConfig.Protocol.valueOf(psiProtocolConfig.getProtocol().name()))
.setRole(PsiTaskConfig.Role.valueOf(psiProtocolConfig.getRole().name()))
.setBroadcastResult(psiProtocolConfig.getBroadcastResult())
- .setEcdhConfig( PsiTaskConfig.EcdhConfig.newBuilder().setCurve(
- ObjectUtils.isEmpty(psiProtocolConfig.getEcdhConfig()) ? PsiConfig.CurveType.valueOf(org.secretflow.secretpad.common.constant.JobConstants.CurveType.CURVE_FOURQ.name())
- :PsiConfig.CurveType.valueOf(psiProtocolConfig.getEcdhConfig().getCurve())))
+ .setEcdhConfig(PsiTaskConfig.EcdhConfig.newBuilder().setCurve(
+ ObjectUtils.isEmpty(psiProtocolConfig.getEcdhConfig()) ? PsiConfig.CurveType.valueOf(org.secretflow.easypsi.common.constant.JobConstants.CurveType.CURVE_FOURQ.name())
+ : PsiConfig.CurveType.valueOf(psiProtocolConfig.getEcdhConfig().getCurve())))
.setKkrtConfig(PsiTaskConfig.KkrtConfig.newBuilder().setBucketSize(
- ObjectUtils.isEmpty(psiProtocolConfig.getKkrtConfig()) ? Long.parseLong(org.secretflow.secretpad.common.constant.JobConstants.BUCKET_SIZE)
+ ObjectUtils.isEmpty(psiProtocolConfig.getKkrtConfig()) ? Long.parseLong(org.secretflow.easypsi.common.constant.JobConstants.BUCKET_SIZE)
: Long.parseLong(psiProtocolConfig.getKkrtConfig().getBucketSize())))
.setRr22Config(PsiTaskConfig.Rr22Config.newBuilder()
- .setBucketSize(ObjectUtils.isEmpty(psiProtocolConfig.getRr22Config()) ? Long.parseLong(org.secretflow.secretpad.common.constant.JobConstants.BUCKET_SIZE)
+ .setBucketSize(ObjectUtils.isEmpty(psiProtocolConfig.getRr22Config()) ? Long.parseLong(org.secretflow.easypsi.common.constant.JobConstants.BUCKET_SIZE)
: Long.parseLong(psiProtocolConfig.getRr22Config().getBucketSize()))
.setLowCommMode(!ObjectUtils.isEmpty(psiProtocolConfig.getRr22Config()) && psiProtocolConfig.getRr22Config().getLowCommMode()))
.build();
@@ -166,12 +178,7 @@ private static PsiTaskConfig.PsiConfig getInputConfig(CreateProjectJobTaskReques
.setFolder(psiRecoveryConfig.getFolder())
.build();
log.debug("get input config psi recovery config:{}", psiRecoveryConfig);
- String advancedJoinType;
- if (psiConfig.getOutputDifference()) {
- advancedJoinType = org.secretflow.secretpad.common.constant.JobConstants.AdvancedJoinTypeEnum.ADVANCED_JOIN_TYPE_DIFFERENCE.name();
- } else {
- advancedJoinType = psiConfig.getAdvancedJoinType().name();
- }
+
PsiTaskConfig.PsiConfig receiverInputConfig = PsiTaskConfig.PsiConfig.newBuilder()
.setProtocolConfig(protocolConfig)
.setInputConfig(inputConfig)
@@ -180,8 +187,8 @@ private static PsiTaskConfig.PsiConfig getInputConfig(CreateProjectJobTaskReques
.setSkipDuplicatesCheck(!psiConfig.getSkipDuplicatesCheck())
.setDisableAlignment(!psiConfig.getDisableAlignment())
.setRecoveryConfig(recoveryConfig)
- .setAdvancedJoinType(PsiTaskConfig.PsiConfig.AdvancedJoinType.valueOf(advancedJoinType))
- .setLeftSide(PsiTaskConfig.Role.valueOf(org.secretflow.secretpad.common.constant.JobConstants.LEFT_SIDE))
+ .setAdvancedJoinType(PsiTaskConfig.PsiConfig.AdvancedJoinType.valueOf(psiConfig.getAdvancedJoinType().name()))
+ .setLeftSide(PsiTaskConfig.Role.valueOf(role.name()))
.build();
log.debug("get input config receiver input config:{}", receiverInputConfig);
return receiverInputConfig;
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/impl/AuthServiceImpl.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/impl/AuthServiceImpl.java
similarity index 71%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/impl/AuthServiceImpl.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/impl/AuthServiceImpl.java
index 0d2ecb4..cf0d140 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/impl/AuthServiceImpl.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/impl/AuthServiceImpl.java
@@ -14,49 +14,49 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.service.impl;
-
-import org.secretflow.secretpad.common.constant.ResourceType;
-import org.secretflow.secretpad.common.dto.UserContextDTO;
-import org.secretflow.secretpad.common.errorcode.AuthErrorCode;
-import org.secretflow.secretpad.common.exception.SecretpadException;
-import org.secretflow.secretpad.common.util.DateTimes;
-import org.secretflow.secretpad.common.util.Sha256Utils;
-import org.secretflow.secretpad.common.util.UUIDUtils;
-import org.secretflow.secretpad.manager.integration.fabric.FabricManager;
-import org.secretflow.secretpad.persistence.entity.AccountsDO;
-import org.secretflow.secretpad.persistence.entity.FabricLogDO;
-import org.secretflow.secretpad.persistence.entity.ProjectJobDO;
-import org.secretflow.secretpad.persistence.entity.TokensDO;
-import org.secretflow.secretpad.persistence.repository.FabricLogRepository;
-import org.secretflow.secretpad.persistence.repository.ProjectJobRepository;
-import org.secretflow.secretpad.persistence.repository.UserAccountsRepository;
-import org.secretflow.secretpad.persistence.repository.UserTokensRepository;
-import org.secretflow.secretpad.service.AuthService;
-import org.secretflow.secretpad.service.EnvService;
-import org.secretflow.secretpad.service.SysResourcesBizService;
-import org.secretflow.secretpad.service.UserService;
+package org.secretflow.easypsi.service.impl;
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.encoder.PatternLayoutEncoder;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.rolling.RollingFileAppender;
import ch.qos.logback.core.rolling.TimeBasedRollingPolicy;
+import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
+import org.secretflow.easypsi.common.constant.CacheConstants;
+import org.secretflow.easypsi.common.constant.ResourceType;
+import org.secretflow.easypsi.common.dto.UserContextDTO;
+import org.secretflow.easypsi.common.errorcode.AuthErrorCode;
+import org.secretflow.easypsi.common.exception.EasyPsiException;
+import org.secretflow.easypsi.common.util.DateTimes;
+import org.secretflow.easypsi.common.util.RsaUtils;
+import org.secretflow.easypsi.common.util.Sha256Utils;
+import org.secretflow.easypsi.common.util.UUIDUtils;
+import org.secretflow.easypsi.manager.integration.fabric.FabricManager;
+import org.secretflow.easypsi.persistence.entity.*;
+import org.secretflow.easypsi.persistence.repository.FabricLogRepository;
+import org.secretflow.easypsi.persistence.repository.ProjectJobRepository;
+import org.secretflow.easypsi.persistence.repository.UserAccountsRepository;
+import org.secretflow.easypsi.persistence.repository.UserTokensRepository;
+import org.secretflow.easypsi.service.*;
+import org.secretflow.easypsi.service.model.auth.LoginRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
+import org.springframework.cache.Cache;
+import org.springframework.cache.CacheManager;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.io.File;
-import java.time.Duration;
import java.time.LocalDateTime;
+import java.util.HashMap;
import java.util.List;
import java.util.Objects;
import java.util.Set;
@@ -91,10 +91,10 @@ public class AuthServiceImpl implements AuthService {
@Autowired
private ProjectJobRepository projectJobRepository;
- @Value("${secretpad.account-error-max-attempts:5}")
+ @Value("${easypsi.account-error-max-attempts:5}")
private Integer maxAttempts;
- @Value("${secretpad.account-error-lock-time-minutes:30}")
+ @Value("${easypsi.account-error-lock-time-minutes:30}")
private Integer lockTimeMinutes;
@Autowired
@@ -103,15 +103,29 @@ public class AuthServiceImpl implements AuthService {
@Autowired
private FabricLogRepository fabricLogRepository;
+ @Autowired
+ private RsaEncryptionKeyService rsaEncryptionKeyService;
+
@Autowired(required = false)
@Qualifier("fabricThreadPool")
private ThreadPoolTaskExecutor threadPoolTaskExecutor;
+ @Resource
+ private CacheManager cacheManager;
+
@Override
- @Transactional(rollbackFor = Exception.class, noRollbackFor = SecretpadException.class)
- public UserContextDTO login(String name, String passwordHash) {
+ @Transactional(rollbackFor = Exception.class, noRollbackFor = EasyPsiException.class)
+ public UserContextDTO login(LoginRequest request) {
+ String passwordHash = request.getPasswordHash();
+ if (StringUtils.isNotBlank(request.getPublicKey())) {
+ RsaEncryptionKeyDO rsaEncryptionKeyDO = rsaEncryptionKeyService.findByPublicKey(request.getPublicKey());
+ if (Objects.nonNull(rsaEncryptionKeyDO)) {
+ passwordHash = RsaUtils.decrypt(passwordHash, rsaEncryptionKeyDO.getPrivateKey());
+ }
+ }
+
//check password and lock
- AccountsDO user = accountLockedCheck(name, passwordHash);
+ AccountsDO user = accountLockedCheck(request.getName(), passwordHash);
String token = UUIDUtils.newUUID();
UserContextDTO userContextDTO = new UserContextDTO();
@@ -125,6 +139,8 @@ public UserContextDTO login(String name, String passwordHash) {
// fill resource codes
List jobDOS = projectJobRepository.findByNodeId(user.getOwnerId());
userContextDTO.setNoviceUser(CollectionUtils.isEmpty(jobDOS));
+ // Determine whether the user has modified the password
+ userContextDTO.setInitial(user.getInitial());
Set resourceCodeSet = resourcesBizService.queryResourceCodeByUserName(user.getOwnerType().toPermissionUserType(), ResourceType.INTERFACE, user.getName());
userContextDTO.setInterfaceResources(resourceCodeSet);
@@ -222,26 +238,25 @@ private static void truncateLog(FabricLogDO fabricLogDO) {
* @param userName
*/
private AccountsDO accountLockedCheck(String userName, String passwordHash) {
-
LocalDateTime currentTime = LocalDateTime.now();
- AccountsDO lockedUser = userService.findLockedUser();
- //check all user locked
- if (Objects.nonNull(lockedUser)) {
- Duration duration = Duration.between(currentTime, lockedUser.getLockedInvalidTime());
- Long minutes = duration.toMinutes();
- if (minutes <= 0) {
- //lock invalid
- lockedUser.setGmtModified(LocalDateTime.now());
- lockedUser.setLockedInvalidTime(null);
- lockedUser.setFailedAttempts(null);
- userAccountsRepository.save(lockedUser);
+ //current user is need lock
+ AccountsDO user = userService.queryUserByName(userName);
+ if (ObjectUtils.isEmpty(user)) {
+ Cache cache = cacheManager.getCache(CacheConstants.USER_LOCK_CACHE);
+ HashMap lockInfo = cache.get(userName, HashMap.class);
+ int failedAttempts = 0;
+ if (lockInfo != null) {
+ failedAttempts = lockInfo.get("failedAttempts");
+ if (failedAttempts >= maxAttempts) {
+ throw EasyPsiException.of(AuthErrorCode.USER_IS_LOCKED, String.valueOf(lockTimeMinutes));
+ }
} else {
- throw SecretpadException.of(AuthErrorCode.USER_IS_LOCKED, String.valueOf(minutes));
+ lockInfo = new HashMap<>();
}
+ lockInfo.put("failedAttempts", ++failedAttempts);
+ cache.put(userName, lockInfo);
+ throw EasyPsiException.of(AuthErrorCode.USER_PASSWORD_ERROR, String.valueOf(maxAttempts - --failedAttempts));
}
-
- //current user is need lock
- AccountsDO user = userService.getUserByName(userName);
//checkPassword success
if (user.getPasswordHash().equals(passwordHash)) {
//lock invalid
@@ -255,10 +270,10 @@ private AccountsDO accountLockedCheck(String userName, String passwordHash) {
if (user.getFailedAttempts() >= maxAttempts) {
user.setLockedInvalidTime(currentTime.plusMinutes(lockTimeMinutes));
userService.userLock(user);
- throw SecretpadException.of(AuthErrorCode.USER_IS_LOCKED, String.valueOf(lockTimeMinutes));
+ throw EasyPsiException.of(AuthErrorCode.USER_IS_LOCKED, String.valueOf(lockTimeMinutes));
}
userService.userLock(user);
- throw SecretpadException.of(AuthErrorCode.USER_PASSWORD_ERROR, String.valueOf(maxAttempts - user.getFailedAttempts()));
+ throw EasyPsiException.of(AuthErrorCode.USER_PASSWORD_ERROR, String.valueOf(maxAttempts - user.getFailedAttempts()));
}
}
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/impl/DataServiceImpl.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/impl/DataServiceImpl.java
similarity index 66%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/impl/DataServiceImpl.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/impl/DataServiceImpl.java
index b98f21a..7769e10 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/impl/DataServiceImpl.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/impl/DataServiceImpl.java
@@ -14,37 +14,32 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.service.impl;
-
-
-import org.secretflow.secretpad.common.errorcode.DataErrorCode;
-import org.secretflow.secretpad.common.exception.SecretpadException;
-import org.secretflow.secretpad.common.util.FileUtils;
-import org.secretflow.secretpad.common.util.JsonUtils;
-import org.secretflow.secretpad.manager.integration.job.AbstractJobManager;
-import org.secretflow.secretpad.manager.integration.job.JobManager;
-import org.secretflow.secretpad.service.DataService;
-import org.secretflow.secretpad.service.EnvService;
-import org.secretflow.secretpad.service.RemoteRequestService;
-import org.secretflow.secretpad.service.model.common.SecretPadResponse;
-import org.secretflow.secretpad.service.model.data.DataSourceVO;
-import org.secretflow.secretpad.service.model.data.DataTableInformationVo;
-import org.secretflow.secretpad.service.model.data.DataVersionVO;
-import org.secretflow.secretpad.service.model.data.GetDataTableInformatinoRequest;
+package org.secretflow.easypsi.service.impl;
+
import org.apache.commons.lang3.ObjectUtils;
+import org.secretflow.easypsi.common.errorcode.DataErrorCode;
+import org.secretflow.easypsi.common.exception.EasyPsiException;
+import org.secretflow.easypsi.common.util.FileUtils;
+import org.secretflow.easypsi.common.util.JsonUtils;
+import org.secretflow.easypsi.manager.integration.data.DataManager;
+import org.secretflow.easypsi.manager.integration.job.AbstractJobManager;
+import org.secretflow.easypsi.manager.integration.job.JobManager;
+import org.secretflow.easypsi.service.DataService;
+import org.secretflow.easypsi.service.EnvService;
+import org.secretflow.easypsi.service.RemoteRequestService;
+import org.secretflow.easypsi.service.model.common.EasyPsiResponse;
+import org.secretflow.easypsi.service.model.data.DataSourceVO;
+import org.secretflow.easypsi.service.model.data.DataTableInformationVo;
+import org.secretflow.easypsi.service.model.data.DataVersionVO;
+import org.secretflow.easypsi.service.model.data.GetDataTableInformatinoRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
-import org.springframework.scheduling.annotation.Async;
-import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Service;
-import java.io.BufferedReader;
import java.io.File;
-import java.io.IOException;
-import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;
@@ -64,19 +59,19 @@ public class DataServiceImpl implements DataService {
private final String VERSION_DEFAULT = "--";
- @Value("${secretpad.data.host-path:/home/kuscia/p2p/}")
+ @Value("${easypsi.data.host-path:/home/kuscia/p2p/}")
private String dataHostPath;
- @Value("${secretpad.version.secretpad-image:--}")
- private String secretpadImage;
+ @Value("${easypsi.version.easypsi-image:--}")
+ private String easypsiImage;
- @Value("${secretpad.version.kuscia-image:--}")
+ @Value("${easypsi.version.kuscia-image:--}")
private String kusciaImage;
- @Value("${secretpad.version.secretflow-image:--}")
+ @Value("${easypsi.version.secretflow-image:--}")
private String secretflowImage;
- @Value("${secretpad.gateway}")
+ @Value("${easypsi.gateway}")
private String gateway;
private static final String QUERY_DATA_TABLE_INFORMATION = "/api/v1alpha1/data/count/kuscia";
@@ -92,6 +87,9 @@ public class DataServiceImpl implements DataService {
@Autowired
private AbstractJobManager jobManager;
+ @Autowired
+ private DataManager dataManager;
+
@Override
public DataSourceVO queryDataPath() {
return DataSourceVO.builder().path(dataHostPath).build();
@@ -100,7 +98,7 @@ public DataSourceVO queryDataPath() {
@Override
public DataVersionVO queryDataVersion() {
return DataVersionVO.builder()
- .secretpadTag(getLastPart(secretpadImage, ":"))
+ .easypsiTag(getLastPart(easypsiImage, ":"))
.kusciaTag(getLastPart(kusciaImage, ":"))
.secretflowTag(getLastPart(secretflowImage, ":"))
.build();
@@ -108,23 +106,23 @@ public DataVersionVO queryDataVersion() {
@Override
public DataTableInformationVo queryDataTableInformation(GetDataTableInformatinoRequest request) {
- remoteRequestService.checkBothSidesNodeRouteIsReady(envService.getPlatformNodeId(), request.getDstNodeId());
+ remoteRequestService.asynCheckBothSidesNodeRouteIsReady(envService.getPlatformNodeId(), request.getDstNodeId());
checkDataTableName(request);
LOGGER.info("Asynchronously request the data table of the other party, request:{}", request);
- Future dataTableInformationFuture = remoteRequestService.asyncSendPostJson(request, request.getDstNodeId(), JobManager.HTTP_HEADER + gateway + QUERY_DATA_TABLE_INFORMATION);
+ Future dataTableInformationFuture = remoteRequestService.asyncSendPostJson(request, request.getDstNodeId(), JobManager.HTTP_HEADER + gateway + QUERY_DATA_TABLE_INFORMATION);
DataTableInformationVo.DataTableInformation srcDataTableInformation = getDataTabelInformation(request);
LOGGER.debug("Query our data table information, data table information: {}", srcDataTableInformation);
DataTableInformationVo.DataTableInformation dstDataTableInformation;
try {
- SecretPadResponse secretPadResponse = dataTableInformationFuture.get();
- LOGGER.debug("Query data information response: {},msg: {}", secretPadResponse.getData(), secretPadResponse.getStatus().getMsg());
- dstDataTableInformation = JsonUtils.toJavaObject(secretPadResponse.getData().toString(), DataTableInformationVo.DataTableInformation.class);
+ EasyPsiResponse easyPsiResponse = dataTableInformationFuture.get();
+ LOGGER.debug("Query data information response: {},msg: {}", easyPsiResponse.getData(), easyPsiResponse.getStatus().getMsg());
+ dstDataTableInformation = JsonUtils.toJavaObject(easyPsiResponse.getData().toString(), DataTableInformationVo.DataTableInformation.class);
LOGGER.debug("Query opposite data table information, data table information: {}", dstDataTableInformation);
dataTableCountCache.put(spliceNodeTable(dstDataTableInformation.getNodeId(), request.getDstDataTableName()), dstDataTableInformation.getDataTableCount());
} catch (ExecutionException | InterruptedException e) {
LOGGER.error("Querying opposite data table information is abnormal,opposite node id: {} error: {}", request.getDstDataTableName(), e.getMessage());
- throw SecretpadException.of(DataErrorCode.QUERY_DATA_ERROR, request.getDstDataTableName());
+ throw EasyPsiException.of(DataErrorCode.QUERY_DATA_ERROR, request.getDstDataTableName());
}
return DataTableInformationVo.builder()
.srcDataTableInformation(srcDataTableInformation)
@@ -143,13 +141,13 @@ public DataTableInformationVo.DataTableInformation getDataTabelInformation(GetDa
dataTableName = request.getSrcDataTableName();
}
String csvFilePath = JobManager.CSV_DATA_PATH + File.separator + dataTableName;
- Future dataLineFuture = countLinesByCommand(csvFilePath, dataTableName);
+ Future dataLineFuture = dataManager.countLinesByCommand(csvFilePath, dataTableName);
String dataLine;
try {
dataLine = dataLineFuture.get();
} catch (InterruptedException | ExecutionException e) {
LOGGER.error("data table read error, data table: {}", dataTableName);
- throw SecretpadException.of(DataErrorCode.QUERY_DATA_ERROR, dataTableName);
+ throw EasyPsiException.of(DataErrorCode.QUERY_DATA_ERROR, dataTableName);
}
long lineCount = Long.parseLong(Objects.requireNonNull(dataLine));
String dataInterval = getDataInterval(lineCount);
@@ -185,29 +183,6 @@ private String processString(String str) {
}
}
- @Async
- private Future countLinesByCommand(String filePath, String fileName) {
- BufferedReader reader = null;
- try {
- Process process = new ProcessBuilder("awk", "NR == 100000001 { print \"100000001\"; exit } END { if (NR < 100000001) print NR } ", filePath).start();
-
- reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
- return new AsyncResult<>(reader.readLine());
-
- } catch (IOException e) {
- LOGGER.error("data table read error, data table: {}", fileName);
- throw SecretpadException.of(DataErrorCode.QUERY_DATA_ERROR, fileName);
- } finally {
- if (!ObjectUtils.isEmpty(reader)) {
- try {
- reader.close();
- } catch (IOException e) {
- LOGGER.error("Close stream error", e);
- }
- }
- }
- }
-
private String getDataInterval(Long dataCount) {
if (dataCount < 0) {
return "L0";
@@ -238,17 +213,17 @@ private void checkDataTableName(GetDataTableInformatinoRequest request) {
List tableNames = FileUtils.traverseDirectories(new File(JobManager.CSV_DATA_PATH), ".csv", FileUtils.FILE_NAME);
if (tableNames == null) {
LOGGER.error("file to be verified not found:{}", request.getSrcDataTableName());
- throw SecretpadException.of(DataErrorCode.FILE_NOT_EXISTS_ERROR, request.getSrcDataTableName());
+ throw EasyPsiException.of(DataErrorCode.FILE_NOT_EXISTS_ERROR, request.getSrcDataTableName());
}
if (envService.getPlatformNodeId().equals(request.getDstNodeId())) {
if (!tableNames.contains(request.getDstDataTableName())) {
LOGGER.error("file to be verified not found:{}", request.getDstDataTableName());
- throw SecretpadException.of(DataErrorCode.FILE_NOT_EXISTS_ERROR, request.getDstDataTableName());
+ throw EasyPsiException.of(DataErrorCode.FILE_NOT_EXISTS_ERROR, request.getDstDataTableName());
}
} else {
if (!tableNames.contains(request.getSrcDataTableName())) {
LOGGER.error("file to be verified not found:{}", request.getSrcDataTableName());
- throw SecretpadException.of(DataErrorCode.FILE_NOT_EXISTS_ERROR, request.getSrcDataTableName());
+ throw EasyPsiException.of(DataErrorCode.FILE_NOT_EXISTS_ERROR, request.getSrcDataTableName());
}
}
}
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/impl/EnvServiceImpl.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/impl/EnvServiceImpl.java
similarity index 81%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/impl/EnvServiceImpl.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/impl/EnvServiceImpl.java
index fd854ca..13311d5 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/impl/EnvServiceImpl.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/impl/EnvServiceImpl.java
@@ -14,11 +14,11 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.service.impl;
+package org.secretflow.easypsi.service.impl;
-import org.secretflow.secretpad.common.constant.PlatformType;
-import org.secretflow.secretpad.common.dto.EnvDTO;
-import org.secretflow.secretpad.service.EnvService;
+import org.secretflow.easypsi.common.constant.PlatformType;
+import org.secretflow.easypsi.common.dto.EnvDTO;
+import org.secretflow.easypsi.service.EnvService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
@@ -29,10 +29,10 @@
*/
@Service
public class EnvServiceImpl implements EnvService {
- @Value("${secretpad.platform-type}")
+ @Value("${easypsi.platform-type}")
private String platformType;
- @Value("${secretpad.node-id}")
+ @Value("${easypsi.node-id}")
private String nodeId;
@Override
public PlatformType getPlatformType() {
diff --git a/easypsi-service/src/main/java/org/secretflow/easypsi/service/impl/JobLogLocalService.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/impl/JobLogLocalService.java
new file mode 100644
index 0000000..75cc2bb
--- /dev/null
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/impl/JobLogLocalService.java
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2023 Ant Group Co., Ltd.
+ *
+ * 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.
+ */
+package org.secretflow.easypsi.service.impl;
+
+import lombok.extern.slf4j.Slf4j;
+import org.secretflow.easypsi.common.util.FileUtils;
+import org.secretflow.easypsi.manager.integration.job.JobManager;
+import org.secretflow.easypsi.service.EnvService;
+import org.secretflow.easypsi.service.JobLogService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.util.ObjectUtils;
+
+import java.io.File;
+import java.io.FilenameFilter;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * @author beiwei
+ * @date 2024/03/01
+ */
+@Service
+//@ConditionalOnProperty(name = "easypsi.job-log.type", havingValue = "sls", matchIfMissing = true)
+@Slf4j
+public class JobLogLocalService implements JobLogService {
+ @Autowired
+ private EnvService envService;
+
+ @Override
+ public List queryJobLog(String jobId) {
+ return getProjectJobLogs(jobId);
+ }
+
+ private List getProjectJobLogs(String jobId) {
+ String directoryPath = JobManager.PROJECT_JOB_LOGS;
+ log.info("get project job logs check job id: {}", jobId);
+ FileUtils.fileNameCheck(jobId);
+ String pattern = envService.getPlatformNodeId() + "_" + jobId + "-0";
+ File directory = new File(directoryPath);
+ FilenameFilter filenameFilter = (dir, name) -> name.startsWith(pattern);
+ File[] matchingFiles = directory.listFiles(filenameFilter);
+ String fileName = null;
+ List projectJobLogs = new ArrayList<>();
+ long lastModified = 0L;
+ if (matchingFiles != null) {
+ for (File file : matchingFiles) {
+ if (file.lastModified() > lastModified) {
+ fileName = file.getName();
+ lastModified = file.lastModified();
+ }
+ }
+ }
+ List filePaths = FileUtils.traverseDirectories(new File(directoryPath + File.separator + fileName + File.separator + "secretflow"), ".log", FileUtils.FILE_PATH);
+ if (filePaths == null) {
+ log.warn("{} task log path not exit", jobId);
+ return Collections.emptyList();
+ }
+ try {
+ for (String filePath : filePaths) {
+ projectJobLogs.addAll(Files.lines(Paths.get(filePath)).collect(Collectors.toList()));
+ }
+ } catch (Exception e) {
+ log.error("{} task log not exit", jobId);
+ return Collections.emptyList();
+ }
+
+ if (ObjectUtils.isEmpty(fileName)) {
+ log.warn("{} task log not exit", jobId);
+ return Collections.emptyList();
+ }
+ return projectJobLogs;
+ }
+
+}
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/impl/NodeRouterServiceImpl.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/impl/NodeRouterServiceImpl.java
similarity index 80%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/impl/NodeRouterServiceImpl.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/impl/NodeRouterServiceImpl.java
index 12d6c0f..93d4e16 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/impl/NodeRouterServiceImpl.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/impl/NodeRouterServiceImpl.java
@@ -14,24 +14,24 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.service.impl;
+package org.secretflow.easypsi.service.impl;
-import org.secretflow.secretpad.common.constant.DomainRouterConstants;
-import org.secretflow.secretpad.common.errorcode.NodeRouteErrorCode;
-import org.secretflow.secretpad.common.exception.SecretpadException;
-import org.secretflow.secretpad.manager.integration.model.CreateNodeRouteParam;
-import org.secretflow.secretpad.manager.integration.model.UpdateNodeRouteParam;
-import org.secretflow.secretpad.manager.integration.node.NodeManager;
-import org.secretflow.secretpad.manager.integration.noderoute.AbstractNodeRouteManager;
-import org.secretflow.secretpad.manager.integration.noderoute.NodeRouteManager;
-import org.secretflow.secretpad.persistence.entity.NodeRouteDO;
-import org.secretflow.secretpad.persistence.repository.NodeRouteRepository;
-import org.secretflow.secretpad.service.EnvService;
-import org.secretflow.secretpad.service.NodeRouterService;
-import org.secretflow.secretpad.service.model.node.NodeVO;
-import org.secretflow.secretpad.service.model.noderoute.CreateNodeRouterRequest;
-import org.secretflow.secretpad.service.model.noderoute.NodeRouterVO;
-import org.secretflow.secretpad.service.model.noderoute.UpdateNodeRouterRequest;
+import org.secretflow.easypsi.common.constant.DomainRouterConstants;
+import org.secretflow.easypsi.common.errorcode.NodeRouteErrorCode;
+import org.secretflow.easypsi.common.exception.EasyPsiException;
+import org.secretflow.easypsi.manager.integration.model.CreateNodeRouteParam;
+import org.secretflow.easypsi.manager.integration.model.UpdateNodeRouteParam;
+import org.secretflow.easypsi.manager.integration.node.NodeManager;
+import org.secretflow.easypsi.manager.integration.noderoute.AbstractNodeRouteManager;
+import org.secretflow.easypsi.manager.integration.noderoute.NodeRouteManager;
+import org.secretflow.easypsi.persistence.entity.NodeRouteDO;
+import org.secretflow.easypsi.persistence.repository.NodeRouteRepository;
+import org.secretflow.easypsi.service.EnvService;
+import org.secretflow.easypsi.service.NodeRouterService;
+import org.secretflow.easypsi.service.model.node.NodeVO;
+import org.secretflow.easypsi.service.model.noderoute.CreateNodeRouterRequest;
+import org.secretflow.easypsi.service.model.noderoute.NodeRouterVO;
+import org.secretflow.easypsi.service.model.noderoute.UpdateNodeRouterRequest;
import lombok.extern.slf4j.Slf4j;
import org.secretflow.v1alpha1.kusciaapi.DomainRoute;
@@ -96,11 +96,11 @@ public void updateNodeRouter(UpdateNodeRouterRequest request) {
NodeRouteDO byRouteId = nodeRouteRepository.findByRouteId(Long.parseLong(request.getRouterId()));
if (ObjectUtils.isEmpty(byRouteId)) {
LOGGER.info("update router address error : route not exist");
- throw SecretpadException.of(NodeRouteErrorCode.NODE_ROUTE_NOT_EXIST_ERROR);
+ throw EasyPsiException.of(NodeRouteErrorCode.NODE_ROUTE_NOT_EXIST_ERROR);
}
if (nodeManager.checkNodeStatus(byRouteId.getDstNodeId())) {
LOGGER.info("update router address error : There are unfinished tasks that cannot be modified");
- throw SecretpadException.of(NodeRouteErrorCode.NODE_ROUTE_UPDATE_UNFINISHED_ERROR);
+ throw EasyPsiException.of(NodeRouteErrorCode.NODE_ROUTE_UPDATE_UNFINISHED_ERROR);
}
nodeRouteManager.updateNodeRoute(UpdateNodeRouteParam.builder()
.nodeRouteId(Long.parseLong(request.getRouterId()))
@@ -113,7 +113,7 @@ public NodeRouterVO getNodeRouter(Long routeId) {
NodeRouteDO byRouteId = nodeRouteRepository.findByRouteId(routeId);
if (ObjectUtils.isEmpty(byRouteId)) {
LOGGER.info("get node router error : route not exist");
- throw SecretpadException.of(NodeRouteErrorCode.NODE_ROUTE_NOT_EXIST_ERROR, "route not exist");
+ throw EasyPsiException.of(NodeRouteErrorCode.NODE_ROUTE_NOT_EXIST_ERROR, "route not exist");
}
NodeRouterVO nodeRouterVO = NodeRouterVO.fromDo(byRouteId);
nodeRouterVO.setSrcNode(NodeVO.from(nodeManager.getNode(nodeRouterVO.getSrcNodeId())));
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/impl/NodeServiceImpl.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/impl/NodeServiceImpl.java
similarity index 59%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/impl/NodeServiceImpl.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/impl/NodeServiceImpl.java
index bfbdfd7..6c7d966 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/impl/NodeServiceImpl.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/impl/NodeServiceImpl.java
@@ -14,43 +14,42 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.service.impl;
-
-import org.secretflow.secretpad.common.constant.PermissionTargetType;
-import org.secretflow.secretpad.common.constant.PermissionUserType;
-import org.secretflow.secretpad.common.constant.role.RoleCodeConstants;
-import org.secretflow.secretpad.common.errorcode.NodeErrorCode;
-import org.secretflow.secretpad.common.exception.SecretpadException;
-import org.secretflow.secretpad.common.util.FileUtils;
-import org.secretflow.secretpad.manager.integration.job.AbstractJobManager;
-import org.secretflow.secretpad.manager.integration.model.CreateNodeParam;
-import org.secretflow.secretpad.manager.integration.model.NodeCertificateDTO;
-import org.secretflow.secretpad.manager.integration.model.NodeDTO;
-import org.secretflow.secretpad.manager.integration.node.AbstractNodeManager;
-import org.secretflow.secretpad.manager.integration.noderoute.AbstractNodeRouteManager;
-import org.secretflow.secretpad.persistence.entity.NodeRouteDO;
-import org.secretflow.secretpad.persistence.entity.SysUserPermissionRelDO;
-import org.secretflow.secretpad.persistence.repository.NodeRouteRepository;
-import org.secretflow.secretpad.persistence.repository.SysUserPermissionRelRepository;
-import org.secretflow.secretpad.service.EnvService;
-import org.secretflow.secretpad.service.NodeRouterService;
-import org.secretflow.secretpad.service.NodeService;
-import org.secretflow.secretpad.service.model.node.*;
-import org.secretflow.secretpad.service.model.noderoute.CreateNodeRouterRequest;
+package org.secretflow.easypsi.service.impl;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
+import org.secretflow.easypsi.common.constant.PermissionTargetType;
+import org.secretflow.easypsi.common.constant.PermissionUserType;
+import org.secretflow.easypsi.common.constant.role.RoleCodeConstants;
+import org.secretflow.easypsi.common.errorcode.NodeErrorCode;
+import org.secretflow.easypsi.common.exception.EasyPsiException;
+import org.secretflow.easypsi.common.util.FileUtils;
+import org.secretflow.easypsi.manager.integration.job.AbstractJobManager;
+import org.secretflow.easypsi.manager.integration.model.CreateNodeParam;
+import org.secretflow.easypsi.manager.integration.model.NodeCertificateDTO;
+import org.secretflow.easypsi.manager.integration.model.NodeDTO;
+import org.secretflow.easypsi.manager.integration.model.UpdateNodeParam;
+import org.secretflow.easypsi.manager.integration.node.AbstractNodeManager;
+import org.secretflow.easypsi.manager.integration.noderoute.AbstractNodeRouteManager;
+import org.secretflow.easypsi.persistence.entity.NodeRouteDO;
+import org.secretflow.easypsi.persistence.entity.SysUserPermissionRelDO;
+import org.secretflow.easypsi.persistence.repository.NodeRouteRepository;
+import org.secretflow.easypsi.persistence.repository.SysUserPermissionRelRepository;
+import org.secretflow.easypsi.service.EnvService;
+import org.secretflow.easypsi.service.NodeRouterService;
+import org.secretflow.easypsi.service.NodeService;
+import org.secretflow.easypsi.service.model.node.*;
+import org.secretflow.easypsi.service.model.noderoute.CreateNodeRouterRequest;
import org.secretflow.v1alpha1.kusciaapi.Domain;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
-import java.io.FileNotFoundException;
+import java.io.ByteArrayInputStream;
import java.io.IOException;
-import java.io.InputStream;
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
@@ -89,43 +88,47 @@ public class NodeServiceImpl implements NodeService {
@Override
@Transactional(rollbackFor = Exception.class)
public String createNode(CreateNodeRequest request) {
+ nodeManager.checkNodeCert(request.getCertText());
+ String nodeId = getNodeIdFromX509Cert(parseCertificate(request.getCertText()));
+ log.info("create node id:{}", nodeId);
+ nodeManager.checkNodeId(envService.getPlatformNodeId(), nodeId);
CreateNodeParam param = CreateNodeParam.builder()
- .nodeId(request.getDstNodeId())
- .name(request.getDstNodeId())
+ .nodeId(nodeId)
+ .name(nodeId)
.netAddress(request.getDstNetAddress())
.certText(request.getCertText())
.nodeRemark(request.getNodeRemark())
+ .trust(request.getTrust())
.build();
- nodeManager.checkNodeCert(envService.getPlatformNodeId(), param);
- String nodeId = nodeManager.createNode(param);
+ nodeManager.createNode(param);
nodeRouterService.createNodeRouter(CreateNodeRouterRequest.builder()
.srcNodeId(envService.getPlatformNodeId())
- .dstNodeId(request.getDstNodeId())
+ .dstNodeId(nodeId)
.dstNetAddress(request.getDstNetAddress())
.build());
-
- SysUserPermissionRelDO sysUserPermission = new SysUserPermissionRelDO();
- sysUserPermission.setUserType(PermissionUserType.NODE);
- sysUserPermission.setTargetType(PermissionTargetType.ROLE);
- SysUserPermissionRelDO.UPK upk = new SysUserPermissionRelDO.UPK();
- upk.setUserKey(nodeId);
- upk.setTargetCode(RoleCodeConstants.P2P_NODE);
- sysUserPermission.setUpk(upk);
- permissionRelRepository.save(sysUserPermission);
+ addNodePermissions(nodeId);
return nodeId;
}
+ @Override
+ public NodeVO updateNode(UpdateNodeRequest request) {
+ NodeDTO it = NodeDTO.fromDo(nodeManager.updateNode(UpdateNodeParam.builder()
+ .nodeId(request.getNodeId())
+ .trust(request.getTrust()).build()));
+ return NodeVO.from(it);
+ }
+
@Override
@Transactional(rollbackFor = Exception.class)
public void deleteNode(String routerId) {
Long id = Long.parseLong(routerId);
NodeRouteDO byRouteId = nodeRouteRepository.findByRouteId(id);
if (ObjectUtils.isEmpty(byRouteId)) {
- throw SecretpadException.of(NodeErrorCode.NODE_NOT_EXIST_ERROR,
+ throw EasyPsiException.of(NodeErrorCode.NODE_NOT_EXIST_ERROR,
"node not exist " + routerId);
}
if (nodeManager.checkNodeStatus(byRouteId.getDstNodeId())) {
- throw SecretpadException.of(NodeErrorCode.NODE_DELETE_UNFINISHED_ERROR);
+ throw EasyPsiException.of(NodeErrorCode.NODE_DELETE_UNFINISHED_ERROR);
}
nodeManager.deleteNode(byRouteId.getDstNodeId());
nodeRouteManager.deleteNodeRoute(id);
@@ -146,39 +149,24 @@ public Domain.QueryDomainResponse getNodeNotCheck() {
@Override
public UploadNodeResultVO convertCertificate(MultipartFile multipartFile) {
- CertificateFactory cf;
- X509Certificate cert;
- String nodeId = "";
String certificate;
- log.info("upload node cert check file name: {}",multipartFile.getOriginalFilename());
+ log.info("upload node cert check file name: {}", multipartFile.getOriginalFilename());
FileUtils.fileNameCheck(multipartFile.getOriginalFilename());
- try (InputStream inputStream = multipartFile.getInputStream() ){
- cf = CertificateFactory.getInstance("X.509");
- cert = (X509Certificate) cf.generateCertificate(multipartFile.getInputStream());
- String subjectDN = cert.getSubjectDN().getName();
- if (StringUtils.isNotBlank(subjectDN)) {
- nodeId = subjectDN.substring(subjectDN.lastIndexOf('=') + 1);
- }
-
- byte[] buffer = new byte[multipartFile.getBytes().length];
- inputStream.read(buffer);
- certificate = new Base64().encodeToString(buffer);
- } catch (FileNotFoundException e) {
- throw new RuntimeException(e);
+ try {
+ certificate = new Base64().encodeToString(multipartFile.getBytes());
} catch (IOException e) {
throw new RuntimeException(e);
- } catch (CertificateException e) {
- throw new RuntimeException(e);
}
return UploadNodeResultVO.builder()
.certificate(certificate)
- .nodeId(nodeId)
.build();
+
}
+
@Override
public CertificateDownloadInfo download(DownloadNodeCertificateRequest request) {
NodeCertificateDTO nodeCertificate = nodeManager.getNodeCertificate(request.getNodeId());
@@ -192,4 +180,40 @@ public CertificateDownloadInfo download(DownloadNodeCertificateRequest request)
public void initialNode() {
nodeManager.initialNode(envService.getPlatformNodeId());
}
+
+ private void addNodePermissions(String nodeId) {
+ SysUserPermissionRelDO sysUserPermission = new SysUserPermissionRelDO();
+ sysUserPermission.setUserType(PermissionUserType.NODE);
+ sysUserPermission.setTargetType(PermissionTargetType.ROLE);
+ SysUserPermissionRelDO.UPK upk = new SysUserPermissionRelDO.UPK();
+ upk.setUserKey(nodeId);
+ upk.setTargetCode(RoleCodeConstants.P2P_NODE);
+ sysUserPermission.setUpk(upk);
+ permissionRelRepository.save(sysUserPermission);
+ }
+
+ private X509Certificate parseCertificate(String certText) {
+ CertificateFactory cf;
+ X509Certificate cert;
+
+ byte[] decode = new Base64().decode(certText);
+
+ try (ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(decode)) {
+ cf = CertificateFactory.getInstance("X.509");
+ cert = (X509Certificate) cf.generateCertificate(byteArrayInputStream);
+
+ } catch (IOException | CertificateException e) {
+ throw new RuntimeException(e);
+ }
+ return cert;
+ }
+
+ private String getNodeIdFromX509Cert(X509Certificate cert) {
+ String subjectDN = cert.getSubjectX500Principal().getName();
+ if (StringUtils.isNotBlank(subjectDN)) {
+ return subjectDN.substring(subjectDN.lastIndexOf('=') + 1);
+ }
+ return "";
+ }
+
}
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/impl/ProjectServiceImpl.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/impl/ProjectServiceImpl.java
similarity index 74%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/impl/ProjectServiceImpl.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/impl/ProjectServiceImpl.java
index d074f69..8e22fe9 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/impl/ProjectServiceImpl.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/impl/ProjectServiceImpl.java
@@ -14,35 +14,36 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.service.impl;
-
-import org.secretflow.secretpad.common.constant.JobConstants;
-import org.secretflow.secretpad.common.dto.DownloadInfo;
-import org.secretflow.secretpad.common.errorcode.JobErrorCode;
-import org.secretflow.secretpad.common.exception.SecretpadException;
-import org.secretflow.secretpad.common.util.*;
-import org.secretflow.secretpad.manager.integration.job.AbstractJobManager;
-import org.secretflow.secretpad.manager.integration.job.JobManager;
-import org.secretflow.secretpad.persistence.entity.ProjectJobDO;
-import org.secretflow.secretpad.persistence.model.GraphJobOperation;
-import org.secretflow.secretpad.persistence.model.GraphJobStatus;
-import org.secretflow.secretpad.persistence.model.PsiConfigDO;
-import org.secretflow.secretpad.persistence.repository.ProjectJobRepository;
-import org.secretflow.secretpad.service.EnvService;
-import org.secretflow.secretpad.service.ProjectService;
-import org.secretflow.secretpad.service.RemoteRequestService;
-import org.secretflow.secretpad.service.graph.JobChain;
-import org.secretflow.secretpad.service.model.common.SecretPadPageResponse;
-import org.secretflow.secretpad.service.model.data.DataTableInformationVo;
-import org.secretflow.secretpad.service.model.graph.GrapDataHeaderVO;
-import org.secretflow.secretpad.service.model.graph.GrapDataTableVO;
-import org.secretflow.secretpad.service.model.graph.GraphNodeJobLogsVO;
-import org.secretflow.secretpad.service.model.graph.ProjectPsiJob;
-import org.secretflow.secretpad.service.model.project.*;
+package org.secretflow.easypsi.service.impl;
import jakarta.persistence.criteria.Predicate;
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
+import org.secretflow.easypsi.common.constant.JobConstants;
+import org.secretflow.easypsi.common.dto.DownloadInfo;
+import org.secretflow.easypsi.common.errorcode.JobErrorCode;
+import org.secretflow.easypsi.common.exception.EasyPsiException;
+import org.secretflow.easypsi.common.util.*;
+import org.secretflow.easypsi.manager.integration.job.AbstractJobManager;
+import org.secretflow.easypsi.manager.integration.job.JobManager;
+import org.secretflow.easypsi.manager.integration.node.NodeManager;
+import org.secretflow.easypsi.persistence.entity.ProjectJobDO;
+import org.secretflow.easypsi.persistence.model.GraphJobOperation;
+import org.secretflow.easypsi.persistence.model.GraphJobStatus;
+import org.secretflow.easypsi.persistence.model.PsiConfigDO;
+import org.secretflow.easypsi.persistence.repository.ProjectJobRepository;
+import org.secretflow.easypsi.service.EnvService;
+import org.secretflow.easypsi.service.JobLogService;
+import org.secretflow.easypsi.service.ProjectService;
+import org.secretflow.easypsi.service.RemoteRequestService;
+import org.secretflow.easypsi.service.graph.JobChain;
+import org.secretflow.easypsi.service.model.common.EasyPsiPageResponse;
+import org.secretflow.easypsi.service.model.data.DataTableInformationVo;
+import org.secretflow.easypsi.service.model.graph.GrapDataHeaderVO;
+import org.secretflow.easypsi.service.model.graph.GrapDataTableVO;
+import org.secretflow.easypsi.service.model.graph.GraphNodeJobLogsVO;
+import org.secretflow.easypsi.service.model.graph.ProjectPsiJob;
+import org.secretflow.easypsi.service.model.project.*;
import org.secretflow.v1alpha1.kusciaapi.Job;
import org.secretflow.v1alpha1.kusciaapi.JobServiceGrpc;
import org.slf4j.Logger;
@@ -60,9 +61,10 @@
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
-import java.io.*;
-import java.nio.file.Files;
-import java.nio.file.Paths;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
import java.util.*;
import java.util.concurrent.Future;
import java.util.stream.Collectors;
@@ -96,16 +98,22 @@ public class ProjectServiceImpl implements ProjectService {
@Autowired
private AbstractJobManager jobManager;
- @Value("${secretpad.data.dir-path:/app/data/}")
+ @Autowired
+ private NodeManager nodeManager;
+
+ @Autowired
+ private JobLogService jobLogService;
+
+ private static Map jobResult = new HashMap<>();
+ @Value("${easypsi.data.dir-path:/app/data/}")
private String storeDir;
- @Value("${secretpad.gateway}")
+ @Value("${easypsi.gateway}")
private String gateway;
- private static Map jobResult = new HashMap<>();
@Override
- public SecretPadPageResponse listProjectJob(ListProjectJobRequest request) {
+ public EasyPsiPageResponse listProjectJob(ListProjectJobRequest request) {
Sort.Direction direction = StringUtils.equals(Sort.Direction.ASC.name(), request.getSortType()) ? Sort.Direction.ASC
: Sort.Direction.DESC;
Specification specification = (root, criteriaQuery, criteriaBuilder) -> {
@@ -135,10 +143,10 @@ public SecretPadPageResponse listProjectJob(ListProjectJobRequ
Page page = projectJobRepository.findAll(specification, pageable);
if (ObjectUtils.isEmpty(page) || page.getTotalElements() == 0) {
- return SecretPadPageResponse.toPage(null, 0);
+ return EasyPsiPageResponse.toPage(null, 0);
}
List data = convert2ListVO(page, UserContext.getUser().getOwnerId());
- return SecretPadPageResponse.toPage(data, page.getTotalElements());
+ return EasyPsiPageResponse.toPage(data, page.getTotalElements());
}
@Override
@@ -147,7 +155,6 @@ public ProjectJobVO getProjectJob(GetProjectJobRequest request) {
return buildProjectJobVO(job, UserContext.getUser().getOwnerId());
}
-
@Override
@Transactional(rollbackFor = Exception.class)
public void stopKusciaJob(StopProjectJobTaskRequest request) {
@@ -160,7 +167,7 @@ public void stopKusciaJob(StopProjectJobTaskRequest request) {
Boolean checkOperation = GraphJobStatus.checkOperation(job.getStatus(), GraphJobOperation.CANCEL);
if (!checkOperation) {
- throw SecretpadException.of(JobErrorCode.PROJECT_JOB_ACTION_NOT_ALLOWED, GraphJobStatus.getName(job.getStatus()), GraphJobOperation.getName(GraphJobOperation.CANCEL));
+ throw EasyPsiException.of(JobErrorCode.PROJECT_JOB_ACTION_NOT_ALLOWED, GraphJobStatus.getName(job.getStatus()), GraphJobOperation.getName(GraphJobOperation.CANCEL));
}
String tmpFilepath = storeDir + JobManager.PROJECT_JOB_TASK_TMP + job.getUpk().getJobId();
@@ -187,8 +194,8 @@ public void stopProjectJob(StopProjectJobTaskRequest request) {
remoteRequestService.checkBothSidesNodeRouteIsReady(platformNodeId, StringUtils.equals(platformNodeId, job.getInitiatorNodeId()) ? job.getPartnerNodeId() : job.getInitiatorNodeId());
Boolean checkOperation = GraphJobStatus.checkOperation(job.getStatus(), GraphJobOperation.CANCEL);
- if (!checkOperation || checkPartnerCancelReview(platformNodeId,job)) {
- throw SecretpadException.of(JobErrorCode.PROJECT_JOB_ACTION_NOT_ALLOWED, GraphJobStatus.getName(job.getStatus()), GraphJobOperation.getName(GraphJobOperation.CANCEL));
+ if (!checkOperation || checkPartnerCancelReview(platformNodeId, job)) {
+ throw EasyPsiException.of(JobErrorCode.PROJECT_JOB_ACTION_NOT_ALLOWED, GraphJobStatus.getName(job.getStatus()), GraphJobOperation.getName(GraphJobOperation.CANCEL));
}
if (StringUtils.equals(platformNodeId, job.getHostNodeId())) {
@@ -199,8 +206,8 @@ public void stopProjectJob(StopProjectJobTaskRequest request) {
}
}
- private boolean checkPartnerCancelReview(String nodeId,ProjectJobDO job) {
- return (StringUtils.equals(nodeId,job.getPartnerNodeId()) && StringUtils.equals(job.getStatus().name(),GraphJobStatus.PENDING_REVIEW.name()));
+ private boolean checkPartnerCancelReview(String nodeId, ProjectJobDO job) {
+ return (StringUtils.equals(nodeId, job.getPartnerNodeId()) && StringUtils.equals(job.getStatus().name(), GraphJobStatus.PENDING_REVIEW.name()));
}
@Override
@@ -211,7 +218,7 @@ public void deleteProjectJob(DeleteProjectJobTaskRequest request) {
Boolean checkOperation = GraphJobStatus.checkOperation(job.getStatus(), GraphJobOperation.DELETE);
if (!checkOperation) {
- throw SecretpadException.of(JobErrorCode.PROJECT_JOB_ACTION_NOT_ALLOWED, GraphJobStatus.getName(job.getStatus()), GraphJobOperation.getName(GraphJobOperation.DELETE));
+ throw EasyPsiException.of(JobErrorCode.PROJECT_JOB_ACTION_NOT_ALLOWED, GraphJobStatus.getName(job.getStatus()), GraphJobOperation.getName(GraphJobOperation.DELETE));
}
String resFilepath = storeDir + JobManager.PROJECT_JOB_TASK_RES + job.getUpk().getJobId() + File.separator;
@@ -231,6 +238,7 @@ public void deleteProjectJob(DeleteProjectJobTaskRequest request) {
@Override
@Transactional(rollbackFor = Exception.class)
public CreateProjectJobVO createJob(CreateProjectJobRequest request) {
+
LOGGER.info("Our Create Task: {}", JsonUtils.toJSONString(request));
createJobFileNameCheck(request);
@@ -238,12 +246,14 @@ public CreateProjectJobVO createJob(CreateProjectJobRequest request) {
remoteRequestService.checkBothSidesNodeRouteIsReady(request.getInitiatorConfig().getNodeId(), request.getPartnerConfig().getNodeId());
String jobId = UUIDUtils.random(8);
- CreateProjectJobTaskRequest taskRequest = convertRequest(request, jobId);
- ProjectJobDO jobDO = saveJob(taskRequest, jobId);
+ CreateProjectJobTaskRequest taskRequest = CreateProjectJobTaskRequest.fromJobRequest(request, jobId);
+ ProjectJobDO jobDO = saveJob(taskRequest);
createFile(jobDO);
taskRequest.setJobId(jobId);
+
String url = JobManager.HTTP_HEADER + gateway + JobManager.CREATE_JOB_API;
remoteRequestService.sendPostJson(taskRequest, taskRequest.getPartnerConfig().getNodeId(), url);
+
return CreateProjectJobVO.builder()
.jobId(jobDO.getUpk().getJobId())
.name(jobDO.getName())
@@ -261,10 +271,10 @@ private void createJobFileNameCheck(CreateProjectJobRequest request) {
@NotNull
- private ProjectJobDO saveJob(CreateProjectJobTaskRequest request, String jobId) {
+ private ProjectJobDO saveJob(CreateProjectJobTaskRequest request) {
ProjectJobDO jobDO = new ProjectJobDO();
ProjectJobDO.UPK upk = new ProjectJobDO.UPK();
- upk.setJobId(jobId);
+ upk.setJobId(request.getJobId());
jobDO.setUpk(upk);
jobDO.setName(request.getName());
jobDO.setDescription(request.getDescription());
@@ -295,10 +305,11 @@ private PsiConfigDO convertPsiConfig(CreateProjectJobTaskRequest.PsiConfig psiCo
psiConfigDO.setInputConfig(inputConfig);
LOGGER.debug("convert psi config input config:{}", inputConfig);
psiConfigDO.setDisableAlignment(psiConfig.getDisableAlignment());
- LOGGER.debug("save job data name: {}, data interval: {}", psiConfig.getInputConfig().getPath(), psiConfig.getDatatableCount());
- psiConfigDO.setDatatableCount(psiConfig.getDatatableCount());
+ LOGGER.debug("save job data name: {}, data interval: {}", psiConfig.getInputConfig().getPath(), psiConfig.getDataTableCount());
psiConfigDO.setSkipDuplicatesCheck(psiConfig.getSkipDuplicatesCheck());
psiConfigDO.setAdvancedJoinType(psiConfig.getAdvancedJoinType());
+ psiConfigDO.setDataTableCount(psiConfig.getDataTableCount());
+ psiConfigDO.setDataTableConfirmation(psiConfig.getDataTableConfirmation());
PsiConfigDO.ContextDescProto contextDescProto = new PsiConfigDO.ContextDescProto();
contextDescProto.setHttpTimeoutMs(psiConfig.getLinkConfig().getHttpTimeoutMs());
@@ -341,7 +352,8 @@ private PsiConfigDO convertPsiConfig(CreateProjectJobTaskRequest.PsiConfig psiCo
psiConfigDO.setProtocolConfig(protocolConfig);
LOGGER.debug("convert psi config protocol config:{}", protocolConfig);
- psiConfigDO.setOutputDifference(psiConfig.getOutputDifference());
+
+ psiConfigDO.setLeftSide(psiConfig.getLeftSide());
PsiConfigDO.RecoveryConfig config = new PsiConfigDO.RecoveryConfig();
config.setEnabled(psiConfig.getRecoveryConfig().getEnabled());
config.setFolder(psiConfig.getRecoveryConfig().getFolder());
@@ -362,7 +374,7 @@ public void agreeJob(AgreeProjectJobTaskRequest request) {
Boolean checkOperation = GraphJobStatus.checkOperation(job.getStatus(), GraphJobOperation.AGREE);
if (!checkOperation) {
- throw SecretpadException.of(JobErrorCode.PROJECT_JOB_ACTION_NOT_ALLOWED, GraphJobStatus.getName(job.getStatus()), GraphJobOperation.getName(GraphJobOperation.AGREE));
+ throw EasyPsiException.of(JobErrorCode.PROJECT_JOB_ACTION_NOT_ALLOWED, GraphJobStatus.getName(job.getStatus()), GraphJobOperation.getName(GraphJobOperation.AGREE));
}
PsiConfigDO partnerPsiConfigDO = JsonUtils.toJavaObject(job.getPartnerConfig(), PsiConfigDO.class);
@@ -374,7 +386,7 @@ public void agreeJob(AgreeProjectJobTaskRequest request) {
tableRequest.setTableName(tableName);
GrapDataTableVO dataTable = getDataTable(tableRequest, true);
if (!dataTable.isResult()) {
- throw SecretpadException.of(JobErrorCode.PROJECT_DATA_NOT_EXISTS_ERROR, "check table name not exist");
+ throw EasyPsiException.of(JobErrorCode.PROJECT_DATA_NOT_EXISTS_ERROR, "check table name not exist");
}
//check data table header
@@ -383,7 +395,7 @@ public void agreeJob(AgreeProjectJobTaskRequest request) {
headerRequest.setCheckTableHeader(partnerPsiConfigDO.getKeys());
GrapDataHeaderVO dataHeader = getDataHeader(headerRequest, true);
if (!dataHeader.isResult()) {
- throw SecretpadException.of(JobErrorCode.PROJECT_TABLE_HEADER_NOT_EXISTS_ERROR, "check table header not exists");
+ throw EasyPsiException.of(JobErrorCode.PROJECT_TABLE_HEADER_NOT_EXISTS_ERROR, "check table header not exists");
}
//convertJob
@@ -403,7 +415,7 @@ public void pauseKusciaJob(StopProjectJobTaskRequest request) {
Boolean checkOperation = GraphJobStatus.checkOperation(job.getStatus(), GraphJobOperation.PAUSE);
if (!checkOperation) {
- throw SecretpadException.of(JobErrorCode.PROJECT_JOB_ACTION_NOT_ALLOWED, GraphJobStatus.getName(job.getStatus()), GraphJobOperation.getName(GraphJobOperation.PAUSE));
+ throw EasyPsiException.of(JobErrorCode.PROJECT_JOB_ACTION_NOT_ALLOWED, GraphJobStatus.getName(job.getStatus()), GraphJobOperation.getName(GraphJobOperation.PAUSE));
}
job.pause();
@@ -412,6 +424,7 @@ public void pauseKusciaJob(StopProjectJobTaskRequest request) {
}
@Override
+ @Transactional(rollbackFor = Exception.class)
public void pauseJob(StopProjectJobTaskRequest request) {
LOGGER.info("We suspend the task: {}", request.getJobId());
ProjectJobDO job = openProjectJob(request.getJobId());
@@ -422,7 +435,7 @@ public void pauseJob(StopProjectJobTaskRequest request) {
Boolean checkOperation = GraphJobStatus.checkOperation(job.getStatus(), GraphJobOperation.PAUSE);
if (!checkOperation) {
- throw SecretpadException.of(JobErrorCode.PROJECT_JOB_ACTION_NOT_ALLOWED, GraphJobStatus.getName(job.getStatus()), GraphJobOperation.getName(GraphJobOperation.PAUSE));
+ throw EasyPsiException.of(JobErrorCode.PROJECT_JOB_ACTION_NOT_ALLOWED, GraphJobStatus.getName(job.getStatus()), GraphJobOperation.getName(GraphJobOperation.PAUSE));
}
if (StringUtils.equals(platformNodeId, job.getHostNodeId())) {
@@ -445,7 +458,7 @@ public void continueKusciaJob(StopProjectJobTaskRequest request) {
Boolean checkOperation = GraphJobStatus.checkOperation(job.getStatus(), GraphJobOperation.CONTINUE);
if (!checkOperation) {
- throw SecretpadException.of(JobErrorCode.PROJECT_JOB_ACTION_NOT_ALLOWED, GraphJobStatus.getName(job.getStatus()), GraphJobOperation.getName(GraphJobOperation.CONTINUE));
+ throw EasyPsiException.of(JobErrorCode.PROJECT_JOB_ACTION_NOT_ALLOWED, GraphJobStatus.getName(job.getStatus()), GraphJobOperation.getName(GraphJobOperation.CONTINUE));
}
Job.DeleteJobResponse deleteJobResponse = jobStub.deleteJob(Job.DeleteJobRequest.newBuilder().setJobId(job.getUpk().getJobId()).build());
@@ -467,7 +480,7 @@ public void continueJob(StopProjectJobTaskRequest request) {
Boolean checkOperation = GraphJobStatus.checkOperation(job.getStatus(), GraphJobOperation.CONTINUE);
if (!checkOperation) {
- throw SecretpadException.of(JobErrorCode.PROJECT_JOB_ACTION_NOT_ALLOWED, GraphJobStatus.getName(job.getStatus()), GraphJobOperation.getName(GraphJobOperation.CONTINUE));
+ throw EasyPsiException.of(JobErrorCode.PROJECT_JOB_ACTION_NOT_ALLOWED, GraphJobStatus.getName(job.getStatus()), GraphJobOperation.getName(GraphJobOperation.CONTINUE));
}
LOGGER.info("continue job {}", request.getJobId());
if (StringUtils.equals(platformNodeId, job.getHostNodeId())) {
@@ -476,6 +489,7 @@ public void continueJob(StopProjectJobTaskRequest request) {
String url = JobManager.HTTP_HEADER + gateway + JobManager.CONTINUE_JOB_API;
remoteRequestService.sendPostJson(request, job.getPartnerNodeId(), url);
}
+
}
@Override
@@ -485,9 +499,14 @@ public void createKusciaJob(CreateProjectJobTaskRequest request) {
FileUtils.fileNameCheck(request.getJobId());
ProjectJobDO jobDO = saveKusciaJob(request);
createFile(jobDO);
+ Boolean trust = nodeManager.getNode(request.getInitiatorConfig().getNodeId()).getTrust();
+ if (trust) {
+ agreeJob(AgreeProjectJobTaskRequest.builder().jobId(request.getJobId()).build());
+ }
}
@Override
+ @Transactional(rollbackFor = Exception.class)
public void rejectJob(RejectProjectJobTaskRequest request) {
LOGGER.info("We reject the task: {}", request.getJobId());
ProjectJobDO job = openProjectJob(request.getJobId());
@@ -498,7 +517,7 @@ public void rejectJob(RejectProjectJobTaskRequest request) {
Boolean checkOperation = GraphJobStatus.checkOperation(job.getStatus(), GraphJobOperation.REJECT);
if (!checkOperation) {
- throw SecretpadException.of(JobErrorCode.PROJECT_JOB_ACTION_NOT_ALLOWED, GraphJobStatus.getName(job.getStatus()), GraphJobOperation.getName(GraphJobOperation.REJECT));
+ throw EasyPsiException.of(JobErrorCode.PROJECT_JOB_ACTION_NOT_ALLOWED, GraphJobStatus.getName(job.getStatus()), GraphJobOperation.getName(GraphJobOperation.REJECT));
}
if (StringUtils.isNotBlank(request.getRejectMsg())) {
@@ -555,6 +574,7 @@ public void syncHostNodeProjectJobs(List jobs) {
projectJobRepository.saveAll(jobDOListNotFinished);
}
+
private void deleteFile(String jobId) {
FileUtils.deleteAllFile(storeDir + JobManager.PROJECT_JOB_TASK_TMP + jobId);
}
@@ -567,12 +587,12 @@ public String downloadProjectResult(String jobId) {
job = projectJobDOFuture.get();
} catch (Exception e) {
LOGGER.error("query project job result is null");
- throw SecretpadException.of(JobErrorCode.PROJECT_JOB_NOT_EXISTS);
+ throw EasyPsiException.of(JobErrorCode.PROJECT_JOB_NOT_EXISTS);
}
Boolean checkOperation = GraphJobStatus.checkOperation(job.getStatus(), GraphJobOperation.DOWNLOAD_RESULT);
if (!checkOperation) {
- throw SecretpadException.of(JobErrorCode.PROJECT_JOB_ACTION_NOT_ALLOWED, GraphJobStatus.getName(job.getStatus()), GraphJobOperation.getName(GraphJobOperation.DOWNLOAD_RESULT));
+ throw EasyPsiException.of(JobErrorCode.PROJECT_JOB_ACTION_NOT_ALLOWED, GraphJobStatus.getName(job.getStatus()), GraphJobOperation.getName(GraphJobOperation.DOWNLOAD_RESULT));
}
// get edge node id
@@ -581,12 +601,12 @@ public String downloadProjectResult(String jobId) {
String psiConfig = StringUtils.equalsIgnoreCase(platformNodeId, job.getInitiatorNodeId()) ?
job.getInitiatorConfig() : job.getPartnerConfig();
if (StringUtils.isBlank(psiConfig)) {
- throw SecretpadException.of(JobErrorCode.PROJECT_JOB_RESULT_DOWNLOAD_ERROR, "node psi config not exists");
+ throw EasyPsiException.of(JobErrorCode.PROJECT_JOB_RESULT_DOWNLOAD_ERROR, "node psi config not exists");
}
PsiConfigDO psiConfigDO = JsonUtils.toJavaObject(psiConfig, PsiConfigDO.class);
// single receiver and not equals
if (!psiConfigDO.getProtocolConfig().getBroadcastResult() && !psiConfigDO.getProtocolConfig().getRole().equals(JobConstants.RoleEnum.ROLE_RECEIVER)) {
- throw SecretpadException.of(JobErrorCode.PROJECT_JOB_RESULT_DOWNLOAD_ERROR, "node is not the receiver");
+ throw EasyPsiException.of(JobErrorCode.PROJECT_JOB_RESULT_DOWNLOAD_ERROR, "node is not the receiver");
}
String enginePath = psiConfigDO.getOutputConfig().getPath();
String path = StringUtils.isBlank(enginePath) ? "" : enginePath.replace(JobManager.KUSCIA_DATA_PATH, storeDir);
@@ -607,7 +627,7 @@ public DownloadInfo getloadProjectResult(String hash) {
Date date = new Date();
if (ObjectUtils.isEmpty(projectJobResultVO) || date.compareTo(projectJobResultVO.getExpirationTime()) > 0) {
jobResult.remove(hash);
- throw SecretpadException.of(JobErrorCode.PROJECT_JOB_RESULT_HASH_EXPIRED_ERROR);
+ throw EasyPsiException.of(JobErrorCode.PROJECT_JOB_RESULT_HASH_EXPIRED_ERROR);
}
LOGGER.debug("load project result : {}", projectJobResultVO);
jobResult.remove(hash);
@@ -617,6 +637,7 @@ public DownloadInfo getloadProjectResult(String hash) {
return FileUtils.download(path, dir, relativeUri);
}
+
@Override
public List queryEdgeProjectJobs(String requestNodeId) {
String platformNodeId = envService.getPlatformNodeId();
@@ -633,11 +654,12 @@ public GraphNodeJobLogsVO getProjectJobInFeilLogs(GetProjectJobLogRequest reques
Boolean checkOperation = GraphJobStatus.checkOperation(job.getStatus(), GraphJobOperation.LOG);
if (!checkOperation) {
- throw SecretpadException.of(JobErrorCode.PROJECT_JOB_ACTION_NOT_ALLOWED, GraphJobStatus.getName(job.getStatus()), GraphJobOperation.getName(GraphJobOperation.LOG));
+ throw EasyPsiException.of(JobErrorCode.PROJECT_JOB_ACTION_NOT_ALLOWED, GraphJobStatus.getName(job.getStatus()), GraphJobOperation.getName(GraphJobOperation.LOG));
}
+ List strings = jobLogService.queryJobLog(request.getJobId());
return new GraphNodeJobLogsVO(job.getStatus(),
- getProjectJobLogs(request));
+ strings);
}
@@ -645,7 +667,7 @@ public GraphNodeJobLogsVO getProjectJobInFeilLogs(GetProjectJobLogRequest reques
public GrapDataHeaderVO getDataHeader(GetProjectJobDataHeaderRequest request, boolean check) {
if (check) {
if (ObjectUtils.isEmpty(request.getCheckTableHeader())) {
- throw SecretpadException.of(JobErrorCode.PROJECT_TABLE_HEADER_NOT_EXISTS_ERROR, "csv table header is empty");
+ throw EasyPsiException.of(JobErrorCode.PROJECT_TABLE_HEADER_NOT_EXISTS_ERROR, "csv table header is empty");
}
GrapDataHeaderVO dataHeader = getDataHeader(request);
ArrayList existHeader = new ArrayList<>(dataHeader.getDataHeader());
@@ -666,7 +688,7 @@ public GrapDataHeaderVO getDataHeader(GetProjectJobDataHeaderRequest request, bo
public GrapDataTableVO getDataTable(GetProjectJobTableRequest request, boolean check) {
if (check) {
if (ObjectUtils.isEmpty(request.getTableName())) {
- throw SecretpadException.of(JobErrorCode.PROJECT_DATA_NOT_EXISTS_ERROR, "csv table name is empty");
+ throw EasyPsiException.of(JobErrorCode.PROJECT_DATA_NOT_EXISTS_ERROR, "csv table name is empty");
}
LOGGER.debug("verify the data table exists check table name:{}", request.getTableName());
FileUtils.fileNameCheck(request.getTableName());
@@ -689,6 +711,9 @@ private List convert2ListVO(Page page, String no
vo.setName(it.getName());
vo.setStatus(it.getStatus());
vo.setGmtCreate(DateTimes.toRfc3339(it.getGmtCreate()));
+ if (StringUtils.equals(it.getStatus().name(), GraphJobStatus.FAILED.name()) || StringUtils.equals(it.getStatus().name(), GraphJobStatus.SUCCEEDED.name())) {
+ vo.setGmtFinished(DateTimes.toRfc3339(it.getFinishedTime()));
+ }
vo.setSrcNodeId(it.getInitiatorNodeId());
vo.setDstNodeId(it.getPartnerNodeId());
//TODO:It will be optimized later.
@@ -697,16 +722,16 @@ private List convert2ListVO(Page page, String no
vo.setInitiatorDataTableInformation(DataTableInformationVo.DataTableInformation.builder()
.nodeId(it.getInitiatorNodeId())
.dataTableName(getTableName(initiatorConfig.getInputConfig().getPath()))
- .dataTableCount(initiatorConfig.getDatatableCount())
+ .dataTableCount(initiatorConfig.getDataTableCount())
.build());
vo.setPartnerdstDataTableInformation(DataTableInformationVo.DataTableInformation.builder()
.nodeId(it.getPartnerNodeId())
.dataTableName(getTableName(partnerConfig.getInputConfig().getPath()))
- .dataTableCount(partnerConfig.getDatatableCount())
+ .dataTableCount(partnerConfig.getDataTableCount())
.build());
PsiConfigDO partnerPsiConfigDO = JsonUtils.toJavaObject(it.getPartnerConfig(), PsiConfigDO.class);
vo.setEnabled(partnerPsiConfigDO.getRecoveryConfig().getEnabled());
-
+ vo.setDataTableConfirmation(initiatorConfig.getDataTableConfirmation());
if (StringUtils.isNotBlank(it.getErrMsg())) {
vo.setErrMsg(it.getErrMsg());
}
@@ -810,9 +835,10 @@ private CreateProjectJobTaskRequest.PsiConfig convertPsiConfigVO(CreateProjectJo
config.setFolder(psiConfigDO.getRecoveryConfig().getFolder());
psiConfig.setRecoveryConfig(config);
LOGGER.debug("convert psi configVO recovery config:{}", config);
- psiConfig.setOutputDifference(psiConfigDO.getOutputDifference());
- LOGGER.debug("Get data table level from psi configuration, path:{}, data count: {}", psiConfigDO.getInputConfig().getPath(), psiConfigDO.getDatatableCount());
- psiConfig.setDatatableCount(psiConfigDO.getDatatableCount());
+ psiConfig.setLeftSide(psiConfigDO.getLeftSide());
+ LOGGER.debug("Get data table level from psi configuration, path:{}, data count: {}", psiConfigDO.getInputConfig().getPath(), psiConfigDO.getDataTableCount());
+ psiConfig.setDataTableCount(psiConfigDO.getDataTableCount());
+ psiConfig.setDataTableConfirmation(psiConfigDO.getDataTableConfirmation());
LOGGER.debug("convert psi configVO psi config:{}", psiConfig);
return psiConfig;
}
@@ -841,6 +867,7 @@ private ProjectJobDO saveKusciaJob(CreateProjectJobTaskRequest request) {
return jobDO;
}
+
private List removeExtraCharacters(List str) {
return str.stream().map(s -> s.trim().replaceAll("^\"|\"$", "").replaceAll("\"\"", "")).collect(Collectors.toList());
}
@@ -848,7 +875,7 @@ private List removeExtraCharacters(List str) {
public GrapDataTableVO getDataTable() {
List data = FileUtils.traverseDirectories(new File(JobManager.CSV_DATA_PATH), ".csv", FileUtils.FILE_NAME);
if (data == null) {
- throw SecretpadException.of(JobErrorCode.PROJECT_DATA_PATH_NOT_EXISTS_ERROR);
+ throw EasyPsiException.of(JobErrorCode.PROJECT_DATA_PATH_NOT_EXISTS_ERROR);
}
return GrapDataTableVO.builder()
.dataTable(data)
@@ -878,7 +905,7 @@ private GrapDataHeaderVO getDataHeader(GetProjectJobDataHeaderRequest request) {
String filepath = JobManager.CSV_DATA_PATH + File.separator + request.getTableName();
File file = new File(filepath);
if (!file.exists()) {
- throw SecretpadException.of(JobErrorCode.PROJECT_DATA_NOT_EXISTS_ERROR, request.getTableName() + " csv data not exists");
+ throw EasyPsiException.of(JobErrorCode.PROJECT_DATA_NOT_EXISTS_ERROR, request.getTableName() + " csv data not exists");
}
BufferedReader reader;
List collect;
@@ -898,46 +925,6 @@ private GrapDataHeaderVO getDataHeader(GetProjectJobDataHeaderRequest request) {
.build();
}
- private List getProjectJobLogs(GetProjectJobLogRequest request) {
- String directoryPath = JobManager.PROJECT_JOB_LOGS;
- LOGGER.info("get project job logs check job id: {}", request.getJobId());
- FileUtils.fileNameCheck(request.getJobId());
- String pattern = envService.getPlatformNodeId() + "_" + request.getJobId() + "-0";
- File directory = new File(directoryPath);
- FilenameFilter filenameFilter = (dir, name) -> name.startsWith(pattern);
- File[] matchingFiles = directory.listFiles(filenameFilter);
- String fileName = null;
- List projectJobLogs = new ArrayList<>();
- long lastModified = 0L;
- if (matchingFiles != null) {
- for (File file : matchingFiles) {
- if (file.lastModified() > lastModified) {
- fileName = file.getName();
- lastModified = file.lastModified();
- }
- }
- }
- List filePaths = FileUtils.traverseDirectories(new File(directoryPath + File.separator + fileName + File.separator + "secretflow"), ".log", FileUtils.FILE_PATH);
- if (filePaths == null) {
- LOGGER.warn("{} task log path not exit", request.getJobId());
- return Collections.emptyList();
- }
- try {
- for (String filePath : filePaths) {
- projectJobLogs.addAll(Files.lines(Paths.get(filePath)).collect(Collectors.toList()));
- }
- } catch (Exception e) {
- LOGGER.error("{} task log not exit", request.getJobId());
- return Collections.emptyList();
- }
-
- if (ObjectUtils.isEmpty(fileName)) {
- LOGGER.warn("{} task log not exit", request.getJobId());
- return Collections.emptyList();
- }
- return projectJobLogs;
- }
-
private void createFile(ProjectJobDO jobDO) {
String resFilepath = storeDir + JobManager.PROJECT_JOB_TASK_RES + jobDO.getUpk().getJobId() + File.separator;
File resFile = new File(resFilepath);
@@ -949,99 +936,6 @@ private void createFile(ProjectJobDO jobDO) {
}
- private CreateProjectJobTaskRequest convertRequest(CreateProjectJobRequest request, String jobId) {
- CreateProjectJobTaskRequest taskRequest = new CreateProjectJobTaskRequest();
- taskRequest.setName(request.getName());
- taskRequest.setDescription(request.getDescription());
-
- CreateProjectJobTaskRequest.PsiConfig initiatorConfig = convertPsiConfig(request, request.getInitiatorConfig(), jobId);
- if (initiatorConfig.getProtocolConfig().getBroadcastResult()) {
- initiatorConfig.getProtocolConfig().setRole(JobConstants.RoleEnum.ROLE_SENDER);
- }
- taskRequest.setInitiatorConfig(initiatorConfig);
-
- CreateProjectJobTaskRequest.PsiConfig partnerConfig = convertPsiConfig(request, request.getPartnerConfig(), jobId);
- taskRequest.setPartnerConfig(partnerConfig);
-
- return taskRequest;
- }
-
- private CreateProjectJobTaskRequest.PsiConfig convertPsiConfig(CreateProjectJobRequest request, CreateProjectJobRequest.PsiConfig requestPsiConfig, String jobId) {
- CreateProjectJobTaskRequest.PsiConfig psiConfig = new CreateProjectJobTaskRequest.PsiConfig();
- psiConfig.setNodeId(requestPsiConfig.getNodeId());
-
- CreateProjectJobRequest.AdvancedConfig.ProtocolConfig requestProtocolConfig = request.getAdvancedConfig().getProtocolConfig();
- LOGGER.debug("convert request psi config protocol config:{}", requestProtocolConfig);
- CreateProjectJobTaskRequest.PsiConfig.ProtocolConfig protocolConfig = new CreateProjectJobTaskRequest.PsiConfig.ProtocolConfig();
- protocolConfig.setProtocol(requestProtocolConfig.getProtocol());
-
- if (!ObjectUtils.isEmpty(requestProtocolConfig.getEcdhConfig())) {
- CreateProjectJobTaskRequest.PsiConfig.ProtocolConfig.EcdhConfig ecdhConfig = new CreateProjectJobTaskRequest.PsiConfig.ProtocolConfig.EcdhConfig();
- ecdhConfig.setCurve(requestProtocolConfig.getEcdhConfig().getCurve());
- protocolConfig.setEcdhConfig(ecdhConfig);
- }
- if (!ObjectUtils.isEmpty(requestProtocolConfig.getRr22Config())) {
- CreateProjectJobTaskRequest.PsiConfig.ProtocolConfig.Rr22Config rr22Config = new CreateProjectJobTaskRequest.PsiConfig.ProtocolConfig.Rr22Config();
- rr22Config.setBucketSize(requestProtocolConfig.getRr22Config().getBucketSize());
- rr22Config.setLowCommMode(requestProtocolConfig.getRr22Config().getLowCommMode());
- protocolConfig.setRr22Config(rr22Config);
- }
- if (!ObjectUtils.isEmpty(requestProtocolConfig.getKkrtConfig())) {
- CreateProjectJobTaskRequest.PsiConfig.ProtocolConfig.KkrtConfig kkrtConfig = new CreateProjectJobTaskRequest.PsiConfig.ProtocolConfig.KkrtConfig();
- kkrtConfig.setBucketSize(requestProtocolConfig.getKkrtConfig().getBucketSize());
- protocolConfig.setKkrtConfig(kkrtConfig);
- }
-
-
- List broadcastResult = request.getOutputConfig().getBroadcastResult();
- LOGGER.debug("convert request psi config broadcast result:{}", broadcastResult);
-
- CreateProjectJobTaskRequest.PsiConfig.OutputConfig outputConfig = new CreateProjectJobTaskRequest.PsiConfig.OutputConfig();
-
- if (broadcastResult.size() == 2) {
- protocolConfig.setRole(JobConstants.RoleEnum.ROLE_RECEIVER);
- protocolConfig.setBroadcastResult(true);
- outputConfig.setPath(request.getOutputConfig().getPath());
- } else {
- if (broadcastResult.contains(psiConfig.getNodeId())) {
- protocolConfig.setRole(JobConstants.RoleEnum.ROLE_RECEIVER);
- outputConfig.setPath(request.getOutputConfig().getPath());
- } else {
- protocolConfig.setRole(JobConstants.RoleEnum.ROLE_SENDER);
- }
- protocolConfig.setBroadcastResult(false);
- }
- psiConfig.setProtocolConfig(protocolConfig);
- LOGGER.debug("convert request psi config protocol config:{}", protocolConfig);
- psiConfig.setOutputConfig(outputConfig);
- LOGGER.debug("convert request psi config output config:{}", outputConfig);
- CreateProjectJobTaskRequest.PsiConfig.InputConfig inputConfig = new CreateProjectJobTaskRequest.PsiConfig.InputConfig();
- inputConfig.setPath(requestPsiConfig.getPath());
- psiConfig.setInputConfig(inputConfig);
- LOGGER.debug("convert request psi config input config:{}", inputConfig);
- CreateProjectJobRequest.AdvancedConfig requestAdvancedConfig = request.getAdvancedConfig();
- LOGGER.debug("convert request psi config advanced config:{}", requestAdvancedConfig);
- CreateProjectJobTaskRequest.PsiConfig.ContextDescProto contextDescProto = new CreateProjectJobTaskRequest.PsiConfig.ContextDescProto();
- contextDescProto.setHttpTimeoutMs(requestAdvancedConfig.getLinkConfig());
- contextDescProto.setRecvTimeoutMs(requestAdvancedConfig.getLinkConfig());
- psiConfig.setLinkConfig(contextDescProto);
- LOGGER.debug("convert request psi config context desc proto:{}", contextDescProto);
- psiConfig.setKeys(requestPsiConfig.getKeys());
- psiConfig.setAdvancedJoinType(requestAdvancedConfig.getAdvancedJoinType());
- psiConfig.setOutputDifference(requestAdvancedConfig.getOutputDifference());
- psiConfig.setDisableAlignment(requestAdvancedConfig.getDisableAlignment());
- psiConfig.setSkipDuplicatesCheck(requestAdvancedConfig.getSkipDuplicatesCheck());
- LOGGER.info("data table name:{}, data interval: {}", requestPsiConfig.getPath(), DataServiceImpl.dataTableCountCache.get(DataServiceImpl.spliceNodeTable(psiConfig.getNodeId(), requestPsiConfig.getPath())));
- psiConfig.setDatatableCount(DataServiceImpl.dataTableCountCache.get(DataServiceImpl.spliceNodeTable(psiConfig.getNodeId(), requestPsiConfig.getPath())));
-
- CreateProjectJobTaskRequest.PsiConfig.RecoveryConfig recoveryConfig = new CreateProjectJobTaskRequest.PsiConfig.RecoveryConfig();
- recoveryConfig.setEnabled(request.getAdvancedConfig().getRecoveryEnabled());
- recoveryConfig.setFolder(JobManager.KUSCIA_DATA_PATH + JobManager.PROJECT_JOB_TASK_TMP + jobId + File.separator);
- psiConfig.setRecoveryConfig(recoveryConfig);
- LOGGER.debug("convert psi config result:{}", psiConfig);
- return psiConfig;
- }
-
/**
* Open the project job information by projectId and jobId
*
@@ -1051,8 +945,19 @@ private CreateProjectJobTaskRequest.PsiConfig convertPsiConfig(CreateProjectJobR
private ProjectJobDO openProjectJob(String jobId) {
Optional jobOpt = projectJobRepository.findByJobId(jobId);
if (jobOpt.isEmpty()) {
- throw SecretpadException.of(JobErrorCode.PROJECT_JOB_NOT_EXISTS);
+ throw EasyPsiException.of(JobErrorCode.PROJECT_JOB_NOT_EXISTS);
}
return jobOpt.get();
}
+
+
+ @Override
+ public List listProjectJobByBlackScreen(ListProjectJobRequest request) {
+ if (ObjectUtils.isEmpty(listProjectJob(request).getList())) {
+ return null;
+ }
+ return listProjectJob(request).getList().stream()
+ .map(ProjectJobListByBlackScreenVO::from)
+ .collect(Collectors.toList());
+ }
}
diff --git a/easypsi-service/src/main/java/org/secretflow/easypsi/service/impl/RemoteRequestServiceImpl.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/impl/RemoteRequestServiceImpl.java
new file mode 100644
index 0000000..56c54e6
--- /dev/null
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/impl/RemoteRequestServiceImpl.java
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2023 Ant Group Co., Ltd.
+ *
+ * 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.
+ */
+package org.secretflow.easypsi.service.impl;
+
+import com.google.common.collect.ImmutableMap;
+import org.secretflow.easypsi.common.errorcode.JobErrorCode;
+import org.secretflow.easypsi.common.errorcode.KusciaGrpcErrorCode;
+import org.secretflow.easypsi.common.exception.EasyPsiException;
+import org.secretflow.easypsi.common.util.JsonUtils;
+import org.secretflow.easypsi.common.util.RestTemplateUtil;
+import org.secretflow.easypsi.service.NodeRouterService;
+import org.secretflow.easypsi.service.NodeService;
+import org.secretflow.easypsi.service.RemoteRequestService;
+import org.secretflow.easypsi.service.model.common.EasyPsiResponse;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.scheduling.annotation.AsyncResult;
+import org.springframework.stereotype.Service;
+
+import java.util.concurrent.Future;
+
+/**
+ * @author liujunhao
+ * @date 2023/11/20
+ */
+@Service
+public class RemoteRequestServiceImpl implements RemoteRequestService {
+
+ private final static Logger LOGGER = LoggerFactory.getLogger(RemoteRequestService.class);
+
+ @Autowired
+ private NodeRouterService nodeRouterService;
+
+ @Autowired
+ private NodeService nodeService;
+
+
+ @Override
+ public boolean checkBothSidesNodeRouteIsReady(String srcNodeId, String dstNodeId) {
+ LOGGER.info("check node nodeRoute status");
+ try {
+ nodeService.getNodeNotCheck();
+ } catch (Exception e) {
+ throw EasyPsiException.of(KusciaGrpcErrorCode.KUSCIA_CPMMECT_ERROR);
+ }
+ return true;
+ }
+
+ @Async
+ @Override
+ public Future asynCheckBothSidesNodeRouteIsReady(String srcNodeId, String dstNodeId) {
+ return new AsyncResult<>(checkBothSidesNodeRouteIsReady(srcNodeId, dstNodeId));
+ }
+
+ @Override
+ public EasyPsiResponse sendPostJson(Object request, String partnerNodeId, String url) {
+ String svc = "secretpad." + partnerNodeId + ".svc";
+ ImmutableMap immutableMap = ImmutableMap.of("Host", svc);
+ EasyPsiResponse easyPsiResponse = RestTemplateUtil.sendPostJson(url, request, immutableMap, EasyPsiResponse.class);
+ LOGGER.info("EasyPsiResponse={}", JsonUtils.toJSONString(easyPsiResponse));
+ if (easyPsiResponse.getStatus().getCode() != 0) {
+ LOGGER.error("EasyPsiResponse error msg={}", easyPsiResponse.getStatus().getMsg());
+ throw EasyPsiException.of(JobErrorCode.PROJECT_JOB_RPC_ERROR, easyPsiResponse.getStatus().getMsg());
+ }
+ return easyPsiResponse;
+ }
+
+ @Async
+ @Override
+ public Future asyncSendPostJson(Object request, String partnerNodeId, String url) {
+ return new AsyncResult<>(sendPostJson(request, partnerNodeId, url));
+ }
+}
diff --git a/easypsi-service/src/main/java/org/secretflow/easypsi/service/impl/RsaEncryptionKeyServiceImpl.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/impl/RsaEncryptionKeyServiceImpl.java
new file mode 100644
index 0000000..10e8629
--- /dev/null
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/impl/RsaEncryptionKeyServiceImpl.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2023 Ant Group Co., Ltd.
+ *
+ * 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.
+ */
+
+package org.secretflow.easypsi.service.impl;
+
+import org.apache.commons.lang3.StringUtils;
+import org.secretflow.easypsi.common.util.RsaUtils;
+import org.secretflow.easypsi.persistence.entity.RsaEncryptionKeyDO;
+import org.secretflow.easypsi.persistence.repository.RsaEncryptionKeyRepository;
+import org.secretflow.easypsi.service.RsaEncryptionKeyService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import java.time.Duration;
+import java.time.LocalDateTime;
+import java.util.Map;
+import java.util.Objects;
+
+/**
+ * Rsa encryption key service implementation class
+ *
+ * @author lihaixin
+ * @date 2024/02/04
+ */
+@Service
+public class RsaEncryptionKeyServiceImpl implements RsaEncryptionKeyService {
+
+
+ @Autowired
+ private RsaEncryptionKeyRepository rsaEncryptionKeyRepository;
+
+
+ @Value("${secretpad.encryption-key-time-minutes:15}")
+ private Integer encryptionKeyTimeMinutes;
+
+ @Override
+ public RsaEncryptionKeyDO findByPublicKey(String publicKey) {
+ if (StringUtils.isNotBlank(publicKey)) {
+ return rsaEncryptionKeyRepository.findByPublicKey(publicKey);
+ }
+
+ LocalDateTime currentTime = LocalDateTime.now();
+ RsaEncryptionKeyDO rsaEncryptionKeyDO = rsaEncryptionKeyRepository.findLastKey();
+ if (Objects.nonNull(rsaEncryptionKeyDO)) {
+ Duration duration = Duration.between(currentTime, rsaEncryptionKeyDO.getKeyInvalidTime());
+ Long minutes = duration.toMinutes();
+ if (minutes > 0) {
+ return rsaEncryptionKeyDO;
+ }
+ }
+ Map keyMap = RsaUtils.generateRSAKeys();
+ rsaEncryptionKeyDO = new RsaEncryptionKeyDO();
+ rsaEncryptionKeyDO.setPublicKey(keyMap.get(RsaUtils.PUBLIC_KEY_NAME));
+ rsaEncryptionKeyDO.setPrivateKey(keyMap.get(RsaUtils.PRIVATE_KEY_NAME));
+ rsaEncryptionKeyDO.setKeyInvalidTime(currentTime.plusMinutes(encryptionKeyTimeMinutes));
+ rsaEncryptionKeyRepository.save(rsaEncryptionKeyDO);
+ return rsaEncryptionKeyDO;
+ }
+}
\ No newline at end of file
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/impl/SysResourcesBizServiceImpl.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/impl/SysResourcesBizServiceImpl.java
similarity index 79%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/impl/SysResourcesBizServiceImpl.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/impl/SysResourcesBizServiceImpl.java
index 5fdfaa0..7fcf4e1 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/impl/SysResourcesBizServiceImpl.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/impl/SysResourcesBizServiceImpl.java
@@ -14,18 +14,18 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.service.impl;
+package org.secretflow.easypsi.service.impl;
-import org.secretflow.secretpad.common.constant.PermissionTargetType;
-import org.secretflow.secretpad.common.constant.PermissionUserType;
-import org.secretflow.secretpad.common.constant.ResourceType;
-import org.secretflow.secretpad.persistence.entity.SysResourceDO;
-import org.secretflow.secretpad.persistence.entity.SysRoleResourceRelDO;
-import org.secretflow.secretpad.persistence.entity.SysUserPermissionRelDO;
-import org.secretflow.secretpad.persistence.repository.SysResourceRepository;
-import org.secretflow.secretpad.persistence.repository.SysRoleResourceRelRepository;
-import org.secretflow.secretpad.persistence.repository.SysUserPermissionRelRepository;
-import org.secretflow.secretpad.service.SysResourcesBizService;
+import org.secretflow.easypsi.common.constant.PermissionTargetType;
+import org.secretflow.easypsi.common.constant.PermissionUserType;
+import org.secretflow.easypsi.common.constant.ResourceType;
+import org.secretflow.easypsi.persistence.entity.SysResourceDO;
+import org.secretflow.easypsi.persistence.entity.SysRoleResourceRelDO;
+import org.secretflow.easypsi.persistence.entity.SysUserPermissionRelDO;
+import org.secretflow.easypsi.persistence.repository.SysResourceRepository;
+import org.secretflow.easypsi.persistence.repository.SysRoleResourceRelRepository;
+import org.secretflow.easypsi.persistence.repository.SysUserPermissionRelRepository;
+import org.secretflow.easypsi.service.SysResourcesBizService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/impl/UserServiceImpl.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/impl/UserServiceImpl.java
similarity index 64%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/impl/UserServiceImpl.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/impl/UserServiceImpl.java
index 5f7b687..2986db5 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/impl/UserServiceImpl.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/impl/UserServiceImpl.java
@@ -14,19 +14,21 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.service.impl;
-
-import org.secretflow.secretpad.common.errorcode.AuthErrorCode;
-import org.secretflow.secretpad.common.errorcode.UserErrorCode;
-import org.secretflow.secretpad.common.exception.SecretpadException;
-import org.secretflow.secretpad.persistence.entity.AccountsDO;
-import org.secretflow.secretpad.persistence.repository.UserAccountsRepository;
-import org.secretflow.secretpad.persistence.repository.UserTokensRepository;
-import org.secretflow.secretpad.service.UserService;
-import org.secretflow.secretpad.service.model.auth.UserUpdatePwdRequest;
+package org.secretflow.easypsi.service.impl;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
+import org.secretflow.easypsi.common.errorcode.AuthErrorCode;
+import org.secretflow.easypsi.common.errorcode.UserErrorCode;
+import org.secretflow.easypsi.common.exception.EasyPsiException;
+import org.secretflow.easypsi.common.util.RsaUtils;
+import org.secretflow.easypsi.persistence.entity.AccountsDO;
+import org.secretflow.easypsi.persistence.entity.RsaEncryptionKeyDO;
+import org.secretflow.easypsi.persistence.repository.UserAccountsRepository;
+import org.secretflow.easypsi.persistence.repository.UserTokensRepository;
+import org.secretflow.easypsi.service.RsaEncryptionKeyService;
+import org.secretflow.easypsi.service.UserService;
+import org.secretflow.easypsi.service.model.auth.UserUpdatePwdRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
@@ -53,15 +55,26 @@ public class UserServiceImpl implements UserService {
@Autowired
private UserTokensRepository userTokensRepository;
- @Value("${secretpad.reset-password-error-max-attempts:5}")
+ @Value("${easypsi.reset-password-error-max-attempts:5}")
private Integer resetPasswordMaxAttempts;
- @Value("${secretpad.reset-password-error-lock-time-minutes:60}")
+ @Value("${easypsi.reset-password-error-lock-time-minutes:60}")
private Integer resetPasswordLockMinutes;
+ @Autowired
+ private RsaEncryptionKeyService rsaEncryptionKeyService;
+
@Override
- @Transactional(rollbackFor = Exception.class, noRollbackFor = SecretpadException.class)
+ @Transactional(rollbackFor = Exception.class, noRollbackFor = EasyPsiException.class)
public void updatePwd(UserUpdatePwdRequest request) {
+ if (StringUtils.isNotBlank(request.getPublicKey())) {
+ RsaEncryptionKeyDO rsaEncryptionKeyDO = rsaEncryptionKeyService.findByPublicKey(request.getPublicKey());
+ if (Objects.nonNull(rsaEncryptionKeyDO)) {
+ request.setOldPasswordHash(RsaUtils.decrypt(request.getOldPasswordHash(), rsaEncryptionKeyDO.getPrivateKey()));
+ request.setNewPasswordHash(RsaUtils.decrypt(request.getNewPasswordHash(), rsaEncryptionKeyDO.getPrivateKey()));
+ request.setConfirmPasswordHash(RsaUtils.decrypt(request.getConfirmPasswordHash(), rsaEncryptionKeyDO.getPrivateKey()));
+ }
+ }
AccountsDO userDO = getUserByName(request.getName());
LocalDateTime currentTime = LocalDateTime.now();
@@ -73,7 +86,7 @@ public void updatePwd(UserUpdatePwdRequest request) {
if (duration.toMinutes() > 0) {
if (userDO.getPasswdResetFailedAttempts() >= resetPasswordMaxAttempts) {
Long minutes = duration.toMinutes();
- throw SecretpadException.of(AuthErrorCode.USER_IS_LOCKED, String.valueOf(minutes));
+ throw EasyPsiException.of(AuthErrorCode.USER_IS_LOCKED, String.valueOf(minutes));
}
} else {
isUnlock = Boolean.TRUE;
@@ -85,11 +98,11 @@ public void updatePwd(UserUpdatePwdRequest request) {
}
}
if (!StringUtils.equals(request.getNewPasswordHash(), request.getConfirmPasswordHash())) {
- throw SecretpadException.of(UserErrorCode.USER_UPDATE_PASSWORD_ERROR_INCONSISTENT);
+ throw EasyPsiException.of(UserErrorCode.USER_UPDATE_PASSWORD_ERROR_INCONSISTENT);
}
if (StringUtils.equals(request.getOldPasswordHash(), request.getNewPasswordHash())) {
- throw SecretpadException.of(UserErrorCode.USER_UPDATE_PASSWORD_ERROR_SAME);
+ throw EasyPsiException.of(UserErrorCode.USER_UPDATE_PASSWORD_ERROR_SAME);
}
//checkPassword success
if (userDO.getPasswordHash().equals(request.getOldPasswordHash())) {
@@ -99,6 +112,7 @@ public void updatePwd(UserUpdatePwdRequest request) {
userDO.setPasswdResetFailedAttempts(null);
userDO.setGmtModified(LocalDateTime.now());
userDO.setPasswordHash(request.getNewPasswordHash());
+ userDO.setInitial(false);
userAccountsRepository.save(userDO);
//after remove need remove user all token
userTokensRepository.deleteByName(request.getName());
@@ -110,12 +124,10 @@ public void updatePwd(UserUpdatePwdRequest request) {
if (userDO.getPasswdResetFailedAttempts() >= resetPasswordMaxAttempts) {
userDO.setGmtPasswdResetRelease(currentTime.plusMinutes(resetPasswordLockMinutes));
userLock(userDO);
- throw SecretpadException.of(AuthErrorCode.RESET_PASSWORD_IS_LOCKED, String.valueOf(resetPasswordLockMinutes));
+ throw EasyPsiException.of(AuthErrorCode.RESET_PASSWORD_IS_LOCKED, String.valueOf(resetPasswordLockMinutes));
}
userLock(userDO);
- throw SecretpadException.of(AuthErrorCode.USER_PASSWORD_ERROR, String.valueOf(resetPasswordMaxAttempts - userDO.getPasswdResetFailedAttempts()));
-
-
+ throw EasyPsiException.of(AuthErrorCode.USER_PASSWORD_ERROR, String.valueOf(resetPasswordMaxAttempts - userDO.getPasswdResetFailedAttempts()));
}
@@ -123,34 +135,21 @@ public void updatePwd(UserUpdatePwdRequest request) {
public AccountsDO getUserByName(String userName) {
Optional userOptional = userAccountsRepository.findByName(userName);
if (userOptional.isEmpty()) {
- throw SecretpadException.of(AuthErrorCode.USER_NOT_FOUND);
+ throw EasyPsiException.of(AuthErrorCode.USER_NOT_FOUND);
}
return userOptional.get();
}
- @Transactional(rollbackFor = Exception.class)
@Override
- public void userLock(AccountsDO accountsDO) {
- accountsDO.setGmtModified(LocalDateTime.now());
- userAccountsRepository.save(accountsDO);
+ public AccountsDO queryUserByName(String userName) {
+ Optional userOptional = userAccountsRepository.findByName(userName);
+ return userOptional.orElse(null);
}
@Transactional(rollbackFor = Exception.class)
@Override
- public void userUnlock(AccountsDO accountsDO) {
+ public void userLock(AccountsDO accountsDO) {
accountsDO.setGmtModified(LocalDateTime.now());
- accountsDO.setLockedInvalidTime(null);
- accountsDO.setFailedAttempts(null);
userAccountsRepository.save(accountsDO);
-
- }
-
- @Override
- public AccountsDO findLockedUser() {
- Optional userOptional = userAccountsRepository.findLockedUser();
- if (userOptional.isEmpty()) {
- return null;
- }
- return userOptional.get();
}
}
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/listener/JobSyncListener.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/listener/JobSyncListener.java
similarity index 78%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/listener/JobSyncListener.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/listener/JobSyncListener.java
index 214ea95..406c5eb 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/listener/JobSyncListener.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/listener/JobSyncListener.java
@@ -14,11 +14,11 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.service.listener;
+package org.secretflow.easypsi.service.listener;
-import org.secretflow.secretpad.common.errorcode.SystemErrorCode;
-import org.secretflow.secretpad.common.exception.SecretpadException;
-import org.secretflow.secretpad.manager.integration.job.JobManager;
+import org.secretflow.easypsi.common.errorcode.SystemErrorCode;
+import org.secretflow.easypsi.common.exception.EasyPsiException;
+import org.secretflow.easypsi.manager.integration.job.JobManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
@@ -38,8 +38,9 @@ public class JobSyncListener implements ApplicationListener implements Serializable {
+public class EasyPsiPageResponse implements Serializable {
private static final long serialVersionUID = 1L;
/**
@@ -46,11 +46,11 @@ public class SecretPadPageResponse implements Serializable {
@Schema(description = "total")
private long total;
- public static SecretPadPageResponse toPage(Page page) {
- return new SecretPadPageResponse<>(page.getContent(), page.getTotalElements());
+ public static EasyPsiPageResponse toPage(Page page) {
+ return new EasyPsiPageResponse<>(page.getContent(), page.getTotalElements());
}
- public static SecretPadPageResponse toPage(List content, long totalElements) {
- return new SecretPadPageResponse<>(content, totalElements);
+ public static EasyPsiPageResponse toPage(List content, long totalElements) {
+ return new EasyPsiPageResponse<>(content, totalElements);
}
}
\ No newline at end of file
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/common/SecretPadResponse.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/common/EasyPsiResponse.java
similarity index 67%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/model/common/SecretPadResponse.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/model/common/EasyPsiResponse.java
index c1aede6..8b78cd6 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/common/SecretPadResponse.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/common/EasyPsiResponse.java
@@ -14,13 +14,13 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.service.model.common;
+package org.secretflow.easypsi.service.model.common;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
/**
- * SecretPad common response
+ * EasyPsi common response
*
* @author yansi
* @date 2023/5/10
@@ -29,41 +29,41 @@
@Getter
@AllArgsConstructor
@NoArgsConstructor
-public class SecretPadResponse {
+public class EasyPsiResponse {
@Schema(description = "status information")
- private SecretPadResponseStatus status;
+ private EasyPsiResponseStatus status;
@Schema
private T data;
/**
- * Build successful secretPad response with data
+ * Build successful easyPsi response with data
*
* @param data return data
* @param
- * @return successful secretPad response with data
+ * @return successful easyPsi response with data
*/
- public static SecretPadResponse success(T data) {
- return new SecretPadResponse<>(new SecretPadResponseStatus(0, "操作成功"), data);
+ public static EasyPsiResponse success(T data) {
+ return new EasyPsiResponse<>(new EasyPsiResponseStatus(0, "操作成功"), data);
}
/**
- * Build successful SecretPad response
+ * Build successful EasyPsi response
*
* @param
- * @return successful SecretPad response
+ * @return successful EasyPsi response
*/
- public static SecretPadResponse success() {
+ public static EasyPsiResponse success() {
return success(null);
}
/**
- * SecretPad response status class
+ * EasyPsi response status class
*/
@Builder
@Getter
@AllArgsConstructor
@NoArgsConstructor
- public static class SecretPadResponseStatus {
+ public static class EasyPsiResponseStatus {
/**
* Status code
*/
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/data/DataSourceVO.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/data/DataSourceVO.java
similarity index 94%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/model/data/DataSourceVO.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/model/data/DataSourceVO.java
index 0544c08..0ef71e8 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/data/DataSourceVO.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/data/DataSourceVO.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.service.model.data;
+package org.secretflow.easypsi.service.model.data;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/data/DataTableInformationVo.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/data/DataTableInformationVo.java
similarity index 96%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/model/data/DataTableInformationVo.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/model/data/DataTableInformationVo.java
index 901f32b..ab1fa18 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/data/DataTableInformationVo.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/data/DataTableInformationVo.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.secretflow.secretpad.service.model.data;
+package org.secretflow.easypsi.service.model.data;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/data/DataVersionVO.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/data/DataVersionVO.java
similarity index 73%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/model/data/DataVersionVO.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/model/data/DataVersionVO.java
index a26e837..84da9f2 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/data/DataVersionVO.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/data/DataVersionVO.java
@@ -1,4 +1,4 @@
-package org.secretflow.secretpad.service.model.data;
+package org.secretflow.easypsi.service.model.data;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
@@ -14,8 +14,8 @@
@Builder
public class DataVersionVO {
- @Schema(description = "secretpad tag")
- private String secretpadTag;
+ @Schema(description = "easypsi tag")
+ private String easypsiTag;
@Schema(description = "kuscia tag")
private String kusciaTag;
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/data/GetDataTableInformatinoRequest.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/data/GetDataTableInformatinoRequest.java
similarity index 95%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/model/data/GetDataTableInformatinoRequest.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/model/data/GetDataTableInformatinoRequest.java
index 234a53d..aadd1a6 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/data/GetDataTableInformatinoRequest.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/data/GetDataTableInformatinoRequest.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.secretflow.secretpad.service.model.data;
+package org.secretflow.easypsi.service.model.data;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/fabric/FabricLogRequest.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/fabric/FabricLogRequest.java
similarity index 94%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/model/fabric/FabricLogRequest.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/model/fabric/FabricLogRequest.java
index c9f8c34..edcfcab 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/fabric/FabricLogRequest.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/fabric/FabricLogRequest.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.service.model.fabric;
+package org.secretflow.easypsi.service.model.fabric;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/graph/GrapDataHeaderVO.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/graph/GrapDataHeaderVO.java
similarity index 91%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/model/graph/GrapDataHeaderVO.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/model/graph/GrapDataHeaderVO.java
index 12055a9..0e10889 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/graph/GrapDataHeaderVO.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/graph/GrapDataHeaderVO.java
@@ -1,4 +1,4 @@
-package org.secretflow.secretpad.service.model.graph;
+package org.secretflow.easypsi.service.model.graph;
import lombok.*;
import java.util.List;
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/graph/GrapDataTableVO.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/graph/GrapDataTableVO.java
similarity index 85%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/model/graph/GrapDataTableVO.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/model/graph/GrapDataTableVO.java
index 6f33c6e..94f09ca 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/graph/GrapDataTableVO.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/graph/GrapDataTableVO.java
@@ -1,4 +1,4 @@
-package org.secretflow.secretpad.service.model.graph;
+package org.secretflow.easypsi.service.model.graph;
import lombok.*;
import java.util.List;
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/graph/GraphNodeJobLogsVO.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/graph/GraphNodeJobLogsVO.java
similarity index 73%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/model/graph/GraphNodeJobLogsVO.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/model/graph/GraphNodeJobLogsVO.java
index a101b4a..d9e1245 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/graph/GraphNodeJobLogsVO.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/graph/GraphNodeJobLogsVO.java
@@ -1,8 +1,8 @@
-package org.secretflow.secretpad.service.model.graph;
+package org.secretflow.easypsi.service.model.graph;
import lombok.AllArgsConstructor;
import lombok.Data;
-import org.secretflow.secretpad.persistence.model.GraphJobStatus;
+import org.secretflow.easypsi.persistence.model.GraphJobStatus;
import java.util.List;
/**
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/graph/ProjectPsiJob.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/graph/ProjectPsiJob.java
similarity index 86%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/model/graph/ProjectPsiJob.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/model/graph/ProjectPsiJob.java
index 70cfacf..b726eb7 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/graph/ProjectPsiJob.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/graph/ProjectPsiJob.java
@@ -14,12 +14,12 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.service.model.graph;
+package org.secretflow.easypsi.service.model.graph;
-import org.secretflow.secretpad.common.util.JsonUtils;
-import org.secretflow.secretpad.persistence.entity.ProjectJobDO;
-import org.secretflow.secretpad.persistence.model.GraphNodeTaskStatus;
-import org.secretflow.secretpad.service.model.project.CreateProjectJobTaskRequest;
+import org.secretflow.easypsi.common.util.JsonUtils;
+import org.secretflow.easypsi.persistence.entity.ProjectJobDO;
+import org.secretflow.easypsi.persistence.model.GraphNodeTaskStatus;
+import org.secretflow.easypsi.service.model.project.CreateProjectJobTaskRequest;
import lombok.AllArgsConstructor;
import lombok.Builder;
@@ -102,12 +102,6 @@ public static ProjectPsiJob genProjectJob(ProjectJobDO job) {
return psiJob;
}
- public static ProjectJobDO toDO(ProjectPsiJob job) {
- ProjectJobDO jobDO = new ProjectJobDO();
- BeanUtils.copyProperties(job, jobDO);
- return jobDO;
- }
-
/**
* Job task
*/
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/node/CertificateDownloadInfo.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/node/CertificateDownloadInfo.java
similarity index 95%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/model/node/CertificateDownloadInfo.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/model/node/CertificateDownloadInfo.java
index 3270dd9..c04a134 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/node/CertificateDownloadInfo.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/node/CertificateDownloadInfo.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.service.model.node;
+package org.secretflow.easypsi.service.model.node;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/node/CreateNodeRequest.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/node/CreateNodeRequest.java
similarity index 86%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/model/node/CreateNodeRequest.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/model/node/CreateNodeRequest.java
index a10dee3..f0c4c3c 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/node/CreateNodeRequest.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/node/CreateNodeRequest.java
@@ -14,14 +14,13 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.service.model.node;
-
-import org.secretflow.secretpad.service.constant.Constants;
+package org.secretflow.easypsi.service.model.node;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Pattern;
import lombok.*;
+import org.secretflow.easypsi.service.constant.Constants;
/**
* Create node request
@@ -43,13 +42,6 @@ public class CreateNodeRequest {
@Schema(description = "certText")
private String certText;
- /**
- * NodeId
- */
- @NotBlank
- @Schema(description = "dstNodeId")
- private String dstNodeId;
-
/**
* dstNetAddress
*/
@@ -63,4 +55,10 @@ public class CreateNodeRequest {
*/
@Schema(description = "nodeRemark")
private String nodeRemark;
+
+ /**
+ * trust
+ */
+ @Schema(description = "trust")
+ private Boolean trust = false;
}
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/node/DeleteNodeIdRequest.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/node/DeleteNodeIdRequest.java
similarity index 85%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/model/node/DeleteNodeIdRequest.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/model/node/DeleteNodeIdRequest.java
index 1a9aeec..b390ed4 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/node/DeleteNodeIdRequest.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/node/DeleteNodeIdRequest.java
@@ -1,4 +1,4 @@
-package org.secretflow.secretpad.service.model.node;
+package org.secretflow.easypsi.service.model.node;
import jakarta.validation.constraints.NotBlank;
import lombok.*;
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/node/DownloadNodeCertificateRequest.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/node/DownloadNodeCertificateRequest.java
similarity index 94%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/model/node/DownloadNodeCertificateRequest.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/model/node/DownloadNodeCertificateRequest.java
index a4a8502..465c77f 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/node/DownloadNodeCertificateRequest.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/node/DownloadNodeCertificateRequest.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.service.model.node;
+package org.secretflow.easypsi.service.model.node;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/node/NodeIdRequest.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/node/NodeIdRequest.java
similarity index 94%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/model/node/NodeIdRequest.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/model/node/NodeIdRequest.java
index 0aaaea9..297410e 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/node/NodeIdRequest.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/node/NodeIdRequest.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.service.model.node;
+package org.secretflow.easypsi.service.model.node;
import jakarta.validation.constraints.NotBlank;
import lombok.*;
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/node/NodeRouteVO.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/node/NodeRouteVO.java
similarity index 93%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/model/node/NodeRouteVO.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/model/node/NodeRouteVO.java
index 6f62929..28480e4 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/node/NodeRouteVO.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/node/NodeRouteVO.java
@@ -14,9 +14,9 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.service.model.node;
+package org.secretflow.easypsi.service.model.node;
-import org.secretflow.secretpad.manager.integration.model.NodeRouteDTO;
+import org.secretflow.easypsi.manager.integration.model.NodeRouteDTO;
import lombok.*;
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/node/NodeVO.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/node/NodeVO.java
similarity index 88%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/model/node/NodeVO.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/model/node/NodeVO.java
index e435846..8412a76 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/node/NodeVO.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/node/NodeVO.java
@@ -14,9 +14,9 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.service.model.node;
+package org.secretflow.easypsi.service.model.node;
-import org.secretflow.secretpad.manager.integration.model.NodeDTO;
+import org.secretflow.easypsi.manager.integration.model.NodeDTO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
@@ -84,6 +84,11 @@ public class NodeVO {
*/
@Schema(description = "nodeRemark")
private String nodeRemark;
+ /**
+ * approved
+ */
+ @Schema(description = "trust")
+ private Boolean trust;
public static NodeVO from(NodeDTO nodeDTO) {
return NodeVO.builder().nodeId(nodeDTO.getNodeId()).nodeName(nodeDTO.getNodeName())
@@ -91,6 +96,8 @@ public static NodeVO from(NodeDTO nodeDTO) {
.netAddress(nodeDTO.getNetAddress()).nodeStatus(nodeDTO.getNodeStatus())
.gmtCreate(nodeDTO.getGmtCreate()).gmtModified(nodeDTO.getGmtModified())
.nodeRemark(nodeDTO.getNodeRemark())
+ .certText(nodeDTO.getCertText())
+ .trust(nodeDTO.getTrust())
.build();
}
diff --git a/secretpad-manager/src/main/java/org/secretflow/secretpad/manager/integration/model/DatatableSchema.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/node/UpdateNodeRequest.java
similarity index 65%
rename from secretpad-manager/src/main/java/org/secretflow/secretpad/manager/integration/model/DatatableSchema.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/model/node/UpdateNodeRequest.java
index cdc72f6..4d1fd42 100644
--- a/secretpad-manager/src/main/java/org/secretflow/secretpad/manager/integration/model/DatatableSchema.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/node/UpdateNodeRequest.java
@@ -14,32 +14,32 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.manager.integration.model;
+package org.secretflow.easypsi.service.model.node;
+import io.swagger.v3.oas.annotations.media.Schema;
+import jakarta.validation.constraints.NotNull;
import lombok.*;
/**
- * Datatable schema data transfer object
- *
- * @author : xiaonan.fhn
- * @date 2023/06/20
+ * @author yutu
+ * @date 2023/08/04
*/
@Builder
@Setter
@Getter
@NoArgsConstructor
@AllArgsConstructor
-public class DatatableSchema {
- /**
- * Feature name
- */
- String featureName;
+public class UpdateNodeRequest {
+
/**
- * Feature type
+ * nodeId
*/
- String featureType;
+ @Schema(description = "nodeId")
+ private String nodeId;
/**
- * Feature description
+ * approval
*/
- String featureDescription;
-}
+ @NotNull
+ @Schema(description = "trust")
+ private Boolean trust;
+}
\ No newline at end of file
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/node/UploadNodeResultVO.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/node/UploadNodeResultVO.java
similarity index 86%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/model/node/UploadNodeResultVO.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/model/node/UploadNodeResultVO.java
index d49499d..a4b17e5 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/node/UploadNodeResultVO.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/node/UploadNodeResultVO.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.service.model.node;
+package org.secretflow.easypsi.service.model.node;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;
@@ -31,12 +31,6 @@
@Setter
@Builder
public class UploadNodeResultVO {
- /**
- * Node id
- */
- @Schema(description = "node id")
- private String nodeId;
-
/**
* Certificate
*/
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/noderoute/CreateNodeRouterRequest.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/noderoute/CreateNodeRouterRequest.java
similarity index 93%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/model/noderoute/CreateNodeRouterRequest.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/model/noderoute/CreateNodeRouterRequest.java
index f578134..1f5354c 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/noderoute/CreateNodeRouterRequest.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/noderoute/CreateNodeRouterRequest.java
@@ -14,9 +14,9 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.service.model.noderoute;
+package org.secretflow.easypsi.service.model.noderoute;
-import org.secretflow.secretpad.service.constant.Constants;
+import org.secretflow.easypsi.service.constant.Constants;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/noderoute/NodeRouterVO.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/noderoute/NodeRouterVO.java
similarity index 89%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/model/noderoute/NodeRouterVO.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/model/noderoute/NodeRouterVO.java
index 8881baa..bdd9c87 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/noderoute/NodeRouterVO.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/noderoute/NodeRouterVO.java
@@ -14,12 +14,12 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.service.model.noderoute;
+package org.secretflow.easypsi.service.model.noderoute;
-import org.secretflow.secretpad.common.constant.DomainRouterConstants;
-import org.secretflow.secretpad.common.util.DateTimes;
-import org.secretflow.secretpad.persistence.entity.NodeRouteDO;
-import org.secretflow.secretpad.service.model.node.NodeVO;
+import org.secretflow.easypsi.common.constant.DomainRouterConstants;
+import org.secretflow.easypsi.common.util.DateTimes;
+import org.secretflow.easypsi.persistence.entity.NodeRouteDO;
+import org.secretflow.easypsi.service.model.node.NodeVO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/noderoute/RouterAddressRequest.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/noderoute/RouterAddressRequest.java
similarity index 81%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/model/noderoute/RouterAddressRequest.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/model/noderoute/RouterAddressRequest.java
index 40f4f80..54a4b42 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/noderoute/RouterAddressRequest.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/noderoute/RouterAddressRequest.java
@@ -1,10 +1,10 @@
-package org.secretflow.secretpad.service.model.noderoute;
+package org.secretflow.easypsi.service.model.noderoute;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Pattern;
import lombok.*;
-import org.secretflow.secretpad.service.constant.Constants;
+import org.secretflow.easypsi.service.constant.Constants;
/**
* @author chixian
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/noderoute/RouterIdRequest.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/noderoute/RouterIdRequest.java
similarity index 94%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/model/noderoute/RouterIdRequest.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/model/noderoute/RouterIdRequest.java
index 5bf97a4..7710f41 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/noderoute/RouterIdRequest.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/noderoute/RouterIdRequest.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.service.model.noderoute;
+package org.secretflow.easypsi.service.model.noderoute;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/noderoute/UpdateNodeRouterRequest.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/noderoute/UpdateNodeRouterRequest.java
similarity index 90%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/model/noderoute/UpdateNodeRouterRequest.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/model/noderoute/UpdateNodeRouterRequest.java
index 73726d1..8a7858b 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/noderoute/UpdateNodeRouterRequest.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/noderoute/UpdateNodeRouterRequest.java
@@ -14,9 +14,9 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.service.model.noderoute;
+package org.secretflow.easypsi.service.model.noderoute;
-import org.secretflow.secretpad.service.constant.Constants;
+import org.secretflow.easypsi.service.constant.Constants;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Pattern;
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/project/AgreeProjectJobTaskRequest.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/project/AgreeProjectJobTaskRequest.java
similarity index 85%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/model/project/AgreeProjectJobTaskRequest.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/model/project/AgreeProjectJobTaskRequest.java
index 783f4be..3ff6eb8 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/project/AgreeProjectJobTaskRequest.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/project/AgreeProjectJobTaskRequest.java
@@ -14,14 +14,11 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.service.model.project;
+package org.secretflow.easypsi.service.model.project;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-import lombok.NoArgsConstructor;
-import lombok.Setter;
+import lombok.*;
/**
* Agree project job task request
@@ -31,6 +28,7 @@
*/
@Getter
@Setter
+@Builder
@AllArgsConstructor
@NoArgsConstructor
public class AgreeProjectJobTaskRequest {
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/project/CreateProjectJobRequest.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/project/CreateProjectJobRequest.java
similarity index 90%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/model/project/CreateProjectJobRequest.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/model/project/CreateProjectJobRequest.java
index 0f40fa9..16807a0 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/project/CreateProjectJobRequest.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/project/CreateProjectJobRequest.java
@@ -14,9 +14,9 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.service.model.project;
+package org.secretflow.easypsi.service.model.project;
-import org.secretflow.secretpad.common.constant.JobConstants;
+import org.secretflow.easypsi.common.constant.JobConstants;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
@@ -111,16 +111,19 @@ public static class AdvancedConfig {
@Schema(description = "advancedJoinType")
private JobConstants.AdvancedJoinTypeEnum advancedJoinType;
- @Schema(description = "outputDifference")
- private Boolean outputDifference;
+ @Schema(description = "leftSide")
+ private String leftSide;
- @Schema(description = "datatableCount")
- private String datatableCount;
+ @Schema(description = "dataTableConfirmation")
+ private Boolean dataTableConfirmation = false;
+
+ @Schema(description = "dataTableCount")
+ private String dataTableCount = "L0";
@Setter
@Getter
@ToString
- public class ProtocolConfig {
+ public static class ProtocolConfig {
@Schema(description = "protocol")
private JobConstants.ProtocolEnum protocol;
diff --git a/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/project/CreateProjectJobTaskRequest.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/project/CreateProjectJobTaskRequest.java
new file mode 100644
index 0000000..15e60f6
--- /dev/null
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/project/CreateProjectJobTaskRequest.java
@@ -0,0 +1,338 @@
+/*
+ * Copyright 2023 Ant Group Co., Ltd.
+ *
+ * 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.
+ */
+
+package org.secretflow.easypsi.service.model.project;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import jakarta.validation.constraints.NotBlank;
+import lombok.*;
+import org.secretflow.easypsi.common.constant.JobConstants;
+import org.secretflow.easypsi.manager.integration.job.JobManager;
+import org.secretflow.easypsi.service.impl.DataServiceImpl;
+
+import java.io.File;
+import java.util.List;
+
+/**
+ * Delete project job task request
+ *
+ * @author guyu
+ * @date 2023/10/27
+ */
+@Builder
+@Getter
+@Setter
+@ToString
+@AllArgsConstructor
+@NoArgsConstructor
+public class CreateProjectJobTaskRequest {
+
+ @Schema(description = "job id")
+ private String jobId;
+ /**
+ * name
+ */
+ @Schema(description = "job name")
+ @NotBlank
+ private String name;
+
+ /**
+ * description
+ */
+ @Schema(description = "description")
+ private String description;
+
+ /**
+ * initiatorConfig
+ */
+ @Schema(description = "initiatorConfig")
+ private PsiConfig initiatorConfig;
+
+ /**
+ * partnerConfig
+ */
+ @Schema(description = "partnerConfig")
+ private PsiConfig partnerConfig;
+
+ @Getter
+ @Setter
+ @ToString
+ @Builder
+ @AllArgsConstructor
+ @NoArgsConstructor
+ public static class PsiConfig {
+ @Schema(description = "nodeId")
+ private String nodeId;
+
+ @Schema(description = "protocolConfig")
+ private ProtocolConfig protocolConfig;
+
+ @Schema(description = "inputConfig")
+ private InputConfig inputConfig;
+
+ @Schema(description = "outputConfig")
+ private OutputConfig outputConfig;
+
+ @Schema(description = "linkConfig")
+ private ContextDescProto linkConfig;
+
+ @Schema(description = "keys")
+ private List keys;
+
+ @Schema(description = "skipDuplicatesCheck")
+ private Boolean skipDuplicatesCheck;
+
+ @Schema(description = "disableAlignment")
+ private Boolean disableAlignment;
+
+ @Schema(description = "recoveryConfig")
+ private RecoveryConfig recoveryConfig;
+
+ @Schema(description = "advancedJoinType")
+ private JobConstants.AdvancedJoinTypeEnum advancedJoinType;
+
+ @Schema(description = "leftSide")
+ private String leftSide;
+
+ @Schema(description = "dataTableConfirmation")
+ private Boolean dataTableConfirmation = false;
+
+ @Schema(description = "dataTableCount")
+ private String dataTableCount = "L0";
+
+ @Getter
+ @Setter
+ @ToString
+ @Builder
+ @AllArgsConstructor
+ @NoArgsConstructor
+ public static class ContextDescProto {
+ private String recvTimeoutMs = JobConstants.RECV_TIMEOUT_MS;
+
+ private String httpTimeoutMs = JobConstants.HTTP_TIMEOUT_MS;
+
+ public static ContextDescProto from(CreateProjectJobRequest.AdvancedConfig advancedConfig) {
+ return ContextDescProto.builder()
+ .recvTimeoutMs(advancedConfig.getLinkConfig())
+ .httpTimeoutMs(advancedConfig.getLinkConfig())
+ .build();
+ }
+ }
+
+ @Getter
+ @Setter
+ @ToString
+ @Builder
+ @AllArgsConstructor
+ @NoArgsConstructor
+ public static class RecoveryConfig {
+ @Schema(description = "enabled")
+ private Boolean enabled;
+
+ @Schema(description = "folder")
+ private String folder;
+ }
+
+ @Getter
+ @Setter
+ @ToString
+ @Builder
+ @AllArgsConstructor
+ @NoArgsConstructor
+ public static class OutputConfig {
+ @Schema(description = "type")
+ private String type = JobConstants.DatatableTypeEnum.IO_TYPE_FILE_CSV.name();
+
+ @Schema(description = "path")
+ private String path;
+
+ public static OutputConfig from(CreateProjectJobRequest.PsiConfig outputConfig, String nodeId) {
+ return OutputConfig.builder()
+ .path(outputConfig.getBroadcastResult().contains(nodeId) ? outputConfig.getPath() : null)
+ .type(JobConstants.DatatableTypeEnum.IO_TYPE_FILE_CSV.name())
+ .build();
+ }
+ }
+
+ @Getter
+ @Setter
+ @ToString
+ @Builder
+ @AllArgsConstructor
+ @NoArgsConstructor
+ public static class InputConfig {
+ @Schema(description = "type")
+ private String type = JobConstants.DatatableTypeEnum.IO_TYPE_FILE_CSV.name();
+
+ @Schema(description = "path")
+ private String path;
+
+ public static InputConfig from(CreateProjectJobRequest.PsiConfig inputConfig) {
+ return InputConfig.builder()
+ .path(inputConfig.getPath())
+ .type(JobConstants.DatatableTypeEnum.IO_TYPE_FILE_CSV.name())
+ .build();
+ }
+ }
+
+ @Getter
+ @Setter
+ @ToString
+ @Builder
+ @AllArgsConstructor
+ @NoArgsConstructor
+ public static class ProtocolConfig {
+ @Schema(description = "protocol")
+ private JobConstants.ProtocolEnum protocol;
+
+ @Schema(description = "role")
+ private JobConstants.RoleEnum role;
+
+ @Schema(description = "broadcastResult")
+ private Boolean broadcastResult;
+
+ @Schema(description = "ecdhConfig")
+ private EcdhConfig ecdhConfig;
+ @Schema(description = "kkrtConfig")
+ private KkrtConfig kkrtConfig;
+
+ @Schema(description = "rr22Config")
+ private Rr22Config rr22Config;
+
+ @Getter
+ @Setter
+ @Builder
+ @AllArgsConstructor
+ @NoArgsConstructor
+ public static class EcdhConfig {
+ @Schema(description = "curve")
+ private String curve = JobConstants.CurveType.CURVE_FOURQ.name();
+
+ public static EcdhConfig from(CreateProjectJobRequest.AdvancedConfig.ProtocolConfig protocol) {
+ if (JobConstants.ProtocolEnum.PROTOCOL_ECDH.equals(protocol.getProtocol())) {
+ return EcdhConfig.builder()
+ .curve(protocol.getEcdhConfig().getCurve())
+ .build();
+ }
+ return null;
+ }
+ }
+
+ @Getter
+ @Setter
+ @Builder
+ @AllArgsConstructor
+ @NoArgsConstructor
+ public static class KkrtConfig {
+ @Schema(description = "bucketSize")
+ private String bucketSize = JobConstants.BUCKET_SIZE;
+
+ public static KkrtConfig from(CreateProjectJobRequest.AdvancedConfig.ProtocolConfig protocol) {
+ if (JobConstants.ProtocolEnum.PROTOCOL_KKRT.equals(protocol.getProtocol())) {
+ return KkrtConfig.builder()
+ .bucketSize(protocol.getKkrtConfig().getBucketSize())
+ .build();
+ }
+ return null;
+ }
+ }
+
+ @Getter
+ @Setter
+ @Builder
+ @AllArgsConstructor
+ @NoArgsConstructor
+ public static class Rr22Config {
+ @Schema(description = "bucketSize")
+ private String bucketSize = JobConstants.BUCKET_SIZE;
+
+ @Schema(description = "lowCommMode")
+ private Boolean lowCommMode = false;
+
+ public static Rr22Config from(CreateProjectJobRequest.AdvancedConfig.ProtocolConfig protocol) {
+ if (JobConstants.ProtocolEnum.PROTOCOL_RR22.equals(protocol.getProtocol())) {
+ return Rr22Config.builder()
+ .bucketSize(protocol.getRr22Config().getBucketSize())
+ .lowCommMode(protocol.getRr22Config().getLowCommMode())
+ .build();
+ }
+ return null;
+ }
+ }
+
+ public static ProtocolConfig from(CreateProjectJobRequest request, CreateProjectJobRequest.PsiConfig reauestPsiConfig) {
+ CreateProjectJobRequest.AdvancedConfig.ProtocolConfig requestProtocolConfig = request.getAdvancedConfig().getProtocolConfig();
+ List broadcast = request.getOutputConfig().getBroadcastResult();
+ JobConstants.RoleEnum role;
+
+ if (broadcast.contains(reauestPsiConfig.getNodeId())) {
+ role = JobConstants.RoleEnum.ROLE_RECEIVER;
+ } else {
+ role = JobConstants.RoleEnum.ROLE_SENDER;
+ }
+
+ return ProtocolConfig.builder()
+ .protocol(requestProtocolConfig.getProtocol())
+ .role(role)
+ .broadcastResult(broadcast.size() == 2)
+ .ecdhConfig(EcdhConfig.from(requestProtocolConfig))
+ .kkrtConfig(KkrtConfig.from(requestProtocolConfig))
+ .rr22Config(Rr22Config.from(requestProtocolConfig))
+ .build();
+ }
+
+
+ }
+
+ public static PsiConfig from(CreateProjectJobRequest request, CreateProjectJobRequest.PsiConfig reauestPsiConfig, String jobId) {
+ CreateProjectJobRequest.AdvancedConfig requestAdvancedConfig = request.getAdvancedConfig();
+ return PsiConfig.builder()
+ .nodeId(reauestPsiConfig.getNodeId())
+ .protocolConfig(ProtocolConfig.from(request, reauestPsiConfig))
+ .inputConfig(InputConfig.from(reauestPsiConfig))
+ .outputConfig(OutputConfig.from(request.getOutputConfig(), reauestPsiConfig.getNodeId()))
+ .linkConfig(ContextDescProto.from(requestAdvancedConfig))
+ .keys(reauestPsiConfig.getKeys())
+ .skipDuplicatesCheck(requestAdvancedConfig.getSkipDuplicatesCheck())
+ .disableAlignment(requestAdvancedConfig.getDisableAlignment())
+ .recoveryConfig(RecoveryConfig.builder()
+ .folder(JobManager.KUSCIA_DATA_PATH + JobManager.PROJECT_JOB_TASK_TMP + jobId + File.separator)
+ .enabled(requestAdvancedConfig.getRecoveryEnabled())
+ .build())
+ .advancedJoinType(requestAdvancedConfig.getAdvancedJoinType())
+ .leftSide(requestAdvancedConfig.getLeftSide())
+ .dataTableConfirmation(requestAdvancedConfig.getDataTableConfirmation())
+ .dataTableCount(requestAdvancedConfig.getDataTableConfirmation() ?
+ DataServiceImpl.dataTableCountCache.get(DataServiceImpl.spliceNodeTable(reauestPsiConfig.getNodeId(), reauestPsiConfig.getPath())) : null)
+ .build();
+ }
+ }
+
+ public static CreateProjectJobTaskRequest fromJobRequest(CreateProjectJobRequest request, String jobId) {
+ PsiConfig partnerConfig = PsiConfig.from(request, request.getPartnerConfig(), jobId);
+ if (partnerConfig.getProtocolConfig().getBroadcastResult())
+ partnerConfig.getProtocolConfig().setRole(JobConstants.RoleEnum.ROLE_SENDER);
+ return CreateProjectJobTaskRequest.builder()
+ .name(request.getName())
+ .description(request.getDescription())
+ .jobId(jobId)
+ .initiatorConfig(PsiConfig.from(request, request.getInitiatorConfig(), jobId))
+ .partnerConfig(partnerConfig)
+ .build();
+
+ }
+
+}
\ No newline at end of file
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/project/CreateProjectJobVO.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/project/CreateProjectJobVO.java
similarity index 93%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/model/project/CreateProjectJobVO.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/model/project/CreateProjectJobVO.java
index 7aee3dd..2375a64 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/project/CreateProjectJobVO.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/project/CreateProjectJobVO.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.service.model.project;
+package org.secretflow.easypsi.service.model.project;
import lombok.*;
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/project/DeleteProjectJobTaskRequest.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/project/DeleteProjectJobTaskRequest.java
similarity index 95%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/model/project/DeleteProjectJobTaskRequest.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/model/project/DeleteProjectJobTaskRequest.java
index 50e59ad..889d9ad 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/project/DeleteProjectJobTaskRequest.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/project/DeleteProjectJobTaskRequest.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.service.model.project;
+package org.secretflow.easypsi.service.model.project;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/project/DownloadProjectResult.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/project/DownloadProjectResult.java
similarity index 94%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/model/project/DownloadProjectResult.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/model/project/DownloadProjectResult.java
index 42e16bc..ae6ac69 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/project/DownloadProjectResult.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/project/DownloadProjectResult.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.secretflow.secretpad.service.model.project;
+package org.secretflow.easypsi.service.model.project;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/project/GetProjectJobDataHeaderRequest.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/project/GetProjectJobDataHeaderRequest.java
similarity index 93%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/model/project/GetProjectJobDataHeaderRequest.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/model/project/GetProjectJobDataHeaderRequest.java
index 2bd8b7c..6e061ba 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/project/GetProjectJobDataHeaderRequest.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/project/GetProjectJobDataHeaderRequest.java
@@ -1,4 +1,4 @@
-package org.secretflow.secretpad.service.model.project;
+package org.secretflow.easypsi.service.model.project;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/project/GetProjectJobLogRequest.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/project/GetProjectJobLogRequest.java
similarity index 87%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/model/project/GetProjectJobLogRequest.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/model/project/GetProjectJobLogRequest.java
index e7502ed..47da199 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/project/GetProjectJobLogRequest.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/project/GetProjectJobLogRequest.java
@@ -1,4 +1,4 @@
-package org.secretflow.secretpad.service.model.project;
+package org.secretflow.easypsi.service.model.project;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/project/GetProjectJobRequest.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/project/GetProjectJobRequest.java
similarity index 95%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/model/project/GetProjectJobRequest.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/model/project/GetProjectJobRequest.java
index df99940..f9ceabe 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/project/GetProjectJobRequest.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/project/GetProjectJobRequest.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.service.model.project;
+package org.secretflow.easypsi.service.model.project;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/project/GetProjectJobTableRequest.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/project/GetProjectJobTableRequest.java
similarity index 89%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/model/project/GetProjectJobTableRequest.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/model/project/GetProjectJobTableRequest.java
index a8b1233..2a10199 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/project/GetProjectJobTableRequest.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/project/GetProjectJobTableRequest.java
@@ -1,4 +1,4 @@
-package org.secretflow.secretpad.service.model.project;
+package org.secretflow.easypsi.service.model.project;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/project/GetloadProjectResult.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/project/GetloadProjectResult.java
similarity index 85%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/model/project/GetloadProjectResult.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/model/project/GetloadProjectResult.java
index 7942a8e..4b8708b 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/project/GetloadProjectResult.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/project/GetloadProjectResult.java
@@ -1,4 +1,4 @@
-package org.secretflow.secretpad.service.model.project;
+package org.secretflow.easypsi.service.model.project;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/project/ListProjectJobRequest.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/project/ListProjectJobRequest.java
similarity index 86%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/model/project/ListProjectJobRequest.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/model/project/ListProjectJobRequest.java
index 9e23cde..dd66154 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/project/ListProjectJobRequest.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/project/ListProjectJobRequest.java
@@ -14,10 +14,10 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.service.model.project;
+package org.secretflow.easypsi.service.model.project;
-import org.secretflow.secretpad.common.constant.DatabaseConstants;
-import org.secretflow.secretpad.persistence.model.GraphJobStatus;
+import org.secretflow.easypsi.common.constant.DatabaseConstants;
+import org.secretflow.easypsi.persistence.model.GraphJobStatus;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/project/PageRequest.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/project/PageRequest.java
similarity index 95%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/model/project/PageRequest.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/model/project/PageRequest.java
index 014c9f9..5487811 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/project/PageRequest.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/project/PageRequest.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.service.model.project;
+package org.secretflow.easypsi.service.model.project;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Max;
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/project/PageResponse.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/project/PageResponse.java
similarity index 96%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/model/project/PageResponse.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/model/project/PageResponse.java
index df3c42c..0f6052e 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/project/PageResponse.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/project/PageResponse.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.service.model.project;
+package org.secretflow.easypsi.service.model.project;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/project/ProjectJobBaseVO.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/project/ProjectJobBaseVO.java
similarity index 89%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/model/project/ProjectJobBaseVO.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/model/project/ProjectJobBaseVO.java
index 17d9bee..3da28c4 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/project/ProjectJobBaseVO.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/project/ProjectJobBaseVO.java
@@ -14,12 +14,12 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.service.model.project;
+package org.secretflow.easypsi.service.model.project;
-import org.secretflow.secretpad.common.util.DateTimes;
-import org.secretflow.secretpad.persistence.entity.ProjectJobDO;
-import org.secretflow.secretpad.persistence.model.GraphJobStatus;
+import org.secretflow.easypsi.common.util.DateTimes;
+import org.secretflow.easypsi.persistence.entity.ProjectJobDO;
+import org.secretflow.easypsi.persistence.model.GraphJobStatus;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
diff --git a/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/project/ProjectJobListByBlackScreenVO.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/project/ProjectJobListByBlackScreenVO.java
new file mode 100644
index 0000000..0942964
--- /dev/null
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/project/ProjectJobListByBlackScreenVO.java
@@ -0,0 +1,100 @@
+/*
+ * Copyright 2024 Ant Group Co., Ltd.
+ *
+ * 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.
+ */
+package org.secretflow.easypsi.service.model.project;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.*;
+import org.secretflow.easypsi.persistence.model.GraphJobOperation;
+import org.secretflow.easypsi.persistence.model.GraphJobStatus;
+
+import java.util.List;
+
+/**
+ * @author chixian
+ * @date 2024/03/05
+ */
+@Getter
+@Setter
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class ProjectJobListByBlackScreenVO {
+ /**
+ * Job id
+ */
+ @Schema(description = "job id")
+ private String jobId;
+ /**
+ * name
+ */
+ @Schema(description = "job name")
+ private String name;
+
+ /**
+ * srcNodeId
+ */
+ @Schema(description = "srcNodeId")
+ private String srcNodeId;
+
+ /**
+ * dstNodeId
+ */
+ @Schema(description = "dstNodeId")
+ private String dstNodeId;
+
+ /**
+ * operation
+ */
+ @Schema(description = "operation")
+ private List operation;
+
+ /**
+ * Job status
+ */
+ @Schema(description = "job status")
+ private GraphJobStatus status;
+ /**
+ * Job start time
+ */
+ @Schema(description = "job start time")
+ private String gmtCreate;
+ /**
+ * Job finish time
+ */
+ @Schema(description = "job finish time")
+ private String gmtFinished;
+
+
+ /**
+ * Job error message
+ */
+ @Schema(description = "job error message")
+ private String errMsg;
+
+ public static ProjectJobListByBlackScreenVO from(ProjectJobListVO projectJobListVO){
+ return ProjectJobListByBlackScreenVO.builder()
+ .jobId(projectJobListVO.getJobId())
+ .name(projectJobListVO.getName())
+ .srcNodeId(projectJobListVO.getSrcNodeId())
+ .dstNodeId(projectJobListVO.getDstNodeId())
+ .operation(projectJobListVO.getOperation())
+ .status(projectJobListVO.getStatus())
+ .gmtCreate(projectJobListVO.getGmtCreate())
+ .gmtFinished(projectJobListVO.getGmtFinished())
+ .errMsg(projectJobListVO.getErrMsg())
+ .build();
+ }
+}
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/project/ProjectJobListVO.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/project/ProjectJobListVO.java
similarity index 84%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/model/project/ProjectJobListVO.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/model/project/ProjectJobListVO.java
index e2dbafa..aaf08df 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/project/ProjectJobListVO.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/project/ProjectJobListVO.java
@@ -14,10 +14,10 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.service.model.project;
+package org.secretflow.easypsi.service.model.project;
-import org.secretflow.secretpad.persistence.model.GraphJobOperation;
-import org.secretflow.secretpad.service.model.data.DataTableInformationVo;
+import org.secretflow.easypsi.persistence.model.GraphJobOperation;
+import org.secretflow.easypsi.service.model.data.DataTableInformationVo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
@@ -77,4 +77,10 @@ public class ProjectJobListVO extends ProjectJobBaseVO {
*/
@Schema(description = "partnerdstDataTableInformation")
private DataTableInformationVo.DataTableInformation partnerdstDataTableInformation;
+
+ /**
+ * dataTableConfirmation
+ */
+ @Schema(description = "dataTableConfirmation")
+ private Boolean dataTableConfirmation;
}
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/project/ProjectJobResultVO.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/project/ProjectJobResultVO.java
similarity index 95%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/model/project/ProjectJobResultVO.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/model/project/ProjectJobResultVO.java
index a9db980..b0abe2c 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/project/ProjectJobResultVO.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/project/ProjectJobResultVO.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.secretflow.secretpad.service.model.project;
+package org.secretflow.easypsi.service.model.project;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/project/ProjectJobVO.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/project/ProjectJobVO.java
similarity index 92%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/model/project/ProjectJobVO.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/model/project/ProjectJobVO.java
index 217d84a..37f03ce 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/project/ProjectJobVO.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/project/ProjectJobVO.java
@@ -14,9 +14,9 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.service.model.project;
+package org.secretflow.easypsi.service.model.project;
-import org.secretflow.secretpad.persistence.model.GraphJobOperation;
+import org.secretflow.easypsi.persistence.model.GraphJobOperation;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/project/RejectProjectJobTaskRequest.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/project/RejectProjectJobTaskRequest.java
similarity index 95%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/model/project/RejectProjectJobTaskRequest.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/model/project/RejectProjectJobTaskRequest.java
index f9a0f87..a20c868 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/project/RejectProjectJobTaskRequest.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/project/RejectProjectJobTaskRequest.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.service.model.project;
+package org.secretflow.easypsi.service.model.project;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/project/StopProjectJobTaskRequest.java b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/project/StopProjectJobTaskRequest.java
similarity index 95%
rename from secretpad-service/src/main/java/org/secretflow/secretpad/service/model/project/StopProjectJobTaskRequest.java
rename to easypsi-service/src/main/java/org/secretflow/easypsi/service/model/project/StopProjectJobTaskRequest.java
index e5b0345..a4ae91c 100644
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/project/StopProjectJobTaskRequest.java
+++ b/easypsi-service/src/main/java/org/secretflow/easypsi/service/model/project/StopProjectJobTaskRequest.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.service.model.project;
+package org.secretflow.easypsi.service.model.project;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
diff --git a/easypsi-service/src/test/java/org/secretflow/easypsi/service/DefaultInterfaceResourceAuthTest.java b/easypsi-service/src/test/java/org/secretflow/easypsi/service/DefaultInterfaceResourceAuthTest.java
new file mode 100644
index 0000000..f11fcea
--- /dev/null
+++ b/easypsi-service/src/test/java/org/secretflow/easypsi/service/DefaultInterfaceResourceAuthTest.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2024 Ant Group Co., Ltd.
+ *
+ * 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.
+ */
+
+package org.secretflow.easypsi.service;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.mockito.Mockito;
+import org.secretflow.easypsi.common.constant.PlatformType;
+import org.secretflow.easypsi.common.constant.UserOwnerType;
+import org.secretflow.easypsi.common.dto.UserContextDTO;
+import org.secretflow.easypsi.common.util.UserContext;
+import org.secretflow.easypsi.service.auth.impl.DefaultInterfaceResourceAuth;
+import org.secretflow.easypsi.service.impl.EnvServiceImpl;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.mock.mockito.MockBean;
+
+/**
+ * Interface Resource Auth Test
+ *
+ * @author lihaixin
+ * @date 2024/03/11
+ */
+@SpringBootTest(classes = {DefaultInterfaceResourceAuth.class, EnvServiceImpl.class})
+public class DefaultInterfaceResourceAuthTest {
+
+
+ @MockBean
+ private EnvService envService;
+
+ @MockBean
+ private DefaultInterfaceResourceAuth defaultInterfaceResourceAuth;
+
+
+ @BeforeEach
+ void setUp() {
+ UserContextDTO userContextDTO = new UserContextDTO();
+ userContextDTO.setName("admin");
+ userContextDTO.setOwnerId("kuscia-system");
+ userContextDTO.setOwnerType(UserOwnerType.CENTER);
+ userContextDTO.setToken("token");
+ userContextDTO.setPlatformType(PlatformType.P2P);
+ UserContext.setBaseUser(userContextDTO);
+ }
+
+ @Test
+ void testCheckForPlatformManager() {
+ Mockito.when(envService.getPlatformNodeId()).thenReturn("platformManagerId");
+ defaultInterfaceResourceAuth.check("anyResourceCode");
+ }
+
+
+}
\ No newline at end of file
diff --git a/easypsi-service/src/test/java/org/secretflow/easypsi/service/JobSyncListenerTest.java b/easypsi-service/src/test/java/org/secretflow/easypsi/service/JobSyncListenerTest.java
new file mode 100644
index 0000000..9dabfc9
--- /dev/null
+++ b/easypsi-service/src/test/java/org/secretflow/easypsi/service/JobSyncListenerTest.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2024 Ant Group Co., Ltd.
+ *
+ * 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.
+ */
+
+package org.secretflow.easypsi.service;
+
+import org.junit.jupiter.api.Test;
+import org.mockito.Mockito;
+import org.secretflow.easypsi.manager.integration.job.JobManager;
+import org.secretflow.easypsi.service.listener.JobSyncListener;
+import org.springframework.boot.context.event.ApplicationReadyEvent;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.mock.mockito.MockBean;
+
+/**
+ * Job Sync Listener Test
+ *
+ * @author lihaixin
+ * @date 2024/03/08
+ */
+@SpringBootTest(classes = {JobManager.class, JobSyncListener.class})
+public class JobSyncListenerTest {
+
+ @MockBean
+ private JobManager jobManager;
+
+ @MockBean
+ private JobSyncListener jobSyncListener;
+
+
+ @Test
+ public void testOnApplicationEvent() {
+ ApplicationReadyEvent event = Mockito.mock(ApplicationReadyEvent.class);
+ Mockito.doNothing().when(jobManager).startSync();
+ jobSyncListener.onApplicationEvent(event);
+ //exception
+ Mockito.doThrow(new RuntimeException()).when(jobManager).startSync();
+ jobSyncListener.onApplicationEvent(event);
+ }
+}
\ No newline at end of file
diff --git a/secretpad-common/src/test/java/org/secretflow/secretpad/common/util/FileTest.java b/easypsi-service/src/test/java/org/secretflow/easypsi/service/ProtoUtilsTest.java
similarity index 65%
rename from secretpad-common/src/test/java/org/secretflow/secretpad/common/util/FileTest.java
rename to easypsi-service/src/test/java/org/secretflow/easypsi/service/ProtoUtilsTest.java
index 9ff2dbc..b121974 100644
--- a/secretpad-common/src/test/java/org/secretflow/secretpad/common/util/FileTest.java
+++ b/easypsi-service/src/test/java/org/secretflow/easypsi/service/ProtoUtilsTest.java
@@ -14,24 +14,23 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.common.util;
+package org.secretflow.easypsi.service;
+import com.google.protobuf.InvalidProtocolBufferException;
import org.junit.jupiter.api.Test;
-
-import java.io.FileNotFoundException;
+import org.secretflow.proto.component.Data;
/**
- * File test
+ * ProtoUtils test
*
* @author yansi
- * @date 2023/5/9
+ * @date 2023/6/1
*/
-public class FileTest {
+public class ProtoUtilsTest {
+
@Test
- public void testLoadFile() throws FileNotFoundException {
- String[] filenames = {"classpath:./a/a.txt"};
- for (String filename : filenames) {
- FileUtils.readFile(filename);
- }
+ public void testPrint() throws InvalidProtocolBufferException {
+ Data.DistData.Builder distDataBuilder = Data.DistData.newBuilder();
+
}
}
diff --git a/easypsi-service/src/test/java/org/secretflow/easypsi/service/RsaEncryptionKeyServiceTest.java b/easypsi-service/src/test/java/org/secretflow/easypsi/service/RsaEncryptionKeyServiceTest.java
new file mode 100644
index 0000000..1dd6ecb
--- /dev/null
+++ b/easypsi-service/src/test/java/org/secretflow/easypsi/service/RsaEncryptionKeyServiceTest.java
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2024 Ant Group Co., Ltd.
+ *
+ * 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.
+ */
+
+package org.secretflow.easypsi.service;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.secretflow.easypsi.common.util.RsaUtils;
+import org.secretflow.easypsi.persistence.entity.RsaEncryptionKeyDO;
+import org.secretflow.easypsi.persistence.repository.RsaEncryptionKeyRepository;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.mock.mockito.MockBean;
+
+import java.time.LocalDateTime;
+import java.util.Map;
+
+import static org.mockito.Mockito.when;
+
+/**
+ * Rsa Encryption Key Service Test
+ *
+ * @author lihaixin
+ * @date 2024/03/12
+ */
+@SpringBootTest(classes = {RsaEncryptionKeyService.class, RsaEncryptionKeyRepository.class})
+public class RsaEncryptionKeyServiceTest {
+
+ @MockBean
+ private RsaEncryptionKeyService rsaEncryptionKeyService;
+
+ @MockBean
+ private RsaEncryptionKeyRepository rsaEncryptionKeyRepository;
+
+ public static String rsaPublicKey;
+ public static String rsaPrivateKey;
+
+ @BeforeEach
+ public void setUp() {
+ Map keyMap = RsaUtils.generateRSAKeys();
+ rsaPublicKey = keyMap.get(RsaUtils.PUBLIC_KEY_NAME);
+ rsaPrivateKey = keyMap.get(RsaUtils.PRIVATE_KEY_NAME);
+ }
+
+ @Test
+ public void testByPublicKeyExistingKey() {
+ RsaEncryptionKeyDO expectedRsaKey = buildRsaEncryptionKeyDO();
+ when(rsaEncryptionKeyRepository.findByPublicKey(rsaPublicKey)).thenReturn(expectedRsaKey);
+ rsaEncryptionKeyService.findByPublicKey(rsaPublicKey);
+ }
+
+ @Test
+ public void testLasKey() {
+ LocalDateTime now = LocalDateTime.now();
+ RsaEncryptionKeyDO latestKey = buildRsaEncryptionKeyDO();
+ latestKey.setKeyInvalidTime(now.plusMinutes(60));
+ when(rsaEncryptionKeyRepository.findLastKey()).thenReturn(latestKey);
+ rsaEncryptionKeyService.findByPublicKey(null);
+ }
+
+ @Test
+ public void testFindByPublicKeyNoValidKeys() {
+ LocalDateTime now = LocalDateTime.now();
+ RsaEncryptionKeyDO expiredKey = buildRsaEncryptionKeyDO();
+ expiredKey.setKeyInvalidTime(now.minusMinutes(1));
+ when(rsaEncryptionKeyRepository.findLastKey()).thenReturn(expiredKey);
+ rsaEncryptionKeyService.findByPublicKey(null);
+ }
+
+ private RsaEncryptionKeyDO buildRsaEncryptionKeyDO() {
+ RsaEncryptionKeyDO rsaEncryptionKeyDO = new RsaEncryptionKeyDO();
+ rsaEncryptionKeyDO.setPublicKey(rsaPublicKey);
+ rsaEncryptionKeyDO.setPrivateKey(rsaPrivateKey);
+ return rsaEncryptionKeyDO;
+ }
+
+}
\ No newline at end of file
diff --git a/easypsi-service/src/test/java/org/secretflow/easypsi/service/auth/AuthServiceTest.java b/easypsi-service/src/test/java/org/secretflow/easypsi/service/auth/AuthServiceTest.java
new file mode 100644
index 0000000..d6a7c49
--- /dev/null
+++ b/easypsi-service/src/test/java/org/secretflow/easypsi/service/auth/AuthServiceTest.java
@@ -0,0 +1,142 @@
+/*
+ * Copyright 2024 Ant Group Co., Ltd.
+ *
+ * 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.
+ */
+
+package org.secretflow.easypsi.service.auth;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.mockito.Mockito;
+import org.secretflow.easypsi.common.dto.UserContextDTO;
+import org.secretflow.easypsi.common.util.RsaUtils;
+import org.secretflow.easypsi.common.util.Sha256Utils;
+import org.secretflow.easypsi.common.util.UUIDUtils;
+import org.secretflow.easypsi.manager.integration.fabric.FabricManager;
+import org.secretflow.easypsi.persistence.entity.AccountsDO;
+import org.secretflow.easypsi.persistence.entity.RsaEncryptionKeyDO;
+import org.secretflow.easypsi.persistence.entity.TokensDO;
+import org.secretflow.easypsi.persistence.repository.FabricLogRepository;
+import org.secretflow.easypsi.persistence.repository.ProjectJobRepository;
+import org.secretflow.easypsi.persistence.repository.UserAccountsRepository;
+import org.secretflow.easypsi.persistence.repository.UserTokensRepository;
+import org.secretflow.easypsi.service.*;
+import org.secretflow.easypsi.service.model.auth.LoginRequest;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.mock.mockito.MockBean;
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
+
+import java.time.LocalDateTime;
+import java.util.Map;
+
+/**
+ * Auth Service Test
+ *
+ * @author lihaixin
+ * @date 2024/03/11
+ */
+@SpringBootTest(classes = {AuthService.class, UserService.class, UserTokensRepository.class})
+public class AuthServiceTest {
+
+ @MockBean
+ private UserService userService;
+
+ @MockBean
+ private AuthService authService;
+
+ @MockBean
+ private UserAccountsRepository userAccountsRepository;
+
+ @MockBean
+ private UserTokensRepository userTokensRepository;
+
+ @MockBean
+ private EnvService envService;
+
+ @MockBean
+ private SysResourcesBizService resourcesBizService;
+
+ @MockBean
+ private ProjectJobRepository projectJobRepository;
+
+ @Value("${easypsi.account-error-max-attempts:5}")
+ private Integer maxAttempts;
+
+ @Value("${easypsi.account-error-lock-time-minutes:30}")
+ private Integer lockTimeMinutes;
+
+ @MockBean
+ private FabricManager fabricManager;
+
+ @MockBean
+ private FabricLogRepository fabricLogRepository;
+
+ @MockBean
+ private RsaEncryptionKeyService rsaEncryptionKeyService;
+
+ @MockBean
+ @Qualifier("fabricThreadPool")
+ private ThreadPoolTaskExecutor threadPoolTaskExecutor;
+
+
+ public static String userName = "admin";
+ public static String password = "admin";
+
+ public static String rsaPublicKey;
+ public static String rsaPrivateKey;
+
+ @BeforeEach
+ public void setUp() {
+ Map keyMap = RsaUtils.generateRSAKeys();
+ rsaPublicKey = keyMap.get(RsaUtils.PUBLIC_KEY_NAME);
+ rsaPrivateKey = keyMap.get(RsaUtils.PRIVATE_KEY_NAME);
+ password = Sha256Utils.hash(password);
+ }
+
+ @Test
+ public void testLoginSuccess() {
+ //not rsa
+ LoginRequest request = new LoginRequest();
+ request.setName(userName);
+ //rsa password
+ request.setPasswordHash(RsaUtils.encrypt(password, rsaPublicKey));
+ Mockito.when(userService.getUserByName(request.getName())).thenReturn(buildAccountsDO());
+ Mockito.when(rsaEncryptionKeyService.findByPublicKey(request.getPublicKey())).thenReturn(buildRsaEncryptionKeyDO());
+
+ //success
+ authService.login(request);
+
+
+ //fail
+ LoginRequest failRequest = new LoginRequest();
+ authService.login(failRequest);
+ }
+
+ private AccountsDO buildAccountsDO() {
+ AccountsDO accountsDO = new AccountsDO();
+ accountsDO.setName(userName);
+ accountsDO.setPasswordHash(password);
+ return accountsDO;
+ }
+
+ private RsaEncryptionKeyDO buildRsaEncryptionKeyDO() {
+ RsaEncryptionKeyDO rsaEncryptionKeyDO = new RsaEncryptionKeyDO();
+ rsaEncryptionKeyDO.setPublicKey(rsaPublicKey);
+ rsaEncryptionKeyDO.setPrivateKey(rsaPrivateKey);
+ return rsaEncryptionKeyDO;
+ }
+
+}
\ No newline at end of file
diff --git a/secretpad-common/src/main/java/org/secretflow/secretpad/common/util/TypeConvertUtils.java b/easypsi-service/src/test/java/org/secretflow/easypsi/service/constant/ConstantTest.java
similarity index 51%
rename from secretpad-common/src/main/java/org/secretflow/secretpad/common/util/TypeConvertUtils.java
rename to easypsi-service/src/test/java/org/secretflow/easypsi/service/constant/ConstantTest.java
index e59459a..ce418ff 100644
--- a/secretpad-common/src/main/java/org/secretflow/secretpad/common/util/TypeConvertUtils.java
+++ b/easypsi-service/src/test/java/org/secretflow/easypsi/service/constant/ConstantTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2023 Ant Group Co., Ltd.
+ * Copyright 2024 Ant Group Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,27 +14,24 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.common.util;
+package org.secretflow.easypsi.service.constant;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
- * Type convert utils
+ * Constant Test
*
- * @author : xiaonan.fhn
- * @date 2023/06/27
+ * @author lihaixin
+ * @date 2024/03/11
*/
-public class TypeConvertUtils {
- /**
- * Convert long to bytes
- *
- * @param v
- * @return bytes
- */
- public static byte[] long2Bytes(long v) {
- byte[] buffer = new byte[8];
- for (int i = 0; i < 8; i++) {
- int offset = 64 - (i + 1) * 8;
- buffer[i] = (byte) ((v >> offset) & 0xff);
- }
- return buffer;
+public class ConstantTest {
+
+
+ @Test
+ public void constantTest() {
+ assertEquals("easypsi", ComponentConstants.EASYPSI);
+ assertEquals("^.{1,50}:([0-9]|[1-9]\\d|[1-9]\\d{2}|[1-9]\\d{3}|[1-5]\\d{4}|6[0-4]\\d{3}|65[0-4]\\d{2}|655[0-2]\\d|6553[0-5])$", Constants.IP_PORT_PATTERN);
}
-}
+}
\ No newline at end of file
diff --git a/easypsi-service/src/test/java/org/secretflow/easypsi/service/model/AgreeProjectJobTaskRequestTest.java b/easypsi-service/src/test/java/org/secretflow/easypsi/service/model/AgreeProjectJobTaskRequestTest.java
new file mode 100644
index 0000000..4837b31
--- /dev/null
+++ b/easypsi-service/src/test/java/org/secretflow/easypsi/service/model/AgreeProjectJobTaskRequestTest.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2024 Ant Group Co., Ltd.
+ *
+ * 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.
+ */
+
+package org.secretflow.easypsi.service.model;
+
+import jakarta.validation.Validation;
+import jakarta.validation.Validator;
+import jakarta.validation.ValidatorFactory;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.secretflow.easypsi.service.model.project.AgreeProjectJobTaskRequest;
+
+import java.util.Set;
+
+/**
+ * Agree Project Job Task Request Test
+ *
+ * @author lihaixin
+ * @date 2024/03/12
+ */
+@ExtendWith(MockitoExtension.class)
+public class AgreeProjectJobTaskRequestTest {
+
+ private Validator validator;
+
+ @BeforeEach
+ public void setUp() {
+ ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
+ validator = factory.getValidator();
+ }
+
+ @Test
+ public void testValidJobId() {
+ AgreeProjectJobTaskRequest request = AgreeProjectJobTaskRequest.builder().jobId("valid-job-id").build();
+ Set> violations = validator.validate(request);
+ assert violations.isEmpty();
+ }
+
+ @Test
+ public void testBlankJobId() {
+ AgreeProjectJobTaskRequest request = AgreeProjectJobTaskRequest.builder().jobId("").build();
+ Set> violations = validator.validate(request);
+ assert !violations.isEmpty();
+ }
+
+ @Test
+ public void testNullJobId() {
+ AgreeProjectJobTaskRequest request = AgreeProjectJobTaskRequest.builder().jobId(null).build();
+ Set> violations = validator.validate(request);
+ assert !violations.isEmpty();
+ }
+}
\ No newline at end of file
diff --git a/easypsi-service/src/test/java/org/secretflow/easypsi/service/model/CreateProjectJobRequestTest.java b/easypsi-service/src/test/java/org/secretflow/easypsi/service/model/CreateProjectJobRequestTest.java
new file mode 100644
index 0000000..6a6775b
--- /dev/null
+++ b/easypsi-service/src/test/java/org/secretflow/easypsi/service/model/CreateProjectJobRequestTest.java
@@ -0,0 +1,146 @@
+/*
+ * Copyright 2024 Ant Group Co., Ltd.
+ *
+ * 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.
+ */
+
+package org.secretflow.easypsi.service.model;
+
+import jakarta.validation.ConstraintViolation;
+import jakarta.validation.Validation;
+import jakarta.validation.Validator;
+import jakarta.validation.ValidatorFactory;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.secretflow.easypsi.common.constant.JobConstants;
+import org.secretflow.easypsi.service.model.project.CreateProjectJobRequest;
+
+import java.util.Arrays;
+import java.util.Set;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+/**
+ * Create Project Job Request Test
+ *
+ * @author lihaixin
+ * @date 2024/03/12
+ */
+@ExtendWith(MockitoExtension.class)
+public class CreateProjectJobRequestTest {
+
+ private Validator validator;
+
+ @BeforeEach
+ public void setUp() {
+ ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
+ validator = factory.getValidator();
+ }
+
+ @Test
+ public void testNoArgsConstructor() {
+ CreateProjectJobRequest request = new CreateProjectJobRequest();
+ assertNotNull(request);
+ }
+
+ @Test
+ public void testSetNameAndGet() {
+ CreateProjectJobRequest request = new CreateProjectJobRequest();
+ request.setName("jobName");
+ assertEquals("jobName", request.getName());
+ }
+
+ @Test
+ public void testNameNotBlankValidation() {
+ CreateProjectJobRequest request = new CreateProjectJobRequest();
+ request.setName("");
+ Set> violations = validator.validate(request);
+ assertEquals(1, violations.size());
+ }
+
+ @Test
+ public void testPsiConfigNoArgsConstructorAndSetterGetter() {
+ CreateProjectJobRequest.PsiConfig psiConfig = new CreateProjectJobRequest.PsiConfig();
+ psiConfig.setNodeId("nodeId");
+ psiConfig.setPath("path");
+ psiConfig.setKeys(Arrays.asList("key1", "key2"));
+ psiConfig.setBroadcastResult(Arrays.asList("result1", "result2"));
+ assertEquals("nodeId", psiConfig.getNodeId());
+ assertEquals("path", psiConfig.getPath());
+ assertEquals(Arrays.asList("key1", "key2"), psiConfig.getKeys());
+ assertEquals(Arrays.asList("result1", "result2"), psiConfig.getBroadcastResult());
+ }
+
+ @Test
+ public void testAdvancedConfigNoArgsConstructorAndSetterGetter() {
+ CreateProjectJobRequest.AdvancedConfig.ProtocolConfig protocolConfig = new CreateProjectJobRequest.AdvancedConfig.ProtocolConfig();
+ protocolConfig.setProtocol(JobConstants.ProtocolEnum.PROTOCOL_RR22);
+ protocolConfig.setRole(JobConstants.RoleEnum.ROLE_RECEIVER);
+ protocolConfig.setBroadcastResult(true);
+
+ CreateProjectJobRequest.AdvancedConfig advancedConfig = new CreateProjectJobRequest.AdvancedConfig();
+ advancedConfig.setProtocolConfig(protocolConfig);
+ advancedConfig.setLinkConfig("linkConfigValue");
+ advancedConfig.setSkipDuplicatesCheck(true);
+ advancedConfig.setRecoveryEnabled(Boolean.TRUE);
+ advancedConfig.setLeftSide("leftSide");
+ advancedConfig.setAdvancedJoinType(JobConstants.AdvancedJoinTypeEnum.ADVANCED_JOIN_TYPE_DIFFERENCE);
+ advancedConfig.setDisableAlignment(Boolean.TRUE);
+ advancedConfig.setDataTableCount("10");
+ advancedConfig.setDataTableConfirmation(Boolean.TRUE);
+
+ assertEquals(protocolConfig, advancedConfig.getProtocolConfig());
+ assertEquals("linkConfigValue", advancedConfig.getLinkConfig());
+ assertEquals(true, advancedConfig.getSkipDuplicatesCheck());
+ assertEquals(true, advancedConfig.getRecoveryEnabled());
+ assertEquals("leftSide", advancedConfig.getLeftSide());
+ assertEquals(JobConstants.AdvancedJoinTypeEnum.ADVANCED_JOIN_TYPE_DIFFERENCE, advancedConfig.getAdvancedJoinType());
+ assertEquals(true, advancedConfig.getDisableAlignment());
+ assertEquals("10", advancedConfig.getDataTableCount());
+ assertEquals(true, advancedConfig.getDataTableConfirmation());
+
+ assertEquals(JobConstants.ProtocolEnum.PROTOCOL_RR22, protocolConfig.getProtocol());
+ assertEquals(JobConstants.RoleEnum.ROLE_RECEIVER, protocolConfig.getRole());
+ assertEquals(true, protocolConfig.getBroadcastResult());
+ }
+
+ @Test
+ public void testProtocolConfigNoArgsConstructorAndSetterGetter() {
+ CreateProjectJobRequest.AdvancedConfig.ProtocolConfig.EcdhConfig ecdhConfig = new CreateProjectJobRequest.AdvancedConfig.ProtocolConfig.EcdhConfig();
+ ecdhConfig.setCurve(JobConstants.CurveType.CURVE_FOURQ.name());
+
+ CreateProjectJobRequest.AdvancedConfig.ProtocolConfig.KkrtConfig kkrtConfig = new CreateProjectJobRequest.AdvancedConfig.ProtocolConfig.KkrtConfig();
+ kkrtConfig.setBucketSize(JobConstants.BUCKET_SIZE);
+
+ CreateProjectJobRequest.AdvancedConfig.ProtocolConfig.Rr22Config rr22Config = new CreateProjectJobRequest.AdvancedConfig.ProtocolConfig.Rr22Config();
+ rr22Config.setBucketSize(JobConstants.BUCKET_SIZE);
+ rr22Config.setLowCommMode(false);
+
+ CreateProjectJobRequest.AdvancedConfig.ProtocolConfig protocolConfig = new CreateProjectJobRequest.AdvancedConfig.ProtocolConfig();
+ protocolConfig.setProtocol(JobConstants.ProtocolEnum.PROTOCOL_RR22);
+ protocolConfig.setRole(JobConstants.RoleEnum.ROLE_RECEIVER);
+ protocolConfig.setBroadcastResult(true);
+ protocolConfig.setEcdhConfig(ecdhConfig);
+ protocolConfig.setKkrtConfig(kkrtConfig);
+ protocolConfig.setRr22Config(rr22Config);
+
+ assertEquals(JobConstants.ProtocolEnum.PROTOCOL_RR22, protocolConfig.getProtocol());
+ assertEquals(JobConstants.RoleEnum.ROLE_RECEIVER, protocolConfig.getRole());
+ assertEquals(ecdhConfig, protocolConfig.getEcdhConfig());
+ assertEquals(kkrtConfig, protocolConfig.getKkrtConfig());
+ assertEquals(rr22Config, protocolConfig.getRr22Config());
+ }
+}
\ No newline at end of file
diff --git a/easypsi-service/src/test/java/org/secretflow/easypsi/service/model/CreateProjectJobTaskRequestTest.java b/easypsi-service/src/test/java/org/secretflow/easypsi/service/model/CreateProjectJobTaskRequestTest.java
new file mode 100644
index 0000000..21a2e24
--- /dev/null
+++ b/easypsi-service/src/test/java/org/secretflow/easypsi/service/model/CreateProjectJobTaskRequestTest.java
@@ -0,0 +1,208 @@
+/*
+ * Copyright 2024 Ant Group Co., Ltd.
+ *
+ * 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.
+ */
+
+package org.secretflow.easypsi.service.model;
+
+import jakarta.validation.ConstraintViolation;
+import jakarta.validation.Validation;
+import jakarta.validation.Validator;
+import jakarta.validation.ValidatorFactory;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.secretflow.easypsi.common.constant.JobConstants;
+import org.secretflow.easypsi.service.model.project.CreateProjectJobRequest;
+import org.secretflow.easypsi.service.model.project.CreateProjectJobTaskRequest;
+
+import java.util.Arrays;
+import java.util.Set;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+/**
+ * Create Project Job Task Request Test
+ *
+ * @author lihaixin
+ * @date 2024/03/12
+ */
+@ExtendWith(MockitoExtension.class)
+public class CreateProjectJobTaskRequestTest {
+
+ private Validator validator;
+
+ private CreateProjectJobTaskRequest taskRequest;
+ private CreateProjectJobTaskRequest.PsiConfig taskPsiConfig;
+
+ private CreateProjectJobRequest jobRequest;
+ private CreateProjectJobRequest.PsiConfig jobPsiConfig;
+
+ private CreateProjectJobRequest.AdvancedConfig advancedConfig;
+ private CreateProjectJobTaskRequest.PsiConfig.OutputConfig outputConfig;
+ private CreateProjectJobTaskRequest.PsiConfig.RecoveryConfig recoveryConfig;
+
+ @BeforeEach
+ public void setUp() {
+ ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
+ validator = factory.getValidator();
+
+ taskRequest = mock(CreateProjectJobTaskRequest.class);
+ taskPsiConfig = mock(CreateProjectJobTaskRequest.PsiConfig.class);
+
+ jobRequest = mock(CreateProjectJobRequest.class);
+ jobPsiConfig = mock(CreateProjectJobRequest.PsiConfig.class);
+
+ advancedConfig = mock(CreateProjectJobRequest.AdvancedConfig.class);
+ outputConfig = mock(CreateProjectJobTaskRequest.PsiConfig.OutputConfig.class);
+ recoveryConfig = mock(CreateProjectJobTaskRequest.PsiConfig.RecoveryConfig.class);
+ }
+
+
+ @Test
+ public void testNoArgsConstructor() {
+ CreateProjectJobTaskRequest request = new CreateProjectJobTaskRequest();
+ assertNotNull(request);
+ }
+
+ @Test
+ public void testSetNameAndGet() {
+ CreateProjectJobTaskRequest request = new CreateProjectJobTaskRequest();
+ request.setName("jobName");
+ request.setJobId("testJobId");
+ request.setDescription("testDescription");
+ request.setPartnerConfig(taskPsiConfig);
+ request.setInitiatorConfig(taskPsiConfig);
+ assertNotNull(request.toString());
+ assertNotNull(taskPsiConfig.toString());
+ assertNotNull(mockAdvancedConfig().toString());
+ assertNotNull(mockInputConfig().toString());
+ assertNotNull(mockOutputConfig().toString());
+ assertEquals("jobName", request.getName());
+ }
+
+
+ @Test
+ public void testNameNotBlankValidation() {
+ CreateProjectJobTaskRequest request = new CreateProjectJobTaskRequest();
+ request.setName("");
+ Set> violations = validator.validate(request);
+ assertEquals(1, violations.size());
+ }
+
+
+ @Test
+ public void testPsiConfigConstructor() {
+ CreateProjectJobTaskRequest.PsiConfig psiConfig = new CreateProjectJobTaskRequest.PsiConfig(
+ "testNodeId",
+ mockProtocolConfig(),
+ mockInputConfig(),
+ mockOutputConfig(),
+ mock(CreateProjectJobTaskRequest.PsiConfig.ContextDescProto.class),
+ Arrays.asList("key1", "key2"),
+ true,
+ false,
+ mockRecoveryConfig(),
+ JobConstants.AdvancedJoinTypeEnum.ADVANCED_JOIN_TYPE_DIFFERENCE,
+ "leftSide",
+ true,
+ "L0"
+ );
+ assertEquals("testNodeId", psiConfig.getNodeId());
+ }
+
+ @Test
+ public void testFromMethod() {
+ when(jobRequest.getAdvancedConfig()).thenReturn(mockAdvancedConfig());
+ when(jobRequest.getOutputConfig()).thenReturn(mockPsiConfig());
+ when(jobRequest.getName()).thenReturn("name");
+ when(jobRequest.getDescription()).thenReturn("description");
+ when(jobRequest.getPartnerConfig()).thenReturn(mockPsiConfig());
+ when(jobRequest.getInitiatorConfig()).thenReturn(mockPsiConfig());
+ when(jobPsiConfig.getNodeId()).thenReturn("testNodeId");
+
+
+ CreateProjectJobTaskRequest.PsiConfig actualPsiConfig = CreateProjectJobTaskRequest.PsiConfig.from(jobRequest, jobPsiConfig, "testJobId");
+ CreateProjectJobTaskRequest testJob = CreateProjectJobTaskRequest.fromJobRequest(jobRequest, "testJobId");
+ assertEquals("name", testJob.getName());
+ assertEquals("testNodeId", actualPsiConfig.getNodeId());
+ assertEquals(true, actualPsiConfig.getSkipDuplicatesCheck());
+ assertEquals(true, actualPsiConfig.getDisableAlignment());
+ assertEquals(JobConstants.AdvancedJoinTypeEnum.ADVANCED_JOIN_TYPE_FULL_JOIN, actualPsiConfig.getAdvancedJoinType());
+ assertEquals("leftSide", actualPsiConfig.getLeftSide());
+ assertEquals(true, actualPsiConfig.getDataTableConfirmation());
+ }
+
+ private CreateProjectJobTaskRequest.PsiConfig.ProtocolConfig mockProtocolConfig() {
+ return CreateProjectJobTaskRequest.PsiConfig.ProtocolConfig.builder()
+ .protocol(JobConstants.ProtocolEnum.PROTOCOL_ECDH)
+ .role(JobConstants.RoleEnum.ROLE_SENDER)
+ .build();
+ }
+
+ private CreateProjectJobTaskRequest.PsiConfig.InputConfig mockInputConfig() {
+ return CreateProjectJobTaskRequest.PsiConfig.InputConfig.builder()
+ .type(JobConstants.DatatableTypeEnum.IO_TYPE_FILE_CSV.name())
+ .path("mockInputPath")
+ .build();
+ }
+
+ private CreateProjectJobTaskRequest.PsiConfig.OutputConfig mockOutputConfig() {
+ return CreateProjectJobTaskRequest.PsiConfig.OutputConfig.builder()
+ .type(JobConstants.DatatableTypeEnum.IO_TYPE_FILE_CSV.name())
+ .path("mockOutputPath")
+ .build();
+ }
+
+ private CreateProjectJobTaskRequest.PsiConfig.RecoveryConfig mockRecoveryConfig() {
+ return CreateProjectJobTaskRequest.PsiConfig.RecoveryConfig.builder()
+ .enabled(true)
+ .folder("mockFolder")
+ .build();
+ }
+
+ private CreateProjectJobRequest.AdvancedConfig mockAdvancedConfig() {
+ CreateProjectJobRequest.AdvancedConfig.ProtocolConfig protocolConfig = new CreateProjectJobRequest.AdvancedConfig.ProtocolConfig();
+ protocolConfig.setProtocol(JobConstants.ProtocolEnum.PROTOCOL_RR22);
+ protocolConfig.setRr22Config(new CreateProjectJobRequest.AdvancedConfig.ProtocolConfig.Rr22Config());
+ protocolConfig.setRole(JobConstants.RoleEnum.ROLE_RECEIVER);
+ protocolConfig.setBroadcastResult(true);
+ CreateProjectJobRequest.AdvancedConfig advancedConfig = new CreateProjectJobRequest.AdvancedConfig();
+ advancedConfig.setProtocolConfig(protocolConfig);
+ advancedConfig.setLinkConfig("linkConfigValue");
+ advancedConfig.setSkipDuplicatesCheck(true);
+ advancedConfig.setRecoveryEnabled(Boolean.TRUE);
+ advancedConfig.setLeftSide("leftSide");
+ advancedConfig.setAdvancedJoinType(JobConstants.AdvancedJoinTypeEnum.ADVANCED_JOIN_TYPE_FULL_JOIN);
+ advancedConfig.setDisableAlignment(Boolean.TRUE);
+ advancedConfig.setDataTableCount("10");
+ advancedConfig.setDataTableConfirmation(Boolean.TRUE);
+ return advancedConfig;
+ }
+
+ private CreateProjectJobRequest.PsiConfig mockPsiConfig() {
+ CreateProjectJobRequest.PsiConfig psiConfig = new CreateProjectJobRequest.PsiConfig();
+ psiConfig.setNodeId("testNodeId");
+ psiConfig.setPath("path");
+ psiConfig.setKeys(Arrays.asList("key1", "key2"));
+ psiConfig.setBroadcastResult(Arrays.asList("result1", "result2"));
+ return psiConfig;
+ }
+
+
+}
\ No newline at end of file
diff --git a/easypsi-service/src/test/java/org/secretflow/easypsi/service/model/EasyPsiPageResponseTest.java b/easypsi-service/src/test/java/org/secretflow/easypsi/service/model/EasyPsiPageResponseTest.java
new file mode 100644
index 0000000..89e9608
--- /dev/null
+++ b/easypsi-service/src/test/java/org/secretflow/easypsi/service/model/EasyPsiPageResponseTest.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2024 Ant Group Co., Ltd.
+ *
+ * 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.
+ */
+
+package org.secretflow.easypsi.service.model;
+
+/**
+ * @author lihaixin
+ * @date 2024/03/11
+ */
+
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.secretflow.easypsi.service.model.common.EasyPsiPageResponse;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.PageImpl;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.data.domain.Sort;
+
+import java.util.Arrays;
+import java.util.List;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+/**
+ * EasyPsi Page Response Test
+ *
+ * @author lihaixin
+ * @date 2024/03/12
+ */
+@ExtendWith(MockitoExtension.class)
+public class EasyPsiPageResponseTest {
+
+ @Test
+ public void testToPageFromPage() {
+ PageRequest pageable = PageRequest.of(0, 10, Sort.by(Sort.Direction.DESC, "id"));
+ Page mockPage = new PageImpl<>(Arrays.asList("item1", "item2"), pageable, 2L);
+ EasyPsiPageResponse response = EasyPsiPageResponse.toPage(mockPage);
+ assertNotNull(response);
+ assertEquals(2, response.getList().size());
+ assertEquals(Arrays.asList("item1", "item2"), response.getList());
+ assertEquals(2L, response.getTotal());
+ }
+
+ @Test
+ public void testToPageFromContentAndTotal() {
+ List content = Arrays.asList("item1", "item2");
+ long totalElements = 2L;
+ EasyPsiPageResponse response = EasyPsiPageResponse.toPage(content, totalElements);
+ assertNotNull(response);
+ assertEquals(2, response.getList().size());
+ assertEquals(content, response.getList());
+ assertEquals(totalElements, response.getTotal());
+ }
+}
\ No newline at end of file
diff --git a/easypsi-service/src/test/java/org/secretflow/easypsi/service/model/ProjectJobListByBlackScreenVOTest.java b/easypsi-service/src/test/java/org/secretflow/easypsi/service/model/ProjectJobListByBlackScreenVOTest.java
new file mode 100644
index 0000000..212ff23
--- /dev/null
+++ b/easypsi-service/src/test/java/org/secretflow/easypsi/service/model/ProjectJobListByBlackScreenVOTest.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2024 Ant Group Co., Ltd.
+ *
+ * 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.
+ */
+
+package org.secretflow.easypsi.service.model;
+
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.secretflow.easypsi.persistence.model.GraphJobOperation;
+import org.secretflow.easypsi.persistence.model.GraphJobStatus;
+import org.secretflow.easypsi.service.model.project.ProjectJobListByBlackScreenVO;
+import org.secretflow.easypsi.service.model.project.ProjectJobListVO;
+
+import java.util.Arrays;
+import java.util.List;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+/**
+ * Project Job List By Black Screen VO Test
+ *
+ * @author lihaixin
+ * @date 2024/03/12
+ */
+@ExtendWith(MockitoExtension.class)
+public class ProjectJobListByBlackScreenVOTest {
+
+
+ @Test
+ public void testFrom() {
+ // 创建Mock对象
+ ProjectJobListVO projectJobListVO = mock(ProjectJobListVO.class);
+
+ // 设置Mock对象属性值
+ String expectedJobId = "test_job_id";
+ String expectedName = "test_name";
+ String expectedSrcNodeId = "src_node";
+ String expectedDstNodeId = "dst_node";
+ List expectedOperations = Arrays.asList(GraphJobOperation.REJECT, GraphJobOperation.AGREE);
+ GraphJobStatus expectedStatus = GraphJobStatus.RUNNING;
+ String expectedGmtCreate = "2022-01-01 00:00:00";
+ String expectedGmtFinished = "2022-01-02 00:00:00";
+ String expectedErrMsg = "test_error_message";
+
+ when(projectJobListVO.getJobId()).thenReturn(expectedJobId);
+ when(projectJobListVO.getName()).thenReturn(expectedName);
+ when(projectJobListVO.getSrcNodeId()).thenReturn(expectedSrcNodeId);
+ when(projectJobListVO.getDstNodeId()).thenReturn(expectedDstNodeId);
+ when(projectJobListVO.getOperation()).thenReturn(expectedOperations);
+ when(projectJobListVO.getStatus()).thenReturn(expectedStatus);
+ when(projectJobListVO.getGmtCreate()).thenReturn(expectedGmtCreate);
+ when(projectJobListVO.getGmtFinished()).thenReturn(expectedGmtFinished);
+ when(projectJobListVO.getErrMsg()).thenReturn(expectedErrMsg);
+
+ // 调用待测试方法
+ ProjectJobListByBlackScreenVO result = ProjectJobListByBlackScreenVO.from(projectJobListVO);
+
+ // 验证结果
+ assertEquals(expectedJobId, result.getJobId());
+ assertEquals(expectedName, result.getName());
+ assertEquals(expectedSrcNodeId, result.getSrcNodeId());
+ assertEquals(expectedDstNodeId, result.getDstNodeId());
+ assertEquals(expectedOperations, result.getOperation());
+ assertEquals(expectedStatus, result.getStatus());
+ assertEquals(expectedGmtCreate, result.getGmtCreate());
+ assertEquals(expectedGmtFinished, result.getGmtFinished());
+ assertEquals(expectedErrMsg, result.getErrMsg());
+ }
+}
\ No newline at end of file
diff --git a/easypsi-service/src/test/java/org/secretflow/easypsi/service/model/ProjectJobListVOTest.java b/easypsi-service/src/test/java/org/secretflow/easypsi/service/model/ProjectJobListVOTest.java
new file mode 100644
index 0000000..d677a90
--- /dev/null
+++ b/easypsi-service/src/test/java/org/secretflow/easypsi/service/model/ProjectJobListVOTest.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2024 Ant Group Co., Ltd.
+ *
+ * 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.
+ */
+
+package org.secretflow.easypsi.service.model;
+
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.secretflow.easypsi.persistence.model.GraphJobOperation;
+import org.secretflow.easypsi.service.model.data.DataTableInformationVo;
+import org.secretflow.easypsi.service.model.project.ProjectJobListVO;
+
+import java.util.Arrays;
+import java.util.List;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+/**
+ * Project Job List VO Test
+ *
+ * @author lihaixin
+ * @date 2024/03/12
+ */
+@ExtendWith(MockitoExtension.class)
+public class ProjectJobListVOTest {
+
+
+ @Test
+ public void testNoArgsConstructor() {
+ ProjectJobListVO projectJobListVO = new ProjectJobListVO();
+ assertNotNull(projectJobListVO);
+ }
+
+ @Test
+ public void testAllArgsConstructor() {
+ List operations = Arrays.asList(GraphJobOperation.AGREE, GraphJobOperation.REJECT);
+
+ DataTableInformationVo.DataTableInformation initiatorInfo = new DataTableInformationVo.DataTableInformation();
+ DataTableInformationVo.DataTableInformation partnerInfo = new DataTableInformationVo.DataTableInformation();
+
+ ProjectJobListVO projectJobListVO = ProjectJobListVO.builder()
+ .name("jobName")
+ .srcNodeId("srcNodeId")
+ .dstNodeId("dstNodeId")
+ .operation(operations)
+ .enabled(true)
+ .initiatorDataTableInformation(initiatorInfo)
+ .partnerdstDataTableInformation(partnerInfo)
+ .dataTableConfirmation(true)
+ .build();
+
+ assertEquals("jobName", projectJobListVO.getName());
+ assertEquals("srcNodeId", projectJobListVO.getSrcNodeId());
+ assertEquals("dstNodeId", projectJobListVO.getDstNodeId());
+ assertEquals(operations, projectJobListVO.getOperation());
+ assertEquals(true, projectJobListVO.getEnabled());
+ assertEquals(initiatorInfo, projectJobListVO.getInitiatorDataTableInformation());
+ assertEquals(partnerInfo, projectJobListVO.getPartnerdstDataTableInformation());
+ assertEquals(true, projectJobListVO.getDataTableConfirmation());
+ }
+}
\ No newline at end of file
diff --git a/easypsi-service/src/test/java/org/secretflow/easypsi/service/model/UpdateNodeRequestTest.java b/easypsi-service/src/test/java/org/secretflow/easypsi/service/model/UpdateNodeRequestTest.java
new file mode 100644
index 0000000..c7e2282
--- /dev/null
+++ b/easypsi-service/src/test/java/org/secretflow/easypsi/service/model/UpdateNodeRequestTest.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2024 Ant Group Co., Ltd.
+ *
+ * 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.
+ */
+
+package org.secretflow.easypsi.service.model;
+
+import org.hamcrest.Matchers;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.secretflow.easypsi.service.model.node.UpdateNodeRequest;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.notNullValue;
+
+/**
+ * Update Node Request Test
+ *
+ * @author lihaixin
+ * @date 2024/03/12
+ */
+@ExtendWith(MockitoExtension.class)
+public class UpdateNodeRequestTest {
+
+
+ @Test
+ public void testNoArgsConstructor() {
+ UpdateNodeRequest request = new UpdateNodeRequest();
+ assertThat(request, notNullValue());
+ }
+
+ @Test
+ public void testAllArgsConstructor() {
+ String nodeId = "testNodeId";
+ boolean trust = true;
+ UpdateNodeRequest request = UpdateNodeRequest.builder()
+ .nodeId(nodeId)
+ .trust(trust)
+ .build();
+
+ assertThat(request.getNodeId(), equalTo(nodeId));
+ assertThat(request.getTrust(), equalTo(trust));
+ }
+
+ @Test
+ public void testSettersAndGetters() {
+ UpdateNodeRequest request = new UpdateNodeRequest();
+
+ String nodeId = "testNodeId";
+ boolean trust = false;
+
+ request.setNodeId(nodeId);
+ request.setTrust(trust);
+
+ assertThat(request.getNodeId(), Matchers.equalTo(nodeId));
+ assertThat(request.getTrust(), Matchers.equalTo(trust));
+ }
+
+}
\ No newline at end of file
diff --git a/easypsi-test/pom.xml b/easypsi-test/pom.xml
new file mode 100644
index 0000000..d3131be
--- /dev/null
+++ b/easypsi-test/pom.xml
@@ -0,0 +1,127 @@
+
+
+ 4.0.0
+
+ org.secretflow
+ easypsi-parent
+ 0.0.1-SNAPSHOT
+
+
+
+ easypsi-test
+
+
+ 17
+ 17
+ UTF-8
+
+
+
+
+ org.secretflow
+ easypsi-common
+ ${project.version}
+
+
+ org.secretflow
+ easypsi-persistence
+ ${project.version}
+
+
+ org.secretflow
+ easypsi-manager
+ ${project.version}
+
+
+ org.secretflow
+ easypsi-service
+ ${project.version}
+
+
+
+
+
+
+
+
+
+
+
+
+ org.secretflow
+ easypsi-web
+ ${project.version}
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+ true
+
+
+
+ org.jacoco
+ jacoco-maven-plugin
+ ${jacoco-maven-plugin.version}
+
+
+ report-aggregate
+ test
+
+ report-aggregate
+
+
+
+
+
+ **/opensecretflow/spec/**
+ **/secretflow/proto/**
+
+
+
+
+ org.apache.maven.plugins
+ maven-antrun-plugin
+ 1.8
+
+
+ build
+ compile
+
+ run
+
+
+
+ run chmod in ${basedir}
+
+
+
+
+
+
+
+ exec-maven-plugin
+ org.codehaus.mojo
+ 1.6.0
+
+
+ test
+
+ exec
+
+
+ /bin/bash
+ ${basedir}/../scripts/ci/merge_test.sh
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/secretpad-web/pom.xml b/easypsi-web/pom.xml
similarity index 70%
rename from secretpad-web/pom.xml
rename to easypsi-web/pom.xml
index 211fcfe..fedb5d7 100644
--- a/secretpad-web/pom.xml
+++ b/easypsi-web/pom.xml
@@ -19,13 +19,13 @@
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- secretpad-parent
+ easypsi-parent
org.secretflow
0.0.1-SNAPSHOT
4.0.0
- secretpad-web
+ easypsi-web
@@ -52,23 +52,23 @@
org.secretflow
- secretpad-manager
+ easypsi-manager
org.secretflow
- secretpad-common
+ easypsi-common
org.secretflow
- secretpad-persistence
+ easypsi-persistence
org.secretflow
- secretpad-service
+ easypsi-service
org.secretflow
- client-java-secretpad
+ client-java-easypsi
@@ -79,9 +79,31 @@
spring-boot-maven-plugin
../target
- secretpad
+ easypsi
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+ true
+ methods
+ 20
+
+
+
+ org.jacoco
+ jacoco-maven-plugin
+
+
+ report-aggregate
+ test
+
+ report-aggregate
+
+
+
+
diff --git a/secretpad-web/src/main/java/org/secretflow/secretpad/web/SecretPadApplication.java b/easypsi-web/src/main/java/org/secretflow/easypsi/web/EasyPsiApplication.java
similarity index 91%
rename from secretpad-web/src/main/java/org/secretflow/secretpad/web/SecretPadApplication.java
rename to easypsi-web/src/main/java/org/secretflow/easypsi/web/EasyPsiApplication.java
index 8f2b92b..90fcbbb 100644
--- a/secretpad-web/src/main/java/org/secretflow/secretpad/web/SecretPadApplication.java
+++ b/easypsi-web/src/main/java/org/secretflow/easypsi/web/EasyPsiApplication.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.web;
+package org.secretflow.easypsi.web;
import com.google.common.collect.Lists;
import org.apache.catalina.connector.Connector;
@@ -24,6 +24,7 @@
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
+import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.http.MediaType;
@@ -31,15 +32,16 @@
import org.springframework.scheduling.annotation.EnableAsync;
/**
- * SecretPad application
+ * EasyPsi application
*
* @author yansi
* @date 2023/3/23
*/
-@ComponentScan(basePackages = "org.secretflow.secretpad.*")
+@ComponentScan(basePackages = "org.secretflow.easypsi.*")
@SpringBootApplication
@EnableAsync
-public class SecretPadApplication {
+@EnableCaching
+public class EasyPsiApplication {
@Value("${server.http-port}")
private Integer httpPort;
@@ -47,7 +49,7 @@ public class SecretPadApplication {
private Integer innerHttpPort;
public static void main(String[] args) {
- SpringApplication.run(SecretPadApplication.class, args);
+ SpringApplication.run(EasyPsiApplication.class, args);
}
/**
diff --git a/secretpad-web/src/main/java/org/secretflow/secretpad/web/aop/InterfaceResourceAspect.java b/easypsi-web/src/main/java/org/secretflow/easypsi/web/aop/InterfaceResourceAspect.java
similarity index 75%
rename from secretpad-web/src/main/java/org/secretflow/secretpad/web/aop/InterfaceResourceAspect.java
rename to easypsi-web/src/main/java/org/secretflow/easypsi/web/aop/InterfaceResourceAspect.java
index 0464e74..210ca89 100644
--- a/secretpad-web/src/main/java/org/secretflow/secretpad/web/aop/InterfaceResourceAspect.java
+++ b/easypsi-web/src/main/java/org/secretflow/easypsi/web/aop/InterfaceResourceAspect.java
@@ -14,13 +14,13 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.web.aop;
+package org.secretflow.easypsi.web.aop;
-import org.secretflow.secretpad.common.annotation.resource.InterfaceResource;
-import org.secretflow.secretpad.common.errorcode.AuthErrorCode;
-import org.secretflow.secretpad.common.exception.SecretpadException;
-import org.secretflow.secretpad.common.util.UserContext;
-import org.secretflow.secretpad.service.auth.InterfaceResourceAuth;
+import org.secretflow.easypsi.common.annotation.resource.InterfaceResource;
+import org.secretflow.easypsi.common.errorcode.AuthErrorCode;
+import org.secretflow.easypsi.common.exception.EasyPsiException;
+import org.secretflow.easypsi.common.util.UserContext;
+import org.secretflow.easypsi.service.auth.InterfaceResourceAuth;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
@@ -40,7 +40,7 @@ public class InterfaceResourceAspect {
private InterfaceResourceAuth interfaceResourceAuth;
- @Pointcut("@annotation(org.secretflow.secretpad.common.annotation.resource.InterfaceResource)")
+ @Pointcut("@annotation(org.secretflow.easypsi.common.annotation.resource.InterfaceResource)")
public void pointCut() {
}
@@ -50,7 +50,7 @@ public Object check(ProceedingJoinPoint joinPoint, Object data, InterfaceResourc
String err = String.format("No permission to access the interface(%s). owner_type(%s), owner_id(%s)",
interfaceResource.interfaceCode(),
UserContext.getUser().getOwnerType(),UserContext.getUser().getOwnerId());
- throw SecretpadException.of(AuthErrorCode.AUTH_FAILED, err);
+ throw EasyPsiException.of(AuthErrorCode.AUTH_FAILED, err);
}
return joinPoint.proceed();
}
diff --git a/secretpad-web/src/main/java/org/secretflow/secretpad/web/aop/WebLogAspect.java b/easypsi-web/src/main/java/org/secretflow/easypsi/web/aop/WebLogAspect.java
similarity index 91%
rename from secretpad-web/src/main/java/org/secretflow/secretpad/web/aop/WebLogAspect.java
rename to easypsi-web/src/main/java/org/secretflow/easypsi/web/aop/WebLogAspect.java
index 495eb43..ab7f82a 100644
--- a/secretpad-web/src/main/java/org/secretflow/secretpad/web/aop/WebLogAspect.java
+++ b/easypsi-web/src/main/java/org/secretflow/easypsi/web/aop/WebLogAspect.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.web.aop;
+package org.secretflow.easypsi.web.aop;
import com.fasterxml.jackson.databind.ObjectMapper;
import jakarta.servlet.http.HttpServletRequest;
@@ -48,19 +48,17 @@ public class WebLogAspect {
ThreadLocal startTime = new ThreadLocal<>();
- @Pointcut("execution(public * org.secretflow.secretpad.web.controller..*.*(..))")
+ @Pointcut("execution(public * org.secretflow.easypsi.web.controller..*.*(..))")
public void webLog() {
}
@Before("webLog()")
public void doBefore(JoinPoint joinPoint) throws Throwable {
- // 获取当前Http请求
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
HttpServletRequest request = attributes.getRequest();
String params = StringUtils.EMPTY;
Object[] args = joinPoint.getArgs();
if (args.length > 0) {
- // 格式化参数,防止出现特殊字符
CharSequenceTranslator translator = new AggregateTranslator(new CharSequenceTranslator[]{new LookupTranslator(EntityArrays.BASIC_ESCAPE()), new LookupTranslator(EntityArrays.ISO8859_1_ESCAPE()), new LookupTranslator(EntityArrays.HTML40_EXTENDED_ESCAPE())});
params = objectMapper.writeValueAsString(translator.translate(String.valueOf(args[0])));
}
@@ -70,7 +68,6 @@ public void doBefore(JoinPoint joinPoint) throws Throwable {
@AfterReturning(returning = "ret", pointcut = "webLog()")
public void doAfterReturning(Object ret) throws Throwable {
- // 处理完请求,返回内容
log.info("Response data:{},Spend Time:{} ms", objectMapper.writeValueAsString(ret), System.currentTimeMillis() - startTime.get());
}
diff --git a/secretpad-web/src/main/java/org/secretflow/secretpad/web/configuration/CorsConfig.java b/easypsi-web/src/main/java/org/secretflow/easypsi/web/configuration/CorsConfig.java
similarity index 93%
rename from secretpad-web/src/main/java/org/secretflow/secretpad/web/configuration/CorsConfig.java
rename to easypsi-web/src/main/java/org/secretflow/easypsi/web/configuration/CorsConfig.java
index 545e04e..b5540b3 100644
--- a/secretpad-web/src/main/java/org/secretflow/secretpad/web/configuration/CorsConfig.java
+++ b/easypsi-web/src/main/java/org/secretflow/easypsi/web/configuration/CorsConfig.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.web.configuration;
+package org.secretflow.easypsi.web.configuration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Configuration;
@@ -28,7 +28,7 @@
* @date 2023/5/30
*/
@Configuration
-@ConditionalOnProperty(name = "secretpad.cors.enabled", havingValue = "true")
+@ConditionalOnProperty(name = "easypsi.cors.enabled", havingValue = "true")
public class CorsConfig implements WebMvcConfigurer {
/**
* The method types which be allowed
diff --git a/secretpad-web/src/main/java/org/secretflow/secretpad/web/configuration/SecretPadConfiguration.java b/easypsi-web/src/main/java/org/secretflow/easypsi/web/configuration/EasyPsiConfiguration.java
similarity index 88%
rename from secretpad-web/src/main/java/org/secretflow/secretpad/web/configuration/SecretPadConfiguration.java
rename to easypsi-web/src/main/java/org/secretflow/easypsi/web/configuration/EasyPsiConfiguration.java
index b0112dc..bd6da49 100644
--- a/secretpad-web/src/main/java/org/secretflow/secretpad/web/configuration/SecretPadConfiguration.java
+++ b/easypsi-web/src/main/java/org/secretflow/easypsi/web/configuration/EasyPsiConfiguration.java
@@ -14,11 +14,11 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.web.configuration;
+package org.secretflow.easypsi.web.configuration;
-import org.secretflow.secretpad.common.i18n.LocaleMessageResolver;
-import org.secretflow.secretpad.common.i18n.MessageResolver;
-import org.secretflow.secretpad.web.exception.BasicErrorHandler;
+import org.secretflow.easypsi.common.i18n.LocaleMessageResolver;
+import org.secretflow.easypsi.common.i18n.MessageResolver;
+import org.secretflow.easypsi.web.exception.BasicErrorHandler;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
@@ -33,14 +33,14 @@
import java.util.List;
/**
- * Configuration for secretPad
+ * Configuration for easyPsi
*
* @author yansi
* @date 2023/3/24
*/
@Configuration
@EnableAutoConfiguration
-public class SecretPadConfiguration {
+public class EasyPsiConfiguration {
/**
* Create a new bean for message source
diff --git a/secretpad-web/src/main/java/org/secretflow/secretpad/web/configuration/LoginConfiguration.java b/easypsi-web/src/main/java/org/secretflow/easypsi/web/configuration/LoginConfiguration.java
similarity index 62%
rename from secretpad-web/src/main/java/org/secretflow/secretpad/web/configuration/LoginConfiguration.java
rename to easypsi-web/src/main/java/org/secretflow/easypsi/web/configuration/LoginConfiguration.java
index b78e4dd..a12a883 100644
--- a/secretpad-web/src/main/java/org/secretflow/secretpad/web/configuration/LoginConfiguration.java
+++ b/easypsi-web/src/main/java/org/secretflow/easypsi/web/configuration/LoginConfiguration.java
@@ -14,12 +14,16 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.web.configuration;
-
-import org.secretflow.secretpad.web.interceptor.LoginInterceptor;
+package org.secretflow.easypsi.web.configuration;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+import org.secretflow.easypsi.web.interceptor.LoginInterceptor;
+import org.secretflow.easypsi.web.util.ResponseUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
+import org.springframework.web.servlet.HandlerExceptionResolver;
+import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@@ -30,7 +34,7 @@
* @date 2023/5/25
*/
@Configuration
-public class LoginConfiguration implements WebMvcConfigurer {
+public class LoginConfiguration implements HandlerExceptionResolver, WebMvcConfigurer {
/**
* The interceptor for user login
*/
@@ -48,6 +52,16 @@ public LoginConfiguration(LoginInterceptor loginInterceptor) {
*/
@Override
public void addInterceptors(InterceptorRegistry registry) {
- registry.addInterceptor(loginInterceptor).addPathPatterns("/api/v1alpha1/**").addPathPatterns("/api/logout");
+ registry.addInterceptor(loginInterceptor).addPathPatterns("/api/v1alpha1/**", "/api/get").addPathPatterns("/api/logout");
+ }
+
+ @Override
+ public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {
+ try {
+ ResponseUtils.buildResponse_404(response, request);
+ return new ModelAndView();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
}
}
diff --git a/secretpad-web/src/main/java/org/secretflow/secretpad/web/configuration/SpringDocConfig.java b/easypsi-web/src/main/java/org/secretflow/easypsi/web/configuration/SpringDocConfig.java
similarity index 86%
rename from secretpad-web/src/main/java/org/secretflow/secretpad/web/configuration/SpringDocConfig.java
rename to easypsi-web/src/main/java/org/secretflow/easypsi/web/configuration/SpringDocConfig.java
index 07f9a5b..6373d7e 100644
--- a/secretpad-web/src/main/java/org/secretflow/secretpad/web/configuration/SpringDocConfig.java
+++ b/easypsi-web/src/main/java/org/secretflow/easypsi/web/configuration/SpringDocConfig.java
@@ -14,9 +14,9 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.web.configuration;
+package org.secretflow.easypsi.web.configuration;
-import org.secretflow.secretpad.web.constant.AuthConstants;
+import org.secretflow.easypsi.web.constant.AuthConstants;
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.enums.SecuritySchemeIn;
@@ -35,7 +35,7 @@
*/
@Profile({"dev", "test"})
@OpenAPIDefinition(
- info = @Info(title = "Secretpad Restful API", version = "0.0.1-SNAPSHOT", license = @License(name = "Apache 2.0")),
+ info = @Info(title = "EasyPsi Restful API", version = "0.0.1-SNAPSHOT", license = @License(name = "Apache 2.0")),
security = @SecurityRequirement(name = AuthConstants.TOKEN_NAME))
@SecurityScheme(name = AuthConstants.TOKEN_NAME, type = SecuritySchemeType.APIKEY, in = SecuritySchemeIn.COOKIE)
@Configuration
diff --git a/secretpad-web/src/main/java/org/secretflow/secretpad/web/configuration/UploadConfiguration.java b/easypsi-web/src/main/java/org/secretflow/easypsi/web/configuration/UploadConfiguration.java
similarity index 91%
rename from secretpad-web/src/main/java/org/secretflow/secretpad/web/configuration/UploadConfiguration.java
rename to easypsi-web/src/main/java/org/secretflow/easypsi/web/configuration/UploadConfiguration.java
index b29ca29..eea1b93 100644
--- a/secretpad-web/src/main/java/org/secretflow/secretpad/web/configuration/UploadConfiguration.java
+++ b/easypsi-web/src/main/java/org/secretflow/easypsi/web/configuration/UploadConfiguration.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.web.configuration;
+package org.secretflow.easypsi.web.configuration;
import jakarta.servlet.MultipartConfigElement;
import org.springframework.beans.factory.annotation.Value;
@@ -32,9 +32,9 @@
@Configuration
public class UploadConfiguration {
private static final String NOT_LIMIT_SIZE = "-1";
- @Value("${secretpad.upload-file.max-file-size:-1}")
+ @Value("${easypsi.upload-file.max-file-size:-1}")
private String maxFileSize;
- @Value("${secretpad.upload-file.max-request-size:-1}")
+ @Value("${easypsi.upload-file.max-request-size:-1}")
private String maxRequestSize;
/**
diff --git a/secretpad-web/src/main/java/org/secretflow/secretpad/web/constant/AuthConstants.java b/easypsi-web/src/main/java/org/secretflow/easypsi/web/constant/AuthConstants.java
similarity index 95%
rename from secretpad-web/src/main/java/org/secretflow/secretpad/web/constant/AuthConstants.java
rename to easypsi-web/src/main/java/org/secretflow/easypsi/web/constant/AuthConstants.java
index 07ba679..6019a34 100644
--- a/secretpad-web/src/main/java/org/secretflow/secretpad/web/constant/AuthConstants.java
+++ b/easypsi-web/src/main/java/org/secretflow/easypsi/web/constant/AuthConstants.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.web.constant;
+package org.secretflow.easypsi.web.constant;
/**
* Authorization Constants
diff --git a/secretpad-web/src/main/java/org/secretflow/secretpad/web/controller/AuthController.java b/easypsi-web/src/main/java/org/secretflow/easypsi/web/controller/AuthController.java
similarity index 58%
rename from secretpad-web/src/main/java/org/secretflow/secretpad/web/controller/AuthController.java
rename to easypsi-web/src/main/java/org/secretflow/easypsi/web/controller/AuthController.java
index 218b4fd..90c8135 100644
--- a/secretpad-web/src/main/java/org/secretflow/secretpad/web/controller/AuthController.java
+++ b/easypsi-web/src/main/java/org/secretflow/easypsi/web/controller/AuthController.java
@@ -14,20 +14,19 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.web.controller;
-
-import org.secretflow.secretpad.common.annotation.resource.InterfaceResource;
-import org.secretflow.secretpad.common.constant.resource.InterfaceResourceCode;
-import org.secretflow.secretpad.common.dto.UserContextDTO;
-import org.secretflow.secretpad.common.util.UserContext;
-import org.secretflow.secretpad.service.AuthService;
-import org.secretflow.secretpad.service.model.auth.LoginRequest;
-import org.secretflow.secretpad.service.model.common.SecretPadResponse;
-import org.secretflow.secretpad.web.util.AuthUtils;
+package org.secretflow.easypsi.web.controller;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
+import org.secretflow.easypsi.common.annotation.resource.InterfaceResource;
+import org.secretflow.easypsi.common.constant.resource.InterfaceResourceCode;
+import org.secretflow.easypsi.common.dto.UserContextDTO;
+import org.secretflow.easypsi.common.util.UserContext;
+import org.secretflow.easypsi.service.AuthService;
+import org.secretflow.easypsi.service.model.auth.LoginRequest;
+import org.secretflow.easypsi.service.model.common.EasyPsiResponse;
+import org.secretflow.easypsi.web.util.AuthUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@@ -53,31 +52,42 @@ public AuthController(AuthService authService) {
*
* @param response http servlet response
* @param request login request
- * @return successful SecretPadResponse with token
+ * @return successful EasyPsiResponse with token
*/
@ResponseBody
@PostMapping(value = "/login", consumes = "application/json")
@InterfaceResource(interfaceCode = InterfaceResourceCode.AUTH_LOGIN)
- public SecretPadResponse login(HttpServletResponse response, @Valid @RequestBody LoginRequest request) {
- UserContextDTO login = authService.login(request.getName(), request.getPasswordHash());
- return SecretPadResponse.success(login);
+ public EasyPsiResponse login(HttpServletResponse response, @Valid @RequestBody LoginRequest request) {
+ UserContextDTO login = authService.login(request);
+ return EasyPsiResponse.success(login);
}
/**
* User logout api
*
* @param request http servlet request
- * @return {@link SecretPadResponse }<{@link String }>
+ * @return {@link EasyPsiResponse }<{@link String }>
*/
@ResponseBody
@PostMapping(value = "/logout", consumes = "application/json")
@InterfaceResource(interfaceCode = InterfaceResourceCode.AUTH_LOGOUT)
- public SecretPadResponse logout(HttpServletRequest request) {
+ public EasyPsiResponse logout(HttpServletRequest request) {
UserContextDTO userContextDTO = UserContext.getUser();
String token = AuthUtils.findTokenInHeader(request);
authService.logout(userContextDTO.getName(), token);
- return SecretPadResponse.success(userContextDTO.getName());
+ return EasyPsiResponse.success(userContextDTO.getName());
+ }
+
+ /**
+ * query user info
+ *
+ * @return successful EasyPsiResponse with user name
+ */
+ @PostMapping(value = "/get")
+ @InterfaceResource(interfaceCode = InterfaceResourceCode.USER_GET)
+ public EasyPsiResponse get() {
+ return EasyPsiResponse.success(UserContext.getUser());
}
}
diff --git a/secretpad-web/src/main/java/org/secretflow/secretpad/web/controller/DataController.java b/easypsi-web/src/main/java/org/secretflow/easypsi/web/controller/DataController.java
similarity index 66%
rename from secretpad-web/src/main/java/org/secretflow/secretpad/web/controller/DataController.java
rename to easypsi-web/src/main/java/org/secretflow/easypsi/web/controller/DataController.java
index 62ecca3..61083e7 100644
--- a/secretpad-web/src/main/java/org/secretflow/secretpad/web/controller/DataController.java
+++ b/easypsi-web/src/main/java/org/secretflow/easypsi/web/controller/DataController.java
@@ -14,25 +14,24 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.web.controller;
-
-import org.secretflow.secretpad.common.annotation.resource.InterfaceResource;
-import org.secretflow.secretpad.common.constant.resource.InterfaceResourceCode;
-import org.secretflow.secretpad.common.dto.DownloadInfo;
-import org.secretflow.secretpad.common.errorcode.SystemErrorCode;
-import org.secretflow.secretpad.common.exception.SecretpadException;
-import org.secretflow.secretpad.common.util.JsonUtils;
-import org.secretflow.secretpad.common.util.UserContext;
-import org.secretflow.secretpad.service.DataService;
-import org.secretflow.secretpad.service.model.common.SecretPadResponse;
-import org.secretflow.secretpad.service.model.data.DataSourceVO;
-import org.secretflow.secretpad.service.model.data.DataTableInformationVo;
-import org.secretflow.secretpad.service.model.data.DataVersionVO;
-import org.secretflow.secretpad.service.model.data.GetDataTableInformatinoRequest;
+package org.secretflow.easypsi.web.controller;
import jakarta.servlet.ServletOutputStream;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
+import org.secretflow.easypsi.common.annotation.resource.InterfaceResource;
+import org.secretflow.easypsi.common.constant.resource.InterfaceResourceCode;
+import org.secretflow.easypsi.common.dto.DownloadInfo;
+import org.secretflow.easypsi.common.errorcode.SystemErrorCode;
+import org.secretflow.easypsi.common.exception.EasyPsiException;
+import org.secretflow.easypsi.common.util.JsonUtils;
+import org.secretflow.easypsi.common.util.UserContext;
+import org.secretflow.easypsi.service.DataService;
+import org.secretflow.easypsi.service.model.common.EasyPsiResponse;
+import org.secretflow.easypsi.service.model.data.DataSourceVO;
+import org.secretflow.easypsi.service.model.data.DataTableInformationVo;
+import org.secretflow.easypsi.service.model.data.DataVersionVO;
+import org.secretflow.easypsi.service.model.data.GetDataTableInformatinoRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -81,41 +80,39 @@ public static void downloadFileByStream(HttpServletResponse response, DownloadIn
inputStream.close();
} catch (Exception e) {
logger.error(e.getMessage());
- throw SecretpadException.of(SystemErrorCode.UNKNOWN_ERROR, e);
+ throw EasyPsiException.of(SystemErrorCode.UNKNOWN_ERROR, e);
}
}
@PostMapping(value = "/host/path")
@InterfaceResource(interfaceCode = InterfaceResourceCode.DATA_HOST_PATH)
- public SecretPadResponse queryHostPath() {
- return SecretPadResponse.success(dataService.queryDataPath());
+ public EasyPsiResponse queryHostPath() {
+ return EasyPsiResponse.success(dataService.queryDataPath());
}
@PostMapping(value = "/version")
@InterfaceResource(interfaceCode = InterfaceResourceCode.DATA_VERSION)
- public SecretPadResponse queryDataVersion() {
- return SecretPadResponse.success(dataService.queryDataVersion());
+ public EasyPsiResponse queryDataVersion() {
+ return EasyPsiResponse.success(dataService.queryDataVersion());
}
- @PostMapping(value = "/count")
/**
* query data table info. for web ui
*/
+ @PostMapping(value = "/count")
@InterfaceResource(interfaceCode = InterfaceResourceCode.DATA_COUNT)
- public SecretPadResponse queryDataTableInformation(@Valid @RequestBody GetDataTableInformatinoRequest request) {
- return SecretPadResponse.success(dataService.queryDataTableInformation(request));
+ public EasyPsiResponse queryDataTableInformation(@Valid @RequestBody GetDataTableInformatinoRequest request) {
+ return EasyPsiResponse.success(dataService.queryDataTableInformation(request));
}
- @PostMapping(value = "/count/kuscia")
- @InterfaceResource(interfaceCode = InterfaceResourceCode.DATA_COUNT_KUSCIA)
/**
* query data table info. for partner node
*/
- public SecretPadResponse queryKusciaDataTableInformation(@Valid @RequestBody GetDataTableInformatinoRequest request) {
+ @PostMapping(value = "/count/kuscia")
+ @InterfaceResource(interfaceCode = InterfaceResourceCode.DATA_COUNT_KUSCIA)
+ public EasyPsiResponse queryKusciaDataTableInformation(@Valid @RequestBody GetDataTableInformatinoRequest request) {
LOGGER.info("The opposite party queries our data table information, opposite node id: {},query data table information : {}", UserContext.getUser().getOwnerId(), request.getDstDataTableName());
DataTableInformationVo.DataTableInformation dataTabelInformation = dataService.getDataTabelInformation(request);
- return SecretPadResponse.success(JsonUtils.toJSONString(dataTabelInformation));
+ return EasyPsiResponse.success(JsonUtils.toJSONString(dataTabelInformation));
}
-
-
}
diff --git a/easypsi-web/src/main/java/org/secretflow/easypsi/web/controller/EncryptionController.java b/easypsi-web/src/main/java/org/secretflow/easypsi/web/controller/EncryptionController.java
new file mode 100644
index 0000000..c5d2e0e
--- /dev/null
+++ b/easypsi-web/src/main/java/org/secretflow/easypsi/web/controller/EncryptionController.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2023 Ant Group Co., Ltd.
+ *
+ * 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.
+ */
+
+package org.secretflow.easypsi.web.controller;
+
+import org.secretflow.easypsi.service.RsaEncryptionKeyService;
+import org.secretflow.easypsi.service.model.common.EasyPsiResponse;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+
+/**
+ * Encryption controller
+ *
+ * @author lihaixin
+ * @date 2024/02/04
+ */
+@RestController
+@RequestMapping(value = "/api/encryption")
+public class EncryptionController {
+ @Autowired
+ private RsaEncryptionKeyService rsaEncryptionKeyService;
+
+
+ /**
+ * Get random key string.
+ *
+ * @return {@link String }
+ */
+ @GetMapping(value = "/getRandomKey")
+ public EasyPsiResponse getRandomKey() {
+ return EasyPsiResponse.success(rsaEncryptionKeyService.findByPublicKey(null).getPublicKey());
+ }
+}
diff --git a/secretpad-web/src/main/java/org/secretflow/secretpad/web/controller/FabricLogController.java b/easypsi-web/src/main/java/org/secretflow/easypsi/web/controller/FabricLogController.java
similarity index 59%
rename from secretpad-web/src/main/java/org/secretflow/secretpad/web/controller/FabricLogController.java
rename to easypsi-web/src/main/java/org/secretflow/easypsi/web/controller/FabricLogController.java
index 95726ef..c8bdc7f 100644
--- a/secretpad-web/src/main/java/org/secretflow/secretpad/web/controller/FabricLogController.java
+++ b/easypsi-web/src/main/java/org/secretflow/easypsi/web/controller/FabricLogController.java
@@ -14,19 +14,18 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.web.controller;
-
-import org.secretflow.secretpad.common.annotation.resource.InterfaceResource;
-import org.secretflow.secretpad.common.constant.resource.InterfaceResourceCode;
-import org.secretflow.secretpad.common.errorcode.SystemErrorCode;
-import org.secretflow.secretpad.common.exception.SecretpadException;
-import org.secretflow.secretpad.manager.integration.fabric.FabricManager;
-import org.secretflow.secretpad.persistence.entity.FabricLogDO;
-import org.secretflow.secretpad.persistence.repository.FabricLogRepository;
-import org.secretflow.secretpad.service.model.common.SecretPadResponse;
-import org.secretflow.secretpad.service.model.fabric.FabricLogRequest;
+package org.secretflow.easypsi.web.controller;
import org.apache.commons.lang3.StringUtils;
+import org.secretflow.easypsi.common.annotation.resource.InterfaceResource;
+import org.secretflow.easypsi.common.constant.resource.InterfaceResourceCode;
+import org.secretflow.easypsi.common.errorcode.SystemErrorCode;
+import org.secretflow.easypsi.common.exception.EasyPsiException;
+import org.secretflow.easypsi.manager.integration.fabric.FabricManager;
+import org.secretflow.easypsi.persistence.entity.FabricLogDO;
+import org.secretflow.easypsi.persistence.repository.FabricLogRepository;
+import org.secretflow.easypsi.service.model.common.EasyPsiResponse;
+import org.secretflow.easypsi.service.model.fabric.FabricLogRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@@ -52,28 +51,28 @@ public class FabricLogController {
* Query fabric log by log path or log hash
*
* @param fabricLogRequest
- * @return {@link SecretPadResponse }<{@link Object }>
+ * @return {@link EasyPsiResponse }<{@link Object }>
*/
@ResponseBody
@PostMapping(value = "/query", consumes = "application/json")
@InterfaceResource(interfaceCode = InterfaceResourceCode.AUTH_LOGIN)
- public SecretPadResponse queryFabricLog(@RequestBody FabricLogRequest fabricLogRequest) {
+ public EasyPsiResponse queryFabricLog(@RequestBody FabricLogRequest fabricLogRequest) {
if (StringUtils.isBlank(fabricLogRequest.getLogHash()) && StringUtils.isBlank(fabricLogRequest.getLogPath())) {
- throw SecretpadException.of(SystemErrorCode.VALIDATION_ERROR, "params is null");
+ throw EasyPsiException.of(SystemErrorCode.VALIDATION_ERROR, "params is null");
}
if (StringUtils.isBlank(fabricLogRequest.getLogHash())) {
FabricLogDO fabricLogDO = fabricLogRepository.findByLogPath(fabricLogRequest.getLogPath());
if (Objects.isNull(fabricLogDO)) {
- throw SecretpadException.of(SystemErrorCode.HTTP_5XX_ERROR, "data is null");
+ throw EasyPsiException.of(SystemErrorCode.HTTP_5XX_ERROR, "data is null");
}
fabricLogRequest.setLogHash(fabricLogDO.getLogHash());
}
try {
- return SecretPadResponse.success(fabricManager.evaluateTransactionByAssetId(fabricLogRequest.getLogHash()));
+ return EasyPsiResponse.success(fabricManager.evaluateTransactionByAssetId(fabricLogRequest.getLogHash()));
} catch (Exception exception) {
- throw SecretpadException.of(SystemErrorCode.HTTP_5XX_ERROR, "data is null");
+ throw EasyPsiException.of(SystemErrorCode.HTTP_5XX_ERROR, "data is null");
}
}
diff --git a/secretpad-web/src/main/java/org/secretflow/secretpad/web/controller/IndexController.java b/easypsi-web/src/main/java/org/secretflow/easypsi/web/controller/IndexController.java
similarity index 82%
rename from secretpad-web/src/main/java/org/secretflow/secretpad/web/controller/IndexController.java
rename to easypsi-web/src/main/java/org/secretflow/easypsi/web/controller/IndexController.java
index 6a4a42b..1a27bfa 100644
--- a/secretpad-web/src/main/java/org/secretflow/secretpad/web/controller/IndexController.java
+++ b/easypsi-web/src/main/java/org/secretflow/easypsi/web/controller/IndexController.java
@@ -14,10 +14,10 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.web.controller;
+package org.secretflow.easypsi.web.controller;
-import org.secretflow.secretpad.common.annotation.resource.InterfaceResource;
-import org.secretflow.secretpad.common.constant.resource.InterfaceResourceCode;
+import org.secretflow.easypsi.common.annotation.resource.InterfaceResource;
+import org.secretflow.easypsi.common.constant.resource.InterfaceResourceCode;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@@ -36,7 +36,7 @@ public class IndexController {
* @return the string
*/
@InterfaceResource(interfaceCode = InterfaceResourceCode.INDEX)
- @RequestMapping(value = {"/","/login", "/guide","/task","/task-details"}, method = RequestMethod.GET)
+ @RequestMapping(value = {"/","/login", "/guide","/task","/task-details","/home","/auth"}, method = RequestMethod.GET)
public String index() {
return "index";
}
diff --git a/secretpad-web/src/main/java/org/secretflow/secretpad/web/controller/NodeController.java b/easypsi-web/src/main/java/org/secretflow/easypsi/web/controller/NodeController.java
similarity index 65%
rename from secretpad-web/src/main/java/org/secretflow/secretpad/web/controller/NodeController.java
rename to easypsi-web/src/main/java/org/secretflow/easypsi/web/controller/NodeController.java
index 08c94ef..aa01924 100644
--- a/secretpad-web/src/main/java/org/secretflow/secretpad/web/controller/NodeController.java
+++ b/easypsi-web/src/main/java/org/secretflow/easypsi/web/controller/NodeController.java
@@ -14,23 +14,22 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.web.controller;
-
-import org.secretflow.secretpad.common.annotation.resource.DataResource;
-import org.secretflow.secretpad.common.annotation.resource.InterfaceResource;
-import org.secretflow.secretpad.common.constant.resource.DataResourceType;
-import org.secretflow.secretpad.common.constant.resource.InterfaceResourceCode;
-import org.secretflow.secretpad.common.errorcode.SystemErrorCode;
-import org.secretflow.secretpad.common.exception.SecretpadException;
-import org.secretflow.secretpad.service.NodeService;
-import org.secretflow.secretpad.service.model.common.SecretPadResponse;
-import org.secretflow.secretpad.service.model.node.*;
+package org.secretflow.easypsi.web.controller;
import jakarta.servlet.ServletOutputStream;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.apache.commons.codec.binary.Base64;
+import org.secretflow.easypsi.common.annotation.resource.DataResource;
+import org.secretflow.easypsi.common.annotation.resource.InterfaceResource;
+import org.secretflow.easypsi.common.constant.resource.DataResourceType;
+import org.secretflow.easypsi.common.constant.resource.InterfaceResourceCode;
+import org.secretflow.easypsi.common.errorcode.SystemErrorCode;
+import org.secretflow.easypsi.common.exception.EasyPsiException;
+import org.secretflow.easypsi.service.NodeService;
+import org.secretflow.easypsi.service.model.common.EasyPsiResponse;
+import org.secretflow.easypsi.service.model.node.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.MediaType;
@@ -53,51 +52,62 @@ public class NodeController {
* Create a new node api
*
* @param request create node request
- * @return successful SecretPadResponse with nodeId
+ * @return successful EasyPsiResponse with nodeId
*/
@PostMapping(value = "/create", consumes = "application/json")
@InterfaceResource(interfaceCode = InterfaceResourceCode.NODE_CREATE)
- public SecretPadResponse createNode(@Valid @RequestBody CreateNodeRequest request) {
+ public EasyPsiResponse createNode(@Valid @RequestBody CreateNodeRequest request) {
String node = nodeService.createNode(request);
- return SecretPadResponse.success(node);
+ return EasyPsiResponse.success(node);
}
+ /**
+ * Update node api
+ *
+ * @param request create node request
+ * @return successful EasyPsiResponse with nodeId
+ */
+ @PostMapping(value = "/update", consumes = "application/json")
+ @InterfaceResource(interfaceCode = InterfaceResourceCode.NODE_CREATE)
+ public EasyPsiResponse updateNode(@Valid @RequestBody UpdateNodeRequest request) {
+ return EasyPsiResponse.success(nodeService.updateNode(request));
+ }
@PostMapping(value = "/get", consumes = "application/json")
@DataResource(field = "nodeId", resourceType = DataResourceType.NODE_ID)
@InterfaceResource(interfaceCode = InterfaceResourceCode.NODE_GET)
- public SecretPadResponse get() {
- return SecretPadResponse.success(nodeService.getNode());
+ public EasyPsiResponse get() {
+ return EasyPsiResponse.success(nodeService.getNode());
}
@PostMapping(value = "/delete", consumes = "application/json")
@DataResource(field = "nodeId", resourceType = DataResourceType.NODE_ID)
@InterfaceResource(interfaceCode = InterfaceResourceCode.NODE_DELETE)
- public SecretPadResponse deleteNode(@Valid @RequestBody DeleteNodeIdRequest request) {
+ public EasyPsiResponse deleteNode(@Valid @RequestBody DeleteNodeIdRequest request) {
nodeService.deleteNode(request.getRouterId());
- return SecretPadResponse.success();
+ return EasyPsiResponse.success();
}
/**
* Upload node certificate api
*
* @param file multipart file
- * @return successful SecretPadResponse with upload certificate result view object
+ * @return successful EasyPsiResponse with upload certificate result view object
*/
@ResponseBody
@PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
@InterfaceResource(interfaceCode = InterfaceResourceCode.NODE_CERTIFICATE_UPLOAD)
- public SecretPadResponse upload(
+ public EasyPsiResponse upload(
@RequestParam("file") MultipartFile file
) {
- return SecretPadResponse.success(nodeService.convertCertificate(file));
+ return EasyPsiResponse.success(nodeService.convertCertificate(file));
}
/**
* Download node certificate api
*
* @param response http servlet response
- * @return successful SecretPadResponse with null data
+ * @return successful EasyPsiResponse with null data
*/
@ResponseBody
@PostMapping(value = "/download")
@@ -115,7 +125,7 @@ public void download(HttpServletResponse response, @Valid @RequestBody DownloadN
outputStream.close();
} catch (Exception e) {
LOGGER.error(e.getMessage());
- throw SecretpadException.of(SystemErrorCode.UNKNOWN_ERROR, e);
+ throw EasyPsiException.of(SystemErrorCode.UNKNOWN_ERROR, e);
}
}
diff --git a/secretpad-web/src/main/java/org/secretflow/secretpad/web/controller/NodeRouteController.java b/easypsi-web/src/main/java/org/secretflow/easypsi/web/controller/NodeRouteController.java
similarity index 57%
rename from secretpad-web/src/main/java/org/secretflow/secretpad/web/controller/NodeRouteController.java
rename to easypsi-web/src/main/java/org/secretflow/easypsi/web/controller/NodeRouteController.java
index 56f520b..cb25779 100644
--- a/secretpad-web/src/main/java/org/secretflow/secretpad/web/controller/NodeRouteController.java
+++ b/easypsi-web/src/main/java/org/secretflow/easypsi/web/controller/NodeRouteController.java
@@ -14,19 +14,18 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.web.controller;
-
-import org.secretflow.secretpad.common.annotation.resource.InterfaceResource;
-import org.secretflow.secretpad.common.constant.resource.InterfaceResourceCode;
-import org.secretflow.secretpad.service.NodeRouterService;
-import org.secretflow.secretpad.service.model.common.SecretPadResponse;
-import org.secretflow.secretpad.service.model.noderoute.NodeRouterVO;
-import org.secretflow.secretpad.service.model.noderoute.RouterAddressRequest;
-import org.secretflow.secretpad.service.model.noderoute.RouterIdRequest;
-import org.secretflow.secretpad.service.model.noderoute.UpdateNodeRouterRequest;
+package org.secretflow.easypsi.web.controller;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
+import org.secretflow.easypsi.common.annotation.resource.InterfaceResource;
+import org.secretflow.easypsi.common.constant.resource.InterfaceResourceCode;
+import org.secretflow.easypsi.service.NodeRouterService;
+import org.secretflow.easypsi.service.model.common.EasyPsiResponse;
+import org.secretflow.easypsi.service.model.noderoute.NodeRouterVO;
+import org.secretflow.easypsi.service.model.noderoute.RouterAddressRequest;
+import org.secretflow.easypsi.service.model.noderoute.RouterIdRequest;
+import org.secretflow.easypsi.service.model.noderoute.UpdateNodeRouterRequest;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -46,27 +45,27 @@ public class NodeRouteController {
@PostMapping(value = "/update", consumes = "application/json")
@InterfaceResource(interfaceCode = InterfaceResourceCode.NODE_ROUTE_UPDATE)
- public SecretPadResponse update(@Valid @RequestBody UpdateNodeRouterRequest request) {
+ public EasyPsiResponse update(@Valid @RequestBody UpdateNodeRouterRequest request) {
nodeRouterService.updateNodeRouter(request);
- return SecretPadResponse.success(request.getRouterId());
+ return EasyPsiResponse.success(request.getRouterId());
}
@PostMapping(value = "/refresh", consumes = "application/json")
@InterfaceResource(interfaceCode = InterfaceResourceCode.NODE_ROUTE_REFRESH)
- public SecretPadResponse refresh(@Valid @RequestBody RouterIdRequest request) {
- return SecretPadResponse.success(nodeRouterService.refreshRouter(Long.parseLong(request.getRouterId())));
+ public EasyPsiResponse refresh(@Valid @RequestBody RouterIdRequest request) {
+ return EasyPsiResponse.success(nodeRouterService.refreshRouter(Long.parseLong(request.getRouterId())));
}
@PostMapping(value = "/test", consumes = "application/json")
@InterfaceResource(interfaceCode = InterfaceResourceCode.NODE_ROUTE_TEST)
- public SecretPadResponse test(@Valid @RequestBody RouterAddressRequest request){
- return SecretPadResponse.success(nodeRouterService.testAddress(request.getNetAddress()));
+ public EasyPsiResponse test(@Valid @RequestBody RouterAddressRequest request){
+ return EasyPsiResponse.success(nodeRouterService.testAddress(request.getNetAddress()));
}
@PostMapping(value = "/collaborationRoute")
@InterfaceResource(interfaceCode = InterfaceResourceCode.NODE_ROUTE_LIST)
- public SecretPadResponse> queryCollaborationList() {
- return SecretPadResponse.success(nodeRouterService.listNodeRoute());
+ public EasyPsiResponse> queryCollaborationList() {
+ return EasyPsiResponse.success(nodeRouterService.listNodeRoute());
}
}
\ No newline at end of file
diff --git a/secretpad-web/src/main/java/org/secretflow/secretpad/web/controller/ProjectController.java b/easypsi-web/src/main/java/org/secretflow/easypsi/web/controller/ProjectController.java
similarity index 61%
rename from secretpad-web/src/main/java/org/secretflow/secretpad/web/controller/ProjectController.java
rename to easypsi-web/src/main/java/org/secretflow/easypsi/web/controller/ProjectController.java
index 0ba8f80..2de1f73 100644
--- a/secretpad-web/src/main/java/org/secretflow/secretpad/web/controller/ProjectController.java
+++ b/easypsi-web/src/main/java/org/secretflow/easypsi/web/controller/ProjectController.java
@@ -14,25 +14,24 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.web.controller;
-
-import org.secretflow.secretpad.common.annotation.resource.DataResource;
-import org.secretflow.secretpad.common.annotation.resource.InterfaceResource;
-import org.secretflow.secretpad.common.constant.resource.DataResourceType;
-import org.secretflow.secretpad.common.constant.resource.InterfaceResourceCode;
-import org.secretflow.secretpad.common.dto.DownloadInfo;
-import org.secretflow.secretpad.common.util.UserContext;
-import org.secretflow.secretpad.service.ProjectService;
-import org.secretflow.secretpad.service.model.common.SecretPadPageResponse;
-import org.secretflow.secretpad.service.model.common.SecretPadResponse;
-import org.secretflow.secretpad.service.model.graph.GrapDataHeaderVO;
-import org.secretflow.secretpad.service.model.graph.GrapDataTableVO;
-import org.secretflow.secretpad.service.model.graph.GraphNodeJobLogsVO;
-import org.secretflow.secretpad.service.model.project.*;
+package org.secretflow.easypsi.web.controller;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
+import org.secretflow.easypsi.common.annotation.resource.DataResource;
+import org.secretflow.easypsi.common.annotation.resource.InterfaceResource;
+import org.secretflow.easypsi.common.constant.resource.DataResourceType;
+import org.secretflow.easypsi.common.constant.resource.InterfaceResourceCode;
+import org.secretflow.easypsi.common.dto.DownloadInfo;
+import org.secretflow.easypsi.common.util.UserContext;
+import org.secretflow.easypsi.service.ProjectService;
+import org.secretflow.easypsi.service.model.common.EasyPsiPageResponse;
+import org.secretflow.easypsi.service.model.common.EasyPsiResponse;
+import org.secretflow.easypsi.service.model.graph.GrapDataHeaderVO;
+import org.secretflow.easypsi.service.model.graph.GrapDataTableVO;
+import org.secretflow.easypsi.service.model.graph.GraphNodeJobLogsVO;
+import org.secretflow.easypsi.service.model.project.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -59,254 +58,259 @@ public class ProjectController {
* Paging list project job list api
*
* @param request list project job request
- * @return successful SecretPadResponse with paging project job view object
+ * @return successful EasyPsiResponse with paging project job view object
*/
@ResponseBody
@PostMapping(value = "/job/list")
@Operation(summary = "project job list", description = "project job list")
@DataResource(field = "projectId", resourceType = DataResourceType.PROJECT_ID)
@InterfaceResource(interfaceCode = InterfaceResourceCode.PRJ_JOB_LIST)
- public SecretPadResponse> listJob(@Valid @RequestBody ListProjectJobRequest request) {
- return SecretPadResponse.success(projectService.listProjectJob(request));
+ public EasyPsiResponse> listJob(@Valid @RequestBody ListProjectJobRequest request) {
+ return EasyPsiResponse.success(projectService.listProjectJob(request));
}
/**
* Query project job detail api
*
* @param request get project job request
- * @return successful SecretPadResponse with project job view object
+ * @return successful EasyPsiResponse with project job view object
*/
@ResponseBody
@PostMapping(value = "/job/get")
@Operation(summary = "project job detail", description = "project job detail")
@DataResource(field = "projectId", resourceType = DataResourceType.PROJECT_ID)
@InterfaceResource(interfaceCode = InterfaceResourceCode.PRJ_JOB_GET)
- public SecretPadResponse getJob(@Valid @RequestBody GetProjectJobRequest request) {
- return SecretPadResponse.success(projectService.getProjectJob(request));
+ public EasyPsiResponse getJob(@Valid @RequestBody GetProjectJobRequest request) {
+ return EasyPsiResponse.success(projectService.getProjectJob(request));
}
/**
* Stop project job api
*
* @param request stop project job task request
- * @return successful SecretPadResponse with null data
+ * @return successful EasyPsiResponse with null data
*/
@ResponseBody
@PostMapping(value = "/job/stop")
@DataResource(field = "projectId", resourceType = DataResourceType.PROJECT_ID)
@InterfaceResource(interfaceCode = InterfaceResourceCode.PRJ_JOB_STOP)
@Operation(summary = "stop project job", description = "stop project job")
- public SecretPadResponse stopJob(@Valid @RequestBody StopProjectJobTaskRequest request) {
+ public EasyPsiResponse stopJob(@Valid @RequestBody StopProjectJobTaskRequest request) {
projectService.stopProjectJob(request);
- return SecretPadResponse.success();
+ return EasyPsiResponse.success();
}
+
/**
* Query project job logs
*
- * @return successful SecretPadResponse with project job logs list view object
+ * @return successful EasyPsiResponse with project job logs list view object
*/
@PostMapping(value = "/job/logs")
@InterfaceResource(interfaceCode = InterfaceResourceCode.PRJ_JOB_LOGS)
@Operation(summary = "project job logs", description = "project job logs")
- public SecretPadResponse getProjectLogs(@Valid @RequestBody GetProjectJobLogRequest request) {
- return SecretPadResponse.success(projectService.getProjectJobInFeilLogs(request));
+ public EasyPsiResponse getProjectLogs(@Valid @RequestBody GetProjectJobLogRequest request) {
+ return EasyPsiResponse.success(projectService.getProjectJobInFeilLogs(request));
}
/**
* Query csv data table
*
- * @return successful SecretPadResponse with csv data table list view object
+ * @return successful EasyPsiResponse with csv data table list view object
*/
@PostMapping(value = "/data/table")
@InterfaceResource(interfaceCode = InterfaceResourceCode.PRJ_DATA_HEADER)
@Operation(summary = "query data table", description = "query data table")
- public SecretPadResponse getDataTable(@Valid @RequestBody GetProjectJobTableRequest request) {
- return SecretPadResponse.success(projectService.getDataTable(request, request.isCheckTableExist()));
+ public EasyPsiResponse getDataTable(@Valid @RequestBody GetProjectJobTableRequest request) {
+ return EasyPsiResponse.success(projectService.getDataTable(request, request.isCheckTableExist()));
}
/**
* Query csv data header
*
- * @return successful SecretPadResponse with csv data header list view object
+ * @return successful EasyPsiResponse with csv data header list view object
*/
@PostMapping(value = "/data/header")
@InterfaceResource(interfaceCode = InterfaceResourceCode.PRJ_DATA_HEADER)
@Operation(summary = "query data header", description = "query data header")
- public SecretPadResponse getDataHeader(@Valid @RequestBody GetProjectJobDataHeaderRequest request) {
- return SecretPadResponse.success(projectService.getDataHeader(request, request.isCheckDataHeaderExist()));
+ public EasyPsiResponse getDataHeader(@Valid @RequestBody GetProjectJobDataHeaderRequest request) {
+ return EasyPsiResponse.success(projectService.getDataHeader(request, request.isCheckDataHeaderExist()));
}
/**
* Delete project job api
*
* @param request delete project job task request
- * @return successful SecretPadResponse with null data
+ * @return successful EasyPsiResponse with null data
*/
@ResponseBody
@PostMapping(value = "/job/delete")
@DataResource(field = "projectId", resourceType = DataResourceType.PROJECT_ID)
@InterfaceResource(interfaceCode = InterfaceResourceCode.PRJ_JOB_DELETE)
@Operation(summary = "delete project job", description = "delete project job")
- public SecretPadResponse deleteJob(@Valid @RequestBody DeleteProjectJobTaskRequest request) {
+ public EasyPsiResponse deleteJob(@Valid @RequestBody DeleteProjectJobTaskRequest request) {
projectService.deleteProjectJob(request);
- return SecretPadResponse.success();
+ return EasyPsiResponse.success();
}
/**
* Create project job api
*
* @param request create project job task request
- * @return successful SecretPadResponse with CreateProjectJobVO
+ * @return successful EasyPsiResponse with CreateProjectJobVO
*/
@ResponseBody
@PostMapping(value = "/job/create")
@DataResource(field = "projectId", resourceType = DataResourceType.PROJECT_ID)
@InterfaceResource(interfaceCode = InterfaceResourceCode.PRJ_JOB_CREATE)
@Operation(summary = "create project job", description = "create project job")
- public SecretPadResponse createJob(@Valid @RequestBody CreateProjectJobRequest request) {
- return SecretPadResponse.success(projectService.createJob(request));
+ public EasyPsiResponse createJob(@Valid @RequestBody CreateProjectJobRequest request) {
+ return EasyPsiResponse.success(projectService.createJob(request));
}
/**
* Agree project job api
*
* @param request agree project job task request
- * @return successful SecretPadResponse with null data
+ * @return successful EasyPsiResponse with null data
*/
@ResponseBody
@PostMapping(value = "/job/agree")
@DataResource(field = "projectId", resourceType = DataResourceType.PROJECT_ID)
@InterfaceResource(interfaceCode = InterfaceResourceCode.PRJ_JOB_AGREE)
@Operation(summary = "agree project job", description = "agree project job")
- public SecretPadResponse agreeJob(@Valid @RequestBody AgreeProjectJobTaskRequest request) {
+ public EasyPsiResponse agreeJob(@Valid @RequestBody AgreeProjectJobTaskRequest request) {
projectService.agreeJob(request);
- return SecretPadResponse.success();
+ return EasyPsiResponse.success();
}
/**
* Pause project job api
*
* @param request pause project job task request
- * @return successful SecretPadResponse with null data
+ * @return successful EasyPsiResponse with null data
*/
@ResponseBody
@PostMapping(value = "/job/pause")
@DataResource(field = "projectId", resourceType = DataResourceType.PROJECT_ID)
@InterfaceResource(interfaceCode = InterfaceResourceCode.PRJ_JOB_PAUSE)
@Operation(summary = "pause project job", description = "pause project job")
- public SecretPadResponse pauseJob(@Valid @RequestBody StopProjectJobTaskRequest request) {
+ public EasyPsiResponse pauseJob(@Valid @RequestBody StopProjectJobTaskRequest request) {
projectService.pauseJob(request);
- return SecretPadResponse.success();
+ return EasyPsiResponse.success();
}
/**
* Continue project job api
*
* @param request Continue project job task request
- * @return successful SecretPadResponse with null data
+ * @return successful EasyPsiResponse with null data
*/
@ResponseBody
@PostMapping(value = "/job/continue")
@DataResource(field = "projectId", resourceType = DataResourceType.PROJECT_ID)
@InterfaceResource(interfaceCode = InterfaceResourceCode.PRJ_JOB_CONTINUE)
@Operation(summary = "continue project job", description = "continue project job")
- public SecretPadResponse continueJob(@Valid @RequestBody StopProjectJobTaskRequest request) {
+ public EasyPsiResponse continueJob(@Valid @RequestBody StopProjectJobTaskRequest request) {
projectService.continueJob(request);
- return SecretPadResponse.success();
+ return EasyPsiResponse.success();
}
/**
* Create project job api
+ * Call the partner remotely through kuscia
*
* @param request create project job task request
- * @return successful SecretPadResponse with null data
+ * @return successful EasyPsiResponse with null data
*/
@ResponseBody
@PostMapping(value = "/job/create/kuscia")
@DataResource(field = "projectId", resourceType = DataResourceType.PROJECT_ID)
@InterfaceResource(interfaceCode = InterfaceResourceCode.PRJ_JOB_CREATE_KUSCIA)
@Operation(summary = "create project job", description = "create project job")
- public SecretPadResponse createKusciaJob(@Valid @RequestBody CreateProjectJobTaskRequest request) {
+ public EasyPsiResponse createKusciaJob(@Valid @RequestBody CreateProjectJobTaskRequest request) {
projectService.createKusciaJob(request);
- return SecretPadResponse.success();
+ return EasyPsiResponse.success();
}
-
/**
* Stop project job api
+ * Call the partner remotely through kuscia
*
* @param request stop project job task request
- * @return successful SecretPadResponse with null data
+ * @return successful EasyPsiResponse with null data
*/
@ResponseBody
@PostMapping(value = "/job/stop/kuscia")
@DataResource(field = "projectId", resourceType = DataResourceType.PROJECT_ID)
@InterfaceResource(interfaceCode = InterfaceResourceCode.PRJ_JOB_STOP_KUSCIA)
@Operation(summary = "stop project job", description = "stop project job")
- public SecretPadResponse stopKusciaJob(@Valid @RequestBody StopProjectJobTaskRequest request) {
+ public EasyPsiResponse stopKusciaJob(@Valid @RequestBody StopProjectJobTaskRequest request) {
projectService.stopKusciaJob(request);
- return SecretPadResponse.success();
+ return EasyPsiResponse.success();
}
/**
* Continue project job api
+ * Call the partner remotely through kuscia
*
* @param request Continue project job task request
- * @return successful SecretPadResponse with null data
+ * @return successful EasyPsiResponse with null data
*/
@ResponseBody
@PostMapping(value = "/job/continue/kuscia")
@DataResource(field = "projectId", resourceType = DataResourceType.PROJECT_ID)
@InterfaceResource(interfaceCode = InterfaceResourceCode.PRJ_JOB_CONTINUE_KUSCIA)
@Operation(summary = "continue project job", description = "continue project job")
- public SecretPadResponse continueKusciaJob(@Valid @RequestBody StopProjectJobTaskRequest request) {
+ public EasyPsiResponse continueKusciaJob(@Valid @RequestBody StopProjectJobTaskRequest request) {
projectService.continueKusciaJob(request);
- return SecretPadResponse.success();
+ return EasyPsiResponse.success();
}
/**
* Pause project job api
+ * Call the partner remotely through kuscia
*
* @param request pause project job task request
- * @return successful SecretPadResponse with null data
+ * @return successful EasyPsiResponse with null data
*/
@ResponseBody
@PostMapping(value = "/job/pause/kuscia")
@DataResource(field = "projectId", resourceType = DataResourceType.PROJECT_ID)
@InterfaceResource(interfaceCode = InterfaceResourceCode.PRJ_JOB_PAUSE_KUSCIA)
@Operation(summary = "pause project job", description = "pause project job")
- public SecretPadResponse pauseKusciaJob(@Valid @RequestBody StopProjectJobTaskRequest request) {
+ public EasyPsiResponse pauseKusciaJob(@Valid @RequestBody StopProjectJobTaskRequest request) {
projectService.pauseKusciaJob(request);
- return SecretPadResponse.success();
+ return EasyPsiResponse.success();
}
+
/**
* Reject project job api
*
* @param request Reject project job task request
- * @return successful SecretPadResponse with null data
+ * @return successful EasyPsiResponse with null data
*/
@ResponseBody
@PostMapping(value = "/job/reject")
@DataResource(field = "projectId", resourceType = DataResourceType.PROJECT_ID)
@InterfaceResource(interfaceCode = InterfaceResourceCode.PRJ_JOB_REJECT)
@Operation(summary = "reject project job", description = "reject project job")
- public SecretPadResponse rejectJob(@Valid @RequestBody RejectProjectJobTaskRequest request) {
+ public EasyPsiResponse rejectJob(@Valid @RequestBody RejectProjectJobTaskRequest request) {
projectService.rejectJob(request);
- return SecretPadResponse.success();
+ return EasyPsiResponse.success();
}
/**
* Download project result api
*
* @param request download data request
- * @return successful SecretPadResponse with hash string
+ * @return successful EasyPsiResponse with hash string
*/
@ResponseBody
@PostMapping(value = "/job/result/download")
@InterfaceResource(interfaceCode = InterfaceResourceCode.PRJ_JOB_RESULT_DOWNLOAD)
- public SecretPadResponse downloadProjectResult(@Valid @RequestBody DownloadProjectResult request) {
- return SecretPadResponse.success(projectService.downloadProjectResult(request.getJobId()));
+ public EasyPsiResponse downloadProjectResult(@Valid @RequestBody DownloadProjectResult request) {
+ return EasyPsiResponse.success(projectService.downloadProjectResult(request.getJobId()));
}
/**
@@ -314,7 +318,7 @@ public SecretPadResponse downloadProjectResult(@Valid @RequestBody Downl
*
* @param response http servlet response
* @param request download data request
- * @return successful SecretPadResponse with null data
+ * @return successful EasyPsiResponse with null data
*/
@ResponseBody
@GetMapping(value = "/job/result/download")
@@ -324,8 +328,10 @@ public void getloadProjectResult(HttpServletResponse response, GetloadProjectRes
DataController.downloadFileByStream(response, downloadInfo, LOGGER);
}
+
/**
* Query project edge job list
+ * Call the partner remotely through kuscia
*
* @return project job view object list
*/
@@ -333,9 +339,25 @@ public void getloadProjectResult(HttpServletResponse response, GetloadProjectRes
@PostMapping(value = "/edge/job/list")
@InterfaceResource(interfaceCode = InterfaceResourceCode.PRJ_EDGE_JOB_LIST)
@Operation(summary = "query project edge job list", description = "query project edge job list")
- public SecretPadResponse> queryEdgeProjectJobs() {
+ public EasyPsiResponse> queryEdgeProjectJobs() {
LOGGER.info("requestNodeId = {}", UserContext.getUser().getOwnerId());
List projectJobs = projectService.queryEdgeProjectJobs(UserContext.getUser().getOwnerId());
- return SecretPadResponse.success(projectJobs);
+ return EasyPsiResponse.success(projectJobs);
}
+
+ /**
+ * Paging list project job list api
+ *
+ * @param request list project job request
+ * @return successful EasyPsiResponse with paging project job view object
+ */
+ @ResponseBody
+ @PostMapping(value = "/job/list/black_screen")
+ @Operation(summary = "project job list", description = "project job list")
+ @DataResource(field = "projectId", resourceType = DataResourceType.PROJECT_ID)
+ @InterfaceResource(interfaceCode = InterfaceResourceCode.PRJ_JOB_LIST)
+ public EasyPsiResponse> listJobByBlackScreen(@Valid @RequestBody ListProjectJobRequest request) {
+ return EasyPsiResponse.success(projectService.listProjectJobByBlackScreen(request));
+ }
+
}
diff --git a/secretpad-web/src/main/java/org/secretflow/secretpad/web/controller/UserController.java b/easypsi-web/src/main/java/org/secretflow/easypsi/web/controller/UserController.java
similarity index 58%
rename from secretpad-web/src/main/java/org/secretflow/secretpad/web/controller/UserController.java
rename to easypsi-web/src/main/java/org/secretflow/easypsi/web/controller/UserController.java
index 3a6edf5..19deaba 100644
--- a/secretpad-web/src/main/java/org/secretflow/secretpad/web/controller/UserController.java
+++ b/easypsi-web/src/main/java/org/secretflow/easypsi/web/controller/UserController.java
@@ -14,17 +14,16 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.web.controller;
-
-import org.secretflow.secretpad.common.annotation.resource.InterfaceResource;
-import org.secretflow.secretpad.common.constant.resource.InterfaceResourceCode;
-import org.secretflow.secretpad.common.dto.UserContextDTO;
-import org.secretflow.secretpad.common.util.UserContext;
-import org.secretflow.secretpad.service.UserService;
-import org.secretflow.secretpad.service.model.auth.UserUpdatePwdRequest;
-import org.secretflow.secretpad.service.model.common.SecretPadResponse;
+package org.secretflow.easypsi.web.controller;
import jakarta.validation.Valid;
+import org.secretflow.easypsi.common.annotation.resource.InterfaceResource;
+import org.secretflow.easypsi.common.constant.resource.InterfaceResourceCode;
+import org.secretflow.easypsi.common.dto.UserContextDTO;
+import org.secretflow.easypsi.common.util.UserContext;
+import org.secretflow.easypsi.service.UserService;
+import org.secretflow.easypsi.service.model.auth.UserUpdatePwdRequest;
+import org.secretflow.easypsi.service.model.common.EasyPsiResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
@@ -35,39 +34,29 @@
* @author beiwei
* @date 2023/9/13
*/
+
@RestController
@RequestMapping(value = "/api/v1alpha1/user")
public class UserController {
+
@Autowired
private UserService userService;
- /**
- * query user info
- *
- * @return successful SecretPadResponse with user name
- */
- @PostMapping(value = "/get")
- @InterfaceResource(interfaceCode = InterfaceResourceCode.USER_GET)
- public SecretPadResponse get() {
- return SecretPadResponse.success(UserContext.getUser());
- }
-
/**
* Update user pwd by userName
*
* @param userUpdatePwdRequest
- * @return {@link SecretPadResponse }<{@link Boolean }>
+ * @return {@link EasyPsiResponse }<{@link Boolean }>
*/
@PostMapping(value = "/updatePwd")
@InterfaceResource(interfaceCode = InterfaceResourceCode.USER_UPDATE_PWD)
- public SecretPadResponse updatePwd(@Valid @RequestBody UserUpdatePwdRequest userUpdatePwdRequest) {
+ public EasyPsiResponse updatePwd(@Valid @RequestBody UserUpdatePwdRequest userUpdatePwdRequest) {
UserContextDTO userContextDTO = UserContext.getUser();
userUpdatePwdRequest.setName(userContextDTO.getName());
userService.updatePwd(userUpdatePwdRequest);
- return SecretPadResponse.success(Boolean.TRUE);
+ return EasyPsiResponse.success(Boolean.TRUE);
}
-
}
diff --git a/secretpad-web/src/main/java/org/secretflow/secretpad/web/exception/BasicErrorHandler.java b/easypsi-web/src/main/java/org/secretflow/easypsi/web/exception/BasicErrorHandler.java
similarity index 80%
rename from secretpad-web/src/main/java/org/secretflow/secretpad/web/exception/BasicErrorHandler.java
rename to easypsi-web/src/main/java/org/secretflow/easypsi/web/exception/BasicErrorHandler.java
index b84ebe9..861fa6e 100644
--- a/secretpad-web/src/main/java/org/secretflow/secretpad/web/exception/BasicErrorHandler.java
+++ b/easypsi-web/src/main/java/org/secretflow/easypsi/web/exception/BasicErrorHandler.java
@@ -14,10 +14,10 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.web.exception;
+package org.secretflow.easypsi.web.exception;
-import org.secretflow.secretpad.common.errorcode.SystemErrorCode;
-import org.secretflow.secretpad.common.exception.SecretpadException;
+import org.secretflow.easypsi.common.errorcode.SystemErrorCode;
+import org.secretflow.easypsi.common.exception.EasyPsiException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
@@ -49,10 +49,10 @@ public ModelAndView errorHtml(HttpServletRequest request, HttpServletResponse re
log.error("BasicErrorController get error {}", status.toString());
if (status.is4xxClientError()) {
if (status.equals(HttpStatus.NOT_FOUND)) {
- throw SecretpadException.of(SystemErrorCode.HTTP_404_ERROR, status.toString());
+ throw EasyPsiException.of(SystemErrorCode.HTTP_404_ERROR, status.toString());
}
- throw SecretpadException.of(SystemErrorCode.HTTP_4XX_ERROR, status.toString());
+ throw EasyPsiException.of(SystemErrorCode.HTTP_4XX_ERROR, status.toString());
}
- throw SecretpadException.of(SystemErrorCode.HTTP_5XX_ERROR, status.toString());
+ throw EasyPsiException.of(SystemErrorCode.HTTP_5XX_ERROR, status.toString());
}
}
diff --git a/secretpad-web/src/main/java/org/secretflow/secretpad/web/exception/SecretpadExceptionHandler.java b/easypsi-web/src/main/java/org/secretflow/easypsi/web/exception/EasyPsiExceptionHandler.java
similarity index 55%
rename from secretpad-web/src/main/java/org/secretflow/secretpad/web/exception/SecretpadExceptionHandler.java
rename to easypsi-web/src/main/java/org/secretflow/easypsi/web/exception/EasyPsiExceptionHandler.java
index 2415939..87cec32 100644
--- a/secretpad-web/src/main/java/org/secretflow/secretpad/web/exception/SecretpadExceptionHandler.java
+++ b/easypsi-web/src/main/java/org/secretflow/easypsi/web/exception/EasyPsiExceptionHandler.java
@@ -14,68 +14,65 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.web.exception;
+package org.secretflow.easypsi.web.exception;
-import org.secretflow.secretpad.common.errorcode.ErrorCode;
-import org.secretflow.secretpad.common.errorcode.SystemErrorCode;
-import org.secretflow.secretpad.common.exception.SecretpadException;
-import org.secretflow.secretpad.common.i18n.MessageResolver;
-import org.secretflow.secretpad.service.model.common.SecretPadResponse;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.google.common.collect.Maps;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
-import org.apache.commons.codec.CharEncoding;
import org.apache.tomcat.util.http.fileupload.impl.FileSizeLimitExceededException;
+import org.secretflow.easypsi.common.errorcode.ErrorCode;
+import org.secretflow.easypsi.common.errorcode.SystemErrorCode;
+import org.secretflow.easypsi.common.exception.EasyPsiException;
+import org.secretflow.easypsi.common.i18n.MessageResolver;
+import org.secretflow.easypsi.service.model.common.EasyPsiResponse;
+import org.secretflow.easypsi.web.util.ResponseUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.MediaType;
+import org.springframework.dao.DataAccessResourceFailureException;
import org.springframework.validation.FieldError;
import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
+import org.springframework.web.servlet.NoHandlerFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
-import java.util.Map;
/**
- * SecretPad exception handler
+ * EasyPsi exception handler
*
* @author yansi
* @date 2023/5/10
*/
@RestControllerAdvice
-public class SecretpadExceptionHandler {
- private static final Logger LOGGER = LoggerFactory.getLogger(SecretpadExceptionHandler.class);
+public class EasyPsiExceptionHandler {
+ private static final Logger LOGGER = LoggerFactory.getLogger(EasyPsiExceptionHandler.class);
@Autowired
private MessageResolver messageResolver;
/**
- * Catch SecretPadException and build SecretPadResponse with errorCode and message
+ * Catch EasyPsiException and build EasyPsiResponse with errorCode and message
*
- * @param ex SecretPadException
- * @return SecretPadResponse with errorCode and message
+ * @param ex EasyPsiException
+ * @return EasyPsiResponse with errorCode and message
*/
- @ExceptionHandler(value = SecretpadException.class)
- public SecretPadResponse handlerSecretpadException(SecretpadException ex) {
+ @ExceptionHandler(value = EasyPsiException.class)
+ public EasyPsiResponse handlerEasyPsiException(EasyPsiException ex) {
ErrorCode errorCode = ex.getErrorCode();
String message = messageResolver.getMessage(errorCode, ex.getArgs());
LOGGER.error("find error: {}, message: {} ", ex.getErrorCode(), ex.getMessage());
- return new SecretPadResponse<>(new SecretPadResponse.SecretPadResponseStatus(errorCode.getCode(), message),
+ return new EasyPsiResponse<>(new EasyPsiResponse.EasyPsiResponseStatus(errorCode.getCode(), message),
null);
}
/**
- * Catch MethodArgumentNotValidException and build SecretPadResponse with validation error and message
+ * Catch MethodArgumentNotValidException and build EasyPsiResponse with validation error and message
*
* @param ex MethodArgumentNotValidException
- * @return SecretPadResponse with validation error and message
+ * @return EasyPsiResponse with validation error and message
*/
@ExceptionHandler(value = MethodArgumentNotValidException.class)
public Object handlerValidation(MethodArgumentNotValidException ex) {
@@ -86,31 +83,31 @@ public Object handlerValidation(MethodArgumentNotValidException ex) {
collect.add(defaultMessage);
}
LOGGER.error("handler argument check error: {}, cause: {}", ex.getMessage(), ex.getCause());
- return handlerSecretpadException(SecretpadException.of(SystemErrorCode.VALIDATION_ERROR, collect.get(0)));
+ return handlerEasyPsiException(EasyPsiException.of(SystemErrorCode.VALIDATION_ERROR, collect.get(0)));
}
/**
- * Catch Exception and build SecretPadResponse with unknown error and message
+ * Catch Exception and build EasyPsiResponse with unknown error and message
*
* @param ex Exception
- * @return SecretPadResponse with unknown error and message
+ * @return EasyPsiResponse with unknown error and message
*/
@ExceptionHandler(value = Exception.class)
public Object handleException(Exception ex) {
LOGGER.error("handler error: {}, cause: {}, ex: {}", ex.getMessage(), ex.getCause(), ex);
- return handlerSecretpadException(SecretpadException.of(SystemErrorCode.UNKNOWN_ERROR, ex.getMessage()));
+ return handlerEasyPsiException(EasyPsiException.of(SystemErrorCode.UNKNOWN_ERROR, ex.getMessage()));
}
/**
- * Catch FileSizeLimitExceededException and build SecretPadResponse with unknown error and message
+ * Catch FileSizeLimitExceededException and build EasyPsiResponse with unknown error and message
*
* @param ex FileSizeLimitExceededException
- * @return SecretPadResponse with unknown error and message
+ * @return EasyPsiResponse with unknown error and message
*/
@ExceptionHandler(value = FileSizeLimitExceededException.class)
public Object handleFileSizeException(Exception ex) {
LOGGER.error("handler error: {}, cause: {}, ex: {}", ex.getMessage(), ex.getCause(), ex);
- return handlerSecretpadException(SecretpadException.of(SystemErrorCode.UNKNOWN_ERROR, ex.getMessage()));
+ return handlerEasyPsiException(EasyPsiException.of(SystemErrorCode.UNKNOWN_ERROR, ex.getMessage()));
}
/**
@@ -122,16 +119,27 @@ public Object handleFileSizeException(Exception ex) {
@ExceptionHandler(value = HttpRequestMethodNotSupportedException.class)
public void handlerMethodNotSupportedException(HttpServletResponse response, HttpServletRequest request) throws IOException {
- Map errorMap = Maps.newLinkedHashMap();
- errorMap.put("timestamp", System.currentTimeMillis());
- errorMap.put("status", HttpServletResponse.SC_NOT_FOUND);
- errorMap.put("error", "Not Found");
- errorMap.put("path", request.getRequestURI());
- response.setCharacterEncoding(CharEncoding.UTF_8);
- response.setContentType(MediaType.APPLICATION_JSON_UTF8_VALUE);
- ObjectMapper objectMapper = new ObjectMapper();
- String json = objectMapper.writeValueAsString(errorMap);
- response.getWriter().write(json);
+ ResponseUtils.buildResponse_404(response, request);
+ }
+
+ /**
+ * Catch handlerNoHandlerFoundException and build response
+ *
+ * @param response
+ * @param request
+ */
+
+ @ExceptionHandler(value = NoHandlerFoundException.class)
+ public void handlerNoHandlerFoundException(HttpServletResponse response, HttpServletRequest request) throws IOException {
+ ResponseUtils.buildResponse_404(response, request);
+ }
+
+ /**
+ * capture additional exception information
+ */
+ @ExceptionHandler(value = DataAccessResourceFailureException.class)
+ public void DataAccessResourceFailureException() {
+ LOGGER.error("capture additional exception information: {}", DataAccessResourceFailureException.class);
}
}
diff --git a/secretpad-web/src/main/java/org/secretflow/secretpad/web/filter/AddResponseHeaderFilter.java b/easypsi-web/src/main/java/org/secretflow/easypsi/web/filter/AddResponseHeaderFilter.java
similarity index 87%
rename from secretpad-web/src/main/java/org/secretflow/secretpad/web/filter/AddResponseHeaderFilter.java
rename to easypsi-web/src/main/java/org/secretflow/easypsi/web/filter/AddResponseHeaderFilter.java
index 457a6cf..85a58eb 100644
--- a/secretpad-web/src/main/java/org/secretflow/secretpad/web/filter/AddResponseHeaderFilter.java
+++ b/easypsi-web/src/main/java/org/secretflow/easypsi/web/filter/AddResponseHeaderFilter.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.web.filter;
+package org.secretflow.easypsi.web.filter;
import jakarta.servlet.FilterChain;
import jakarta.servlet.ServletException;
@@ -39,7 +39,7 @@
@Component
public class AddResponseHeaderFilter extends OncePerRequestFilter {
@Autowired
- private SecretPadResponse secretPadResponse;
+ private EasyPsiResponse easyPsiResponse;
/**
* Filter response header via map of extra headers
@@ -52,7 +52,7 @@ public class AddResponseHeaderFilter extends OncePerRequestFilter {
*/
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
- Map extraResponseHeaders = secretPadResponse.getExtraHeaders();
+ Map extraResponseHeaders = easyPsiResponse.getExtraHeaders();
if (!CollectionUtils.isEmpty(extraResponseHeaders)) {
extraResponseHeaders.forEach((key, value) -> {
response.addHeader(key, value);
@@ -63,8 +63,8 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse
@Data
@Component
- @ConfigurationProperties(prefix = "secretpad.response")
- public static class SecretPadResponse {
+ @ConfigurationProperties(prefix = "easypsi.response")
+ public static class EasyPsiResponse {
private Map extraHeaders;
}
}
diff --git a/secretpad-web/src/main/java/org/secretflow/secretpad/web/init/DataInitializer.java b/easypsi-web/src/main/java/org/secretflow/easypsi/web/init/DataInitializer.java
similarity index 52%
rename from secretpad-web/src/main/java/org/secretflow/secretpad/web/init/DataInitializer.java
rename to easypsi-web/src/main/java/org/secretflow/easypsi/web/init/DataInitializer.java
index 3affc63..49b2bf9 100644
--- a/secretpad-web/src/main/java/org/secretflow/secretpad/web/init/DataInitializer.java
+++ b/easypsi-web/src/main/java/org/secretflow/easypsi/web/init/DataInitializer.java
@@ -1,6 +1,22 @@
-package org.secretflow.secretpad.web.init;
+/*
+ * Copyright 2023 Ant Group Co., Ltd.
+ *
+ * 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.
+ */
+
+package org.secretflow.easypsi.web.init;
-import org.secretflow.secretpad.service.NodeService;
+import org.secretflow.easypsi.service.NodeService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/secretpad-web/src/main/java/org/secretflow/secretpad/web/interceptor/InnerPortPathConfig.java b/easypsi-web/src/main/java/org/secretflow/easypsi/web/interceptor/InnerPortPathConfig.java
similarity index 95%
rename from secretpad-web/src/main/java/org/secretflow/secretpad/web/interceptor/InnerPortPathConfig.java
rename to easypsi-web/src/main/java/org/secretflow/easypsi/web/interceptor/InnerPortPathConfig.java
index 136c9c6..bf3c2df 100644
--- a/secretpad-web/src/main/java/org/secretflow/secretpad/web/interceptor/InnerPortPathConfig.java
+++ b/easypsi-web/src/main/java/org/secretflow/easypsi/web/interceptor/InnerPortPathConfig.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.web.interceptor;
+package org.secretflow.easypsi.web.interceptor;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
diff --git a/secretpad-web/src/main/java/org/secretflow/secretpad/web/interceptor/LoginInterceptor.java b/easypsi-web/src/main/java/org/secretflow/easypsi/web/interceptor/LoginInterceptor.java
similarity index 80%
rename from secretpad-web/src/main/java/org/secretflow/secretpad/web/interceptor/LoginInterceptor.java
rename to easypsi-web/src/main/java/org/secretflow/easypsi/web/interceptor/LoginInterceptor.java
index 6a75263..2da97d8 100644
--- a/secretpad-web/src/main/java/org/secretflow/secretpad/web/interceptor/LoginInterceptor.java
+++ b/easypsi-web/src/main/java/org/secretflow/easypsi/web/interceptor/LoginInterceptor.java
@@ -14,22 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.web.interceptor;
-
-import org.secretflow.secretpad.common.constant.PermissionUserType;
-import org.secretflow.secretpad.common.constant.PlatformType;
-import org.secretflow.secretpad.common.constant.ResourceType;
-import org.secretflow.secretpad.common.constant.UserOwnerType;
-import org.secretflow.secretpad.common.dto.UserContextDTO;
-import org.secretflow.secretpad.common.errorcode.AuthErrorCode;
-import org.secretflow.secretpad.common.exception.SecretpadException;
-import org.secretflow.secretpad.common.util.UserContext;
-import org.secretflow.secretpad.persistence.entity.TokensDO;
-import org.secretflow.secretpad.persistence.repository.UserTokensRepository;
-import org.secretflow.secretpad.service.EnvService;
-import org.secretflow.secretpad.service.SysResourcesBizService;
-import org.secretflow.secretpad.web.constant.AuthConstants;
-import org.secretflow.secretpad.web.util.AuthUtils;
+package org.secretflow.easypsi.web.interceptor;
import jakarta.annotation.Resource;
import jakarta.servlet.http.Cookie;
@@ -38,6 +23,22 @@
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
+import org.secretflow.easypsi.common.constant.PermissionUserType;
+import org.secretflow.easypsi.common.constant.PlatformType;
+import org.secretflow.easypsi.common.constant.ResourceType;
+import org.secretflow.easypsi.common.constant.UserOwnerType;
+import org.secretflow.easypsi.common.dto.UserContextDTO;
+import org.secretflow.easypsi.common.errorcode.AuthErrorCode;
+import org.secretflow.easypsi.common.exception.EasyPsiException;
+import org.secretflow.easypsi.common.util.UserContext;
+import org.secretflow.easypsi.persistence.entity.AccountsDO;
+import org.secretflow.easypsi.persistence.entity.TokensDO;
+import org.secretflow.easypsi.persistence.repository.UserTokensRepository;
+import org.secretflow.easypsi.service.EnvService;
+import org.secretflow.easypsi.service.SysResourcesBizService;
+import org.secretflow.easypsi.service.UserService;
+import org.secretflow.easypsi.web.constant.AuthConstants;
+import org.secretflow.easypsi.web.util.AuthUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpMethod;
@@ -47,6 +48,7 @@
import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
+import java.util.List;
import java.util.Optional;
import java.util.Set;
@@ -72,7 +74,9 @@ public class LoginInterceptor implements HandlerInterceptor {
private final SysResourcesBizService sysResourcesBizService;
- @Value("${secretpad.auth.enabled:true}")
+ private final UserService userService;
+
+ @Value("${easypsi.auth.enabled:true}")
private boolean enable;
@Value("${server.http-port-inner}")
@@ -83,10 +87,11 @@ public class LoginInterceptor implements HandlerInterceptor {
@Autowired
public LoginInterceptor(UserTokensRepository userTokensRepository, EnvService envService,
- SysResourcesBizService sysResourcesBizService) {
+ SysResourcesBizService sysResourcesBizService, UserService userService) {
this.userTokensRepository = userTokensRepository;
this.envService = envService;
this.sysResourcesBizService = sysResourcesBizService;
+ this.userService = userService;
}
private UserContextDTO createTmpUserForPlaformType(PlatformType platformType) {
@@ -166,7 +171,7 @@ private void csrfDefense(HttpServletResponse response) {
private void processByNodeRpcRequest(HttpServletRequest request) {
String sourceNodeId = request.getHeader("kuscia-origin-source");
if (StringUtils.isBlank(sourceNodeId)) {
- throw SecretpadException.of(AuthErrorCode.AUTH_FAILED, "Cannot find node id in header for rpc.");
+ throw EasyPsiException.of(AuthErrorCode.AUTH_FAILED, "Cannot find node id in header for rpc.");
}
UserContextDTO virtualUser = new UserContextDTO();
virtualUser.setVirtualUserForNode(true);
@@ -193,13 +198,17 @@ private void processByUserRequest(HttpServletRequest request) throws HttpRequest
String token = AuthUtils.findTokenInHeader(request);
Optional tokensDO = userTokensRepository.findByToken(token);
if (tokensDO.isEmpty()) {
- throw SecretpadException.of(AuthErrorCode.AUTH_FAILED, "Cannot find token in db, user not login in.");
+ throw EasyPsiException.of(AuthErrorCode.AUTH_FAILED, "Cannot find token in db, user not login in.");
+ }
+ AccountsDO userByName = userService.getUserByName(tokensDO.get().getName());
+ if (userByName.getInitial() && !accessibleUrlNotInitialized(request.getServletPath())) {
+ throw EasyPsiException.of(AuthErrorCode.PASSWORD_NOT_INITIALIZED);
}
LocalDateTime now = LocalDateTime.now();
LocalDateTime gmtToken = tokensDO.get().getGmtToken();
long until = gmtToken.until(now, ChronoUnit.SECONDS);
if (until > EXPIRE) {
- throw SecretpadException.of(AuthErrorCode.AUTH_FAILED, "The login session is expire, please login again.");
+ throw EasyPsiException.of(AuthErrorCode.AUTH_FAILED, "The login session is expire, please login again.");
}
userTokensRepository.saveAndFlush(
TokensDO.builder()
@@ -212,7 +221,7 @@ private void processByUserRequest(HttpServletRequest request) throws HttpRequest
String sessionData = tokensDO.get().getSessionData();
if (StringUtils.isBlank(sessionData)) {
- throw SecretpadException.of(AuthErrorCode.AUTH_FAILED, "The login session is null, please login again.");
+ throw EasyPsiException.of(AuthErrorCode.AUTH_FAILED, "The login session is null, please login again.");
}
UserContextDTO userContextDTO = UserContextDTO.fromJson(sessionData);
UserContext.setBaseUser(userContextDTO);
@@ -243,4 +252,8 @@ private boolean ignoreCheck(HttpServletRequest request) {
return request.getMethod().equalsIgnoreCase("GET") && request.getServletPath().equals("/api/v1alpha1/project/job/result/download");
}
+ private boolean accessibleUrlNotInitialized(String url) {
+ return List.of("/api/v1alpha1/user/updatePwd", "/api/get").contains(url);
+ }
+
}
diff --git a/secretpad-web/src/main/java/org/secretflow/secretpad/web/listener/EdgeJobSyncListener.java b/easypsi-web/src/main/java/org/secretflow/easypsi/web/listener/EdgeJobSyncListener.java
similarity index 74%
rename from secretpad-web/src/main/java/org/secretflow/secretpad/web/listener/EdgeJobSyncListener.java
rename to easypsi-web/src/main/java/org/secretflow/easypsi/web/listener/EdgeJobSyncListener.java
index cc2cd8b..6450688 100644
--- a/secretpad-web/src/main/java/org/secretflow/secretpad/web/listener/EdgeJobSyncListener.java
+++ b/easypsi-web/src/main/java/org/secretflow/easypsi/web/listener/EdgeJobSyncListener.java
@@ -1,15 +1,31 @@
-package org.secretflow.secretpad.web.listener;
-
-import org.secretflow.secretpad.common.constant.DomainRouterConstants;
-import org.secretflow.secretpad.common.util.JsonUtils;
-import org.secretflow.secretpad.common.util.RestTemplateUtil;
-import org.secretflow.secretpad.persistence.entity.NodeRouteDO;
-import org.secretflow.secretpad.persistence.repository.NodeRouteRepository;
-import org.secretflow.secretpad.service.EnvService;
-import org.secretflow.secretpad.service.NodeRouterService;
-import org.secretflow.secretpad.service.ProjectService;
-import org.secretflow.secretpad.service.model.common.SecretPadResponse;
-import org.secretflow.secretpad.service.model.project.ProjectJobVO;
+/*
+ * Copyright 2023 Ant Group Co., Ltd.
+ *
+ * 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.
+ */
+
+package org.secretflow.easypsi.web.listener;
+
+import org.secretflow.easypsi.common.constant.DomainRouterConstants;
+import org.secretflow.easypsi.common.util.JsonUtils;
+import org.secretflow.easypsi.common.util.RestTemplateUtil;
+import org.secretflow.easypsi.persistence.entity.NodeRouteDO;
+import org.secretflow.easypsi.persistence.repository.NodeRouteRepository;
+import org.secretflow.easypsi.service.EnvService;
+import org.secretflow.easypsi.service.NodeRouterService;
+import org.secretflow.easypsi.service.ProjectService;
+import org.secretflow.easypsi.service.model.common.EasyPsiResponse;
+import org.secretflow.easypsi.service.model.project.ProjectJobVO;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
@@ -61,7 +77,7 @@ public class EdgeJobSyncListener {
/**
* "http://localhost:8080/api/v1alpha1/user/node";
*/
- @Value("${secretpad.gateway}")
+ @Value("${easypsi.gateway}")
private String gateway;
@Scheduled(initialDelay = 5000, fixedDelay = 5000)
@@ -91,8 +107,8 @@ public void onSyncEdgeJobs() {
if (StringUtils.isBlank(nodeRouteStatus) || !StringUtils.equals(nodeRouteStatus, DomainRouterConstants.DomainRouterStatusEnum.Succeeded.name())) {
return;
}
- SecretPadResponse secretPadResponse = RestTemplateUtil.sendPostJson(queryEdgeProjectUrl() + "/edge/job/list",
- ImmutableMap.of(), buildHeader(requestNodeId), SecretPadResponse.class);
+ EasyPsiResponse secretPadResponse = RestTemplateUtil.sendPostJson(queryEdgeProjectUrl() + "/edge/job/list",
+ ImmutableMap.of(), buildHeader(requestNodeId), EasyPsiResponse.class);
Object responseData = secretPadResponse.getData();
// project job list
List projectJobVOList = JsonUtils.toJavaList(JsonUtils.toJSONString(responseData), ProjectJobVO.class);
@@ -117,4 +133,4 @@ private ImmutableMap buildHeader(String requestId) {
// TODO 调试使用 "Host", centerUserNodeUrl(),
// return ImmutableMap.of("Content-Type", "application/json", "kuscia-origin-source", requestId);
}
-}
+}
\ No newline at end of file
diff --git a/secretpad-web/src/main/java/org/secretflow/secretpad/web/util/AuthUtils.java b/easypsi-web/src/main/java/org/secretflow/easypsi/web/util/AuthUtils.java
similarity index 76%
rename from secretpad-web/src/main/java/org/secretflow/secretpad/web/util/AuthUtils.java
rename to easypsi-web/src/main/java/org/secretflow/easypsi/web/util/AuthUtils.java
index 7fa5450..7b7e66a 100644
--- a/secretpad-web/src/main/java/org/secretflow/secretpad/web/util/AuthUtils.java
+++ b/easypsi-web/src/main/java/org/secretflow/easypsi/web/util/AuthUtils.java
@@ -14,11 +14,11 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.web.util;
+package org.secretflow.easypsi.web.util;
-import org.secretflow.secretpad.common.errorcode.AuthErrorCode;
-import org.secretflow.secretpad.common.exception.SecretpadException;
-import org.secretflow.secretpad.web.constant.AuthConstants;
+import org.secretflow.easypsi.common.errorcode.AuthErrorCode;
+import org.secretflow.easypsi.common.exception.EasyPsiException;
+import org.secretflow.easypsi.web.constant.AuthConstants;
import jakarta.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.StringUtils;
@@ -40,7 +40,7 @@ public class AuthUtils {
public static String findTokenInHeader(HttpServletRequest request) {
String token = request.getHeader(AuthConstants.TOKEN_NAME);
if (StringUtils.isEmpty(token)) {
- throw SecretpadException.of(AuthErrorCode.AUTH_FAILED, "The request header does not contain header!");
+ throw EasyPsiException.of(AuthErrorCode.AUTH_FAILED, "The request header does not contain header!");
}
return token;
}
diff --git a/easypsi-web/src/main/java/org/secretflow/easypsi/web/util/ResponseUtils.java b/easypsi-web/src/main/java/org/secretflow/easypsi/web/util/ResponseUtils.java
new file mode 100644
index 0000000..bd37a37
--- /dev/null
+++ b/easypsi-web/src/main/java/org/secretflow/easypsi/web/util/ResponseUtils.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2023 Ant Group Co., Ltd.
+ *
+ * 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.
+ */
+
+package org.secretflow.easypsi.web.util;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.collect.Maps;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+import org.apache.commons.codec.CharEncoding;
+import org.springframework.http.MediaType;
+
+import java.io.IOException;
+import java.util.Map;
+
+/**
+ * Response utils
+ *
+ * @author lihaixin
+ * @date 2024/02/01
+ */
+public class ResponseUtils {
+
+ /**
+ * Builds 404 response.
+ *
+ * @param response
+ * @param request
+ */
+
+ public static void buildResponse_404(HttpServletResponse response, HttpServletRequest request) throws IOException {
+ Map errorMap = Maps.newLinkedHashMap();
+ errorMap.put("timestamp", System.currentTimeMillis());
+ errorMap.put("status", HttpServletResponse.SC_NOT_FOUND);
+ errorMap.put("error", "Not Found");
+ errorMap.put("path", request.getRequestURI());
+ response.setCharacterEncoding(CharEncoding.UTF_8);
+ response.setContentType(MediaType.APPLICATION_JSON_UTF8_VALUE);
+ ObjectMapper objectMapper = new ObjectMapper();
+ String json = objectMapper.writeValueAsString(errorMap);
+ response.getWriter().write(json);
+ }
+}
\ No newline at end of file
diff --git a/secretpad-web/src/main/resources/logback-spring.xml b/easypsi-web/src/main/resources/logback-spring.xml
similarity index 77%
rename from secretpad-web/src/main/resources/logback-spring.xml
rename to easypsi-web/src/main/resources/logback-spring.xml
index 03d1eed..d5df901 100644
--- a/secretpad-web/src/main/resources/logback-spring.xml
+++ b/easypsi-web/src/main/resources/logback-spring.xml
@@ -2,7 +2,6 @@
-
@@ -12,11 +11,9 @@
- ${LOG_PATH}/secretpad.log -->
+ ${LOG_PATH}/easypsi.log -->
-
- ${LOG_PATH}/secretpad-%d{yyyy-MM-dd}.%i.log
-
+ ${LOG_PATH}/easypsi-%d{yyyy-MM-dd}.%i.log
365
100MB
diff --git a/secretpad-web/src/main/resources/templates/index.html b/easypsi-web/src/main/resources/templates/index.html
similarity index 96%
rename from secretpad-web/src/main/resources/templates/index.html
rename to easypsi-web/src/main/resources/templates/index.html
index 05f454d..bd3da90 100644
--- a/secretpad-web/src/main/resources/templates/index.html
+++ b/easypsi-web/src/main/resources/templates/index.html
@@ -21,6 +21,7 @@
SecretFlow Easy PSI
+
diff --git a/secretpad-web/src/test/java/org/secretflow/secretpad/web/controller/AuthControllerTest.java b/easypsi-web/src/test/java/org/secretflow/easypsi/web/controller/AuthControllerTest.java
similarity index 51%
rename from secretpad-web/src/test/java/org/secretflow/secretpad/web/controller/AuthControllerTest.java
rename to easypsi-web/src/test/java/org/secretflow/easypsi/web/controller/AuthControllerTest.java
index 9f60680..ae99f2c 100644
--- a/secretpad-web/src/test/java/org/secretflow/secretpad/web/controller/AuthControllerTest.java
+++ b/easypsi-web/src/test/java/org/secretflow/easypsi/web/controller/AuthControllerTest.java
@@ -15,27 +15,33 @@
*
*/
-package org.secretflow.secretpad.web.controller;
-
-import org.secretflow.secretpad.common.util.JsonUtils;
-import org.secretflow.secretpad.persistence.entity.AccountsDO;
-import org.secretflow.secretpad.persistence.entity.ProjectJobDO;
-import org.secretflow.secretpad.persistence.repository.ProjectJobRepository;
-import org.secretflow.secretpad.persistence.repository.UserAccountsRepository;
-import org.secretflow.secretpad.persistence.repository.UserTokensRepository;
-import org.secretflow.secretpad.service.model.auth.LoginRequest;
-import org.secretflow.secretpad.web.constant.AuthConstants;
-import org.secretflow.secretpad.web.utils.FakerUtils;
+package org.secretflow.easypsi.web.controller;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
+import org.secretflow.easypsi.common.dto.UserContextDTO;
+import org.secretflow.easypsi.common.util.JsonUtils;
+import org.secretflow.easypsi.common.util.RsaUtils;
+import org.secretflow.easypsi.common.util.Sha256Utils;
+import org.secretflow.easypsi.common.util.UserContext;
+import org.secretflow.easypsi.persistence.entity.AccountsDO;
+import org.secretflow.easypsi.persistence.entity.ProjectJobDO;
+import org.secretflow.easypsi.persistence.entity.RsaEncryptionKeyDO;
+import org.secretflow.easypsi.persistence.repository.ProjectJobRepository;
+import org.secretflow.easypsi.persistence.repository.UserAccountsRepository;
+import org.secretflow.easypsi.persistence.repository.UserTokensRepository;
+import org.secretflow.easypsi.service.RsaEncryptionKeyService;
+import org.secretflow.easypsi.service.model.auth.LoginRequest;
+import org.secretflow.easypsi.web.constant.AuthConstants;
+import org.secretflow.easypsi.web.utils.FakerUtils;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
import java.util.Optional;
import static org.mockito.Mockito.doNothing;
@@ -59,12 +65,29 @@ class AuthControllerTest extends ControllerTest {
@MockBean
private ProjectJobRepository projectJobRepository;
+ @MockBean
+ private RsaEncryptionKeyService rsaEncryptionKeyService;
+
+
@Test
void login() throws Exception {
assertResponse(() -> {
- LoginRequest loginRequest = FakerUtils.fake(LoginRequest.class);
+ Map keyMap = RsaUtils.generateRSAKeys();
+ String rsaPublicKey = keyMap.get(RsaUtils.PUBLIC_KEY_NAME);
+ String rsaPrivateKey = keyMap.get(RsaUtils.PRIVATE_KEY_NAME);
+ String passwordHash = Sha256Utils.hash("admin");
+ LoginRequest loginRequest = new LoginRequest();
+ loginRequest.setName("admin");
+ //rsa password
+ loginRequest.setPasswordHash(RsaUtils.encrypt(passwordHash, rsaPublicKey));
+ loginRequest.setPublicKey(rsaPublicKey);
+ RsaEncryptionKeyDO rsaEncryptionKeyDO = new RsaEncryptionKeyDO();
+ rsaEncryptionKeyDO.setPublicKey(rsaPublicKey);
+ rsaEncryptionKeyDO.setPrivateKey(rsaPrivateKey);
AccountsDO accountsDO = FakerUtils.fake(AccountsDO.class);
- accountsDO.setPasswordHash(loginRequest.getPasswordHash());
+ accountsDO.setName(loginRequest.getName());
+ accountsDO.setPasswordHash(passwordHash);
+ Mockito.when(rsaEncryptionKeyService.findByPublicKey(loginRequest.getPublicKey())).thenReturn(rsaEncryptionKeyDO);
when(userAccountsRepository.findByName(loginRequest.getName())).thenReturn(Optional.of(accountsDO));
Mockito.when(projectJobRepository.findByNodeId(Mockito.anyString())).thenReturn(buildProjectJobDOs());
return MockMvcRequestBuilders.post(getMappingUrl(AuthController.class, "login", HttpServletResponse.class, LoginRequest.class))
@@ -84,7 +107,16 @@ void logout() throws Exception {
assertResponse(() -> {
doNothing().when(userTokensRepository).deleteByNameAndToken(Mockito.anyString(), Mockito.anyString());
return MockMvcRequestBuilders.post(getMappingUrl(AuthController.class, "logout", HttpServletRequest.class))
- .header(AuthConstants.TOKEN_NAME,"tokens").content(JsonUtils.toJSONString("token"));
+ .header(AuthConstants.TOKEN_NAME, "tokens").content(JsonUtils.toJSONString("token"));
+ });
+ }
+
+ @Test
+ void get() throws Exception {
+ assertResponse(() -> {
+ UserContext.setBaseUser(FakerUtils.fake(UserContextDTO.class));
+ UserContext.getUser();
+ return MockMvcRequestBuilders.post(getMappingUrl(AuthController.class, "get"));
});
}
}
\ No newline at end of file
diff --git a/secretpad-web/src/test/java/org/secretflow/secretpad/web/controller/ControllerTest.java b/easypsi-web/src/test/java/org/secretflow/easypsi/web/controller/ControllerTest.java
similarity index 84%
rename from secretpad-web/src/test/java/org/secretflow/secretpad/web/controller/ControllerTest.java
rename to easypsi-web/src/test/java/org/secretflow/easypsi/web/controller/ControllerTest.java
index c588a56..d934248 100644
--- a/secretpad-web/src/test/java/org/secretflow/secretpad/web/controller/ControllerTest.java
+++ b/easypsi-web/src/test/java/org/secretflow/easypsi/web/controller/ControllerTest.java
@@ -14,16 +14,16 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.web.controller;
+package org.secretflow.easypsi.web.controller;
-import org.secretflow.secretpad.common.errorcode.ErrorCode;
-import org.secretflow.secretpad.common.util.JsonUtils;
-import org.secretflow.secretpad.service.model.common.SecretPadResponse;
-import org.secretflow.secretpad.web.SecretPadApplication;
+import org.secretflow.easypsi.common.errorcode.ErrorCode;
+import org.secretflow.easypsi.common.util.JsonUtils;
import org.apache.commons.lang3.StringUtils;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
+import org.secretflow.easypsi.service.model.common.EasyPsiResponse;
+import org.secretflow.easypsi.web.EasyPsiApplication;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -58,7 +58,7 @@
@WebAppConfiguration
@ActiveProfiles(value = "test")
@AutoConfigureMockMvc
-@SpringBootTest(classes = SecretPadApplication.class)
+@SpringBootTest(classes = EasyPsiApplication.class)
public class ControllerTest {
private final static Logger LOGGER = LoggerFactory.getLogger(ControllerTest.class);
@Autowired
@@ -80,9 +80,9 @@ void assertResponse(MvcRequestFunction f) throws
.andExpect(MockMvcResultMatchers.status().isOk())
.andReturn()
.getResponse();
- SecretPadResponse secretPadResponse = JsonUtils.toJavaObject(response.getContentAsString(), SecretPadResponse.class);
- Assertions.assertEquals(secretPadResponse.getStatus().getCode(), 0);
- Assertions.assertNotNull(secretPadResponse.getData());
+ EasyPsiResponse easyPsiResponse = JsonUtils.toJavaObject(response.getContentAsString(), EasyPsiResponse.class);
+ Assertions.assertEquals(easyPsiResponse.getStatus().getCode(), 0);
+ Assertions.assertNotNull(easyPsiResponse.getData());
}
void assertResponseWithEmptyData(MvcRequestFunction f) throws Exception {
@@ -92,9 +92,9 @@ void assertResponseWithEmptyData(MvcRequestFunction f, ErrorCode errorCode) throws Exception {
@@ -104,8 +104,8 @@ void assertErrorCode(MvcRequestFunction f, ErrorC
.andExpect(MockMvcResultMatchers.status().isOk())
.andReturn()
.getResponse();
- SecretPadResponse secretPadResponse = JsonUtils.toJavaObject(response.getContentAsString(), SecretPadResponse.class);
- Assertions.assertEquals(secretPadResponse.getStatus().getCode(), errorCode.getCode());
+ EasyPsiResponse easyPsiResponse = JsonUtils.toJavaObject(response.getContentAsString(), EasyPsiResponse.class);
+ Assertions.assertEquals(easyPsiResponse.getStatus().getCode(), errorCode.getCode());
}
void assertResponseWithEmptyContent(MvcRequestFunction f) throws Exception {
@@ -135,9 +135,9 @@ void assertMultipartResponse(MvcRequestFunction f
.andExpect(MockMvcResultMatchers.status().isOk())
.andReturn()
.getResponse();
- SecretPadResponse secretPadResponse = JsonUtils.toJavaObject(response.getContentAsString(), SecretPadResponse.class);
- Assertions.assertEquals(secretPadResponse.getStatus().getCode(), 0);
- Assertions.assertNotNull(secretPadResponse.getData());
+ EasyPsiResponse easyPsiResponse = JsonUtils.toJavaObject(response.getContentAsString(), EasyPsiResponse.class);
+ Assertions.assertEquals(easyPsiResponse.getStatus().getCode(), 0);
+ Assertions.assertNotNull(easyPsiResponse.getData());
}
String getMappingUrl(Class> clazz, String methodName, @Nullable Class>... paramTypes) {
diff --git a/secretpad-web/src/test/java/org/secretflow/secretpad/web/controller/DataControllerTest.java b/easypsi-web/src/test/java/org/secretflow/easypsi/web/controller/DataControllerTest.java
similarity index 60%
rename from secretpad-web/src/test/java/org/secretflow/secretpad/web/controller/DataControllerTest.java
rename to easypsi-web/src/test/java/org/secretflow/easypsi/web/controller/DataControllerTest.java
index fe3d2a0..3bdaabf 100644
--- a/secretpad-web/src/test/java/org/secretflow/secretpad/web/controller/DataControllerTest.java
+++ b/easypsi-web/src/test/java/org/secretflow/easypsi/web/controller/DataControllerTest.java
@@ -14,27 +14,33 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.web.controller;
-
-import org.secretflow.secretpad.common.constant.DomainRouterConstants;
-import org.secretflow.secretpad.common.errorcode.KusciaGrpcErrorCode;
-import org.secretflow.secretpad.common.errorcode.NodeRouteErrorCode;
-import org.secretflow.secretpad.common.exception.SecretpadException;
-import org.secretflow.secretpad.common.util.JsonUtils;
-import org.secretflow.secretpad.manager.integration.node.NodeManager;
-import org.secretflow.secretpad.manager.integration.noderoute.NodeRouteManager;
-import org.secretflow.secretpad.service.model.data.GetDataTableInformatinoRequest;
-import org.secretflow.secretpad.web.utils.FakerUtils;
+package org.secretflow.easypsi.web.controller;
+import jakarta.servlet.http.HttpServletResponse;
+import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
+import org.secretflow.easypsi.common.constant.DomainRouterConstants;
+import org.secretflow.easypsi.common.dto.DownloadInfo;
+import org.secretflow.easypsi.common.errorcode.DataErrorCode;
+import org.secretflow.easypsi.common.errorcode.KusciaGrpcErrorCode;
+import org.secretflow.easypsi.common.errorcode.NodeRouteErrorCode;
+import org.secretflow.easypsi.common.exception.EasyPsiException;
+import org.secretflow.easypsi.common.util.JsonUtils;
+import org.secretflow.easypsi.manager.integration.data.DataManager;
+import org.secretflow.easypsi.manager.integration.node.NodeManager;
+import org.secretflow.easypsi.manager.integration.noderoute.NodeRouteManager;
+import org.secretflow.easypsi.service.model.data.GetDataTableInformatinoRequest;
+import org.secretflow.easypsi.web.utils.FakerUtils;
import org.secretflow.v1alpha1.common.Common;
import org.secretflow.v1alpha1.kusciaapi.Domain;
import org.secretflow.v1alpha1.kusciaapi.DomainRoute;
+import org.slf4j.Logger;
import org.springframework.boot.test.mock.mockito.MockBean;
+import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
-import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.*;
/**
* DataController test
@@ -50,6 +56,10 @@ class DataControllerTest extends ControllerTest {
@MockBean
private NodeRouteManager nodeRouteManager;
+ @MockBean
+ private DataManager dataManager;
+
+
@Test
void queryHostPath() throws Exception {
assertResponse(() -> MockMvcRequestBuilders.post(getMappingUrl(DataController.class, "queryHostPath")));
@@ -72,17 +82,18 @@ private DomainRoute.RouteStatus buildRouteStatus(Integer code) {
.setStatus(DomainRouterConstants.DomainRouterStatusEnum.Succeeded.name())
.build();
}
+
@Test
void queryDataTableInformationKusciaError() throws Exception {
assertErrorCode(() -> {
GetDataTableInformatinoRequest request = FakerUtils.fake(GetDataTableInformatinoRequest.class);
- Mockito.when(nodeManager.getNodeNotCheck(Mockito.anyString())).thenThrow(SecretpadException.of(KusciaGrpcErrorCode.KUSCIA_CPMMECT_ERROR));
- doNothing().when(nodeRouteManager).checkRouteNotExist(Mockito.anyString(),Mockito.anyString());
- Mockito.when(nodeRouteManager.getRouteStatus(Mockito.anyString(),Mockito.anyString())).thenReturn(buildRouteStatus(0));
+ Mockito.when(nodeManager.getNodeNotCheck(Mockito.anyString())).thenThrow(EasyPsiException.of(KusciaGrpcErrorCode.KUSCIA_CPMMECT_ERROR));
+ doNothing().when(nodeRouteManager).checkRouteNotExist(Mockito.anyString(), Mockito.anyString());
+ Mockito.when(nodeRouteManager.getRouteStatus(Mockito.anyString(), Mockito.anyString())).thenReturn(buildRouteStatus(0));
return MockMvcRequestBuilders.post(getMappingUrl(DataController.class, "queryDataTableInformation", GetDataTableInformatinoRequest.class)).
content(JsonUtils.toJSONString(request));
- }, KusciaGrpcErrorCode.KUSCIA_CPMMECT_ERROR);
+ }, DataErrorCode.FILE_NOT_EXISTS_ERROR);
}
@Test
@@ -90,11 +101,23 @@ void queryDataTableInformationNodeRouteError() throws Exception {
assertErrorCode(() -> {
GetDataTableInformatinoRequest request = FakerUtils.fake(GetDataTableInformatinoRequest.class);
Mockito.when(nodeManager.getNodeNotCheck(Mockito.anyString())).thenReturn(buildQueryDomainResponse(0));
- doNothing().when(nodeRouteManager).checkRouteNotExist(Mockito.anyString(),Mockito.anyString());
- Mockito.when(nodeRouteManager.getRouteStatus(Mockito.anyString(),Mockito.anyString())).thenThrow(SecretpadException.of(NodeRouteErrorCode.NODE_ROUTE_NOT_READY));
+ doNothing().when(nodeRouteManager).checkRouteNotExist(Mockito.anyString(), Mockito.anyString());
+ Mockito.when(nodeRouteManager.getRouteStatus(Mockito.anyString(), Mockito.anyString())).thenThrow(EasyPsiException.of(NodeRouteErrorCode.NODE_ROUTE_NOT_READY));
return MockMvcRequestBuilders.post(getMappingUrl(DataController.class, "queryDataTableInformation", GetDataTableInformatinoRequest.class)).
content(JsonUtils.toJSONString(request));
- }, NodeRouteErrorCode.NODE_ROUTE_NOT_READY);
+ }, DataErrorCode.FILE_NOT_EXISTS_ERROR);
+ }
+
+
+ @Test
+ public void testDownloadFileByStream() throws Exception {
+ HttpServletResponse mockResponse = mock(HttpServletResponse.class);
+ mockResponse.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
+ mockResponse.setHeader(eq("Content-Disposition"), anyString());
+ mockResponse.setContentLength(anyInt());
+ Logger mockLogger = mock(Logger.class);
+ DownloadInfo sampleDownloadInfo = DownloadInfo.builder().fileName("testFileName").filePath("/path/to/test/file").build();
+ Assertions.assertThrows(EasyPsiException.class, () -> DataController.downloadFileByStream(mockResponse, sampleDownloadInfo, mockLogger));
}
}
\ No newline at end of file
diff --git a/easypsi-web/src/test/java/org/secretflow/easypsi/web/controller/EncryptionControllerTest.java b/easypsi-web/src/test/java/org/secretflow/easypsi/web/controller/EncryptionControllerTest.java
new file mode 100644
index 0000000..05683a1
--- /dev/null
+++ b/easypsi-web/src/test/java/org/secretflow/easypsi/web/controller/EncryptionControllerTest.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2023 Ant Group Co., Ltd.
+ *
+ * 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.
+ *
+ */
+
+package org.secretflow.easypsi.web.controller;
+
+import org.junit.jupiter.api.Test;
+import org.mockito.Mockito;
+import org.secretflow.easypsi.persistence.entity.RsaEncryptionKeyDO;
+import org.secretflow.easypsi.service.RsaEncryptionKeyService;
+import org.springframework.boot.test.mock.mockito.MockBean;
+import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
+
+import java.util.Optional;
+
+/**
+ * EncryptionControllerTest
+ *
+ * @author lihaixin
+ * @date 2024/02/23
+ */
+class EncryptionControllerTest extends ControllerTest {
+
+ @MockBean
+ private RsaEncryptionKeyService rsaEncryptionKeyService;
+
+
+ @Test
+ void getRandomKey() throws Exception {
+ assertResponse(() -> {
+ Mockito.when(rsaEncryptionKeyService.findByPublicKey(Mockito.any())).thenReturn(buildReturn().get());
+ return MockMvcRequestBuilders.get(getMappingUrl(EncryptionController.class, "getRandomKey"));
+ });
+
+ }
+
+
+ private Optional buildReturn() {
+ return Optional.of(RsaEncryptionKeyDO.builder().privateKey(Mockito.anyString()).publicKey("testKey").build());
+ }
+
+}
\ No newline at end of file
diff --git a/easypsi-web/src/test/java/org/secretflow/easypsi/web/controller/FabricLogControllerTest.java b/easypsi-web/src/test/java/org/secretflow/easypsi/web/controller/FabricLogControllerTest.java
new file mode 100644
index 0000000..cedf2bf
--- /dev/null
+++ b/easypsi-web/src/test/java/org/secretflow/easypsi/web/controller/FabricLogControllerTest.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2023 Ant Group Co., Ltd.
+ *
+ * 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.
+ */
+
+package org.secretflow.easypsi.web.controller;
+
+import org.junit.jupiter.api.Test;
+import org.junit.platform.commons.util.StringUtils;
+import org.mockito.Mockito;
+import org.secretflow.easypsi.common.errorcode.NodeErrorCode;
+import org.secretflow.easypsi.common.errorcode.SystemErrorCode;
+import org.secretflow.easypsi.common.exception.EasyPsiException;
+import org.secretflow.easypsi.common.util.JsonUtils;
+import org.secretflow.easypsi.common.util.Sha256Utils;
+import org.secretflow.easypsi.manager.integration.fabric.FabricManager;
+import org.secretflow.easypsi.persistence.entity.FabricLogDO;
+import org.secretflow.easypsi.persistence.entity.RsaEncryptionKeyDO;
+import org.secretflow.easypsi.persistence.repository.FabricLogRepository;
+import org.secretflow.easypsi.service.model.auth.UserUpdatePwdRequest;
+import org.secretflow.easypsi.service.model.fabric.FabricLogRequest;
+import org.springframework.boot.test.mock.mockito.MockBean;
+import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
+
+import java.util.Optional;
+
+/**
+ * FabricLogControllerTest
+ *
+ * @author lihaixin
+ * @date 2024/02/23
+ */
+public class FabricLogControllerTest extends ControllerTest {
+
+
+ @MockBean
+ private FabricLogRepository fabricLogRepository;
+
+ @MockBean
+ private FabricManager fabricManager;
+
+
+ @Test
+ void queryFabricLog() throws Exception {
+ assertResponse(() -> {
+ FabricLogRequest fabricLogRequest = new FabricLogRequest();
+ fabricLogRequest.setLogHash(Sha256Utils.hash("testHash"));
+ fabricLogRequest.setLogPath("/logs/test.log");
+ Mockito.when(org.apache.commons.lang3.StringUtils.isBlank(fabricLogRequest.getLogHash())
+ && org.apache.commons.lang3.StringUtils.isBlank(fabricLogRequest.getLogPath())).
+ thenThrow(EasyPsiException.of(SystemErrorCode.VALIDATION_ERROR));
+ Mockito.when(fabricLogRepository.findByLogPath(fabricLogRequest.getLogPath())).thenReturn(buildReturn().get());
+ Mockito.when(fabricManager.evaluateTransactionByAssetId(fabricLogRequest.getLogHash())).thenReturn("success");
+ return MockMvcRequestBuilders.post(getMappingUrl(FabricLogController.class, "queryFabricLog", FabricLogRequest.class))
+ .content(JsonUtils.toJSONString(fabricLogRequest));
+ });
+ }
+
+ private Optional buildReturn() {
+ return Optional.of(FabricLogDO.builder().logHash("testHash").logPath("/logs/test.log").chainCodeName("alice")
+ .build());
+ }
+}
\ No newline at end of file
diff --git a/easypsi-web/src/test/java/org/secretflow/easypsi/web/controller/IndexControllerTest.java b/easypsi-web/src/test/java/org/secretflow/easypsi/web/controller/IndexControllerTest.java
new file mode 100644
index 0000000..dd66755
--- /dev/null
+++ b/easypsi-web/src/test/java/org/secretflow/easypsi/web/controller/IndexControllerTest.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2023 Ant Group Co., Ltd.
+ *
+ * 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.
+ *
+ */
+
+package org.secretflow.easypsi.web.controller;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.web.servlet.MockMvc;
+import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
+
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.view;
+
+/**
+ * Index controller test
+ *
+ * @author lihaixin
+ * @date 2023/12/14
+ */
+class IndexControllerTest extends ControllerTest {
+ @Autowired
+ private MockMvc mockMvc;
+
+
+ @Test
+ void indexMapping() throws Exception {
+ mockMvc.perform(MockMvcRequestBuilders.get("/"))
+ .andExpect(status().isOk())
+ .andExpect(view().name("index"));
+
+
+ mockMvc.perform(MockMvcRequestBuilders.get("/login"))
+ .andExpect(status().isOk())
+ .andExpect(view().name("index"));
+
+ mockMvc.perform(MockMvcRequestBuilders.get("/guide"))
+ .andExpect(status().isOk())
+ .andExpect(view().name("index"));
+
+ mockMvc.perform(MockMvcRequestBuilders.get("/task"))
+ .andExpect(status().isOk())
+ .andExpect(view().name("index"));
+
+ mockMvc.perform(MockMvcRequestBuilders.get("/task-details"))
+ .andExpect(status().isOk())
+ .andExpect(view().name("index"));
+
+ mockMvc.perform(MockMvcRequestBuilders.get("/home"))
+ .andExpect(status().isOk())
+ .andExpect(view().name("index"));
+
+ mockMvc.perform(MockMvcRequestBuilders.get("/auth"))
+ .andExpect(status().isOk())
+ .andExpect(view().name("index"));
+ }
+}
\ No newline at end of file
diff --git a/secretpad-web/src/test/java/org/secretflow/secretpad/web/controller/MvcRequestFunction.java b/easypsi-web/src/test/java/org/secretflow/easypsi/web/controller/MvcRequestFunction.java
similarity index 94%
rename from secretpad-web/src/test/java/org/secretflow/secretpad/web/controller/MvcRequestFunction.java
rename to easypsi-web/src/test/java/org/secretflow/easypsi/web/controller/MvcRequestFunction.java
index 55457d5..ff084db 100644
--- a/secretpad-web/src/test/java/org/secretflow/secretpad/web/controller/MvcRequestFunction.java
+++ b/easypsi-web/src/test/java/org/secretflow/easypsi/web/controller/MvcRequestFunction.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.web.controller;
+package org.secretflow.easypsi.web.controller;
/**
* Mvc request function interface
diff --git a/secretpad-web/src/test/java/org/secretflow/secretpad/web/controller/NodeControllerTest.java b/easypsi-web/src/test/java/org/secretflow/easypsi/web/controller/NodeControllerTest.java
similarity index 78%
rename from secretpad-web/src/test/java/org/secretflow/secretpad/web/controller/NodeControllerTest.java
rename to easypsi-web/src/test/java/org/secretflow/easypsi/web/controller/NodeControllerTest.java
index 1544663..76ced88 100644
--- a/secretpad-web/src/test/java/org/secretflow/secretpad/web/controller/NodeControllerTest.java
+++ b/easypsi-web/src/test/java/org/secretflow/easypsi/web/controller/NodeControllerTest.java
@@ -1,20 +1,20 @@
-package org.secretflow.secretpad.web.controller;
-
-import org.secretflow.secretpad.common.errorcode.NodeErrorCode;
-import org.secretflow.secretpad.common.util.JsonUtils;
-import org.secretflow.secretpad.persistence.entity.NodeDO;
-import org.secretflow.secretpad.persistence.entity.NodeRouteDO;
-import org.secretflow.secretpad.persistence.repository.NodeRepository;
-import org.secretflow.secretpad.persistence.repository.NodeRouteRepository;
-import org.secretflow.secretpad.service.model.node.CreateNodeRequest;
-import org.secretflow.secretpad.service.model.node.DeleteNodeIdRequest;
-import org.secretflow.secretpad.service.model.node.DownloadNodeCertificateRequest;
-import org.secretflow.secretpad.web.utils.FakerUtils;
+package org.secretflow.easypsi.web.controller;
import jakarta.servlet.http.HttpServletResponse;
import org.apache.commons.codec.binary.Base64;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
+import org.secretflow.easypsi.common.errorcode.NodeErrorCode;
+import org.secretflow.easypsi.common.exception.EasyPsiException;
+import org.secretflow.easypsi.common.util.JsonUtils;
+import org.secretflow.easypsi.persistence.entity.NodeDO;
+import org.secretflow.easypsi.persistence.entity.NodeRouteDO;
+import org.secretflow.easypsi.persistence.repository.NodeRepository;
+import org.secretflow.easypsi.persistence.repository.NodeRouteRepository;
+import org.secretflow.easypsi.service.model.node.CreateNodeRequest;
+import org.secretflow.easypsi.service.model.node.DeleteNodeIdRequest;
+import org.secretflow.easypsi.service.model.node.DownloadNodeCertificateRequest;
+import org.secretflow.easypsi.web.utils.FakerUtils;
import org.secretflow.v1alpha1.common.Common;
import org.secretflow.v1alpha1.kusciaapi.Domain;
import org.secretflow.v1alpha1.kusciaapi.DomainRoute;
@@ -88,7 +88,9 @@ private DomainRoute.DeleteDomainRouteResponse buildDeleteDomainRouteResponse(int
private CreateNodeRequest buildCreateNodeRequest() {
return CreateNodeRequest.builder().certText("certText")
- .dstNodeId("bob").dstNetAddress("127.0.0.1:8090").nodeRemark("remark").build();
+ .dstNetAddress("127.0.0.1:8090").nodeRemark("remark")
+ .certText("LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUNxRENDQVpBQ0ZIZUxQT09TOG5qUHc5dHA2ajNlTGR1bTdlZ2hNQTBHQ1NxR1NJYjNEUUVCQ3dVQU1CRXgKRHpBTkJnTlZCQU1NQmt0MWMyTnBZVEFnRncweU16RXdNVE13TmpBNU5UbGFHQTh5TURVeE1ESXlPREEyTURrMQpPVm93RGpFTU1Bb0dBMVVFQXd3RFltOWlNSUlCSWpBTkJna3Foa2lHOXcwQkFRRUZBQU9DQVE4QU1JSUJDZ0tDCkFRRUFzQ1ZXSkpOWmZHSmd3Tm5nSTMxOG1wYmdpK0FqTSs0aTBvY2ZZY2hUbG1xaGpQRVJvWWl4R2xFREdmQisKSHduNmdLVEhNV2FHZjg0UTczbit3c0hhRjl6WUlvREU4VFVLZVh0ZmlmeGJCVEYxN0VuR3B3OHNUTitYSndJaAo1SVZxZjNRNVNiWldYSWJIYlBZbVdOR28vbiszTUVQRzVrZEpJdVQvQmNHNVJQVlZOMGRkSkFNK05XSnd5ZzZJCktYSHJUMjB5K3lWeTExem1yclk0MlpvVE8wZXlzVE52TU53Wm1WSVdPMmYxOUlmNDhrWTkxVG1paDlXa3J0bUEKSWk1RVRqY09NQ2pOZEFENnpNbXptbC92T3lIRnR5UDVSNnBQTkVTTUZLNm9OSHIvVTBkdVRDaUE5TE44RE9IYwpnN2lReW1GbFk4aGVlNU1ualBBbzhPdFc3UUlEQVFBQk1BMEdDU3FHU0liM0RRRUJDd1VBQTRJQkFRQU1qd21rCktyUWw0TThKQ2cyeWNlR1dIRE5IRXBMVzhKbUQwckJVWUVqem8xSkdOMS9tOEhSSUFFd0hTaEJQSzM0bkRaVUcKY1laMDEwM1BveWNoOFk2bHRYS1h2MWRhWGdHTUNGaW01OTFQVDBEbVZIU1A4QzVvTGZFSHVaMWNySkFVNDF3bgpHOEk2Nzgwa3JmT2hZY3dLaVZoODR5ZEluczFCVGF4RWw0TlkxTVUyVmc1V0x0ZlNkWmR4akZ1eHp3WWprbk0xCktKNXBpY2tNak8ySEtkRFdHTk5KN2dNNW50RlJOUllaTkZaZEkwbGtjb1ZQNEZyekFzQkFtbDZOTEdJd2ozeHAKc2toRWlQTlRHOXA1MHU5eWZyYkhFTGIvd2ZsY25zM3NUWTlnVGVocXc1cmN2bDZYemttRWJRZkFycjczUTA0WApIQ1JSRXN5VVhGdmxVK3BHCi0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K")
+ .trust(false).build();
}
private DeleteNodeIdRequest buildeDeleteNodeIdRequest(){
@@ -119,12 +121,20 @@ void createNode() throws Exception {
void createNodeByNodeAlreadyExistsException() throws Exception {
assertErrorCode(() -> {
CreateNodeRequest request = buildCreateNodeRequest();
- Domain.QueryDomainResponse queryDomainResponse = buildQueryDomainResponse(0);
+ Domain.QueryDomainResponse queryDomainResponse = buildQueryDomainResponse(1);
Mockito.when(domainServiceStub.queryDomain(Mockito.any())).thenReturn(queryDomainResponse);
- Mockito.when(nodeRepository.existsById(Mockito.anyString())).thenReturn(false);
+ Domain.CreateDomainResponse createDomainResponse = buildCreateDomainResponse(0);
+ Mockito.when(domainServiceStub.createDomain(Mockito.any())).thenReturn(createDomainResponse);
+ Mockito.when(nodeRepository.findByNodeId(Mockito.any())).thenReturn(buildNodeDO());
+ Mockito.when(nodeRepository.existsById(Mockito.anyString())).thenReturn(true);
+ Mockito.when(nodeRouteRepository.save(Mockito.any())).thenReturn(buildNodeRouteDO().get());
+ Mockito.when(nodeRouteRepository.findBySrcNodeIdAndDstNodeId(Mockito.anyString(), Mockito.anyString())).thenReturn(buildEmptyNodeRouteDO());
+ Mockito.when(domainRouteServiceBlockingStub.createDomainRoute(Mockito.any())).thenReturn(buildCreateDomainRouteResponse(0));
+ Mockito.when(domainRouteServiceBlockingStub.queryDomainRoute(Mockito.any())).thenReturn(buildQueryDomainRouteResponse(0));
+ Mockito.when(domainServiceStub.queryDomain(Mockito.any())).thenReturn(buildQueryDomainResponse(1));
return MockMvcRequestBuilders.post(getMappingUrl(NodeController.class, "createNode", CreateNodeRequest.class)).
content(JsonUtils.toJSONString(request));
- }, NodeErrorCode.NODE_CREATE_ERROR);
+ }, NodeErrorCode.NODE_CERT_CONFIG_ERROR);
}
@Test
@@ -133,9 +143,15 @@ void createNodeByNodeCreateFailedException() throws Exception {
CreateNodeRequest request = buildCreateNodeRequest();
Domain.QueryDomainResponse queryDomainResponse = buildQueryDomainResponse(1);
Mockito.when(domainServiceStub.queryDomain(Mockito.any())).thenReturn(queryDomainResponse);
+ Domain.CreateDomainResponse createDomainResponse = buildCreateDomainResponse(0);
+ Mockito.when(domainServiceStub.createDomain(Mockito.any())).thenThrow(EasyPsiException.of(NodeErrorCode.NODE_CREATE_ERROR));
+ Mockito.when(nodeRepository.findByNodeId(Mockito.any())).thenReturn(buildNodeDO());
Mockito.when(nodeRepository.existsById(Mockito.anyString())).thenReturn(false);
- Domain.CreateDomainResponse createDomainResponse = buildCreateDomainResponse(1);
- Mockito.when(domainServiceStub.createDomain(Mockito.any())).thenReturn(createDomainResponse);
+ Mockito.when(nodeRouteRepository.save(Mockito.any())).thenReturn(buildNodeRouteDO().get());
+ Mockito.when(nodeRouteRepository.findBySrcNodeIdAndDstNodeId(Mockito.anyString(), Mockito.anyString())).thenReturn(buildEmptyNodeRouteDO());
+ Mockito.when(domainRouteServiceBlockingStub.createDomainRoute(Mockito.any())).thenReturn(buildCreateDomainRouteResponse(0));
+ Mockito.when(domainRouteServiceBlockingStub.queryDomainRoute(Mockito.any())).thenReturn(buildQueryDomainRouteResponse(0));
+ Mockito.when(domainServiceStub.queryDomain(Mockito.any())).thenReturn(buildQueryDomainResponse(0));
return MockMvcRequestBuilders.post(getMappingUrl(NodeController.class, "createNode", CreateNodeRequest.class)).
content(JsonUtils.toJSONString(request));
}, NodeErrorCode.NODE_CREATE_ERROR);
@@ -193,7 +209,6 @@ void deleteNodeByNodeDeleteFailedException() throws Exception {
}
-
@Test
void getNode() throws Exception {
assertResponse(() -> {
@@ -235,7 +250,7 @@ void upload() throws Exception {
assertMultipartResponse(() -> {
File file = new File("mockCertText");
byte[] bytes = Base64.decodeBase64("LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUNxRENDQVpBQ0ZIZUxQT09TOG5qUHc5dHA2ajNlTGR1bTdlZ2hNQTBHQ1NxR1NJYjNEUUVCQ3dVQU1CRXgKRHpBTkJnTlZCQU1NQmt0MWMyTnBZVEFnRncweU16RXdNVE13TmpBNU5UbGFHQTh5TURVeE1ESXlPREEyTURrMQpPVm93RGpFTU1Bb0dBMVVFQXd3RFltOWlNSUlCSWpBTkJna3Foa2lHOXcwQkFRRUZBQU9DQVE4QU1JSUJDZ0tDCkFRRUFzQ1ZXSkpOWmZHSmd3Tm5nSTMxOG1wYmdpK0FqTSs0aTBvY2ZZY2hUbG1xaGpQRVJvWWl4R2xFREdmQisKSHduNmdLVEhNV2FHZjg0UTczbit3c0hhRjl6WUlvREU4VFVLZVh0ZmlmeGJCVEYxN0VuR3B3OHNUTitYSndJaAo1SVZxZjNRNVNiWldYSWJIYlBZbVdOR28vbiszTUVQRzVrZEpJdVQvQmNHNVJQVlZOMGRkSkFNK05XSnd5ZzZJCktYSHJUMjB5K3lWeTExem1yclk0MlpvVE8wZXlzVE52TU53Wm1WSVdPMmYxOUlmNDhrWTkxVG1paDlXa3J0bUEKSWk1RVRqY09NQ2pOZEFENnpNbXptbC92T3lIRnR5UDVSNnBQTkVTTUZLNm9OSHIvVTBkdVRDaUE5TE44RE9IYwpnN2lReW1GbFk4aGVlNU1ualBBbzhPdFc3UUlEQVFBQk1BMEdDU3FHU0liM0RRRUJDd1VBQTRJQkFRQU1qd21rCktyUWw0TThKQ2cyeWNlR1dIRE5IRXBMVzhKbUQwckJVWUVqem8xSkdOMS9tOEhSSUFFd0hTaEJQSzM0bkRaVUcKY1laMDEwM1BveWNoOFk2bHRYS1h2MWRhWGdHTUNGaW01OTFQVDBEbVZIU1A4QzVvTGZFSHVaMWNySkFVNDF3bgpHOEk2Nzgwa3JmT2hZY3dLaVZoODR5ZEluczFCVGF4RWw0TlkxTVUyVmc1V0x0ZlNkWmR4akZ1eHp3WWprbk0xCktKNXBpY2tNak8ySEtkRFdHTk5KN2dNNW50RlJOUllaTkZaZEkwbGtjb1ZQNEZyekFzQkFtbDZOTEdJd2ozeHAKc2toRWlQTlRHOXA1MHU5eWZyYkhFTGIvd2ZsY25zM3NUWTlnVGVocXc1cmN2bDZYemttRWJRZkFycjczUTA0WApIQ1JSRXN5VVhGdmxVK3BHCi0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K");
- FileOutputStream out = null;
+ FileOutputStream out;
try {
out = new FileOutputStream(file);
out.write(bytes);
@@ -252,6 +267,7 @@ void upload() throws Exception {
});
}
+
@Test
void download() throws Exception {
assertResponseWithContent(() -> {
diff --git a/secretpad-web/src/test/java/org/secretflow/secretpad/web/controller/NodeRouteControllerTest.java b/easypsi-web/src/test/java/org/secretflow/easypsi/web/controller/NodeRouteControllerTest.java
similarity index 90%
rename from secretpad-web/src/test/java/org/secretflow/secretpad/web/controller/NodeRouteControllerTest.java
rename to easypsi-web/src/test/java/org/secretflow/easypsi/web/controller/NodeRouteControllerTest.java
index 4d416b8..ddf1beb 100644
--- a/secretpad-web/src/test/java/org/secretflow/secretpad/web/controller/NodeRouteControllerTest.java
+++ b/easypsi-web/src/test/java/org/secretflow/easypsi/web/controller/NodeRouteControllerTest.java
@@ -1,21 +1,21 @@
-package org.secretflow.secretpad.web.controller;
-
-import org.secretflow.secretpad.common.constant.DomainConstants;
-import org.secretflow.secretpad.common.constant.DomainRouterConstants;
-import org.secretflow.secretpad.common.errorcode.NodeRouteErrorCode;
-import org.secretflow.secretpad.common.exception.SecretpadException;
-import org.secretflow.secretpad.common.util.JsonUtils;
-import org.secretflow.secretpad.manager.integration.model.NodeDTO;
-import org.secretflow.secretpad.manager.integration.node.NodeManager;
-import org.secretflow.secretpad.manager.integration.noderoute.NodeRouteManager;
-import org.secretflow.secretpad.persistence.entity.NodeDO;
-import org.secretflow.secretpad.persistence.entity.NodeRouteDO;
-import org.secretflow.secretpad.persistence.model.GraphJobStatus;
-import org.secretflow.secretpad.persistence.repository.NodeRepository;
-import org.secretflow.secretpad.persistence.repository.NodeRouteRepository;
-import org.secretflow.secretpad.service.model.noderoute.RouterAddressRequest;
-import org.secretflow.secretpad.service.model.noderoute.RouterIdRequest;
-import org.secretflow.secretpad.service.model.noderoute.UpdateNodeRouterRequest;
+package org.secretflow.easypsi.web.controller;
+
+import org.secretflow.easypsi.common.constant.DomainConstants;
+import org.secretflow.easypsi.common.constant.DomainRouterConstants;
+import org.secretflow.easypsi.common.errorcode.NodeRouteErrorCode;
+import org.secretflow.easypsi.common.exception.EasyPsiException;
+import org.secretflow.easypsi.common.util.JsonUtils;
+import org.secretflow.easypsi.manager.integration.model.NodeDTO;
+import org.secretflow.easypsi.manager.integration.node.NodeManager;
+import org.secretflow.easypsi.manager.integration.noderoute.NodeRouteManager;
+import org.secretflow.easypsi.persistence.entity.NodeDO;
+import org.secretflow.easypsi.persistence.entity.NodeRouteDO;
+import org.secretflow.easypsi.persistence.model.GraphJobStatus;
+import org.secretflow.easypsi.persistence.repository.NodeRepository;
+import org.secretflow.easypsi.persistence.repository.NodeRouteRepository;
+import org.secretflow.easypsi.service.model.noderoute.RouterAddressRequest;
+import org.secretflow.easypsi.service.model.noderoute.RouterIdRequest;
+import org.secretflow.easypsi.service.model.noderoute.UpdateNodeRouterRequest;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
@@ -109,7 +109,7 @@ void updateByRouteNotExist() throws Exception {
Mockito.when(domainRouteServiceBlockingStub.createDomainRoute(Mockito.any())).thenReturn(buildCreateDomainRouteResponse(0));
Mockito.when(domainRouteServiceBlockingStub.queryDomainRoute(Mockito.any())).thenReturn(buildQueryDomainRouteResponse(0));
Mockito.when(domainServiceStub.queryDomain(Mockito.any())).thenReturn(buildQueryDomainResponse(0));
- Mockito.doThrow(SecretpadException.of(NodeRouteErrorCode.NODE_ROUTE_NOT_EXIST_ERROR,
+ Mockito.doThrow(EasyPsiException.of(NodeRouteErrorCode.NODE_ROUTE_NOT_EXIST_ERROR,
"route not exist ")).when(nodeRouteManager).updateNodeRoute(Mockito.any());
doNothing().when(nodeRouteRepository).updateGmtModified(Mockito.anyString(), Mockito.anyString());
return MockMvcRequestBuilders.post(getMappingUrl(NodeRouteController.class, "update", UpdateNodeRouterRequest.class)).
@@ -130,7 +130,7 @@ void updateByNodeNotExist() throws Exception {
Mockito.when(domainRouteServiceBlockingStub.createDomainRoute(Mockito.any())).thenReturn(buildCreateDomainRouteResponse(0));
Mockito.when(domainRouteServiceBlockingStub.queryDomainRoute(Mockito.any())).thenReturn(buildQueryDomainRouteResponse(0));
Mockito.when(domainServiceStub.queryDomain(Mockito.any())).thenReturn(buildQueryDomainResponse(0));
- Mockito.doThrow(SecretpadException.of(NodeRouteErrorCode.NODE_ROUTE_CREATE_ERROR,
+ Mockito.doThrow(EasyPsiException.of(NodeRouteErrorCode.NODE_ROUTE_CREATE_ERROR,
"node do not exit")).when(nodeRouteManager).updateNodeRoute(Mockito.any());
doNothing().when(nodeRouteRepository).updateGmtModified(Mockito.anyString(), Mockito.anyString());
return MockMvcRequestBuilders.post(getMappingUrl(NodeRouteController.class, "update", UpdateNodeRouterRequest.class)).
diff --git a/secretpad-web/src/test/java/org/secretflow/secretpad/web/controller/ProjectControllerTest.java b/easypsi-web/src/test/java/org/secretflow/easypsi/web/controller/ProjectControllerTest.java
similarity index 88%
rename from secretpad-web/src/test/java/org/secretflow/secretpad/web/controller/ProjectControllerTest.java
rename to easypsi-web/src/test/java/org/secretflow/easypsi/web/controller/ProjectControllerTest.java
index 4823d09..822a122 100644
--- a/secretpad-web/src/test/java/org/secretflow/secretpad/web/controller/ProjectControllerTest.java
+++ b/easypsi-web/src/test/java/org/secretflow/easypsi/web/controller/ProjectControllerTest.java
@@ -14,27 +14,28 @@
* limitations under the License.
*/
-package org.secretflow.secretpad.web.controller;
-
-import org.secretflow.secretpad.common.constant.DatabaseConstants;
-import org.secretflow.secretpad.common.errorcode.JobErrorCode;
-import org.secretflow.secretpad.common.util.DateTimes;
-import org.secretflow.secretpad.common.util.JsonUtils;
-import org.secretflow.secretpad.manager.integration.job.JobManager;
-import org.secretflow.secretpad.manager.integration.noderoute.NodeRouteManager;
-import org.secretflow.secretpad.persistence.entity.NodeRouteDO;
-import org.secretflow.secretpad.persistence.entity.ProjectJobDO;
-import org.secretflow.secretpad.persistence.model.GraphJobStatus;
-import org.secretflow.secretpad.persistence.repository.NodeRouteRepository;
-import org.secretflow.secretpad.persistence.repository.ProjectJobRepository;
-import org.secretflow.secretpad.service.RemoteRequestService;
-import org.secretflow.secretpad.service.model.common.SecretPadResponse;
-import org.secretflow.secretpad.service.model.project.*;
-import org.secretflow.secretpad.web.utils.FakerUtils;
+package org.secretflow.easypsi.web.controller;
+
+import org.secretflow.easypsi.common.constant.DatabaseConstants;
+import org.secretflow.easypsi.common.errorcode.JobErrorCode;
+import org.secretflow.easypsi.common.util.DateTimes;
+import org.secretflow.easypsi.common.util.JsonUtils;
+import org.secretflow.easypsi.manager.integration.job.JobManager;
+import org.secretflow.easypsi.manager.integration.noderoute.NodeRouteManager;
+import org.secretflow.easypsi.persistence.entity.NodeRouteDO;
+import org.secretflow.easypsi.persistence.entity.ProjectJobDO;
+import org.secretflow.easypsi.persistence.model.GraphJobStatus;
+import org.secretflow.easypsi.persistence.repository.NodeRouteRepository;
+import org.secretflow.easypsi.persistence.repository.ProjectJobRepository;
+import org.secretflow.easypsi.service.RemoteRequestService;
+
+import org.secretflow.easypsi.service.model.common.EasyPsiResponse;
+import org.secretflow.easypsi.web.utils.FakerUtils;
import jakarta.servlet.http.HttpServletResponse;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
+import org.secretflow.easypsi.service.model.project.*;
import org.secretflow.v1alpha1.common.Common;
import org.secretflow.v1alpha1.kusciaapi.DomainRoute;
import org.secretflow.v1alpha1.kusciaapi.Job;
@@ -87,7 +88,7 @@ private ProjectJobDO buildProjectJobDO(boolean isTaskEmpty) {
upk.setJobId(JOB_ID);
ProjectJobDO projectJobDO = ProjectJobDO.builder().upk(upk).build();
if (!isTaskEmpty) {
- projectJobDO.setInitiatorConfig("{\"advancedJoinType\":\"ADVANCED_JOIN_TYPE_INNER_JOIN\",\"datatableCount\":\"L5\",\"disableAlignment\":false,\"inputConfig\":{\"path\":\"/home/kuscia/var/storage/data/testdata_1000w_50_sender.csv\",\"type\":\"IO_TYPE_FILE_CSV\"},\"keys\":[\"id0\"],\"linkConfig\":{\"httpTimeoutMs\":\"30\",\"recvTimeoutMs\":\"30\"},\"nodeId\":\"psi1\",\"outputConfig\":{\"path\":\"/home/kuscia/var/storage/data/result/gaddayeb/ss.csv\",\"type\":\"IO_TYPE_FILE_CSV\"},\"outputDifference\":false,\"protocolConfig\":{\"broadcastResult\":true,\"protocol\":\"PROTOCOL_RR22\",\"role\":\"ROLE_SENDER\",\"rr22Config\":{\"bucketSize\":\"1048576\",\"lowCommMode\":false}},\"recoveryConfig\":{\"enabled\":false,\"folder\":\"/home/kuscia/var/storage/data/tmp/gaddayeb/\"},\"skipDuplicatesCheck\":true}");
+ projectJobDO.setInitiatorConfig("{\"advancedJoinType\":\"ADVANCED_JOIN_TYPE_INNER_JOIN\",\"leftSide\":\"psi1\",\"datatableCount\":\"L5\",\"disableAlignment\":false,\"inputConfig\":{\"path\":\"/home/kuscia/var/storage/data/testdata_1000w_50_sender.csv\",\"type\":\"IO_TYPE_FILE_CSV\"},\"keys\":[\"id0\"],\"linkConfig\":{\"httpTimeoutMs\":\"30\",\"recvTimeoutMs\":\"30\"},\"nodeId\":\"psi1\",\"outputConfig\":{\"path\":\"/home/kuscia/var/storage/data/result/gaddayeb/ss.csv\",\"type\":\"IO_TYPE_FILE_CSV\"},\"outputDifference\":false,\"protocolConfig\":{\"broadcastResult\":true,\"protocol\":\"PROTOCOL_RR22\",\"role\":\"ROLE_SENDER\",\"rr22Config\":{\"bucketSize\":\"1048576\",\"lowCommMode\":false}},\"recoveryConfig\":{\"enabled\":false,\"folder\":\"/home/kuscia/var/storage/data/tmp/gaddayeb/\"},\"skipDuplicatesCheck\":true}");
} else {
projectJobDO.setInitiatorConfig("");
}
@@ -95,7 +96,7 @@ private ProjectJobDO buildProjectJobDO(boolean isTaskEmpty) {
projectJobDO.setGmtModified(DateTimes.utcFromRfc3339("2023-08-02T16:30:15.235+08:00"));
projectJobDO.setInitiatorNodeId("alice");
projectJobDO.setPartnerNodeId("bob");
- projectJobDO.setPartnerConfig("{\"advancedJoinType\":\"ADVANCED_JOIN_TYPE_INNER_JOIN\",\"datatableCount\":\"L5\",\"disableAlignment\":false,\"inputConfig\":{\"path\":\"/home/kuscia/var/storage/data/testdata_1000w_50_receiver.csv\",\"type\":\"IO_TYPE_FILE_CSV\"},\"keys\":[\"id0\"],\"linkConfig\":{\"httpTimeoutMs\":\"30\",\"recvTimeoutMs\":\"30\"},\"nodeId\":\"psi2\",\"outputConfig\":{\"path\":\"/home/kuscia/var/storage/data/result/gaddayeb/ss.csv\",\"type\":\"IO_TYPE_FILE_CSV\"},\"outputDifference\":false,\"protocolConfig\":{\"broadcastResult\":true,\"protocol\":\"PROTOCOL_RR22\",\"role\":\"ROLE_RECEIVER\",\"rr22Config\":{\"bucketSize\":\"1048576\",\"lowCommMode\":false}},\"recoveryConfig\":{\"enabled\":false,\"folder\":\"/home/kuscia/var/storage/data/tmp/gaddayeb/\"},\"skipDuplicatesCheck\":true}");
+ projectJobDO.setPartnerConfig("{\"advancedJoinType\":\"ADVANCED_JOIN_TYPE_INNER_JOIN\",\"leftSide\":\"psi1\",\"datatableCount\":\"L5\",\"disableAlignment\":false,\"inputConfig\":{\"path\":\"/home/kuscia/var/storage/data/testdata_1000w_50_sender.csv\",\"type\":\"IO_TYPE_FILE_CSV\"},\"keys\":[\"id0\"],\"linkConfig\":{\"httpTimeoutMs\":\"30\",\"recvTimeoutMs\":\"30\"},\"nodeId\":\"psi1\",\"outputConfig\":{\"path\":\"/home/kuscia/var/storage/data/result/gaddayeb/ss.csv\",\"type\":\"IO_TYPE_FILE_CSV\"},\"outputDifference\":false,\"protocolConfig\":{\"broadcastResult\":true,\"protocol\":\"PROTOCOL_RR22\",\"role\":\"ROLE_SENDER\",\"rr22Config\":{\"bucketSize\":\"1048576\",\"lowCommMode\":false}},\"recoveryConfig\":{\"enabled\":false,\"folder\":\"/home/kuscia/var/storage/data/tmp/gaddayeb/\"},\"skipDuplicatesCheck\":true}");
return projectJobDO;
}
@@ -112,8 +113,8 @@ private DomainRoute.RouteStatus buildRouteStatus() {
return DomainRoute.RouteStatus.newBuilder().setStatus("Succeeded").build();
}
- private SecretPadResponse buildSecretPadResponse() {
- return SecretPadResponse.success("Succeeded");
+ private EasyPsiResponse buildEasyPsiResponse() {
+ return EasyPsiResponse.success("Succeeded");
}
private ProjectJobDO buildProjectJobDO() {
@@ -201,7 +202,7 @@ void stopJob() throws Exception {
Mockito.when(nodeRouteManager.getRouteStatus(Mockito.anyString(), Mockito.anyString())).thenReturn(buildRouteStatus());
Mockito.when(nodeRouteRepository.findBySrcNodeIdAndDstNodeId(Mockito.anyString(), Mockito.anyString())).thenReturn(Optional.of(buildNodeRouteDO()));
Mockito.when(remoteRequestService.checkBothSidesNodeRouteIsReady(Mockito.anyString(), Mockito.anyString())).thenReturn(true);
- Mockito.when(remoteRequestService.sendPostJson(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(buildSecretPadResponse());
+ Mockito.when(remoteRequestService.sendPostJson(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(buildEasyPsiResponse());
Mockito.when(jobStub.deleteJob(Mockito.any())).thenReturn(org.secretflow.v1alpha1.kusciaapi.Job.DeleteJobResponse.newBuilder().build());
return MockMvcRequestBuilders.post(getMappingUrl(ProjectController.class, "stopJob", StopProjectJobTaskRequest.class)).
@@ -231,7 +232,7 @@ void getProjectLogs() throws Exception {
Mockito.when(nodeRouteManager.getRouteStatus(Mockito.anyString(), Mockito.anyString())).thenReturn(buildRouteStatus());
Mockito.when(nodeRouteRepository.findBySrcNodeIdAndDstNodeId(Mockito.anyString(), Mockito.anyString())).thenReturn(Optional.of(buildNodeRouteDO()));
Mockito.when(remoteRequestService.checkBothSidesNodeRouteIsReady(Mockito.anyString(), Mockito.anyString())).thenReturn(true);
- Mockito.when(remoteRequestService.sendPostJson(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(buildSecretPadResponse());
+ Mockito.when(remoteRequestService.sendPostJson(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(buildEasyPsiResponse());
return MockMvcRequestBuilders.post(getMappingUrl(ProjectController.class, "getProjectLogs", GetProjectJobLogRequest.class)).
content(JsonUtils.toJSONString(request));
@@ -274,7 +275,7 @@ void agreeJobErrorException() throws Exception {
Mockito.when(nodeRouteManager.getRouteStatus(Mockito.anyString(), Mockito.anyString())).thenReturn(buildRouteStatus());
Mockito.when(nodeRouteRepository.findBySrcNodeIdAndDstNodeId(Mockito.anyString(), Mockito.anyString())).thenReturn(Optional.of(buildNodeRouteDO()));
Mockito.when(remoteRequestService.checkBothSidesNodeRouteIsReady(Mockito.anyString(), Mockito.anyString())).thenReturn(true);
- Mockito.when(remoteRequestService.sendPostJson(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(buildSecretPadResponse());
+ Mockito.when(remoteRequestService.sendPostJson(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(buildEasyPsiResponse());
return MockMvcRequestBuilders.post(getMappingUrl(ProjectController.class, "agreeJob", AgreeProjectJobTaskRequest.class)).
content(JsonUtils.toJSONString(request));
@@ -292,7 +293,7 @@ void pauseJob() throws Exception {
Mockito.when(nodeRouteManager.getRouteStatus(Mockito.anyString(), Mockito.anyString())).thenReturn(buildRouteStatus());
Mockito.when(nodeRouteRepository.findBySrcNodeIdAndDstNodeId(Mockito.anyString(), Mockito.anyString())).thenReturn(Optional.of(buildNodeRouteDO()));
Mockito.when(remoteRequestService.checkBothSidesNodeRouteIsReady(Mockito.anyString(), Mockito.anyString())).thenReturn(true);
- Mockito.when(remoteRequestService.sendPostJson(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(buildSecretPadResponse());
+ Mockito.when(remoteRequestService.sendPostJson(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(buildEasyPsiResponse());
Mockito.when(jobStub.deleteJob(Mockito.any())).thenReturn(org.secretflow.v1alpha1.kusciaapi.Job.DeleteJobResponse.newBuilder().build());
return MockMvcRequestBuilders.post(getMappingUrl(ProjectController.class, "pauseJob", StopProjectJobTaskRequest.class)).
@@ -311,7 +312,7 @@ void pauseJobErrorException() throws Exception {
Mockito.when(nodeRouteManager.getRouteStatus(Mockito.anyString(), Mockito.anyString())).thenReturn(buildRouteStatus());
Mockito.when(nodeRouteRepository.findBySrcNodeIdAndDstNodeId(Mockito.anyString(), Mockito.anyString())).thenReturn(Optional.of(buildNodeRouteDO()));
Mockito.when(remoteRequestService.checkBothSidesNodeRouteIsReady(Mockito.anyString(), Mockito.anyString())).thenReturn(true);
- Mockito.when(remoteRequestService.sendPostJson(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(buildSecretPadResponse());
+ Mockito.when(remoteRequestService.sendPostJson(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(buildEasyPsiResponse());
Mockito.when(jobStub.deleteJob(Mockito.any())).thenReturn(org.secretflow.v1alpha1.kusciaapi.Job.DeleteJobResponse.newBuilder().build());
return MockMvcRequestBuilders.post(getMappingUrl(ProjectController.class, "pauseJob", StopProjectJobTaskRequest.class)).
@@ -331,7 +332,7 @@ void continueJob() throws Exception {
Mockito.when(nodeRouteManager.getRouteStatus(Mockito.anyString(), Mockito.anyString())).thenReturn(buildRouteStatus());
Mockito.when(nodeRouteRepository.findBySrcNodeIdAndDstNodeId(Mockito.anyString(), Mockito.anyString())).thenReturn(Optional.of(buildNodeRouteDO()));
Mockito.when(remoteRequestService.checkBothSidesNodeRouteIsReady(Mockito.anyString(), Mockito.anyString())).thenReturn(true);
- Mockito.when(remoteRequestService.sendPostJson(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(buildSecretPadResponse());
+ Mockito.when(remoteRequestService.sendPostJson(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(buildEasyPsiResponse());
Mockito.when(jobStub.deleteJob(Mockito.any())).thenReturn(org.secretflow.v1alpha1.kusciaapi.Job.DeleteJobResponse.newBuilder().build());
Job.CreateJobResponse response = Job.CreateJobResponse.newBuilder()
.setStatus(Common.Status.newBuilder().setCode(0).build())
@@ -353,7 +354,7 @@ void continueJobErrorException() throws Exception {
Mockito.when(nodeRouteManager.getRouteStatus(Mockito.anyString(), Mockito.anyString())).thenReturn(buildRouteStatus());
Mockito.when(nodeRouteRepository.findBySrcNodeIdAndDstNodeId(Mockito.anyString(), Mockito.anyString())).thenReturn(Optional.of(buildNodeRouteDO()));
Mockito.when(remoteRequestService.checkBothSidesNodeRouteIsReady(Mockito.anyString(), Mockito.anyString())).thenReturn(true);
- Mockito.when(remoteRequestService.sendPostJson(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(buildSecretPadResponse());
+ Mockito.when(remoteRequestService.sendPostJson(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(buildEasyPsiResponse());
return MockMvcRequestBuilders.post(getMappingUrl(ProjectController.class, "continueJob", StopProjectJobTaskRequest.class)).
content(JsonUtils.toJSONString(request));
@@ -371,7 +372,7 @@ void rejectJob() throws Exception {
Mockito.when(nodeRouteManager.getRouteStatus(Mockito.anyString(), Mockito.anyString())).thenReturn(buildRouteStatus());
Mockito.when(nodeRouteRepository.findBySrcNodeIdAndDstNodeId(Mockito.anyString(), Mockito.anyString())).thenReturn(Optional.of(buildNodeRouteDO()));
Mockito.when(remoteRequestService.checkBothSidesNodeRouteIsReady(Mockito.anyString(), Mockito.anyString())).thenReturn(true);
- Mockito.when(remoteRequestService.sendPostJson(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(buildSecretPadResponse());
+ Mockito.when(remoteRequestService.sendPostJson(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(buildEasyPsiResponse());
return MockMvcRequestBuilders.post(getMappingUrl(ProjectController.class, "rejectJob", RejectProjectJobTaskRequest.class)).
content(JsonUtils.toJSONString(request));
@@ -389,7 +390,7 @@ void rejectJobErrorException() throws Exception {
Mockito.when(nodeRouteManager.getRouteStatus(Mockito.anyString(), Mockito.anyString())).thenReturn(buildRouteStatus());
Mockito.when(nodeRouteRepository.findBySrcNodeIdAndDstNodeId(Mockito.anyString(), Mockito.anyString())).thenReturn(Optional.of(buildNodeRouteDO()));
Mockito.when(remoteRequestService.checkBothSidesNodeRouteIsReady(Mockito.anyString(), Mockito.anyString())).thenReturn(true);
- Mockito.when(remoteRequestService.sendPostJson(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(buildSecretPadResponse());
+ Mockito.when(remoteRequestService.sendPostJson(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(buildEasyPsiResponse());
return MockMvcRequestBuilders.post(getMappingUrl(ProjectController.class, "rejectJob", RejectProjectJobTaskRequest.class)).
content(JsonUtils.toJSONString(request));
}, JobErrorCode.PROJECT_JOB_ACTION_NOT_ALLOWED);
diff --git a/secretpad-web/src/test/java/org/secretflow/secretpad/web/controller/UserControllerTest.java b/easypsi-web/src/test/java/org/secretflow/easypsi/web/controller/UserControllerTest.java
similarity index 86%
rename from secretpad-web/src/test/java/org/secretflow/secretpad/web/controller/UserControllerTest.java
rename to easypsi-web/src/test/java/org/secretflow/easypsi/web/controller/UserControllerTest.java
index 77bd31a..158d2d4 100644
--- a/secretpad-web/src/test/java/org/secretflow/secretpad/web/controller/UserControllerTest.java
+++ b/easypsi-web/src/test/java/org/secretflow/easypsi/web/controller/UserControllerTest.java
@@ -15,13 +15,13 @@
*
*/
-package org.secretflow.secretpad.web.controller;
+package org.secretflow.easypsi.web.controller;
-import org.secretflow.secretpad.common.util.JsonUtils;
-import org.secretflow.secretpad.persistence.entity.AccountsDO;
-import org.secretflow.secretpad.persistence.repository.UserAccountsRepository;
-import org.secretflow.secretpad.persistence.repository.UserTokensRepository;
-import org.secretflow.secretpad.service.model.auth.UserUpdatePwdRequest;
+import org.secretflow.easypsi.common.util.JsonUtils;
+import org.secretflow.easypsi.persistence.entity.AccountsDO;
+import org.secretflow.easypsi.persistence.repository.UserAccountsRepository;
+import org.secretflow.easypsi.persistence.repository.UserTokensRepository;
+import org.secretflow.easypsi.service.model.auth.UserUpdatePwdRequest;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
diff --git a/easypsi-web/src/test/java/org/secretflow/easypsi/web/exception/BasicErrorHandlerTest.java b/easypsi-web/src/test/java/org/secretflow/easypsi/web/exception/BasicErrorHandlerTest.java
new file mode 100644
index 0000000..c158c98
--- /dev/null
+++ b/easypsi-web/src/test/java/org/secretflow/easypsi/web/exception/BasicErrorHandlerTest.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2024 Ant Group Co., Ltd.
+ *
+ * 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.
+ */
+
+package org.secretflow.easypsi.web.exception;
+
+import jakarta.servlet.http.HttpServletRequest;
+import org.junit.jupiter.api.Test;
+import org.mockito.BDDMockito;
+import org.secretflow.easypsi.common.exception.EasyPsiException;
+import org.springframework.boot.autoconfigure.web.ErrorProperties;
+import org.springframework.boot.web.servlet.error.DefaultErrorAttributes;
+import org.springframework.http.HttpStatus;
+import org.springframework.mock.web.MockHttpServletRequest;
+import org.springframework.mock.web.MockHttpServletResponse;
+
+
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+/**
+ * @author chenmingliang
+ * @date 2024/03/13
+ */
+public class BasicErrorHandlerTest {
+
+ @Test
+ public void testErrorHtml() {
+
+ DefaultErrorAttributes attributes = BDDMockito.mock(DefaultErrorAttributes.class);
+ ErrorProperties errorProperties = BDDMockito.mock(ErrorProperties.class);
+ BasicErrorHandler handler = new BasicErrorHandler(attributes,errorProperties,null){
+ @Override
+ protected HttpStatus getStatus(HttpServletRequest request) {
+ return HttpStatus.NOT_FOUND;
+ }
+ };
+ MockHttpServletRequest request = new MockHttpServletRequest();
+ MockHttpServletResponse response = new MockHttpServletResponse();
+ assertThrows(EasyPsiException.class, () -> handler.errorHtml(request, response));
+
+ BasicErrorHandler handler4xx = new BasicErrorHandler(attributes,errorProperties,null){
+ @Override
+ protected HttpStatus getStatus(HttpServletRequest request) {
+ return HttpStatus.FORBIDDEN;
+ }
+ };
+ assertThrows(EasyPsiException.class, () -> handler4xx.errorHtml(request, response));
+
+ BasicErrorHandler handler5xx = new BasicErrorHandler(attributes,errorProperties,null){
+ @Override
+ protected HttpStatus getStatus(HttpServletRequest request) {
+ return HttpStatus.GATEWAY_TIMEOUT;
+ }
+ };
+
+ assertThrows(EasyPsiException.class, () -> handler5xx.errorHtml(request, response));
+
+ }
+}
diff --git a/easypsi-web/src/test/java/org/secretflow/easypsi/web/exception/EasyPsiExceptionHandlerTest.java b/easypsi-web/src/test/java/org/secretflow/easypsi/web/exception/EasyPsiExceptionHandlerTest.java
new file mode 100644
index 0000000..96cac60
--- /dev/null
+++ b/easypsi-web/src/test/java/org/secretflow/easypsi/web/exception/EasyPsiExceptionHandlerTest.java
@@ -0,0 +1,125 @@
+/*
+ * Copyright 2024 Ant Group Co., Ltd.
+ *
+ * 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.
+ */
+
+package org.secretflow.easypsi.web.exception;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.secretflow.easypsi.common.errorcode.ErrorCode;
+import org.secretflow.easypsi.common.errorcode.SystemErrorCode;
+import org.secretflow.easypsi.common.exception.EasyPsiException;
+import org.secretflow.easypsi.common.i18n.MessageResolver;
+import org.secretflow.easypsi.service.model.common.EasyPsiResponse;
+import org.springframework.core.MethodParameter;
+import org.springframework.validation.BeanPropertyBindingResult;
+import org.springframework.validation.BindException;
+import org.springframework.validation.FieldError;
+import org.springframework.web.bind.MethodArgumentNotValidException;
+
+
+import static org.mockito.Mockito.*;
+
+/**
+ * @author chenmingliang
+ * @date 2024/03/13
+ */
+public class EasyPsiExceptionHandlerTest {
+ @InjectMocks
+ private EasyPsiExceptionHandler easyPsiExceptionHandler;
+
+ @Mock
+ private MessageResolver messageResolver;
+
+
+ @Mock
+ private BindException bindException;
+
+ private MethodArgumentNotValidException methodArgumentNotValidException;
+
+ private Exception exception;
+
+ @BeforeEach
+ public void setUp() throws NoSuchMethodException {
+ MockitoAnnotations.openMocks(this);
+
+ // 创建 BeanPropertyBindingResult 对象,模拟绑定结果
+ BeanPropertyBindingResult bindingResult = new BeanPropertyBindingResult(new Object(), "objectName");
+ FieldError fieldError = new FieldError("objectName", "field", "default message");
+ bindingResult.addError(fieldError);
+
+ MethodParameter methodParameter = new MethodParameter(
+ Object.class.getDeclaredMethod("toString"), -1);
+
+ methodArgumentNotValidException = new MethodArgumentNotValidException(methodParameter, bindingResult);
+
+ exception = new Exception("Test exception");
+
+ }
+
+ @Test
+ public void testHandlerEasyPsiException() {
+ EasyPsiException easyPsiException = mock(EasyPsiException.class);
+ ErrorCode errorCode = SystemErrorCode.UNKNOWN_ERROR; // Example ErrorCode
+ String errorMessage = "Error message";
+
+ when(easyPsiException.getErrorCode()).thenReturn(errorCode);
+ when(messageResolver.getMessage(Mockito.any(ErrorCode.class), Mockito.any())).thenReturn(errorMessage);
+
+ EasyPsiResponse result = easyPsiExceptionHandler.handlerEasyPsiException(easyPsiException);
+
+ verify(messageResolver).getMessage(errorCode, easyPsiException.getArgs());
+ Assertions.assertNotNull(result);
+ Assertions.assertEquals(errorCode.getCode(), result.getStatus().getCode());
+ Assertions.assertEquals(errorMessage, result.getStatus().getMsg());
+ }
+
+ @Test
+ public void testHandlerValidation() {
+ String errorMessage = "Validation Error Message";
+ ErrorCode errorCode = SystemErrorCode.VALIDATION_ERROR;
+
+ when(messageResolver.getMessage(any(ErrorCode.class), any())).thenReturn(errorMessage);
+
+ EasyPsiResponse response = (EasyPsiResponse) easyPsiExceptionHandler.handlerValidation(methodArgumentNotValidException);
+
+ verify(messageResolver).getMessage(any(ErrorCode.class), any());
+ Assertions.assertNotNull(response);
+ Assertions.assertEquals(errorCode.getCode(), response.getStatus().getCode());
+ Assertions.assertEquals(errorMessage, response.getStatus().getMsg());
+ }
+
+ @Test
+ public void testHandleException() {
+ String resolvedErrorMessage = "An unknown error has occurred.";
+ when(messageResolver.getMessage(any(SystemErrorCode.class), any())).thenReturn(resolvedErrorMessage);
+
+ Object result = easyPsiExceptionHandler.handleException(exception);
+
+ Assertions.assertNotNull(result);
+ EasyPsiResponse> response = (EasyPsiResponse>) result;
+
+ Assertions.assertEquals(SystemErrorCode.UNKNOWN_ERROR.getCode(), response.getStatus().getCode());
+ Assertions.assertEquals(resolvedErrorMessage, response.getStatus().getMsg());
+
+ verify(messageResolver).getMessage(any(SystemErrorCode.class), any());
+ }
+
+}
diff --git a/easypsi-web/src/test/java/org/secretflow/easypsi/web/init/DataInitializerTest.java b/easypsi-web/src/test/java/org/secretflow/easypsi/web/init/DataInitializerTest.java
new file mode 100644
index 0000000..71f3dd4
--- /dev/null
+++ b/easypsi-web/src/test/java/org/secretflow/easypsi/web/init/DataInitializerTest.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2024 Ant Group Co., Ltd.
+ *
+ * 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.
+ */
+
+package org.secretflow.easypsi.web.init;
+
+import org.junit.jupiter.api.Test;
+import org.secretflow.easypsi.service.impl.NodeServiceImpl;
+import org.springframework.boot.CommandLineRunner;
+
+import java.lang.reflect.Field;
+
+/**
+ * @author chenmingliang
+ * @date 2024/03/13
+ */
+public class DataInitializerTest {
+
+ @Test
+ public void testRun() throws Exception {
+ CommandLineRunner runner = new DataInitializer();
+ Field nodeService = DataInitializer.class.getDeclaredField("nodeService");
+ nodeService.setAccessible(true);
+ nodeService.set(runner,new NodeServiceImpl());
+
+ runner.run();
+ }
+}
diff --git a/easypsi-web/src/test/java/org/secretflow/easypsi/web/util/AuthUtilsTest.java b/easypsi-web/src/test/java/org/secretflow/easypsi/web/util/AuthUtilsTest.java
new file mode 100644
index 0000000..0d69b4d
--- /dev/null
+++ b/easypsi-web/src/test/java/org/secretflow/easypsi/web/util/AuthUtilsTest.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2024 Ant Group Co., Ltd.
+ *
+ * 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.
+ */
+
+package org.secretflow.easypsi.web.util;
+
+import jakarta.servlet.http.HttpServletRequest;
+import org.assertj.core.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.mockito.BDDMockito;
+import org.secretflow.easypsi.common.exception.EasyPsiException;
+import org.secretflow.easypsi.web.constant.AuthConstants;
+
+class AuthUtilsTest {
+
+ @Test
+ void findTokenInHeader() {
+ String token = "token";
+ HttpServletRequest request = BDDMockito.mock(HttpServletRequest.class);
+ BDDMockito.given(request.getHeader(AuthConstants.TOKEN_NAME)).willReturn("token");
+ String tokenInHeader = AuthUtils.findTokenInHeader(request);
+ Assertions.assertThat(tokenInHeader).isNotBlank().isEqualTo(token);
+ }
+
+ @Test
+ void findTokenInHeaderWithThrow() {
+ HttpServletRequest request = BDDMockito.mock(HttpServletRequest.class);
+ BDDMockito.given(request.getHeader(AuthConstants.TOKEN_NAME)).willReturn("");
+ org.junit.jupiter.api.Assertions.assertThrows(EasyPsiException.class,()->AuthUtils.findTokenInHeader(request));
+ }
+}
\ No newline at end of file
diff --git a/easypsi-web/src/test/java/org/secretflow/easypsi/web/util/ResponseUtilsTest.java b/easypsi-web/src/test/java/org/secretflow/easypsi/web/util/ResponseUtilsTest.java
new file mode 100644
index 0000000..3c0f418
--- /dev/null
+++ b/easypsi-web/src/test/java/org/secretflow/easypsi/web/util/ResponseUtilsTest.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2024 Ant Group Co., Ltd.
+ *
+ * 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.
+ */
+
+package org.secretflow.easypsi.web.util;
+
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+import org.junit.jupiter.api.Test;
+import org.mockito.BDDMockito;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+class ResponseUtilsTest {
+
+ @Test
+ void buildResponse_404() throws IOException {
+ HttpServletRequest request = BDDMockito.mock(HttpServletRequest.class);
+ HttpServletResponse response = BDDMockito.mock(HttpServletResponse.class);
+ PrintWriter writer = BDDMockito.mock(PrintWriter.class);
+
+ BDDMockito.given(request.getRequestURI()).willReturn("uri");
+ BDDMockito.given(response.getWriter()).willReturn(writer);
+
+ ResponseUtils.buildResponse_404(response, request);
+
+ BDDMockito.verify(writer, BDDMockito.times(1)).write(BDDMockito.anyString());
+ }
+}
\ No newline at end of file
diff --git a/secretpad-web/src/test/java/org/secretflow/secretpad/web/utils/ClazzUtils.java b/easypsi-web/src/test/java/org/secretflow/easypsi/web/utils/ClazzUtils.java
similarity index 98%
rename from secretpad-web/src/test/java/org/secretflow/secretpad/web/utils/ClazzUtils.java
rename to easypsi-web/src/test/java/org/secretflow/easypsi/web/utils/ClazzUtils.java
index 3b8beb7..1f7c265 100644
--- a/secretpad-web/src/test/java/org/secretflow/secretpad/web/utils/ClazzUtils.java
+++ b/easypsi-web/src/test/java/org/secretflow/easypsi/web/utils/ClazzUtils.java
@@ -15,7 +15,7 @@
*
*/
-package org.secretflow.secretpad.web.utils;
+package org.secretflow.easypsi.web.utils;
/**
* Class util, avoid conflict with org.apache.commons.lang3.ClassUtils
diff --git a/secretpad-web/src/test/java/org/secretflow/secretpad/web/utils/DataUtils.java b/easypsi-web/src/test/java/org/secretflow/easypsi/web/utils/DataUtils.java
similarity index 97%
rename from secretpad-web/src/test/java/org/secretflow/secretpad/web/utils/DataUtils.java
rename to easypsi-web/src/test/java/org/secretflow/easypsi/web/utils/DataUtils.java
index 7175bd2..8be94e7 100644
--- a/secretpad-web/src/test/java/org/secretflow/secretpad/web/utils/DataUtils.java
+++ b/easypsi-web/src/test/java/org/secretflow/easypsi/web/utils/DataUtils.java
@@ -15,7 +15,7 @@
*
*/
-package org.secretflow.secretpad.web.utils;
+package org.secretflow.easypsi.web.utils;
import org.apache.commons.lang3.RandomUtils;
diff --git a/secretpad-web/src/test/java/org/secretflow/secretpad/web/utils/FakerUtils.java b/easypsi-web/src/test/java/org/secretflow/easypsi/web/utils/FakerUtils.java
similarity index 99%
rename from secretpad-web/src/test/java/org/secretflow/secretpad/web/utils/FakerUtils.java
rename to easypsi-web/src/test/java/org/secretflow/easypsi/web/utils/FakerUtils.java
index 92f69aa..71a466d 100644
--- a/secretpad-web/src/test/java/org/secretflow/secretpad/web/utils/FakerUtils.java
+++ b/easypsi-web/src/test/java/org/secretflow/easypsi/web/utils/FakerUtils.java
@@ -15,7 +15,7 @@
*
*/
-package org.secretflow.secretpad.web.utils;
+package org.secretflow.easypsi.web.utils;
/**
* Faker utils, mock data for test
diff --git a/pom.xml b/pom.xml
index 53ae6cb..ca53c00 100644
--- a/pom.xml
+++ b/pom.xml
@@ -20,12 +20,13 @@
4.0.0
pom
- secretpad-manager
- secretpad-web
- secretpad-common
- secretpad-persistence
- secretpad-api
- secretpad-service
+ easypsi-manager
+ easypsi-web
+ easypsi-common
+ easypsi-persistence
+ easypsi-api
+ easypsi-service
+ easypsi-test
org.springframework.boot
@@ -33,13 +34,13 @@
3.1.7
org.secretflow
- secretpad-parent
+ easypsi-parent
0.0.1-SNAPSHOT
- secretpad-parent
- secretpad parent
+ easypsi-parent
+ easypsi parent
17
- 6.0.16
+ 6.0.17
3.1.7
6.1.2
17
@@ -57,7 +58,7 @@
2.1.1
1.3.2
32.1.1-jre
- 1.21
+ 1.26.0
2.1.0
1.7.1
0.6.1
@@ -66,28 +67,31 @@
3.4.0
UTF-8
1.4.14
+ 0.8.7
+ 3.2.5
+ ${project.build.directory}/jacoco-ut.exec
org.secretflow
- secretpad-common
+ easypsi-common
${project.version}
org.secretflow
- secretpad-persistence
+ easypsi-persistence
${project.version}
org.secretflow
- secretpad-manager
+ easypsi-manager
${project.version}
org.secretflow
- secretpad-service
+ easypsi-service
${project.version}
@@ -97,7 +101,7 @@
org.secretflow
- client-java-secretpad
+ client-java-easypsi
${project.version}
@@ -265,8 +269,37 @@
+
+ org.jacoco
+ jacoco-maven-plugin
+ ${jacoco-maven-plugin.version}
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+ true
+
+ ${maven-surefire-plugin.version}
+
+
+
+ org.jacoco
+ jacoco-maven-plugin
+
+
+ prepare-agent
+
+ prepare-agent
+
+
+
+
+
+
+
diff --git a/proto/kuscia/proto/api/v1alpha1/kusciaapi/domaindata.proto b/proto/kuscia/proto/api/v1alpha1/kusciaapi/domaindata.proto
deleted file mode 100644
index f48f5db..0000000
--- a/proto/kuscia/proto/api/v1alpha1/kusciaapi/domaindata.proto
+++ /dev/null
@@ -1,203 +0,0 @@
-// Copyright 2023 Ant Group Co., Ltd.
-//
-// 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.
-
-syntax = "proto3";
-
-package kuscia.proto.api.v1alpha1.kusciaapi;
-
-import "kuscia/proto/api/v1alpha1/common.proto";
-
-option go_package = "github.com/secretflow/kuscia/proto/api/v1alpha1/kusciaapi";
-option java_package = "org.secretflow.v1alpha1.kusciaapi";
-
-service DomainDataService {
- rpc CreateDomainData(CreateDomainDataRequest) returns (CreateDomainDataResponse);
-
- rpc UpdateDomainData(UpdateDomainDataRequest) returns (UpdateDomainDataResponse);
-
- rpc DeleteDomainData(DeleteDomainDataRequest) returns (DeleteDomainDataResponse);
-
- rpc QueryDomainData(QueryDomainDataRequest) returns (QueryDomainDataResponse);
-
- rpc BatchQueryDomainData(BatchQueryDomainDataRequest) returns (BatchQueryDomainDataResponse);
-
- rpc ListDomainData(ListDomainDataRequest) returns (ListDomainDataResponse);
-}
-
-message CreateDomainDataRequest {
- RequestHeader header = 1;
- // Optional, the domaindata_id would be generated by server if the domaindata_id is empty.
- // The unique identity of domaindata,it couldn't duplicate in the same domain.
- string domaindata_id = 2;
- // The human readable, it could duplicate in the domain.
- string name = 3;
- // Enum: table,model,rule,report,unknown
- string type = 4;
- // The relative_uri is relative to the datasource URI, The datasourceURI appends relative_uri is the domaindataURI.
- // e.g. the relative_uri is "train/table.csv"
- // the URI of datasource is "/home/data"
- // the URI of domaindata is "/home/data/train/table.csv"
- string relative_uri = 5;
- // Domain_id is the unique identity of the domain. the domaindata is belong to this domain.
- string domain_id = 6;
- // Optional, server would use default datasource if datasource_id is empty.
- // The datasource is where the domain is stored.
- string datasource_id = 7;
- // Optional, The attributes of the domaindata, this field use as a extra field, User could set
- // this field to any data what they need.
- map attributes = 8;
- // Optional, Partition not support now
- Partition partition = 9;
- // This field must be set if the type is 'table',
- // the columns describe the table's schema information.
- repeated DataColumn columns = 10;
- // Optional , The vendor is the one who outputs the domain data, it may be the SecretFlow engine,
- // another vendor's engine, or manually registered. it's could be manual, secretflow or other vendor string.
- string vendor = 11;
-}
-
-message CreateDomainDataResponse {
- Status status = 1;
- CreateDomainDataResponseData data = 2;
-}
-
-message CreateDomainDataResponseData {
- // id of created datasource
- string domaindata_id = 1;
-}
-
-// UpdateDomainDataRequest : The field would not be updated if the field not set in the UpdateDomainDataRequest
-// or the field is invalid.
-message UpdateDomainDataRequest {
- RequestHeader header = 1;
- // Mandatory, The domaindata_id indicate which domaindata would be updated.
- string domaindata_id = 2;
- // The human-readable name
- string name = 3;
- // Enum: table,model,rule,report,unknown
- string type = 4;
- // The relative_uri is relative to the datasource URI, The datasourceURI appends relative_uri is the domaindataURI.
- // e.g. the relative_uri is "train/table.csv"
- // the URI of datasource is "/home/data"
- // the URI of domaindata is "/home/data/train/table.csv"
- string relative_uri = 5;
- // Mandatory, The domain_id indicate which domain's domaindata would be updated.
- string domain_id = 6;
- // The datasource is where the domain is stored.
- string datasource_id = 7;
- // The attributes of the domaindata, this field use as a extra field, User could set
- // this field to any data that they need.
- map attributes = 8;
- // Partition not support now
- Partition partition = 9;
- // The columns describe the table's schema information.
- repeated DataColumn columns = 10;
- // The vendor is the one who outputs the domain data, it may be the SecretFlow engine,
- // another vendor's engine, or manually registered. it's could be manual, secretflow or other vendor string.
- string vendor = 11;
-}
-
-message UpdateDomainDataResponse {
- Status status = 1;
-}
-
-message DeleteDomainDataRequest {
- RequestHeader header = 1;
- // domaindata id
- string domain_id = 2;
- string domaindata_id = 3;
-}
-
-message DeleteDomainDataResponse {
- Status status = 1;
-}
-
-message QueryDomainDataRequest {
- RequestHeader header = 1;
- QueryDomainDataRequestData data = 2;
-}
-
-message QueryDomainDataResponse {
- Status status = 1;
- DomainData data = 2;
-}
-
-message QueryDomainDataRequestData {
- string domain_id = 1;
- string domaindata_id = 2;
-}
-
-message BatchQueryDomainDataRequest {
- RequestHeader header = 1;
- repeated QueryDomainDataRequestData data = 2;
-}
-
-message BatchQueryDomainDataResponse {
- Status status = 1;
- DomainDataList data = 2;
-}
-
-message ListDomainDataRequest {
- RequestHeader header = 1;
- ListDomainDataRequestData data = 2;
-}
-
-message ListDomainDataResponse {
- Status status = 1;
- DomainDataList data = 2;
-}
-
-message ListDomainDataRequestData {
- // couldn't be empty
- string domain_id = 1;
- // Optional, The domaindata_type would be use as the filter condition to list the domaindata.
- string domaindata_type = 2;
- // Optional, the domaindata_vendor would be use as the filter condition to list the domaindata.
- string domaindata_vendor = 3;
-}
-
-message DomainDataList {
- repeated DomainData domaindata_list = 1;
-}
-
-message DomainData {
- // domaindata_id is the identification of domaindata, it couldn't duplicate in the same domain.
- string domaindata_id = 1;
- // The human readable, it could duplicate in the domain.
- string name = 2;
- // DomainData type , Enum: table,model,rule,report,unknown
- string type = 3;
- // The relative_uri is relative to the datasource URI, The datasourceURI appends relative_uri is the domaindataURI.
- // e.g. the relative_uri is "train/table.csv"
- // the URI of datasource is "/home/data"
- // the URI of domaindata is "/home/data/train/table.csv"
- string relative_uri = 4;
- // domain_id the unique identity of the domain. the domaindata is belong to this domain.
- string domain_id = 5;
- // datasource_id is the identity of the domaindatasource, the domaindatasource that storage the domaindata file.
- string datasource_id = 6;
- // The attributes of the domaindata, this field use as a extra field, User could set
- // this field to any data that they need.
- map attributes = 7;
- // Partition not support now,
- Partition partition = 8;
- // This field must be set if the type is 'table',
- // The columns describe the table's schema information.
- repeated DataColumn columns = 9;
- // The vendor is the one who outputs the domain data, it may be the SecretFlow engine,
- // another vendor's engine, or manually registered. it's could be manual, secretflow or other vendor string.
- string vendor = 10;
- // The status of the domaindata , enum: Available,Unavailable
- string status = 11;
-}
\ No newline at end of file
diff --git a/proto/kuscia/proto/api/v1alpha1/kusciaapi/domaindatagrant.proto b/proto/kuscia/proto/api/v1alpha1/kusciaapi/domaindatagrant.proto
deleted file mode 100644
index 2f4bd1a..0000000
--- a/proto/kuscia/proto/api/v1alpha1/kusciaapi/domaindatagrant.proto
+++ /dev/null
@@ -1,164 +0,0 @@
-// 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.
-
-syntax = "proto3";
-
-package kuscia.proto.api.v1alpha1.kusciaapi;
-
-import "kuscia/proto/api/v1alpha1/common.proto";
-
-option go_package = "github.com/secretflow/kuscia/proto/api/v1alpha1/kusciaapi";
-option java_package = "org.secretflow.v1alpha1.kusciaapi";
-
-service DomainDataGrantService {
- rpc CreateDomainDataGrant(CreateDomainDataGrantRequest)
- returns (CreateDomainDataGrantResponse);
-
- rpc UpdateDomainDataGrant(UpdateDomainDataGrantRequest)
- returns (UpdateDomainDataGrantResponse);
-
- rpc DeleteDomainDataGrant(DeleteDomainDataGrantRequest)
- returns (DeleteDomainDataGrantResponse);
-
- rpc QueryDomainDataGrant(QueryDomainDataGrantRequest)
- returns (QueryDomainDataGrantResponse);
-
- rpc BatchQueryDomainDataGrant(BatchQueryDomainDataGrantRequest)
- returns (BatchQueryDomainDataGrantResponse);
-
- rpc ListDomainDataGrant(ListDomainDataGrantRequest)
- returns (ListDomainDataGrantResponse);
-}
-
-message CreateDomainDataGrantRequest {
- RequestHeader header = 1;
- string domaindatagrant_id = 2;
- string domaindata_id = 3;
- string grant_domain = 4;
- GrantLimit limit = 5;
- map description = 6;
- string signature = 7;
- string domain_id = 8;
-}
-
-message CreateDomainDataGrantResponse {
- Status status = 1;
- CreateDomainDataGrantResponseData data = 2;
-}
-
-message CreateDomainDataGrantResponseData {
- // id of created domaindatagrant
- string domaindatagrant_id = 1;
-}
-
-message DomainDataGrant {
- DomainDataGrantData data = 1;
- DomainDataGrantStatus status = 2;
-}
-
-message DomainDataGrantStatus {
- string phase = 1;
- string message = 2;
- repeated UseRecord records = 3;
-}
-
-message UseRecord {
- int64 use_time = 1;
- string grant_domain = 2;
- string componet = 3;
- string output = 4;
-}
-
-message DomainDataGrantData {
- string domaindatagrant_id = 1;
- string author = 2;
- string domaindata_id = 3;
- string grant_domain = 4;
- GrantLimit limit = 5;
- map description = 6;
- string signature = 7;
- string domain_id = 8;
-}
-
-message GrantLimit {
- int64 expiration_time = 1;
- int32 use_count = 2;
- string flow_id = 3;
- repeated string componets = 4;
- string initiator = 5;
- string input_config = 6;
-}
-
-message UpdateDomainDataGrantRequest {
- RequestHeader header = 1;
- string domaindatagrant_id = 2;
- string domaindata_id = 3;
- string grant_domain = 4;
- GrantLimit limit = 5;
- map description = 6;
- string signature = 7;
- string domain_id = 8;
-}
-
-message UpdateDomainDataGrantResponse { Status status = 1; }
-
-message DeleteDomainDataGrantRequest {
- RequestHeader header = 1;
- string domain_id = 2;
- string domaindatagrant_id = 3;
-}
-
-message DeleteDomainDataGrantResponse { Status status = 1; }
-
-message QueryDomainDataGrantRequestData {
- string domain_id = 1;
- string domaindatagrant_id = 2;
-}
-
-message QueryDomainDataGrantRequest {
- RequestHeader header = 1;
- QueryDomainDataGrantRequestData data = 2;
-}
-
-message QueryDomainDataGrantResponse {
- Status status = 1;
- DomainDataGrant data = 2;
-}
-
-message BatchQueryDomainDataGrantRequest {
- RequestHeader header = 1;
- repeated QueryDomainDataGrantRequestData data = 2;
-}
-
-message BatchQueryDomainDataGrantResponse {
- Status status = 1;
- repeated DomainDataGrant data = 2;
-}
-
-message ListDomainDataGrantRequest {
- RequestHeader header = 1;
- ListDomainDataGrantRequestData data = 2;
-}
-
-message ListDomainDataGrantRequestData {
- string domain_id = 1;
- string grant_domain = 2;
- string domaindata_vendor = 3;
-}
-
-message ListDomainDataGrantResponse {
- Status status = 1;
- DomainDataGrantList data = 2;
-}
-
-message DomainDataGrantList {
- repeated DomainDataGrant domaindatagrant_list = 1;
-}
\ No newline at end of file
diff --git a/proto/kuscia/proto/api/v1alpha1/kusciaapi/job.proto b/proto/kuscia/proto/api/v1alpha1/kusciaapi/job.proto
index 864cd44..8ff35cc 100644
--- a/proto/kuscia/proto/api/v1alpha1/kusciaapi/job.proto
+++ b/proto/kuscia/proto/api/v1alpha1/kusciaapi/job.proto
@@ -26,8 +26,6 @@ service JobService {
rpc QueryJob(QueryJobRequest) returns (QueryJobResponse);
- rpc QueryJobStatus(QueryJobRequest) returns (JobStatusResponse);
-
rpc BatchQueryJobStatus(BatchQueryJobStatusRequest) returns (BatchQueryJobStatusResponse);
rpc StopJob(StopJobRequest)returns (StopJobResponse);
@@ -35,6 +33,8 @@ service JobService {
rpc DeleteJob(DeleteJobRequest) returns (DeleteJobResponse);
rpc WatchJob(WatchJobRequest) returns (stream WatchJobEventResponse);
+
+ rpc ApproveJob(ApproveJobRequest) returns (ApproveJobResponse);
}
message CreateJobRequest {
@@ -43,6 +43,7 @@ message CreateJobRequest {
string initiator = 3; // 发起方
int32 max_parallelism = 4; // 并发度
repeated Task tasks = 5; // 任务参数
+ map custom_fields = 6; // 自定义参数
}
message CreateJobResponse {
@@ -113,6 +114,22 @@ message QueryJobResponseData {
int32 max_parallelism = 3;
repeated TaskConfig tasks = 4;
JobStatusDetail status = 5;
+ map custom_fields = 6;
+}
+
+message ApproveJobRequest {
+ string job_id = 1;
+ ApproveResult result = 2;
+ string reason = 3;
+}
+
+message ApproveJobResponse {
+ Status status = 1;
+ ApproveJobResponseData data = 2;
+}
+
+message ApproveJobResponseData {
+ string job_id = 1;
}
message JobStatusDetail {
@@ -122,6 +139,8 @@ message JobStatusDetail {
string start_time = 4;
string end_time = 5;
repeated TaskStatus tasks = 6;
+ repeated PartyStageStatus stage_status_list = 7;
+ repeated PartyApproveStatus approve_status_list = 8;
}
message TaskConfig {
@@ -134,6 +153,16 @@ message TaskConfig {
int32 priority = 7;
}
+message PartyStageStatus {
+ string domain_id = 1;
+ string state = 2;
+}
+
+message PartyApproveStatus {
+ string domain_id = 1;
+ string state = 2;
+}
+
message TaskStatus {
string task_id = 1;
string state = 2;
@@ -148,13 +177,25 @@ message PartyStatus {
string domain_id = 1;
string state = 2;
string err_msg = 3;
+ repeated JobPartyEndpoint endpoints = 4;
+ // repeated ApprovalDetail approval_details= 5;
+}
+
+enum State {
+ Unknown = 0;
+ Pending = 1;
+ Running = 2;
+ Succeeded = 3;
+ Failed = 4; // the job run failed
+ AwaitingApproval = 5; // await the partner to approval the job
+ ApprovalReject = 6; // partner reject the job
+ Cancelled = 7; // the job cannot start again when it was cancelled
}
-enum TaskState {
- Pending = 0;
- Running = 1;
- Succeeded = 2;
- Failed = 3;
+enum ApproveResult {
+ APPROVE_RESULT_UNKNOWN = 0;
+ APPROVE_RESULT_ACCEPT = 1;
+ APPROVE_RESULT_REJECT = 2;
}
message BatchQueryJobStatusRequest {
@@ -201,4 +242,14 @@ enum EventType {
MODIFIED = 1;
DELETED = 2;
ERROR = 3;
+ HEARTBEAT = 4;
+}
+
+message JobPartyEndpoint {
+ // service port name which defined in AppImage container port.
+ string port_name = 1;
+ // service scope which defined in AppImage container port.
+ string scope = 2;
+ // service access address.
+ string endpoint = 3;
}
diff --git a/proto/secretflow/protos/audit/vote_invite.proto b/proto/secretflow/protos/audit/vote_invite.proto
deleted file mode 100644
index 8243c05..0000000
--- a/proto/secretflow/protos/audit/vote_invite.proto
+++ /dev/null
@@ -1,43 +0,0 @@
-// Copyright 2023 Ant Group Co., Ltd.
-//
-// 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.
-
-syntax = "proto3";
-
-package secretflow.audit;
-
-option java_package = "org.secretflow.proto.audit";
-
-
-enum Action {
- APPROVE = 0;
- REJECT = 1;
-}
-message VoteInvite {
- //unique vote id
- string vote_request_id = 1;
-
- //participant
- string voter = 2;
-
- Action action = 3;
-
- string cert_chain = 4;
-
- //from 1~4 base64
- string body = 5;
-
- //signature for 5;
- string voter_signature = 6;
-
-}
diff --git a/proto/secretflow/protos/audit/vote_request.proto b/proto/secretflow/protos/audit/vote_request.proto
deleted file mode 100644
index 457c359..0000000
--- a/proto/secretflow/protos/audit/vote_request.proto
+++ /dev/null
@@ -1,64 +0,0 @@
-// Copyright 2023 Ant Group Co., Ltd.
-//
-// 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.
-
-syntax = "proto3";
-
-package secretflow.audit;
-
-option java_package = "org.secretflow.proto.audit";
-
-
-enum VoteType {
- TEE_DOWNLOAD = 0;
- NODE_ROUTE = 1;
-}
-
-message VoteRequest {
- //unique vote id
- string vote_request_id = 1;
-
- //vote type
- VoteType type = 2;
-
- //vote initiator
- string initiator = 3;
-
- //vote_counter
- string vote_counter = 4;
-
- //vote participants
- repeated string voters = 5;
-
- //executors
- repeated string executors = 6;
-
- //approved_threshold
- uint32 approved_threshold = 7;
-
- //approved_action
- string approved_action = 8;
-
- //rejected_action
- string rejected_action = 9;
-
- //cert_chain
- string cert_chain = 10;
-
- //bas464 from 1~10
- string body = 11;
-
- //signature for 11
- string vote_request_signature = 12;
-
-}
\ No newline at end of file
diff --git a/proto/secretflow/protos/audit/vote_result.proto b/proto/secretflow/protos/audit/vote_result.proto
deleted file mode 100644
index a3d22cb..0000000
--- a/proto/secretflow/protos/audit/vote_result.proto
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright 2023 Ant Group Co., Ltd.
-//
-// 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.
-
-syntax = "proto3";
-
-package secretflow.audit;
-
-import "secretflow/protos/audit/vote_request.proto";
-import "secretflow/protos/audit/vote_invite.proto";
-
-option java_package = "org.secretflow.proto.audit";
-
-message VoteResult {
- VoteRequest vote_request = 1;
- repeated VoteInvite vote_invite = 2;
-}
diff --git a/proto/secretflow/protos/component/cluster.proto b/proto/secretflow/protos/component/cluster.proto
deleted file mode 100644
index 5f682ca..0000000
--- a/proto/secretflow/protos/component/cluster.proto
+++ /dev/null
@@ -1,126 +0,0 @@
-// Copyright 2023 Ant Group Co., Ltd.
-//
-// 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.
-
-syntax = "proto3";
-
-package secretflow.component;
-
-option java_package = "org.secretflow.proto.component";
-
-// Description of a SecretFlow cluster, including:
-// - version info
-// - parties: who participate in the computation.
-// - secret devices and their configs: security levels.
-message SFClusterDesc {
- // SecretFlow version.
- string sf_version = 1;
-
- // Python version.
- string py_version = 2;
-
- // Joined entities.
- // e.g. [CompanyA, CompanyB]
- repeated string parties = 3;
-
- // Description for a secret device.
- // PYUs do not need to claim.
- message DeviceDesc {
- // Name of the device.
- string name = 1;
-
- // Supported: SPU, HEU, TEEU
- string type = 2;
-
- // Parties of device.
- repeated string parties = 3;
-
- // Specific config for the secret device.
- string config = 4;
- }
-
- // Description of secret devices
- repeated DeviceDesc devices = 4;
-
- message RayFedConfig {
- // Indicates communication backend of RayFed.
- // Accepted: 'grpc', 'brpc_link'
- // Dafault is 'grpc'
- string cross_silo_comm_backend = 1;
- }
-
- RayFedConfig ray_fed_config = 5;
-}
-
-// A StorageConfig is the root for all data for one party.
-// For security reasons, you have to put the a JSON format of config at
-// .sf_storage file at each node for each party in production.
-message StorageConfig {
- // supported: local_fs
- string type = 1;
-
- message LocalFSConfig {
- // working directory
- string wd = 1;
- }
- // local_fs
- LocalFSConfig local_fs = 2;
-}
-
-// Runtime Config for a SecretFlow cluster.
-message SFClusterConfig {
- // Contains addresses for a RayFed cluster.
- // Each party should own an address.
- // Only for production mode.
- message RayFedConfig {
- repeated string parties = 1;
-
- repeated string addresses = 2;
-
- repeated string listen_addresses = 3;
- }
-
- // Contains addresses for a SPU device.
- message SPUConfig {
- string name = 1;
-
- repeated string parties = 2;
-
- repeated string addresses = 3;
-
- repeated string listen_addresses = 4;
- }
-
- // Public and shared to all parties.
- message PublicConfig {
- RayFedConfig rayfed_config = 1;
-
- repeated SPUConfig spu_configs = 2;
- }
-
- // Different for each party.
- // For production mode only.
- message PrivateConfig {
- string self_party = 1;
-
- string ray_head_addr = 2;
-
- StorageConfig storage_config = 3;
- }
-
- SFClusterDesc desc = 1;
-
- PublicConfig public_config = 2;
-
- PrivateConfig private_config = 3;
-}
diff --git a/proto/secretflow/protos/component/comp.proto b/proto/secretflow/protos/component/comp.proto
deleted file mode 100644
index 7851c67..0000000
--- a/proto/secretflow/protos/component/comp.proto
+++ /dev/null
@@ -1,203 +0,0 @@
-// Copyright 2023 Ant Group Co., Ltd.
-//
-// 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.
-//
-
-syntax = "proto3";
-
-package secretflow.component;
-
-option java_package = "org.secretflow.proto.component";
-
-// Different types of attributes.
-enum AttrType {
- // Atomic types
- AT_UNDEFINED = 0;
- AT_FLOAT = 1;
- AT_INT = 2;
- AT_STRING = 3;
- AT_BOOL = 4;
-
- AT_FLOATS = 5;
- AT_INTS = 6;
- AT_STRINGS = 7;
- AT_BOOLS = 8;
-
- // Special types
- AT_STRUCT_GROUP = 9;
- AT_UNION_GROUP = 10;
- AT_SF_TABLE_COL = 11;
-}
-
-// The value of a attribute
-message Attribute {
- float f = 1; // FLOAT
- // NOTE(junfeng): "is" is preserved by Python. Replaced with "i64".
- int64 i64 = 2; // INT
- string s = 3; // STRING
- bool b = 4; // BOOL
-
- // lists
- repeated float fs = 5; // FLOATS
- repeated int64 i64s = 6; // INTS
- repeated string ss = 7; // STRINGS
- repeated bool bs = 8; // BOOLS
-
- // indicates the value is missing explicitly.
- bool is_na = 9;
-}
-
-// Describe a attribute.
-message AttributeDef {
- // indicates the ancestors of a node,
- // e.g. [name_a, name_b, name_c] means the path prefixes of current Attribute
- // is name_a/name_b/name_c/
- // only ^[a-zA-Z0-9_.-]*$ is allowed.
- // "input" and "output" are reserved.
- repeated string prefixes = 1;
-
- // must be uniqe in the same level just like linux file systems.
- // only ^[a-zA-Z0-9_.-]*$ is allowed.
- // "input" and "output" are reserved.
- string name = 2;
-
- string desc = 3;
-
- AttrType type = 4;
-
- // Extras for a atomic attribute.
- message AtomicAttrDesc {
- // Only valid when type is {FLOATS, INTS, STRINGS, BOOLS}
- int64 list_min_length_inclusive = 1;
- int64 list_max_length_inclusive = 2;
-
- bool is_optional = 3;
- // A reasonable default for this attribute if the user does not supply a
- // value.
- Attribute default_value = 4;
-
- // Only valid when type is {FLOAT, INT, STRING, FLOATS, INTS, STRINGS}
- // Please use list fields of AtomicParameter, i.e. ss, i64s, fs
- // If type is list, allowed_values is applied to each element.
- Attribute allowed_values = 5;
-
- // Only valid when type is {FLOAT, INT, FLOATS, INTS}
- // If type is list, allowed_values is applied to each element.
- bool has_lower_bound = 6;
- Attribute lower_bound = 7;
- bool lower_bound_inclusive = 8;
- bool has_upper_bound = 9;
- Attribute upper_bound = 10;
- bool upper_bound_inclusive = 11;
- }
-
- // required for ATOMIC
- AtomicAttrDesc atomic = 5;
-
- // Extras for union attribute group.
- message UnionAttrGroupDesc {
- // name of default selected child.
- string default_selection = 1;
- }
-
- // required for UNION
- UnionAttrGroupDesc union = 6;
-}
-
-// Define an input/output for component
-message IoDef {
- // should be unique among all IOs.
- string name = 1;
-
- string desc = 2;
-
- // Multiple types are accepted.
- // Please check DistData in data.proto
- repeated string types = 3;
-
- // An extra attribute for a table
- // If provided in a IoDef, e.g.
- // {
- // "name": "feature",
- // "types": [
- // "int",
- // "float"
- // ],
- // "col_min_cnt_inclusive": 1,
- // "col_max_cnt": 3,
- // "attrs": [
- // {
- // "name": "bucket_size",
- // "type": "AT_INT"
- // }
- // ]
- // }
- // means after a user provide a table as IO, they should also specify
- // cols as "feature"
- // - col_min_cnt_inclusive is 1: At least 1 col to be selected
- // - col_max_cnt_inclusive is 3: At most 3 cols to be selected.
- // And afterwards, user have to fill an int attribute called bucket_size for
- // each selected cols.
- message TableAttrDef {
- // unique among all attributes for the table.
- string name = 1;
-
- string desc = 2;
-
- // accepted col data types.
- // Please check DistData.VerticalTable in data.proto
- repeated string types = 3;
-
- // inclusive
- int64 col_min_cnt_inclusive = 4;
- int64 col_max_cnt_inclusive = 5;
-
- // extra attribute for specified col.
- repeated AttributeDef attrs = 6;
- }
-
- // only valid for tables.
- // The attribute path is "{input|output}/{IoDef name}/{TableAttrDef name}"
- repeated TableAttrDef attrs = 4;
-}
-
-// The definition of a comp.
-message ComponentDef {
- // namespace of the comp.
- string domain = 1;
-
- // should be unique among all comps of the same domain.
- string name = 2;
-
- string desc = 3;
-
- // version of the comp.
- string version = 4;
-
- repeated AttributeDef attrs = 5;
-
- repeated IoDef inputs = 6;
-
- repeated IoDef outputs = 7;
-}
-
-// A list of component
-message CompListDef {
- string name = 1;
-
- string desc = 2;
-
- string version = 3;
-
- repeated ComponentDef comps = 4;
-}
diff --git a/proto/secretflow/protos/component/data.proto b/proto/secretflow/protos/component/data.proto
index b81f7e3..b516ca5 100644
--- a/proto/secretflow/protos/component/data.proto
+++ b/proto/secretflow/protos/component/data.proto
@@ -17,7 +17,6 @@ syntax = "proto3";
package secretflow.component;
import "google/protobuf/any.proto";
-import "secretflow/protos/component/cluster.proto";
option java_package = "org.secretflow.proto.component";
@@ -28,8 +27,6 @@ message SystemInfo {
// Supported: Secretflow
string app_name = 1;
- // Only valid when app_name is Secretflow.
- SFClusterDesc secretflow = 2;
// SCQL, GRM related meta information should be here.
// You can add more field here, when a new type of application is added.
diff --git a/proto/secretflow/protos/component/evaluation.proto b/proto/secretflow/protos/component/evaluation.proto
deleted file mode 100644
index c1d5b1e..0000000
--- a/proto/secretflow/protos/component/evaluation.proto
+++ /dev/null
@@ -1,53 +0,0 @@
-// Copyright 2023 Ant Group Co., Ltd.
-//
-// 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.
-
-syntax = "proto3";
-
-package secretflow.component;
-
-import "secretflow/protos/component/comp.proto";
-import "secretflow/protos/component/data.proto";
-
-option java_package = "org.secretflow.proto.component";
-
-// Evaluate a node.
-// evaluate(NodeEvalParam param, SFClusterConfig sf_config) -> NodeEvalResult
-// NodeEvalParam contains all the information to evaluate a component.
-message NodeEvalParam {
- // domain of component
- string domain = 1;
-
- // name of component
- string name = 2;
-
- // version of component
- string version = 3;
-
- // The attribute value.
- repeated string attr_paths = 4;
-
- repeated Attribute attrs = 5;
-
- // The input values
- // NOTE: name of DistData doesn't need to match name of input in Comp
- // definition.
- repeated DistData inputs = 6;
-
- repeated string output_uris = 7;
-}
-
-message NodeEvalResult {
- // Output values.
- repeated DistData outputs = 1;
-}
diff --git a/proto/secretflow/protos/component/report.proto b/proto/secretflow/protos/component/report.proto
deleted file mode 100644
index 93eaaf2..0000000
--- a/proto/secretflow/protos/component/report.proto
+++ /dev/null
@@ -1,115 +0,0 @@
-// Copyright 2023 Ant Group Co., Ltd.
-//
-// 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.
-
-syntax = "proto3";
-
-package secretflow.component;
-
-import "secretflow/protos/component/comp.proto";
-
-option java_package = "org.secretflow.proto.component";
-
-// Displays multiple read-only fields in groups.
-message Descriptions {
- message Item {
- // Name of the field.
- string name = 1;
-
- string desc = 2;
-
- AttrType type = 3;
-
- Attribute value = 4;
- }
-
- // Name of the group.
- string name = 1;
-
- string desc = 2;
-
- repeated Item items = 3;
-}
-
-// Displays rows of data.
-message Table {
- message HeaderItem {
- string name = 1;
-
- string desc = 2;
-
- AttrType type = 3;
- }
-
- message Row {
- string name = 1;
-
- string desc = 2;
-
- repeated Attribute items = 3;
- }
-
- // Name of the table
- string name = 1;
-
- string desc = 2;
-
- repeated HeaderItem headers = 3;
-
- repeated Row rows = 4;
-}
-
-// A division or a section of the page
-message Div {
- message Child {
- // supported: descriptions, table, div
- string type = 1;
-
- Descriptions descriptions = 2;
-
- Table table = 3;
-
- Div div = 4;
- }
-
- // Name of the Div
- string name = 1;
-
- string desc = 2;
-
- repeated Child children = 3;
-}
-
-// A page of report.
-message Tab {
- // Name of the tab.
- string name = 1;
-
- string desc = 2;
-
- repeated Div divs = 3;
-}
-
-message Report {
- // Name of the report.
- string name = 1;
-
- string desc = 2;
-
- repeated Tab tabs = 3;
-
- int32 err_code = 4;
-
- // err detail (json encoded message, structed error detail)
- string err_detail = 5;
-}
diff --git a/proto/secretflow/protos/kuscia/task_config.proto b/proto/secretflow/protos/kuscia/task_config.proto
deleted file mode 100644
index 187af57..0000000
--- a/proto/secretflow/protos/kuscia/task_config.proto
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright 2023 Ant Group Co., Ltd.
-//
-// 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.
-
-syntax = "proto3";
-
-package secretflow.kuscia;
-
-option java_package = "org.secretflow.proto.kuscia";
-
-import "secretflow/protos/component/cluster.proto";
-import "secretflow/protos/pipeline/pipeline.proto";
-import "secretflow/protos/pipeline/task_config.proto";
-
-message TaskInputConfig {
- map sf_datasource_config = 1;
- secretflow.component.SFClusterDesc sf_cluster_desc = 2;
- secretflow.pipeline.NodeDef sf_node_eval_param = 3;
- repeated string sf_output_uris = 4;
- repeated string sf_input_ids = 5;
- repeated string sf_output_ids = 6;
- secretflow.pipeline.TaskConfig tee_task_config = 7 [json_name = "tee_task_config"];
-}
-
-message DatasourceConfig {
- string id = 1;
-}
\ No newline at end of file
diff --git a/proto/secretflow/protos/kuscia/tee_task_config.proto b/proto/secretflow/protos/kuscia/tee_task_config.proto
deleted file mode 100644
index 70fd3f4..0000000
--- a/proto/secretflow/protos/kuscia/tee_task_config.proto
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright 2023 Ant Group Co., Ltd.
-//
-// 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.
-
-syntax = "proto3";
-
-package secretflow.kuscia.tee;
-
-option java_package = "org.secretflow.proto.kuscia.tee";
-
-import "secretflow/protos/pipeline/tee/tee_pipeline.proto";
-import "secretflow/protos/pipeline/task_config.proto";
-
-message TeeTaskInputConfig {
- map sf_datasource_config = 1;
- secretflow.pipeline.tee.NodeDef sf_node_eval_param = 2;
- repeated string sf_output_uris = 3;
- repeated string sf_input_ids = 4;
- repeated string sf_output_ids = 5;
- secretflow.pipeline.TaskConfig tee_task_config = 6 [json_name = "tee_task_config"];
-}
-
-message DatasourceConfig {
- string id = 1;
-}
\ No newline at end of file
diff --git a/proto/secretflow/protos/pipeline/pipeline.proto b/proto/secretflow/protos/pipeline/pipeline.proto
deleted file mode 100644
index 59d8a12..0000000
--- a/proto/secretflow/protos/pipeline/pipeline.proto
+++ /dev/null
@@ -1,98 +0,0 @@
-// Copyright 2023 Ant Group Co., Ltd.
-//
-// 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.
-
-syntax = "proto3";
-
-package secretflow.pipeline;
-
-option java_package = "org.secretflow.proto.pipeline";
-
-import "secretflow/protos/component/comp.proto";
-import "secretflow/protos/component/data.proto";
-
-
-// A node is a building block of a DAG, nodes and edges together forms a DAG.
-// similar to NodeEvalParam except IO are ids.
-message NodeDef {
- // id of this node, unique per-pipeline.
- string id = 1;
-
- // domain of component
- string domain = 2;
-
- // name of component
- string name = 3;
-
- // version of component
- string version = 4;
-
- // The attribute value.
- repeated string attr_paths = 5;
-
- repeated secretflow.component.Attribute attrs = 6;
-
- repeated secretflow.component.DistData inputs = 7;
-
- repeated string output_uris = 8;
-}
-
-// The pipeline(DAG) definition.
-message PipelineDef {
- // The id of this pipeline.
- // Must match the regexp "[A-Za-z0-9.][A-Za-z0-9_>./]*".
- string id = 1;
-
- // The node definitions.
- repeated NodeDef nodes = 2;
-}
-
-enum State {
- // The default state.
- Staging = 0;
-
- // For a node, it is connected and the schema is inferenced.
- // For a pipeline, it is about to run.
- Initialized = 1;
-
- // For a node, it is fired and still running by the backend.
- // For a pipeline, at least one of its nodes is still running.
- Running = 2;
-
- // Finished, succeed.
- Succeed = 3;
-
- // Finished, failed.
- Failed = 4;
-}
-
-message NodeState {
- // A id of this node, unique within a single DAG.
- // Must match the regexp "[A-Za-z0-9.][A-Za-z0-9_>./]*".
- string id = 1;
-
- // The state of this node.
- State state = 2;
-}
-
-message PipelineState {
- // The id of this pipeline.
- // Must match the regexp "[A-Za-z0-9.][A-Za-z0-9_>./]*".
- string id = 1;
-
- // The state of this node.
- State state = 2;
-
- // The node states.
- repeated NodeState nodes = 3;
-}
diff --git a/proto/secretflow/protos/pipeline/task_config.proto b/proto/secretflow/protos/pipeline/task_config.proto
deleted file mode 100644
index 9f8ba35..0000000
--- a/proto/secretflow/protos/pipeline/task_config.proto
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright 2023 Ant Group Co., Ltd.
-//
-// 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.
-
-syntax = "proto3";
-
-package secretflow.pipeline;
-
-option java_package = "org.secretflow.proto.pipeline";
-
-message TaskConfig {
- // 任务发起者的 id
- string task_initiator_id = 1 [json_name = "task_initiator_id"];
- // 授权的范围
- // kuscia模式填写 {project_id}
- // local模式填写 "default"
- string scope = 2 [json_name = "scope"];
- // 任务内容,比如 NodeEvalParam
- // base64格式
- string task_body = 3 [json_name = "task_body"];
-
- // 任务发起者使用私钥对 task_initiator_id || . || scope || . || task_body 的签名
- string signature = 20 [json_name = "signature"];
-
- // 签名算法
- // * RS256: RSASSA-PKCS1-v1_5 using SHA-256
- // * ES256: ECDSA using P-256 and SHA-256
- string sign_algorithm = 21 [json_name = "sign_algorithm"];
-
- // PEM格式的任务发起者多级证书,根证书位于最后,从后往前逐个验证
- repeated string task_initiator_certs = 22 [json_name = "task_initiator_certs"];
-
- // capsule manager service
- string capsule_manager_endpoint = 23
- [json_name = "capsule_manager_endpoint"];
-}
\ No newline at end of file
diff --git a/proto/secretflow/protos/pipeline/tee/tee_pipeline.proto b/proto/secretflow/protos/pipeline/tee/tee_pipeline.proto
deleted file mode 100644
index e1959fb..0000000
--- a/proto/secretflow/protos/pipeline/tee/tee_pipeline.proto
+++ /dev/null
@@ -1,98 +0,0 @@
-// Copyright 2023 Ant Group Co., Ltd.
-//
-// 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.
-
-syntax = "proto3";
-
-package secretflow.pipeline.tee;
-
-option java_package = "org.secretflow.proto.pipeline.tee";
-
-import "opensecretflow/spec/v1/component.proto";
-import "opensecretflow/spec/v1/data.proto";
-
-
-// A node is a building block of a DAG, nodes and edges together forms a DAG.
-// similar to NodeEvalParam except IO are ids.
-message NodeDef {
- // id of this node, unique per-pipeline.
- string id = 1;
-
- // domain of component
- string domain = 2;
-
- // name of component
- string name = 3;
-
- // version of component
- string version = 4;
-
- // The attribute value.
- repeated string attr_paths = 5;
-
- repeated opensecretflow.spec.v1.Attribute attrs = 6;
-
- repeated opensecretflow.spec.v1.DistData inputs = 7;
-
- repeated string output_uris = 8;
-}
-
-// The pipeline(DAG) definition.
-message PipelineDef {
- // The id of this pipeline.
- // Must match the regexp "[A-Za-z0-9.][A-Za-z0-9_>./]*".
- string id = 1;
-
- // The node definitions.
- repeated NodeDef nodes = 2;
-}
-
-enum State {
- // The default state.
- Staging = 0;
-
- // For a node, it is connected and the schema is inferenced.
- // For a pipeline, it is about to run.
- Initialized = 1;
-
- // For a node, it is fired and still running by the backend.
- // For a pipeline, at least one of its nodes is still running.
- Running = 2;
-
- // Finished, succeed.
- Succeed = 3;
-
- // Finished, failed.
- Failed = 4;
-}
-
-message NodeState {
- // A id of this node, unique within a single DAG.
- // Must match the regexp "[A-Za-z0-9.][A-Za-z0-9_>./]*".
- string id = 1;
-
- // The state of this node.
- State state = 2;
-}
-
-message PipelineState {
- // The id of this pipeline.
- // Must match the regexp "[A-Za-z0-9.][A-Za-z0-9_>./]*".
- string id = 1;
-
- // The state of this node.
- State state = 2;
-
- // The node states.
- repeated NodeState nodes = 3;
-}
diff --git a/scripts/build.sh b/scripts/build.sh
index b106272..563596a 100755
--- a/scripts/build.sh
+++ b/scripts/build.sh
@@ -17,20 +17,23 @@
set -e
WITH_FRONTEND_FLAG=$1
+FRONTEND_TAG=$2
if [[ $WITH_FRONTEND_FLAG == "" ]]; then
WITH_FRONTEND_FLAG=false
fi
if [[ $WITH_FRONTEND_FLAG == true ]]; then
+ if [ "${FRONTEND_TAG}" == "" ]; then
+ FRONTEND_TAG=$(git ls-remote --sort='version:refname' --tags https://github.com/secretflow/easy-psi-frontend.git | tail -n1 | sed 's/.*\///')
+ fi
ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)
- FRONTEND_LATEST_TAG=$(git ls-remote --sort='version:refname' --tags https://github.com/secretflow/secretpad-frontend.git | tail -n1 | sed 's/.*\///')
WORK_DIR="./tmp/frontend"
mkdir -p $WORK_DIR
- wget -O $WORK_DIR/frontend.tar https://github.com/secretflow/secretpad-frontend/releases/download/"${FRONTEND_LATEST_TAG}"/"${FRONTEND_LATEST_TAG}".tar
- tar -xvf $WORK_DIR/frontend.tar -C ${WORK_DIR} --strip-components=1
+ wget -O $WORK_DIR/frontend.tar https://github.com/secretflow/easypsi-frontend/releases/download/"${FRONTEND_TAG}"/"${FRONTEND_TAG}".tar
+ tar -xvf $WORK_DIR/frontend.tar -C ${WORK_DIR} --strip-components=1
DIST_DIR="$WORK_DIR/apps/platform/dist"
- TARGET_DIR="${ROOT}/secretpad-web/src/main/resources/static"
+ TARGET_DIR="${ROOT}/easypsi-web/src/main/resources/static"
mkdir -p "${TARGET_DIR}"
cp -rpf $DIST_DIR/* "${TARGET_DIR}"
rm -rf "$WORK_DIR"
diff --git a/scripts/build_fatimage.sh b/scripts/build_fatimage.sh
new file mode 100755
index 0000000..36e7359
--- /dev/null
+++ b/scripts/build_fatimage.sh
@@ -0,0 +1,61 @@
+#!/bin/bash
+#
+# Copyright 2024 Ant Group Co., Ltd.
+#
+# 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.
+#
+set -e
+
+export SECRETFLOW_IMAGE=secretflow-registry.cn-hangzhou.cr.aliyuncs.com/secretflow/psi-anolis8:0.3.0beta
+export KUSCIA_IMAGE=secretflow/kuscia:0.6.0b0
+
+# Verify
+if [[ ${SECRETFLOW_IMAGE} == "" ]]; then
+ printf "empty SECRETFLOW_IMAGE\n" >&2
+ exit 1
+fi
+
+if [[ ${KUSCIA_IMAGE} == "" ]]; then
+ printf "empty KUSCIA_IMAGE\n" >&2
+ exit 1
+fi
+
+
+CURRENT_DIR=$(cd $(dirname $0); pwd)
+PRJ_ROOT_DIR=${CURRENT_DIR}/..
+PRJ_TARGET_DIR=${PRJ_ROOT_DIR}/target
+mkdir -p $PRJ_TARGET_DIR
+
+cd $PRJ_ROOT_DIR
+./scripts/build.sh false
+
+# gen image name
+DATETIME=$(date +"%Y%m%d%H%M%S")
+git fetch --tags
+VERSION_TAG="$(git describe --tags)"
+commit_id=$(git log -n 1 --pretty=oneline | awk '{print $1}' | cut -b 1-6)
+echo "$commit_id"
+tag=${VERSION_TAG}-${DATETIME}-"${commit_id}"
+local_image=easypsi:$tag
+echo "local_image: ${local_image}"
+
+# gen sf tar
+docker pull ${SECRETFLOW_IMAGE}
+docker save ${SECRETFLOW_IMAGE} -o ${PRJ_TARGET_DIR}/secretflow.tar
+
+# build pad image
+docker build --build-arg KUSCIA_IMAGE_NAME=${KUSCIA_IMAGE} --build-arg EASYPSI_IMAGE_NAME=${local_image} --build-arg SECRETFLOW_IMAGE_NAME=${SECRETFLOW_IMAGE} -f ./build/Dockerfiles/fatimage.Dockerfile --platform linux/amd64 -t "$local_image" .
+# push image
+
+
+export EASYPSI_FAT_IMAGE=${local_image}
diff --git a/scripts/build_image.sh b/scripts/build_image.sh
index badec30..2710a47 100755
--- a/scripts/build_image.sh
+++ b/scripts/build_image.sh
@@ -24,6 +24,6 @@ git fetch --tags
VERSION_TAG="$(git describe --tags)"
commit_id=$(git log -n 1 --pretty=oneline | awk '{print $1}' | cut -b 1-6)
tag=${VERSION_TAG}-${DATETIME}-"${commit_id}"
-local_image=secretpad:$tag
+local_image=easypsi:$tag
echo "$commit_id"
docker build -f ./build/Dockerfiles/anolis.Dockerfile --platform linux/amd64 -t "$local_image" .
diff --git a/scripts/ci/merge_test.sh b/scripts/ci/merge_test.sh
new file mode 100644
index 0000000..ffa9b1d
--- /dev/null
+++ b/scripts/ci/merge_test.sh
@@ -0,0 +1,45 @@
+#!/bin/bash
+#
+# Copyright 2023 Ant Group Co., Ltd.
+#
+# 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.
+#
+set -e
+
+EASYPSI_ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../.." && pwd )"
+
+echo "root path : ${EASYPSI_ROOT_DIR}"
+
+rm -rf "${EASYPSI_ROOT_DIR}"/surefire-report
+mkdir -p "${EASYPSI_ROOT_DIR}"/surefire-report
+
+#cp "${EASYPSI_ROOT_DIR}"/easypsi-api/client-java-kusciaapi/target/surefire-reports/*.xml "${EASYPSI_ROOT_DIR}"/surefire-report/>/dev/null || :
+cp "${EASYPSI_ROOT_DIR}"/easypsi-api/client-java-easypsi/target/surefire-reports/*.xml "${EASYPSI_ROOT_DIR}"/surefire-report/>/dev/null || :
+cp "${EASYPSI_ROOT_DIR}"/easypsi-common/target/surefire-reports/*.xml "${EASYPSI_ROOT_DIR}"/surefire-report/>/dev/null || :
+cp "${EASYPSI_ROOT_DIR}"/easypsi-manager/target/surefire-reports/*.xml "${EASYPSI_ROOT_DIR}"/surefire-report/>/dev/null || :
+cp "${EASYPSI_ROOT_DIR}"/easypsi-persistence/target/surefire-reports/*.xml "${EASYPSI_ROOT_DIR}"/surefire-report/>/dev/null || :
+cp "${EASYPSI_ROOT_DIR}"/easypsi-service/target/surefire-reports/*.xml "${EASYPSI_ROOT_DIR}"/surefire-report/>/dev/null || :
+cp "${EASYPSI_ROOT_DIR}"/easypsi-web/target/surefire-reports/*.xml "${EASYPSI_ROOT_DIR}"/surefire-report/>/dev/null || :
+
+touch "${EASYPSI_ROOT_DIR}"/easypsi-test/TEST-all.xml
+echo '' > "${EASYPSI_ROOT_DIR}"/easypsi-test/TEST-all.xml
+
+for file in "${EASYPSI_ROOT_DIR}"/surefire-report/*
+do
+ if test -f $file
+ then
+ echo `tail -n +2 $file` >> ${EASYPSI_ROOT_DIR}/easypsi-test/TEST-all.xml
+ fi
+done
+echo ' ' >> "${EASYPSI_ROOT_DIR}"/easypsi-test/TEST-all.xml
+rm -rf "${EASYPSI_ROOT_DIR}"/surefire-report
\ No newline at end of file
diff --git a/scripts/fatimage/entrypoint_command.sh b/scripts/fatimage/entrypoint_command.sh
new file mode 100644
index 0000000..2741ca1
--- /dev/null
+++ b/scripts/fatimage/entrypoint_command.sh
@@ -0,0 +1,214 @@
+#!/bin/bash
+#
+# Copyright 2024 Ant Group Co., Ltd.
+#
+# 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.
+#
+
+set -e
+GREEN='\033[0;32m'
+NC='\033[0m'
+
+function log() {
+ local log_content=$1
+ echo -e "${GREEN}${log_content}${NC}"
+}
+
+log "KUSCIA_PROTOCOL=${KUSCIA_PROTOCOL}"
+KUSCIA_WORKDIR=/home/kuscia
+PAD_WORKDIR=/app
+CTR_CERT_ROOT=${KUSCIA_WORKDIR}/var/certs
+EASYPSI_PASSWORD=
+
+
+ # random uppercase letters
+function get_uppercase_letter() {
+ letters="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ echo -n ${letters:$(( RANDOM % ${#letters} )):1}
+}
+
+ # random lowercase letters
+function get_lowercase_letter() {
+ letters="abcdefghijklmnopqrstuvwxyz"
+ echo -n ${letters:$(( RANDOM % ${#letters} )):1}
+}
+
+# random numbers
+function get_number() {
+ numbers="0123456789"
+ echo -n ${numbers:$(( RANDOM % ${#numbers} )):1}
+}
+
+# random special characters
+get_special_character() {
+ characters="!@#$%^&*()_+-=:;<>?,."
+ echo -n ${characters:$(( RANDOM % ${#characters} )):1}
+}
+
+# random fixed length password
+function generate_password() {
+ length=$1
+ random_password=""
+ while [ ${#random_password} -lt $length ]; do
+ random_password+="$(get_uppercase_letter)"
+ random_password+="$(get_lowercase_letter)"
+ random_password+="$(get_number)"
+ random_password+="$(get_special_character)"
+ done
+ echo "${random_password:0:$length}"
+}
+
+EASYPSI_PASSWORD=$(generate_password 10)
+
+function do_http_probe() {
+ local endpoint=$1
+ local max_retry=$2
+ local retry=0
+ while [ $retry -lt $max_retry ]; do
+ local status_code
+ # TODO support MTLS
+ status_code=$(curl -k --write-out '%{http_code}' --silent --output /dev/null ${endpoint})
+ if [[ $status_code -eq 200 || $status_code -eq 404 || $status_code -eq 401 ]]; then
+ return 0
+ fi
+ retry=$((retry + 1))
+ log "check kuscia status: ${status_code}. times: ${retry}"
+ sleep 2
+ done
+
+ return 1
+}
+
+function probe_kuscia() {
+ if ! do_http_probe "http://127.0.0.1:80" 60; then
+ echo "[Error] Probe kuscia is not running. Please check the log" >&2
+ exit 1
+ fi
+}
+
+
+function start_kuscia() {
+ pushd ${KUSCIA_WORKDIR}
+ log "start kuscia..."
+ bin/kuscia start -c etc/conf/kuscia.yaml &
+ log "check kuscia status..."
+ probe_kuscia
+ popd
+}
+
+
+function create_secretflow_app_image() {
+ local image_repo=$SECRETFLOW_IMAGE
+ local image_tag=latest
+
+ if [[ "${SECRETFLOW_IMAGE}" == *":"* ]]; then
+ image_repo=${SECRETFLOW_IMAGE%%:*}
+ image_tag=${SECRETFLOW_IMAGE##*:}
+ fi
+
+ app_type=$(echo "${image_repo}" | awk -F'/' '{print $NF}' | awk -F'-' '{print $1}')
+ if [[ ${app_type} == "" ]]; then
+ app_type="secretflow"
+ fi
+
+ scripts/deploy/create_sf_app_image.sh "${image_repo}" "${image_tag}" "${app_type}" "${SF_IMAGE_ID}"
+ log "Create secretflow app image done"
+}
+
+function copy_kuscia_api_client_certs() {
+ # notls
+ mkdir -p ${PAD_WORKDIR}/config/certs
+ if [[ ${KUSCIA_PROTOCOL} != "notls" ]]; then
+ cp ${CTR_CERT_ROOT}/ca.crt ${PAD_WORKDIR}/config/certs/ca.crt
+ # mtls
+ if [[ ${KUSCIA_PROTOCOL} -eq "mtls" ]]; then
+ cp ${CTR_CERT_ROOT}/kusciaapi-client.crt ${PAD_WORKDIR}/config/certs/client.crt
+ cp ${CTR_CERT_ROOT}/kusciaapi-client.key ${PAD_WORKDIR}/config/certs/client.pem
+ fi
+ fi
+ cp ${CTR_CERT_ROOT}/token ${PAD_WORKDIR}/config/certs/token
+ log "copy kuscia api client certs to web server container done"
+}
+
+function pre_kuscia() {
+ log "init kuscia.yaml"
+ DOMAIN_KEY_DATA=$(openssl genrsa 2048 | base64 | tr -d "\n")
+ CONFIG_DATA=$(sed -e "s!{{.DOMAIN_ID}}!${NODE_ID}!g;s!{{.DOMAIN_KEY_DATA}}!${DOMAIN_KEY_DATA}!g" <"/app/scripts/template/kuscia-autonomy-template.yaml")
+ echo "${CONFIG_DATA}" > etc/conf/kuscia.yaml
+}
+function post_kuscia() {
+ log "1. load secretflow image..."
+ kuscia image load -i image_libs/secretflow.tar --store /home/kuscia/var/images
+ log "2. create_secretflow_app_image..."
+ create_secretflow_app_image
+ log "3. gen kuscia api client certs..."
+ sh scripts/deploy/init_kusciaapi_client_certs.sh
+ log "4. creat secretpad svc ..."
+ sh scripts/deploy/create_secretpad_svc.sh 127.0.0.1 ${NODE_ID}
+}
+function copy_easypsi_config() {
+ cp -r /app/bak/config /app
+ cp -r /app/bak/scripts /app
+ cp -r /app/bak/data /app
+ cp /app/bak/scripts/fatimage/ezpsi_get_token.sh /app/tmp/scripts
+ cp /app/bak/scripts/fatimage/ezpsi_update_password.sh /app/tmp/scripts
+}
+
+function generate_easypsi_serverkey() {
+ /app/scripts/gen_easypsi_serverkey.sh 'easypsi' /app/config
+
+ log "generate webserver server key done"
+}
+function init_easypsi_db() {
+ /app/scripts/update-sql.sh
+ log "initialize webserver database done"
+}
+function create_easypsi_user_password() {
+ /app/scripts/register_account.sh -n 'admin' -p "${EASYPSI_PASSWORD}" -t P2P -o "${NODE_ID}"
+ log "create webserver user and password done"
+}
+
+function prepare_pad() {
+ pushd ${KUSCIA_WORKDIR}
+ log "1. generate easypsi serverkey..."
+ generate_easypsi_serverkey
+ log "2. init easypsi db..."
+ init_easypsi_db
+ log "3. create easypsi user password..."
+ create_easypsi_user_password
+ log "4. copy kuscia api client certs..."
+ copy_kuscia_api_client_certs
+
+ popd
+}
+
+function start_pad() {
+ pushd ${PAD_WORKDIR}
+ java -jar -Dsun.net.http.allowRestrictedHeaders=true /app/easypsi.jar
+ popd
+}
+
+log ">> copy easypsi config..."
+copy_easypsi_config
+log ">> pre kuscia..."
+pre_kuscia
+log ">> start kuscia..."
+start_kuscia
+log ">> post kuscia..."
+post_kuscia
+log ">> pre pad..."
+prepare_pad
+log ">> start pad..."
+start_pad
+log ">> finish start"
+log "would use default password: ${EASYPSI_PASSWORD}"
\ No newline at end of file
diff --git a/scripts/fatimage/ezpsi_get_token.sh b/scripts/fatimage/ezpsi_get_token.sh
new file mode 100644
index 0000000..e174ad0
--- /dev/null
+++ b/scripts/fatimage/ezpsi_get_token.sh
@@ -0,0 +1,166 @@
+#!/bin/bash
+#
+# Copyright 2024 Ant Group Co., Ltd.
+#
+# 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.
+#
+set -e
+
+GREEN='\033[0;32m'
+RED='\033[0;31m'
+NC='\033[0m'
+
+usage() {
+ echo "$(basename "$0") DEPLOY_MODE [OPTIONS]
+
+ OPTIONS:
+ -w [optional] Password of the account, required
+ -p [optional] The port exposed by easypsi-edge, The port must NOT be occupied by other processes, default 8088
+ "
+}
+
+PASSWORD=
+easypsi_port=${EASYPSI_PORT}
+ip=
+
+while getopts 'w:p:' option; do
+ case "$option" in
+ w)
+ PASSWORD=$OPTARG
+ ;;
+ p)
+ easypsi_port=$OPTARG
+ ;;
+ :)
+ printf "missing argument for -%s\n" "$OPTARG" >&2
+ usage
+ exit 1
+ ;;
+ \?)
+ printf "illegal option: -%s\n" "$OPTARG" >&2
+ usage
+ exit 1
+ ;;
+ esac
+done
+shift $((OPTIND - 1))
+
+function log() {
+ local log_content=$1
+ echo -e "${GREEN}${log_content}${NC}"
+}
+
+function error() {
+ local log_content=$1
+ echo -e "${RED}${log_content}${NC}"
+}
+
+if [[ ${PASSWORD} == "" ]]; then
+ echo "-w parameter missing,Password cannot be empty"
+ return 1
+fi
+
+if [[ ${easypsi_port} == "" ]]; then
+ easypsi_port="8088"
+ log "No port specified, using default port 8088"
+fi
+
+if [[ ${ip} == "" ]]; then
+ ip="localhost"
+ log "default ip address is localhost"
+fi
+
+export EASYPSI_PORT=$easypsi_port
+
+function public_key_check() {
+ file_path="$1"
+ if [ -f "$file_path" ]; then
+ log "$file_path already exists. Do you want to overwrite it? (y/n)"
+ read input
+ if [ "$input" = "y" ]; then
+ log "Overwriting the file..."
+ else
+ log "Aborting the overwrite. "
+ fi
+ else
+ echo "$file_path does not exist."
+ fi
+}
+
+# Message code validation
+function response_code_check() {
+ response="$1"
+ if [ -z "$response" ]; then
+ error "response is null"
+ return 1
+ fi
+ response_status=$(echo $response | grep -o '"code": *[0-9]*' | awk -F ': *' '{print $2}')
+ log "Response code is $response_status"
+ if [[ $response_status == '0' ]]; then
+ log "Response success!"
+ elif [[ $response_status == '404' ]]; then
+ error "Port Error! Please reconfigure the port"
+ return 1
+ else
+ error "Login feature request failed"
+ return 1
+ fi
+}
+
+# Get the RSA public key
+encryption_response=$(curl -k -X GET "http://$ip:$EASYPSI_PORT/api/encryption/getRandomKey")
+
+log "Public key request return value:"
+echo $encryption_response
+response_code_check $encryption_response
+
+EASYPSI_PUBLIC_KEY=$(echo $encryption_response | grep -o '"data": *"[^"]*' | awk -F '": *"' '{print $2}')
+
+log "Intercepted public key data:"
+echo $EASYPSI_PUBLIC_KEY
+export EASYPSI_PUBLIC_KEY=$EASYPSI_PUBLIC_KEY
+
+export EASYPSI_PASSWORD_256=$(echo -n ${PASSWORD} | openssl dgst -sha256 | awk '{print $2}')
+log "password after sha256 encryption:"
+echo ${EASYPSI_PASSWORD_256}
+
+# Check if the file already exists
+public_key_check 'public_key.pem'
+echo "-----BEGIN PUBLIC KEY-----" > public_key.pem
+echo "$EASYPSI_PUBLIC_KEY" >> public_key.pem
+echo "-----END PUBLIC KEY-----" >> public_key.pem
+
+log "Public key information:"
+cat public_key.pem
+
+export EASYPSI_ENCRYPTED=$(echo -n $EASYPSI_PASSWORD_256 | openssl pkeyutl -encrypt -pubin -inkey public_key.pem | base64 | tr -d '\n')
+log "Password after public key encryption:"
+echo ${EASYPSI_ENCRYPTED}
+
+# Login to obtain token
+login_response=$(curl -k -X POST "http://$ip:$EASYPSI_PORT/api/login" \
+--header 'Content-Type: application/json' \
+-d '{
+ "name": "admin",
+ "passwordHash":"'"$EASYPSI_ENCRYPTED"'",
+ "publicKey":"'"$EASYPSI_PUBLIC_KEY"'"
+}')
+
+log "login_response:$login_response"
+response_code_check $login_response
+
+token_value=$(echo $login_response | grep -o '"token": *"[^"]*' | awk -F '": *"' '{print $2}')
+export EASYPSI_TOKEN=$token_value
+if [[ -n $EASYPSI_TOKEN ]]; then
+ log "User-Token: $EASYPSI_TOKEN ,token has been added to the environment variable!"
+fi
diff --git a/scripts/fatimage/ezpsi_update_password.sh b/scripts/fatimage/ezpsi_update_password.sh
new file mode 100644
index 0000000..a3d0f32
--- /dev/null
+++ b/scripts/fatimage/ezpsi_update_password.sh
@@ -0,0 +1,161 @@
+#!/bin/bash
+#
+# Copyright 2024 Ant Group Co., Ltd.
+#
+# 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.
+#
+set -e
+
+GREEN='\033[0;32m'
+RED='\033[0;31m'
+NC='\033[0m'
+
+usage() {
+ echo "$(basename "$0") DEPLOY_MODE [OPTIONS]
+
+ OPTIONS:
+ -o [optional] old password
+ -n [optional] new password
+ -p [optional] The port exposed by easypsi-edge, The port must NOT be occupied by other processes, default 8088
+ "
+}
+
+old_password=
+new_password=
+easypsi_port=$EASYPSI_PORT
+
+while getopts 'o:n:p:' option; do
+ case "$option" in
+ o)
+ old_password=$OPTARG
+ ;;
+ n)
+ new_password=$OPTARG
+ ;;
+ p)
+ easypsi_port=$OPTARG
+ ;;
+ :)
+ printf "missing argument for -%s\n" "$OPTARG" >&2
+ usage
+ exit 1
+ ;;
+ \?)
+ printf "illegal option: -%s\n" "$OPTARG" >&2
+ usage
+ exit 1
+ ;;
+ esac
+done
+shift $((OPTIND - 1))
+
+function log() {
+ local log_content=$1
+ echo -e "${GREEN}${log_content}${NC}"
+}
+
+function error() {
+ local log_content=$1
+ echo -e "${RED}${log_content}${NC}"
+}
+
+if [[ ${old_password} == "" ]]; then
+ error "-o parameter missing,old password cannot be empty"
+ return 1
+fi
+
+if [[ ${new_password} == "" ]]; then
+ error "-n parameter missing,new password cannot be empty"
+ return 1
+fi
+
+if [[ $EASYPSI_TOKEN == "" ]]; then
+ error "token is empty, please log in first"
+ return 1
+fi
+
+if [[ ${ip} == "" ]]; then
+ ip="localhost"
+ log "default ip address is localhost"
+fi
+
+if [[ ${easypsi_port} == "" ]]; then
+ easypsi_port="8088"
+ log "No port specified, using default port 8088"
+fi
+
+EASYPSI_PORT=$easypsi_port
+
+function public_key_check() {
+ file_path="$1"
+ if [ -f "$file_path" ]; then
+ log "Use $file_path file for password encryption"
+ else
+ error "$file_path does not exist."
+ return 1
+ fi
+}
+
+# Message code validation
+function response_code_check() {
+ response="$1"
+ if [ -z "$response" ]; then
+ error "response is null"
+ return 1
+ fi
+ response_status=$(echo $response | grep -o '"code": *[0-9]*' | awk -F ': *' '{print $2}')
+ log "Response code is $response_status"
+ if [[ $response_status == '0' ]]; then
+ log "Response success!"
+ elif [[ $response_status == '404' ]]; then
+ error "Port Error! Please reconfigure the port"
+ else
+ error "Update password request failed"
+ fi
+}
+
+# check whether the public key exists
+public_key_check 'public_key.pem'
+
+# Password Encryption
+function password_encryption() {
+ password="$1"
+ password_256=$(echo -n ${password} | openssl dgst -sha256 | awk '{print $2}')
+ password_public_key=$(echo -n $password_256 | openssl pkeyutl -encrypt -pubin -inkey public_key.pem | base64 | tr -d '\n')
+ echo "$password_public_key"
+}
+
+log "old_password before encryption: ${old_password}"
+OLD_PASSWORD=$(password_encryption ${old_password})
+log "old_password after public key encryption: $OLD_PASSWORD"
+
+log "new_password before encryption: ${new_password}"
+NEW_PASSWORD=$(password_encryption ${new_password})
+log "new_password after public key encryption: $NEW_PASSWORD"
+
+CONFIRM_PASSWORD=$NEW_PASSWORD
+
+update_pwd_response=$(curl -k -X POST "http://${ip}:${easypsi_port}/api/v1alpha1/user/updatePwd" \
+--header 'Content-Type: application/json' \
+--header "User-Token:$EASYPSI_TOKEN" \
+-d '{
+ "name": "admin",
+ "oldPasswordHash":"'"$OLD_PASSWORD"'",
+ "newPasswordHash":"'"$NEW_PASSWORD"'",
+ "confirmPasswordHash":"'"$CONFIRM_PASSWORD"'",
+ "publicKey":"'"$EASYPSI_PUBLIC_KEY"'"
+}')
+
+log "modify password response:"
+echo $update_pwd_response
+response_code_check $update_pwd_response
diff --git a/scripts/fatimage/install_fatimage.sh b/scripts/fatimage/install_fatimage.sh
new file mode 100644
index 0000000..5a7f047
--- /dev/null
+++ b/scripts/fatimage/install_fatimage.sh
@@ -0,0 +1,424 @@
+#!/bin/bash
+#
+# Copyright 2024 Ant Group Co., Ltd.
+#
+# 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.
+#
+
+p2p_default_dir="$HOME/kuscia/p2p"
+
+set -e
+GREEN='\033[0;32m'
+NC='\033[0m'
+
+
+usage() {
+ echo "$(basename "$0") DEPLOY_MODE [OPTIONS]
+
+ OPTIONS:
+ -n [mandatory] Domain id to be deployed.
+ -h [optional] Show this help text.
+ -p [optional] The port exposed by kuscia-lite-gateway, The port must NOT be occupied by other processes, default 8080
+ -s [optional] The port exposed by easypsi-edge, The port must NOT be occupied by other processes, default 8088
+ -d [optional] The install directory. Default is ${p2p_default_dir}.
+
+example:
+ install.sh -n alice -d /root/tm/t4 -p 7001 -s 7002'
+ "
+}
+
+function log() {
+ local log_content=$1
+ echo -e "\033[36m[$(date +%y/%m/%d-%H:%M:%S)] \033[0m${GREEN}${log_content}${NC}"
+}
+
+while getopts ':n:d:p:s:t:' option; do
+ case "$option" in
+ n)
+ NODE_ID=$OPTARG
+ ;;
+ d)
+ ROOT_PATH=$OPTARG
+ ;;
+ p)
+ KUSCIA_DOMAIN_PORT=$OPTARG
+ ;;
+ s)
+ WEB_PORT=$OPTARG
+ ;;
+ :)
+ printf "missing argument for -%s\n" "$OPTARG" >&2
+ usage
+ exit 1
+ ;;
+ \?)
+ printf "illegal option: -%s\n" "$OPTARG" >&2
+ usage
+ exit 1
+ ;;
+ esac
+done
+
+for file in images/*; do
+ if [ -f "$file" ]; then
+ echo "$file"
+ imageInfo="$(docker load <$file)"
+ echo "echo ${imageInfo}"
+ someimage=$(echo ${imageInfo} | sed "s/Loaded image: //")
+ if [[ $someimage == *easypsi* ]]; then
+ EASYPSI_FAT_IMAGE=$someimage
+ fi
+ fi
+done
+
+#### Fill default data ####
+#if [ "${EASYPSI_FAT_IMAGE}" == "" ]; then
+# EASYPSI_FAT_IMAGE=${default_fat_image}
+#fi
+
+if [[ ${KUSCIA_DOMAIN_PORT} == "" ]]; then
+ KUSCIA_DOMAIN_PORT="8080"
+fi
+if [[ ${WEB_PORT} == "" ]]; then
+ WEB_PORT="8088"
+fi
+if [[ $USER == "" ]]; then
+ USER=default
+fi
+if [[ ${KUSCIA_PROTOCOL} == "" ]]; then
+ KUSCIA_PROTOCOL="mtls"
+fi
+if [[ $ROOT_PATH == "" ]]; then
+ ROOT_PATH=${p2p_default_dir}
+fi
+
+#### Verify ####
+if [[ ${EASYPSI_FAT_IMAGE} == "" ]]; then
+ printf "empty EASYPSI_FAT_IMAGE\n" >&2
+ exit 1
+fi
+if [[ ${NODE_ID} == "" ]]; then
+ printf "empty node id\n" >&2
+ exit 1
+fi
+
+#### prepare
+mkdir -p $ROOT_PATH
+CTR_PREFIX=${USER}-kuscia
+CTR_CERT_ROOT=${ROOT_PATH}/var/certs
+FORCE_START=false
+# set by account_settings function
+EASYPSI_USER_NAME=""
+EASYPSI_PASSWORD=""
+SPRING_PROFILES_ACTIVE="p2p"
+LITE_MEMORY_LIMIT=4G
+EASYPSI_IMAGE=${EASYPSI_FAT_IMAGE}
+log "EASYPSI_FAT_IMAGE=${EASYPSI_FAT_IMAGE}"
+log "easypsi root dir: $ROOT_PATH"
+
+
+function need_start_docker_container() {
+ ctr=$1
+
+ if [[ ! "$(docker ps -a -q -f name=^/${ctr}$)" ]]; then
+ # need start your container
+ return 0
+ fi
+
+ if $FORCE_START; then
+ log "Remove container '${ctr}' ..."
+ docker rm -f $ctr >/dev/null 2>&1
+ # need start your container
+ return 0
+ fi
+
+ read -rp "$(echo -e ${GREEN}The container \'${ctr}\' already exists. Do you need to recreate it? [y/n]: ${NC})" yn
+ case $yn in
+ [Yy]*)
+ echo -e "${GREEN}Remove container ${ctr} ...${NC}"
+ docker rm -f $ctr
+ # need start your container
+ return 0
+ ;;
+ *)
+ return 1
+ ;;
+ esac
+
+ return 1
+}
+
+function copy_easypsi_file_to_volume() {
+ local dst_path=$1
+ mkdir -p ${dst_path}/easypsi
+ mkdir -p ${dst_path}/data
+ # copy config file
+ docker run --rm --entrypoint /bin/bash -v ${dst_path}/easypsi:/tmp/easypsi $EASYPSI_IMAGE -c 'cp -R /app/config /tmp/easypsi/'
+ # copy sqlite db file
+ docker run --rm --entrypoint /bin/bash -v ${dst_path}/easypsi:/tmp/easypsi $EASYPSI_IMAGE -c 'cp -R /app/db /tmp/easypsi/'
+ # copy demo data file
+ docker run --rm --entrypoint /bin/bash -v ${dst_path}:/tmp/easypsi $EASYPSI_IMAGE -c 'cp -R /app/data /tmp/easypsi/'
+ log "copy webserver config and database file done"
+}
+
+function generate_easypsi_serverkey() {
+ local tmp_volume=$1
+ local password=$2
+ # generate server key in edge container
+ docker run -it --rm --entrypoint /bin/bash --volume=${tmp_volume}/easypsi/config/:/tmp/temp ${EASYPSI_IMAGE} -c "/app/scripts/gen_easypsi_serverkey.sh ${password} /tmp/temp"
+ rm -rf ${tmp_volume}/server.jks
+ log "generate webserver server key done"
+}
+
+function init_easypsi_db() {
+ local root_path=$1
+ # generate server key in edge container
+ docker run -it --rm --entrypoint /bin/bash --volume=${root_path}/easypsi/db:/app/db ${EASYPSI_IMAGE} -c "/app/scripts/update-sql.sh"
+ log "initialize webserver database done"
+}
+
+function create_easypsi_user_password() {
+ local root_path=$1
+ local user_name=$2
+ local password=$3
+ # generate server key in edge container
+ docker run -it --rm --entrypoint /bin/bash --volume=${root_path}/easypsi/db:/app/db ${EASYPSI_IMAGE} -c "/app/scripts/register_account.sh -n '${user_name}' -p '${password}' -t P2P -o '${NODE_ID}'"
+
+ log "create webserver user and password done"
+}
+
+
+function render_easypsi_config() {
+ local root_path=$1
+ local tmpl_path=${root_path}/easypsi/config/template/application.yaml.tmpl
+ local store_key_password=$2
+ # cp file to easypsi's config path
+ docker run -d --rm --name ${CTR_PREFIX}-dummy --volume=${root_path}/easypsi/config:/tmp/temp $IMAGE tail -f /dev/null >/dev/null 2>&1
+ docker cp ${root_path}/application.yaml ${CTR_PREFIX}-dummy:/tmp/temp/
+ docker rm -f ${CTR_PREFIX}-dummy >/dev/null 2>&1
+ # rm temp file
+ rm -rf ${root_path}/application_01.yaml ${root_path}/application.yaml
+
+ log "render webserver config done"
+}
+
+function do_http_probe() {
+ local ctr=$1
+ local endpoint=$2
+ local max_retry=$3
+ local retry=0
+ while [ $retry -lt $max_retry ]; do
+ local status_code
+ # TODO support MTLS
+ status_code=$(docker exec -it $ctr curl -k --write-out '%{http_code}' --silent --output /dev/null ${endpoint})
+ if [[ $status_code -eq 200 || $status_code -eq 404 || $status_code -eq 401 ]]; then
+ return 0
+ fi
+ sleep 2
+ retry=$((retry + 1))
+ log "check server status: ${status_code}. times: ${retry}"
+ done
+
+ return 1
+}
+
+function probe_easy_psi() {
+ local easypsi_ctr=$1
+ if ! do_http_probe $easypsi_ctr "http://127.0.0.1:8080" 60; then
+ echo "[Error] Probe secret pad in container '$easypsi_ctr' failed. Please check the log" >&2
+ exit 1
+ fi
+}
+
+function check_user_name() {
+ local user_name=$1
+ strlen=$(echo "${user_name}" | grep -E --color '^(.{4,}).*$')
+ if [ -n "${strlen}" ]; then
+ return 0
+ else
+ log "The username requires a length greater than 4"
+ return 1
+ fi
+}
+
+function check_user_passwd() {
+ local password=$1
+ # length greater than 8
+ str_len=$(echo "${password}" | grep -E --color '^(.{8,}).*$')
+ # with lowercase letters
+ str_low=$(echo "${password}" | grep -E --color '^(.*[a-z]+).*$')
+ # with uppercase letters
+ str_upp=$(echo "${password}" | grep -E --color '^(.*[A-Z]).*$')
+ # with special characters
+ str_ts=$(echo "${password}" | grep -E --color '^(.*\W).*$')
+ # with numbers
+ str_num=$(echo "${password}" | grep -E --color '^(.*[0-9]).*$')
+ if [ -n "${str_len}" ] && [ -n "${str_low}" ] && [ -n "${str_upp}" ] && [ -n "${str_ts}" ] && [ -n "${str_num}" ]; then
+ return 0
+ else
+ log "The password requires a length greater than 8, including uppercase and lowercase letters, numbers, and special characters."
+ return 2
+ fi
+}
+
+function account_settings() {
+ local RET
+ set +e
+ log "Please set the username and the password used to login the KUSCIA-WEB.\n\
+The username requires a length greater than 4, The password requires a length greater than 8,\n\
+including uppercase and lowercase letters, numbers, and special characters."
+ for ((i = 0; i < 1; i++)); do
+ read -r -p "Enter username(admin):" EASYPSI_USER_NAME
+ check_user_name "${EASYPSI_USER_NAME}"
+ RET=$?
+ if [ "${RET}" -eq 0 ]; then
+ break
+ elif [ "${RET}" -ne 0 ] && [ "${i}" == 0 ]; then
+ log "would use default user: admin"
+ EASYPSI_USER_NAME="admin"
+ fi
+ done
+ stty -echo # disable display
+ for ((i = 0; i < 3; i++)); do
+ read -r -p "Enter password: " EASYPSI_PASSWORD
+ echo ""
+ check_user_passwd "${EASYPSI_PASSWORD}"
+ RET=$?
+ if [ "${RET}" -eq 0 ]; then
+ local CONFIRM_PASSWD
+ read -r -p "Confirm password again: " CONFIRM_PASSWD
+ echo ""
+ if [ "${CONFIRM_PASSWD}" == "${EASYPSI_PASSWORD}" ]; then
+ break
+ else
+ log "Password not match! please reset"
+ fi
+ elif [ "${RET}" -ne 0 ] && [ "${i}" == 2 ]; then
+ log "would use default password: 12#\$qwER"
+ EASYPSI_PASSWORD="12#\$qwER"
+ fi
+ done
+ set -e
+ stty echo # enable display
+ log "The user and password have been set up successfully."
+}
+function copy_kuscia_api_client_certs() {
+ # notls
+ if [[ ${KUSCIA_PROTOCOL} != "notls" ]]; then
+ cp ${CTR_CERT_ROOT}/ca.crt ${PAD_WORK_DIR}/config/certs/ca.crt
+ # mtls
+ if [[ ${KUSCIA_PROTOCOL} -eq "mtls" ]]; then
+ cp ${CTR_CERT_ROOT}/kusciaapi-client.crt ${PAD_WORK_DIR}/config/certs/client.crt
+ cp ${CTR_CERT_ROOT}/kusciaapi-client.key ${PAD_WORK_DIR}/config/certs/client.pem
+ fi
+ fi
+ cp ${CTR_CERT_ROOT}/token ${PAD_WORK_DIR}/config/certs/token
+ log "copy kuscia api client certs to web server container done"
+}
+function prepare_pad_config() {
+ # root_path
+ # ├── data
+ # │ ├── alice
+ # │ │ └── alice.csv
+ # │ └── bob
+ # │ └── bob.csv
+ # └── easypsi
+ # ├── config
+ # └── db
+ #
+ log "Prepare pad config..."
+ account_settings
+ local root_path=${ROOT_PATH}
+ local kuscia_protocol=${KUSCIA_PROTOCOL}
+ local user_name=$EASYPSI_USER_NAME
+ local password=$EASYPSI_PASSWORD
+
+ easypsi_key_pass="easypsi"
+ # copy db,config,demodata from easypsi image
+ log "copy db,config,demodata to '$root_path' ..."
+ copy_easypsi_file_to_volume ${root_path}
+ # generate server key
+ log "generate server key '$root_path' ..."
+ generate_easypsi_serverkey ${root_path} ${easypsi_key_pass}
+ # initialize easypsi dbd
+ init_easypsi_db ${root_path}
+ # create easypsi user and password
+ create_easypsi_user_password ${root_path} ${user_name} ${password}
+ # TODO render easypsi config
+ # render_easypsi_config ${root_path} ${easypsi_key_pass}
+}
+function start_fat_image(){
+ local fat_ctr=$1 # root-kuscia-easypsi-fat-alice
+ local volume_data_path=$2 # ${root_path}/kuscia-autonomy-${NODE_ID}-data
+ local volume_log_path=$3 # ${root_path}/kuscia-autonomy-${NODE_ID}-log
+ local volume_pad_config_path=$4 # ${root_path}/easypsi/config
+ local volume_pad_db_path=$5 # ${root_path}/easypsi/db
+
+ echo ${fat_ctr} > ${ROOT_PATH}/continer_name
+ docker run -itd --init --name=${fat_ctr} --restart=always -m $LITE_MEMORY_LIMIT \
+ --volume=${volume_data_path}:/app/data \
+ --volume=${volume_data_path}:/home/kuscia/var/storage/data \
+ --volume=${volume_log_path}/pods:/home/kuscia/var/stdout/pods \
+ --volume=${volume_log_path}/kuscia:/home/kuscia/var/logs \
+ --volume=${volume_log_path}/easypsi:/app/log/easypsi \
+ --volume=${volume_log_path}/pods:/app/log/pods \
+ --volume=${volume_pad_config_path}:/app/config \
+ --volume=${volume_pad_db_path}:/app/db \
+ --workdir=/home/kuscia \
+ -p $WEB_PORT:8080 \
+ -p ${KUSCIA_DOMAIN_PORT}:1080 \
+ -v ${ROOT_PATH}/kuscia.yaml:/home/kuscia/etc/conf/kuscia.yaml \
+ -e SPRING_PROFILES_ACTIVE=${SPRING_PROFILES_ACTIVE} \
+ -e NODE_ID=${NODE_ID} \
+ -e KUSCIA_API_ADDRESS=127.0.0.1:8083 \
+ -e KUSCIA_GW_ADDRESS=127.0.0.1:80 \
+ -e HOST_PATH=${volume_data_path} \
+ -e KUSCIA_PROTOCOL=${KUSCIA_PROTOCOL} \
+ ${EASYPSI_IMAGE}
+ probe_easy_psi ${fat_ctr}
+ log "web server started successfully"
+ log "Please visit the website http://localhost:${port} (or http://{the IPAddress of this machine}:${port}) to experience the Kuscia web's functions ."
+ log "The login name:'${EASYPSI_USER_NAME}' ,The login password:'${EASYPSI_PASSWORD}' ."
+ log "The demo data would be stored in the path: ${volume_data_path} ."
+ log "The kuscia tls mode is: ${KUSCIA_PROTOCOL} ."
+ log "The EASYPSI_IMAGE is: ${EASYPSI_IMAGE} ."
+}
+function prepare_uninstall_script() {
+ docker run --rm --entrypoint /bin/bash -v ${ROOT_PATH}:/tmp/scripts $EASYPSI_IMAGE -c 'cp -R /app/scripts/fatimage/uninstall_fatimage.sh /tmp/scripts/uninstall.sh && chmod +x /tmp/scripts/uninstall.sh'
+ chmod +x ${ROOT_PATH}/uninstall.sh
+}
+function prepare_kuscia_config() {
+ log "init kuscia.yaml"
+ docker run --rm --entrypoint /bin/bash -v ${ROOT_PATH}:/tmp/scripts $EASYPSI_IMAGE -c 'cp -R /app/scripts/template/kuscia-autonomy-template.yaml /tmp/scripts/kuscia-autonomy-template.yaml'
+
+ DOMAIN_KEY_DATA=$(docker run --rm --entrypoint /bin/bash $EASYPSI_IMAGE -c 'openssl genrsa 2048 | base64 | tr -d "\n"')
+ CONFIG_DATA=$(sed -e "s!{{.DOMAIN_ID}}!${NODE_ID}!g;s!{{.DOMAIN_KEY_DATA}}!${DOMAIN_KEY_DATA}!g" <"${ROOT_PATH}/kuscia-autonomy-template.yaml")
+ echo "${CONFIG_DATA}" > ${ROOT_PATH}/kuscia.yaml
+
+}
+
+# If the container exists.
+fat_ctr=${CTR_PREFIX}-easypsi-fat-${NODE_ID}
+if need_start_docker_container $fat_ctr; then
+ log ">> Prepare uninstall script."
+ prepare_uninstall_script
+ log ">> Prepare kuscia config."
+ prepare_kuscia_config
+ log ">> Prepare pad config."
+ prepare_pad_config
+ log ">> Run image."
+ start_fat_image $fat_ctr ${ROOT_PATH}/kuscia-autonomy-${NODE_ID}-data ${ROOT_PATH}/kuscia-autonomy-${NODE_ID}-log ${ROOT_PATH}/easypsi/config ${ROOT_PATH}/easypsi/db
+ shift $((OPTIND - 1))
+else
+ log "The container is running. Ignore this action."
+fi
diff --git a/scripts/fatimage/package_fatimage.sh b/scripts/fatimage/package_fatimage.sh
new file mode 100644
index 0000000..8bd8e93
--- /dev/null
+++ b/scripts/fatimage/package_fatimage.sh
@@ -0,0 +1,64 @@
+#!/bin/bash
+#
+# Copyright 2024 Ant Group Co., Ltd.
+#
+# 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.
+#
+
+# Load images
+# Set image
+# EASYPSI_FAT_IMAGE=""
+
+GREEN='\033[0;32m'
+NC='\033[0m'
+function log() {
+ local log_content=$1
+ echo -e "${GREEN}${log_content}${NC}"
+}
+
+# Prepare
+CURRENT_DIR=$(cd $(dirname $0); pwd)
+PRJ_TARGET=${CURRENT_DIR}/../../target
+
+# Rebuild pad image
+read -rp "$(echo -e ${GREEN}Do you need to rebuild image? [N/y]: ${NC})" yn
+case $yn in
+[Yy]*)
+ log "rebuild image"
+ sh ${CURRENT_DIR}/../build_fatimage.sh
+esac
+
+#### Verify ####
+if [[ ${EASYPSI_FAT_IMAGE} == "" ]]; then
+ printf "empty EASYPSI_FAT_IMAGE\n" >&2
+ exit 1
+fi
+
+# Package tar.gz
+pushd ${PRJ_TARGET}
+VERSION_TAG="$(git describe --tags)"
+package_name=secretflow-easypsi-fat
+result_tar_name=${package_name}-${VERSION_TAG}.tar.gz
+mkdir -p ${package_name}/images
+fatTag=${EASYPSI_FAT_IMAGE##*:}
+log "fat tag: $fatTag"
+docker save -o ${package_name}/images/easypsi-fat-${fatTag}.tar ${EASYPSI_FAT_IMAGE}
+cp ${CURRENT_DIR}/install_fatimage.sh ${package_name}/install.sh
+cp ${CURRENT_DIR}/ezpsi_get_token.sh ${package_name}/ezpsi_get_token.sh
+cp ${CURRENT_DIR}/ezpsi_update_password.sh ${package_name}/ezpsi_update_password.sh
+chmod +x ${package_name}/install.sh
+tar --no-xattrs -zcvf ${result_tar_name} ./${package_name}
+popd
+
+log "package done. result: ${PRJ_TARGET}/${result_tar_name}"
+open ${PRJ_TARGET}
\ No newline at end of file
diff --git a/scripts/fatimage/uninstall_fatimage.sh b/scripts/fatimage/uninstall_fatimage.sh
new file mode 100644
index 0000000..a2a0281
--- /dev/null
+++ b/scripts/fatimage/uninstall_fatimage.sh
@@ -0,0 +1,55 @@
+#!/bin/bash
+#
+# Copyright 2024 Ant Group Co., Ltd.
+#
+# 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.
+#
+set -e
+GREEN='\033[0;32m'
+NC='\033[0m'
+
+function log() {
+ local log_content=$1
+ echo -e "\033[36m[$(date +%y/%m/%d-%H:%M:%S)] \033[0m${GREEN}${log_content}${NC}"
+}
+
+CURRENT_DIR=$(cd $(dirname $0); pwd)
+log "Uninstall dir: ${CURRENT_DIR}"
+
+# Delete container
+function delete_container() {
+ if [ -f ${CURRENT_DIR}/continer_name ]; then
+ continer_name=`cat ${CURRENT_DIR}/continer_name`
+ if [[ "$(docker ps -a -q -f name=^/${continer_name}$)" ]]; then
+ # need start your container
+ log "Delete container ${continer_name} ..."
+ docker rm -f ${continer_name} > /dev/null 2>&1
+ fi
+ else
+ log "Container ${continer_name} does not exist."
+ fi
+}
+# Delete data
+function delete_data() {
+ local RET
+ log "Delete all data for path: ${CURRENT_DIR}"
+ read -r -p $'\033[1;35mDelete all data? N/y: \033[0m' delete_flag
+ if [[ "Y" == $delete_flag || "y" == $delete_flag ]]; then
+ cd $CURRENT_DIR
+ log "Delete data ${CURRENT_DIR} ..."
+ rm -rf `ls -a | grep -v uninstall | grep -v '^\.$' | grep -v '^\.\.$'`
+ fi
+}
+
+delete_container
+delete_data
diff --git a/scripts/gen_secretpad_serverkey.sh b/scripts/gen_easypsi_serverkey.sh
similarity index 89%
rename from scripts/gen_secretpad_serverkey.sh
rename to scripts/gen_easypsi_serverkey.sh
index d3b9fd4..fdb6035 100755
--- a/scripts/gen_secretpad_serverkey.sh
+++ b/scripts/gen_easypsi_serverkey.sh
@@ -15,7 +15,7 @@
# limitations under the License.
#
-SecretPadAddress="SecretPad"
+EasyPsiAddress="EasyPsi"
Password=$1
OutPath=$2
usage="$(basename "$0") password"
@@ -28,5 +28,5 @@ fi
# generate jks
set +e
keytool -genkey -keystore ${OutPath}/server.jks -keyalg RSA -keysize 2048 -validity 3650 \
- -keypass ${Password} -storepass ${Password} -dname "OU=SF, O=ANT, L=Shanghai, ST=Shanghai, C=CN, CN=${SecretPadAddress}" -alias secretpad-server
+ -keypass ${Password} -storepass ${Password} -dname "OU=SF, O=ANT, L=Shanghai, ST=Shanghai, C=CN, CN=${EasyPsiAddress}" -alias easypsi-server
set -e
diff --git a/scripts/init_kusciaapi_certs.sh b/scripts/init_kusciaapi_certs.sh
index 638393b..ee8cb0a 100755
--- a/scripts/init_kusciaapi_certs.sh
+++ b/scripts/init_kusciaapi_certs.sh
@@ -14,10 +14,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-SECRETPAD_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)
+EASYPSI_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)
-echo "root path is: $SECRETPAD_ROOT"
-CERT_DIR="$SECRETPAD_ROOT/config/certs"
+echo "root path is: $EASYPSI_ROOT"
+CERT_DIR="$EASYPSI_ROOT/config/certs"
echo "cert path is: $CERT_DIR"
diff --git a/scripts/init_kusciaapi_client_certs.sh b/scripts/init_kusciaapi_client_certs.sh
new file mode 100755
index 0000000..cceeed7
--- /dev/null
+++ b/scripts/init_kusciaapi_client_certs.sh
@@ -0,0 +1,36 @@
+#!/bin/bash
+# Copyright 2023 Ant Group Co., Ltd.
+#
+# 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.
+
+set -e
+
+ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P)
+
+pushd ${ROOT}/var/certs >/dev/null || exit
+
+CLIENT=kusciaapi-client
+
+#create a PKCS#8 key for client(JAVA native supported), default is PKCS#1
+openssl genpkey -out ${CLIENT}.key -algorithm RSA -pkeyopt rsa_keygen_bits:2048 >/dev/null 2>&1
+
+#generate the Certificate Signing Request for client
+openssl req -new -key ${CLIENT}.key -out ${CLIENT}.csr -subj "/CN=KusciaAPIClient" >/dev/null 2>&1
+
+#sign it with Root CA for client
+openssl x509 -req -in ${CLIENT}.csr \
+ -CA ca.crt -CAkey ca.key \
+ -days 1000 -sha256 -CAcreateserial \
+ -out ${CLIENT}.crt >/dev/null 2>&1
+
+popd >/dev/null || exit
diff --git a/scripts/pack/install.sh b/scripts/pack/install.sh
index e6e3599..7d38b5e 100755
--- a/scripts/pack/install.sh
+++ b/scripts/pack/install.sh
@@ -18,7 +18,7 @@
# load images
KUSCIA_IMAGE=""
-SECRETPAD_IMAGE=""
+EASYPSI_IMAGE=""
SECRETFLOW_IMAGE=""
P2P_DEFAULT_DIR="$HOME/kuscia/p2p"
@@ -29,11 +29,10 @@ usage() {
p2p OPTIONS:
-n [mandatory] Domain id to be deployed.
- -i [optional] The IP address exposed by the domain. Usually the host IP, default is the IP address of interface eth0.
-c [optional] The host directory used to store domain certificates, default is 'kuscia-{{DEPLOY_MODE}}-{{DOMAIN_ID}}-certs'. It will be mounted into the domain container.
-h [optional] Show this help text.
-p [optional] The port exposed by kuscia-lite-gateway, The port must NOT be occupied by other processes, default 8080
- -s [optional] The port exposed by secretpad-edge, The port must NOT be occupied by other processes, default 8088
+ -s [optional] The port exposed by easypsi-edge, The port must NOT be occupied by other processes, default 8088
-k [optional] The port exposed by kuscia-lite-api-http, The port must NOT be occupied by other processes, default 8081
-g [optional] The port exposed by kuscia-lite-api-grpc, The port must NOT be occupied by other processes, default 8082
-m [optional] The kuscia endpoint.
@@ -45,19 +44,19 @@ example:
}
domain_id=
-domain_host_ip=
domain_host_port=
domain_api_http_port=
domain_api_grpc_port=
-secretpad_edge_port=
+easypsi_edge_port=
domain_certs_dir=
master_endpoint=
token=
masterca=
volume_path=$(pwd)
install_dir=
+kuscia_protocol="mtls"
-while getopts 'c:d:i:n:p:s:t:m:k:g:h' option; do
+while getopts 'c:d:i:n:p:s:t:m:k:g:h:' option; do
case "$option" in
c)
domain_certs_dir=$OPTARG
@@ -65,9 +64,6 @@ while getopts 'c:d:i:n:p:s:t:m:k:g:h' option; do
d)
install_dir=$OPTARG
;;
- i)
- domain_host_ip=$OPTARG
- ;;
n)
domain_id=$OPTARG
;;
@@ -75,7 +71,7 @@ while getopts 'c:d:i:n:p:s:t:m:k:g:h' option; do
domain_host_port=$OPTARG
;;
s)
- secretpad_edge_port=$OPTARG
+ easypsi_edge_port=$OPTARG
;;
k)
domain_api_http_port=$OPTARG
@@ -118,8 +114,8 @@ for file in images/*; do
someimage=$(echo ${imageInfo} | sed "s/Loaded image: //")
if [[ $someimage == *kuscia* ]]; then
KUSCIA_IMAGE=$someimage
- elif [[ $someimage == *secretpad* ]]; then
- SECRETPAD_IMAGE=$someimage
+ elif [[ $someimage == *easypsi* ]]; then
+ EASYPSI_IMAGE=$someimage
# elif [[ $someimage == *secretflow-lite* ]]; then
# SECRETFLOW_IMAGE=$someimage
# elif [[ $someimage == *sf-dev-anolis8* ]]; then
@@ -130,7 +126,7 @@ for file in images/*; do
fi
done
export KUSCIA_IMAGE=$KUSCIA_IMAGE
-export SECRETPAD_IMAGE=$SECRETPAD_IMAGE
+export EASYPSI_IMAGE=$EASYPSI_IMAGE
export SECRETFLOW_IMAGE=$SECRETFLOW_IMAGE
# deploy p2p
@@ -139,12 +135,8 @@ if [[ ${domain_id} == "" ]]; then
exit 1
fi
-if [[ ${domain_host_ip} == "" ]]; then
- domain_host_ip="127.0.0.1"
-fi
-
-if [[ ${secretpad_edge_port} == "" ]]; then
- secretpad_edge_port="8088"
+if [[ ${easypsi_edge_port} == "" ]]; then
+ easypsi_edge_port="8088"
fi
if [[ ${domain_host_port} == "" ]]; then
@@ -166,17 +158,21 @@ fi
# set intall dir of the deploy.sh
# the datapath is ${ROOT}/kuscia-${deploy_mode}-${DOMAIN_ID}-data
# the certpath is ${ROOT}/kuscia-${deploy_mode}-${DOMAIN_ID}-certs
+# the kuscia-configpath is ${ROOT}
export ROOT=${install_dir}
-cmd_opt="-n ${domain_id} -i ${domain_host_ip} -p ${domain_host_port} -k ${domain_api_http_port} -g ${domain_api_grpc_port} \
--d ${install_dir}/kuscia-autonomy-${domain_id}-data -l ${install_dir}/kuscia-autonomy-${domain_id}-log"
+mkdir -p ${ROOT}
+kuscia_config=${ROOT}/kuscia.yaml
+# generate kuscia configuration file
+docker run --rm $KUSCIA_IMAGE bin/kuscia init --mode autonomy --domain $domain_id --protocol $kuscia_protocol > $kuscia_config
+
+cmd_opt="-n ${domain_id} -p ${domain_host_port} -k ${domain_api_http_port} -g ${domain_api_grpc_port} \
+-d ${install_dir}/kuscia-autonomy-${domain_id}-data -l ${install_dir}/kuscia-autonomy-${domain_id}-log \
+-c ${kuscia_config}"
if [[ ${domain_certs_dir} != "" ]]; then
- cmd_opt="${cmd_opt} -c ${domain_certs_dir}"
+ domain_certs_dir=${ROOT}/kuscia-autonomy-${domain_id}-certs
fi
-
-
-
# copy deploy.sh from kuscia image
docker run --rm $KUSCIA_IMAGE cat /home/kuscia/scripts/deploy/deploy.sh > deploy.sh && chmod u+x deploy.sh
# execute deploy lite shell
@@ -185,14 +181,15 @@ echo "bash $(pwd)/deploy.sh autonomy ${cmd_opt}"
bash $(pwd)/deploy.sh autonomy ${cmd_opt}
# add external name svc
-docker exec -it ${USER}-kuscia-autonomy-${domain_id} scripts/deploy/create_secretpad_svc.sh ${USER}-kuscia-secretpad-p2p-${domain_id} ${domain_id}
+docker exec -it ${USER}-kuscia-autonomy-${domain_id} scripts/deploy/create_secretpad_svc.sh ${USER}-kuscia-easypsi-p2p-${domain_id} ${domain_id}
# initialize start_p2p.sh
#edge_opt="-n ${node_id} -s 8088 -m root-kuscia-autonomy-alice:8083"
KUSCIA_NAME="${USER}-kuscia-autonomy-${domain_id}"
-edge_opt="-n ${domain_id} -s ${secretpad_edge_port} -m ${KUSCIA_NAME}:8083 "
+edge_opt="-n ${domain_id} -s ${easypsi_edge_port} -m ${KUSCIA_NAME}:8083 -t ${kuscia_protocol}"
+export EASYPSI_PORT=${easypsi_edge_port}
# initialize start_p2p.sh
-docker run --rm --entrypoint /bin/bash -v $(pwd):/tmp/secretpad $SECRETPAD_IMAGE -c 'cp -R /app/scripts/start_p2p.sh /tmp/secretpad/'
+docker run --rm --entrypoint /bin/bash -v $(pwd):/tmp/easypsi $EASYPSI_IMAGE -c 'cp -R /app/scripts/start_p2p.sh /tmp/easypsi/'
echo "bash $(pwd)/start_p2p.sh ${edge_opt}"
bash $(pwd)/start_p2p.sh ${edge_opt}
diff --git a/scripts/pack/pack_allinone.sh b/scripts/pack/pack_allinone.sh
index a3c21e7..69fa9f4 100755
--- a/scripts/pack/pack_allinone.sh
+++ b/scripts/pack/pack_allinone.sh
@@ -17,7 +17,7 @@
# load images
KUSCIA_IMAGE=""
-SECRETPAD_IMAGE=""
+EASYPSI_IMAGE=""
SECRETFLOW_IMAGE=""
GREEN='\033[0;32m'
@@ -46,8 +46,8 @@ if [ "${KUSCIA_IMAGE}" == "" ]; then
KUSCIA_IMAGE=secretflow-registry.cn-hangzhou.cr.aliyuncs.com/secretflow/kuscia:latest
fi
-if [ "${SECRETPAD_IMAGE}" == "" ]; then
- SECRETPAD_IMAGE=secretflow-registry.cn-hangzhou.cr.aliyuncs.com/secretflow/secretpad:latest
+if [ "${EASYPSI_IMAGE}" == "" ]; then
+ EASYPSI_IMAGE=secretflow-registry.cn-hangzhou.cr.aliyuncs.com/secretflow/easypsi:latest
fi
if [ "${SECRETFLOW_IMAGE}" == "" ]; then
@@ -55,24 +55,24 @@ if [ "${SECRETFLOW_IMAGE}" == "" ]; then
fi
echo "kuscia image: $KUSCIA_IMAGE"
-echo "secretpad image: $SECRETPAD_IMAGE"
+echo "easypsi image: $EASYPSI_IMAGE"
echo "secretflow image: $SECRETFLOW_IMAGE"
set -e
echo "docker pull ${KUSCIA_IMAGE}"
docker pull ${KUSCIA_IMAGE}
log "docker pull ${KUSCIA_IMAGE} done"
-echo "docker pull ${SECRETPAD_IMAGE}"
-docker pull ${SECRETPAD_IMAGE}
-log "docker pull ${SECRETPAD_IMAGE} done"
+echo "docker pull ${EASYPSI_IMAGE}"
+docker pull ${EASYPSI_IMAGE}
+log "docker pull ${EASYPSI_IMAGE} done"
echo "docker pull ${SECRETFLOW_IMAGE}"
docker pull ${SECRETFLOW_IMAGE}
log "docker pull ${SECRETFLOW_IMAGE} done"
kusciaTag=${KUSCIA_IMAGE##*:}
echo "kuscia tag: $kusciaTag"
-secretpadTag=${SECRETPAD_IMAGE##*:}
-echo "secretpad tag: $secretpadTag"
+easypsiTag=${EASYPSI_IMAGE##*:}
+echo "easypsi tag: $easypsiTag"
secretflowTag=${SECRETFLOW_IMAGE##*:}
echo "secretflow tag: $secretflowTag"
VERSION_TAG="$(git describe --tags)"
@@ -81,8 +81,8 @@ echo "${package_name} tag: $VERSION_TAG"
echo "docker save -o ./${package_name}/images/kuscia-${kusciaTag}.tar ${KUSCIA_IMAGE} "
docker save -o ./${package_name}/images/kuscia-${kusciaTag}.tar ${KUSCIA_IMAGE}
-echo "docker save -o ./${package_name}/images/secretpad-${secretpadTag}.tar ${SECRETPAD_IMAGE} "
-docker save -o ./${package_name}/images/secretpad-${secretpadTag}.tar ${SECRETPAD_IMAGE}
+echo "docker save -o ./${package_name}/images/easypsi-${easypsiTag}.tar ${EASYPSI_IMAGE} "
+docker save -o ./${package_name}/images/easypsi-${easypsiTag}.tar ${EASYPSI_IMAGE}
echo "docker save -o ./${package_name}/images/secretflow-${secretflowTag}.tar ${SECRETFLOW_IMAGE} "
docker save -o ./${package_name}/images/secretflow-${secretflowTag}.tar ${SECRETFLOW_IMAGE}
diff --git a/scripts/proto-to-java.sh b/scripts/proto-to-java.sh
index e6b4d7f..f903947 100755
--- a/scripts/proto-to-java.sh
+++ b/scripts/proto-to-java.sh
@@ -21,11 +21,11 @@ set -o pipefail
PROTOC=protoc
-SECRETPAD_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)
-echo "${SECRETPAD_ROOT}"
+EASYPSI_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)
+echo "${EASYPSI_ROOT}"
-SCRIPT_DIR=${SECRETPAD_ROOT}/scripts
-TMP_WORK_DIR=${SECRETPAD_ROOT}/tmp
+SCRIPT_DIR=${EASYPSI_ROOT}/scripts
+TMP_WORK_DIR=${EASYPSI_ROOT}/tmp
GRPC_JAVA_ROOT=${TMP_WORK_DIR}/grpc-java
GRPC_JAVA_PLUGIN=${GRPC_JAVA_ROOT}/compiler/build/exe/java_plugin/protoc-gen-grpc-java
@@ -69,7 +69,7 @@ function generate_java_code() {
function generate_kusciaapi_code() {
PROTO_ROOT_DIR=$1
PROTO_DIR="$1/kuscia"
- PROTO_OUTPUT_PATH=${SECRETPAD_ROOT}/secretpad-api/client-java-kusciaapi/src/main/java
+ PROTO_OUTPUT_PATH=${EASYPSI_ROOT}/easypsi-api/client-java-kusciaapi/src/main/java
pushd "$PROTO_ROOT_DIR" || exit
generate_java_code "$PROTO_DIR"
popd
@@ -78,7 +78,7 @@ function generate_kusciaapi_code() {
function generate_sf_code() {
PROTO_ROOT_DIR=$1
PROTO_DIR="$1/secretflow"
- PROTO_OUTPUT_PATH=${SECRETPAD_ROOT}/secretpad-service/src/main/java
+ PROTO_OUTPUT_PATH=${EASYPSI_ROOT}/easypsi-service/src/main/java
pushd "$PROTO_ROOT_DIR" || exit
generate_java_code "$PROTO_DIR"
popd
@@ -86,8 +86,8 @@ function generate_sf_code() {
function main() {
prepare
- generate_kusciaapi_code "${SECRETPAD_ROOT}/proto"
- generate_sf_code "${SECRETPAD_ROOT}/proto"
+ generate_kusciaapi_code "${EASYPSI_ROOT}/proto"
+ generate_sf_code "${EASYPSI_ROOT}/proto"
}
main
diff --git a/scripts/register_account.sh b/scripts/register_account.sh
index 9bcde15..7a19044 100755
--- a/scripts/register_account.sh
+++ b/scripts/register_account.sh
@@ -16,7 +16,7 @@
#
# global configuration
-DB_PATH="/app/db/secretpad.sqlite"
+DB_PATH="/app/db/easypsi.sqlite"
LOG_FILE_PATH_DEFAULT="/app/log/init.log"
USER_NAME=""
USER_PASSWD=""
diff --git a/scripts/start_p2p.sh b/scripts/start_p2p.sh
index 9e1079a..9b3e0b6 100755
--- a/scripts/start_p2p.sh
+++ b/scripts/start_p2p.sh
@@ -19,10 +19,10 @@ set -e
usage() {
echo "$(basename "$0") DEPLOY_MODE [OPTIONS]
- OPTIONS:
+ OPTIONS:
-n [mandatory] Domain id to be deployed.
-s [optional] The port exposed by edge, The port must NOT be occupied by other processes, default 10801
-
+ -t [optional] The kuscia TLS mode.
"
}
@@ -30,7 +30,7 @@ if [[ $ROOT == "" ]]; then
ROOT=$HOME/kuscia/p2p
fi
mkdir -p $ROOT
-echo "secretpad dir: $ROOT"
+echo "easypsi dir: $ROOT"
GREEN='\033[0;32m'
NC='\033[0m'
@@ -38,7 +38,7 @@ NC='\033[0m'
NODE_ID=""
CTR_PREFIX=${USER}-kuscia
CTR_ROOT=/home/kuscia
-CTR_CERT_ROOT=${CTR_ROOT}/etc/certs
+CTR_CERT_ROOT=${CTR_ROOT}/var/certs
FORCE_START=false
KUSCIA_CTR="" # ${CTR_PREFIX}-autonomy-${NODE_ID}
NETWORK_NAME="kuscia-exchange"
@@ -47,12 +47,12 @@ if [ "${KUSCIA_IMAGE}" != "" ]; then
IMAGE=${KUSCIA_IMAGE}
fi
echo -e "IMAGE=${IMAGE}"
-if [ "${SECRETPAD_IMAGE}" == "" ]; then
- SECRETPAD_IMAGE=secretflow-registry.cn-hangzhou.cr.aliyuncs.com/secretflow/secretpad
+if [ "${EASYPSI_IMAGE}" == "" ]; then
+ EASYPSI_IMAGE=secretflow-registry.cn-hangzhou.cr.aliyuncs.com/secretflow/easypsi
fi
-echo -e "SECRETPAD_IMAGE=${SECRETPAD_IMAGE}"
-SECRETPAD_USER_NAME=""
-SECRETPAD_PASSWORD=""
+echo -e "EASYPSI_IMAGE=${EASYPSI_IMAGE}"
+EASYPSI_USER_NAME=""
+EASYPSI_PASSWORD=""
VOLUME_PATH=""
JAVA_OPTS=""
SPRING_PROFILES_ACTIVE="p2p"
@@ -60,8 +60,9 @@ KUSCIA_API_ADDRESS=""
EDGE_DOMAIN_HOST_PORT=""
LITE_MEMORY_LIMIT=4G
KUSCIA_IMAGE=${KUSCIA_IMAGE}
-SECRETPAD_IMAGE=${SECRETPAD_IMAGE}
+EASYPSI_IMAGE=${EASYPSI_IMAGE}
SECRETFLOW_IMAGE=${SECRETFLOW_IMAGE}
+KUSCIA_PROTOCOL="mtls"
function log() {
local log_content=$1
@@ -99,64 +100,73 @@ function need_start_docker_container() {
return 1
}
-function copy_secretpad_file_to_volume() {
+function copy_easypsi_file_to_volume() {
local dst_path=$1
- mkdir -p ${dst_path}/secretpad
+ mkdir -p ${dst_path}/easypsi
mkdir -p ${dst_path}/data
# copy config file
- docker run --rm --entrypoint /bin/bash -v ${dst_path}/secretpad:/tmp/secretpad $SECRETPAD_IMAGE -c 'cp -R /app/config /tmp/secretpad/'
+ docker run --rm --entrypoint /bin/bash -v ${dst_path}/easypsi:/tmp/easypsi $EASYPSI_IMAGE -c 'cp -R /app/config /tmp/easypsi/'
# copy sqlite db file
- docker run --rm --entrypoint /bin/bash -v ${dst_path}/secretpad:/tmp/secretpad $SECRETPAD_IMAGE -c 'cp -R /app/db /tmp/secretpad/'
+ docker run --rm --entrypoint /bin/bash -v ${dst_path}/easypsi:/tmp/easypsi $EASYPSI_IMAGE -c 'cp -R /app/db /tmp/easypsi/'
# copy demo data file
- docker run --rm --entrypoint /bin/bash -v ${dst_path}:/tmp/secretpad $SECRETPAD_IMAGE -c 'cp -R /app/data /tmp/secretpad/'
+ docker run --rm --entrypoint /bin/bash -v ${dst_path}:/tmp/easypsi $EASYPSI_IMAGE -c 'cp -R /app/data /tmp/easypsi/'
log "copy webserver config and database file done"
}
-function generate_secretpad_serverkey() {
+function generate_easypsi_serverkey() {
local tmp_volume=$1
local password=$2
# generate server key in edge container
- docker run -it --rm --entrypoint /bin/bash --volume=${tmp_volume}/secretpad/config/:/tmp/temp ${SECRETPAD_IMAGE} -c "scripts/gen_secretpad_serverkey.sh ${password} /tmp/temp"
+ docker run -it --rm --entrypoint /bin/bash --volume=${tmp_volume}/easypsi/config/:/tmp/temp ${EASYPSI_IMAGE} -c "scripts/gen_easypsi_serverkey.sh ${password} /tmp/temp"
rm -rf ${tmp_volume}/server.jks
log "generate webserver server key done"
}
-function init_secretpad_db() {
+function init_easypsi_db() {
local root_path=$1
# generate server key in edge container
- docker run -it --rm --entrypoint /bin/bash --volume=${root_path}/secretpad/db:/app/db ${SECRETPAD_IMAGE} -c "scripts/update-sql.sh"
+ docker run -it --rm --entrypoint /bin/bash --volume=${root_path}/easypsi/db:/app/db ${EASYPSI_IMAGE} -c "scripts/update-sql.sh"
log "initialize webserver database done"
}
-function create_secretpad_user_password() {
+function create_easypsi_user_password() {
local root_path=$1
local user_name=$2
local password=$3
# generate server key in edge container
- docker run -it --rm --entrypoint /bin/bash --volume=${root_path}/secretpad/db:/app/db ${SECRETPAD_IMAGE} -c "scripts/register_account.sh -n '${user_name}' -p '${password}' -t P2P -o '${NODE_ID}'"
+ docker run -it --rm --entrypoint /bin/bash --volume=${root_path}/easypsi/db:/app/db ${EASYPSI_IMAGE} -c "scripts/register_account.sh -n '${user_name}' -p '${password}' -t P2P -o '${NODE_ID}'"
log "create webserver user and password done"
}
function copy_kuscia_api_client_certs() {
local root_path=$1
+ local kuscia_protocol=$2
# copy result
tmp_path=${root_path}/temp/certs
mkdir -p ${tmp_path}
- docker cp ${KUSCIA_CTR}:/${CTR_CERT_ROOT}/ca.crt ${tmp_path}/ca.crt
- docker cp ${KUSCIA_CTR}:/${CTR_CERT_ROOT}/kusciaapi-client.crt ${tmp_path}/client.crt
- docker cp ${KUSCIA_CTR}:/${CTR_CERT_ROOT}/kusciaapi-client.key ${tmp_path}/client.pem
+ # notls
+ if [[ ${kuscia_protocol} != "notls" ]]; then
+ docker cp ${KUSCIA_CTR}:/${CTR_CERT_ROOT}/ca.crt ${tmp_path}/ca.crt
+ fi
+
+ # mtls
+ if [[ ${kuscia_protocol} -eq "mtls" ]]; then
+ docker cp ${KUSCIA_CTR}:/${CTR_CERT_ROOT}/kusciaapi-client.crt ${tmp_path}/client.crt
+ docker cp ${KUSCIA_CTR}:/${CTR_CERT_ROOT}/kusciaapi-client.key ${tmp_path}/client.pem
+ fi
+
docker cp ${KUSCIA_CTR}:/${CTR_CERT_ROOT}/token ${tmp_path}/token
- docker run -d --rm --name ${CTR_PREFIX}-dummy --volume=${root_path}/secretpad/config:/tmp/temp $IMAGE tail -f /dev/null >/dev/null 2>&1
+ docker run -d --rm --name ${CTR_PREFIX}-dummy --volume=${root_path}/easypsi/config:/tmp/temp $IMAGE tail -f /dev/null >/dev/null 2>&1
docker cp -a ${tmp_path} ${CTR_PREFIX}-dummy:/tmp/temp/
docker rm -f ${CTR_PREFIX}-dummy >/dev/null 2>&1
rm -rf ${root_path}/temp
log "copy kuscia api client certs to web server container done"
}
-function render_secretpad_config() {
+function render_easypsi_config() {
local root_path=$1
- local tmpl_path=${root_path}/secretpad/config/template/application.yaml.tmpl
+ local tmpl_path=${root_path}/easypsi/config/template/application.yaml.tmpl
local store_key_password=$2
#local default_login_password
# create data mesh service
@@ -165,8 +175,8 @@ function render_secretpad_config() {
sed "s/{{.KUSCIA_API_ADDRESS}}/${KUSCIA_CTR}/g" ${tmpl_path} >${root_path}/application_01.yaml
# render store password
sed "s/{{.PASSWORD}}/${store_key_password}/g" ${root_path}/application_01.yaml >${root_path}/application.yaml
- # cp file to secretpad's config path
- docker run -d --rm --name ${CTR_PREFIX}-dummy --volume=${root_path}/secretpad/config:/tmp/temp $IMAGE tail -f /dev/null >/dev/null 2>&1
+ # cp file to easypsi's config path
+ docker run -d --rm --name ${CTR_PREFIX}-dummy --volume=${root_path}/easypsi/config:/tmp/temp $IMAGE tail -f /dev/null >/dev/null 2>&1
docker cp ${root_path}/application.yaml ${CTR_PREFIX}-dummy:/tmp/temp/
docker rm -f ${CTR_PREFIX}-dummy >/dev/null 2>&1
# rm temp file
@@ -194,10 +204,10 @@ function do_http_probe() {
return 1
}
-function probe_secret_pad() {
- local secretpad_ctr=$1
- if ! do_http_probe $secretpad_ctr "http://127.0.0.1:8080" 60; then
- echo "[Error] Probe secret pad in container '$secretpad_ctr' failed. Please check the log" >&2
+function probe_easy_psi() {
+ local easypsi_ctr=$1
+ if ! do_http_probe $easypsi_ctr "http://127.0.0.1:8080" 60; then
+ echo "[Error] Probe secret pad in container '$easypsi_ctr' failed. Please check the log" >&2
exit 1
fi
}
@@ -240,34 +250,34 @@ function account_settings() {
The username requires a length greater than 4, The password requires a length greater than 8,\n\
including uppercase and lowercase letters, numbers, and special characters."
for ((i = 0; i < 1; i++)); do
- read -r -p "Enter username(admin):" SECRETPAD_USER_NAME
- check_user_name "${SECRETPAD_USER_NAME}"
+ read -r -p "Enter username(admin):" EASYPSI_USER_NAME
+ check_user_name "${EASYPSI_USER_NAME}"
RET=$?
if [ "${RET}" -eq 0 ]; then
break
elif [ "${RET}" -ne 0 ] && [ "${i}" == 0 ]; then
log "would use default user: admin"
- SECRETPAD_USER_NAME="admin"
+ EASYPSI_USER_NAME="admin"
fi
done
stty -echo # disable display
for ((i = 0; i < 3; i++)); do
- read -r -p "Enter password: " SECRETPAD_PASSWORD
+ read -r -p "Enter password: " EASYPSI_PASSWORD
echo ""
- check_user_passwd "${SECRETPAD_PASSWORD}"
+ check_user_passwd "${EASYPSI_PASSWORD}"
RET=$?
if [ "${RET}" -eq 0 ]; then
local CONFIRM_PASSWD
read -r -p "Confirm password again: " CONFIRM_PASSWD
echo ""
- if [ "${CONFIRM_PASSWD}" == "${SECRETPAD_PASSWORD}" ]; then
+ if [ "${CONFIRM_PASSWD}" == "${EASYPSI_PASSWORD}" ]; then
break
else
log "Password not match! please reset"
fi
elif [ "${RET}" -ne 0 ] && [ "${i}" == 2 ]; then
log "would use default password: 12#\$qwER"
- SECRETPAD_PASSWORD="12#\$qwER"
+ EASYPSI_PASSWORD="12#\$qwER"
fi
done
set -e
@@ -282,7 +292,7 @@ function start_edge() {
# │ │ └── alice.csv
# │ └── bob
# │ └── bob.csv
- # └── secretpad
+ # └── easypsi
# ├── config
# └── db
#
@@ -290,34 +300,35 @@ function start_edge() {
local volume_data_path=$1
local port=$2
local root_path=$3
- local user_name=$SECRETPAD_USER_NAME
- local password=$SECRETPAD_PASSWORD
- local secretpad_ctr=${CTR_PREFIX}-secretpad-p2p-${NODE_ID}
- if need_start_docker_container $secretpad_ctr; then
- log "Starting container '$secretpad_ctr' ..."
- secretpad_key_pass="secretpad"
- # copy db,config,demodata from secretpad image
+ local kuscia_protocol=$4
+ local user_name=$EASYPSI_USER_NAME
+ local password=$EASYPSI_PASSWORD
+ local easypsi_ctr=${CTR_PREFIX}-easypsi-p2p-${NODE_ID}
+ if need_start_docker_container $easypsi_ctr; then
+ log "Starting container '$easypsi_ctr' ..."
+ easypsi_key_pass="easypsi"
+ # copy db,config,demodata from easypsi image
log "copy db,config,demodata to '$root_path' ..."
- copy_secretpad_file_to_volume ${root_path}
+ copy_easypsi_file_to_volume ${root_path}
# generate server key
log "generate server key '$root_path' ..."
- generate_secretpad_serverkey ${root_path} ${secretpad_key_pass}
- # initialize secretpad dbd
- init_secretpad_db ${root_path}
- # create secretpad user and password
- create_secretpad_user_password ${root_path} ${user_name} ${password}
+ generate_easypsi_serverkey ${root_path} ${easypsi_key_pass}
+ # initialize easypsi dbd
+ init_easypsi_db ${root_path}
+ # create easypsi user and password
+ create_easypsi_user_password ${root_path} ${user_name} ${password}
# copy kuscia api client certs
- copy_kuscia_api_client_certs ${root_path}
- # render secretpad config
- render_secretpad_config ${root_path} ${secretpad_key_pass}
+ copy_kuscia_api_client_certs ${root_path} ${kuscia_protocol}
+ # render easypsi config
+ render_easypsi_config ${root_path} ${easypsi_key_pass}
# make directory
mkdir -p ${root_path}
- # run secretpad
- docker run -itd --init --name=${secretpad_ctr} --restart=always --network=${NETWORK_NAME} -m $LITE_MEMORY_LIMIT \
+ # run easypsi
+ docker run -itd --init --name=${easypsi_ctr} --restart=always --network=${NETWORK_NAME} -m $LITE_MEMORY_LIMIT \
--volume=${volume_data_path}:/app/data \
--volume=${root_path}/kuscia-autonomy-${NODE_ID}-log:/app/log \
- --volume=${root_path}/secretpad/config:/app/config \
- --volume=${root_path}/secretpad/db:/app/db \
+ --volume=${root_path}/easypsi/config:/app/config \
+ --volume=${root_path}/easypsi/db:/app/db \
--workdir=/app \
-p $port:8080 \
-e SPRING_PROFILES_ACTIVE=${SPRING_PROFILES_ACTIVE} \
@@ -325,22 +336,24 @@ function start_edge() {
-e KUSCIA_API_ADDRESS=${KUSCIA_API_ADDRESS} \
-e KUSCIA_GW_ADDRESS=${KUSCIA_CTR}:80 \
-e HOST_PATH=${volume_data_path} \
- -e SECRETPAD_IMAGE=${SECRETPAD_IMAGE} \
+ -e EASYPSI_IMAGE=${EASYPSI_IMAGE} \
-e KUSCIA_IMAGE=${KUSCIA_IMAGE} \
-e SECRETFLOW_IMAGE=${SECRETFLOW_IMAGE} \
- ${SECRETPAD_IMAGE}
- probe_secret_pad ${secretpad_ctr}
+ -e KUSCIA_PROTOCOL=${KUSCIA_PROTOCOL} \
+ ${EASYPSI_IMAGE}
+ probe_easy_psi ${easypsi_ctr}
log "web server started successfully"
log "Please visit the website http://localhost:${port} (or http://{the IPAddress of this machine}:${port}) to experience the Kuscia web's functions ."
- log "The login name:'${SECRETPAD_USER_NAME}' ,The login password:'${SECRETPAD_PASSWORD}' ."
+ log "The login name:'${EASYPSI_USER_NAME}' ,The login password:'${EASYPSI_PASSWORD}' ."
log "The demo data would be stored in the path: ${VOLUME_PATH} ."
- log "the SECRETPAD_IMAGE is: ${SECRETPAD_IMAGE} ."
+ log "the kuscia tls mode is: ${KUSCIA_PROTOCOL} ."
+ log "the EASYPSI_IMAGE is: ${EASYPSI_IMAGE} ."
log "the KUSCIA_IMAGE is: ${KUSCIA_IMAGE} ."
log "the SECRETFLOW_TAG is: ${SECRETFLOW_IMAGE} ."
fi
}
-while getopts 'm:n:s:' option; do
+while getopts 'm:n:s:t:' option; do
case "$option" in
m)
KUSCIA_API_ADDRESS=$OPTARG
@@ -357,6 +370,9 @@ while getopts 'm:n:s:' option; do
s)
EDGE_DOMAIN_HOST_PORT=$OPTARG
;;
+ t)
+ KUSCIA_PROTOCOL=$OPTARG
+ ;;
:)
printf "missing argument for -%s\n" "$OPTARG" >&2
usage
@@ -369,5 +385,5 @@ while getopts 'm:n:s:' option; do
;;
esac
done
-start_edge "${VOLUME_PATH}" "$EDGE_DOMAIN_HOST_PORT" "${ROOT}"
+start_edge "${VOLUME_PATH}" "$EDGE_DOMAIN_HOST_PORT" "${ROOT}" "${KUSCIA_PROTOCOL}"
shift $((OPTIND - 1))
diff --git a/scripts/template/kuscia-autonomy-template.yaml b/scripts/template/kuscia-autonomy-template.yaml
new file mode 100644
index 0000000..12a365a
--- /dev/null
+++ b/scripts/template/kuscia-autonomy-template.yaml
@@ -0,0 +1,34 @@
+#
+# Copyright 2024 Ant Group Co., Ltd.
+#
+# 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.
+#
+mode: Autonomy
+domainID: {{.DOMAIN_ID}}
+domainKeyData: {{.DOMAIN_KEY_DATA}}
+logLevel: INFO
+runtime: runp
+runk:
+ namespace: ""
+ dnsServers: [ ]
+ kubeconfigFile: ""
+capacity:
+ cpu: ""
+ memory: ""
+ pods: ""
+ storage: ""
+image:
+ pullPolicy: ""
+ defaultRegistry: ""
+ registries: [ ]
+datastoreEndpoint: ""
\ No newline at end of file
diff --git a/scripts/test/setup.sh b/scripts/test/setup.sh
index d24a455..91c31d8 100755
--- a/scripts/test/setup.sh
+++ b/scripts/test/setup.sh
@@ -17,12 +17,12 @@
set -ex
-SECRETPAD_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)
+EASYPSI_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)
-echo "root path is: $SECRETPAD_ROOT"
+echo "root path is: $EASYPSI_ROOT"
function init_kusciaapi_certs() {
- CERT_DIR="$SECRETPAD_ROOT/config/certs"
+ CERT_DIR="$EASYPSI_ROOT/config/certs"
echo "cert path is: $CERT_DIR"
mkdir -p "$CERT_DIR"
pushd "$CERT_DIR" || exit
@@ -65,9 +65,9 @@ init_kusciaapi_certs
echo "generate kusciaapi certs successfully"
echo "start to init sqlite"
-mkdir -p "${SECRETPAD_ROOT}/db"
-SQL_PATH="${SECRETPAD_ROOT}/config/schema/init.sql"
-DB_PATH="${SECRETPAD_ROOT}/db/secretpad.sqlite"
+mkdir -p "${EASYPSI_ROOT}/db"
+SQL_PATH="${EASYPSI_ROOT}/config/schema/init.sql"
+DB_PATH="${EASYPSI_ROOT}/db/easypsi.sqlite"
if [ -e "${DB_PATH}" ]; then
echo >"${DB_PATH}"
sqlite3 "${DB_PATH}" ".read ${SQL_PATH}"
diff --git a/scripts/update-sf-components.sh b/scripts/update-sf-components.sh
index db04e20..0b1e352 100755
--- a/scripts/update-sf-components.sh
+++ b/scripts/update-sf-components.sh
@@ -25,7 +25,7 @@ usage="$(basename "$0") [OPTIONS]
OPTIONS:
-h [optional] show this help text
-i [mandatory] secretflow docker image info
- -u [optional] the user name of deploying the secretpad and kuscia container, default value: ${USER}
+ -u [optional] the user name of deploying the easypsi and kuscia container, default value: ${USER}
example:
./update-sf-components.sh -u ${USER} -i secretflow-registry.cn-hangzhou.cr.aliyuncs.com/secretflow/secretflow-lite-anolis8:latest
@@ -56,7 +56,7 @@ if [[ $SF_IMAGE = "" ]]; then
exit 1
fi
-SECRETPAD_CONTAINER_NAME="${DEPLOY_USER}-kuscia-secretpad"
+EASYPSI_CONTAINER_NAME="${DEPLOY_USER}-kuscia-easypsi"
SF_COMP_TEMP_DIR="/tmp/sf-cpts"
COMP_LIST=""
COMP_LIST_FILE="sf_comp_list.json"
@@ -93,21 +93,21 @@ function post_action() {
}
function update_sf_components() {
- echo "=> update secretflow components of the ${SECRETPAD_CONTAINER_NAME} container"
+ echo "=> update secretflow components of the ${EASYPSI_CONTAINER_NAME} container"
parse_sf_image_labels
echo "=> => replace secretflow components config file"
- docker cp "${SF_COMP_TEMP_DIR}/${COMP_LIST_FILE}" "${SECRETPAD_CONTAINER_NAME}:/app/config/components/secretflow.json" || exit 1
- docker cp "${SF_COMP_TEMP_DIR}/${COMP_TRANSLATION_FILE}" "${SECRETPAD_CONTAINER_NAME}:/app/config/i18n/secretflow.json" || exit 1
+ docker cp "${SF_COMP_TEMP_DIR}/${COMP_LIST_FILE}" "${EASYPSI_CONTAINER_NAME}:/app/config/components/secretflow.json" || exit 1
+ docker cp "${SF_COMP_TEMP_DIR}/${COMP_TRANSLATION_FILE}" "${EASYPSI_CONTAINER_NAME}:/app/config/i18n/secretflow.json" || exit 1
echo "=> => finish replacing secretflow components config file"
- echo "=> => restart container: ${SECRETPAD_CONTAINER_NAME}"
- docker restart "${SECRETPAD_CONTAINER_NAME}" > /dev/null
+ echo "=> => restart container: ${EASYPSI_CONTAINER_NAME}"
+ docker restart "${EASYPSI_CONTAINER_NAME}" > /dev/null
post_action
- echo "=> finish updating secretflow components of the ${SECRETPAD_CONTAINER_NAME} container"
+ echo "=> finish updating secretflow components of the ${EASYPSI_CONTAINER_NAME} container"
}
diff --git a/scripts/update-sql.sh b/scripts/update-sql.sh
index 3c9d251..6cd2527 100755
--- a/scripts/update-sql.sh
+++ b/scripts/update-sql.sh
@@ -16,10 +16,10 @@
#
set -ex
-SECRETPAD_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)
+EASYPSI_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)
-DB_PATH="$SECRETPAD_ROOT/db/secretpad.sqlite"
-SCHEMA_PATH="$SECRETPAD_ROOT/config/schema/init.sql"
+DB_PATH="$EASYPSI_ROOT/db/easypsi.sqlite"
+SCHEMA_PATH="$EASYPSI_ROOT/config/schema/init.sql"
rm -rf "$DB_PATH"
diff --git a/secretpad-common/src/main/java/org/secretflow/secretpad/common/annotation/JpaQuery.java b/secretpad-common/src/main/java/org/secretflow/secretpad/common/annotation/JpaQuery.java
deleted file mode 100644
index 1be5529..0000000
--- a/secretpad-common/src/main/java/org/secretflow/secretpad/common/annotation/JpaQuery.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright 2023 Ant Group Co., Ltd.
- *
- * 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.
- */
-
-package org.secretflow.secretpad.common.annotation;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * @author yutu
- * @date 2023/08/03
- */
-@Target(ElementType.FIELD)
-@Retention(RetentionPolicy.RUNTIME)
-public @interface JpaQuery {
- String propName() default "";
-
- Type type() default Type.EQUAL;
-
- String joinName() default "";
-
- Join join() default Join.LEFT;
-
- String blurry() default "";
-
- String or() default "";
-
- enum Type {
- /*
- * EQUAL
- */
- EQUAL,
- /*
- * GREATER_THAN
- */
- GREATER_THAN,
- /*
- * LESS_THAN
- */
- LESS_THAN,
- /*
- * INNER_LIKE
- */
- INNER_LIKE,
- /*
- * OR_INNER_LIKE
- */
- OR_INNER_LIKE,
- /*
- * LEFT_LIKE
- */
- LEFT_LIKE,
- /*
- * RIGHT_LIKE
- */
- RIGHT_LIKE,
- /*
- * LESS_THAN_NQ
- */
- LESS_THAN_NQ,
- /*
- * IN
- */
- IN,
- /*
- * NOT_IN
- */
- NOT_IN,
- /*
- * NOT_EQUAL
- */
- NOT_EQUAL,
- /*
- * BETWEEN
- */
- BETWEEN,
- /*
- * NOT_NULL
- */
- NOT_NULL,
- /*
- * IS_NULL
- */
- IS_NULL,
- // eg: SELECT * FROM table WHERE FIND_IN_SET('querytag', table.tags);
- FIND_IN_SET
- }
-
- enum Join {
- /*
- * LEFT
- */
- LEFT,
- /*
- * RIGHT
- */
- RIGHT,
- /*
- * INNER
- */
- INNER
- }
-}
\ No newline at end of file
diff --git a/secretpad-common/src/main/java/org/secretflow/secretpad/common/util/RSAUtils.java b/secretpad-common/src/main/java/org/secretflow/secretpad/common/util/RSAUtils.java
deleted file mode 100644
index 5be384a..0000000
--- a/secretpad-common/src/main/java/org/secretflow/secretpad/common/util/RSAUtils.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright 2023 Ant Group Co., Ltd.
- *
- * 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.
- */
-
-package org.secretflow.secretpad.common.util;
-
-import java.io.IOException;
-import java.security.KeyFactory;
-import java.security.Signature;
-import java.security.spec.PKCS8EncodedKeySpec;
-import java.util.Base64;
-
-/**
- * @author yutu
- * @date 2023/09/11
- */
-public class RSAUtils {
-
- public static String signRs256(String input) throws Exception {
- String strPk = FileUtils.readFile2String("./config/certs/client.pem");
- return signSHA256RSA(input, strPk);
- }
-
- public static String signSHA256RSAByPkFilePath(String input, String strPkFilePath) throws Exception {
- String strPk = FileUtils.readFile2String(strPkFilePath);
- return signSHA256RSA(input, strPk);
- }
-
- /**
- * Create base64 encoded signature using SHA256/RSA.
- *
- * @param input str
- * @param strPk pk
- */
- public static String signSHA256RSA(String input, String strPk) throws Exception {
- // Remove markers and new line characters in private key
- String realPK = strPk.replaceAll("-----END PRIVATE KEY-----", "")
- .replaceAll("-----BEGIN PRIVATE KEY-----", "")
- .replaceAll("\n", "");
- byte[] b1 = Base64.getDecoder().decode(realPK);
- PKCS8EncodedKeySpec spec = new PKCS8EncodedKeySpec(b1);
- KeyFactory kf = KeyFactory.getInstance("RSA");
- Signature privateSignature = Signature.getInstance("SHA256withRSA");
- privateSignature.initSign(kf.generatePrivate(spec));
- byte[] encode = input.getBytes();
- privateSignature.update(encode);
- byte[] s = privateSignature.sign();
- return Base64.getEncoder().encodeToString(s);
- }
-
- public static String getClientCert() throws IOException {
- String clientCertPath = "./config/certs/client.crt";
- return FileUtils.readFile2String(clientCertPath);
- }
-
- public static String getCaCert() throws IOException {
- String caCertPath = "./config/certs/ca.crt";
- return FileUtils.readFile2String(caCertPath);
- }
-
- public static String getTaskCertChain() throws IOException {
- String clientCertPath = "./config/certs/client.crt";
- String caCertPath = "./config/certs/ca.crt";
- String ca = FileUtils.readFile2String(caCertPath);
- String caStr = ca.replaceAll("-----END CERTIFICATE-----", "")
- .replaceAll("-----BEGIN CERTIFICATE-----", "")
- .replaceAll("\n", "");
- String client = FileUtils.readFile2String(clientCertPath);
- String clientStr = client.replaceAll("-----END CERTIFICATE-----", "")
- .replaceAll("-----BEGIN CERTIFICATE-----", "")
- .replaceAll("\n", "");
- return String.format("%s.%s", clientStr, caStr);
- }
-}
\ No newline at end of file
diff --git a/secretpad-common/src/main/java/org/secretflow/secretpad/common/util/SafeFileUtils.java b/secretpad-common/src/main/java/org/secretflow/secretpad/common/util/SafeFileUtils.java
deleted file mode 100644
index 71a8606..0000000
--- a/secretpad-common/src/main/java/org/secretflow/secretpad/common/util/SafeFileUtils.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright 2023 Ant Group Co., Ltd.
- *
- * 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.
- */
-
-package org.secretflow.secretpad.common.util;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.File;
-import java.util.List;
-
-/**
- * Check if the file safe utils
- *
- * @author : xiaonan.fhn
- * @date 2023/06/27
- */
-public class SafeFileUtils {
- private final static Logger LOGGER = LoggerFactory.getLogger(SafeFileUtils.class);
-
- /**
- * Check the filePath whether exist in the whitelist
- * The argument is util of the file path
- *
- * @param filePath file path
- * @param whitelistPath while list of path
- * @return whether exist in the whitelist
- */
- public static boolean checkPathInWhitelist(String filePath, List whitelistPath) {
- try {
- File file = new File(filePath);
- return checkPathInWhitelist(file, whitelistPath);
- } catch (Exception e) {
- LOGGER.error("FilepathTraversalChecker checkPathTraversal CatchException, " +
- "filePath = {} Check path traversal catch exception, not deny! error is {}", filePath, e);
- return true;
- }
- }
-
- /**
- * Check the filePath whether exist in the whitelist
- * The argument is util of the file path
- *
- * @param file file path
- * @param whitelistPath while list of path
- * @return whether exist in the whitelist
- */
- public static boolean checkPathInWhitelist(File file, List whitelistPath) {
- try {
- if (file == null) {
- LOGGER.error("Target file path is null, need to be deny!");
- return false;
- }
- String canonicalPath = file.getCanonicalPath();
- if ("".equals(canonicalPath)) {
- LOGGER.error("Target canonical file path is null, need to be deny!");
- return false;
- }
- if (whitelistPath == null) {
- LOGGER.error("White path list is null, using error, need to be deny!");
- return false;
- }
- for (String whitePath : whitelistPath) {
- if (canonicalPath.startsWith(whitePath)) {
- return true;
- }
- }
- LOGGER.error("Target canonical file path not in white list, need to deny!");
- return false;
- } catch (Exception e) {
- LOGGER.error("Check path traversal catch exception, not deny! error is {}", e);
- return true;
- }
- }
-}
diff --git a/secretpad-common/src/test/resources/a/a.txt b/secretpad-common/src/test/resources/a/a.txt
deleted file mode 100644
index 30d74d2..0000000
--- a/secretpad-common/src/test/resources/a/a.txt
+++ /dev/null
@@ -1 +0,0 @@
-test
\ No newline at end of file
diff --git a/secretpad-manager/src/main/java/org/secretflow/secretpad/manager/integration/model/NodeInstanceDTO.java b/secretpad-manager/src/main/java/org/secretflow/secretpad/manager/integration/model/NodeInstanceDTO.java
deleted file mode 100644
index e647cac..0000000
--- a/secretpad-manager/src/main/java/org/secretflow/secretpad/manager/integration/model/NodeInstanceDTO.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright 2023 Ant Group Co., Ltd.
- *
- * 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.
- */
-
-package org.secretflow.secretpad.manager.integration.model;
-
-import org.secretflow.secretpad.common.util.DateTimes;
-
-import lombok.Builder;
-import lombok.Data;
-import org.secretflow.v1alpha1.kusciaapi.Domain;
-
-import java.io.Serializable;
-
-/**
- * NodeInstanceDTO
- *
- * @author yutu
- * @date 2023/08/07
- */
-@Data
-@Builder
-public class NodeInstanceDTO implements Serializable {
- /**
- * domain name
- */
- private String name;
- /**
- * domain status Ready, NotReady
- */
- private String status;
- /**
- * Agent version
- */
- private String version;
- /**
- * lastHeartbeatTime,RFC3339(e.g. 2006-01-02T15:04:05Z)
- */
- private String lastHeartbeatTime;
- /**
- * lastTransitionTime,RFC3339(e.g. 2006-01-02T15:04:05Z)
- */
- private String lastTransitionTime;
-
- public static NodeInstanceDTO formDomainNodeStatus(Domain.NodeStatus nodeStatus) {
- return NodeInstanceDTO.builder().name(nodeStatus.getName()).status(nodeStatus.getStatus())
- .version(nodeStatus.getVersion())
- .lastHeartbeatTime(DateTimes.rfc3339ToGmt8(nodeStatus.getLastHeartbeatTime()))
- .lastTransitionTime(DateTimes.rfc3339ToGmt8(nodeStatus.getLastTransitionTime()))
- .build();
- }
-}
\ No newline at end of file
diff --git a/secretpad-manager/src/main/java/org/secretflow/secretpad/manager/kuscia/grpc/KusciaDomainRouteRpc.java b/secretpad-manager/src/main/java/org/secretflow/secretpad/manager/kuscia/grpc/KusciaDomainRouteRpc.java
deleted file mode 100644
index 9c997f9..0000000
--- a/secretpad-manager/src/main/java/org/secretflow/secretpad/manager/kuscia/grpc/KusciaDomainRouteRpc.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright 2023 Ant Group Co., Ltd.
- *
- * 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.
- */
-
-package org.secretflow.secretpad.manager.kuscia.grpc;
-
-import org.secretflow.v1alpha1.kusciaapi.DomainRoute;
-
-/**
- * @author yutu
- * @date 2023/08/09
- */
-public interface KusciaDomainRouteRpc extends KusciaRpc {
- DomainRoute.CreateDomainRouteResponse createDomainRoute(DomainRoute.CreateDomainRouteRequest request);
-
- DomainRoute.DeleteDomainRouteResponse deleteDomainRoute(DomainRoute.DeleteDomainRouteRequest request);
-
- DomainRoute.QueryDomainRouteResponse queryDomainRoute(DomainRoute.QueryDomainRouteRequest request);
-
- DomainRoute.BatchQueryDomainRouteStatusResponse
- batchQueryDomainRouteStatus(DomainRoute.BatchQueryDomainRouteStatusRequest request);
-}
\ No newline at end of file
diff --git a/secretpad-manager/src/main/java/org/secretflow/secretpad/manager/kuscia/grpc/impl/KusciaDomainRouteRpcImpl.java b/secretpad-manager/src/main/java/org/secretflow/secretpad/manager/kuscia/grpc/impl/KusciaDomainRouteRpcImpl.java
deleted file mode 100644
index 325c689..0000000
--- a/secretpad-manager/src/main/java/org/secretflow/secretpad/manager/kuscia/grpc/impl/KusciaDomainRouteRpcImpl.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright 2023 Ant Group Co., Ltd.
- *
- * 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.
- */
-
-package org.secretflow.secretpad.manager.kuscia.grpc.impl;
-
-import org.secretflow.secretpad.manager.kuscia.grpc.KusciaDomainRouteRpc;
-
-import lombok.RequiredArgsConstructor;
-import lombok.extern.slf4j.Slf4j;
-import org.secretflow.v1alpha1.kusciaapi.DomainRoute;
-import org.secretflow.v1alpha1.kusciaapi.DomainRouteServiceGrpc;
-import org.springframework.stereotype.Service;
-
-/**
- * @author yutu
- * @date 2023/08/09
- */
-@Slf4j
-@Service
-@RequiredArgsConstructor
-public class KusciaDomainRouteRpcImpl implements KusciaDomainRouteRpc {
- private final DomainRouteServiceGrpc.DomainRouteServiceBlockingStub domainRouteServiceBlockingStub;
-
- @Override
- public DomainRoute.CreateDomainRouteResponse createDomainRoute(DomainRoute.CreateDomainRouteRequest request) {
- log.info("DomainRouteServiceGrpc createDomainRoute request{}", request);
- DomainRoute.CreateDomainRouteResponse response = domainRouteServiceBlockingStub.createDomainRoute(request);
- log.info("DomainRouteServiceGrpc createDomainRoute response{}", response);
- checkResponse(response.getStatus());
- return response;
- }
-
- @Override
- public DomainRoute.DeleteDomainRouteResponse deleteDomainRoute(DomainRoute.DeleteDomainRouteRequest request) {
- log.info("DomainRouteServiceGrpc deleteDomainRoute request{}", request);
- DomainRoute.DeleteDomainRouteResponse response = domainRouteServiceBlockingStub.deleteDomainRoute(request);
- log.info("DomainRouteServiceGrpc deleteDomainRoute response{}", response);
- checkResponse(response.getStatus());
- return response;
- }
-
- @Override
- public DomainRoute.QueryDomainRouteResponse queryDomainRoute(DomainRoute.QueryDomainRouteRequest request) {
- log.info("DomainRouteServiceGrpc queryDomainRoute request{}", request);
- DomainRoute.QueryDomainRouteResponse response = domainRouteServiceBlockingStub.queryDomainRoute(request);
- log.info("DomainRouteServiceGrpc queryDomainRoute response{}", response);
- checkResponse(response.getStatus());
- return response;
- }
-
- @Override
- public DomainRoute.BatchQueryDomainRouteStatusResponse
- batchQueryDomainRouteStatus(DomainRoute.BatchQueryDomainRouteStatusRequest request) {
- log.info("DomainRouteServiceGrpc batchQueryDomainRouteStatus request{}", request);
- DomainRoute.BatchQueryDomainRouteStatusResponse response =
- domainRouteServiceBlockingStub.batchQueryDomainRouteStatus(request);
- log.info("DomainRouteServiceGrpc batchQueryDomainRouteStatus response{}", response);
- checkResponse(response.getStatus());
- return response;
- }
-}
\ No newline at end of file
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/auth/impl/DefaultDataResourceAuth.java b/secretpad-service/src/main/java/org/secretflow/secretpad/service/auth/impl/DefaultDataResourceAuth.java
deleted file mode 100644
index 4dd3986..0000000
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/auth/impl/DefaultDataResourceAuth.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright 2023 Ant Group Co., Ltd.
- *
- * 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.
- */
-
-package org.secretflow.secretpad.service.auth.impl;
-
-import org.secretflow.secretpad.common.constant.UserOwnerType;
-import org.secretflow.secretpad.common.constant.resource.DataResourceType;
-import org.secretflow.secretpad.common.util.UserContext;
-import org.secretflow.secretpad.service.auth.DataResourceAuth;
-
-import lombok.extern.slf4j.Slf4j;
-
-/**
- * @author beiwei
- * @date 2023/9/11
- */
-//@Service
-@Slf4j
-public class DefaultDataResourceAuth implements DataResourceAuth {
- /**
- * @param resourceType resource type
- * @param resourceId resource id
- * @return result
- */
- @Override
- public boolean check(DataResourceType resourceType, String resourceId) {
- UserOwnerType ownerType = UserContext.getUser().getOwnerType();
- if (UserOwnerType.CENTER.equals(ownerType)) {
- // Center user has all data permission
- return true;
- }
-
- if (DataResourceType.NODE_ID.equals(resourceType)) {
- return UserContext.getUser().getOwnerId().equals(resourceId);
- }
-
-// if (DataResourceType.PROJECT_ID.equals(resourceType)) {
-// return UserContext.getUser().containProjectId(resourceId);
-// }
- return false;
- }
-}
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/factory/JsonProtobufSourceFactory.java b/secretpad-service/src/main/java/org/secretflow/secretpad/service/factory/JsonProtobufSourceFactory.java
deleted file mode 100644
index befca56..0000000
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/factory/JsonProtobufSourceFactory.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright 2023 Ant Group Co., Ltd.
- *
- * 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.
- */
-
-package org.secretflow.secretpad.service.factory;
-
-import org.secretflow.secretpad.service.constant.ComponentConstants;
-
-import com.google.protobuf.Message;
-import com.google.protobuf.util.JsonFormat;
-import org.secretflow.proto.component.Comp;
-import org.springframework.util.ResourceUtils;
-
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Json protobuf source factory
- *
- * @author yansi
- * @date 2023/5/30
- */
-public class JsonProtobufSourceFactory {
- private final String[] locations;
-
- public JsonProtobufSourceFactory(String[] locations) {
- this.locations = locations;
- }
-
- /**
- * Load components from locations
- *
- * @return component list
- * @throws IOException
- */
- public List load() throws IOException {
- if (locations == null || locations.length <= 0) {
- throw new IllegalArgumentException("locations can not be null or empty");
- }
- List items = new ArrayList<>();
- List resp = new ArrayList<>();
- List secretpad = new ArrayList<>();
- for (String location : locations) {
- File dir = ResourceUtils.getFile(location);
- File[] files = dir.listFiles();
- for (File file : files) {
- Message.Builder itemBuilder = Comp.CompListDef.newBuilder();
- JsonFormat.parser().ignoringUnknownFields().merge(new FileReader(file), itemBuilder);
- Comp.CompListDef compListDef = (Comp.CompListDef) itemBuilder.build();
- items.add(compListDef);
- if (compListDef.getName().equals(ComponentConstants.SECRETPAD)) {
- secretpad = compListDef.getCompsList();
- }
- }
- }
- for (Comp.CompListDef item : items) {
- if (!item.getName().equals(ComponentConstants.SECRETPAD)) {
- Comp.CompListDef build = item.toBuilder().addAllComps(secretpad).build();
- resp.add(build);
- } else {
- resp.add(item);
- }
- }
- return resp;
- }
-}
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/impl/RemoteRequestServiceImpl.java b/secretpad-service/src/main/java/org/secretflow/secretpad/service/impl/RemoteRequestServiceImpl.java
deleted file mode 100644
index 673b241..0000000
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/impl/RemoteRequestServiceImpl.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright 2023 Ant Group Co., Ltd.
- *
- * 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.
- */
-package org.secretflow.secretpad.service.impl;
-
-import org.secretflow.secretpad.common.constant.DomainRouterConstants;
-import org.secretflow.secretpad.common.errorcode.JobErrorCode;
-import org.secretflow.secretpad.common.errorcode.KusciaGrpcErrorCode;
-import org.secretflow.secretpad.common.errorcode.NodeRouteErrorCode;
-import org.secretflow.secretpad.common.exception.SecretpadException;
-import org.secretflow.secretpad.common.util.JsonUtils;
-import org.secretflow.secretpad.common.util.RestTemplateUtil;
-import org.secretflow.secretpad.service.NodeRouterService;
-import org.secretflow.secretpad.service.NodeService;
-import org.secretflow.secretpad.service.RemoteRequestService;
-import org.secretflow.secretpad.service.model.common.SecretPadResponse;
-
-import com.google.common.collect.ImmutableMap;
-import org.apache.commons.lang3.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.scheduling.annotation.Async;
-import org.springframework.scheduling.annotation.AsyncResult;
-import org.springframework.stereotype.Service;
-
-import java.util.concurrent.Future;
-
-/**
- * @author liujunhao
- * @date 2023/11/20
- */
-@Service
-public class RemoteRequestServiceImpl implements RemoteRequestService {
-
- private final static Logger LOGGER = LoggerFactory.getLogger(RemoteRequestService.class);
-
- @Autowired
- private NodeRouterService nodeRouterService;
-
- @Autowired
- private NodeService nodeService;
-
-
- @Override
- public boolean checkBothSidesNodeRouteIsReady(String srcNodeId, String dstNodeId) {
- LOGGER.info("check node nodeRoute status");
- String nodeRouteStatus;
- try{
- nodeService.getNodeNotCheck();
- }catch (Exception e){
- throw SecretpadException.of(KusciaGrpcErrorCode.KUSCIA_CPMMECT_ERROR);
- }
- try {
- nodeRouteStatus = nodeRouterService.getNodeRouteStatus(srcNodeId, dstNodeId);
- }catch (Exception e){
- throw SecretpadException.of(NodeRouteErrorCode.NODE_ROUTE_NOT_READY, dstNodeId);
- }
- if (!StringUtils.equals(nodeRouteStatus, DomainRouterConstants.DomainRouterStatusEnum.Succeeded.name())) {
- throw SecretpadException.of(NodeRouteErrorCode.NODE_ROUTE_NOT_READY, dstNodeId);
- }
- return true;
- }
-
- @Override
- public SecretPadResponse sendPostJson(Object request, String partnerNodeId, String url) {
- String svc = "secretpad." + partnerNodeId + ".svc";
- ImmutableMap immutableMap = ImmutableMap.of("Host", svc);
- SecretPadResponse secretPadResponse = RestTemplateUtil.sendPostJson(url, request, immutableMap, SecretPadResponse.class);
- LOGGER.info("secretPadResponse={}", JsonUtils.toJSONString(secretPadResponse));
- if (secretPadResponse.getStatus().getCode() != 0) {
- LOGGER.error("secretPadResponse error msg={}", secretPadResponse.getStatus().getMsg());
- throw SecretpadException.of(JobErrorCode.PROJECT_JOB_RPC_ERROR,secretPadResponse.getStatus().getMsg());
- }
- return secretPadResponse;
- }
-
- @Async
- @Override
- public Future asyncSendPostJson(Object request, String partnerNodeId, String url) {
- return new AsyncResult<>(sendPostJson(request,partnerNodeId,url));
- }
-}
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/auth/UserCreateRequest.java b/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/auth/UserCreateRequest.java
deleted file mode 100644
index afb8616..0000000
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/auth/UserCreateRequest.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright 2023 Ant Group Co., Ltd.
- *
- * 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.
- */
-
-package org.secretflow.secretpad.service.model.auth;
-
-import io.swagger.v3.oas.annotations.media.Schema;
-import jakarta.validation.constraints.NotBlank;
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
-import org.secretflow.secretpad.common.constant.UserOwnerType;
-
-/**
- * @author beiwei
- * @date 2023/9/13
- */
-@Setter
-@Getter
-@ToString
-public class UserCreateRequest {
- /**
- * CENTER or EDGE
- */
- @NotBlank
- private UserOwnerType ownerType;
-
- @NotBlank
- private String ownerId;
- /**
- * User name
- */
- @Schema(description = "user name")
- @NotBlank
- private String name;
-
- /**
- * User password
- */
- @NotBlank
- @Schema(description = "user password")
- private String passwordHash;
-
-
-}
diff --git a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/common/SecretPadPageRequest.java b/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/common/SecretPadPageRequest.java
deleted file mode 100644
index 8550215..0000000
--- a/secretpad-service/src/main/java/org/secretflow/secretpad/service/model/common/SecretPadPageRequest.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright 2023 Ant Group Co., Ltd.
- *
- * 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.
- */
-
-package org.secretflow.secretpad.service.model.common;
-
-import org.secretflow.secretpad.common.constant.DatabaseConstants;
-
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.data.domain.PageRequest;
-import org.springframework.data.domain.Pageable;
-import org.springframework.data.domain.Sort;
-import org.springframework.util.CollectionUtils;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * @author yutu
- * @date 2023/08/06
- */
-@Slf4j
-@Getter
-@Setter
-@ToString
-public class SecretPadPageRequest {
-
- /**
- * page num default 1
- */
- private int page = 1;
- /**
- * page size default 10
- */
- private int size = 10;
- /**
- * sort,property,property(,ASC|DESC) "createdDate,desc"
- */
- private Map