diff --git a/docker-compose-v1.yml b/docker-compose-v1.yml index 4e5fa1520..ebb506ff9 100644 --- a/docker-compose-v1.yml +++ b/docker-compose-v1.yml @@ -75,23 +75,8 @@ services: - sunbird_sso_admin_client_secret=${KEYCLOAK_SECRET} - claims_enabled=${CLAIMS_ENABLED-false} - claims_url=http://claim-ms:8082 - - did_enabled=${DID_ENABLED-false} - - did_health_check_url=${DID_HEALTH_CHECK_URL-http://identity:3332/health} - - did_generate_url=${DID_GENERATE_URL-http://identity:3332/did/generate} - - did_resolve_url=${DID_RESOLVE_URL-http://identity:3332/did/resolve} - signature_enabled=${SIGNATURE_ENABLED-false} - signature_provider=${SIGNATURE_PROVIDER-dev.sunbirdrc.registry.service.impl.SignatureV1ServiceImpl} - - signature_v2_health_check_url=${SIGNATURE_V2_HEALTH_CHECK_URL-http://credential:3000/health} - - signature_v2_issue_url=${SIGNATURE_V2_ISSUE_URL-http://credential:3000/credentials/issue} - - signature_v2_get_url=${SIGNATURE_V2_GET_URL-http://credential:3000/credentials/{id}} - - signature_v2_delete_url=${SIGNATURE_V2_DELETE_URL-http://credential:3000/credentials/{id}} - - signature_v2_verify_url=${SIGNATURE_V2_VERIFY_URL-http://credential:3000/credentials/{id}/verify} - - signature_v2_revocation_list_url=${SIGNATURE_V2_REVOCATION_LIST_URL-http://credential:3000/credentials/revocation-list?issuerId={issuerDid}&page={page}&limit={limit}} - - signature_v2_schema_health_check_url=${SIGNATURE_V2_SCHEMA_HEALTH_CHECK_URL-http://schema:3333/health} - - signature_v2_schema_create_url=${SIGNATURE_V2_SCHEMA_CREATE_URL-http://schema:3333/credential-schema} - - signature_v2_schema_update_url=${SIGNATURE_V2_SCHEMA_UPDATE_URL-http://schema:3333/credential-schema/{id}/{version}} - - signature_v2_schema_get_by_id_and_version_url=${SIGNATURE_V2_SCHEMA_GET_BY_ID_AND_VERSION_URL-http://schema:3333/credential-schema/{id}/{version} - - signature_v2_schema_search_by_tags_url=${SIGNATURE_V2_SCHEMA_GET_BY_TAGS_URL-http://schema:3333/credential-schema?tags={tags}} - sign_url=http://certificate-signer:8079/sign - verify_url=http://certificate-signer:8079/verify - sign_health_check_url=http://certificate-signer:8079/health diff --git a/docker-compose.yml b/docker-compose.yml index 9d55a2e13..96e593abd 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -76,22 +76,26 @@ services: - claims_enabled=${CLAIMS_ENABLED-false} - claims_url=http://claim-ms:8082 - did_enabled=${DID_ENABLED-false} - - did_health_check_url=${DID_HEALTH_CHECK_URL-http://identity:3332/health} - - did_generate_url=${DID_GENERATE_URL-http://identity:3332/did/generate} - - did_resolve_url=${DID_RESOLVE_URL-http://identity:3332/did/resolve} + - did_health_check_url=http://identity:3332/health + - did_generate_url=http://identity:3332/did/generate + - did_resolve_url=http://identity:3332/did/resolve/{id} - signature_enabled=${SIGNATURE_ENABLED-false} - signature_provider=${SIGNATURE_PROVIDER-dev.sunbirdrc.registry.service.impl.SignatureV2ServiceImpl} - - signature_v2_health_check_url=${SIGNATURE_V2_HEALTH_CHECK_URL-http://credential:3000/health} - - signature_v2_issue_url=${SIGNATURE_V2_ISSUE_URL-http://credential:3000/credentials/issue} - - signature_v2_get_url=${SIGNATURE_V2_GET_URL-http://credential:3000/credentials/{id}} - - signature_v2_delete_url=${SIGNATURE_V2_DELETE_URL-http://credential:3000/credentials/{id}} - - signature_v2_verify_url=${SIGNATURE_V2_VERIFY_URL-http://credential:3000/credentials/{id}/verify} - - signature_v2_revocation_list_url=${SIGNATURE_V2_REVOCATION_LIST_URL-http://credential:3000/credentials/revocation-list?issuerId={issuerDid}&page={page}&limit={limit}} - - signature_v2_schema_health_check_url=${SIGNATURE_V2_SCHEMA_HEALTH_CHECK_URL-http://credential-schema:3333/health} - - signature_v2_schema_create_url=${SIGNATURE_V2_SCHEMA_CREATE_URL-http://credential-schema:3333/credential-schema} - - signature_v2_schema_update_url=${SIGNATURE_V2_SCHEMA_UPDATE_URL-http://credential-schema:3333/credential-schema/{id}/{version}} - - signature_v2_schema_get_by_id_and_version_url=${SIGNATURE_V2_SCHEMA_GET_BY_ID_AND_VERSION_URL-http://credential-schema:3333/credential-schema/{id}/{version} - - signature_v2_schema_search_by_tags_url=${SIGNATURE_V2_SCHEMA_GET_BY_TAGS_URL-http://credential-schema:3333/credential-schema?tags={tags}} + - signature_v2_credential_did_method=rcw + - signature_v2_issuer_did_method=issuer + - signature_v2_schema_author=Registry + - signature_v2_schema_author_did_method=author + - signature_v2_health_check_url=http://credential:3000/health + - signature_v2_issue_url=http://credential:3000/credentials/issue + - signature_v2_get_url=http://credential:3000/credentials/{id} + - signature_v2_delete_url=http://credential:3000/credentials/{id} + - signature_v2_verify_url=http://credential:3000/credentials/{id}/verify + - signature_v2_revocation_list_url=http://credential:3000/credentials/revocation-list?issuerId={issuerDid}&page={page}&limit={limit} + - signature_v2_schema_health_check_url=http://credential-schema:3333/health + - signature_v2_schema_create_url=http://credential-schema:3333/credential-schema + - signature_v2_schema_update_url=http://credential-schema:3333/credential-schema/{id}/{version} + - signature_v2_schema_get_by_id_and_version_url=http://credential-schema:3333/credential-schema/{id}/{version} + - signature_v2_schema_search_by_tags_url=http://credential-schema:3333/credential-schema?tags={tags} - sign_url=http://certificate-signer:8079/sign - verify_url=http://certificate-signer:8079/verify - sign_health_check_url=http://certificate-signer:8079/health diff --git a/java/registry/src/main/java/dev/sunbirdrc/registry/service/CredentialSchemaService.java b/java/registry/src/main/java/dev/sunbirdrc/registry/service/CredentialSchemaService.java index 56ae4edeb..3790b27da 100644 --- a/java/registry/src/main/java/dev/sunbirdrc/registry/service/CredentialSchemaService.java +++ b/java/registry/src/main/java/dev/sunbirdrc/registry/service/CredentialSchemaService.java @@ -46,12 +46,14 @@ public class CredentialSchemaService implements HealthIndicator { private String getByTagsUrl; @Autowired(required = false) - dev.sunbirdrc.registry.service.DIDService DIDService; + private DIDService didService; @Autowired IDefinitionsManager definitionsManager; - private static final String authorName = "Registry"; - private static final String authorDidMethod = "abc"; + @Value("${signature.v2.schema.author}") + private String authorName; + @Value("${signature.v2.schema.authorDidMethod}") + private String authorDidMethod; @Autowired private RetryRestTemplate retryRestTemplate; @@ -111,7 +113,7 @@ public void ensureCredentialSchema(String title, Object credTemplate, String sta logger.debug("Ensuring credential schema for {}", title); JsonNode schema = convertCredentialTemplateToSchema(title, credTemplate); ObjectNode prevSchema = (ObjectNode) getLatestSchemaByTags(Collections.singletonList(title)); - String author = DIDService.ensureDidForName(authorName, authorDidMethod); + String author = didService.ensureDidForName(authorName, authorDidMethod); String authored = Instant.now().toString(); ((ObjectNode) schema).set("author", JsonNodeFactory.instance.textNode(author)); ((ObjectNode) schema).set("authored", JsonNodeFactory.instance.textNode(authored)); diff --git a/java/registry/src/main/java/dev/sunbirdrc/registry/service/DIDService.java b/java/registry/src/main/java/dev/sunbirdrc/registry/service/DIDService.java index 88eea0847..e3c3a4654 100644 --- a/java/registry/src/main/java/dev/sunbirdrc/registry/service/DIDService.java +++ b/java/registry/src/main/java/dev/sunbirdrc/registry/service/DIDService.java @@ -15,6 +15,7 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; @@ -29,6 +30,7 @@ import static dev.sunbirdrc.registry.middleware.util.Constants.*; @Component +@ConditionalOnProperty(value = "did.enabled", havingValue = "true") public class DIDService implements HealthIndicator { private static final Logger logger = LoggerFactory.getLogger(DIDService.class); @Value("${did.healthCheckURL}") @@ -120,7 +122,7 @@ public String generateDid(String method, Map content) { public JsonNode resolveDid(String didId) { try { - ResponseEntity response = retryRestTemplate.getForEntity(resolveIdUrl + "/" + didId); + ResponseEntity response = retryRestTemplate.getForEntity(resolveIdUrl, didId); if (response.getStatusCode().is2xxSuccessful()) { return JSONUtil.convertStringJsonNode(response.getBody()); } diff --git a/java/registry/src/main/java/dev/sunbirdrc/registry/service/impl/SignatureV2ServiceImpl.java b/java/registry/src/main/java/dev/sunbirdrc/registry/service/impl/SignatureV2ServiceImpl.java index bcb251a41..4f3bc6c86 100644 --- a/java/registry/src/main/java/dev/sunbirdrc/registry/service/impl/SignatureV2ServiceImpl.java +++ b/java/registry/src/main/java/dev/sunbirdrc/registry/service/impl/SignatureV2ServiceImpl.java @@ -12,6 +12,7 @@ import dev.sunbirdrc.registry.exception.SignatureException; import dev.sunbirdrc.registry.middleware.util.JSONUtil; import dev.sunbirdrc.registry.service.CredentialSchemaService; +import dev.sunbirdrc.registry.service.DIDService; import dev.sunbirdrc.registry.service.ICertificateService; import dev.sunbirdrc.registry.service.SignatureService; import org.apache.commons.lang3.exception.ExceptionUtils; @@ -56,8 +57,10 @@ public class SignatureV2ServiceImpl implements SignatureService, ICertificateSer @Value("${signature.v2.getRevocationListURL}") private String getRevocationListURL; - private static final String credentialMethod = "rcw"; - private static final String credentialIssuerMethod = "abc"; + @Value("${signature.v2.credentialDidMethod}") + private String credentialMethod; + @Value("${signature.v2.issuerDidMethod}") + private String credentialIssuerMethod; @Autowired protected RetryRestTemplate retryRestTemplate; @@ -66,7 +69,7 @@ public class SignatureV2ServiceImpl implements SignatureService, ICertificateSer @Autowired private CredentialSchemaService credentialSchemaService; @Autowired - private dev.sunbirdrc.registry.service.DIDService DIDService; + private DIDService didService; @Override public Object sign(Map propertyValue) throws SignatureException.UnreachableException, SignatureException.CreationException { @@ -99,7 +102,7 @@ public boolean verify(Object propertyValue) throws SignatureException.Unreachabl @Override public String getKey(String keyId) throws SignatureException.UnreachableException, SignatureException.KeyNotFoundException { - ObjectNode didDocument = (ObjectNode) DIDService.resolveDid(keyId); + ObjectNode didDocument = (ObjectNode) didService.resolveDid(keyId); ArrayNode verificationMethods = (ArrayNode) didDocument.get("verificationMethod"); AtomicReference verificationMethod = new AtomicReference<>(); verificationMethods.elements().forEachRemaining(vm -> { @@ -131,7 +134,7 @@ public Object getCertificate(JsonNode credentialId, String entityName, String en return getCredentialById(credentialId.asText(), mediaType, templateId, template); } - private JsonNode issueCredential(String title, Object credentialTemplate, JsonNode input) throws Exception { + public JsonNode issueCredential(String title, Object credentialTemplate, JsonNode input) throws Exception { // Render the credential using credential template Handlebars hb = new Handlebars(); String templateJsonString = null; @@ -152,7 +155,7 @@ private JsonNode issueCredential(String title, Object credentialTemplate, JsonNo // ensure issuer did - String issuerDid = DIDService.ensureDidForName(credential.get("issuer").asText(), credentialIssuerMethod); + String issuerDid = didService.ensureDidForName(credential.get("issuer").asText(), credentialIssuerMethod); credential.set("issuer", JsonNodeFactory.instance.textNode(issuerDid)); // Wire the create credential request payload diff --git a/java/registry/src/main/resources/application.yml b/java/registry/src/main/resources/application.yml index abf0001f1..c4972a3e2 100644 --- a/java/registry/src/main/resources/application.yml +++ b/java/registry/src/main/resources/application.yml @@ -357,7 +357,7 @@ did: enabled: ${did_enabled:false} healthCheckURL: ${did_health_check_url:http://localhost:3332/health} generateURL: ${did_generate_url:http://localhost:3332/did/generate} - resolveURL: ${did_resolve_url:http://localhost:3332/did/resolve} + resolveURL: ${did_resolve_url:http://localhost:3332/did/resolve/{id}} signature: enabled: ${signature_enabled:false} @@ -369,6 +369,8 @@ signature: keysURL: ${keys_url:http://localhost:8013/keys/} domain: ${domain_url:https://w3id.org/security/v1/} v2: + credentialDidMethod: ${signature_v2_credential_did_method:rcw} + issuerDidMethod: ${signature_v2_issuer_did_method:issuer} healthCheckURL: ${signature_v2_health_check_url:http://localhost:3000/health} issueCredentialURL: ${signature_v2_issue_url:http://localhost:3000/credentials/issue} getCredentialByIdURL: ${signature_v2_get_url:http://localhost:3000/credentials/{id}} @@ -376,6 +378,8 @@ signature: verifyCredentialURL: ${signature_v2_verify_url:http://localhost:3000/credentials/{id}/verify} getRevocationListURL: ${signature_v2_revocation_list_url:http://localhost:3000/credentials/revocation-list?issuerId={issuerDid}&page={page}&limit={limit}} schema: + author: ${signature_v2_schema_author:Registry} + authorDidMethod: ${signature_v2_schema_author_did_method:author} healthCheckURL: ${signature_v2_schema_health_check_url:http://localhost:3333/health} createSchemaURL: ${signature_v2_schema_create_url:http://localhost:3333/credential-schema} updateSchemaURL: ${signature_v2_schema_update_url:http://localhost:3333/credential-schema/{id}/{version}}