Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
c1414d5
Add problem report
baegjae May 26, 2021
16aed35
Add problem report
baegjae May 31, 2021
2fd9437
Refactor
baegjae May 31, 2021
f6d5dc3
Add manual web view at holder
baegjae May 31, 2021
37347c3
Update form.html
baegjae May 31, 2021
b01f823
Merge pull request #16 from sktston/feature/problem-report
baegjae May 31, 2021
7232f8c
Update printing error message
baegjae Jun 1, 2021
36fa6e6
Add agreement at presentation request
baegjae Jun 17, 2021
40fa9a3
Merge pull request #17 from sktston/feature/add-agreement-presentatio…
baegjae Jun 17, 2021
6103131
Print predicates results
baegjae Jul 9, 2021
316676e
Merge pull request #19 from sktston/feature/add-predicates
baegjae Jul 9, 2021
1c1927c
Fix type cast
baegjae Jul 9, 2021
72ce208
Update README.md
baegjae Aug 3, 2021
471d316
Fix typo
baegjae Aug 10, 2021
508ae11
Add testing webhook configuration
baegjae Aug 10, 2021
52046e5
Refactor
baegjae Aug 10, 2021
e10c716
Update checking webhook url
baegjae Aug 10, 2021
f3ee110
Update waiting time
baegjae Aug 10, 2021
72b3ff9
Add webhook url checking in holder
baegjae Aug 10, 2021
d663c21
Fix error
baegjae Aug 10, 2021
3686ec5
Add verifier
baegjae Aug 10, 2021
04e8dbf
Fix gradle
baegjae Aug 10, 2021
ff41598
Remove webviewUrl
baegjae Aug 10, 2021
f0b9f02
Adjust port
baegjae Aug 10, 2021
01378dd
Update README.md
baegjae Aug 10, 2021
2b52edb
Add oob-invitation-url
baegjae Sep 3, 2021
4ab0a5d
Fix parse oob invitation url
baegjae Sep 3, 2021
aae974a
upgrade gradle
baegjae Oct 13, 2021
8fd4b27
Merge pull request #21 from sktston/feature/upgrade-gradle
baegjae Oct 13, 2021
367be3a
Remove oob to avoid confusion
baegjae Oct 15, 2021
2e0b051
Merge pull request #22 from sktston/feature/temp-remove-oob
baegjae Oct 15, 2021
7417c98
Update GlobalService.java
stonskt Jan 26, 2022
19c2aba
Update holder
baegjae Jul 13, 2022
097930c
Update issuer and holder
baegjae Jul 13, 2022
4ae268d
Update verifier
baegjae Jul 14, 2022
86331ef
Update conf
baegjae Jul 14, 2022
bcccc74
Update holder
baegjae Jul 14, 2022
e4b4576
Merge pull request #25 from sktston/feature/upgrade
baegjae Jul 14, 2022
27d0867
Rename test -> tp (third party)
baegjae Jul 14, 2022
9c0293c
Update README.md
baegjae Jul 14, 2022
a168ac5
Update conf
baegjae Jul 14, 2022
b2fdf81
Change test issuer from webview issuer to no webview issuer
baegjae Sep 16, 2022
8aeb71d
Rename tp to mobile
baegjae Sep 16, 2022
54c6de0
Add params when getting events last
baegjae Oct 5, 2022
dc09486
Add self attested hint sample
baegjae May 4, 2023
f41fdc1
Merge pull request #26 from sktston/feature/add-self-attested
baegjae May 4, 2023
76be33e
Add holder code
baegjae May 4, 2023
a542dc2
Merge pull request #27 from sktston/feature/add-self-attested-demo
baegjae May 4, 2023
8638df2
Add handling for encrypted webhook messages
baegjae May 19, 2023
bea1bd9
Merge pull request #29 from sktston/feature/encrypted-webhook
baegjae May 19, 2023
60df994
Add demo for encrypted send offer
baegjae Jun 2, 2023
f111a57
Merge pull request #30 from sktston/feature/encrypt-demo
baegjae Jun 2, 2023
8a9713b
Revise enc send offer
baegjae Jun 20, 2023
70a2115
Merge pull request #31 from sktston/feature/revise-enc-send-offer
baegjae Jun 20, 2023
d0c01f6
Update configuration
baegjae Jul 6, 2023
1df973b
Update README.md
khujin1 Aug 9, 2023
0ef400e
Update demo cred def id
baegjae Aug 10, 2023
98f20a5
Add webhook based holder demo
baegjae Oct 23, 2023
874611b
Merge pull request #32 from sktston/feature/webhook-holder
baegjae Oct 23, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
140 changes: 103 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# initial controller (java)
initial 플랫폼 서비스를 사용하기 위한 Java기반의 Issuer, Verifier, Holder controller 코드를 제공합니다.
initial 플랫폼 서비스를 사용하기 위한 Java기반의 Issuer, Verifier controller 와 Holder 코드를 제공합니다.

