[java-idp-plugin-vci] 04/04: status-list assignments review, OP conventions, client auth is now required, mapping auth errors, shared store bean, response headers, decoder loggin

Codeberg noreply at shibboleth.net
Wed Nov 11 10:42:20 UTC 2026


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

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

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

commit 7cf0dad4cf1ffc8b3ac3e6817fccc9f2fb383da9
Author: Janne Lauros <janne.lauros at csc.fi>
AuthorDate: Wed Nov 11 12:41:18 2026 +0200

     status-list assignments review, OP conventions, client auth is now required, mapping auth errors, shared store bean, response headers, decoder loggin
---
 .../impl/StatusListAssignmentsRequestDecoder.java  |  21 +++-
 .../impl/StatusListAssignmentsRequest.java         |  33 ++----
 .../impl/StatusListAssignmentsSuccessResponse.java |   4 -
 .../DefaultStatusListAssignmentsConfiguration.java |   5 +
 ...tboundStatusListAssignmentsResponseMessage.java |  14 ++-
 .../META-INF/net.shibboleth.idp/postconfig.xml     |   7 ++
 .../oauth/status-list/assign/assign-beans.xml      |   7 --
 .../status-list/assignments/assignments-beans.xml  |  40 +++++--
 .../StatusListAssignmentsRequestDecoderTest.java   | 109 +++++++++++++++++++
 .../impl/StatusListAssignmentsRequestTest.java     | 121 +++++++++++++++++++++
 ...aultStatusListAssignmentsConfigurationTest.java |  48 ++++++++
 ...ndStatusListAssignmentsResponseMessageTest.java |  41 +++++++
 .../storage/StatusListAssignmentsTest.java         |  77 +++++++++++++
 13 files changed, 475 insertions(+), 52 deletions(-)

diff --git a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/statuslist/decoding/impl/StatusListAssignmentsRequestDecoder.java b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/statuslist/decoding/impl/StatusListAssignmentsRequestDecoder.java
index ba67c30..c0ab2b4 100644
--- a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/statuslist/decoding/impl/StatusListAssignmentsRequestDecoder.java
+++ b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/statuslist/decoding/impl/StatusListAssignmentsRequestDecoder.java
@@ -19,11 +19,15 @@ package org.geant.shibboleth.plugin.openidvci.statuslist.decoding.impl;
 import java.io.IOException;
 
 import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
 
 import org.geant.shibboleth.plugin.openidvci.statuslist.messaging.impl.StatusListAssignmentsRequest;
+import org.opensaml.messaging.decoder.MessageDecodingException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import net.shibboleth.idp.plugin.oidc.op.decoding.impl.RequestUtil;
 import net.shibboleth.idp.plugin.oidc.op.oauth2.decoding.impl.BaseOAuth2RequestDecoder;
-import org.opensaml.messaging.decoder.MessageDecodingException;
 
 import com.google.common.base.MoreObjects;
 import com.nimbusds.oauth2.sdk.ParseException;
@@ -36,6 +40,10 @@ import com.nimbusds.oauth2.sdk.http.JakartaServletUtils;
 public class StatusListAssignmentsRequestDecoder
         extends BaseOAuth2RequestDecoder<StatusListAssignmentsRequest> {
 
+    /** Class logger. */
+    @Nonnull
+    private final Logger log = LoggerFactory.getLogger(StatusListAssignmentsRequestDecoder.class);
+
     /** {@inheritDoc} */
     @Override
     protected StatusListAssignmentsRequest parseMessage() throws MessageDecodingException {
@@ -44,15 +52,20 @@ public class StatusListAssignmentsRequestDecoder
             getProtocolMessageLogger().trace("Inbound request {}", RequestUtil.toString(httpRequest));
             return StatusListAssignmentsRequest.parse(httpRequest);
         } catch (final ParseException | IOException e) {
+            log.error("Unable to decode inbound request: {}", e.getMessage());
             throw new MessageDecodingException(e);
         }
     }
 
     /** {@inheritDoc} */
     @Override
-    protected String getMessageToLog(@Nonnull final StatusListAssignmentsRequest message) {
-        return MoreObjects.toStringHelper(this).omitNullValues().add("from", message.getFrom())
-                .add("limit", message.getLimit()).toString();
+    protected String getMessageToLog(@Nullable final StatusListAssignmentsRequest message) {
+        return message == null ? null : MoreObjects.toStringHelper(this).omitNullValues()
+                .add("from", message.getFrom())
+                .add("limit", message.getLimit())
+                .add("clientAuthentication", RequestUtil.getClientAuthenticationLog(message.getClientAuthentication()))
+                .add("endpointURI", getEndpointURI(message))
+                .toString();
     }
 
 }
diff --git a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/statuslist/messaging/impl/StatusListAssignmentsRequest.java b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/statuslist/messaging/impl/StatusListAssignmentsRequest.java
index 631fd0c..dc6ebe3 100644
--- a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/statuslist/messaging/impl/StatusListAssignmentsRequest.java
+++ b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/statuslist/messaging/impl/StatusListAssignmentsRequest.java
@@ -32,7 +32,6 @@ import com.nimbusds.oauth2.sdk.OAuth2Error;
 import com.nimbusds.oauth2.sdk.ParseException;
 import com.nimbusds.oauth2.sdk.auth.ClientAuthentication;
 import com.nimbusds.oauth2.sdk.http.HTTPRequest;
