Skip to content

Commit

Permalink
Merge pull request #27 from sktston/feature/add-self-attested-demo
Browse files Browse the repository at this point in the history
Add holder code
  • Loading branch information
baegjae authored May 4, 2023
2 parents f41fdc1 + 76be33e commit a542dc2
Showing 1 changed file with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
import com.jayway.jsonpath.JsonPath;
import com.jayway.jsonpath.PathNotFoundException;
import com.sktelecom.initial.controller.utils.Common;
import com.sktelecom.initial.controller.utils.HttpClient;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -180,6 +181,9 @@ static void runIssueProcess() {
log.info("Print agreement");
printAgreement(presExId);

log.info("Print self attested attributes");
printSelfAttestedAttrs(presExId);

log.info("Send presentation");
sendPresentation(presExId);
waitUntilPresentationExchangeState(presExId, "presentation_acked");
Expand Down Expand Up @@ -237,6 +241,9 @@ static void runVerifyProcess() {
log.info("Print agreement");
printAgreement(presExId);

log.info("Print self attested attributes");
printSelfAttestedAttrs(presExId);

log.info("Send presentation");
sendPresentation(presExId);
waitUntilPresentationExchangeState(presExId, "presentation_acked");
Expand Down Expand Up @@ -380,8 +387,20 @@ static void printAgreement(String presExId) {
String response = client.requestGET(agentDataStoreUrl + "/present-proof/records/" + presExId, accessToken);
log.debug("response: " + response);
String comment = JsonPath.read(response, "$.presentation_request_dict.comment");
String agreement = JsonPath.parse((LinkedHashMap)JsonPath.read(comment, "$.agreement")).jsonString();
log.info("agreement: " + agreement);
try {
String agreement = JsonPath.parse((LinkedHashMap) JsonPath.read(comment, "$.agreement")).jsonString();
log.info("agreement: " + agreement);
} catch (PathNotFoundException ignored){}
}

static void printSelfAttestedAttrs(String presExId) {
String response = client.requestGET(agentDataStoreUrl + "/present-proof/records/" + presExId, accessToken);
log.debug("response: " + response);
String comment = JsonPath.read(response, "$.presentation_request_dict.comment");
try {
String selfAttestedAttrs = JsonPath.parse((ArrayList) JsonPath.read(comment, "$.self_attested_attrs")).jsonString();
log.info("self attested attributes: " + selfAttestedAttrs);
} catch (PathNotFoundException ignored){}
}

static void deleteCredential(String credId) {
Expand Down

0 comments on commit a542dc2

Please sign in to comment.