Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ public Optional<Object> get(String said) throws IOException, InterruptedExceptio
*
* @param said - SAID of the credential
* @param includeCESR - Optional flag export the credential in CESR format
* @return Optional containing the credential if found, or empty if not found
* @return Optional containing the credential if found, or empty if not found.
* Returns String (raw CESR text) when includeCESR=true,
* or Object (parsed JSON) when includeCESR=false
*/
public Optional<Object> get(String said, boolean includeCESR) throws IOException, InterruptedException, LibsodiumException {
final String path = "/credentials/" + said;
Expand All @@ -75,7 +77,7 @@ public Optional<Object> get(String said, boolean includeCESR) throws IOException
return Optional.empty();
}

return Optional.of(Utils.fromJson(response.body(), Object.class));
return Optional.of(includeCESR ? response.body() : Utils.fromJson(response.body(), Object.class));
}

/**
Expand Down Expand Up @@ -256,4 +258,27 @@ public RevokeCredentialResult revoke(String name, String said, String datetime)

return new RevokeCredentialResult(new Serder(ixn), new Serder(rev), op);
}

/**
* Verify a credential and issuing event
*
* @param acdc ACDC to process and verify
* @param iss Issuing event for ACDC in TEL
* @param atc Optional attachment string to be verified against the credential
* @return Operation containing the verification result
*/
public Operation<?> verify(Serder acdc, Serder iss, String atc) throws IOException, InterruptedException, LibsodiumException {
final String path = "/credentials/verify";
final String method = "POST";

Map<String, Object> body = new LinkedHashMap<>();
body.put("acdc", acdc.getKed());
body.put("iss", iss.getKed());
if (atc != null && !atc.isEmpty()) {
body.put("atc", atc);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This atc is for iss only? Maybe we can update it to pass both atcs and update KERIA. It'll be more flexible in the future

}

HttpResponse<String> response = this.client.fetch(path, method, body);
return Operation.fromObject(Utils.fromJson(response.body(), Map.class));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.cardanofoundation.signify.app.clienting.SignifyClient;
import org.cardanofoundation.signify.app.coring.Coring;
import org.cardanofoundation.signify.app.coring.Operation;
import org.cardanofoundation.signify.app.habery.TraitCodex;
import org.cardanofoundation.signify.cesr.Keeping;
import org.cardanofoundation.signify.cesr.Serder;
Expand Down Expand Up @@ -165,4 +166,28 @@ public Object rename(String name, String registryName, String newName) throws IO
HttpResponse<String> response = this.client.fetch(path, method, data);
return Utils.fromJson(response.body(), Object.class);
}

/**
* Verify a registry with optional attachment
*
* @param vcp the VCP (Verifiable Credential Protocol) data to verify
* @param atc the optional attachment data (metadata)
* @return Operation containing the verification result
* @throws IOException if an I/O error occurs
* @throws InterruptedException if the operation is interrupted
* @throws LibsodiumException if a sodium exception occurs
*/
public Operation<?> verify(Serder vcp, String atc) throws IOException, InterruptedException, LibsodiumException {
final String path = "/registries/verify";
final String method = "POST";

Map<String, Object> body = new LinkedHashMap<>();
body.put("vcp", vcp.getKed());
if (atc != null && !atc.isEmpty()) {
body.put("atc", atc);
}

HttpResponse<String> response = this.client.fetch(path, method, body);
return Operation.fromObject(Utils.fromJson(response.body(), Map.class));
}
}
Loading
Loading