## Steps to run
용도에 따라 Issuer 또는 Verifier 를 선택하여 생성하고 테스트 바랍니다.

### 1. 사전준비 - 이니셜 웹 콘솔
테스트넷: https://dev-console.myinitial.io

Expand All @@ -10,20 +12,20 @@ initial 플랫폼 서비스를 사용하기 위한 Java기반의 Issuer, Verifie
- 기관명: Issuer명 (변경되지 앖는 값, 신중하게 작성하세요)
- 도메인 접속 URL: https://issuer-controller.url (예시)
- Webhook URL: https://issuer-controller.url/webhooks (webhooks 변경하지 마세요)
- 도메인 접속 URL: https://issuer-controller.url/invitation-url (invitation-url 변경하지 마세요)
- Invitation URL: https://issuer-controller.url/invitation-url (invitation-url 변경하지 마세요)
- 기관 구분: Issuer, Verifier 동시 선택
- AppType: Android, iOS 동시 선택
- App 노출: 미사용 (협의 후 사용)
- 기관 사용: 미사용 (협의 후 사용)

(아래는 샘플 데모를 수행하기 위함으로, 추후 새로 작성하여 사용하세요)

검증관리 - 검증 양식 생성 - 참여기관별 증명 양식 - (샘플)이니셜모바일가입증명 - 샘플 모바일 가입증명 - 생성하기
- 검증 양식명: 샘플 모바일 가입 증명 검증 (예시)
- 양식 설명: 샘플 모바일 가입 증명 검증 (예시)
검증관리 - 검증 양식 생성 - 참여기관별 증명 양식 - 증명서양식 기반 - 이니셜 모바일가입증명 - 생성하기
- 검증 양식명: 모바일 가입 증명 검증 (예시)
- 양식 설명: 모바일 가입 증명 검증 (예시)
- 검증 항목 선택: person_name, mobile_num 등

검증관리 - 검증 양식 관리 - 샘플 모바일 가입 증명 검증 - 상세 보기
검증관리 - 검증 양식 관리 - 모바일 가입 증명 검증 - 상세 보기
- 검증 양식 ID (`verifTplId`): `0012d683-bdb0-4050-ac85-ae37e59bad09` (예시) **확인**

발행관리 - 발행 양식 생성 - 샘플 학위증명(1.0)
Expand All @@ -39,66 +41,104 @@ initial 플랫폼 서비스를 사용하기 위한 Java기반의 Issuer, Verifie
- `Access Token`: `514ac4f8-e0da-43c9-910d-4894279909b2` (예시) **확인**
- Webhook URL: https://issuer-controller.url/webhooks (**서버 주소 및 webhooks 다시 한번 확인**)

#### Holder 생성 및 설정 (Issuer 동작 확인 위함)
#### Verifier 생성 및 설정
기관 생성하기
- 기관명: Holder명 (테스트 용도)
- 도메인 접속 URL: https://holder-controller.url (예시)
- Webhook URL: https://holder-controller.url/webhooks (webhooks 변경하지 마세요)
- 도메인 접속 URL: https://holder-controller.url/invitation-url (invitation-url 변경하지 마세요)
- 기관명: Verifier명 (변경되지 앖는 값, 신중하게 작성하세요)
- 도메인 접속 URL: https://verifier-controller.url (예시)
- Webhook URL: https://verifier-controller.url/webhooks (webhooks 변경하지 마세요)
- Invitation URL: https://verifier-controller.url/invitation-url (invitation-url 변경하지 마세요)
- 기관 구분: Verifier 선택
- AppType: Android, iOS 동시 선택
- App 노출: 미사용
- 기관 사용: 미사용
- App 노출: 미사용 (협의 후 사용)
- 기관 사용: 미사용 (협의 후 사용)

