From f824f2b1dc2f071e6db3806ce875f33dc74aa8ce Mon Sep 17 00:00:00 2001 From: Glauco <37829079+rglauco@users.noreply.github.com> Date: Thu, 2 Nov 2023 22:23:28 +0100 Subject: [PATCH] fix: aligned claims "trust_mark_issuer", "trust_marks_issuers" to trust_mark_issuers --- .../persistence/model/FederationEntityModel.java | 16 ++++++++-------- .../src/main/resources/sql/schema.sql | 2 +- .../cie/oidc/handler/RelyingPartyHandler.java | 2 +- .../spid/cie/oidc/model/EntityConfiguration.java | 12 ++++++------ .../it/spid/cie/oidc/model/FederationEntity.java | 10 +++++----- .../oidc/handler/TestRelyingPartyHandler.java | 4 ++-- .../cie/oidc/model/TestEntityConfiguration.java | 12 ++++++------ .../cie/oidc/model/TestFederationEntity.java | 4 ++-- .../cie/oidc/model/TestTrustChainBuilder.java | 8 ++++---- .../it/spid/cie/oidc/model/TestTrustMark.java | 4 ++-- .../it/spid/cie/oidc/test/util/RPTestUtils.java | 8 ++++---- 11 files changed, 41 insertions(+), 41 deletions(-) diff --git a/examples/relying-party-spring-boot/src/main/java/it/spid/cie/oidc/spring/boot/relying/party/persistence/model/FederationEntityModel.java b/examples/relying-party-spring-boot/src/main/java/it/spid/cie/oidc/spring/boot/relying/party/persistence/model/FederationEntityModel.java index ee0d1a1..4c8c40d 100644 --- a/examples/relying-party-spring-boot/src/main/java/it/spid/cie/oidc/spring/boot/relying/party/persistence/model/FederationEntityModel.java +++ b/examples/relying-party-spring-boot/src/main/java/it/spid/cie/oidc/spring/boot/relying/party/persistence/model/FederationEntityModel.java @@ -32,7 +32,7 @@ public static FederationEntityModel of(FederationEntity source) { target.setConstraints(source.getConstraints()); target.setJwks(source.getJwks()); target.setTrustMarks(source.getTrustMarks()); - target.setTrustMarksIssuers(source.getTrustMarksIssuers()); + target.setTrustMarkIssuers(source.gettrustMarkIssuers()); target.setMetadata(source.getMetadata()); return target; @@ -79,8 +79,8 @@ public String getTrustMarks() { return trustMarks; } - public String getTrustMarksIssuers() { - return trustMarksIssuers; + public String getTrustMarkIssuers() { + return trustMarkIssuers; } public String getMetadata() { @@ -134,8 +134,8 @@ public void setTrustMarks(String trustMarks) { this.trustMarks = trustMarks; } - public void setTrustMarksIssuers(String trustMarksIssuers) { - this.trustMarksIssuers = trustMarksIssuers; + public void setTrustMarkIssuers(String trustMarkIssuers) { + this.trustMarkIssuers = trustMarkIssuers; } public void setMetadata(String metadata) { @@ -169,7 +169,7 @@ public FederationEntity toFederationEntity() { target.setConstraints(getConstraints()); target.setJwks(getJwks()); target.setTrustMarks(getTrustMarks()); - target.setTrustMarksIssuers(getTrustMarksIssuers()); + target.settrustMarkIssuers(getTrustMarkIssuers()); target.setMetadata(getMetadata()); return target; @@ -218,8 +218,8 @@ private String getStorageId() { @Column(name = "trust_marks", nullable = false, length = 2000) private String trustMarks; - @Column(name = "trust_marks_issuers", nullable = false, length = 2000) - private String trustMarksIssuers; + @Column(name = "trust_mark_issuers", nullable = false, length = 2000) + private String trustMarkIssuers; @Column(nullable = false, length = 5000) private String metadata; diff --git a/examples/relying-party-spring-boot/src/main/resources/sql/schema.sql b/examples/relying-party-spring-boot/src/main/resources/sql/schema.sql index d1ed951..97d86a8 100644 --- a/examples/relying-party-spring-boot/src/main/resources/sql/schema.sql +++ b/examples/relying-party-spring-boot/src/main/resources/sql/schema.sql @@ -40,7 +40,7 @@ CREATE TABLE IF NOT EXISTS federation_entity_configuration ( authority_hints VARCHAR NOT NULL, jwks VARCHAR NOT NULL, trust_marks VARCHAR NOT NULL, - trust_marks_issuers VARCHAR NOT NULL, + trust_mark_issuers VARCHAR NOT NULL, metadata VARCHAR NOT NULL, constraints VARCHAR NOT NULL, is_active BOOLEAN NOT NULL, diff --git a/starter-kit/src/main/java/it/spid/cie/oidc/handler/RelyingPartyHandler.java b/starter-kit/src/main/java/it/spid/cie/oidc/handler/RelyingPartyHandler.java index fb0ae3b..f8122bb 100644 --- a/starter-kit/src/main/java/it/spid/cie/oidc/handler/RelyingPartyHandler.java +++ b/starter-kit/src/main/java/it/spid/cie/oidc/handler/RelyingPartyHandler.java @@ -929,7 +929,7 @@ private WellKnownData prepareOnboardingData(String sub, boolean jsonMode) entity.setJwks( JWTHelper.getJWKSetAsJSONArray(jwkSet, true, false).toString()); entity.setTrustMarks(json.getJSONArray("trust_marks").toString()); - entity.setTrustMarksIssuers("{}"); + entity.settrustMarkIssuers("{}"); entity.setMetadata(json.getJSONObject("metadata").toString()); entity.setActive(true); entity.setConstraints("{}"); diff --git a/starter-kit/src/main/java/it/spid/cie/oidc/model/EntityConfiguration.java b/starter-kit/src/main/java/it/spid/cie/oidc/model/EntityConfiguration.java index e212319..d219b92 100644 --- a/starter-kit/src/main/java/it/spid/cie/oidc/model/EntityConfiguration.java +++ b/starter-kit/src/main/java/it/spid/cie/oidc/model/EntityConfiguration.java @@ -250,14 +250,14 @@ public Map getSuperiors( return this.verifiedSuperiors; } - public Map> getTrustMarksIssuers() { + public Map> gettrustMarkIssuers() { Map> result = new HashMap<>(); - JSONObject trustMarksIssuers = payload.optJSONObject( - "trust_marks_issuers", new JSONObject()); + JSONObject trustMarkIssuers = payload.optJSONObject( + "trust_mark_issuers", new JSONObject()); - for (String key : trustMarksIssuers.keySet()) { - JSONArray jsonArray = trustMarksIssuers.optJSONArray(key); + for (String key : trustMarkIssuers.keySet()) { + JSONArray jsonArray = trustMarkIssuers.optJSONArray(key); if (jsonArray == null) { continue; @@ -422,7 +422,7 @@ else if (!isTrustMarkAllowed(jsonTrustMark)) { "Required Trust marks are missing."); } - Map> trustAnchorIssuers = trustAnchor.getTrustMarksIssuers(); + Map> trustAnchorIssuers = trustAnchor.gettrustMarkIssuers(); boolean valid = false; diff --git a/starter-kit/src/main/java/it/spid/cie/oidc/model/FederationEntity.java b/starter-kit/src/main/java/it/spid/cie/oidc/model/FederationEntity.java index 78bb1d4..9ce0854 100644 --- a/starter-kit/src/main/java/it/spid/cie/oidc/model/FederationEntity.java +++ b/starter-kit/src/main/java/it/spid/cie/oidc/model/FederationEntity.java @@ -27,7 +27,7 @@ public class FederationEntity extends BaseModel { private String authorityHints; private String jwks; private String trustMarks; - private String trustMarksIssuers; + private String trustMarkIssuers; private String metadata; private boolean active = false; private String constraints; @@ -80,8 +80,8 @@ public String getTrustMarks() { return trustMarks; } - public String getTrustMarksIssuers() { - return trustMarksIssuers; + public String gettrustMarkIssuers() { + return trustMarkIssuers; } public boolean isActive() { @@ -134,8 +134,8 @@ public void setTrustMarks(String trustMarks) { this.trustMarks = trustMarks; } - public void setTrustMarksIssuers(String trustMarksIssuers) { - this.trustMarksIssuers = trustMarksIssuers; + public void settrustMarkIssuers(String trustMarkIssuers) { + this.trustMarkIssuers = trustMarkIssuers; } diff --git a/starter-kit/src/test/java/it/spid/cie/oidc/handler/TestRelyingPartyHandler.java b/starter-kit/src/test/java/it/spid/cie/oidc/handler/TestRelyingPartyHandler.java index 3e891bf..b8f7179 100644 --- a/starter-kit/src/test/java/it/spid/cie/oidc/handler/TestRelyingPartyHandler.java +++ b/starter-kit/src/test/java/it/spid/cie/oidc/handler/TestRelyingPartyHandler.java @@ -675,7 +675,7 @@ private String mockedTrustAnchorEntityConfiguration() throws Exception { payload.put( "metadata", new JSONObject().put("federation_entity", trustAnchorMetadata)); - JSONObject trustMarksIssuers = new JSONObject() + JSONObject trustMarkIssuers = new JSONObject() .put( "https://www.spid.gov.it/certification/rp/public", JSONUtil.asJSONArray( "https://registry.spid.agid.gov.it", @@ -688,7 +688,7 @@ private String mockedTrustAnchorEntityConfiguration() throws Exception { "https://sgd.aa.it/onboarding", JSONUtil.asJSONArray( "https://sgd.aa.it")); - payload.put("trust_marks_issuers", trustMarksIssuers); + payload.put("trust_mark_issuers", trustMarkIssuers); payload.put("constraints", new JSONObject().put("max_path_length", 1)); JSONObject jwks = mockedTrustAnchorPrivateJWKS(); diff --git a/starter-kit/src/test/java/it/spid/cie/oidc/model/TestEntityConfiguration.java b/starter-kit/src/test/java/it/spid/cie/oidc/model/TestEntityConfiguration.java index e877a56..1b5cb89 100644 --- a/starter-kit/src/test/java/it/spid/cie/oidc/model/TestEntityConfiguration.java +++ b/starter-kit/src/test/java/it/spid/cie/oidc/model/TestEntityConfiguration.java @@ -260,7 +260,7 @@ public void test_validateBySuperiors() { } @Test - public void test_getTrustMarksIssuers() { + public void test_gettrustMarkIssuers() { JWTHelper jwtHelper = null; EntityConfiguration ec = null; boolean catched = false; @@ -283,7 +283,7 @@ public void test_getTrustMarksIssuers() { Map> res = null; try { - res = ec.getTrustMarksIssuers(); + res = ec.gettrustMarkIssuers(); } catch (Exception e) { catched = true; @@ -762,7 +762,7 @@ private String mockedTrustAnchorEntityConfigurationC1() payload.put( "metadata", new JSONObject().put("federation_entity", trustAnchorMetadata)); - JSONObject trustMarksIssuers = new JSONObject() + JSONObject trustMarkIssuers = new JSONObject() .put( "https://www.spid.gov.it/certification/rp/public", JSONUtil.asJSONArray( "https://registry.spid.agid.gov.it", @@ -775,7 +775,7 @@ private String mockedTrustAnchorEntityConfigurationC1() "https://sgd.aa.it/onboarding", JSONUtil.asJSONArray( "https://sgd.aa.it")); - payload.put("trust_marks_issuers", trustMarksIssuers); + payload.put("trust_mark_issuers", trustMarkIssuers); payload.put("constraints", new JSONObject().put("max_path_length", 1)); JSONObject jwks = RPTestUtils.mockedTrustAnchorPrivateJWKS(); @@ -805,7 +805,7 @@ private String mockedTrustAnchorEntityConfigurationC2() payload.put( "metadata", new JSONObject().put("federation_entity", trustAnchorMetadata)); - JSONObject trustMarksIssuers = new JSONObject() + JSONObject trustMarkIssuers = new JSONObject() .put( "https://www.spid.gov.it/certification/rp/public", JSONUtil.asJSONArray( "https://registry.spid.agid.gov.it", @@ -819,7 +819,7 @@ private String mockedTrustAnchorEntityConfigurationC2() "https://sgd.aa.it/onboarding", JSONUtil.asJSONArray( "https://sgd.aa.it")); - payload.put("trust_marks_issuers", trustMarksIssuers); + payload.put("trust_mark_issuers", trustMarkIssuers); //payload.put("constraints", new JSONObject().put("max_path_length", 1)); JSONObject jwks = RPTestUtils.mockedTrustAnchorPrivateJWKS(); diff --git a/starter-kit/src/test/java/it/spid/cie/oidc/model/TestFederationEntity.java b/starter-kit/src/test/java/it/spid/cie/oidc/model/TestFederationEntity.java index 8d786f3..f0a441b 100644 --- a/starter-kit/src/test/java/it/spid/cie/oidc/model/TestFederationEntity.java +++ b/starter-kit/src/test/java/it/spid/cie/oidc/model/TestFederationEntity.java @@ -30,7 +30,7 @@ public void testFederationEntityClass() { model.getMetadata(); model.getSubject(); model.getTrustMarks(); - model.getTrustMarksIssuers(); + model.gettrustMarkIssuers(); model.isActive(); LocalDateTime now = LocalDateTime.now(); @@ -48,7 +48,7 @@ public void testFederationEntityClass() { model.setJwks("testJwks"); model.setSubject("testSubject"); model.setTrustMarks("testTrustMarks"); - model.setTrustMarksIssuers("testIssuer"); + model.settrustMarkIssuers("testIssuer"); JSONObject metadata = new JSONObject() .put("testKey", new JSONObject().put("test", "ok")); diff --git a/starter-kit/src/test/java/it/spid/cie/oidc/model/TestTrustChainBuilder.java b/starter-kit/src/test/java/it/spid/cie/oidc/model/TestTrustChainBuilder.java index 9ba11e4..86823c7 100644 --- a/starter-kit/src/test/java/it/spid/cie/oidc/model/TestTrustChainBuilder.java +++ b/starter-kit/src/test/java/it/spid/cie/oidc/model/TestTrustChainBuilder.java @@ -747,7 +747,7 @@ private static String mockedTrustAnchorEntityConfigurationC3(JWKSet jwkSet) payload.put( "metadata", new JSONObject().put("federation_entity", trustAnchorMetadata)); - JSONObject trustMarksIssuers = new JSONObject() + JSONObject trustMarkIssuers = new JSONObject() .put( "https://www.spid.gov.it/certification/rp/public", JSONUtil.asJSONArray( "https://registry.spid.agid.gov.it", @@ -760,7 +760,7 @@ private static String mockedTrustAnchorEntityConfigurationC3(JWKSet jwkSet) "https://sgd.aa.it/onboarding", JSONUtil.asJSONArray( "https://sgd.aa.it")); - payload.put("trust_marks_issuers", trustMarksIssuers); + payload.put("trust_mark_issuers", trustMarkIssuers); payload.put("constraints", new JSONObject().put("max_path_length", 1)); JSONObject jwks = new JSONObject(jwkSet.toJSONObject(false)); @@ -790,7 +790,7 @@ private static String mockedTrustAnchorEntityConfigurationC4() payload.put( "metadata", new JSONObject().put("federation_entity", trustAnchorMetadata)); - JSONObject trustMarksIssuers = new JSONObject() + JSONObject trustMarkIssuers = new JSONObject() .put( "https://www.spid.gov.it/certification/rp/public", JSONUtil.asJSONArray( "https://registry.spid.agid.gov.it", @@ -803,7 +803,7 @@ private static String mockedTrustAnchorEntityConfigurationC4() "https://sgd.aa.it/onboarding", JSONUtil.asJSONArray( "https://sgd.aa.it")); - payload.put("trust_marks_issuers", trustMarksIssuers); + payload.put("trust_mark_issuers", trustMarkIssuers); payload.put("constraints", new JSONObject().put("max_path_length", 1)); JSONObject jwks = new JSONObject(RPTestUtils.createJWKSet().toJSONObject(false)); diff --git a/starter-kit/src/test/java/it/spid/cie/oidc/model/TestTrustMark.java b/starter-kit/src/test/java/it/spid/cie/oidc/model/TestTrustMark.java index 6c93be3..1736848 100644 --- a/starter-kit/src/test/java/it/spid/cie/oidc/model/TestTrustMark.java +++ b/starter-kit/src/test/java/it/spid/cie/oidc/model/TestTrustMark.java @@ -297,7 +297,7 @@ private static String doMockedTrustAnchorEntityConfiguration( payload.put( "metadata", new JSONObject().put("federation_entity", trustAnchorMetadata)); - JSONObject trustMarksIssuers = new JSONObject() + JSONObject trustMarkIssuers = new JSONObject() .put( "https://www.spid.gov.it/certification/rp/public", JSONUtil.asJSONArray( "https://registry.spid.agid.gov.it", @@ -310,7 +310,7 @@ private static String doMockedTrustAnchorEntityConfiguration( "https://sgd.aa.it/onboarding", JSONUtil.asJSONArray( "https://sgd.aa.it")); - payload.put("trust_marks_issuers", trustMarksIssuers); + payload.put("trust_mark_issuers", trustMarkIssuers); payload.put("constraints", new JSONObject().put("max_path_length", 1)); return RPTestUtils.createJWS(payload, privateJwks); diff --git a/starter-kit/src/test/java/it/spid/cie/oidc/test/util/RPTestUtils.java b/starter-kit/src/test/java/it/spid/cie/oidc/test/util/RPTestUtils.java index 9e365e4..6808685 100644 --- a/starter-kit/src/test/java/it/spid/cie/oidc/test/util/RPTestUtils.java +++ b/starter-kit/src/test/java/it/spid/cie/oidc/test/util/RPTestUtils.java @@ -322,7 +322,7 @@ public static String mockedTrustAnchorEntityConfiguration() throws Exception { payload.put( "metadata", new JSONObject().put("federation_entity", trustAnchorMetadata)); - JSONObject trustMarksIssuers = new JSONObject() + JSONObject trustMarkIssuers = new JSONObject() .put( "https://www.spid.gov.it/certification/rp/public", JSONUtil.asJSONArray( TM_ISSUER1, TM_ISSUER2)) @@ -333,7 +333,7 @@ public static String mockedTrustAnchorEntityConfiguration() throws Exception { "https://sgd.aa.it/onboarding", JSONUtil.asJSONArray( TM_ISSUER1)); - payload.put("trust_marks_issuers", trustMarksIssuers); + payload.put("trust_mark_issuers", trustMarkIssuers); payload.put("constraints", new JSONObject().put("max_path_length", 1)); JSONObject jwks = mockedTrustAnchorPrivateJWKS(); @@ -361,7 +361,7 @@ public static String mockedTrustMarkIssuer1EntityConfiguration() throws Exceptio payload.put( "metadata", new JSONObject().put("federation_entity", trustAnchorMetadata)); -// JSONObject trustMarksIssuers = new JSONObject() +// JSONObject trustMarkIssuers = new JSONObject() // .put( // "https://www.spid.gov.it/certification/rp/public", JSONUtil.asJSONArray( // TM_ISSUER1, TM_ISSUER2)) @@ -372,7 +372,7 @@ public static String mockedTrustMarkIssuer1EntityConfiguration() throws Exceptio // "https://sgd.aa.it/onboarding", JSONUtil.asJSONArray( // TM_ISSUER1)); // -// payload.put("trust_marks_issuers", trustMarksIssuers); +// payload.put("trust_mark_issuers", trustMarkIssuers); payload.put("constraints", new JSONObject().put("max_path_length", 1)); JSONObject jwks = mockedTrustAnchorPrivateJWKS();