Skip to content

sktston/initial-controller-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

87 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

initial controller (java)

initial ํ”Œ๋žซํผ ์„œ๋น„์Šค๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•œ Java๊ธฐ๋ฐ˜์˜ Issuer, Verifier controller ์™€ Holder ์ฝ”๋“œ๋ฅผ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.

Steps to run

์šฉ๋„์— ๋”ฐ๋ผ Issuer ๋˜๋Š” Verifier ๋ฅผ ์„ ํƒํ•˜์—ฌ ์ƒ์„ฑํ•˜๊ณ  ํ…Œ์ŠคํŠธ ๋ฐ”๋ž๋‹ˆ๋‹ค.

1. ์‚ฌ์ „์ค€๋น„ - ์ด๋‹ˆ์…œ ์›น ์ฝ˜์†”

ํ…Œ์ŠคํŠธ๋„ท: https://dev-console.myinitial.io

Issuer ์ƒ์„ฑ ๋ฐ ์„ค์ •

๊ธฐ๊ด€ ์ƒ์„ฑํ•˜๊ธฐ

  • ๊ธฐ๊ด€๋ช…: Issuer๋ช… (๋ณ€๊ฒฝ๋˜์ง€ ์•–๋Š” ๊ฐ’, ์‹ ์ค‘ํ•˜๊ฒŒ ์ž‘์„ฑํ•˜์„ธ์š”)
  • ๋„๋ฉ”์ธ ์ ‘์† URL: https://issuer-controller.url (์˜ˆ์‹œ)
  • Webhook URL: https://issuer-controller.url/webhooks (webhooks ๋ณ€๊ฒฝํ•˜์ง€ ๋งˆ์„ธ์š”)
  • 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)

  • ์–‘์‹์„ค๋ช…: ์ƒ˜ํ”Œ ์ฆ๋ช…์„œ (์˜ˆ์‹œ)
  • ๊ธฐ๋ณธ ๋ฐœํ–‰ ํ•ญ๋ชฉ: ๋ณ€๊ฒฝ ๋ถˆ๊ฐ€ (ํ˜‘์˜ ํ›„ ์ƒˆ๋กœ์šด ๊ธฐ๋ณธ์–‘์‹ ์ถ”๊ฐ€ ๊ฐ€๋Šฅ)
  • ํ๊ธฐ์ง€์›์—ฌ๋ถ€: ์˜ˆ

๋ฐœํ–‰๊ด€๋ฆฌ - ๋ฐœํ–‰ ์–‘์‹ ๊ด€๋ฆฌ - ์ƒ˜ํ”Œ ํ•™์œ„์ฆ๋ช…(1.0)

  • ์ฆ๋ช…์„œ ๋ฐœํ–‰ ์„ค์ •: ๋ฐœํ–‰ ์‹œ์ž‘
  • ์ฆ๋ช…์„œ ID (CredDefId): Qr7Yo4sPs7cXiiVbEYwGsJ:3:CL:1618984624:1ee53b6d-7d8c-461e-910a-623302dc854a (์˜ˆ์‹œ) ํ™•์ธ

๊ธฐ๊ด€๊ด€๋ฆฌ - ๊ธฐ๊ด€ ์ •๋ณด

  • Access Token: 514ac4f8-e0da-43c9-910d-4894279909b2 (์˜ˆ์‹œ) ํ™•์ธ
  • Webhook URL: https://issuer-controller.url/webhooks (์„œ๋ฒ„ ์ฃผ์†Œ ๋ฐ webhooks ๋‹ค์‹œ ํ•œ๋ฒˆ ํ™•์ธ)

Verifier ์ƒ์„ฑ ๋ฐ ์„ค์ •

๊ธฐ๊ด€ ์ƒ์„ฑํ•˜๊ธฐ

  • ๊ธฐ๊ด€๋ช…: 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 ๋…ธ์ถœ: ๋ฏธ์‚ฌ์šฉ (ํ˜‘์˜ ํ›„ ์‚ฌ์šฉ)
  • ๊ธฐ๊ด€ ์‚ฌ์šฉ: ๋ฏธ์‚ฌ์šฉ (ํ˜‘์˜ ํ›„ ์‚ฌ์šฉ)

