[java-idp-plugin-vci] branch dev/VCDM updated: Minor hardening for mutability

Codeberg noreply at shibboleth.net
Mon Apr 27 17:09:36 UTC 2026


This is an automated email from the git hooks/post-receive script.

codeberg pushed a commit to branch dev/VCDM
in repository java-idp-plugin-vci.

View the commit online:
https://codeberg.org/Shibboleth/java-idp-plugin-vci/commit/22a30e0a0289473d4d7fb2a852d34cd901640379

The following commit(s) were added to refs/heads/dev/VCDM by this push:
     new 22a30e0  Minor hardening for mutability
22a30e0 is described below

commit 22a30e0a0289473d4d7fb2a852d34cd901640379
Author: Janne Lauros <janne.lauros at csc.fi>
AuthorDate: Mon Apr 27 20:09:07 2026 +0300

    Minor hardening for mutability
---
 ...FormJsonLdSelectiveDisclosureJWTCredential.java | 46 ++++++++++------------
 1 file changed, 20 insertions(+), 26 deletions(-)

diff --git a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/FormJsonLdSelectiveDisclosureJWTCredential.java b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/FormJsonLdSelectiveDisclosureJWTCredential.java
index 1c8f217..27a1fb8 100644
--- a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/FormJsonLdSelectiveDisclosureJWTCredential.java
+++ b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/FormJsonLdSelectiveDisclosureJWTCredential.java
@@ -42,9 +42,9 @@ import com.nimbusds.oauth2.sdk.ParseException;
 
 /**
  * Action that forms
- * {@link hhttps://www.w3.org/TR/2025/REC-vc-jose-cose-20250515/#with-sd-jwt}.
- * 
- * 
+ * {@link https://www.w3.org/TR/2025/REC-vc-jose-cose-20250515/#with-sd-jwt}.
+ *
+ *
  * Action verifies first that we are indeed forming 'vc+sd-jwt' type credential
  * and then combines content for disclosure
  * {@link CredentialsContext#getCredentialContent()} with credential shells
@@ -52,24 +52,22 @@ import com.nimbusds.oauth2.sdk.ParseException;
  * JWTs ready to be signed. The list is stored to
  * {@link CredentialsContext#setJWTCredentials}. The disclosure data is stored
  * to {@link CredentialsContext#setDisclosures}
- * 
+ *
  * TODO, only partial support. Missing still numerous fields not yet parsed by
  * {@link CredentialConfiguration}. Also id parameter is never set.
- * 
+ *
  */
 public class FormJsonLdSelectiveDisclosureJWTCredential extends AbstractProfileAction {
 
-    /** Class logger. */
     @Nonnull
-    private Logger log = LoggerFactory.getLogger(FormJsonLdSelectiveDisclosureJWTCredential.class);
+    private final Logger log = LoggerFactory.getLogger(FormJsonLdSelectiveDisclosureJWTCredential.class);
 
     @NonnullBeforeExec
     private CredentialsContext ctx;
 
     @NonnullBeforeExec
-    CredentialOfferRequestedCredential credential;
+    private CredentialOfferRequestedCredential credential;
 
-    /** {@inheritDoc} */
     @Override
     protected boolean doPreExecute(@Nonnull final ProfileRequestContext profileRequestContext) {
 
@@ -89,17 +87,17 @@ public class FormJsonLdSelectiveDisclosureJWTCredential extends AbstractProfileA
         }
         credential = ctx.getCredentialContent();
         if (credential == null) {
-            log.warn("{} No credential content in context, nothingh to do", getLogPrefix());
+            log.warn("{} No credential content in context, nothing to do", getLogPrefix());
             return false;
         }
         if (ctx.getCredentialShells() == null || ctx.getCredentialShells().isEmpty()) {
             log.warn("{} No shells stored to context, nothing to do", getLogPrefix());
             return false;
         }
+
         return true;
     }
 
-    /** {@inheritDoc} */
     @SuppressWarnings("unchecked")
     @Override
     protected void doExecute(@Nonnull final ProfileRequestContext profileRequestContext) {
@@ -108,26 +106,23 @@ public class FormJsonLdSelectiveDisclosureJWTCredential extends AbstractProfileA
         for (CredentialOfferRequestedClaim claim : credential.getRequestedCredential()) {
             List<String> path = new ArrayList<>(claim.getPath());
             path.remove(path.size() - 1);
-            if (sdMaps.get(path) == null) {
-                sdMaps.put(path, new HashMap<>());
-            }
-            sdMaps.get(path).put(claim.getPath().get(claim.getPath().size() - 1), claim.getValue());
+            List<String> key = List.copyOf(path);
+            String leafKey = claim.getPath().get(claim.getPath().size() - 1);
+            sdMaps.computeIfAbsent(key, k -> new HashMap<>()).put(leafKey, claim.getValue());
         }
         String disclosures = null;
         Map<String, Object> credentialSubject = new HashMap<>();
-        for (List<String> path : sdMaps.keySet()) {
+        for (Map.Entry<List<String>, Map<String, Object>> entry : sdMaps.entrySet()) {
+            List<String> path = entry.getKey();
+            Map<String, Object> claims = entry.getValue();
             Map<String, Object> map = credentialSubject;
-            for (int i = 1; i < path.size() - 1; i++) {
-                if (!map.containsKey(path.get(i))) {
-                    map.put(path.get(i), new HashMap<String, Object>());
-                }
-                map = ((Map<String, Object>) map.get(path.get(i)));
-                log.info("map is the value of {}", path.get(i));
+            for (String segment : path) {
+                map = (Map<String, Object>) map.computeIfAbsent(segment, k -> new HashMap<String, Object>());
             }
-            SelectiveDisclosureClaimSetUtil sdActClaims = new SelectiveDisclosureClaimSetUtil(sdMaps.get(path));
+            SelectiveDisclosureClaimSetUtil sdActClaims = new SelectiveDisclosureClaimSetUtil(claims);
             map.put("_sd", sdActClaims.get_sd());
-            disclosures = (disclosures == null ? sdActClaims.getFormattedDisclosures()
-                    : disclosures + "~" + sdActClaims.getFormattedDisclosures());
+            disclosures = (disclosures == null) ? sdActClaims.getFormattedDisclosures()
+                    : disclosures + "~" + sdActClaims.getFormattedDisclosures();
         }
         List<JWTClaimsSet> credentials = new ArrayList<>();
         ctx.getCredentialShells().forEach(cred -> {
@@ -139,7 +134,6 @@ public class FormJsonLdSelectiveDisclosureJWTCredential extends AbstractProfileA
             } catch (ParseException e) {
                 log.error("{} Parsing credential failed", getLogPrefix(), e);
                 ActionSupport.buildEvent(profileRequestContext, OpenIDVCIEventIds.INVALID_CREDENTIAL);
-                return;
             }
         });
         ctx.setJWTCredentials(credentials);

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list