Skip to content

Commit

Permalink
[INJIMOB: 2452]: Add Credential Issuer Host in IssuerDTO (#534)
Browse files Browse the repository at this point in the history
* [INJIMOB-2452]: Add credential_issuer_identifier to IssuerDTO

Signed-off-by: BalachandarG <[email protected]>

* [INJIMOB-2452]: Update Credential Issuer Identifier to Credential Issuer Host

Signed-off-by: BalachandarG <[email protected]>

* [INJIMOB-2452]: Add issuer host field in local mimoto-issuers-config.json

Signed-off-by: BalachandarG <[email protected]>

* [INJIMOB-2452]: Move enabled field as last attribute

Signed-off-by: BalachandarG <[email protected]>

* [INJIMOB-2452]: Attribute name change for issuer_id

Signed-off-by: BalachandarG <[email protected]>

* [INJIMOB-2452]: Update issuerId variable name

Signed-off-by: BalachandarG <[email protected]>

* [INJIMOB-2452]: Update in TestUtilities.

Signed-off-by: BalachandarG <[email protected]>

---------

Signed-off-by: BalachandarG <[email protected]>
  • Loading branch information
balachandarg-tw authored Dec 18, 2024
1 parent f4fba59 commit 8fa93d8
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 44 deletions.
21 changes: 12 additions & 9 deletions docker-compose/config/mimoto-issuers-config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"issuers": [
{
"credential_issuer": "Mosip",
"issuer_id": "Mosip",
"protocol": "OpenId4VCI",
"display": [
{
Expand Down Expand Up @@ -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": [
{
Expand All @@ -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": [
{
Expand All @@ -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"
}
]
}
35 changes: 21 additions & 14 deletions docs/api-documentation-openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -1171,7 +1171,7 @@
"properties": {
"issuers": [
{
"credential_issuer": "string",
"issuer_id": "string",
"protocol": "string",
"display": [
{
Expand Down Expand Up @@ -1205,7 +1205,8 @@
"additionalProp2": "string",
"additionalProp3": "string"
},
"wellknown_endpoint": "string"
"wellknown_endpoint": "string",
"credential_issuer": "string"
}
]
}
Expand All @@ -1220,7 +1221,7 @@
"response": {
"issuers": [
{
"credential_issuer": "MOSIPInsurance",
"issuer_id": "MOSIPInsurance",
"protocol": "OpenId4VCI",
"display": [
{
Expand All @@ -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": [
{
Expand All @@ -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"
}
]
}
Expand All @@ -1271,7 +1274,7 @@
"response": {
"issuers": [
{
"credential_issuer": "MOSIPInsurance",
"issuer_id": "MOSIPInsurance",
"protocol": "OpenId4VCI",
"display": [
{
Expand All @@ -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": [
{
Expand All @@ -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"
}
]
}
Expand Down Expand Up @@ -1408,7 +1413,7 @@
"responsetime": "2024-04-25T05:56:55.890Z",
"metadata": null,
"response": {
"credential_issuer": "ESignet",
"issuer_id": "ESignet",
"protocol": "OpenId4VCI",
"display": [
{
Expand Down Expand Up @@ -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": []
},
Expand All @@ -1506,7 +1512,7 @@
"responsetime": "2024-04-25T05:56:55.890Z",
"metadata": null,
"response": {
"credential_issuer": "ESignet",
"issuer_id": "ESignet",
"protocol": "OpenId4VCI",
"display": [
{
Expand Down Expand Up @@ -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": []
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> 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);
Expand Down
9 changes: 6 additions & 3 deletions src/main/java/io/mosip/mimoto/dto/IssuerDTO.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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"})
Expand Down Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public IssuerDTO getIssuerConfig(String issuerId) throws ApiNotAccessibleExcepti
}
IssuersDTO issuers = new Gson().fromJson(issuersConfigJsonValue, IssuersDTO.class);
Optional<IssuerDTO> 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();
Expand All @@ -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);
Expand Down
21 changes: 12 additions & 9 deletions src/main/resources/mimoto-issuers-config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"issuers": [
{
"credential_issuer": "Mosip",
"issuer_id": "Mosip",
"protocol": "OpenId4VCI",
"display": [
{
Expand Down Expand Up @@ -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": [
{
Expand All @@ -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": [
{
Expand All @@ -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"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand All @@ -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"),
Expand Down
6 changes: 4 additions & 2 deletions src/test/java/io/mosip/mimoto/util/TestUtilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -121,7 +122,8 @@ public static IssuerDTO getIssuerConfigDTO(String issuerName, List<String> 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");
Expand Down

0 comments on commit 8fa93d8

Please sign in to comment.