(아래는 샘플 데모를 수행하기 위함으로, 추후 새로 작성하여 사용하세요)

검증관리 - 검증 양식 생성 - 참여기관별 증명 양식 - 증명서양식 기반 - 이니셜 모바일가입증명 - 생성하기
- 검증 양식명: 모바일 가입 증명 검증 (예시)
- 양식 설명: 모바일 가입 증명 검증 (예시)
- 검증 항목 선택: person_name, mobile_num 등

검증관리 - 검증 양식 관리 - 샘플 모바일 가입 증명 검증 - 상세 보기
- 검증 양식 ID (`verifTplId`): `0012d683-bdb0-4050-ac85-ae37e59bad09` (예시) **확인**

기관관리 - 기관 정보
- `Access Token`: `3a0ece13-dd04-419d-b3ea-f12b52e297d7` (예시) **확인**
- Webhook URL: https://holder-controller.url/webhooks (**서버 주소 및 webhooks 다시 한번 확인**)
- `Access Token`: `514ac4f8-e0da-43c9-910d-4894279909b2` (예시) **확인**
- Webhook URL: https://verifier-controller.url/webhooks (**서버 주소 및 webhooks 다시 한번 확인**)

### 2. properties 설정 - 본 repository 코드
`src/main/resources/`

#### application-issuer.properties
server.port = 8040 \
agentApiUrl = https://dev-console.myinitial.io/agent/api (고정) \
agentApiUrl = https://dev-console.myinitial.io/agent/api 혹은 https://dev-console.myinitial.io/agent/v2/api (기관 설정 값에서 확인) \
accessToken = issuer의 `Access Token` \
credDefId = 작성한 issuer의 `CredDefId` \
verifTplId = 작성한 issuer의 `verifTplId` \
webViewUrl = `https://issuer-controller.url/web-view/form.html` (Optional) Holder 에게 보여줄 Web View 페이지 주소

#### application-holder.properties
server.port = 8041 \
agentApiUrl = https://dev-console.myinitial.io/agent/api (고정) \
accessToken = holder의 `Access Token` \
issuerInvitationUrl = `https://issuer-controller.url/invitation-url` invitation-url 을 받을 주소 \
issuerCredDefId = 작성한 issuer의 `CredDefId`
#### application-verifier.properties
server.port = 8040 \
agentApiUrl = https://dev-console.myinitial.io/agent/api 혹은 https://dev-console.myinitial.io/agent/v2/api (기관 설정 값에서 확인) \
accessToken = verifier `Access Token` \
verifTplId = 작성한 issuer의 `verifTplId`

### 3. issuer 및 holder 실행 - 각 terminal
### 3. issuer 또는 verifier 실행
#### issuer 실행 (issuer terminal)
```
./gradlew issuer
```
또는 web view 로직이 들어간 데모를 수행하려는 경우 `./gradlew issuer_webview` \
또는 revocation 로직이 들어간 데모를 수행하려는 경우 `./gradlew issuer_revoke`

#### 정상 구동 시 메시지 (issuer terminal)
#### verifier 실행 (verifier terminal)
```
./gradlew verifier
```

#### 정상 구동 시 메시지 (issuer 또는 verifier terminal)
```
[GlobalService.java]initializeAfterStartup(61) : Controller is ready
```

### 4. holder 실행 (issuer 또는 verifier 테스트 위함)

#### holder 설정 변경
`src/main/java/com/sktelecom/initial/controller/holder/Application.java`

String appMode = "dev"; // dev 또는 prod \
String runType = "issue"; // issue 또는 verify

String tpIssuerInvitationUrl = "https://issuer-controller.url/invitation-url"; \
String tpCredDefId = "작성한 issuer의 `CredDefId`";

또는

String tpVerifierInvitationUrl = "https://verifier-controller.url/invitation-url";

