Skip to content

Commit

Permalink
chore: Updated issuance of schema and VC to Cord v3 specifications
Browse files Browse the repository at this point in the history
Signed-off-by: vikastc <[email protected]>
  • Loading branch information
Vikastc committed Mar 22, 2024
1 parent 356b74e commit 782993d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ public class RegistryHelper {
@Value("${invite.signature_enabled}") boolean skipSignatureForInvite = true;

@Value("${registry.cord.issuer_schema_url}") String issuer_schema_url;
@Value("${registry.cord.issuer_registry_url}") String issuer_registry_url;
@Value("${registry.cord.issuer_credential_url}") String issuer_credential_url;


Expand Down Expand Up @@ -239,11 +238,6 @@ public JsonNode anchorSchemaAPI(JsonNode obj) throws Exception{
JsonNode schema=apiHelper(obj,issuer_schema_url);
return schema;
}
/** Anchors registry to the CORD NETWORK ,*/
public JsonNode anchorRegistryAPI(JsonNode obj) throws Exception{
JsonNode registryDetails=apiHelper(obj,issuer_registry_url);
return registryDetails;
}

/** Helper function for Anchoring to CORD */
public JsonNode anchorToCord(JsonNode rootNode) throws Exception{
Expand All @@ -269,16 +263,7 @@ public JsonNode anchorToCord(JsonNode rootNode) throws Exception{

JsonNode anchoredSchema=anchorSchemaAPI(schemaToBeAnchored);
logger.info("ANCHORED SCHEMA TO CORD CHAIN {}",anchoredSchema);
/* Anchoring registry to CORD */
JsonNode registrySchema=objectMapper.createObjectNode()
.put("title",convertedSchema.get("title").asText())
.put("description",convertedSchema.get("description").asText())
.put("schemaId",anchoredSchema.get("schemaId").asText());

JsonNode registryId=anchorRegistryAPI(registrySchema);
logger.info("REGISTRY ID GENERATED ON CORD {} ",registryId);

((ObjectNode)rootNode).set("cord_registry_id", registryId.get("registryId"));
((ObjectNode)rootNode).set("cord_schema_id", anchoredSchema.get("schemaId"));

return rootNode;
Expand All @@ -289,7 +274,7 @@ public JsonNode anchorToCord(JsonNode rootNode) throws Exception{

}
/* Anchor documents to the CORD chain
* The below function first calls the search schema endpoint to get the registry_id & schema_id
* The below function first calls the search schema endpoint to get the schema_id
* to create a proper json structure for issuer agent credentials api
*
* Schema for the search API
Expand All @@ -306,9 +291,7 @@ public JsonNode anchorToCord(JsonNode rootNode) throws Exception{
* Schema accepted by ISSUER AGENT Credentials api
* {
* "schemaId":"",
* "registryId":"",
* "holderDid":"",
* "property":{
* "properties":{
* "":""
* }
* }
Expand All @@ -332,23 +315,21 @@ public void anchorCredentialsToCord(String schemaName,JsonNode credentials) thro

JsonNode schemaArray=getDetails.get("Schema");
JsonNode firstSchema = schemaArray.get(0);
appendCredentialsToCord(firstSchema.get("cord_schema_id").asText(),firstSchema.get("cord_registry_id").asText(), credentials);
appendCredentialsToCord(firstSchema.get("cord_schema_id").asText(), credentials);

} catch (Exception e) {
logger.error("EXCEPTION OCCURRED",e);
}
}
// The holderDid is hardcoded for now.
private void appendCredentialsToCord(String schemaId,String registryId,JsonNode document){

private void appendCredentialsToCord(String schemaId,JsonNode document){
try {
ObjectNode documentObject = (ObjectNode) document;
if(documentObject.has("osid")) documentObject.remove("osid");
if(documentObject.has("osOwner")) documentObject.remove("osOwner");
JsonNode rootNode=new ObjectMapper().createObjectNode()
.put("schemaId",schemaId)
.put("registryId",registryId)
.put("holderDid","did:cord:3yxVe6KTeexjYkK43q1SZxthbBVhnBdxwh1SYLTxzWxPobSS")
.set("property",documentObject);
.set("properties",documentObject);

JsonNode anchorVC=apiHelper(rootNode,issuer_credential_url);
} catch (Exception e) {
Expand Down
5 changes: 2 additions & 3 deletions java/registry/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,8 @@ registry:
port: ${redis_port:6379}
cord:
anchor_to_cord: ${anchor_to_cord:true}
issuer_schema_url: ${issuer_schema_url:http://172.24.0.1:5106/api/v1/schema}
issuer_registry_url : ${issuer_registry_url:http://172.24.0.1:5106/api/v1/registry}
issuer_credential_url: ${issuer_credential_url:http://172.24.0.1:5106/api/v1/cred}
issuer_schema_url: ${issuer_schema_url:http://172.17.0.1:5106/api/v1/schema}
issuer_credential_url: ${issuer_credential_url:http://172.17.0.1:5106/api/v1/cred}

workflow:
enabled: ${workflow.enable:true}
Expand Down

0 comments on commit 782993d

Please sign in to comment.