Skip to content

Commit

Permalink
fix: aligned claims "trust_mark_issuer", "trust_marks_issuers" to tru…
Browse files Browse the repository at this point in the history
…st_mark_issuers
  • Loading branch information
rglauco committed Nov 2, 2023
1 parent 331ca7e commit f824f2b
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -79,8 +79,8 @@ public String getTrustMarks() {
return trustMarks;
}

public String getTrustMarksIssuers() {
return trustMarksIssuers;
public String getTrustMarkIssuers() {
return trustMarkIssuers;
}

public String getMetadata() {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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("{}");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,14 +250,14 @@ public Map<String, EntityConfiguration> getSuperiors(
return this.verifiedSuperiors;
}

public Map<String, Set<String>> getTrustMarksIssuers() {
public Map<String, Set<String>> gettrustMarkIssuers() {
Map<String, Set<String>> 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;
Expand Down Expand Up @@ -422,7 +422,7 @@ else if (!isTrustMarkAllowed(jsonTrustMark)) {
"Required Trust marks are missing.");
}

Map<String, Set<String>> trustAnchorIssuers = trustAnchor.getTrustMarksIssuers();
Map<String, Set<String>> trustAnchorIssuers = trustAnchor.gettrustMarkIssuers();

boolean valid = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -80,8 +80,8 @@ public String getTrustMarks() {
return trustMarks;
}

public String getTrustMarksIssuers() {
return trustMarksIssuers;
public String gettrustMarkIssuers() {
return trustMarkIssuers;
}

public boolean isActive() {
Expand Down Expand Up @@ -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;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -283,7 +283,7 @@ public void test_getTrustMarksIssuers() {
Map<String, Set<String>> res = null;

try {
res = ec.getTrustMarksIssuers();
res = ec.gettrustMarkIssuers();
}
catch (Exception e) {
catched = true;
Expand Down Expand Up @@ -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",
Expand All @@ -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();
Expand Down Expand Up @@ -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",
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void testFederationEntityClass() {
model.getMetadata();
model.getSubject();
model.getTrustMarks();
model.getTrustMarksIssuers();
model.gettrustMarkIssuers();
model.isActive();

LocalDateTime now = LocalDateTime.now();
Expand All @@ -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"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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));
Expand Down Expand Up @@ -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",
Expand All @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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();
Expand Down Expand Up @@ -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))
Expand All @@ -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();
Expand Down

0 comments on commit f824f2b

Please sign in to comment.