Skip to content

Commit

Permalink
[INJICERT-434] add mandatory issuer property for DataProvider VC
Browse files Browse the repository at this point in the history
Signed-off-by: Harsh Vardhan <[email protected]>
  • Loading branch information
vharsh committed Oct 17, 2024
1 parent 0eed1ce commit a2f50b8
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,12 @@ public class CertifyIssuanceServiceImpl implements VCIssuanceService {
@Autowired
private DataProviderPlugin dataModelService;

@Value("${mosip.certify.pub.key}")
@Value("${mosip.certify.issuer.pub.key}")
private String hostedKey;

@Value("${mosip.certify.issuer.uri}")
private String issuerURI;

@Autowired
private ProofValidatorFactory proofValidatorFactory;

Expand Down Expand Up @@ -150,6 +153,7 @@ private VCResult<?> getVerifiableCredential(CredentialRequest credentialRequest,
Map<String, Object> identityData = dataModelService.fetchData(parsedAccessToken.getClaims());
Map<String, Object> templateParams = new HashMap<>();
templateParams.put("templateName", CredentialUtils.getTemplateName(vcRequestDto));
templateParams.put("issuerURI", issuerURI);
String templatedVC = vcFormatter.format(identityData, templateParams);
Map<String, String> vcSignerParams = new HashMap<>();
// TODO: Collate this into simpler APIs where just key-type is specified
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public void initialize() {
public String format(Map<String, Object> templateInput, Map<String, Object> defaultSettings) {
// TODO: Isn't template name becoming too complex with VC_CONTEXTS & CREDENTIAL_TYPES both?
String templateName = defaultSettings.get("templateName").toString();
String issuer = defaultSettings.get("issuerURI").toString();
String t = templateCache.get(templateName);
StringWriter writer = new StringWriter();
// 1. Prepare map
Expand All @@ -79,6 +80,8 @@ public String format(Map<String, Object> templateInput, Map<String, Object> defa
finalTemplate.put(key, value);
}
}
// add the issuer value
finalTemplate.put("issuer", issuer);
if (shouldHaveDates && !(templateInput.containsKey(VCDM2Constants.VALID_FROM)
&& templateInput.containsKey(VCDM2Constants.VALID_UNITL))) {
templateInput.put("_dateTool", new DateTool());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ mosip.certify.domain.url=http://localhost:8090
mosipbox.public.url=https://localhost:8090
mosip.certify.authorization.url=http://localhost:8088
mosip.certify.discovery.issuer-id=${mosip.certify.domain.url}${server.servlet.path}
mosip.certify.pub.key=https://vharsh.github.io/DID/mock-rsa.json

mosip.certify.issuer=CertifyIssuer

##--------------change this later---------------------------------
Expand Down Expand Up @@ -208,6 +208,10 @@ mosip.certify.mock.authenticator.get-identity-url=http://localhost:8082/v1/mock-
mosip.certify.mock.vciplugin.issuer.key-cert="dummy-issuer-cert"
mosip.certify.mock.vciplugin.ca.key-cert="dummy-ca-cert"

# details of VC issuer's public key & controller for DataProvider plugin
mosip.certify.issuer.pub.key=https://vharsh.github.io/DID/mock-rsa.json
mosip.certify.issuer.uri=https://vharsh.github.io/DID/mock-rsac.json

## ---------------------------------------- Cache configuration --------------------------------------------------------

mosip.certify.cache.secure.individual-id=true
Expand All @@ -220,7 +224,6 @@ spring.data.redis.host=localhost
spring.data.redis.port=6379
#spring.data.redis.password=eYVX7EwVmmxKPCDmwMtyKVge8oLd2t81

spring.cache.type=simple
mosip.certify.cache.names=userinfo,vcissuance
spring.cache.cache-names=${mosip.certify.cache.names}
management.health.redis.enabled=false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public void testTemplating() {
assert t != null;
Map<String, Object> ret = new HashMap<>();
ret.put("vcVer", "VC-V1");
ret.put("issuer", "https://example.com/fake-issuer");
// ret.put("issuer", "https://example.com/fake-issuer");
ret.put("fullName", "Amit Developer");
ret.put("validFrom", "01/01/2022");
ret.put("validUntil", "02/02/2122");
Expand All @@ -134,7 +134,8 @@ public void testTemplating() {
ret.put("region", "FakeRegion");
ret.put("postalCode", "123");
ret.put("face", "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAIAQMAAAD+wSzIAAAABlBMVEX///+/v7+jQ3Y5AAAADklEQVQI12P4AIX8EAgALgAD/aNpbtEAAAAASUVORK5CYII");
Map<String, Object> templateMap = Map.of("templateName", "MockVerifiableCredential,VerifiableCredential:https://example.org/Person.json,https://www.w3.org/ns/credentials/v2");
Map<String, Object> templateMap = Map.of("templateName", "MockVerifiableCredential,VerifiableCredential:https://example.org/Person.json,https://www.w3.org/ns/credentials/v2",
"issuerURI", "https://example.com/fake-issuer");
String actualJSON = formatter.format(ret, templateMap);
String expectedJSON = """
{"credentialSubject":{"face":"data:image\\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAIAQMAAAD+wSzIAAAABlBMVEX\\/\\/\\/+\\/v7+jQ3Y5AAAADklEQVQI12P4AIX8EAgALgAD\\/aNpbtEAAAAASUVORK5CYII","gender":"female","province":"Fake Area","phone":"1234567890","postalCode":123,"fullName":"Amit Developer","addressLine1":["1","Fake building","Fake Area","Fake City","Near Fake Landmark"],"dateOfBirth":"01\\/01\\/2022","vcVer":"VC-V1","UIN":123456,"region":"FakeRegion","email":"[email protected]"},"validUntil":"02\\/02\\/2122","validFrom":"01\\/01\\/2022","type":["VerifiableCredential","MockVerifiableCredential"],"@context":["https:\\/\\/www.w3.org\\/ns\\/credentials\\/v2"],"issuer":"https:\\/\\/example.com\\/fake-issuer"}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ mosip.certify.issuer=PluginIssuer
## ------------------------------------------ Discovery openid-configuration -------------------------------------------
mosipbox.public.url=http://localhost:8090
mosip.certify.discovery.issuer-id=${mosipbox.public.url}${server.servlet.path}
mosip.certify.pub.key=http://localhost/pub.key.json
mosip.certify.issuer.pub.key=http://localhost/pub.key.json
mosip.certify.issuer.uri=http://localhost/pub.key.json

##---------------------------------------------------------------------------------------------------------------------
spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration,org.springframework.boot.actuate.autoconfigure.security.servlet.ManagementWebSecurityAutoConfiguration
Expand Down

0 comments on commit a2f50b8

Please sign in to comment.