초기값은 dev환경의 미리 설정되어 있는 test issuer 또는 test verifier 로 설정되어 있습니다. \
변경없이 우선 테스트 해보시면 holder 동작을 파악하실 수 있습니다.

#### holder 실행 (holder terminal)
```
./gradlew holder
```

#### issuer 의 증명서가 정상 발급 된 경우 메시지 (holder terminal)
#### issuer 서비스 사용하여 증명서가 정상 발급 된 경우 메시지 (issuer terminal)
```
2021-08-10 17:25:48 [INFO ] [GlobalService.java]handleEvent(97) : - Case (topic:issue_credential, state:credential_acked) -> credential issued successfully
```

#### verifier 서비스 사용하여 정상 검증된 경우 메시지 (verifier terminal)
```
[GlobalService.java]handleEvent(97) : - Case (topic:issue_credential, state:credential_acked) -> credential received successfully
2021-08-10 17:24:38 [INFO ] [GlobalService.java]handleEvent(77) : - Case (topic:present_proof, state:verified) -> getPresentationResult
2021-08-10 17:24:38 [INFO ] [GlobalService.java]getPresentationResult(283) : Requested Attribute - person_name: 김증명
2021-08-10 17:24:38 [INFO ] [GlobalService.java]getPresentationResult(283) : Requested Attribute - mobile_num: 01023456789
```

## Work flow
## Issuer Work flow
### Initialization
Issuer는 accessToken, credDefId, verifTplId 가 valid 한 지 확인 하고 대기함. \
Holder는 accessToken이 valid 한 지 확인 후, 샘플 모바일 가입증명을 발급 받고, 아래 과정 진행.
Issuer는 accessToken, credDefId, verifTplId, webhookUrl 이 valid 한 지 확인 하고 대기함.

### Connection
Holder가 https://issuer-controller.url/invitation-url 호출부터 시작
Expand All @@ -111,14 +151,12 @@ Holder가 https://issuer-controller.url/invitation-url 호출부터 시작
| | | connections, response | connections, response |
| | | connections, active | connections, active |

### Presentation
### Presentation before Issue Credential
Holder가 (connections, active) 시점에 credential proposal을 보냄

| Issuer API | Holder API | Issuer webhook (topic, state, *msg_type) | Holder webhook (topic, state, *msg_type) |
|---|---|---|---|
| | POST /issue-credential/send-proposal | issue_credential, proposal_received | issue_credential, proposal_sent |
| POST /connections/{conn_id}/send-message | | | basicmessages, received, *initial_agreement |
| | POST /connections/{conn_id}/send-message | basicmessages, received, *initial_agreement_decision | |
| POST /present-proof/send-verification-request | | present_proof, request_sent | present_proof, request_received |
| | GET /present-proof/records/{presExId}/credentials | | |
| | POST /present-proof/records/{presExId}/send-presentation | present_proof, presentation_received | present_proof, presentation_sent |
Expand Down Expand Up @@ -148,7 +186,7 @@ Issuer는 받은 정보를 기반으로 DB를 query 하여 증명서를 작성
| | | issuer_cred_rev, issued | |
| | | issue_credential, credential_acked | issue_credential, credential_acked |

발급한 증명서를 폐기(revocation)하기 위해, \
추후 발급한 증명서를 폐기(revocation)하기 위해서는, \
Issuer는 (issue_credential, credential_acked) 시점에 webhook 메시지를 확인하여 credential_exchange_id 를 DB에 기록해 두어야 함

### (Optional) Revocation
Expand All @@ -158,6 +196,34 @@ Issuer는 (issue_credential, credential_acked) 시점에 webhook 메시지를

Revoke된 credential은 Issuer가 (present_proof, verified) 시점에, webhook 메시지를 getPresentationResult 하는 과정에서 verified 가 false 임

## Verifier Work flow
### Initialization
Verifier는 accessToken, credDefId, verifTplId, webhookUrl 이 valid 한 지 확인 하고 대기함.

### Connection
Holder가 https://verifier-controller.url/invitation-url 호출부터 시작

