diff --git a/docker-compose/config/mimoto-issuers-config.json b/docker-compose/config/mimoto-issuers-config.json index ff624399..6c31f3eb 100644 --- a/docker-compose/config/mimoto-issuers-config.json +++ b/docker-compose/config/mimoto-issuers-config.json @@ -1,7 +1,7 @@ { "issuers": [ { - "credential_issuer": "Mosip", + "issuer_id": "Mosip", "protocol": "OpenId4VCI", "display": [ { @@ -72,11 +72,12 @@ "proxy_token_endpoint": "https://esignet-mosipid.collab.mosip.net/v1/esignet/oauth/v2/token", "client_alias": "mpartner-default-test-mosipid", "qr_code_type": "OnlineSharing", - "enabled": "true", - "wellknown_endpoint": "https://injicertify-mosipid.collab.mosip.net/v1/certify/issuance/.well-known/openid-credential-issuer" + "wellknown_endpoint": "https://injicertify-mosipid.collab.mosip.net/v1/certify/issuance/.well-known/openid-credential-issuer", + "credential_issuer": "https://injicertify-mosipid.collab.mosip.net", + "enabled": "true" }, { - "credential_issuer": "StayProtected", + "issuer_id": "StayProtected", "protocol": "OpenId4VCI", "display": [ { @@ -97,11 +98,12 @@ "proxy_token_endpoint": "https://esignet-insurance.collab.mosip.net/v1/esignet/oauth/v2/token", "client_alias": "esignet-sunbird-partner", "qr_code_type": "OnlineSharing", - "enabled": "true", - "wellknown_endpoint": "https://injicertify-insurance.collab.mosip.net/v1/certify/issuance/.well-known/openid-credential-issuer" + "wellknown_endpoint": "https://injicertify-insurance.collab.mosip.net/v1/certify/issuance/.well-known/openid-credential-issuer", + "credential_issuer": "https://injicertify-insurance.collab.mosip.net", + "enabled": "true" }, { - "credential_issuer": "Mock", + "issuer_id": "Mock", "protocol": "OpenId4VCI", "display": [ { @@ -122,8 +124,9 @@ "proxy_token_endpoint": "https://esignet-mock.collab.mosip.net/v1/esignet/oauth/v2/token", "client_alias": "mpartner-mock-testing", "qr_code_type": "OnlineSharing", - "enabled": "true", - "wellknown_endpoint": "https://injicertify-mock.collab.mosip.net/v1/certify/issuance/.well-known/openid-credential-issuer" + "wellknown_endpoint": "https://injicertify-mock.collab.mosip.net/v1/certify/issuance/.well-known/openid-credential-issuer", + "credential_issuer": "https://injicertify-mock.collab.mosip.net", + "enabled": "true" } ] } diff --git a/docs/api-documentation-openapi.json b/docs/api-documentation-openapi.json index 45fcb7e9..26df249f 100644 --- a/docs/api-documentation-openapi.json +++ b/docs/api-documentation-openapi.json @@ -1171,7 +1171,7 @@ "properties": { "issuers": [ { - "credential_issuer": "string", + "issuer_id": "string", "protocol": "string", "display": [ { @@ -1205,7 +1205,8 @@ "additionalProp2": "string", "additionalProp3": "string" }, - "wellknown_endpoint": "string" + "wellknown_endpoint": "string", + "credential_issuer": "string" } ] } @@ -1220,7 +1221,7 @@ "response": { "issuers": [ { - "credential_issuer": "MOSIPInsurance", + "issuer_id": "MOSIPInsurance", "protocol": "OpenId4VCI", "display": [ { @@ -1235,10 +1236,11 @@ } ], "client_id": "3yz7-j3xRzU3SODdoNgSGvO_cD8UijH3AIWRDAg1x-M", - ".well-known": "http://localhost:8088/.well-known/openid-credential-issuer" + ".well-known": "http://localhost:8088/.well-known/openid-credential-issuer", + "credential_issuer": "http://localhost:8088" }, { - "credential_issuer": "MOSIPNationalID", + "issuer_id": "MOSIPNationalID", "protocol": "OpenId4VCI", "display": [ { @@ -1253,7 +1255,8 @@ } ], "client_id": "3yz7-j3xRzU3SODdoNgSGvO_cD8UijH3AIWRDAg1x-M", - ".well-known": "http://localhost:8088/.well-known/openid-credential-issuer" + ".well-known": "http://localhost:8088/.well-known/openid-credential-issuer", + "credential_issuer": "http://localhost:8088" } ] } @@ -1271,7 +1274,7 @@ "response": { "issuers": [ { - "credential_issuer": "MOSIPInsurance", + "issuer_id": "MOSIPInsurance", "protocol": "OpenId4VCI", "display": [ { @@ -1286,10 +1289,11 @@ } ], "client_id": "3yz7-j3xRzU3SODdoNgSGvO_cD8UijH3AIWRDAg1x-M", - ".well-known": "http://localhost:8088/.well-known/openid-credential-issuer" + ".well-known": "http://localhost:8088/.well-known/openid-credential-issuer", + "credential_issuer": "http://localhost:8088" }, { - "credential_issuer": "MOSIPNationalID", + "issuer_id": "MOSIPNationalID", "protocol": "OpenId4VCI", "display": [ { @@ -1304,7 +1308,8 @@ } ], "client_id": "3yz7-j3xRzU3SODdoNgSGvO_cD8UijH3AIWRDAg1x-M", - ".well-known": "http://localhost:8088/.well-known/openid-credential-issuer" + ".well-known": "http://localhost:8088/.well-known/openid-credential-issuer", + "credential_issuer": "http://localhost:8088" } ] } @@ -1408,7 +1413,7 @@ "responsetime": "2024-04-25T05:56:55.890Z", "metadata": null, "response": { - "credential_issuer": "ESignet", + "issuer_id": "ESignet", "protocol": "OpenId4VCI", "display": [ { @@ -1491,7 +1496,8 @@ "additional_headers": { "Accept": "application/json" }, - ".well-known": "https://esignet.collab.mosip.net/.well-known/openid-credential-issuer" + ".well-known": "https://esignet.collab.mosip.net/.well-known/openid-credential-issuer", + "credential_issuer": "https://esignet.collab.mosip.net" }, "errors": [] }, @@ -1506,7 +1512,7 @@ "responsetime": "2024-04-25T05:56:55.890Z", "metadata": null, "response": { - "credential_issuer": "ESignet", + "issuer_id": "ESignet", "protocol": "OpenId4VCI", "display": [ { @@ -1589,7 +1595,8 @@ "additional_headers": { "Accept": "application/json" }, - ".well-known": "https://esignet.collab.mosip.net/.well-known/openid-credential-issuer" + ".well-known": "https://esignet.collab.mosip.net/.well-known/openid-credential-issuer", + "credential_issuer": "https://esignet.collab.mosip.net" }, "errors": [] }, diff --git a/src/main/java/io/mosip/mimoto/config/IssuersValidationConfig.java b/src/main/java/io/mosip/mimoto/config/IssuersValidationConfig.java index dac6ae80..6cbe8fe5 100644 --- a/src/main/java/io/mosip/mimoto/config/IssuersValidationConfig.java +++ b/src/main/java/io/mosip/mimoto/config/IssuersValidationConfig.java @@ -42,15 +42,15 @@ public void run(ApplicationArguments args) throws ApiNotAccessibleException, IOE if (!issuerDTO.getProtocol().equals("OTP")) { errors.set(new BeanPropertyBindingResult(issuerDTO, "issuerDTO")); validator.validate(issuerDTO, errors.get()); - String credentialIssuer = issuerDTO.getCredential_issuer(); + String issuerId = issuerDTO.getIssuer_id(); String[] tokenEndpointArray = issuerDTO.getToken_endpoint().split("/"); Set currentIssuers = credentialIssuers.get(); - if (!currentIssuers.add(credentialIssuer)) { - log.error(VALIDATION_ERROR_MSG + "duplicate value found " + credentialIssuer); + if (!currentIssuers.add(issuerId)) { + log.error(VALIDATION_ERROR_MSG + "duplicate value found " + issuerId); throw new RuntimeException(VALIDATION_ERROR_MSG); } - if (!tokenEndpointArray[tokenEndpointArray.length - 1].equals(credentialIssuer)) { - log.error(VALIDATION_ERROR_MSG + "TokenEndpoint does not match with the credential issuer " + credentialIssuer); + if (!tokenEndpointArray[tokenEndpointArray.length - 1].equals(issuerId)) { + log.error(VALIDATION_ERROR_MSG + "TokenEndpoint does not match with the credential issuer " + issuerId); throw new RuntimeException(VALIDATION_ERROR_MSG); } credentialIssuers.set(currentIssuers); diff --git a/src/main/java/io/mosip/mimoto/dto/IssuerDTO.java b/src/main/java/io/mosip/mimoto/dto/IssuerDTO.java index b12749ec..5f76ba80 100644 --- a/src/main/java/io/mosip/mimoto/dto/IssuerDTO.java +++ b/src/main/java/io/mosip/mimoto/dto/IssuerDTO.java @@ -1,9 +1,7 @@ package io.mosip.mimoto.dto; import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; import io.mosip.mimoto.model.QRCodeType; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.Valid; @@ -21,7 +19,7 @@ public class IssuerDTO { @Expose @NotBlank @Schema(description = "Unique Identifier of the Issuer") - String credential_issuer; + String issuer_id; @Expose @NotBlank @Schema(description = "protocol of the download flow", allowableValues = {"OTP", "OpenId4VCI"}) @@ -68,4 +66,9 @@ public class IssuerDTO { @NotBlank @Schema(description = "Toggler to Enable / Disable the Issuer", defaultValue = "false") String enabled; + @Expose + @NotBlank + @JsonInclude(NON_NULL) + @Schema(description = "Credential Issuer Host") + String credential_issuer; } diff --git a/src/main/java/io/mosip/mimoto/service/impl/IssuersServiceImpl.java b/src/main/java/io/mosip/mimoto/service/impl/IssuersServiceImpl.java index 07f895db..23f6d2eb 100644 --- a/src/main/java/io/mosip/mimoto/service/impl/IssuersServiceImpl.java +++ b/src/main/java/io/mosip/mimoto/service/impl/IssuersServiceImpl.java @@ -95,7 +95,7 @@ public IssuerDTO getIssuerConfig(String issuerId) throws ApiNotAccessibleExcepti } IssuersDTO issuers = new Gson().fromJson(issuersConfigJsonValue, IssuersDTO.class); Optional issuerConfigResp = issuers.getIssuers().stream() - .filter(issuer -> issuer.getCredential_issuer().equals(issuerId)) + .filter(issuer -> issuer.getIssuer_id().equals(issuerId)) .findFirst(); if (issuerConfigResp.isPresent()) issuerDTO = issuerConfigResp.get(); @@ -107,7 +107,7 @@ public IssuerDTO getIssuerConfig(String issuerId) throws ApiNotAccessibleExcepti @Override public CredentialIssuerWellKnownResponse getIssuerWellknown(String issuerId) throws ApiNotAccessibleException, IOException { return getAllIssuersWithAllFields().getIssuers().stream() - .filter(issuer -> issuer.getCredential_issuer().equals(issuerId)) + .filter(issuer -> issuer.getIssuer_id().equals(issuerId)) .findFirst() .map(issuerDTO -> { String wellknownResponse = restApiClient.getApi(issuerDTO.getWellknown_endpoint(), String.class); diff --git a/src/main/resources/mimoto-issuers-config.json b/src/main/resources/mimoto-issuers-config.json index 86a5a464..6df6e205 100644 --- a/src/main/resources/mimoto-issuers-config.json +++ b/src/main/resources/mimoto-issuers-config.json @@ -1,7 +1,7 @@ { "issuers": [ { - "credential_issuer": "Mosip", + "issuer_id": "Mosip", "protocol": "OpenId4VCI", "display": [ { @@ -72,11 +72,12 @@ "proxy_token_endpoint": "https://esignet-mosipid.dev1.mosip.net/v1/esignet/oauth/v2/token", "client_alias": "mpartner-default-test-mosipid", "qr_code_type": "OnlineSharing", - "enabled": "true", - "wellknown_endpoint": "https://injicertify-mosipid.dev1.mosip.net/v1/certify/issuance/.well-known/openid-credential-issuer" + "wellknown_endpoint": "https://injicertify-mosipid.dev1.mosip.net/v1/certify/issuance/.well-known/openid-credential-issuer", + "credential_issuer": "https://injicertify-mosipid.dev1.mosip.net", + "enabled": "true" }, { - "credential_issuer": "StayProtected", + "issuer_id": "StayProtected", "protocol": "OpenId4VCI", "display": [ { @@ -97,11 +98,12 @@ "proxy_token_endpoint": "https://esignet-insurance.dev1.mosip.net/v1/esignet/oauth/v2/token", "client_alias": "esignet-sunbird-partner", "qr_code_type": "OnlineSharing", - "enabled": "true", - "wellknown_endpoint": "https://injicertify-insurance.dev1.mosip.net/v1/certify/issuance/.well-known/openid-credential-issuer" + "wellknown_endpoint": "https://injicertify-insurance.dev1.mosip.net/v1/certify/issuance/.well-known/openid-credential-issuer", + "credential_issuer": "https://injicertify-insurance.dev1.mosip.net", + "enabled": "true" }, { - "credential_issuer": "Mock", + "issuer_id": "Mock", "protocol": "OpenId4VCI", "display": [ { @@ -122,8 +124,9 @@ "proxy_token_endpoint": "https://esignet-mock.dev1.mosip.net/v1/esignet/oauth/v2/token", "client_alias": "mpartner-mock-testing", "qr_code_type": "OnlineSharing", - "enabled": "true", - "wellknown_endpoint": "https://injicertify-mock.dev1.mosip.net/v1/certify/issuance/.well-known/openid-credential-issuer" + "wellknown_endpoint": "https://injicertify-mock.dev1.mosip.net/v1/certify/issuance/.well-known/openid-credential-issuer", + "credential_issuer": "https://injicertify-mock.dev1.mosip.net", + "enabled": "true" } ] } diff --git a/src/test/java/io/mosip/mimoto/controller/IssuersControllerTest.java b/src/test/java/io/mosip/mimoto/controller/IssuersControllerTest.java index 0fe3280c..2ecd10b0 100644 --- a/src/test/java/io/mosip/mimoto/controller/IssuersControllerTest.java +++ b/src/test/java/io/mosip/mimoto/controller/IssuersControllerTest.java @@ -68,6 +68,7 @@ public void getAllIssuersTest() throws Exception { .andExpect(status().isOk()) .andExpect(jsonPath("$.response.issuers", Matchers.everyItem( Matchers.allOf( + Matchers.hasKey("issuer_id"), Matchers.hasKey("credential_issuer"), Matchers.hasKey("display"), Matchers.hasKey("client_id"), @@ -86,6 +87,7 @@ public void getAllIssuersTest() throws Exception { .andExpect(status().isOk()) .andExpect(jsonPath("$.response.issuers", Matchers.everyItem( Matchers.allOf( + Matchers.hasKey("issuer_id"), Matchers.hasKey("credential_issuer"), Matchers.hasKey("display"), Matchers.hasKey("client_id"), diff --git a/src/test/java/io/mosip/mimoto/util/TestUtilities.java b/src/test/java/io/mosip/mimoto/util/TestUtilities.java index da9828d6..72235d93 100644 --- a/src/test/java/io/mosip/mimoto/util/TestUtilities.java +++ b/src/test/java/io/mosip/mimoto/util/TestUtilities.java @@ -100,7 +100,8 @@ public static IssuerDTO getIssuerDTO(String issuerName) { display.setLanguage("en"); display.setLogo(logo); IssuerDTO issuer = new IssuerDTO(); - issuer.setCredential_issuer(issuerName + "id"); + issuer.setIssuer_id(issuerName + "id"); + issuer.setCredential_issuer("https://injicertify-mock.dev1.mosip.net"); issuer.setDisplay(Collections.singletonList(display)); issuer.setClient_id("123"); if (issuerName.equals("Issuer1")) issuer.setWellknown_endpoint("/well-known-proxy"); @@ -121,7 +122,8 @@ public static IssuerDTO getIssuerConfigDTO(String issuerName, List nullF display.setLanguage("en"); display.setLogo(logo); IssuerDTO issuer = new IssuerDTO(); - issuer.setCredential_issuer(issuerName + "id"); + issuer.setIssuer_id(issuerName + "id"); + issuer.setCredential_issuer("https://injicertify-mock.dev1.mosip.net"); issuer.setDisplay(Collections.singletonList(display)); issuer.setClient_id("123"); issuer.setEnabled("true");