[java-idp-plugin-vci] branch main updated: Nonce response with c_nonce only and no-cache headers set once

Codeberg noreply at shibboleth.net
Thu Oct 22 14:12:13 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/9545af17d47ca0d337bee3642ebbb8a6a7794eba

The following commit(s) were added to refs/heads/main by this push:
     new 9545af1  Nonce response with c_nonce only and no-cache headers set once
9545af1 is described below

commit 9545af17d47ca0d337bee3642ebbb8a6a7794eba
Author: Janne Lauros <janne.lauros at csc.fi>
AuthorDate: Thu Oct 22 17:11:45 2026 +0300

    Nonce response with c_nonce only and no-cache headers set once
---
 .../messaging/impl/NonceSuccessResponse.java       | 26 +++++-----------------
 .../impl/FormOutboundNonceResponseMessage.java     | 10 +++++++++
 .../idp/flows/openid/vci/nonce/nonce-beans.xml     |  2 +-
 3 files changed, 16 insertions(+), 22 deletions(-)

diff --git a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/messaging/impl/NonceSuccessResponse.java b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/messaging/impl/NonceSuccessResponse.java
index 56bd6ac..a45fb96 100644
--- a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/messaging/impl/NonceSuccessResponse.java
+++ b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/messaging/impl/NonceSuccessResponse.java
@@ -18,34 +18,24 @@ package org.geant.shibboleth.plugin.openidvci.messaging.impl;
 
 import javax.annotation.Nonnull;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
 import com.nimbusds.common.contenttype.ContentType;
 import com.nimbusds.oauth2.sdk.SuccessResponse;
 import com.nimbusds.oauth2.sdk.http.HTTPResponse;
 
+import net.minidev.json.JSONObject;
 import net.shibboleth.shared.annotation.constraint.NotEmpty;
 
 /**
- * hhttps://openid.net/specs/openid-4-verifiable-credential-issuance-1_0.html#name-nonce-response
+ * https://openid.net/specs/openid-4-verifiable-credential-issuance-1_0.html#name-nonce-response
  * 
  * Forms a nonce response.
  *
  */
 public class NonceSuccessResponse implements SuccessResponse {
-    
-    /** Class logger. */
-    @Nonnull
-    private Logger log = LoggerFactory.getLogger(NonceSuccessResponse.class);
 
     /** c_nonce. */
     @Nonnull
     @NotEmpty
-    @JsonProperty("c_nonce")
     private final String cNonce;
 
     /**
@@ -81,15 +71,9 @@ public class NonceSuccessResponse implements SuccessResponse {
     public HTTPResponse toHTTPResponse() {
         final HTTPResponse httpResponse = new HTTPResponse(HTTPResponse.SC_OK);
         httpResponse.setEntityContentType(ContentType.APPLICATION_JSON);
-        //httpResponse.setCacheControl("no-store");
-        httpResponse.setPragma("no-cache");
-        try {
-            httpResponse.setContent(new ObjectMapper().writeValueAsString(this));
-        } catch (final JsonProcessingException e) {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
-            return null;
-        }
+        final JSONObject content = new JSONObject();
+        content.put("c_nonce", cNonce);
+        httpResponse.setContent(content.toJSONString());
         return httpResponse;
     }
 
diff --git a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/FormOutboundNonceResponseMessage.java b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/FormOutboundNonceResponseMessage.java
index f767a41..ff7a6ef 100644
--- a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/FormOutboundNonceResponseMessage.java
+++ b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/FormOutboundNonceResponseMessage.java
@@ -21,6 +21,8 @@ import java.util.function.Function;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 
+import jakarta.servlet.http.HttpServletResponse;
+
 import org.geant.shibboleth.plugin.openidvci.profile.config.OpenIDVCIConfiguration;
 import org.geant.shibboleth.plugin.openidvci.messaging.impl.NonceSuccessResponse;
 import org.opensaml.messaging.context.navigate.ChildContextLookup;
@@ -33,6 +35,7 @@ import net.shibboleth.idp.profile.IdPEventIds;
 import net.shibboleth.profile.config.ProfileConfiguration;
 import net.shibboleth.profile.context.RelyingPartyContext;
 import net.shibboleth.shared.logic.Constraint;
+import net.shibboleth.shared.servlet.HttpServletSupport;
 
 /**
  * Action forming {@link NonceSuccessResponse}.
@@ -111,6 +114,13 @@ public class FormOutboundNonceResponseMessage extends AbstractProfileAction {
             ActionSupport.buildEvent(profileRequestContext, IdPEventIds.INVALID_PROFILE_CONFIG);
             return;
         }
+        final HttpServletResponse response = getHttpServletResponse();
+        if (response == null) {
+            log.error("{} Could not fetch HttpServletResponse", getLogPrefix());
+            ActionSupport.buildEvent(profileRequestContext, IdPEventIds.INVALID_PROFILE_CONFIG);
+            return;
+        }
+        HttpServletSupport.addNoCacheHeaders(response);
         profileRequestContext.ensureOutboundMessageContext().setMessage(new NonceSuccessResponse(nonce));
     }
 }
\ No newline at end of file
diff --git a/openid-vci-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/openid/vci/nonce/nonce-beans.xml b/openid-vci-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/openid/vci/nonce/nonce-beans.xml
index 60fae60..f9a9562 100644
--- a/openid-vci-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/openid/vci/nonce/nonce-beans.xml
+++ b/openid-vci-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/openid/vci/nonce/nonce-beans.xml
@@ -22,7 +22,7 @@
         class="net.shibboleth.idp.plugin.oidc.op.profile.impl.InitializeUnverifiedRelyingPartyContext" scope="prototype" />
     
   <bean id="FormOutboundMessage" class="org.geant.shibboleth.plugin.openidvci.profile.impl.FormOutboundNonceResponseMessage"
-        scope="prototype" />
+        scope="prototype" p:httpServletResponseSupplier-ref="shibboleth.HttpServletResponseSupplier" />
  
   <bean id="BuildErrorResponseFromEvent" class="net.shibboleth.oidc.profile.impl.BuildJSONErrorResponseFromEvent" 
         scope="prototype" p:defaultStatusCode="500" p:defaultCode="server_error"

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


More information about the commits mailing list