| Issuer API | Holder API | Issuer webhook (topic, state) | Holder webhook (topic, state) |
|---|---|---|---|
| POST /connections/create-invitation | | | |
| | POST /connections/receive-invitation | | connections, invitation |
| | | connections, request | connections, request |
| | | connections, response | connections, response |
| | | connections, active | connections, active |

### Presentation
Holder가 (connections, active) 시점에 presentation proposal을 보냄

| Issuer API | Holder API | Issuer webhook (topic, state, *msg_type) | Holder webhook (topic, state, *msg_type) |
|---|---|---|---|
| | POST /present-proof/send-proposal | present_proof, proposal_received | present_proof, proposal_sent |
| POST /present-proof/send-verification-request | | present_proof, request_sent | present_proof, request_received |
| | GET /present-proof/records/{presExId}/credentials | | |
| | POST /present-proof/records/{presExId}/send-presentation | present_proof, presentation_received | present_proof, presentation_sent |
| | | present_proof, verified | present_proof, presentation_acked |

Verifier는 (present_proof, verified) 시점에 webhook 메시지를 getPresentationResult 하여 요구한 정보 획득

## Production
뱐경 해야 할 항목만 정리

Expand All @@ -174,16 +240,16 @@ production 새로 작성
#### application-issuer-prod.properties
agentApiUrl = https://console.myinitial.io/agent/api (고정)

#### application-holder-prod.properties
#### application-verifier-prod.properties
agentApiUrl = https://console.myinitial.io/agent/api (고정)

### 3. issuer 및 holder 실행
### 3. issuer 또는 verifier 실행
#### issuer 실행
```
./gradlew issuer_prod
```

#### holder 실행
#### verifier 실행
```
./gradlew holder_prod
./gradlew verifier_prod
```
36 changes: 23 additions & 13 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,15 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
testImplementation 'org.springframework.boot:spring-boot-starter-test'

compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
compileOnly 'org.projectlombok:lombok:1.18.24'
annotationProcessor 'org.projectlombok:lombok:1.18.24'

compile group: 'com.squareup.okhttp3', name: 'okhttp', version: '4.8.0'
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.6'
implementation 'com.jayway.jsonpath:json-path:2.4.0'
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.10'
compile 'com.google.zxing:javase:3.3.3'
compile group: 'commons-codec', name: 'commons-codec', version: '1.15'
implementation group: 'commons-io', name: 'commons-io', version: '2.6'
implementation 'com.squareup.okhttp3:okhttp:4.10.0'
implementation 'com.google.code.gson:gson:2.9.0'
implementation 'com.jayway.jsonpath:json-path:2.7.0'
implementation 'org.apache.commons:commons-lang3:3.12.0'
implementation 'commons-codec:commons-codec:1.15'
implementation 'commons-io:commons-io:2.11.0'
}

test {
Expand Down Expand Up @@ -65,15 +64,26 @@ task issuer_prod(type:JavaExec) {
main = 'com.sktelecom.initial.controller.issuer.Application'
args(['--spring.config.location=classpath:/application-issuer-prod.properties'])
}
task verifier(type:JavaExec) {
group 'application'
classpath sourceSets.main.runtimeClasspath
main = 'com.sktelecom.initial.controller.verifier.Application'
args(['--spring.config.location=classpath:/application-verifier.properties'])
}
task verifier_prod(type:JavaExec) {
group 'application'
classpath sourceSets.main.runtimeClasspath
main = 'com.sktelecom.initial.controller.verifier.Application'
args(['--spring.config.location=classpath:/application-verifier-prod.properties'])
}
task holder(type:JavaExec) {
group 'application'
classpath sourceSets.main.runtimeClasspath
main = 'com.sktelecom.initial.controller.holder.Application'
args(['--spring.config.location=classpath:/application-holder.properties'])
}
task holder_prod(type:JavaExec) {
task holder_webhook(type:JavaExec) {
group 'application'
classpath sourceSets.main.runtimeClasspath
main = 'com.sktelecom.initial.controller.holder.Application'
args(['--spring.config.location=classpath:/application-holder-prod.properties'])
main = 'com.sktelecom.initial.controller.holder_webhook.Application'
args(['--spring.config.location=classpath:/application-holder_webhook.properties'])
}
Loading