-
Notifications
You must be signed in to change notification settings - Fork 0
[KW-659] Kw 659/feat/invitation polling #8
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 all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
e535c3d
KW-659/feat: Mediator, Hospital WebClient ๊ตฌํ
willjsw 82a623e
KW-659/feat: redis ์์กด์ฑ ์ถ๊ฐ
willjsw f5df495
KW-659/feat: grpc pass-interface & acapy-interface v0.3.3 ์ ์ฉ
willjsw 4a6c4af
KW-659/feat: webflux yml config ์ถ๊ฐ
willjsw 0c484bf
KW-659/feat: redis property ์ถ๊ฐ
willjsw 05fd3ff
KW-659/feat: acapy errorcode ์ถ๊ฐ
willjsw a96abbe
KW-659/feat: hospital invitation req/res, mediator res dto ๊ตฌํ
willjsw 28436de
KW-659/feat: MemberConnection redis ๋๋ฉ์ธ ์ค๊ณ ๋ฐ MVC ๊ตฌํ
willjsw fd56b30
KW-659/feat: connectionStatus ๊ตฌํ
willjsw e1873da
KW-659/feat: HospitalInvitation redis ๋๋ฉ์ธ ๊ตฌํ ๋ฐ repository ๊ตฌํ, acapyClโฆ
willjsw eae5f8c
KW-659/refactor: did ์์ฑ ์๋น์ค ๋ก์ง ๋๋ ํ ๋ฆฌ ์์ /์์กด์ฑ ์์
willjsw 6557ac4
KW-659/feat: grpc interface ๋ชจ๋ ์ถ๊ฐ(server: acapy, client: tenant, pass)
willjsw 8e074c3
KW-659/refactor: test์ฉ ํ๋์ฝ๋ฉ๋ tenantId -> tenantClient์์ ์ง์ ํธ์ถ ๋ฐ ๋ณํ
willjsw 262994c
KW-659/refactor: config & build.gradle ๋ฐฐํฌ ํ๊ฒฝ ์ค์ ์ผ๋ก ๋ณ๊ฒฝ
willjsw 332f715
KW-659/refactor:๋ฏธ์ฌ์ฉ datasource ํ๋กํ ์ ๊ฑฐ
willjsw cf1436d
KW-659/fix: invitation/did ์์ฑ ์ค๋ฅ 400 -> 500 ์๋ฌ๋ก ์์
willjsw a0f7110
KW-659/fix: ์คํ ์์
willjsw f16e35a
KW-659/refactor: gRPC Clients try-catch ์ฒ๋ฆฌ
willjsw 6e9ecc4
KW-659/refactor: memberPollController convention ์์
willjsw 41bb1b9
KW-659/fix: INVITATION_REQUEST_FAILED ์๋ฌ ๋ฉ์ธ์ง ์คํ ์์
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
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
This file was deleted.
Oops, something went wrong.
13 changes: 13 additions & 0 deletions
13
src/main/java/com/doubleo/didagent/agent/client/AcapyClient.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,13 @@ | ||
| package com.doubleo.didagent.agent.client; | ||
|
|
||
| import lombok.Getter; | ||
| import org.springframework.web.reactive.function.client.WebClient; | ||
|
|
||
| @Getter | ||
| public class AcapyClient { | ||
| private final WebClient webClient; | ||
|
|
||
| public AcapyClient(WebClient webClient) { | ||
| this.webClient = webClient; | ||
| } | ||
| } |
27 changes: 27 additions & 0 deletions
27
src/main/java/com/doubleo/didagent/agent/client/AcapyClientConfig.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,27 @@ | ||
| package com.doubleo.didagent.agent.client; | ||
|
|
||
| import com.doubleo.didagent.infra.config.hospital.HospitalProperties; | ||
| import com.doubleo.didagent.infra.config.mediator.MediatorProperties; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.context.annotation.Bean; | ||
| import org.springframework.context.annotation.Configuration; | ||
| import org.springframework.web.reactive.function.client.WebClient; | ||
|
|
||
| @Configuration | ||
| @RequiredArgsConstructor | ||
| public class AcapyClientConfig { | ||
| private final MediatorProperties mediatorProperties; | ||
| private final HospitalProperties hospitalProperties; | ||
|
|
||
| @Bean("mediatorClient") | ||
| public AcapyClient mediatorClient(WebClient.Builder builder) { | ||
| WebClient wc = builder.baseUrl(mediatorProperties.adminUrl()).build(); | ||
| return new AcapyClient(wc); | ||
| } | ||
|
|
||
| @Bean("hospitalClient") | ||
| public AcapyClient hospitalClient(WebClient.Builder builder) { | ||
| WebClient wc = builder.baseUrl(hospitalProperties.adminUrl()).build(); | ||
| return new AcapyClient(wc); | ||
| } | ||
| } |
27 changes: 27 additions & 0 deletions
27
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| package com.doubleo.didagent.controller; | ||
|
|
||
| import jakarta.servlet.http.HttpServletRequest; | ||
| import java.util.Map; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.springframework.http.HttpStatus; | ||
| import org.springframework.web.bind.annotation.*; | ||
|
|
||
| @RestController | ||
| @RequestMapping("/webhooks") | ||
| @Slf4j | ||
| public class AcapyWebhookController { | ||
|
|
||
| @PostMapping("/**") | ||
| @ResponseStatus(HttpStatus.OK) | ||
| public void receiveAnyWebhook( | ||
| HttpServletRequest req, | ||
| @RequestBody Map<String, Object> payload, | ||
| @RequestHeader Map<String, String> headers) { | ||
| String path = req.getRequestURI(); | ||
| log.info("=== Webhook Path: {} ===", path); | ||
| log.info("--- Headers ---"); | ||
| headers.forEach((k, v) -> log.info("{}: {}", k, v)); | ||
| log.info("--- Payload ---"); | ||
| log.info("{}", payload); | ||
| } | ||
| } |
4 changes: 2 additions & 2 deletions
4
src/main/java/com/doubleo/didagent/controller/DidController.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
28 changes: 28 additions & 0 deletions
28
src/main/java/com/doubleo/didagent/controller/MemberPollController.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,28 @@ | ||
| package com.doubleo.didagent.controller; | ||
|
|
||
| import com.doubleo.didagent.dto.request.poll.HospitalInvitationInfoRequest; | ||
| import com.doubleo.didagent.dto.response.poll.InvitationInfoResponse; | ||
| import com.doubleo.didagent.service.MemberPollService; | ||
| import lombok.RequiredArgsConstructor; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.springframework.web.bind.annotation.*; | ||
|
|
||
| @RestController | ||
| @RequestMapping("/polls") | ||
| @RequiredArgsConstructor | ||
| @Slf4j | ||
| public class MemberPollController { | ||
|
|
||
| private final MemberPollService memberPollService; | ||
|
|
||
| @GetMapping("/mediator-invitation") | ||
| public InvitationInfoResponse mediatorInvitationInfoGet() { | ||
| return memberPollService.getMediatorInvitation(); | ||
| } | ||
|
|
||
| @PostMapping("/hospital-invitation") | ||
| public InvitationInfoResponse hospitalInvitationInfoGet( | ||
| @RequestBody HospitalInvitationInfoRequest request) { | ||
| return memberPollService.getHospitalInvitation(request); | ||
| } | ||
| } |
28 changes: 28 additions & 0 deletions
28
src/main/java/com/doubleo/didagent/domain/domain/ConnectionStatus.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,28 @@ | ||
| package com.doubleo.didagent.domain.domain; | ||
|
|
||
| public enum ConnectionStatus { | ||
| VC_OFFERED("vc_offered"), | ||
| VC_ISSUED("vc_issued"), | ||
| ACTIVE("active"), | ||
| INACTIVE("inactive"), | ||
| ERROR("error"); | ||
|
|
||
| private final String value; | ||
|
|
||
| ConnectionStatus(String value) { | ||
| this.value = value; | ||
| } | ||
|
|
||
| public String getValue() { | ||
| return value; | ||
| } | ||
|
|
||
| public static ConnectionStatus fromValue(String value) { | ||
| for (ConnectionStatus status : ConnectionStatus.values()) { | ||
| if (status.value.equalsIgnoreCase(value)) { | ||
| return status; | ||
| } | ||
| } | ||
| throw new IllegalArgumentException("Unknown ConnectionStatus: " + value); | ||
| } | ||
| } |
54 changes: 54 additions & 0 deletions
54
src/main/java/com/doubleo/didagent/domain/domain/HospitalInvitation.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,54 @@ | ||
| package com.doubleo.didagent.domain.domain; | ||
|
|
||
| import lombok.AccessLevel; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
| import org.springframework.data.annotation.Id; | ||
| import org.springframework.data.redis.core.RedisHash; | ||
| import org.springframework.data.redis.core.TimeToLive; | ||
| import org.springframework.data.redis.core.index.Indexed; | ||
|
|
||
| @Getter | ||
| @RedisHash("hospital-invitation") | ||
| public class HospitalInvitation { | ||
|
|
||
| @Id private final String invitationId; | ||
| private final String invitationUrl; | ||
| private final String memberId; | ||
| @Indexed private final String passId; | ||
| @Indexed private final String tenantId; | ||
|
|
||
| @TimeToLive private final long ttl; | ||
|
|
||
| @Builder(access = AccessLevel.PRIVATE) | ||
| private HospitalInvitation( | ||
| String invitationId, | ||
| String invitationUrl, | ||
| String tenantId, | ||
| String passId, | ||
| String memberId, | ||
| long ttl) { | ||
| this.invitationId = invitationId; | ||
| this.invitationUrl = invitationUrl; | ||
| this.tenantId = tenantId; | ||
| this.passId = passId; | ||
| this.memberId = memberId; | ||
| this.ttl = ttl; | ||
| } | ||
|
|
||
| public static HospitalInvitation createHospitalInvitation( | ||
| String invitationId, | ||
| String invitationUrl, | ||
| String tenantId, | ||
| String passId, | ||
| String memberId) { | ||
| return builder() | ||
| .invitationId(invitationId) | ||
| .invitationUrl(invitationUrl) | ||
| .tenantId(tenantId) | ||
| .passId(passId) | ||
| .memberId(memberId) | ||
| .ttl(1000L * 3600 * 24 * 3) | ||
| .build(); | ||
| } | ||
| } |
61 changes: 61 additions & 0 deletions
61
src/main/java/com/doubleo/didagent/domain/domain/MemberConnection.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,61 @@ | ||
| package com.doubleo.didagent.domain.domain; | ||
|
|
||
| import lombok.AccessLevel; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
| import org.springframework.data.annotation.Id; | ||
| import org.springframework.data.redis.core.RedisHash; | ||
| import org.springframework.data.redis.core.TimeToLive; | ||
| import org.springframework.data.redis.core.index.Indexed; | ||
|
|
||
| @Getter | ||
| @RedisHash("connection") | ||
| public class MemberConnection { | ||
|
|
||
| @Id private final String connectionId; | ||
| private final String tenantId; | ||
| @Indexed private final String passId; | ||
| private final String memberId; | ||
| private final ConnectionStatus connectionStatus; | ||
|
|
||
| @TimeToLive private final long ttl; | ||
|
|
||
| @Builder(access = AccessLevel.PRIVATE) | ||
| private MemberConnection( | ||
| String tenantId, | ||
| String passId, | ||
| String memberId, | ||
| String connectionId, | ||
| ConnectionStatus connectionStatus, | ||
| long ttl) { | ||
| this.connectionId = connectionId; | ||
| this.tenantId = tenantId; | ||
| this.passId = passId; | ||
| this.memberId = memberId; | ||
| this.connectionStatus = connectionStatus; | ||
| this.ttl = ttl; | ||
| } | ||
|
|
||
| public static MemberConnection createMemberConnection( | ||
| String connectionId, String tenantId, String passId, String memberId) { | ||
| return builder() | ||
| .connectionId(connectionId) | ||
| .tenantId(tenantId) | ||
| .passId(passId) | ||
| .memberId(memberId) | ||
| .connectionStatus(ConnectionStatus.ACTIVE) | ||
| .ttl(1000L * 3600 * 24 * 3) | ||
| .build(); | ||
| } | ||
|
|
||
| public MemberConnection updateConnectionStatus(ConnectionStatus newStatus) { | ||
| return builder() | ||
| .connectionId(this.connectionId) | ||
| .tenantId(this.tenantId) | ||
| .passId(this.passId) | ||
| .memberId(this.memberId) | ||
| .connectionStatus(newStatus) | ||
| .ttl(this.ttl) | ||
| .build(); | ||
| } | ||
| } |
15 changes: 15 additions & 0 deletions
15
src/main/java/com/doubleo/didagent/domain/repository/HospitalInvitationRepository.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,15 @@ | ||
| package com.doubleo.didagent.domain.repository; | ||
|
|
||
| import com.doubleo.didagent.domain.domain.HospitalInvitation; | ||
| import java.util.Optional; | ||
| import org.springframework.data.repository.CrudRepository; | ||
|
|
||
| public interface HospitalInvitationRepository extends CrudRepository<HospitalInvitation, String> { | ||
|
|
||
| Optional<HospitalInvitation> findByInvitationId(String invitationId); | ||
|
|
||
| Optional<HospitalInvitation> findHospitalInvitationByPassIdAndTenantId( | ||
| String passId, String tenantId); | ||
|
|
||
| void deleteHospitalInvitationByInvitationId(String invitationId); | ||
| } | ||
9 changes: 9 additions & 0 deletions
9
src/main/java/com/doubleo/didagent/domain/repository/MemberConnectionRepository.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,9 @@ | ||
| package com.doubleo.didagent.domain.repository; | ||
|
|
||
| import com.doubleo.didagent.domain.domain.MemberConnection; | ||
| import java.util.Optional; | ||
| import org.springframework.data.repository.CrudRepository; | ||
|
|
||
| public interface MemberConnectionRepository extends CrudRepository<MemberConnection, String> { | ||
| Optional<MemberConnection> findMemberConnectionByConnectionId(String connectionId); | ||
| } |
8 changes: 8 additions & 0 deletions
8
src/main/java/com/doubleo/didagent/dto/request/did/DidCreateRequest.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,8 @@ | ||
| package com.doubleo.didagent.dto.request.did; | ||
|
|
||
| import jakarta.validation.constraints.NotBlank; | ||
| import jakarta.validation.constraints.NotNull; | ||
| import java.util.List; | ||
|
|
||
| public record DidCreateRequest( | ||
| @NotNull List<String> routingKeys, @NotBlank String serviceEndpoint) {} |
32 changes: 32 additions & 0 deletions
32
src/main/java/com/doubleo/didagent/dto/request/hospital/HospitalInvitationCreateRequest.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.hospital; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonProperty; | ||
| import java.time.LocalDateTime; | ||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
|
|
||
| public record HospitalInvitationCreateRequest( | ||
| @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 HospitalInvitationCreateRequest create(String tenantId) { | ||
| 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 HospitalInvitationCreateRequest( | ||
| tenantId + ":" + LocalDateTime.now(), | ||
| handshakeProtocols, | ||
| "vc-issue", | ||
| tenantId, | ||
| accept, | ||
| "did:peer:2", | ||
| true); | ||
| } | ||
| } |
5 changes: 5 additions & 0 deletions
5
src/main/java/com/doubleo/didagent/dto/request/poll/HospitalInvitationInfoRequest.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,5 @@ | ||
| package com.doubleo.didagent.dto.request.poll; | ||
|
|
||
| import jakarta.validation.constraints.NotNull; | ||
|
|
||
| public record HospitalInvitationInfoRequest(@NotNull Long passId, @NotNull Long hospitalId) {} |
10 changes: 10 additions & 0 deletions
10
src/main/java/com/doubleo/didagent/dto/response/did/DidCreateResponse.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.response.did; | ||
|
|
||
| import jakarta.validation.constraints.NotBlank; | ||
|
|
||
| public record DidCreateResponse( | ||
| @NotBlank String peerDid2, | ||
| @NotBlank String signingKeyMb58, | ||
| @NotBlank String signingPrivBase58, | ||
| @NotBlank String agreementKeyMb58, | ||
| @NotBlank String x25519PrivateMb58) {} |
5 changes: 5 additions & 0 deletions
5
src/main/java/com/doubleo/didagent/dto/response/poll/InvitationInfoResponse.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,5 @@ | ||
| package com.doubleo.didagent.dto.response.poll; | ||
|
|
||
| import jakarta.validation.constraints.NotBlank; | ||
|
|
||
| public record InvitationInfoResponse(@NotBlank String invitationUrl) {} |
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.