-import com.nimbusds.oauth2.sdk.id.ClientID;
 
 /**
  * Request for a page of records of status list assignments.
@@ -70,16 +69,6 @@ public class StatusListAssignmentsRequest extends AbstractOptionallyIdentifiedRe
         super(uri, clientAuthentication);
     }
 
-    /**
-     * Constructor for a request identifying its client without authenticating.
-     *
-     * @param uri      endpoint the request was made to
-     * @param clientId client identifier
-     */
-    protected StatusListAssignmentsRequest(@Nullable final URI uri, @Nonnull final ClientID clientId) {
-        super(uri, clientId);
-    }
-
     /**
      * Get position to read from.
      *
@@ -141,6 +130,10 @@ public class StatusListAssignmentsRequest extends AbstractOptionallyIdentifiedRe
             throw new ParseException(e.getMessage(),
                     OAuth2Error.INVALID_REQUEST.appendDescription(": " + e.getMessage()));
         }
+        if (clientAuthentication == null) {
+            throw new ParseException("Missing client authentication",
+                    OAuth2Error.INVALID_CLIENT.appendDescription(": no client authentication"));
+        }
 
         final Map<String, Object> payload;
         try {
@@ -149,7 +142,11 @@ public class StatusListAssignmentsRequest extends AbstractOptionallyIdentifiedRe
                     });
         } catch (final JsonProcessingException e) {
             throw new ParseException(e.getMessage(),
-                    OAuth2Error.INVALID_REQUEST.appendDescription(": " + e.getMessage()));
+                    OAuth2Error.INVALID_REQUEST.appendDescription(": request body is not a JSON object"));
+        }
+        if (payload == null) {
+            throw new ParseException("Request body is not a JSON object",
+                    OAuth2Error.INVALID_REQUEST.appendDescription(": request body is not a JSON object"));
         }
 
         final URI uri;
@@ -159,17 +156,7 @@ public class StatusListAssignmentsRequest extends AbstractOptionallyIdentifiedRe
             throw new ParseException(e.getMessage(), e);
         }
 
-        final StatusListAssignmentsRequest request;
-        if (clientAuthentication != null) {
-            request = new StatusListAssignmentsRequest(uri, clientAuthentication);
-        } else {
-            final Object clientId = payload.get("client_id");
-            if (!(clientId instanceof String value) || value.isEmpty()) {
-                throw new ParseException("Missing client authentication",
-                        OAuth2Error.INVALID_CLIENT.appendDescription(": no client authentication or client_id"));
-            }
-            request = new StatusListAssignmentsRequest(uri, new ClientID(value));
-        }
+        final StatusListAssignmentsRequest request = new StatusListAssignmentsRequest(uri, clientAuthentication);
 
         final Object from = payload.get(FROM_KEY);
         if (from != null) {
diff --git a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/statuslist/messaging/impl/StatusListAssignmentsSuccessResponse.java b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/statuslist/messaging/impl/StatusListAssignmentsSuccessResponse.java
index e3fd8c4..0d3cd70 100644
--- a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/statuslist/messaging/impl/StatusListAssignmentsSuccessResponse.java
+++ b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/statuslist/messaging/impl/StatusListAssignmentsSuccessResponse.java
@@ -28,8 +28,6 @@ import com.nimbusds.oauth2.sdk.http.HTTPResponse;
 
 /**
  * Response carrying a page of records of status list assignments.
- *
- * The records describe what was issued, so the response is not to be cached.
  */
 public class StatusListAssignmentsSuccessResponse implements SuccessResponse {
 
@@ -67,8 +65,6 @@ public class StatusListAssignmentsSuccessResponse 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(records.serialize());
         } catch (final JsonProcessingException e) {
diff --git a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/statuslist/profile/config/impl/DefaultStatusListAssignmentsConfiguration.java b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/statuslist/profile/config/impl/DefaultStatusListAssignmentsConfiguration.java
index 3d2138c..a8b022c 100644
--- a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/statuslist/profile/config/impl/DefaultStatusListAssignmentsConfiguration.java
+++ b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/statuslist/profile/config/impl/DefaultStatusListAssignmentsConfiguration.java
@@ -33,6 +33,11 @@ public class DefaultStatusListAssignmentsConfiguration extends AbstractOpenIDVCI
     @NotEmpty
     public static final String PROFILE_ID = "http://geant.org/ns/profiles/oauth/status-list/assignments";
 
+    /** Status list assignments profile counter name. */
+    @Nonnull
+    @NotEmpty
+    public static final String PROFILE_COUNTER = "net.shibboleth.idp.profiles.oauth.status-list.assignments";
+
     /** Constructor. */
     public DefaultStatusListAssignmentsConfiguration() {
         super(PROFILE_ID);
diff --git a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/statuslist/profile/impl/FormOutboundStatusListAssignmentsResponseMessage.java b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/statuslist/profile/impl/FormOutboundStatusListAssignmentsResponseMessage.java
index a8889fa..5be0279 100644
--- a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/statuslist/profile/impl/FormOutboundStatusListAssignmentsResponseMessage.java
+++ b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/statuslist/profile/impl/FormOutboundStatusListAssignmentsResponseMessage.java
@@ -22,12 +22,15 @@ import java.util.function.Function;
 
 import javax.annotation.Nonnull;
 
+import jakarta.servlet.http.HttpServletResponse;
 import net.shibboleth.idp.profile.AbstractProfileAction;
+import net.shibboleth.idp.profile.IdPEventIds;
 import net.shibboleth.shared.annotation.constraint.NonnullAfterInit;
 import net.shibboleth.shared.annotation.constraint.NonnullBeforeExec;
 import net.shibboleth.shared.component.ComponentInitializationException;
 import net.shibboleth.shared.logic.Constraint;
 import net.shibboleth.shared.primitive.LoggerFactory;
+import net.shibboleth.shared.servlet.HttpServletSupport;
 
 import org.geant.shibboleth.plugin.openidvci.statuslist.messaging.impl.StatusListAssignmentsRequest;
 import org.geant.shibboleth.plugin.openidvci.statuslist.messaging.impl.StatusListAssignmentsSuccessResponse;
@@ -43,7 +46,6 @@ import org.slf4j.Logger;
  * Action reading a page of records of status list assignments and forming
  * {@link StatusListAssignmentsSuccessResponse}, leaving out records of Credential Configurations not allowed for the
  * client.
- *
  */
 public class FormOutboundStatusListAssignmentsResponseMessage extends AbstractProfileAction {
 
@@ -53,7 +55,7 @@ public class FormOutboundStatusListAssignmentsResponseMessage extends AbstractPr
 
     /** Class logger. */
     @Nonnull
-    private Logger log = LoggerFactory.getLogger(FormOutboundStatusListAssignmentsResponseMessage.class);
+    private final Logger log = LoggerFactory.getLogger(FormOutboundStatusListAssignmentsResponseMessage.class);
 
     /** Store holding the records. */
     @NonnullAfterInit
@@ -126,6 +128,13 @@ public class FormOutboundStatusListAssignmentsResponseMessage extends AbstractPr
     protected void doExecute(@Nonnull final ProfileRequestContext profileRequestContext) {
         assert request != null;
 
+        final HttpServletResponse response = getHttpServletResponse();
+        if (response == null) {
+            log.error("{} Could not fetch HttpServletResponse", getLogPrefix());
+            ActionSupport.buildEvent(profileRequestContext, IdPEventIds.INVALID_PROFILE_CONFIG);
+            return;
+        }
+
         final StatusListAssignments records;
         try {
             records = statusListAssignmentStore.read(request.getFrom(), request.getLimit());
@@ -141,6 +150,7 @@ public class FormOutboundStatusListAssignmentsResponseMessage extends AbstractPr
                         .filter(assignment -> isAllowed(assignment, allowed)).toList(), records.getNext(),
                         records.getHighWater());
 
+        HttpServletSupport.addNoCacheHeaders(response);
         profileRequestContext.ensureOutboundMessageContext()
                 .setMessage(new StatusListAssignmentsSuccessResponse(visible));
 
diff --git a/openid-vci-impl/src/main/resources/META-INF/net.shibboleth.idp/postconfig.xml b/openid-vci-impl/src/main/resources/META-INF/net.shibboleth.idp/postconfig.xml
index 7902541..49339c9 100644
--- a/openid-vci-impl/src/main/resources/META-INF/net.shibboleth.idp/postconfig.xml
+++ b/openid-vci-impl/src/main/resources/META-INF/net.shibboleth.idp/postconfig.xml
@@ -61,6 +61,13 @@
         p:storage-ref="#{'%{openidvci.status-list.index.StorageService:shibboleth.StorageService}'.trim()}"
         p:permutationKey="%{openidvci.status-list.index.permutationKey:}" />
 
+    <bean id="openidvci.status-list.AssignmentStore"
+        class="org.geant.shibboleth.plugin.openidvci.statuslist.storage.StatusListAssignmentStore"
+        lazy-init="true" depends-on="shibboleth.LoggingService"
+        p:id="openidvci.status-list.AssignmentStore"
+        p:retention="%{openidvci.status-list.assignment.retention:P7D}"
+        p:storage-ref="#{'%{openidvci.status-list.assignment.StorageService:shibboleth.StorageService}'.trim()}" />
+
     <bean id="openidvci.DefaultAttestationTrustEvaluator" lazy-init="true"
         class="org.opensaml.security.x509.impl.CertPathPKIXTrustEvaluator">
         <property name="pKIXValidationOptions">
diff --git a/openid-vci-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/oauth/status-list/assign/assign-beans.xml b/openid-vci-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/oauth/status-list/assign/assign-beans.xml
index 9756e3d..79c4024 100644
--- a/openid-vci-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/oauth/status-list/assign/assign-beans.xml
+++ b/openid-vci-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/oauth/status-list/assign/assign-beans.xml
@@ -37,13 +37,6 @@
     </property>
   </bean>
 
-  <bean id="openidvci.status-list.AssignmentStore"
-        class="org.geant.shibboleth.plugin.openidvci.statuslist.storage.StatusListAssignmentStore"
-        depends-on="shibboleth.LoggingService"
-        p:id="openidvci.status-list.AssignmentStore"
-        p:retention="%{openidvci.status-list.assignment.retention:P7D}"
-        p:storage-ref="#{'%{openidvci.status-list.assignment.StorageService:shibboleth.StorageService}'.trim()}" />
-
   <bean id="AssignIndex"
         class="org.geant.shibboleth.plugin.openidvci.statuslist.profile.impl.AssignIndex"
         scope="prototype"
diff --git a/openid-vci-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/oauth/status-list/assignments/assignments-beans.xml b/openid-vci-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/oauth/status-list/assignments/assignments-beans.xml
index 11b7885..88547cd 100644
--- a/openid-vci-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/oauth/status-list/assignments/assignments-beans.xml
+++ b/openid-vci-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/oauth/status-list/assignments/assignments-beans.xml
@@ -12,14 +12,17 @@
        default-init-method="initialize" default-destroy-method="destroy">
 
   <bean id="openidvci.profileId" class="java.lang.String"
-        c:_0="http://geant.org/ns/profiles/oauth/status-list/assignments"/>
+        c:_0="#{T(org.geant.shibboleth.plugin.openidvci.statuslist.profile.config.impl.DefaultStatusListAssignmentsConfiguration).PROFILE_ID}"/>
   <bean id="openidvci.loggingId" class="java.lang.String"
         c:_0="%{openidvci.logging.status-list.assignments:OAuth.StatusList.Assignments}"/>
+  <util:constant id="shibboleth.metrics.ProfileCounter"
+        static-field="org.geant.shibboleth.plugin.openidvci.statuslist.profile.config.impl.DefaultStatusListAssignmentsConfiguration.PROFILE_COUNTER"/>
 
   <bean id="OpenIDVCIDecodeMessage" class="org.opensaml.profile.action.impl.DecodeMessage" scope="prototype">
     <constructor-arg>
       <bean class="org.geant.shibboleth.plugin.openidvci.statuslist.decoding.impl.StatusListAssignmentsRequestDecoder"
-            scope="prototype" p:httpServletRequestSupplier-ref="shibboleth.HttpServletRequestSupplier" />
+            scope="prototype" p:httpServletRequestSupplier-ref="shibboleth.HttpServletRequestSupplier"
+            p:removeIpAddressFromEndpointUri="%{idp.oidc.logging.removeIpAddressFromProtocolMessage:false}" />
     </constructor-arg>
   </bean>
 
@@ -28,18 +31,13 @@
         scope="prototype" />
 
   <bean id="shibboleth.ClientIDLookupStrategy"
-        class="net.shibboleth.idp.plugin.oidc.op.messaging.context.navigate.TokenRequestClientIDLookupFunction" />
-
-  <bean id="openidvci.status-list.AssignmentStore"
-        class="org.geant.shibboleth.plugin.openidvci.statuslist.storage.StatusListAssignmentStore"
-        depends-on="shibboleth.LoggingService"
-        p:id="openidvci.status-list.AssignmentStore"
-        p:retention="%{openidvci.status-list.assignment.retention:P7D}"
-        p:storage-ref="#{'%{openidvci.status-list.assignment.StorageService:shibboleth.StorageService}'.trim()}" />
+        class="net.shibboleth.idp.plugin.oidc.op.messaging.context.navigate.TokenRequestClientIDLookupFunction"
+        scope="prototype" />
 
   <bean id="OpenIDVCIFormOutboundMessage"
         class="org.geant.shibboleth.plugin.openidvci.statuslist.profile.impl.FormOutboundStatusListAssignmentsResponseMessage"
         scope="prototype"
+        p:httpServletResponseSupplier-ref="shibboleth.HttpServletResponseSupplier"
         p:statusListAssignmentStore-ref="openidvci.status-list.AssignmentStore"
         p:allowedCredentialConfigurationsLookupStrategy-ref="openidvci.AllowedCredentialConfigurationsLookup" />
 
@@ -51,10 +49,28 @@
     </property>
     <property name="mappedErrors">
       <map value-type="com.nimbusds.oauth2.sdk.ErrorObject">
-        <entry key="#{T(org.opensaml.profile.action.EventIds).INVALID_MSG_CTX}"
-               value="#{T(com.nimbusds.oauth2.sdk.OAuth2Error).INVALID_REQUEST}" />
+        <entry key="#{T(net.shibboleth.idp.authn.AuthnEventIds).AUTHN_EXCEPTION}"
+               value="#{T(com.nimbusds.oauth2.sdk.OAuth2Error).INVALID_CLIENT}" />
+        <entry key="#{T(net.shibboleth.idp.authn.AuthnEventIds).SUBJECT_C14N_ERROR}"
+               value="#{T(com.nimbusds.oauth2.sdk.OAuth2Error).INVALID_CLIENT}" />
+        <entry key="#{T(net.shibboleth.idp.authn.AuthnEventIds).UNKNOWN_USERNAME}"
+               value="#{T(com.nimbusds.oauth2.sdk.OAuth2Error).INVALID_CLIENT}" />
+        <entry key="#{T(net.shibboleth.idp.authn.AuthnEventIds).NO_CREDENTIALS}"
+               value="#{T(com.nimbusds.oauth2.sdk.OAuth2Error).INVALID_CLIENT}" />
+        <entry key="#{T(net.shibboleth.idp.authn.AuthnEventIds).INVALID_CREDENTIALS}"
+               value="#{T(com.nimbusds.oauth2.sdk.OAuth2Error).INVALID_CLIENT}" />
+        <entry key="#{T(net.shibboleth.idp.authn.AuthnEventIds).ACCOUNT_LOCKED}"
+               value="#{T(com.nimbusds.oauth2.sdk.OAuth2Error).INVALID_CLIENT}" />
+        <entry key="#{T(net.shibboleth.idp.authn.AuthnEventIds).ACCOUNT_ERROR}"
+               value="#{T(com.nimbusds.oauth2.sdk.OAuth2Error).INVALID_CLIENT}" />
+        <entry key="#{T(net.shibboleth.idp.authn.AuthnEventIds).RESELECT_FLOW}"
+               value="#{T(com.nimbusds.oauth2.sdk.OAuth2Error).INVALID_CLIENT}" />
+        <entry key="#{T(net.shibboleth.idp.authn.AuthnEventIds).NO_POTENTIAL_FLOW}"
+               value="#{T(com.nimbusds.oauth2.sdk.OAuth2Error).INVALID_CLIENT}" />
         <entry key="#{T(org.opensaml.profile.action.EventIds).ACCESS_DENIED}"
                value="#{T(com.nimbusds.oauth2.sdk.OAuth2Error).INVALID_CLIENT}" />
+        <entry key="#{T(net.shibboleth.idp.profile.IdPEventIds).INVALID_PROFILE_CONFIG}"
+               value="#{T(com.nimbusds.oauth2.sdk.OAuth2Error).UNAUTHORIZED_CLIENT}" />
         <entry key="#{T(org.opensaml.profile.action.EventIds).IO_ERROR}"
                value="#{T(com.nimbusds.oauth2.sdk.OAuth2Error).SERVER_ERROR}" />
       </map>
diff --git a/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/statuslist/decoding/impl/StatusListAssignmentsRequestDecoderTest.java b/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/statuslist/decoding/impl/StatusListAssignmentsRequestDecoderTest.java
new file mode 100644
index 0000000..2f90d20
--- /dev/null
+++ b/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/statuslist/decoding/impl/StatusListAssignmentsRequestDecoderTest.java
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2025, GÉANT
+ *
+ * Licensed under the Apache License, Version 2.0 (the “License”); you may not
+ * use this file except in compliance with the License. You may obtain a copy
+ * of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an “AS IS” BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.geant.shibboleth.plugin.openidvci.statuslist.decoding.impl;
+
+import org.geant.shibboleth.plugin.openidvci.statuslist.messaging.impl.StatusListAssignmentsRequest;
+import org.opensaml.messaging.decoder.MessageDecodingException;
+import org.springframework.mock.web.MockHttpServletRequest;
+import org.testng.Assert;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import jakarta.servlet.http.HttpServletRequest;
+import net.shibboleth.shared.component.ComponentInitializationException;
+import net.shibboleth.shared.primitive.NonnullSupplier;
+
+/** Tests for {@link StatusListAssignmentsRequestDecoder}. */
+public class StatusListAssignmentsRequestDecoderTest {
+
+    private MockHttpServletRequest httpRequest;
+
+    private StatusListAssignmentsRequestDecoder decoder;
+
+    @BeforeMethod
+    public void setUp() {
+        httpRequest = new MockHttpServletRequest();
+        httpRequest.setMethod("POST");
+        httpRequest.setScheme("https");
+        httpRequest.setServerName("10.0.0.1");
+        httpRequest.setLocalAddr("10.0.0.1");
+        httpRequest.setServerPort(443);
+        httpRequest.setRequestURI("/idp/profile/oauth/status-list/assignments");
+        httpRequest.setContentType("application/json");
+        httpRequest.setContent("{\"from\": 41337, \"limit\": 7}".getBytes());
+        decoder = new StatusListAssignmentsRequestDecoder();
+        decoder.setHttpServletRequestSupplier(new NonnullSupplier<>() {
+            public HttpServletRequest get() {
+                return httpRequest;
+            }
+        });
+    }
+
+    @Test
+    public void testDecode() throws ComponentInitializationException, MessageDecodingException {
+        httpRequest.addHeader("Authorization", "Basic Y2xpZW50OnA0c3N3MHJk");
+        decoder.initialize();
+        decoder.decode();
+
+        final StatusListAssignmentsRequest request =
+                (StatusListAssignmentsRequest) decoder.getMessageContext().getMessage();
+        Assert.assertEquals(request.getClientAuthentication().getClientID().getValue(), "client");
+        Assert.assertEquals(request.getFrom(), 41337L);
+        Assert.assertEquals(request.getLimit(), 7);
+    }
+
+    @Test
+    public void testNoClientAuthentication() throws ComponentInitializationException {
+        decoder.initialize();
+
+        Assert.assertThrows(MessageDecodingException.class, () -> decoder.decode());
+    }
+
+    @Test
+    public void testMessageToLog() throws ComponentInitializationException, MessageDecodingException {
+        httpRequest.addHeader("Authorization", "Basic Y2xpZW50OnA0c3N3MHJk");
+        decoder.initialize();
+        decoder.decode();
+
+        final String logged =
+                decoder.getMessageToLog((StatusListAssignmentsRequest) decoder.getMessageContext().getMessage());
+        Assert.assertTrue(logged.contains("from=41337"));
+        Assert.assertTrue(logged.contains("limit=7"));
+        Assert.assertTrue(logged.contains("client"));
+        Assert.assertFalse(logged.contains("p4ssw0rd"));
+        Assert.assertTrue(logged.contains("10.0.0.1"));
+    }
+
+    @Test
+    public void testMessageToLogWithoutIpAddress() throws ComponentInitializationException, MessageDecodingException {
+        httpRequest.addHeader("Authorization", "Basic Y2xpZW50OnA0c3N3MHJk");
+        decoder.setRemoveIpAddressFromEndpointUri(true);
+        decoder.initialize();
+        decoder.decode();
+
+        final String logged =
+                decoder.getMessageToLog((StatusListAssignmentsRequest) decoder.getMessageContext().getMessage());
+        Assert.assertTrue(logged.contains("/idp/profile/oauth/status-list/assignments"));
+        Assert.assertFalse(logged.contains("10.0.0.1"));
+    }
+
+    @Test
+    public void testNullMessageToLog() {
+        Assert.assertNull(decoder.getMessageToLog(null));
+    }
+
+}
diff --git a/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/statuslist/messaging/impl/StatusListAssignmentsRequestTest.java b/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/statuslist/messaging/impl/StatusListAssignmentsRequestTest.java
new file mode 100644
index 0000000..bd6f475
--- /dev/null
+++ b/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/statuslist/messaging/impl/StatusListAssignmentsRequestTest.java
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2025, GÉANT
+ *
+ * Licensed under the Apache License, Version 2.0 (the “License”); you may not
+ * use this file except in compliance with the License. You may obtain a copy
+ * of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an “AS IS” BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.geant.shibboleth.plugin.openidvci.statuslist.messaging.impl;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import com.nimbusds.oauth2.sdk.OAuth2Error;
+import com.nimbusds.oauth2.sdk.ParseException;
+import com.nimbusds.oauth2.sdk.http.HTTPRequest;
+
+/** Tests for {@link StatusListAssignmentsRequest}. */
+public class StatusListAssignmentsRequestTest {
+
+    private static HTTPRequest request(final String authorization, final String body)
+            throws URISyntaxException, ParseException {
+        final HTTPRequest httpRequest = new HTTPRequest(HTTPRequest.Method.POST, new URI("http://example.com"));
+        if (authorization != null) {
+            httpRequest.setAuthorization(authorization);
+        }
+        httpRequest.setContentType("application/json");
+        httpRequest.setBody(body);
+        return httpRequest;
+    }
+
+    private static void assertError(final String authorization, final String body, final String code) {
+        final ParseException e = Assert.expectThrows(ParseException.class,
+                () -> StatusListAssignmentsRequest.parse(request(authorization, body)));
+
+        Assert.assertEquals(e.getErrorObject().getCode(), code);
+    }
+
+    @Test
+    public void testAuthenticated() throws Exception {
+        final StatusListAssignmentsRequest request =
+                StatusListAssignmentsRequest.parse(request("Basic dGVzdDp0ZXN0", "{\"from\": 17, \"limit\": 5}"));
+
+        Assert.assertEquals(request.getClientAuthentication().getClientID().getValue(), "test");
+        Assert.assertEquals(request.getFrom(), 17L);
+        Assert.assertEquals(request.getLimit(), 5);
+    }
+
+    @Test
+    public void testDefaults() throws Exception {
+        final StatusListAssignmentsRequest request =
+                StatusListAssignmentsRequest.parse(request("Basic dGVzdDp0ZXN0", "{}"));
+
+        Assert.assertEquals(request.getFrom(), 0L);
+        Assert.assertEquals(request.getLimit(), StatusListAssignmentsRequest.DEFAULT_LIMIT);
+    }
+
+    @Test
+    public void testNoClientAuthentication() {
+        assertError(null, "{\"from\": 0}", OAuth2Error.INVALID_CLIENT.getCode());
+    }
+
+    @Test
+    public void testClientIdIsNotClientAuthentication() {
+        assertError(null, "{\"client_id\": \"test\", \"from\": 0}", OAuth2Error.INVALID_CLIENT.getCode());
+    }
+
+    @Test
+    public void testNoClientAuthenticationBeforeBody() {
+        assertError(null, "not json", OAuth2Error.INVALID_CLIENT.getCode());
+    }
+
+    @Test
+    public void testBodyNotJson() {
+        assertError("Basic dGVzdDp0ZXN0", "not json", OAuth2Error.INVALID_REQUEST.getCode());
+    }
+
+    @Test
+    public void testBodyNull() {
+        assertError("Basic dGVzdDp0ZXN0", "null", OAuth2Error.INVALID_REQUEST.getCode());
+    }
+
+    @Test
+    public void testBodyNotObject() {
+        assertError("Basic dGVzdDp0ZXN0", "[]", OAuth2Error.INVALID_REQUEST.getCode());
+    }
+
+    @Test
+    public void testNegativeFrom() {
+        assertError("Basic dGVzdDp0ZXN0", "{\"from\": -1}", OAuth2Error.INVALID_REQUEST.getCode());
+    }
+
+    @Test
+    public void testFromNotInteger() {
+        assertError("Basic dGVzdDp0ZXN0", "{\"from\": 1.5}", OAuth2Error.INVALID_REQUEST.getCode());
+    }
+
+    @Test
+    public void testLimitZero() {
+        assertError("Basic dGVzdDp0ZXN0", "{\"limit\": 0}", OAuth2Error.INVALID_REQUEST.getCode());
+    }
+
+    @Test
+    public void testLimitOverMaximum() {
+        assertError("Basic dGVzdDp0ZXN0",
+                "{\"limit\": " + (StatusListAssignmentsRequest.MAX_LIMIT + 1) + "}",
+                OAuth2Error.INVALID_REQUEST.getCode());
+    }
+
+}
diff --git a/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/statuslist/profile/config/impl/DefaultStatusListAssignmentsConfigurationTest.java b/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/statuslist/profile/config/impl/DefaultStatusListAssignmentsConfigurationTest.java
new file mode 100644
index 0000000..e8550db
--- /dev/null
+++ b/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/statuslist/profile/config/impl/DefaultStatusListAssignmentsConfigurationTest.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2025, GÉANT
+ *
+ * Licensed under the Apache License, Version 2.0 (the “License”); you may not
+ * use this file except in compliance with the License. You may obtain a copy
+ * of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an “AS IS” BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.geant.shibboleth.plugin.openidvci.statuslist.profile.config.impl;
+
+import java.util.List;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+/** Tests for {@link DefaultStatusListAssignmentsConfiguration}. */
+public class DefaultStatusListAssignmentsConfigurationTest {
+
+    @Test
+    public void testId() {
+        Assert.assertEquals(new DefaultStatusListAssignmentsConfiguration().getId(),
+                "http://geant.org/ns/profiles/oauth/status-list/assignments");
+    }
+
+    @Test
+    public void testCounter() {
+        Assert.assertEquals(DefaultStatusListAssignmentsConfiguration.PROFILE_COUNTER,
+                "net.shibboleth.idp.profiles.oauth.status-list.assignments");
+    }
+
+    @Test
+    public void testNoInterceptorFlowsByDefault() {
+        final DefaultStatusListAssignmentsConfiguration configuration =
+                new DefaultStatusListAssignmentsConfiguration();
+
+        Assert.assertEquals(configuration.getInboundInterceptorFlows(null), List.of());
+        Assert.assertEquals(configuration.getOutboundInterceptorFlows(null), List.of());
+    }
+
+}
diff --git a/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/statuslist/profile/impl/FormOutboundStatusListAssignmentsResponseMessageTest.java b/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/statuslist/profile/impl/FormOutboundStatusListAssignmentsResponseMessageTest.java
index 790bdf1..3deb2f6 100644
--- a/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/statuslist/profile/impl/FormOutboundStatusListAssignmentsResponseMessageTest.java
+++ b/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/statuslist/profile/impl/FormOutboundStatusListAssignmentsResponseMessageTest.java
@@ -29,6 +29,7 @@ import org.geant.shibboleth.plugin.openidvci.statuslist.storage.StatusListAssign
 import org.opensaml.messaging.context.MessageContext;
 import org.opensaml.profile.context.ProfileRequestContext;
 import org.opensaml.storage.impl.MemoryStorageService;
+import org.springframework.mock.web.MockHttpServletResponse;
 import org.springframework.webflow.execution.Event;
 import org.springframework.webflow.execution.RequestContext;
 import org.testng.Assert;
@@ -38,9 +39,12 @@ import org.testng.annotations.Test;
 
 import com.nimbusds.oauth2.sdk.http.HTTPRequest;
 
+import jakarta.servlet.http.HttpServletResponse;
+import net.shibboleth.idp.profile.IdPEventIds;
 import net.shibboleth.idp.profile.context.navigate.WebflowRequestContextProfileRequestContextLookup;
 import net.shibboleth.idp.profile.testing.ActionTestingSupport;
 import net.shibboleth.idp.profile.testing.RequestContextBuilder;
+import net.shibboleth.shared.primitive.NonnullSupplier;
 
 /**
  * Unit tests for {@link FormOutboundStatusListAssignmentsResponseMessage}.
@@ -55,6 +59,8 @@ public class FormOutboundStatusListAssignmentsResponseMessageTest {
 
     private ProfileRequestContext profileRequestCtx;
 
+    private MockHttpServletResponse httpResponse;
+
     private FormOutboundStatusListAssignmentsResponseMessage action;
 
     @BeforeMethod
@@ -82,6 +88,12 @@ public class FormOutboundStatusListAssignmentsResponseMessageTest {
 
         action = new FormOutboundStatusListAssignmentsResponseMessage();
         action.setStatusListAssignmentStore(store);
+        httpResponse = new MockHttpServletResponse();
+        action.setHttpServletResponseSupplier(new NonnullSupplier<>() {
+            public HttpServletResponse get() {
+                return httpResponse;
+            }
+        });
     }
 
     @AfterMethod
@@ -136,4 +148,33 @@ public class FormOutboundStatusListAssignmentsResponseMessageTest {
         Assert.assertEquals(records.getNext(), 3L);
     }
 
+    @Test
+    public void testCacheControlOnce() throws Exception {
+        httpResponse.addHeader("Cache-Control", "no-store");
+        action.initialize();
+        execute();
+
+        Assert.assertEquals(httpResponse.getHeaders("Cache-Control").size(), 1);
+        Assert.assertTrue(httpResponse.getHeader("Cache-Control").contains("no-store"));
+        Assert.assertEquals(httpResponse.getHeader("Pragma"), "no-cache");
+    }
+
+    @Test
+    public void testNoCacheControlOnNimbusResponse() throws Exception {
+        action.initialize();
+        final StatusListAssignments records = execute();
+
+        Assert.assertNull(new StatusListAssignmentsSuccessResponse(records).toHTTPResponse().getCacheControl());
+    }
+
+    @Test
+    public void testNoServletResponse() throws Exception {
+        final FormOutboundStatusListAssignmentsResponseMessage noResponse =
+                new FormOutboundStatusListAssignmentsResponseMessage();
+        noResponse.setStatusListAssignmentStore(store);
+        noResponse.initialize();
+
+        ActionTestingSupport.assertEvent(noResponse.execute(requestCtx), IdPEventIds.INVALID_PROFILE_CONFIG);
+    }
+
 }
diff --git a/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/statuslist/storage/StatusListAssignmentsTest.java b/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/statuslist/storage/StatusListAssignmentsTest.java
new file mode 100644
index 0000000..9205daa
--- /dev/null
+++ b/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/statuslist/storage/StatusListAssignmentsTest.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2025, GÉANT
+ *
+ * Licensed under the Apache License, Version 2.0 (the “License”); you may not
+ * use this file except in compliance with the License. You may obtain a copy
+ * of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an “AS IS” BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.geant.shibboleth.plugin.openidvci.statuslist.storage;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+/** Tests for {@link StatusListAssignments}. */
+public class StatusListAssignmentsTest {
+
+    private static StatusListAssignment record() {
+        final StatusListAssignment assignment = new StatusListAssignment();
+        assignment.setSeq(17L);
+        assignment.setId("2027-03");
+        assignment.setIndices(List.of(41337L));
+        assignment.setExpires(1802769445L);
+        assignment.setDetails(Map.of("credential_configuration_id", "ScopedCredential"));
+        return assignment;
+    }
+
+    @Test
+    public void testSerializedMembers() throws Exception {
+        final Map<String, Object> page = new ObjectMapper().readValue(
+                new StatusListAssignments(List.of(record()), 18L, 19L).serialize(),
+                new TypeReference<Map<String, Object>>() {
+                });
+
+        Assert.assertEquals(page.keySet(), Set.of("records", "next", "high_water"));
+        Assert.assertEquals(((Number) page.get("next")).longValue(), 18L);
+        Assert.assertEquals(((Number) page.get("high_water")).longValue(), 19L);
+    }
+
+    @Test
+    public void testSerializedRecordMembers() throws Exception {
+        final Map<String, Object> page = new ObjectMapper().readValue(
+                new StatusListAssignments(List.of(record()), 18L, 19L).serialize(),
+                new TypeReference<Map<String, Object>>() {
+                });
+
+        final List<?> records = (List<?>) page.get("records");
+        Assert.assertEquals(records.size(), 1);
+        Assert.assertEquals(((Map<?, ?>) records.get(0)).keySet(),
+                Set.of("seq", "id", "idx", "expires", "details"));
+    }
+
+    @Test
+    public void testEmptyPage() throws Exception {
+        final Map<String, Object> page = new ObjectMapper().readValue(
+                new StatusListAssignments(List.of(), 0L, 0L).serialize(), new TypeReference<Map<String, Object>>() {
+                });
+
+        Assert.assertEquals(page.keySet(), Set.of("records", "next", "high_water"));
+        Assert.assertTrue(((List<?>) page.get("records")).isEmpty());
+    }
+
+}

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


More information about the commits mailing list