-
Notifications
You must be signed in to change notification settings - Fork 0
[KW-682] feat/webhook handler #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 5 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
610365d
KW-682/feat: acapy webhook controller ꡬν
willjsw 67a9a00
KW-682/feat: mediator agent ꡬν λ° invitation μμ± μν req/res dto ꡬν
willjsw 367895e
KW-682/feat: hospital agent ꡬν λ° res/req dto ꡬν
willjsw c0197d7
KW-682/feat: web hook νΈλ€λ¬ service ꡬν
willjsw 3d35007
KW-682/refactor: λλ ν°λ¦¬ μ΄λ ν μμ¬ did dto μμ
willjsw 1ef3da4
KW-682/refactor: test 무λ ₯ν
willjsw 7af93af
Update src/main/java/com/doubleo/didagent/agent/HospitalAgent.java
willjsw 517a56b
Update src/main/java/com/doubleo/didagent/service/AcapyWebhookServiceβ¦
willjsw 58c145b
Update src/main/java/com/doubleo/didagent/agent/HospitalAgent.java
willjsw 4970707
Update src/main/java/com/doubleo/didagent/agent/HospitalAgent.java
willjsw c8add9a
Update src/main/java/com/doubleo/didagent/service/AcapyWebhookServiceβ¦
willjsw a9084d1
KW-682/refactor: spotless apply
willjsw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
101 changes: 101 additions & 0 deletions
101
src/main/java/com/doubleo/didagent/agent/HospitalAgent.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| package com.doubleo.didagent.agent; | ||
|
|
||
| import com.doubleo.didagent.agent.client.AcapyClient; | ||
| import com.doubleo.didagent.dto.request.hospital.HospitalDidCreateRequest; | ||
| import com.doubleo.didagent.dto.request.hospital.HospitalInvitationCreateRequest; | ||
| import com.doubleo.didagent.dto.request.hospital.HospitalVcIssueRequest; | ||
| import com.doubleo.didagent.dto.response.hospital.*; | ||
| import com.doubleo.didagent.infra.config.acapy.AcapyProperties; | ||
| import lombok.RequiredArgsConstructor; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.springframework.http.MediaType; | ||
| import org.springframework.stereotype.Service; | ||
| import reactor.core.publisher.Mono; | ||
|
|
||
| @Service | ||
| @RequiredArgsConstructor | ||
| @Slf4j | ||
| public class HospitalAgent { | ||
|
|
||
| private final AcapyClient hospitalClient; | ||
| private final AcapyProperties acapyProperties; | ||
|
|
||
| public Mono<HospitalInvitationCreateResponse> createHospitalInvitation( | ||
| HospitalInvitationCreateRequest request, String token) { | ||
| System.out.println(acapyProperties.createInvitation()); | ||
| return hospitalClient | ||
| .getWebClient() | ||
| .post() | ||
| .uri(uriBuilder -> uriBuilder.path(acapyProperties.createInvitation()).build()) | ||
| .contentType(MediaType.APPLICATION_JSON) | ||
| .header("Authorization", "Bearer " + token) | ||
| .bodyValue(request) | ||
| .retrieve() | ||
| .bodyToMono(HospitalInvitationCreateResponse.class) | ||
| .doOnError( | ||
| error -> { | ||
| log.error( | ||
| "Hospital MemberConnection fetch error: {}", | ||
| error.getMessage()); | ||
| }); | ||
| } | ||
|
|
||
| public Mono<HospitalDidCreateResponse> createHospitalDid( | ||
| HospitalDidCreateRequest request, String token) { | ||
| return hospitalClient | ||
| .getWebClient() | ||
| .post() | ||
| .uri(uriBuilder -> uriBuilder.path(acapyProperties.createDid()).build()) | ||
| .contentType(MediaType.APPLICATION_JSON) | ||
| .header("Authorization", "Bearer " + token) | ||
| .bodyValue(request) | ||
| .retrieve() | ||
| .bodyToMono(HospitalDidCreateResponse.class) | ||
| .doOnError( | ||
| error -> { | ||
| log.error("Hospital Did Creation error: {}", error.getMessage()); | ||
| }); | ||
| } | ||
|
|
||
| public Mono<HospitalDidPostResponse> postHospitalDid(String token, String did) { | ||
| return hospitalClient | ||
| .getWebClient() | ||
| .post() | ||
| .uri( | ||
| uriBuilder -> | ||
| uriBuilder | ||
| .path(acapyProperties.postPublicDid()) | ||
| .queryParam("did", did) | ||
| .build()) | ||
| .contentType(MediaType.APPLICATION_JSON) | ||
| .header("Authorization", "Bearer " + token) | ||
| .retrieve() | ||
| .bodyToMono(HospitalDidPostResponse.class) | ||
| .doOnError( | ||
| error -> { | ||
| log.error("Hospital DID Post error: {}", error.getMessage()); | ||
| }); | ||
| } | ||
|
|
||
| public Mono<HospitalVcIssueResponse> issueHospitalVc( | ||
| HospitalVcIssueRequest request, String token) { | ||
| System.out.println(acapyProperties.issueVc()); | ||
willjsw marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| Mono<HospitalVcIssueResponse> res = | ||
| hospitalClient | ||
| .getWebClient() | ||
| .post() | ||
| .uri(uriBuilder -> uriBuilder.path(acapyProperties.issueVc()).build()) | ||
| .contentType(MediaType.APPLICATION_JSON) | ||
| .header("Authorization", "Bearer " + token) | ||
| .bodyValue(request) | ||
| .retrieve() | ||
| .bodyToMono(HospitalVcIssueResponse.class) | ||
| .doOnError( | ||
| error -> { | ||
| log.error("Hospital VC Issuance error: {}", error.getMessage()); | ||
| }); | ||
|
|
||
| System.out.println(res); | ||
willjsw marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| return res; | ||
| } | ||
| } | ||
38 changes: 38 additions & 0 deletions
38
src/main/java/com/doubleo/didagent/agent/MediatorAgent.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| package com.doubleo.didagent.agent; | ||
|
|
||
| import com.doubleo.didagent.agent.client.AcapyClient; | ||
| import com.doubleo.didagent.dto.request.mediator.MediatorInvitationCreateRequest; | ||
| import com.doubleo.didagent.dto.response.mediator.MediatorInvitationCreateResponse; | ||
| import com.doubleo.didagent.infra.config.acapy.AcapyProperties; | ||
| import lombok.RequiredArgsConstructor; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.springframework.http.MediaType; | ||
| import org.springframework.stereotype.Service; | ||
| import reactor.core.publisher.Mono; | ||
|
|
||
| @Service | ||
| @RequiredArgsConstructor | ||
| @Slf4j | ||
| public class MediatorAgent { | ||
|
|
||
| private final AcapyClient mediatorClient; | ||
| private final AcapyProperties acapyProperties; | ||
|
|
||
| public Mono<MediatorInvitationCreateResponse> createMediatorInvitation( | ||
| MediatorInvitationCreateRequest request) { | ||
| return mediatorClient | ||
| .getWebClient() | ||
| .post() | ||
| .uri(uriBuilder -> uriBuilder.path(acapyProperties.createInvitation()).build()) | ||
| .contentType(MediaType.APPLICATION_JSON) | ||
| .bodyValue(request) | ||
| .retrieve() | ||
| .bodyToMono(MediatorInvitationCreateResponse.class) | ||
| .doOnError( | ||
| error -> { | ||
| log.error( | ||
| "Mediator MemberConnection fetch error: {}", | ||
| error.getMessage()); | ||
| }); | ||
| } | ||
| } |
60 changes: 58 additions & 2 deletions
60
src/main/java/com/doubleo/didagent/controller/AcapyWebhookController.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 0 additions & 8 deletions
8
src/main/java/com/doubleo/didagent/dto/request/DidCreateRequest.java
This file was deleted.
Oops, something went wrong.
10 changes: 10 additions & 0 deletions
10
src/main/java/com/doubleo/didagent/dto/request/hospital/HospitalDidCreateRequest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package com.doubleo.didagent.dto.request.hospital; | ||
|
|
||
| public record HospitalDidCreateRequest(String method, Options options) { | ||
| public record Options(String key_type) {} | ||
|
|
||
| public static HospitalDidCreateRequest didKey() { | ||
| Options options = new Options("ed25519"); | ||
| return new HospitalDidCreateRequest("key", options); | ||
| } | ||
| } |
108 changes: 108 additions & 0 deletions
108
src/main/java/com/doubleo/didagent/dto/request/hospital/HospitalVcIssueRequest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| package com.doubleo.didagent.dto.request.hospital; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonProperty; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
||
| public record HospitalVcIssueRequest( | ||
| @JsonProperty("connection_id") String connectionId, | ||
| @JsonProperty("credential_preview") CredentialPreview credentialPreview, | ||
| Filter filter, | ||
| @JsonProperty("auto_issue") boolean autoIssue, | ||
| @JsonProperty("auto_remove") boolean autoRemove) { | ||
|
|
||
| public record CredentialPreview( | ||
| @JsonProperty("@type") String type, List<Attribute> attributes) { | ||
| public record Attribute(String name, String value) {} | ||
| } | ||
|
|
||
| public record Filter(@JsonProperty("ld_proof") LdProofFilter ldProof) {} | ||
|
|
||
| public record LdProofFilter( | ||
| @JsonProperty("credential") Credential credential, | ||
| @JsonProperty("options") Options options) {} | ||
|
|
||
| public record Credential( | ||
| @JsonProperty("@context") List<Object> context, | ||
| @JsonProperty("type") List<String> type, | ||
| @JsonProperty("issuer") String issuer, | ||
| @JsonProperty("issuanceDate") String issuanceDate, | ||
| @JsonProperty("credentialSubject") CredentialSubject credentialSubject) {} | ||
|
|
||
| public record CredentialSubject( | ||
| @JsonProperty("id") String id, | ||
| @JsonProperty("hospital_tenant") String hospitalTenant, | ||
| @JsonProperty("area_code") String areaCode) {} | ||
|
|
||
| public record Options( | ||
| @JsonProperty("proofType") String proofType, | ||
| @JsonProperty("proofPurpose") String proofPurpose) {} | ||
|
|
||
| // LD Proof κΈ°λ° λ³μ μ κ·Ό ν¬λ¦¬λ΄μ μ© ν©ν 리 λ©μλ | ||
| public static HospitalVcIssueRequest createLdProofCredential( | ||
| String connectionId, | ||
| String issuer, | ||
| String credentialSubjectId, | ||
| String hospitalTenant, | ||
| String areaCode) { | ||
|
|
||
| List<Object> defaultContext = | ||
| List.of( | ||
| "https://www.w3.org/2018/credentials/v1", | ||
| Map.of( | ||
| "hospital_tenant", "https://example.org/hospital_tenant", | ||
| "area_code", "https://example.org/area_code")); | ||
|
|
||
| List<String> defaultType = List.of("VerifiableCredential", "HospitalAccessCredential"); | ||
| String defaultIssuanceDate = java.time.Instant.now().toString(); | ||
| String defaultProofType = "Ed25519Signature2018"; | ||
| String defaultProofPurpose = "assertionMethod"; | ||
|
|
||
| // Credential Preview μμ± | ||
| CredentialPreview preview = | ||
| new CredentialPreview( | ||
| "https://didcomm.org/issue-credential/2.0/credential-preview", | ||
| List.of( | ||
| new CredentialPreview.Attribute("hospital_tenant", hospitalTenant), | ||
| new CredentialPreview.Attribute("area_code", areaCode))); | ||
|
|
||
| // Credential Subject μμ± | ||
| CredentialSubject credentialSubject = | ||
| new CredentialSubject(credentialSubjectId, hospitalTenant, areaCode); | ||
|
|
||
| // LD Proof Filter μμ± | ||
| LdProofFilter ldProofFilter = | ||
| new LdProofFilter( | ||
| new Credential( | ||
| defaultContext, | ||
| defaultType, | ||
| issuer, | ||
| defaultIssuanceDate, | ||
| credentialSubject), | ||
| new Options(defaultProofType, defaultProofPurpose)); | ||
|
|
||
| // Filter μμ± (LD Proofλ§ μ¬μ©) | ||
| Filter filter = new Filter(ldProofFilter); | ||
|
|
||
| return new HospitalVcIssueRequest( | ||
| connectionId, | ||
| preview, | ||
| filter, | ||
| true, // auto_issue | ||
| false // auto_remove | ||
| ); | ||
| } | ||
|
|
||
| // κ°λ¨ν λ²μ (κΈ°λ³Έκ° μ¬μ©) | ||
| public static HospitalVcIssueRequest createWithDid( | ||
| String connectionId, String issuer, String credentialSubjectId) { | ||
|
|
||
| return createLdProofCredential( | ||
| connectionId, | ||
| issuer, | ||
| credentialSubjectId, | ||
| "default_hospital", // κΈ°λ³Έ λ³μ ν λνΈ | ||
| "default_area" // κΈ°λ³Έ μ§μ μ½λ | ||
| ); | ||
| } | ||
| } |
32 changes: 32 additions & 0 deletions
32
src/main/java/com/doubleo/didagent/dto/request/mediator/MediatorInvitationCreateRequest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| package com.doubleo.didagent.dto.request.mediator; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonProperty; | ||
| import java.time.LocalDateTime; | ||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
|
|
||
| public record MediatorInvitationCreateRequest( | ||
| @JsonProperty("alias") String alias, | ||
| @JsonProperty("handshake_protocols") List<String> handshakeProtocols, | ||
| @JsonProperty("goal_code") String goalCode, | ||
| @JsonProperty("my_label") String myLabel, | ||
| @JsonProperty("accept") List<String> accept, | ||
| @JsonProperty("use_did_method") String useDidMethod, | ||
| @JsonProperty("multi_use") boolean multiUse) { | ||
| public static MediatorInvitationCreateRequest generate() { | ||
| List<String> handshakeProtocols = new ArrayList<>(); | ||
| List<String> accept = new ArrayList<>(); | ||
|
|
||
| handshakeProtocols.add("https://didcomm.org/didexchange/1.0"); | ||
| accept.add("didcomm/aip2;env=rfc19"); | ||
|
|
||
| return new MediatorInvitationCreateRequest( | ||
| "mediator:invitation:" + LocalDateTime.now(), | ||
| handshakeProtocols, | ||
| "vc-issue", | ||
| "keywe_mediator", | ||
| accept, | ||
| "did:peer:2", | ||
| true); | ||
| } | ||
| } |
10 changes: 0 additions & 10 deletions
10
src/main/java/com/doubleo/didagent/dto/response/DidCreateResponse.java
This file was deleted.
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
src/main/java/com/doubleo/didagent/dto/response/hospital/HospitalConnectionInfoResponse.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| package com.doubleo.didagent.dto.response.hospital; | ||
|
|
||
| public record HospitalConnectionInfoResponse() {} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.