├── .gitignore
├── PostmanConfig
├── invoke.postman_collection.json
└── weidentity-restservice.postman_environment.json
├── README.md
├── build.gradle
├── dependencies
├── .gitkeep
└── wallet-agent-0.1.0.jar
├── fisco.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── keys
└── priv
│ └── .gitkeep
├── private_key
├── script
├── deploy_payment.sh
├── server_status.sh
├── start.sh
└── stop.sh
├── settings.gradle
├── src
├── main
│ ├── java
│ │ └── com
│ │ │ └── webank
│ │ │ └── weid
│ │ │ └── http
│ │ │ ├── Application.java
│ │ │ ├── aspect
│ │ │ └── ServiceLogAspect.java
│ │ │ ├── config
│ │ │ ├── BeanConfig.java
│ │ │ └── HttpsConfig.java
│ │ │ ├── constant
│ │ │ ├── HttpReturnCode.java
│ │ │ ├── SignType.java
│ │ │ ├── WalletAgentFunctionNames.java
│ │ │ ├── WeIdentityFunctionNames.java
│ │ │ ├── WeIdentityParamKeyConstant.java
│ │ │ └── WeIdentityServiceEndpoint.java
│ │ │ ├── controller
│ │ │ └── TransactionController.java
│ │ │ ├── protocol
│ │ │ ├── base
│ │ │ │ ├── ResolutionMetadata.java
│ │ │ │ ├── ResolveData.java
│ │ │ │ └── ResolveDataJsonLD.java
│ │ │ ├── request
│ │ │ │ ├── EndpointRequest.java
│ │ │ │ ├── InputArg.java
│ │ │ │ ├── ReqInput.java
│ │ │ │ ├── TransactionArg.java
│ │ │ │ └── payment
│ │ │ │ │ ├── AssetAddressList.java
│ │ │ │ │ ├── BAC004BatchSendInfo.java
│ │ │ │ │ ├── BAC004Info.java
│ │ │ │ │ ├── BAC004SendInfo.java
│ │ │ │ │ ├── BAC005BatchInfo.java
│ │ │ │ │ ├── BAC005Info.java
│ │ │ │ │ ├── BaseQuery.java
│ │ │ │ │ └── PageQuery.java
│ │ │ └── response
│ │ │ │ ├── EncodedTransactionWrapper.java
│ │ │ │ ├── EndpointInfo.java
│ │ │ │ ├── HttpResponseData.java
│ │ │ │ └── WeIdListRsp.java
│ │ │ ├── service
│ │ │ ├── AuthService.java
│ │ │ ├── BaseService.java
│ │ │ ├── EndpointService.java
│ │ │ ├── InvokeService.java
│ │ │ ├── InvokerAuthorityIssuerService.java
│ │ │ ├── InvokerCptService.java
│ │ │ ├── InvokerCredentialService.java
│ │ │ ├── InvokerEvidenceService.java
│ │ │ ├── InvokerWeIdService.java
│ │ │ ├── RawTransaction.java
│ │ │ ├── TransactionService.java
│ │ │ ├── impl
│ │ │ │ ├── AuthServiceImpl.java
│ │ │ │ ├── EndpointServiceImpl.java
│ │ │ │ ├── InvokerAuthorityIssuerServiceImpl.java
│ │ │ │ ├── InvokerCptServiceImpl.java
│ │ │ │ ├── InvokerCredentialServiceImpl.java
│ │ │ │ ├── InvokerEvidenceServiceImpl.java
│ │ │ │ ├── InvokerWeIdServiceImpl.java
│ │ │ │ └── TransactionServiceImpl.java
│ │ │ └── rpc
│ │ │ │ ├── FixedLengthProtocol.java
│ │ │ │ ├── RpcClient.java
│ │ │ │ ├── RpcConnectionHandler.java
│ │ │ │ └── SendTester.java
│ │ │ └── util
│ │ │ ├── EndpointDataUtil.java
│ │ │ ├── JsonUtil.java
│ │ │ ├── KeyUtil.java
│ │ │ ├── PropertiesUtil.java
│ │ │ ├── TransactionEncoderUtil.java
│ │ │ └── TransactionEncoderUtilV2.java
│ └── resources
│ │ ├── SpringApplicationContext.xml
│ │ ├── WeDPR_dynamic_lib
│ │ ├── ffi_selective_disclosure.dll
│ │ ├── libeay32md.dll
│ │ ├── libffi_selective_disclosure.so
│ │ └── ssleay32md.dll
│ │ ├── amop
│ │ ├── consumer_private_key.p12
│ │ └── consumer_public_key.pem
│ │ ├── application.properties
│ │ ├── client.keystore
│ │ ├── cpt.json
│ │ ├── endpoint-data.properties
│ │ ├── fisco.properties
│ │ ├── log4j2.xml
│ │ ├── server.keystore
│ │ ├── tb.jks
│ │ └── weidentity.properties
└── test
│ ├── java
│ └── com
│ │ └── webank
│ │ └── weid
│ │ └── http
│ │ ├── BaseTest.java
│ │ └── service
│ │ ├── CredentialTest.java
│ │ ├── EnCodeAndTranscatTest.java
│ │ ├── PrivateKeyTest.java
│ │ ├── PropertiesTest.java
│ │ ├── PureInvokerTest.java
│ │ ├── TransactionTest.java
│ │ └── TransactionTestV2.java
│ └── resources
│ ├── SpringApplicationContext.xml
│ ├── client.keystore
│ ├── cpt.json
│ ├── log4j2.xml
│ ├── server.keystore
│ └── tb.jks
└── weidentity.properties
/.gitignore:
--------------------------------------------------------------------------------
1 | Created by https://www.gitignore.io/api/vim,java,maven,gradle,java-web,intellij,intellij+iml
2 |
3 | ### Intellij ###
4 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
5 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
6 |
7 | # User-specific stuff:
8 | .idea/**/workspace.xml
9 | .idea/**/tasks.xml
10 | .idea/dictionaries
11 | .idea/checkstyle-idea.xml
12 |
13 | # Sensitive or high-churn files:
14 | .idea/**/dataSources/
15 | .idea/**/dataSources.ids
16 | .idea/**/dataSources.xml
17 | .idea/**/dataSources.local.xml
18 | .idea/**/sqlDataSources.xml
19 | .idea/**/dynamic.xml
20 | .idea/**/uiDesigner.xml
21 |
22 | # Gradle:
23 | .idea/**/gradle.xml
24 | .idea/**/libraries
25 |
26 | # CMake
27 | cmake-build-debug/
28 |
29 | # Mongo Explorer plugin:
30 | .idea/**/mongoSettings.xml
31 |
32 | # For idea
33 | .idea
34 |
35 | ## File-based project format:
36 | *.iws
37 |
38 | ## Plugin-specific files:
39 |
40 | # IntelliJ
41 | /out/
42 |
43 | # mpeltonen/sbt-idea plugin
44 | .idea_modules/
45 |
46 | # JIRA plugin
47 | atlassian-ide-plugin.xml
48 |
49 | # Cursive Clojure plugin
50 | .idea/replstate.xml
51 |
52 | # Crashlytics plugin (for Android Studio and IntelliJ)
53 | com_crashlytics_export_strings.xml
54 | crashlytics.properties
55 | crashlytics-build.properties
56 | fabric.properties
57 |
58 | ### Intellij Patch ###
59 | # Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
60 |
61 | # *.iml
62 | # modules.xml
63 | # .idea/misc.xml
64 | # *.ipr
65 |
66 | # Sonarlint plugin
67 | .idea/sonarlint
68 |
69 | ### Intellij+iml ###
70 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
71 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
72 |
73 | # User-specific stuff:
74 |
75 | # Sensitive or high-churn files:
76 |
77 | # Gradle:
78 |
79 | # CMake
80 |
81 | # Mongo Explorer plugin:
82 |
83 | ## File-based project format:
84 |
85 | ## Plugin-specific files:
86 |
87 | # IntelliJ
88 |
89 | # mpeltonen/sbt-idea plugin
90 |
91 | # JIRA plugin
92 |
93 | # Cursive Clojure plugin
94 |
95 | # Crashlytics plugin (for Android Studio and IntelliJ)
96 |
97 | ### Intellij+iml Patch ###
98 | # Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023
99 |
100 | *.iml
101 | modules.xml
102 | .idea/misc.xml
103 | *.ipr
104 |
105 | ### Java ###
106 | # Compiled class file
107 | *.class
108 |
109 | # Log file
110 | *.log
111 |
112 | # BlueJ files
113 | *.ctxt
114 |
115 | # Mobile Tools for Java (J2ME)
116 | .mtj.tmp/
117 |
118 | # Package Files #
119 | *.jar
120 | *.war
121 | *.ear
122 | *.zip
123 | *.tar.gz
124 | *.rar
125 |
126 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
127 | hs_err_pid*
128 |
129 | ### Java-Web ###
130 | ## ignoring target file
131 | target/
132 |
133 | ### Maven ###
134 | pom.xml.tag
135 | pom.xml.releaseBackup
136 | pom.xml.versionsBackup
137 | pom.xml.next
138 | release.properties
139 | dependency-reduced-pom.xml
140 | buildNumber.properties
141 | .mvn/timing.properties
142 |
143 | # Avoid ignoring Maven wrapper jar file (.jar files are usually ignored)
144 | !/.mvn/wrapper/maven-wrapper.jar
145 |
146 | ### Vim ###
147 | # swap
148 | [._]*.s[a-v][a-z]
149 | [._]*.sw[a-p]
150 | [._]s[a-v][a-z]
151 | [._]sw[a-p]
152 | # session
153 | Session.vim
154 | # temporary
155 | .netrwhist
156 | *~
157 | # auto-generated tag files
158 | tags
159 |
160 | ### Gradle ###
161 | .gradle
162 | /build/
163 |
164 | # Ignore Gradle GUI config
165 | gradle-app.setting
166 |
167 | # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
168 | !gradle-wrapper.jar
169 |
170 | # Cache of project
171 | .gradletasknamecache
172 |
173 | # # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
174 | # gradle/wrapper/gradle-wrapper.properties
175 |
176 | # End of https://www.gitignore.io/api/vim,java,maven,gradle,java-web,intellij,intellij+iml
177 |
178 | # added by junqizhang
179 | build.tar.gz
180 | .rsync.sh
181 | rsync.ex
182 | build/
183 | dist/
184 | bak/
185 | *docx
186 | *pdf
187 | *jpg
188 | javadoc/
189 |
190 | # for specific project
191 | doc/bak/
192 | /bin/
193 |
194 | # for eclipse
195 | .settings/
196 | .project
197 | .classpath
198 | keys/
199 | /resources/
200 | logs/
--------------------------------------------------------------------------------
/PostmanConfig/weidentity-restservice.postman_environment.json:
--------------------------------------------------------------------------------
1 | {
2 | "id": "e9e5df8a-f86d-4fd3-8c04-370dce21bb2d",
3 | "name": "weidentity-restservice",
4 | "values": [
5 | {
6 | "key": "host",
7 | "value": "127.0.0.1",
8 | "description": "",
9 | "enabled": true
10 | },
11 | {
12 | "key": "httpport",
13 | "value": "6001",
14 | "description": "",
15 | "enabled": true
16 | }
17 | ],
18 | "_postman_variable_scope": "environment",
19 | "_postman_exported_at": "2019-04-02T11:00:27.074Z",
20 | "_postman_exported_using": "Postman/7.0.6"
21 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # WeIdentity HTTP Service
2 |
3 | ---
4 |
5 | ## 总体介绍
6 | WeIdentity Restful HTTP Service提供了简化的WeIdentity集成方式与访问能力。
7 | 使用者仅需部署一台Java的机器,
8 | 便可以使用各种类型的HTTP/HTTPS协议访问WeIdentity的功能了,
9 | 不再需要通过Java API方式调用SDK。
10 |
11 | ## 功能介绍
12 | 目前,WeIdentity RestService支持客户端密钥管理、服务器端密钥托管、数字身份标识(WeIdentity DID)管理、
13 | 标准化凭证(WeIdentity Credential)管理、授权机构(Authority Issuer)管理、标准化模板(CPT)管理等功能。
14 |
15 | 详细的设计及使用说明,请参见 [WeIdentity RestService文档](https://weidentity.readthedocs.io/zh_CN/latest/docs/weidentity-rest.html)
16 |
17 | WeIdentity及其组件的[兼容版本说明文档](https://weidentity.readthedocs.io/zh_CN/develop/docs/compatibility.html) 请查看!
18 |
19 | ## 联系我们
20 |
21 | 邮箱:weidentity@webank.com
22 |
23 | ## License
24 |
25 | This project is released under [Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0).
26 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | def gradleVer = "4"
2 | if (gradle.gradleVersion.startsWith("6")
3 | || gradle.gradleVersion.startsWith("5")
4 | || gradle.gradleVersion.startsWith("4.10")
5 | || gradle.gradleVersion.startsWith("4.9")
6 | || gradle.gradleVersion.startsWith("4.8")
7 | || gradle.gradleVersion.startsWith("4.7")) {
8 | println "Gradle with version >= 4.7 detected"
9 | gradleVer = "5"
10 | } else {
11 | println "Gradle with version < 4.7 detected"
12 | }
13 |
14 | apply plugin: 'maven'
15 | apply plugin: 'java'
16 | apply plugin: 'eclipse'
17 | apply plugin: 'idea'
18 |
19 | version = "1.7.0"
20 |
21 | // Specify JDK version - may vary in different scenarios
22 | sourceCompatibility = 1.8
23 | targetCompatibility = 1.8
24 |
25 | [compileJava, compileTestJava, javadoc]*.options*.encoding = 'UTF-8'
26 | // In this section you declare where to find the dependencies of your project
27 | repositories {
28 | maven {
29 | url "http://maven.aliyun.com/nexus/content/groups/public/"
30 | mavenCentral()
31 | }
32 | //maven { url "https://dl.bintray.com/ethereum/maven/" }
33 | maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
34 | maven { url "https://oss.sonatype.org/content/groups/public/" }
35 | mavenLocal()
36 | }
37 |
38 | List lombok = [
39 | 'org.projectlombok:lombok:1.18.12'
40 | ]
41 |
42 | def spring_version = "5.3.18"
43 | List spring = [
44 | "org.springframework:spring-core:$spring_version",
45 | "org.springframework:spring-beans:$spring_version",
46 | "org.springframework:spring-context:$spring_version",
47 | "org.springframework:spring-tx:$spring_version",
48 | "org.springframework:spring-jdbc:$spring_version",
49 | "org.springframework:spring-test:$spring_version",
50 | "org.springframework:spring-context-support:$spring_version",
51 | "org.springframework:spring-web:$spring_version",
52 | "org.springframework:spring-webmvc:$spring_version"
53 | ]
54 |
55 | def spring_boot_version = "2.4.1"
56 | List spring_boot = [
57 | "org.springframework.boot:spring-boot-starter-web:$spring_boot_version",
58 | "org.springframework.boot:spring-boot-autoconfigure:$spring_boot_version",
59 | "org.springframework.boot:spring-boot-configuration-processor:$spring_boot_version",
60 | "org.springframework.boot:spring-boot-starter-log4j2:$spring_boot_version",
61 | "org.springframework.boot:spring-boot-starter-aop:$spring_boot_version"
62 | ]
63 |
64 | def log4j_version = "2.18.0"
65 | List log4j = [
66 | "org.apache.logging.log4j:log4j-api:$log4j_version",
67 | "org.apache.logging.log4j:log4j-web:$log4j_version",
68 | "org.apache.logging.log4j:log4j-core:$log4j_version",
69 | "org.apache.logging.log4j:log4j-jcl:$log4j_version",
70 | "org.apache.logging.log4j:log4j-jul:$log4j_version",
71 | "org.apache.logging.log4j:log4j-slf4j-impl:$log4j_version"
72 | ]
73 |
74 | List spring_boot_test = [
75 | "org.springframework.boot:spring-boot-starter-test:$spring_boot_version"
76 | ]
77 |
78 | // junit test
79 | List junit = [
80 | "junit:junit:4.13.1",
81 | "org.springframework:spring-test:$spring_version"
82 | ]
83 |
84 | // In this section you declare the dependencies for your production and test code
85 | List json = [
86 | "javax.validation:validation-api:1.1.0.Final",
87 | "com.google.code.gson:gson:2.8.9"
88 | ]
89 |
90 | List weid = [
91 | 'com.webank:weid-java-sdk:3.1.1-rc.2-SNAPSHOT',
92 | "com.webank:weid-kit:3.1.0-rc.1"
93 | ]
94 |
95 | // In this section you declare the dependencies for your production and test code
96 | dependencies {
97 | compile spring, json, spring_boot, log4j
98 | testCompile spring, json, junit, spring_boot, log4j, spring_boot_test
99 | // Check SDK pipeline dependency
100 | if (file("./dependencies/weid-java-sdk-pipeline.jar").exists()) {
101 | println "Pipeline jar for WeIdentity Java SDK found."
102 | compile files('./dependencies/weid-java-sdk-pipeline.jar')
103 | testCompile files('./dependencies/weid-java-sdk-pipeline.jar')
104 | compile fileTree(dir: 'libs', include: '*.jar')
105 | testCompile fileTree(dir: 'libs', include: '*.jar')
106 | } else {
107 | println "No pipeline jar found for WeIdentity Java SDK, using gradle version.."
108 | compile weid
109 | testCompile weid
110 | }
111 | if (gradleVer.startsWith("4")) {
112 | compile lombok
113 | testCompile lombok
114 | }
115 | if (gradleVer.startsWith("5")) {
116 | compileOnly lombok
117 | annotationProcessor lombok
118 | testAnnotationProcessor lombok
119 | testCompileOnly lombok
120 | }
121 | compile files('./dependencies/wallet-agent-0.1.0.jar')
122 | }
123 |
124 | configurations {
125 | all*.exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging'
126 | all*.exclude group: "io.netty", module: "netty-tcnative"
127 | }
128 |
129 | sourceSets {
130 | main {
131 | java {
132 | srcDirs = ['src/main/java']
133 | }
134 | resources {
135 | srcDirs = ['src/main/resources']
136 | }
137 | }
138 | test {
139 | java {
140 | srcDirs = ['src/test/java']
141 | }
142 | resources {
143 | srcDirs = ['src/test/resources']
144 | }
145 | }
146 | }
147 |
148 | eclipse {
149 | classpath {
150 | downloadSources = false
151 | }
152 | }
153 |
154 | jar {
155 | destinationDir file('dist/apps')
156 | archiveName project.name + '-' + version + '.jar'
157 | exclude '**/*.xml', '**/*.properties'
158 |
159 | doLast {
160 | copy {
161 | from file('src/main/resources/')
162 | into 'dist/conf'
163 | }
164 | copy {
165 | from file('script/')
166 | into 'dist'
167 | }
168 | copy {
169 | from configurations.runtime
170 | into 'dist/lib'
171 | }
172 | copy {
173 | from file('keys/priv')
174 | into 'dist/keys/priv'
175 | }
176 | copy {
177 | from file('private_key')
178 | into 'dist'
179 | }
180 | copy {
181 | from file('.').listFiles().findAll { File f -> (f.name.endsWith('.bat') || f.name.endsWith('.sh') || f.name.endsWith('.env')) }
182 | into 'dist'
183 | }
184 | }
185 | }
186 |
--------------------------------------------------------------------------------
/dependencies/.gitkeep:
--------------------------------------------------------------------------------
1 | # Ignore everything in this directory
2 | *
3 | # Except this file !.gitkeep
--------------------------------------------------------------------------------
/dependencies/wallet-agent-0.1.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WeBankBlockchain/WeIdentity-Rest-Service/437042e6a4d3a56e52bb1a45fd52bf54fc870ce9/dependencies/wallet-agent-0.1.0.jar
--------------------------------------------------------------------------------
/fisco.properties:
--------------------------------------------------------------------------------
1 | # Fisco-bcos blockchain node related properties
2 |
3 | #######################################################################################################
4 | # #
5 | # fisco bcos version config #
6 | # #
7 | #######################################################################################################
8 | # Version
9 | bcos.version=2
10 |
11 |
12 | #######################################################################################################
13 | # #
14 | # contract address config #
15 | # #
16 | #######################################################################################################
17 | # contract address
18 | weId.contractaddress=
19 | cpt.contractaddress=
20 | issuer.contractaddress=
21 | evidence.contractaddress=
22 | specificissuer.contractaddress=
23 |
24 | # This variable is used to distinguish the environment. You can use "dev" to set the development environment,
25 | # "stg" to set the test environment, "prd" to set the production environment,
26 | # If you do not set it, the system will use allOrg as the environment by default.
27 | # It is not recommended. Production use default configuration
28 | cns.profile.active=prdabce
29 |
30 | #######################################################################################################
31 | # #
32 | # web3sdk connection config #
33 | # #
34 | #######################################################################################################
35 | # blockchain connection params
36 | web3sdk.timeout=30
37 | web3sdk.core-pool-size=100
38 | web3sdk.max-pool-size=200
39 | web3sdk.queue-capacity=1000
40 | web3sdk.keep-alive-seconds=60
41 |
42 |
43 | #######################################################################################################
44 | # #
45 | # fisco bcos 2.0 related config #
46 | # #
47 | #######################################################################################################
48 | # Fisco-Bcos 2.x params, including Group ID and Encrypt Type
49 | group.id=1
50 |
51 | #######################################################################################################
52 | # #
53 | # fisco bcos node cert related config #
54 | # #
55 | #######################################################################################################
56 | # Fisco-Bcos sdk SSL encrypt type, 0:ECDSA, 1:SM2
57 | sdk.sm-crypto=0
58 | # fisco-bcos sdk cert path contains[ca.crt,sdk.crt,sdk.key]
59 | # if sdk.sm-crypto is true, contains [gm] directory, and gm dir contains [gmca.crt,gmsdk.crt,gmsdk.key,gmensdk.crt,gmensdk.key]
60 | sdk.cert-path=resources/conf
61 |
62 | # amop public key of pem and private key of p12 configuration
63 | amop.pub-path=resources/conf/amop/consumer_public_key.pem
64 | amop.pri-path=resources/conf/amop/consumer_private_key.p12
65 | amop.p12-password=123456
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WeBankBlockchain/WeIdentity-Rest-Service/437042e6a4d3a56e52bb1a45fd52bf54fc870ce9/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-bin.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | #
4 | # Copyright 2015 the original author or authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | ##############################################################################
20 | ##
21 | ## Gradle start up script for UN*X
22 | ##
23 | ##############################################################################
24 |
25 | # Attempt to set APP_HOME
26 | # Resolve links: $0 may be a link
27 | PRG="$0"
28 | # Need this for relative symlinks.
29 | while [ -h "$PRG" ] ; do
30 | ls=`ls -ld "$PRG"`
31 | link=`expr "$ls" : '.*-> \(.*\)$'`
32 | if expr "$link" : '/.*' > /dev/null; then
33 | PRG="$link"
34 | else
35 | PRG=`dirname "$PRG"`"/$link"
36 | fi
37 | done
38 | SAVED="`pwd`"
39 | cd "`dirname \"$PRG\"`/" >/dev/null
40 | APP_HOME="`pwd -P`"
41 | cd "$SAVED" >/dev/null
42 |
43 | APP_NAME="Gradle"
44 | APP_BASE_NAME=`basename "$0"`
45 |
46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
48 |
49 | # Use the maximum available, or set MAX_FD != -1 to use that value.
50 | MAX_FD="maximum"
51 |
52 | warn () {
53 | echo "$*"
54 | }
55 |
56 | die () {
57 | echo
58 | echo "$*"
59 | echo
60 | exit 1
61 | }
62 |
63 | # OS specific support (must be 'true' or 'false').
64 | cygwin=false
65 | msys=false
66 | darwin=false
67 | nonstop=false
68 | case "`uname`" in
69 | CYGWIN* )
70 | cygwin=true
71 | ;;
72 | Darwin* )
73 | darwin=true
74 | ;;
75 | MINGW* )
76 | msys=true
77 | ;;
78 | NONSTOP* )
79 | nonstop=true
80 | ;;
81 | esac
82 |
83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
84 |
85 |
86 | # Determine the Java command to use to start the JVM.
87 | if [ -n "$JAVA_HOME" ] ; then
88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
89 | # IBM's JDK on AIX uses strange locations for the executables
90 | JAVACMD="$JAVA_HOME/jre/sh/java"
91 | else
92 | JAVACMD="$JAVA_HOME/bin/java"
93 | fi
94 | if [ ! -x "$JAVACMD" ] ; then
95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
96 |
97 | Please set the JAVA_HOME variable in your environment to match the
98 | location of your Java installation."
99 | fi
100 | else
101 | JAVACMD="java"
102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
103 |
104 | Please set the JAVA_HOME variable in your environment to match the
105 | location of your Java installation."
106 | fi
107 |
108 | # Increase the maximum file descriptors if we can.
109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
110 | MAX_FD_LIMIT=`ulimit -H -n`
111 | if [ $? -eq 0 ] ; then
112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
113 | MAX_FD="$MAX_FD_LIMIT"
114 | fi
115 | ulimit -n $MAX_FD
116 | if [ $? -ne 0 ] ; then
117 | warn "Could not set maximum file descriptor limit: $MAX_FD"
118 | fi
119 | else
120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
121 | fi
122 | fi
123 |
124 | # For Darwin, add options to specify how the application appears in the dock
125 | if $darwin; then
126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
127 | fi
128 |
129 | # For Cygwin or MSYS, switch paths to Windows format before running java
130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
133 |
134 | JAVACMD=`cygpath --unix "$JAVACMD"`
135 |
136 | # We build the pattern for arguments to be converted via cygpath
137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
138 | SEP=""
139 | for dir in $ROOTDIRSRAW ; do
140 | ROOTDIRS="$ROOTDIRS$SEP$dir"
141 | SEP="|"
142 | done
143 | OURCYGPATTERN="(^($ROOTDIRS))"
144 | # Add a user-defined pattern to the cygpath arguments
145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
147 | fi
148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
149 | i=0
150 | for arg in "$@" ; do
151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
153 |
154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
156 | else
157 | eval `echo args$i`="\"$arg\""
158 | fi
159 | i=`expr $i + 1`
160 | done
161 | case $i in
162 | 0) set -- ;;
163 | 1) set -- "$args0" ;;
164 | 2) set -- "$args0" "$args1" ;;
165 | 3) set -- "$args0" "$args1" "$args2" ;;
166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
172 | esac
173 | fi
174 |
175 | # Escape application args
176 | save () {
177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
178 | echo " "
179 | }
180 | APP_ARGS=`save "$@"`
181 |
182 | # Collect all arguments for the java command, following the shell quoting and substitution rules
183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
184 |
185 | exec "$JAVACMD" "$@"
186 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if "%ERRORLEVEL%" == "0" goto execute
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto execute
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :execute
68 | @rem Setup the command line
69 |
70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71 |
72 |
73 | @rem Execute Gradle
74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75 |
76 | :end
77 | @rem End local scope for the variables with windows NT shell
78 | if "%ERRORLEVEL%"=="0" goto mainEnd
79 |
80 | :fail
81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82 | rem the _cmd.exe /c_ return code!
83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84 | exit /b 1
85 |
86 | :mainEnd
87 | if "%OS%"=="Windows_NT" endlocal
88 |
89 | :omega
90 |
--------------------------------------------------------------------------------
/keys/priv/.gitkeep:
--------------------------------------------------------------------------------
1 | # Ignore everything in this directory
2 | *
3 | # Except this file !.gitkeep
--------------------------------------------------------------------------------
/private_key:
--------------------------------------------------------------------------------
1 | 49191370627614877492996337821917274297863513005433547861103892894089436256261
--------------------------------------------------------------------------------
/script/deploy_payment.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | JAVA_HOME="$JAVA_HOME"
4 |
5 | if [ -f conf/payment.properties ];then
6 | echo "Err: the conf/payment.properties is exists"
7 | exit 1
8 | fi
9 |
10 | key=$(cat keys/priv/private_key)
11 |
12 | ${JAVA_HOME}/bin/java -classpath "./conf:./lib/*" com.webank.payment.contract.deploy.DeployService ${key}
13 | if [[ $? -ne 0 ]];then
14 | echo "deploy contract failed."
15 | exit 1
16 | fi
17 |
18 | if [ -f payment.properties ];then
19 | cp payment.properties ./conf/
20 | rm payment.properties
21 | rm private_key
22 | fi
23 |
--------------------------------------------------------------------------------
/script/server_status.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # get JAVA_HOME conf from server.env
4 | #TEMP_JAVA_HOME=`cat server.env | grep JAVA_HOME | cut -d':' -f4`
5 | # jdk path
6 | JAVA_HOME="$JAVA_HOME"
7 |
8 | # Java main
9 | APP_MAIN=com.webank.weid.http.Application
10 |
11 | tradePortalPID=0
12 |
13 | getTradeProtalPID(){
14 | javaps=`$JAVA_HOME/bin/jps -l | grep $APP_MAIN`
15 | if [ -n "$javaps" ]; then
16 | tradePortalPID=`echo $javaps | awk '{print $1}'`
17 | else
18 | tradePortalPID=0
19 | fi
20 | }
21 |
22 | getServerStatus(){
23 | getTradeProtalPID
24 | echo "==============================================================================================="
25 | if [ $tradePortalPID -ne 0 ]; then
26 | echo "$APP_MAIN is running(PID=$tradePortalPID)"
27 | echo "==============================================================================================="
28 | else
29 | echo "$APP_MAIN is not running"
30 | echo "==============================================================================================="
31 | fi
32 | }
33 |
34 | getServerStatus
--------------------------------------------------------------------------------
/script/start.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # get JAVA_HOME conf from server.env
4 | #TEMP_JAVA_HOME=`cat server.env | grep JAVA_HOME | cut -d':' -f4`
5 | # jdk path
6 | JAVA_HOME="$JAVA_HOME"
7 |
8 | CURRENT_DIR=`pwd`
9 | APP_NAME=`basename ${CURRENT_DIR}`
10 |
11 | CONF_DIR=./app/${APP_NAME}/conf
12 | LOG_DIR=./logs/${APP_NAME}
13 |
14 | # Java main
15 | APP_MAIN=com.webank.weid.http.Application
16 | CLASSPATH='conf/:apps/*:lib/*'
17 |
18 | tradePortalPID=0
19 |
20 | getTradeProtalPID(){
21 | javaps=`$JAVA_HOME/bin/jps -l | grep $APP_MAIN`
22 | if [ -n "$javaps" ]; then
23 | tradePortalPID=`echo $javaps | awk '{print $1}'`
24 | else
25 | tradePortalPID=0
26 | fi
27 | }
28 |
29 | JAVA_OPTS=" -Dfile.encoding=UTF-8 -Djdk.tls.namedGroups=\"secp256r1,secp256k1\""
30 | JAVA_OPTS+=" -Dlog4j.configurationfile=${CONF_DIR}/log4j2.xml -Dindex.log.home=${LOG_DIR} -Dconfig=${CONF_DIR}/"
31 | JAVA_OPTS+=" -server -Xmx1024m -Xms1024m -XX:NewSize=256m -XX:MaxNewSize=256m -XX:PermSize=128m -XX:MaxPermSize=128m"
32 | JAVA_OPTS+=" -XX:+UseConcMarkSweepGC -XX:+UseCMSCompactAtFullCollection -XX:CMSInitiatingOccupancyFraction=70"
33 | JAVA_OPTS+=" -XX:+CMSParallelRemarkEnabled -XX:SoftRefLRUPolicyMSPerMB=0 -XX:+CMSClassUnloadingEnabled -XX:+DisableExplicitGC -XX:SurvivorRatio=8"
34 | JAVA_OPTS+=" -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=${LOG_DIR}/ -XX:ErrorFile=${LOG_DIR}/heap_error.log"
35 |
36 | startup(){
37 | getTradeProtalPID
38 | echo "==============================================================================================="
39 | if [ $tradePortalPID -ne 0 ]; then
40 | echo "$APP_MAIN already started(PID=$tradePortalPID)"
41 | echo "==============================================================================================="
42 | else
43 | echo -n "Starting $APP_MAIN ..."
44 | nohup $JAVA_HOME/bin/java ${JAVA_OPTS} -cp $CLASSPATH $APP_MAIN >> /dev/null 2>&1 &
45 | getTradeProtalPID
46 | if [ $tradePortalPID -ne 0 ]; then
47 | echo "(PID=$tradePortalPID)...[Success]"
48 | echo "==============================================================================================="
49 | else
50 | echo "[Failed]"
51 | echo "==============================================================================================="
52 | fi
53 | fi
54 | }
55 |
56 | startup
--------------------------------------------------------------------------------
/script/stop.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # get JAVA_HOME conf from server.env
4 | #TEMP_JAVA_HOME=`cat server.env | grep JAVA_HOME | cut -d':' -f4`
5 | # jdk path
6 | JAVA_HOME="$JAVA_HOME"
7 |
8 | # Java main
9 | APP_MAIN=com.webank.weid.http.Application
10 |
11 | tradePortalPID=0
12 |
13 | getTradeProtalPID(){
14 | javaps=`$JAVA_HOME/bin/jps -l | grep $APP_MAIN`
15 | if [ -n "$javaps" ]; then
16 | tradePortalPID=`echo $javaps | awk '{print $1}'`
17 | else
18 | tradePortalPID=0
19 | fi
20 | }
21 |
22 | shutdown(){
23 | getTradeProtalPID
24 | echo "==============================================================================================="
25 | if [ $tradePortalPID -ne 0 ]; then
26 | echo -n "Stopping $APP_MAIN(PID=$tradePortalPID)..."
27 | kill -9 $tradePortalPID
28 | if [ $? -eq 0 ]; then
29 | echo "[Success]"
30 | echo "==============================================================================================="
31 | else
32 | echo "[Failed]"
33 | echo "==============================================================================================="
34 | fi
35 | getTradeProtalPID
36 | if [ $tradePortalPID -ne 0 ]; then
37 | shutdown
38 | fi
39 | else
40 | echo "$APP_MAIN is not running"
41 | echo "==============================================================================================="
42 | fi
43 | }
44 |
45 | shutdown
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name='weid-http-service'
2 |
--------------------------------------------------------------------------------
/src/main/java/com/webank/weid/http/Application.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright© (2019) WeBank Co., Ltd.
3 | *
4 | * This file is part of weid-http-service.
5 | *
6 | * weid-http-service is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU Lesser General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * weid-http-service is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public License
17 | * along with weid-http-service. If not, see .
18 | */
19 |
20 | package com.webank.weid.http;
21 |
22 | import com.webank.weid.blockchain.config.FiscoConfig;
23 | import com.webank.weid.util.PropertyUtils;
24 | import org.slf4j.Logger;
25 | import org.slf4j.LoggerFactory;
26 | import org.springframework.boot.SpringApplication;
27 | import org.springframework.boot.autoconfigure.SpringBootApplication;
28 | import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
29 | import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
30 | import org.springframework.boot.web.servlet.ServletComponentScan;
31 | import org.springframework.context.annotation.ComponentScan;
32 |
33 | import java.io.InputStream;
34 | import java.net.URL;
35 |
36 | @SpringBootApplication(
37 | exclude = {DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class}
38 | )
39 | @ComponentScan("com.webank.weid")
40 | @ServletComponentScan("com.webank.weid")
41 | public class Application {
42 | private static Logger logger = LoggerFactory.getLogger(Application.class);
43 |
44 | public static void main(String[] args) {
45 | SpringApplication.run(Application.class);
46 | FiscoConfig.topic = "weid-http-service";
47 | logger.info("#### Start finished");
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/main/java/com/webank/weid/http/aspect/ServiceLogAspect.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright© (2019) WeBank Co., Ltd.
3 | *
4 | * This file is part of weid-http-service.
5 | *
6 | * weid-http-service is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU Lesser General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * weid-http-service is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public License
17 | * along with weid-http-service. If not, see .
18 | */
19 |
20 | package com.webank.weid.http.aspect;
21 |
22 | import java.util.Arrays;
23 |
24 | import javax.servlet.http.HttpServletRequest;
25 |
26 | import org.aspectj.lang.JoinPoint;
27 | import org.aspectj.lang.annotation.AfterReturning;
28 | import org.aspectj.lang.annotation.Aspect;
29 | import org.aspectj.lang.annotation.Before;
30 | import org.aspectj.lang.annotation.Pointcut;
31 | import org.slf4j.Logger;
32 | import org.slf4j.LoggerFactory;
33 | import org.springframework.stereotype.Component;
34 | import org.springframework.web.context.request.RequestContextHolder;
35 | import org.springframework.web.context.request.ServletRequestAttributes;
36 |
37 | import com.webank.weid.http.util.JsonUtil;
38 |
39 | @Aspect
40 | @Component
41 | public class ServiceLogAspect {
42 |
43 | private Logger logger = LoggerFactory.getLogger(ServiceLogAspect.class);
44 |
45 | ThreadLocal startTime = new ThreadLocal();
46 |
47 | @Pointcut("execution(public * com.webank.weid.http.service.*.*(..))")
48 | private void controllerAspect(){
49 |
50 | }
51 |
52 | /**
53 | * running before joinPoint
54 | * @param joinPoint this is joinPoint
55 | */
56 | @Before(value = "controllerAspect()")
57 | public void before(JoinPoint joinPoint){
58 |
59 | startTime.set(System.currentTimeMillis());
60 |
61 | ServletRequestAttributes requestAttributes =
62 | (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
63 | HttpServletRequest request = requestAttributes.getRequest();
64 |
65 | logger.info("####request url:{}| type:{}| method:[{}]| args:{}",
66 | request.getRequestURL().toString(),
67 | request.getMethod(),
68 | joinPoint.getSignature(),
69 | Arrays.toString(joinPoint.getArgs()));
70 | }
71 |
72 | /**
73 | * when joinPoint, running after return
74 | * @param joinPoint this is joinPoint
75 | * @param keys return result
76 | */
77 | @AfterReturning(value = "controllerAspect()", returning = "keys")
78 | public void afterReturning(JoinPoint joinPoint, Object keys) {
79 |
80 | logger.info("####response method:[{}]| args:{}| result:{}| cost tims:{}ms",
81 | joinPoint.getSignature(),
82 | Arrays.asList(joinPoint.getArgs()),
83 | JsonUtil.objToJsonStr(keys),
84 | (System.currentTimeMillis() - startTime.get()));
85 | }
86 |
87 | }
88 |
--------------------------------------------------------------------------------
/src/main/java/com/webank/weid/http/config/BeanConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright© (2019) WeBank Co., Ltd.
3 | *
4 | * This file is part of weid-http-service.
5 | *
6 | * weid-http-service is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU Lesser General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * weid-http-service is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public License
17 | * along with weid-http-service. If not, see .
18 | */
19 |
20 | package com.webank.weid.http.config;
21 |
22 | import org.springframework.context.annotation.Bean;
23 | import org.springframework.context.annotation.Configuration;
24 |
25 | import com.webank.weid.service.rpc.AuthorityIssuerService;
26 | import com.webank.weid.service.rpc.CptService;
27 | import com.webank.weid.service.rpc.CredentialService;
28 | import com.webank.weid.service.rpc.WeIdService;
29 | import com.webank.weid.service.impl.AuthorityIssuerServiceImpl;
30 | import com.webank.weid.service.impl.CptServiceImpl;
31 | import com.webank.weid.service.impl.CredentialServiceImpl;
32 | import com.webank.weid.service.impl.WeIdServiceImpl;
33 |
34 | /**
35 | * implement http redirect https.
36 | *
37 | * @author darwindu
38 | */
39 | @Configuration
40 | public class BeanConfig {
41 |
42 | @Bean("authorityIssuerService")
43 | public AuthorityIssuerService getAuthorityIssuerService() {
44 | return new AuthorityIssuerServiceImpl();
45 | }
46 |
47 | @Bean("cptService")
48 | public CptService getCptService() {
49 | return new CptServiceImpl();
50 | }
51 |
52 | @Bean("credentialService")
53 | public CredentialService getCredentialService() {
54 | return new CredentialServiceImpl();
55 | }
56 |
57 | @Bean("weIdService")
58 | public WeIdService getWeIdService() {
59 | return new WeIdServiceImpl();
60 | }
61 |
62 | }
63 |
--------------------------------------------------------------------------------
/src/main/java/com/webank/weid/http/config/HttpsConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright© (2019) WeBank Co., Ltd.
3 | *
4 | * This file is part of weid-http-service.
5 | *
6 | * weid-http-service is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU Lesser General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * weid-http-service is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public License
17 | * along with weid-http-service. If not, see .
18 | */
19 |
20 | package com.webank.weid.http.config;
21 |
22 | import org.apache.catalina.connector.Connector;
23 | import org.springframework.beans.factory.annotation.Value;
24 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
25 | import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
26 | import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
27 | import org.springframework.context.annotation.Bean;
28 | import org.springframework.context.annotation.Configuration;
29 |
30 | /**
31 | * implement http redirect https.
32 | *
33 | * @author darwindu/chaoxinhu
34 | */
35 | @Configuration
36 | @ConditionalOnProperty(value = "server.ssl.enabled", havingValue = "true")
37 | public class HttpsConfig {
38 |
39 | @Value("${server.http.port}")
40 | private Integer serverPort;
41 |
42 |
43 | @Bean
44 | public ServletWebServerFactory servletContainer() {
45 | TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory();
46 | tomcat.addAdditionalTomcatConnectors(createStandardConnector());
47 | return tomcat;
48 | }
49 |
50 | private Connector createStandardConnector() {
51 | Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
52 | connector.setPort(serverPort);
53 | return connector;
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/src/main/java/com/webank/weid/http/constant/HttpReturnCode.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright© (2019) WeBank Co., Ltd.
3 | *
4 | * This file is part of weid-http-service.
5 | *
6 | * weid-http-service is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU Lesser General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * weid-http-service is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public License
17 | * along with weid-http-service. If not, see .
18 | */
19 |
20 | package com.webank.weid.http.constant;
21 |
22 | public enum HttpReturnCode {
23 |
24 | /**
25 | * The success.
26 | */
27 | SUCCESS(0, "success"),
28 |
29 | /**
30 | * base error.
31 | */
32 | VALUE_FORMAT_ILLEGAL(201000, "Input parameter value format illegal. "),
33 |
34 | /**
35 | * other uncatched exceptions or error.
36 | */
37 | UNKNOWN_ERROR(201001, "Unknown error. "),
38 |
39 | /**
40 | * input null.
41 | */
42 | INPUT_NULL(201002, "Input parameter contains null value or missing keys. "),
43 |
44 | /**
45 | * input illegal.
46 | */
47 | INPUT_ILLEGAL(201003,
48 | "One or more input arguments format illegal. Please refer to the API documents. "),
49 |
50 | /**
51 | * function name unknown.
52 | */
53 | FUNCTION_NAME_ILLEGAL(201004, "Function name format illegal or missing. "),
54 |
55 | /**
56 | * transaction hex error.
57 | */
58 | TXN_HEX_ERROR(201005, "Transaction hex creation failed. "),
59 |
60 | /**
61 | * transaction encoder error.
62 | */
63 | TXN_ENCODER_ERROR(201006, "Transaction encoder creation failed. "),
64 |
65 | /**
66 | * SDK call error.
67 | */
68 | WEID_SDK_ERROR(201007, "WeIdentity SDK call failed due to unknown error. "),
69 |
70 | /**
71 | * invoker weId is illegal.
72 | */
73 | INVOKER_ILLEGAL(201008, "Cannot find the private key by the invoker index. "),
74 |
75 | /**
76 | * Nonce value illegal.
77 | */
78 | NONCE_ILLEGAL(201009, "Nonce value illegal. "),
79 |
80 | /**
81 | * function arg illegal.
82 | */
83 | FUNCARG_ILLEGAL(201010, "Function arguments format illegal or missing. "),
84 |
85 | /**
86 | * txn arg illegal.
87 | */
88 | TXNARG_ILLEGAL(201011, "Transaction arguments format illegal or missing. "),
89 |
90 | /**
91 | * version illegal.
92 | */
93 | VER_ILLEGAL(201012, "Version format illegal or missing. "),
94 |
95 | /**
96 | * signed message illegal.
97 | */
98 | SIGNED_MSG_ILLEGAL(201013, "Signed message format illegal or missing. "),
99 |
100 | /**
101 | * data illegal.
102 | */
103 | DATA_ILLEGAL(201014, "data segment format illegal or missing. "),
104 |
105 | /**
106 | * web3j error.
107 | */
108 | WEB3J_ERROR(201015, "Failed to load web3j (maybe from illegal certs, Group ID, networking, or secp256k1 settings)"),
109 |
110 | /**
111 | * contract error.
112 | */
113 | CONTRACT_ERROR(201016, "Failed to load contract (maybe from un-deployed site, DB not storing CNS, or CNS hash illegal)"),
114 |
115 | /**
116 | * BlockLimit value illegal.
117 | */
118 | BLOCK_LIMIT_ILLEGAL(201017, "BlockLimit value illegal. "),
119 |
120 | /**
121 | * Convert a public key to a WeIdentity DID error
122 | */
123 | CONVERT_PUBKEY_TO_WEID_ERROR(201018, "Convert public key to weId error. "),
124 |
125 | /**
126 | * SignType value illegal.
127 | */
128 | SIGN_TYPE_ILLEGAL(201019, "SignType value illegal. "),
129 |
130 | /**
131 | * WeIdentity deploy style(database) not support send rawTransaction.
132 | */
133 | WEIDENTITY_DEPLOY_NOT_SUPPORT(201019, "WeIdentity deploy style(database) not support send rawTransaction. "),
134 |
135 | /**
136 | * getWeIdListByPubKeyList interface error
137 | */
138 | GET_WEID_LIST_BY_PUBKEY_LIST_ERROR(500100, "Get weId list by pubKeyList error. "),
139 |
140 | /**
141 | * RPC related error codes.
142 | */
143 | RPC_SEND_FAIL(205001, "Sending RPC request failure"),
144 | RPC_NETWORK_ERROR(205002, "RPC networking failure"),
145 | RPC_GET_FAIL(205003, "Get RPC reply from request UUID failure"),
146 | RPC_FETCH_FAIL(205004, "Fetching RPC remote service info failure"),
147 | RPC_ENDPOINT_NOT_EXIST(205005, "RPC Endpoint does not exist");
148 |
149 | /**
150 | * error code.
151 | */
152 | private int code;
153 |
154 | /**
155 | * error message.
156 | */
157 | private String codeDesc;
158 |
159 | /**
160 | * Error Code Constructor.
161 | *
162 | * @param code The ErrorCode
163 | * @param codeDesc The ErrorCode Description
164 | */
165 | HttpReturnCode(int code, String codeDesc) {
166 | this.code = code;
167 | this.codeDesc = codeDesc;
168 | }
169 |
170 | /**
171 | * Get the Error Code.
172 | *
173 | * @return the ErrorCode
174 | */
175 | public int getCode() {
176 | return code;
177 | }
178 |
179 | /**
180 | * Set the Error Code.
181 | *
182 | * @param code the new ErrorCode
183 | */
184 | protected void setCode(int code) {
185 | this.code = code;
186 | }
187 |
188 | /**
189 | * Gets the ErrorCode Description.
190 | *
191 | * @return the ErrorCode Description
192 | */
193 | public String getCodeDesc() {
194 | return codeDesc;
195 | }
196 |
197 | /**
198 | * Sets the ErrorCode Description.
199 | *
200 | * @param codeDesc the new ErrorCode Description
201 | */
202 | protected void setCodeDesc(String codeDesc) {
203 | this.codeDesc = codeDesc;
204 | }
205 | }
206 |
--------------------------------------------------------------------------------
/src/main/java/com/webank/weid/http/constant/SignType.java:
--------------------------------------------------------------------------------
1 | package com.webank.weid.http.constant;
2 |
3 | public enum SignType {
4 |
5 | RSV(1), VSR(2);
6 |
7 | private int code;
8 |
9 | SignType(int code) {
10 | this.code = code;
11 | }
12 |
13 | public int getCode() {
14 | return code;
15 | }
16 |
17 | public static SignType getSignTypeByCode(int code) {
18 | for (SignType signType : SignType.values()) {
19 | if (code == signType.getCode()) {
20 | return signType;
21 | }
22 | }
23 | return null;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/main/java/com/webank/weid/http/constant/WalletAgentFunctionNames.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright© (2019-2020) WeBank Co., Ltd.
3 | *
4 | * This file is part of weid-http-service.
5 | *
6 | * weid-http-service is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU Lesser General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * weid-http-service is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public License
17 | * along with weid-http-service. If not, see .
18 | */
19 |
20 | package com.webank.weid.http.constant;
21 |
22 | /**
23 | * Define function names to be picked for calls to WeIdentity Java SDK
24 | *
25 | * @author chaoxinhu
26 | **/
27 |
28 | public final class WalletAgentFunctionNames {
29 |
30 | /**
31 | * Function names to be compared against the passed in encode/send transaction parameters. Case
32 | * insensitive.
33 | */
34 | public static final String FUNCNAME_WALLETAGENT_CONSTRUCT = "construct";
35 | public static final String FUNCNAME_WALLETAGENT_ISSUE = "issue";
36 | public static final String FUNCNAME_WALLETAGENT_CONSTRUCTANDISSUE = "constructAndIssue";
37 | public static final String FUNCNAME_WALLETAGENT_GETBALANCE = "getBalance";
38 | public static final String FUNCNAME_WALLETAGENT_GETBATCHBALANCE = "getBatchBalance";
39 | public static final String FUNCNAME_WALLETAGENT_GETBALANCEBYWEID = "getBalanceByWeId";
40 | public static final String FUNCNAME_WALLETAGENT_SEND = "send";
41 | public static final String FUNCNAME_WALLETAGENT_BATCHSEND = "batchSend";
42 | public static final String FUNCNAME_WALLETAGENT_GETBASEINFO = "getBaseInfo";
43 | public static final String FUNCNAME_WALLETAGENT_GETBASEINFOBYWEID = "getBaseInfoByWeId";
44 |
45 | public static final String FUNCNAME_WALLETAGENT_BATCHISSUE = "batchIssue";
46 | public static final String FUNCNAME_WALLETAGENT_CONSTRUCTANDBATCHISSUE = "constructAndBatchIssue";
47 | public static final String FUNCNAME_WALLETAGENT_QUERYASSETOWNER = "queryAssetOwner";
48 | public static final String FUNCNAME_WALLETAGENT_QUERYASSETNUM = "queryAssetNum";
49 | public static final String FUNCNAME_WALLETAGENT_QUERYASSETLIST = "queryAssetList";
50 | public static final String FUNCNAME_WALLETAGENT_QUERYOWNEDASSETNUM = "queryOwnedAssetNum";
51 | public static final String FUNCNAME_WALLETAGENT_QUERYOWNEDASSETLIST = "queryOwnedAssetList";
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/src/main/java/com/webank/weid/http/constant/WeIdentityFunctionNames.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright© (2019) WeBank Co., Ltd.
3 | *
4 | * This file is part of weid-http-service.
5 | *
6 | * weid-http-service is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU Lesser General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * weid-http-service is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public License
17 | * along with weid-http-service. If not, see .
18 | */
19 |
20 | package com.webank.weid.http.constant;
21 |
22 | import java.util.HashMap;
23 | import java.util.Map;
24 |
25 | /**
26 | * Define function names to be picked for calls to WeIdentity Java SDK
27 | *
28 | * @author chaoxinhu
29 | **/
30 |
31 | public final class WeIdentityFunctionNames {
32 |
33 | /**
34 | * Function names to be compared against the passed in encode/send transaction parameters. Case
35 | * insensitive.
36 | */
37 | public static final String FUNCNAME_CREATE_WEID = "createWeId";
38 | public static final String FUNCNAME_CREATE_WEID_AND_RETURN_DOC = "createWeId2";
39 | public static final String FUNCNAME_REGISTER_AUTHORITY_ISSUER = "registerAuthorityIssuer";
40 | public static final String FUNCNAME_REGISTER_CPT = "registerCpt";
41 | public static final String FUNCNAME_CREATE_CREDENTIAL = "createCredential";
42 | public static final String FUNCNAME_VERIFY_CREDENTIAL = "verifyCredential";
43 | public static final String FUNCNAME_GET_WEID_DOCUMENT = "getWeIdDocument";
44 | public static final String FUNCNAME_GET_WEID_DOCUMENT_JSON = "getWeIdDocumentJson";
45 | public static final String FUNCNAME_QUERY_AUTHORITY_ISSUER = "queryAuthorityIssuer";
46 | public static final String FUNCNAME_QUERY_CPT = "queryCpt";
47 | public static final String FUNCNAME_CREATE_CREDENTIALPOJO = "createCredentialPojo";
48 | public static final String FUNCNAME_VERIFY_CREDENTIALPOJO = "verifyCredentialPojo";
49 |
50 | public static final String FUNCNAME_CREATE_WEID_WITH_PUBKEY = "createWeIdWithPubKey";
51 | public static final String FUNCNAME_CREATE_WEID_WITH_PUBKEY_AND_RETURN_DOC = "createWeIdWithPubKey2";
52 | public static final String FUNCNAME_GET_WEID_DOCUMENT_BY_ORG = "getWeIdDocumentByOrgId";
53 | public static final String FUNCNAME_VERIFY_LITE_CREDENTIAL = "verifyLiteCredential";
54 | public static final String FUNCNAME_CREATE_EVIDENCE_FOR_LITE_CREDENTIAL = "createEvidence";
55 | public static final String FUNCNAME_CREATE_EVIDENCE_FOR_LITE_CREDENTIAL_DELEGATE = "delegateCreateEvidence";
56 | public static final String FUNCNAME_CREATE_EVIDENCE_FOR_LITE_CREDENTIAL_DELEGATE_BATCH = "delegateCreateEvidenceB";
57 | public static final String FUNCNAME_ECCENCRYPT_CREDENTIAL = "createCredentialAndEncrypt";
58 | public static final String FUNCNAME_ECCDECRYPT = "eccDecrypt";
59 | public static final String FUNCNAME_ECCENCRYPT = "eccEncrypt";
60 | public static final String FUNCNAME_GET_EVIDENCE_BY_HASH = "getEvidence";
61 | public static final String FUNCNAME_ADD_WEID_TO_WHITELIST = "addWeIdToWhitelist";
62 | public static final String FUNCNAME_IS_WEID_IN_WHITELIST = "isWeIdInWhitelist";
63 | public static final String FUNCNAME_RECOGNIZE_AUTHORITY_ISSUER = "recognizeAuthorityIssuer";
64 | public static final String FUNCNAME_DERECOGNIZE_AUTHORITY_ISSUER = "deRecognizeAuthorityIssuer";
65 | public static final String FUNCNAME_GETWEIDLIST_BYPUBKEYLIST = "getWeIdListByPubKeyList";
66 | /**
67 | * Function names to be assembled in SDK Function call. Case sensitive. FISCO-BCOS v1.
68 | */
69 | public static final String FUNCCALL_UPDATE_WEID = "updateWeId";
70 | public static final String FUNCCALL_ADD_AUTHORITY_ISSUER = "addAuthorityIssuer";
71 | public static final String FUNCCALL_REGISTER_CPT = "registerCpt";
72 |
73 | /**
74 | * The FISCO-BCOS v2 function name and call map.
75 | */
76 | public static final Map FUNCNAME_CALL_MAP_V2 = new HashMap() {{
77 | put(FUNCNAME_CREATE_WEID, "createWeId");
78 | put(FUNCNAME_REGISTER_AUTHORITY_ISSUER, "addAuthorityIssuer");
79 | put(FUNCNAME_REGISTER_CPT, "registerCpt");
80 | }};
81 | }
82 |
--------------------------------------------------------------------------------
/src/main/java/com/webank/weid/http/constant/WeIdentityParamKeyConstant.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright© (2019) WeBank Co., Ltd.
3 | *
4 | * This file is part of weid-http-service.
5 | *
6 | * weid-http-service is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU Lesser General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * weid-http-service is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public License
17 | * along with weid-http-service. If not, see .
18 | */
19 |
20 | package com.webank.weid.http.constant;
21 |
22 | /**
23 | * Define param key names to be allowed to enable calls to WeIdentity Java SDK
24 | *
25 | * @author chaoxinhu
26 | **/
27 | public final class WeIdentityParamKeyConstant {
28 |
29 | /**
30 | * Universal param key names. Treated as case-INSENSITIVE when being checked.
31 | */
32 | public static final String FUNCTION_NAME = "functionName";
33 | public static final String TRANSACTION_DATA = "data";
34 | public static final String BLOCK_LIMIT = "blockLimit";
35 | public static final String SIGN_TYPE = "signType";
36 | public static final String SIGNED_MESSAGE = "signedMessage";
37 | public static final String API_VERSION = "v";
38 | public static final String NONCE = "nonce";
39 | public static final String FUNCTION_ARG = "functionArg";
40 | public static final String TRANSACTION_ARG = "transactionArg";
41 | public static final String CLAIM_HASH = "claimHash";
42 | public static final String KEY_INDEX = "invokerWeId";
43 | public static final String LOOP_BACK = "loopback";
44 | public static final String BODY = "body";
45 | public static final String LIST = "list";
46 |
47 | public static final String DEFAULT_API_VERSION = "1.0.0";
48 | public static final String DEFAULT_PRIVATE_KEY_FILE_NAME = "private_key";
49 |
50 | public static final String AUTHO_TOKEN = "authToken";
51 | public static final String AUTHO_SIGNED_NONCE = "signedNonce";
52 |
53 | public static final String ORG_ID = "orgId";
54 | public static final String CREDENTIAL_ID = "id";
55 | public static final String HASH = "hash";
56 | public static final String PROOF = "proof";
57 | public static final String SIGN = "sign";
58 | public static final String LOG = "log";
59 | public static final String PUBKEY_ECDSA = "publicKeyECDSA";
60 | public static final String PUBKEY_LIST = "publicKeyList";
61 | public static final String PUBKEY_SM2 = "publicKeySM2";
62 |
63 | public static final String WHITELIST_NAME = "whitelistName";
64 |
65 | public static final String GROUP_ID = "groupId";
66 | public static final String HASH_VALUE = "hashValue";
67 | }
68 |
--------------------------------------------------------------------------------
/src/main/java/com/webank/weid/http/constant/WeIdentityServiceEndpoint.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright© (2019) WeBank Co., Ltd.
3 | *
4 | * This file is part of weid-http-service.
5 | *
6 | * weid-http-service is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU Lesser General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * weid-http-service is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public License
17 | * along with weid-http-service. If not, see .
18 | */
19 |
20 | package com.webank.weid.http.constant;
21 |
22 | /**
23 | * Define function names to be picked for calls to WeIdentity Java SDK
24 | *
25 | * @author chaoxinhu
26 | **/
27 |
28 | public final class WeIdentityServiceEndpoint {
29 |
30 | /**
31 | * API endpoint.
32 | */
33 | public static final String API_ROOT = "weid/api";
34 | public static final String PAYMENT_ROOT = "payment";
35 | public static final String ENCODE_TRANSACTION = "encode";
36 | public static final String SEND_TRANSACTION = "transact";
37 | public static final String INVOKE_FUNCTION = "invoke";
38 | public static final String WALLET_AGENT_BAC004_FUNCTION = "bac004/api/invoke";
39 | public static final String WALLET_AGENT_BAC005_FUNCTION = "bac005/api/invoke";
40 | public static final String WALLET_AGENT_BAC004_FUNCTION_ENCODE = "bac004/api/encode";
41 | public static final String WALLET_AGENT_BAC004_FUNCTION_TRANSACT = "bac004/api/transact";
42 | public static final String WALLET_AGENT_BAC005_FUNCTION_ENCODE = "bac005/api/encode";
43 | public static final String WALLET_AGENT_BAC005_FUNCTION_TRANSACT = "bac005/api/transact";
44 |
45 | /**
46 | * EP Service endpoint.
47 | */
48 | public static final String EPS_ROOT = "endpoint";
49 | public static final String ADD_FUNCTION = "add";
50 | public static final String REMOVE_FUNCTION = "remove";
51 | public static final String FETCH_FUNCTION = "auto-fetch";
52 |
53 | /**
54 | * Data-Authorization related endpoints.
55 | */
56 | public static final String AUTHO_ROOT = "authorize";
57 | public static final String AUTHO_FETCH_DATA = "fetch-data";
58 | public static final String AUTHO_REQUEST_NONCE = "request-nonce";
59 |
60 | /**
61 | * Separator.
62 | */
63 | public static final String EPS_SEPARATOR = "|||";
64 |
65 | /**
66 | * Misc items
67 | */
68 | public static final String ALL_INFO = "ALL";
69 | }
70 |
--------------------------------------------------------------------------------
/src/main/java/com/webank/weid/http/protocol/base/ResolutionMetadata.java:
--------------------------------------------------------------------------------
1 | package com.webank.weid.http.protocol.base;
2 |
3 | import lombok.Data;
4 | /**
5 | * The base data structure to handle WeId Resolution Metadata.
6 | *
7 | * @author afeexian 2022.9.29
8 | */
9 | @Data
10 | public class ResolutionMetadata {
11 | /**
12 | * Media Type of the returned WeId Document Stream, WeId currently support JSON-LD.
13 | */
14 | private String contentType;
15 | /**
16 | * error message.
17 | */
18 | private String error;
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/com/webank/weid/http/protocol/base/ResolveData.java:
--------------------------------------------------------------------------------
1 | package com.webank.weid.http.protocol.base;
2 |
3 | import com.webank.weid.protocol.base.WeIdDocument;
4 | import com.webank.weid.protocol.base.WeIdDocumentMetadata;
5 | import lombok.Data;
6 |
7 | /**
8 | * The base data structure to handle WeIdentity DID Document and DocumentMetadata info.
9 | *
10 | * @author afeexian 2022.9.29
11 | */
12 | @Data
13 | public class ResolveData {
14 |
15 | /**
16 | * Resolution Metadata.
17 | */
18 | private ResolutionMetadata resolutionMetadata;
19 | /**
20 | * WeId Document.
21 | */
22 | private WeIdDocument weIdDocument;
23 |
24 | /**
25 | * WeId Document Metadata.
26 | */
27 | WeIdDocumentMetadata weIdDocumentMetadata;
28 | }
29 |
--------------------------------------------------------------------------------
/src/main/java/com/webank/weid/http/protocol/base/ResolveDataJsonLD.java:
--------------------------------------------------------------------------------
1 | package com.webank.weid.http.protocol.base;
2 |
3 | import com.webank.weid.protocol.base.WeIdDocument;
4 | import com.webank.weid.protocol.base.WeIdDocumentMetadata;
5 | import lombok.Data;
6 |
7 | /**
8 | * The base data structure to handle WeIdentity DID DocumentStream in json-ld and DocumentMetadata info.
9 | *
10 | * @author afeexian 2022.9.29
11 | */
12 | @Data
13 | public class ResolveDataJsonLD {
14 | /**
15 | * Resolution Metadata.
16 | */
17 | private ResolutionMetadata resolutionMetadata;
18 | /**
19 | * WeId Document.
20 | */
21 | private String weIdDocumentJson;
22 |
23 | /**
24 | * WeId Document Metadata.
25 | */
26 | WeIdDocumentMetadata weIdDocumentMetadata;
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/com/webank/weid/http/protocol/request/EndpointRequest.java:
--------------------------------------------------------------------------------
1 | package com.webank.weid.http.protocol.request;
2 |
3 | import lombok.Data;
4 |
5 | @Data
6 | public class EndpointRequest {
7 |
8 | private String requestName;
9 | private String requestBody;
10 | }
11 |
--------------------------------------------------------------------------------
/src/main/java/com/webank/weid/http/protocol/request/InputArg.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright© (2019) WeBank Co., Ltd.
3 | *
4 | * This file is part of weid-http-service.
5 | *
6 | * weid-http-service is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU Lesser General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * weid-http-service is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public License
17 | * along with weid-http-service. If not, see .
18 | */
19 |
20 | package com.webank.weid.http.protocol.request;
21 |
22 | import lombok.Data;
23 |
24 | /**
25 | * The common input argument for all Service API.
26 | *
27 | * @author chaoxinhu
28 | **/
29 | @Data
30 | public class InputArg {
31 |
32 | /**
33 | * Required: the function related arguments.
34 | */
35 | String functionArg;
36 |
37 | /**
38 | * Required: the transaction related arguments.
39 | */
40 | String transactionArg;
41 |
42 | /**
43 | * Required: the function name to be called.
44 | */
45 | String functionName;
46 |
47 | /**
48 | * Required: the API version.
49 | */
50 | String v;
51 | }
52 |
--------------------------------------------------------------------------------
/src/main/java/com/webank/weid/http/protocol/request/ReqInput.java:
--------------------------------------------------------------------------------
1 | package com.webank.weid.http.protocol.request;
2 |
3 | import lombok.Data;
4 |
5 | @Data
6 | public class ReqInput {
7 | /**
8 | * Required: the function related arguments.
9 | */
10 | F functionArg;
11 |
12 | /**
13 | * Required: the transaction related arguments.
14 | */
15 | TransactionArg transactionArg;
16 |
17 | /**
18 | * Required: the function name to be called.
19 | */
20 | String functionName;
21 |
22 | /**
23 | * Required: the API version.
24 | */
25 | String v;
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/com/webank/weid/http/protocol/request/TransactionArg.java:
--------------------------------------------------------------------------------
1 | package com.webank.weid.http.protocol.request;
2 |
3 | import com.webank.weid.http.constant.SignType;
4 |
5 | import lombok.Data;
6 |
7 | @Data
8 | public class TransactionArg {
9 |
10 | String invokerWeId;
11 | String nonce;
12 | String data;
13 | String signedMessage;
14 | String toAddress;
15 | Object loopback;
16 | String blockLimit;
17 | int signType;
18 | }
19 |
--------------------------------------------------------------------------------
/src/main/java/com/webank/weid/http/protocol/request/payment/AssetAddressList.java:
--------------------------------------------------------------------------------
1 | package com.webank.weid.http.protocol.request.payment;
2 |
3 | import java.util.List;
4 |
5 | import lombok.Data;
6 |
7 | @Data
8 | public class AssetAddressList {
9 | private String assetHolder;
10 | private List assetAddressList;
11 | }
12 |
--------------------------------------------------------------------------------
/src/main/java/com/webank/weid/http/protocol/request/payment/BAC004BatchSendInfo.java:
--------------------------------------------------------------------------------
1 | package com.webank.weid.http.protocol.request.payment;
2 |
3 | import java.util.List;
4 |
5 | import com.webank.payment.protocol.base.BaseAsset;
6 |
7 | import lombok.Data;
8 | import lombok.EqualsAndHashCode;
9 | import lombok.ToString;
10 |
11 | @Data
12 | @ToString(callSuper = true)
13 | @EqualsAndHashCode(callSuper = true)
14 | public class BAC004BatchSendInfo extends BaseAsset {
15 |
16 | private List list;
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/com/webank/weid/http/protocol/request/payment/BAC004Info.java:
--------------------------------------------------------------------------------
1 | package com.webank.weid.http.protocol.request.payment;
2 |
3 | import com.webank.payment.protocol.base.BaseBACInfo;
4 |
5 | import lombok.Data;
6 | import lombok.EqualsAndHashCode;
7 | import lombok.ToString;
8 |
9 | @Data
10 | @ToString(callSuper = true)
11 | @EqualsAndHashCode(callSuper = true)
12 | public class BAC004Info extends BaseBACInfo {
13 | private String recipient;
14 | private String remark;
15 | private Integer amount;
16 | }
17 |
--------------------------------------------------------------------------------
/src/main/java/com/webank/weid/http/protocol/request/payment/BAC004SendInfo.java:
--------------------------------------------------------------------------------
1 | package com.webank.weid.http.protocol.request.payment;
2 |
3 | import com.webank.payment.protocol.base.BaseAsset;
4 |
5 | import lombok.Data;
6 | import lombok.EqualsAndHashCode;
7 | import lombok.ToString;
8 |
9 | @Data
10 | @ToString(callSuper = true)
11 | @EqualsAndHashCode(callSuper = true)
12 | public class BAC004SendInfo extends BaseAsset {
13 | private String recipient;
14 | private String remark;
15 | private Integer amount;
16 | }
17 |
--------------------------------------------------------------------------------
/src/main/java/com/webank/weid/http/protocol/request/payment/BAC005BatchInfo.java:
--------------------------------------------------------------------------------
1 | package com.webank.weid.http.protocol.request.payment;
2 |
3 | import com.webank.payment.protocol.base.BaseBACInfo;
4 | import lombok.Data;
5 | import lombok.EqualsAndHashCode;
6 | import lombok.ToString;
7 |
8 | import java.util.List;
9 |
10 | @Data
11 | @ToString(callSuper = true)
12 | @EqualsAndHashCode(callSuper = true)
13 | public class BAC005BatchInfo extends BaseBACInfo {
14 |
15 | private List list;
16 |
17 | private String remark;
18 | }
19 |
--------------------------------------------------------------------------------
/src/main/java/com/webank/weid/http/protocol/request/payment/BAC005Info.java:
--------------------------------------------------------------------------------
1 | package com.webank.weid.http.protocol.request.payment;
2 |
3 | import com.webank.payment.protocol.base.BaseBACInfo;
4 | import lombok.Data;
5 | import lombok.EqualsAndHashCode;
6 | import lombok.ToString;
7 |
8 | @Data
9 | @ToString(callSuper = true)
10 | @EqualsAndHashCode(callSuper = true)
11 | public class BAC005Info extends BaseBACInfo {
12 | private String recipient;
13 | private String remark;
14 | private Integer assetId;
15 | private String assetUri;
16 | }
17 |
--------------------------------------------------------------------------------
/src/main/java/com/webank/weid/http/protocol/request/payment/BaseQuery.java:
--------------------------------------------------------------------------------
1 | package com.webank.weid.http.protocol.request.payment;
2 |
3 | import com.webank.payment.protocol.base.BaseAsset;
4 |
5 | import lombok.Data;
6 | import lombok.EqualsAndHashCode;
7 | import lombok.ToString;
8 |
9 | @Data
10 | @ToString(callSuper = true)
11 | @EqualsAndHashCode(callSuper = true)
12 | public class BaseQuery extends BaseAsset {
13 | private String assetHolder;
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/com/webank/weid/http/protocol/request/payment/PageQuery.java:
--------------------------------------------------------------------------------
1 | package com.webank.weid.http.protocol.request.payment;
2 |
3 | import lombok.Data;
4 | import lombok.EqualsAndHashCode;
5 | import lombok.ToString;
6 |
7 | @Data
8 | @ToString(callSuper = true)
9 | @EqualsAndHashCode(callSuper = true)
10 | public class PageQuery extends BaseQuery{
11 | // private Integer amount;
12 | private Integer index;
13 | private Integer num;
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/com/webank/weid/http/protocol/response/EncodedTransactionWrapper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright© (2019) WeBank Co., Ltd.
3 | *
4 | * This file is part of weid-http-service.
5 | *
6 | * weid-http-service is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU Lesser General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * weid-http-service is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public License
17 | * along with weid-http-service. If not, see .
18 | */
19 |
20 | package com.webank.weid.http.protocol.response;
21 |
22 | import lombok.Data;
23 |
24 | /**
25 | * The result of EncodedTransaction. A wrapper class with both encoded String, and rawTransaction.
26 | *
27 | * @author chaoxinhu
28 | */
29 |
30 | @Data
31 | public class EncodedTransactionWrapper {
32 |
33 | /**
34 | * The Encoded Transaction in String. This MUST be in Base64 format.
35 | */
36 | private String encodedTransaction;
37 |
38 | /**
39 | * The data segment instance in RawTransaction. Client needs this for future sendTransaction.
40 | */
41 | private String data;
42 |
43 | private String blockLimit;
44 | }
45 |
--------------------------------------------------------------------------------
/src/main/java/com/webank/weid/http/protocol/response/EndpointInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright© (2019) WeBank Co., Ltd.
3 | *
4 | * This file is part of weid-http-service.
5 | *
6 | * weid-http-service is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU Lesser General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * weid-http-service is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public License
17 | * along with weid-http-service. If not, see .
18 | */
19 |
20 | package com.webank.weid.http.protocol.response;
21 |
22 | import java.util.List;
23 |
24 | import lombok.Data;
25 |
26 | @Data
27 | public class EndpointInfo {
28 |
29 | private String requestName;
30 | private List inAddr;
31 | private String description;
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/java/com/webank/weid/http/protocol/response/HttpResponseData.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright© (2019) WeBank Co., Ltd.
3 | *
4 | * This file is part of weid-http-service.
5 | *
6 | * weid-http-service is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU Lesser General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * weid-http-service is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public License
17 | * along with weid-http-service. If not, see .
18 | */
19 |
20 | package com.webank.weid.http.protocol.response;
21 |
22 | import lombok.Data;
23 |
24 | import com.webank.weid.http.constant.HttpReturnCode;
25 |
26 | /**
27 | * The internal base response result class.
28 | *
29 | * @param the generic type
30 | * @author tonychen and chaoxinhu
31 | */
32 | @Data
33 | public class HttpResponseData {
34 |
35 | private T respBody;
36 | private Object loopback;
37 | private Integer errorCode;
38 | private String errorMessage;
39 |
40 | /**
41 | * Instantiates a new response data.
42 | */
43 | public HttpResponseData() {
44 | this.setErrorCode(HttpReturnCode.SUCCESS);
45 | }
46 |
47 | /**
48 | * Instantiates a new response data.
49 | *
50 | * @param result the result
51 | * @param errorCode the return code
52 | */
53 | public HttpResponseData(T result, HttpReturnCode errorCode) {
54 | this.respBody = result;
55 | this.errorCode = errorCode.getCode();
56 | this.errorMessage = errorCode.getCodeDesc();
57 | }
58 |
59 | /**
60 | * Instantiates a new response data.
61 | *
62 | * @param result the result
63 | * @param loopback the loopback
64 | * @param errorCode the return code
65 | */
66 | public HttpResponseData(T result, Object loopback, HttpReturnCode errorCode) {
67 | this.respBody = result;
68 | this.loopback = loopback;
69 | this.errorCode = errorCode.getCode();
70 | this.errorMessage = errorCode.getCodeDesc();
71 | }
72 |
73 | /**
74 | * Instantiates a new response data by inputing all params.
75 | *
76 | * @param result the result
77 | * @param errorCode the error code
78 | * @param errorMessage the error msg
79 | */
80 | public HttpResponseData(T result, Integer errorCode, String errorMessage) {
81 | this.respBody = result;
82 | this.errorCode = errorCode;
83 | this.errorMessage = errorMessage;
84 | }
85 |
86 | /**
87 | * Instantiates a new response data by inputing all params.
88 | *
89 | * @param result the result
90 | * @param loopback the loopback
91 | * @param errorCode the error code
92 | * @param errorMessage the error msg
93 | */
94 | public HttpResponseData(T result, Object loopback, Integer errorCode, String errorMessage) {
95 | this.respBody = result;
96 | this.loopback = loopback;
97 | this.errorCode = errorCode;
98 | this.errorMessage = errorMessage;
99 | }
100 |
101 | /**
102 | * set a ErrorCode type errorCode.
103 | */
104 | public void setErrorCode(HttpReturnCode errorCode) {
105 | this.errorCode = errorCode.getCode();
106 | this.errorMessage = errorCode.getCodeDesc();
107 | }
108 |
109 | }
--------------------------------------------------------------------------------
/src/main/java/com/webank/weid/http/protocol/response/WeIdListRsp.java:
--------------------------------------------------------------------------------
1 | package com.webank.weid.http.protocol.response;
2 |
3 | import java.util.List;
4 | import lombok.Data;
5 |
6 | /**
7 | * get WeId and errorCode by pubkeyList response.
8 | *
9 | */
10 |
11 | @Data
12 | public class WeIdListRsp {
13 |
14 | private List weIdList;
15 |
16 | private List errorCodeList;
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/com/webank/weid/http/service/AuthService.java:
--------------------------------------------------------------------------------
1 | package com.webank.weid.http.service;
2 |
3 | import com.webank.weid.http.protocol.response.HttpResponseData;
4 | import com.webank.weid.protocol.base.CredentialPojo;
5 | import org.springframework.stereotype.Service;
6 |
7 | @Service
8 | public interface AuthService {
9 |
10 | /**
11 | * Process data fetching from a service URL based on the CPT101 authorization
12 | * credential and client-side signing of a nonce from http-server.
13 | *
14 | * @return remote data in String format
15 | */
16 | HttpResponseData fetchData(CredentialPojo authToken, String signedNonce);
17 |
18 | /**
19 | * Request a data fetch nonce from http server. TODO to-be-implemented.
20 | *
21 | * @return token in String format
22 | */
23 | HttpResponseData requestNonce(CredentialPojo authToken);
24 | }
25 |
--------------------------------------------------------------------------------
/src/main/java/com/webank/weid/http/service/BaseService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright© (2019) WeBank Co., Ltd.
3 | *
4 | * This file is part of weid-http-service.
5 | *
6 | * weid-http-service is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU Lesser General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * weid-http-service is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public License
17 | * along with weid-http-service. If not, see .
18 | */
19 |
20 | package com.webank.weid.http.service;
21 |
22 | import com.webank.weid.blockchain.rpc.RawTransactionService;
23 | import com.webank.weid.blockchain.service.impl.RawTransactionServiceImpl;
24 | import com.webank.weid.constant.ErrorCode;
25 | import com.webank.weid.http.protocol.request.TransactionArg;
26 | import com.webank.weid.http.protocol.response.HttpResponseData;
27 | import com.webank.weid.http.util.PropertiesUtil;
28 | import com.webank.weid.service.rpc.WeIdService;
29 | import com.webank.weid.util.PropertyUtils;
30 | import org.apache.commons.lang3.StringUtils;
31 | import org.slf4j.Logger;
32 | import org.slf4j.LoggerFactory;
33 | import org.springframework.context.ApplicationContext;
34 | import org.springframework.context.support.ClassPathXmlApplicationContext;
35 |
36 |
37 | import com.webank.payment.protocol.base.Authentication;
38 | import com.webank.payment.protocol.base.PrivateKey;
39 | import com.webank.weid.exception.WeIdBaseException;
40 | import com.webank.weid.http.constant.HttpReturnCode;
41 | import com.webank.weid.http.util.KeyUtil;
42 | import com.webank.weid.util.DataToolUtils;
43 | import com.webank.weid.util.WeIdUtils;
44 |
45 | public abstract class BaseService {
46 |
47 | private static final Logger logger = LoggerFactory.getLogger(BaseService.class);
48 |
49 | /**
50 | * spring context.
51 | */
52 | protected static final ApplicationContext context;
53 |
54 | public static RawTransactionService rawTransactionService;
55 | static {
56 | if (PropertyUtils.getProperty("deploy.style").equals("blockchain")) {
57 | rawTransactionService = new RawTransactionServiceImpl();
58 | }
59 | }
60 |
61 | static {
62 | // initializing spring containers
63 | context = new ClassPathXmlApplicationContext(new String[]{
64 | "classpath:SpringApplicationContext.xml"});
65 | logger.info("initializing spring containers finish...");
66 |
67 | }
68 |
69 | private PrivateKey buildPrivateKey(String value) {
70 | PrivateKey pri = new PrivateKey();
71 | pri.setValue(value);
72 | return pri;
73 | }
74 |
75 | protected Authentication getAuthentication(String weId) {
76 | Authentication authentication = getAuthenticationByWeId(weId);
77 | String passphrase = PropertiesUtil.getProperty("default.passphrase");
78 | if (StringUtils.isNotBlank(weId) && weId.equalsIgnoreCase(passphrase)) {
79 | //将私钥转换成公钥,将公钥转换成weId地址
80 | weId = WeIdUtils.getWeIdFromPrivateKey(authentication.getPrivateKey().getValue());
81 | }
82 | authentication.setUserAddress(WeIdUtils.convertWeIdToAddress(weId));
83 | return authentication;
84 | }
85 |
86 | private Authentication getAuthenticationByWeId(String weId) {
87 | String weIdPrivKey = KeyUtil
88 | .getPrivateKeyByWeId(KeyUtil.SDK_PRIVKEY_PATH, weId);
89 | if (StringUtils.isEmpty(weIdPrivKey)) {
90 | throw new WeIdBaseException(HttpReturnCode.INVOKER_ILLEGAL.getCodeDesc());
91 | }
92 | Authentication authentication = new Authentication();
93 | authentication.setPrivateKey(buildPrivateKey(weIdPrivKey));
94 | return authentication;
95 | }
96 |
97 | protected HttpResponseData