(์•„๋ž˜๋Š” ์ƒ˜ํ”Œ ๋ฐ๋ชจ๋ฅผ ์ˆ˜ํ–‰ํ•˜๊ธฐ ์œ„ํ•จ์œผ๋กœ, ์ถ”ํ›„ ์ƒˆ๋กœ ์ž‘์„ฑํ•˜์—ฌ ์‚ฌ์šฉํ•˜์„ธ์š”)

๊ฒ€์ฆ๊ด€๋ฆฌ - ๊ฒ€์ฆ ์–‘์‹ ์ƒ์„ฑ - ์ฐธ์—ฌ๊ธฐ๊ด€๋ณ„ ์ฆ๋ช… ์–‘์‹ - ์ฆ๋ช…์„œ์–‘์‹ ๊ธฐ๋ฐ˜ - ์ด๋‹ˆ์…œ ๋ชจ๋ฐ”์ผ๊ฐ€์ž…์ฆ๋ช… - ์ƒ์„ฑํ•˜๊ธฐ

  • ๊ฒ€์ฆ ์–‘์‹๋ช…: ๋ชจ๋ฐ”์ผ ๊ฐ€์ž… ์ฆ๋ช… ๊ฒ€์ฆ (์˜ˆ์‹œ)
  • ์–‘์‹ ์„ค๋ช…: ๋ชจ๋ฐ”์ผ ๊ฐ€์ž… ์ฆ๋ช… ๊ฒ€์ฆ (์˜ˆ์‹œ)
  • ๊ฒ€์ฆ ํ•ญ๋ชฉ ์„ ํƒ: person_name, mobile_num ๋“ฑ

๊ฒ€์ฆ๊ด€๋ฆฌ - ๊ฒ€์ฆ ์–‘์‹ ๊ด€๋ฆฌ - ์ƒ˜ํ”Œ ๋ชจ๋ฐ”์ผ ๊ฐ€์ž… ์ฆ๋ช… ๊ฒ€์ฆ - ์ƒ์„ธ ๋ณด๊ธฐ

  • ๊ฒ€์ฆ ์–‘์‹ ID (verifTplId): 0012d683-bdb0-4050-ac85-ae37e59bad09 (์˜ˆ์‹œ) ํ™•์ธ

๊ธฐ๊ด€๊ด€๋ฆฌ - ๊ธฐ๊ด€ ์ •๋ณด

  • 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 ํ˜น์€ 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-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 ๋˜๋Š” verifier ์‹คํ–‰

issuer ์‹คํ–‰ (issuer terminal)

./gradlew issuer

๋˜๋Š” web view ๋กœ์ง์ด ๋“ค์–ด๊ฐ„ ๋ฐ๋ชจ๋ฅผ ์ˆ˜ํ–‰ํ•˜๋ ค๋Š” ๊ฒฝ์šฐ ./gradlew issuer_webview
๋˜๋Š” revocation ๋กœ์ง์ด ๋“ค์–ด๊ฐ„ ๋ฐ๋ชจ๋ฅผ ์ˆ˜ํ–‰ํ•˜๋ ค๋Š” ๊ฒฝ์šฐ ./gradlew issuer_revoke

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 ์„œ๋น„์Šค ์‚ฌ์šฉํ•˜์—ฌ ์ฆ๋ช…์„œ๊ฐ€ ์ •์ƒ ๋ฐœ๊ธ‰ ๋œ ๊ฒฝ์šฐ ๋ฉ”์‹œ์ง€ (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)

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

Issuer Work flow

Initialization

Issuer๋Š” accessToken, credDefId, verifTplId, webhookUrl ์ด valid ํ•œ ์ง€ ํ™•์ธ ํ•˜๊ณ  ๋Œ€๊ธฐํ•จ.

Connection

Holder๊ฐ€ https://issuer-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 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 /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

Issuer๋Š” (issue_credential, proposal_received) ์‹œ์ ์— holder๊ฐ€ ๋ณด๋‚ธ credDefId๋ฅผ ํ™•์ธ ํ›„, ์ถ”ํ›„ issue ๊ณผ์ •์„ ์œ„ํ•ด credExId๋ฅผ ์ €์žฅ ํ•ด ๋‘ 
Issuer๋Š” (present_proof, verified) ์‹œ์ ์— webhook ๋ฉ”์‹œ์ง€๋ฅผ getPresentationResult ํ•˜์—ฌ ์š”๊ตฌํ•œ ์ •๋ณด ํš๋“

