[java-idp-plugin-vci] 01/04: Use JSON.stringify in all examples
Codeberg
noreply at shibboleth.net
Thu Nov 5 17:05:06 UTC 2026
This is an automated email from the git hooks/post-receive script.
codeberg pushed a commit to branch main
in repository java-idp-plugin-vci.
View the commit online:
https://codeberg.org/Shibboleth/java-idp-plugin-vci/commit/8161ac980a7342f69c976d2fb005b35039a6b17e
commit 8161ac980a7342f69c976d2fb005b35039a6b17e
Author: Janne Lauros <janne.lauros at csc.fi>
AuthorDate: Thu Nov 5 16:16:45 2026 +0200
Use JSON.stringify in all examples
---
README.md | 52 +++++++++++++++++++++++++---------------------------
1 file changed, 25 insertions(+), 27 deletions(-)
diff --git a/README.md b/README.md
index d1b617c..5d9e2c3 100644
--- a/README.md
+++ b/README.md
@@ -1201,15 +1201,15 @@ This is the same structure used by the Credential Offer API. Define the attribut
<InputAttributeDefinition ref="sn" />
<InputAttributeDefinition ref="eduPersonAffiliation" />
<Script><![CDATA[
- var credential = '['
- + '{"path":["diploma"],"value":"Scrum Master"},'
- + '{"path":["mail"],"value":"' + mail.getValues().get(0) + '"},'
- + '{"path":["eppn"],"value":"' + eduPersonPrincipalName.getValues().get(0) + '"},'
- + '{"path":["givenName"],"value":"' + givenName.getValues().get(0) + '"},'
- + '{"path":["familyName"],"value":"' + sn.getValues().get(0) + '"},'
- + '{"path":["affiliation"],"value":"' + eduPersonAffiliation.getValues().get(0) + '"}'
- + ']';
- GeantIncubatorDiploma.addValue(credential);
+ var claims = [
+ {"path": ["diploma"], "value": "Scrum Master"},
+ {"path": ["mail"], "value": String(mail.getValues().get(0))},
+ {"path": ["eppn"], "value": String(eduPersonPrincipalName.getValues().get(0))},
+ {"path": ["givenName"], "value": String(givenName.getValues().get(0))},
+ {"path": ["familyName"], "value": String(sn.getValues().get(0))},
+ {"path": ["affiliation"], "value": String(eduPersonAffiliation.getValues().get(0))}
+ ];
+ GeantIncubatorDiploma.addValue(JSON.stringify(claims));
]]></Script>
<AttributeEncoder xsi:type="oidc:OIDCString" name="GeantIncubatorDiploma_SDJWT" />
<AttributeEncoder xsi:type="oidc:OIDCString" name="GeantIncubatorDiploma_W3C" />
@@ -3445,15 +3445,15 @@ The mdoc paths differ from those of the SD-JWT VC credentials, so this credentia
<InputAttributeDefinition ref="givenName" />
<InputAttributeDefinition ref="sn" />
<Script><![CDATA[
- var ns = 'org.geant.incubator.1';
- var credential = '['
- + '{"path":["' + ns + '","diploma"],"value":"Scrum Master"},'
- + '{"path":["' + ns + '","issue_date"],"value":"2026-06-15"},'
- + '{"path":["' + ns + '","mail"],"value":"' + mail.getValues().get(0) + '"},'
- + '{"path":["' + ns + '","given_name"],"value":"' + givenName.getValues().get(0) + '"},'
- + '{"path":["' + ns + '","family_name"],"value":"' + sn.getValues().get(0) + '"}'
- + ']';
- GeantIncubatorDiplomaMdoc.addValue(credential);
+ var ns = "org.geant.incubator.1";
+ var claims = [
+ {"path": [ns, "diploma"], "value": "Scrum Master"},
+ {"path": [ns, "issue_date"], "value": "2026-06-15"},
+ {"path": [ns, "mail"], "value": String(mail.getValues().get(0))},
+ {"path": [ns, "given_name"], "value": String(givenName.getValues().get(0))},
+ {"path": [ns, "family_name"], "value": String(sn.getValues().get(0))}
+ ];
+ GeantIncubatorDiplomaMdoc.addValue(JSON.stringify(claims));
]]></Script>
<AttributeEncoder xsi:type="oidc:OIDCString" name="GeantIncubatorDiploma_MDOC" />
</AttributeDefinition>
@@ -4028,12 +4028,12 @@ The attribute has one value per dataset, and the encoder puts them in an array:
<InputAttributeDefinition ref="sn" />
<Script><![CDATA[
var degree = function(id, field) {
- return '{"dataset_id":"' + id + '","claims":['
- + '{"path":["degree"],"value":"Master of Science"},'
- + '{"path":["field"],"value":"' + field + '"},'
- + '{"path":["givenName"],"value":"' + givenName.getValues().get(0) + '"},'
- + '{"path":["familyName"],"value":"' + sn.getValues().get(0) + '"}'
- + ']}';
+ return JSON.stringify({"dataset_id": id, "claims": [
+ {"path": ["degree"], "value": "Master of Science"},
+ {"path": ["field"], "value": field},
+ {"path": ["givenName"], "value": String(givenName.getValues().get(0))},
+ {"path": ["familyName"], "value": String(sn.getValues().get(0))}
+ ]});
};
UniversityDegrees.addValue(degree('cs', 'Computer Science'));
UniversityDegrees.addValue(degree('math', 'Mathematics'));
@@ -4325,9 +4325,7 @@ The picture is shortened here.
</details>
The type of a value in the credential is the JSON type you give it here, `"70"` is a string and
-`70` a number. The script builds the claims as objects and serializes them with `JSON.stringify`,
-instead of joining strings as in Step 1. This preserves `true` as a Boolean and `70` and `1.82` as numbers. If you build the value by
-joining strings, you have to omit the quotation marks yourself.
+`70` a number. `JSON.stringify` keeps `true` as a Boolean and `70` and `1.82` as numbers.
The values of IdP attributes are strings. Convert them before they go to the list:
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list