(Optional) Web View

Issuer๊ฐ€ Presentation์˜ ์ •๋ณด๋กœ ๋ฐœํ–‰ ๊ฐ€๋Šฅํ•œ ์ฆ๋ช…์„œ๋ฅผ ํ•œ์ •ํ•˜๊ธฐ ์–ด๋ ค์šด ๊ฒฝ์šฐ, ์ถ”๊ฐ€ ์ •๋ณด ํš๋“์„ ์œ„ํ•จ

Issuer API Holder API Issuer webhook (topic, state, *msg_type) Holder webhook (topic, state, *msg_type)
POST /connections/{conn_id}/send-message basicmessages, received, *initial_web_view

Holder๋Š” Issuer๊ฐ€ ์ œ๊ณตํ•œ web view ํŽ˜์ด์ง€ webViewUrl ๋ฅผ ๋ณด์—ฌ์ฃผ๊ณ  ์‚ฌ์šฉ์ž๊ฐ€ item ํ•˜๋‚˜๋ฅผ ์„ ํƒํ•จ
๋ณธ ๋ฐ๋ชจ์—์„œ๋Š” item ํ•˜๋‚˜๋ฅผ ์„ ํƒํ•˜์—ฌ Issuer์˜ POST https://issuer-controller.url/web-view/submit ๋ฅผ ํ˜ธ์ถœํ•œ๋‹ค๋Š” ๊ฐ€์ •ํ•˜์— ๋™์ž‘ํ•จ

Issue Credential

Issuer๋Š” ๋ฐ›์€ ์ •๋ณด๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ DB๋ฅผ query ํ•˜์—ฌ ์ฆ๋ช…์„œ๋ฅผ ์ž‘์„ฑํ•˜์—ฌ ๋ฐœ๊ธ‰ํ•จ

Issuer API Holder API Issuer webhook (topic, state) Holder webhook (topic, state)
POST /issue-credential/records/{credExId}/send-offer issue_credential, offer_sent issue_credential, offer_received
POST /issue-credential/records/{credExId}/send-request issue_credential, request_received issue_credential, request_sent
issue_credential, credential_issued issue_credential, credential_received
issuer_cred_rev, issued
issue_credential, credential_acked issue_credential, credential_acked

์ถ”ํ›„ ๋ฐœ๊ธ‰ํ•œ ์ฆ๋ช…์„œ๋ฅผ ํ๊ธฐ(revocation)ํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š”,
Issuer๋Š” (issue_credential, credential_acked) ์‹œ์ ์— webhook ๋ฉ”์‹œ์ง€๋ฅผ ํ™•์ธํ•˜์—ฌ credential_exchange_id ๋ฅผ DB์— ๊ธฐ๋กํ•ด ๋‘์–ด์•ผ ํ•จ

(Optional) Revocation

Issuer API Holder API Issuer webhook (topic, state) Holder webhook (topic, state)
POST /revocation/revoke issuer_cred_rev, revoked

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

๋ฑ๊ฒฝ ํ•ด์•ผ ํ•  ํ•ญ๋ชฉ๋งŒ ์ •๋ฆฌ

1. ์‚ฌ์ „์ค€๋น„

์ƒ์šฉ: https://console.myinitial.io

Issuer ์ƒ์„ฑ ๋ฐ ์„ค์ •

production ์ƒˆ๋กœ ์ž‘์„ฑ

Holder ์ƒ์„ฑ ๋ฐ ์„ค์ • (Issuer ๋™์ž‘ ํ™•์ธ ์œ„ํ•จ)

production ์ƒˆ๋กœ ์ž‘์„ฑ

2. properties ์„ค์ •

application-issuer-prod.properties

agentApiUrl = https://console.myinitial.io/agent/api (๊ณ ์ •)

application-verifier-prod.properties

agentApiUrl = https://console.myinitial.io/agent/api (๊ณ ์ •)

3. issuer ๋˜๋Š” verifier ์‹คํ–‰

issuer ์‹คํ–‰

./gradlew issuer_prod

verifier ์‹คํ–‰

./gradlew verifier_prod