[java-idp-plugin-vci] 04/04: Status-list revoke flow, use IdP InitializeAuthenticationContext, OP base decoders, only allocated slots revoked, set response headers
Codeberg
noreply at shibboleth.net
Tue Nov 10 10:10:12 UTC 2026
This is an automated email from the git hooks/post-receive script.
codeberg pushed a commit to branch dev/REVIEWREVOKE
in repository java-idp-plugin-vci.
View the commit online:
https://codeberg.org/Shibboleth/java-idp-plugin-vci/commit/f4b708cc1608e1c08a381d4f9b0c9f437d9104fa
commit f4b708cc1608e1c08a381d4f9b0c9f437d9104fa
Author: Janne Lauros <janne.lauros at csc.fi>
AuthorDate: Tue Nov 10 12:09:28 2026 +0200
Status-list revoke flow, use IdP InitializeAuthenticationContext, OP base decoders, only allocated slots revoked, set response headers
---
.../decoding/impl/BaseOpenIDVCIRequestDecoder.java | 122 -------------
.../impl/CredentialOfferRequestDecoder.java | 8 +-
.../impl/OpenIDVCICredentialsRequestDecoder.java | 8 +-
.../impl/InitializeAuthenticationContext.java | 47 -----
.../impl/StatusListAssignmentsRequestDecoder.java | 4 +-
.../impl/StatusListRevokeRequestDecoder.java | 24 ++-
.../impl/StatusListRevokeSuccessResponse.java | 4 +-
...ormOutboundStatusListRevokeResponseMessage.java | 17 ++
.../profile/impl/RevokeStatusListIndex.java | 72 ++++++--
.../storage/FeistelIndexPermutation.java | 22 +++
.../storage/StatusListIndexAllocator.java | 20 ++
.../META-INF/net.shibboleth.idp/postconfig.xml | 7 +
.../oauth/status-list/assign/assign-beans.xml | 7 -
.../status-list/assignments/assignments-beans.xml | 2 +-
.../oauth/status-list/revoke/revoke-beans.xml | 16 +-
.../credential-offer/credential-offer-beans.xml | 2 +-
.../openid/vci/credentials/credentials-beans.xml | 2 +-
.../idp/flows/openid/vci/token/token-beans.xml | 3 -
.../idp/flows/openid/vci/token/token-flow.xml | 7 +-
.../impl/InitializeAuthenticationContextTest.java | 56 ------
.../impl/StatusListRevokeRequestDecoderTest.java | 108 +++++++++++
...utboundStatusListRevokeResponseMessageTest.java | 97 ++++++++++
.../profile/impl/RevokeStatusListIndexTest.java | 202 +++++++++++++++++++++
.../storage/FeistelIndexPermutationTest.java | 19 ++
.../storage/StatusListIndexAllocatorTest.java | 27 +++
25 files changed, 628 insertions(+), 275 deletions(-)
diff --git a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/decoding/impl/BaseOpenIDVCIRequestDecoder.java b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/decoding/impl/BaseOpenIDVCIRequestDecoder.java
deleted file mode 100644
index 2535230..0000000
--- a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/decoding/impl/BaseOpenIDVCIRequestDecoder.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * 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.
- */
-
-/*
- * Derived from net.shibboleth.idp.plugin.oidc.op.oauth2.decoding.impl.BaseOAuth2RequestDecoder
- * of the Shibboleth OpenID Connect Provider plugin, Apache License 2.0, modified by GÉANT.
- */
-
-package org.geant.shibboleth.plugin.openidvci.decoding.impl;
-
-import java.net.URI;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
-import org.opensaml.messaging.context.MessageContext;
-import org.opensaml.messaging.decoder.MessageDecodingException;
-import org.opensaml.messaging.decoder.servlet.AbstractHttpServletRequestMessageDecoder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.nimbusds.oauth2.sdk.Request;
-
-/**
- * Base decoder for Nimbus OAuth2 request messages in OpenID VCI context.
- *
- * @param <T> The exact type of the request message, extends {@link Request}.
- */
-public abstract class BaseOpenIDVCIRequestDecoder<T extends Request> extends AbstractHttpServletRequestMessageDecoder {
-
- /** Class logger. */
- @Nonnull
- private final Logger log = LoggerFactory.getLogger(BaseOpenIDVCIRequestDecoder.class);
-
- /** A flag to remove the IP address from the endpoint URI. */
- private boolean removeIpAddressFromEndpointUri;
-
- /** Constructor. */
- public BaseOpenIDVCIRequestDecoder() {
- super();
- setProtocolMessageLoggerSubCategory("OAUTH2.OpenIDVCI");
- }
-
- /**
- * Set the flag to remove the IP address from the endpoint URI.
- *
- * @param flag What to set.
- */
- public synchronized void setRemoveIpAddressFromEndpointUri(final boolean flag) {
- ifInitializedThrowUnmodifiabledComponentException();
- ifDestroyedThrowDestroyedComponentException();
-
- removeIpAddressFromEndpointUri = flag;
- }
-
- /** {@inheritDoc} */
- @Override
- protected void doDecode() throws MessageDecodingException {
- final MessageContext messageContext = new MessageContext();
- final T requestMessage = parseMessage();
- messageContext.setMessage(requestMessage);
- setMessageContext(messageContext);
- }
-
- /**
- * Parses the message into the exact type of the request message.
- *
- * @return The request message
- * @throws MessageDecodingException if there is a problem decoding the message
- * context
- */
- @Nullable
- protected abstract T parseMessage() throws MessageDecodingException;
-
- /**
- * Get the string representation of what will be logged as the protocol message.
- *
- * @param message the request message
- * @return the string representing the protocol message for logging purposes
- */
- @Nullable
- protected abstract String getMessageToLog(final T message);
-
- /** {@inheritDoc} */
- @Override
- @Nullable
- @SuppressWarnings("unchecked")
- protected String serializeMessageForLogging(@Nullable final Object message) {
- return getMessageToLog((T) message);
- }
-
- /**
- * Returns the endpoint URI either from servlet request or from the given
- * message, depending on the flag for removing IP address from the endpoint URI.
- *
- * @param message the message from which to take the endpoint URI (with IP
- * address), if the flag is false
- * @return the endpoint URI
- */
- @Nullable
- protected String getEndpointURI(final T message) {
- if (removeIpAddressFromEndpointUri) {
- return getHttpServletRequest().getRequestURI();
- } else {
- final URI endpointUri = message.getEndpointURI();
- return endpointUri != null ? endpointUri.toString() : null;
- }
- }
-}
diff --git a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/decoding/impl/CredentialOfferRequestDecoder.java b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/decoding/impl/CredentialOfferRequestDecoder.java
index 713e35c..2a03680 100644
--- a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/decoding/impl/CredentialOfferRequestDecoder.java
+++ b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/decoding/impl/CredentialOfferRequestDecoder.java
@@ -29,6 +29,7 @@ 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 com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -39,12 +40,17 @@ import com.nimbusds.oauth2.sdk.http.JakartaServletUtils;
/**
* Message decoder decoding {@link CredentialOfferRequest}s.
*/
-public class CredentialOfferRequestDecoder extends BaseOpenIDVCIRequestDecoder<CredentialOfferRequest> {
+public class CredentialOfferRequestDecoder extends BaseOAuth2RequestDecoder<CredentialOfferRequest> {
/** Class logger. */
@Nonnull
private final Logger log = LoggerFactory.getLogger(CredentialOfferRequestDecoder.class);
+ /** Constructor. */
+ public CredentialOfferRequestDecoder() {
+ setProtocolMessageLoggerSubCategory("OAUTH2.OpenIDVCI");
+ }
+
/** {@inheritDoc} */
@Override
protected CredentialOfferRequest parseMessage() throws MessageDecodingException {
diff --git a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/decoding/impl/OpenIDVCICredentialsRequestDecoder.java b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/decoding/impl/OpenIDVCICredentialsRequestDecoder.java
index 9154ca0..f06890e 100644
--- a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/decoding/impl/OpenIDVCICredentialsRequestDecoder.java
+++ b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/decoding/impl/OpenIDVCICredentialsRequestDecoder.java
@@ -26,6 +26,7 @@ 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 com.google.common.base.MoreObjects;
import com.nimbusds.oauth2.sdk.http.HTTPRequest;
@@ -34,12 +35,17 @@ import com.nimbusds.oauth2.sdk.http.JakartaServletUtils;
/**
* Message decoder decoding {@link OpenIDVCICredentialsRequest}s.
*/
-public class OpenIDVCICredentialsRequestDecoder extends BaseOpenIDVCIRequestDecoder<OpenIDVCICredentialsRequest> {
+public class OpenIDVCICredentialsRequestDecoder extends BaseOAuth2RequestDecoder<OpenIDVCICredentialsRequest> {
/** Class logger. */
@Nonnull
private final Logger log = LoggerFactory.getLogger(OpenIDVCICredentialsRequestDecoder.class);
+ /** Constructor. */
+ public OpenIDVCICredentialsRequestDecoder() {
+ setProtocolMessageLoggerSubCategory("OAUTH2.OpenIDVCI");
+ }
+
/** {@inheritDoc} */
@Override
protected OpenIDVCICredentialsRequest parseMessage() throws MessageDecodingException {
diff --git a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/InitializeAuthenticationContext.java b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/InitializeAuthenticationContext.java
deleted file mode 100644
index 34fd822..0000000
--- a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/InitializeAuthenticationContext.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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.profile.impl;
-
-import javax.annotation.Nonnull;
-
-import net.shibboleth.idp.authn.context.AuthenticationContext;
-import net.shibboleth.idp.profile.AbstractProfileAction;
-
-import org.opensaml.profile.context.ProfileRequestContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Action creates a vanilla authentication context.
- */
-public class InitializeAuthenticationContext extends AbstractProfileAction {
-
- /** Class logger. */
- @Nonnull
- private final Logger log = LoggerFactory.getLogger(InitializeAuthenticationContext.class);
-
- /** {@inheritDoc} */
- @Override
- protected void doExecute(@Nonnull final ProfileRequestContext profileRequestContext) {
-
- log.debug("{} Initializing authentication context", getLogPrefix());
- final AuthenticationContext authnCtx = new AuthenticationContext();
- profileRequestContext.addSubcontext(authnCtx, true);
- log.debug("{} Created authentication context: {}", getLogPrefix(), authnCtx);
- }
-
-}
\ No newline at end of file
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 1e2a2f4..ba67c30 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
@@ -21,8 +21,8 @@ import java.io.IOException;
import javax.annotation.Nonnull;
import org.geant.shibboleth.plugin.openidvci.statuslist.messaging.impl.StatusListAssignmentsRequest;
-import org.geant.shibboleth.plugin.openidvci.decoding.impl.BaseOpenIDVCIRequestDecoder;
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;
@@ -34,7 +34,7 @@ import com.nimbusds.oauth2.sdk.http.JakartaServletUtils;
* Decoder for {@link StatusListAssignmentsRequest}.
*/
public class StatusListAssignmentsRequestDecoder
- extends BaseOpenIDVCIRequestDecoder<StatusListAssignmentsRequest> {
+ extends BaseOAuth2RequestDecoder<StatusListAssignmentsRequest> {
/** {@inheritDoc} */
@Override
diff --git a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/statuslist/decoding/impl/StatusListRevokeRequestDecoder.java b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/statuslist/decoding/impl/StatusListRevokeRequestDecoder.java
index 76c25bd..4f6f7c7 100644
--- a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/statuslist/decoding/impl/StatusListRevokeRequestDecoder.java
+++ b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/statuslist/decoding/impl/StatusListRevokeRequestDecoder.java
@@ -19,12 +19,16 @@ 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.StatusListParameters;
import org.geant.shibboleth.plugin.openidvci.statuslist.messaging.impl.StatusListRevokeRequest;
-import org.geant.shibboleth.plugin.openidvci.decoding.impl.BaseOpenIDVCIRequestDecoder;
-import net.shibboleth.idp.plugin.oidc.op.decoding.impl.RequestUtil;
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 com.google.common.base.MoreObjects;
import com.nimbusds.oauth2.sdk.ParseException;
@@ -34,7 +38,11 @@ import com.nimbusds.oauth2.sdk.http.JakartaServletUtils;
/**
* Decoder for {@link StatusListRevokeRequest}.
*/
-public class StatusListRevokeRequestDecoder extends BaseOpenIDVCIRequestDecoder<StatusListRevokeRequest> {
+public class StatusListRevokeRequestDecoder extends BaseOAuth2RequestDecoder<StatusListRevokeRequest> {
+
+ /** Class logger. */
+ @Nonnull
+ private final Logger log = LoggerFactory.getLogger(StatusListRevokeRequestDecoder.class);
/** {@inheritDoc} */
@Override
@@ -44,16 +52,20 @@ public class StatusListRevokeRequestDecoder extends BaseOpenIDVCIRequestDecoder<
getProtocolMessageLogger().trace("Inbound request {}", RequestUtil.toString(httpRequest));
return StatusListRevokeRequest.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 StatusListRevokeRequest message) {
- return MoreObjects.toStringHelper(this).omitNullValues()
+ protected String getMessageToLog(@Nullable final StatusListRevokeRequest message) {
+ return message == null ? null : MoreObjects.toStringHelper(this).omitNullValues()
.add(StatusListParameters.BUCKET_PARAMETER, message.getId())
- .add(StatusListParameters.INDEX_PARAMETER, message.getIndex()).toString();
+ .add(StatusListParameters.INDEX_PARAMETER, message.getIndex())
+ .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/StatusListRevokeSuccessResponse.java b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/statuslist/messaging/impl/StatusListRevokeSuccessResponse.java
index 8d03def..1a4217d 100644
--- a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/statuslist/messaging/impl/StatusListRevokeSuccessResponse.java
+++ b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/statuslist/messaging/impl/StatusListRevokeSuccessResponse.java
@@ -36,9 +36,7 @@ public class StatusListRevokeSuccessResponse implements SuccessResponse {
/** {@inheritDoc} */
@Override
public HTTPResponse toHTTPResponse() {
- final HTTPResponse httpResponse = new HTTPResponse(SC_NO_CONTENT);
- httpResponse.setCacheControl("no-store");
- return httpResponse;
+ return new HTTPResponse(SC_NO_CONTENT);
}
}
diff --git a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/statuslist/profile/impl/FormOutboundStatusListRevokeResponseMessage.java b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/statuslist/profile/impl/FormOutboundStatusListRevokeResponseMessage.java
index 5a949b9..aea8d43 100644
--- a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/statuslist/profile/impl/FormOutboundStatusListRevokeResponseMessage.java
+++ b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/statuslist/profile/impl/FormOutboundStatusListRevokeResponseMessage.java
@@ -19,18 +19,35 @@ package org.geant.shibboleth.plugin.openidvci.statuslist.profile.impl;
import javax.annotation.Nonnull;
import org.geant.shibboleth.plugin.openidvci.statuslist.messaging.impl.StatusListRevokeSuccessResponse;
+import org.opensaml.profile.action.ActionSupport;
import org.opensaml.profile.context.ProfileRequestContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import jakarta.servlet.http.HttpServletResponse;
import net.shibboleth.idp.profile.AbstractProfileAction;
+import net.shibboleth.idp.profile.IdPEventIds;
+import net.shibboleth.shared.servlet.HttpServletSupport;
/**
* Action forming {@link StatusListRevokeSuccessResponse}.
*/
public class FormOutboundStatusListRevokeResponseMessage extends AbstractProfileAction {
+ /** Class logger. */
+ @Nonnull
+ private final Logger log = LoggerFactory.getLogger(FormOutboundStatusListRevokeResponseMessage.class);
+
/** {@inheritDoc} */
@Override
protected void doExecute(@Nonnull final ProfileRequestContext profileRequestContext) {
+ 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 StatusListRevokeSuccessResponse());
}
diff --git a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/statuslist/profile/impl/RevokeStatusListIndex.java b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/statuslist/profile/impl/RevokeStatusListIndex.java
index 274060b..b21f3f2 100644
--- a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/statuslist/profile/impl/RevokeStatusListIndex.java
+++ b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/statuslist/profile/impl/RevokeStatusListIndex.java
@@ -17,14 +17,17 @@
package org.geant.shibboleth.plugin.openidvci.statuslist.profile.impl;
import java.io.IOException;
+import java.util.function.Function;
import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import org.geant.shibboleth.plugin.openidvci.statuslist.MonthlyBucketStrategy;
import org.geant.shibboleth.plugin.openidvci.statuslist.StatusListIssuerTag;
import org.geant.shibboleth.plugin.openidvci.statuslist.StatusListBucket;
import org.geant.shibboleth.plugin.openidvci.statuslist.StatusListParameters;
import org.geant.shibboleth.plugin.openidvci.statuslist.messaging.impl.StatusListRevokeRequest;
+import org.geant.shibboleth.plugin.openidvci.statuslist.storage.StatusListIndexAllocator;
import org.geant.shibboleth.plugin.openidvci.statuslist.storage.StatusListStore;
import org.opensaml.profile.action.ActionSupport;
import org.opensaml.profile.action.EventIds;
@@ -32,37 +35,56 @@ import org.opensaml.profile.context.ProfileRequestContext;
import org.slf4j.Logger;
import net.shibboleth.idp.profile.AbstractProfileAction;
+import net.shibboleth.profile.context.navigate.RelyingPartyIdLookupFunction;
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;
/**
- * Action that revokes the slot of a {@link StatusListRevokeRequest} in the
- * stored status list.
- *
- * List is created at the first revocation. Revoking already revoked slot
- * succeeds without writing.
- *
+ * Action that revokes the slot of a {@link StatusListRevokeRequest} in the stored status list.
*/
public class RevokeStatusListIndex extends AbstractProfileAction {
/** Class logger. */
@Nonnull
- private Logger log = LoggerFactory.getLogger(RevokeStatusListIndex.class);
+ private final Logger log = LoggerFactory.getLogger(RevokeStatusListIndex.class);
/** Store of the published status lists. */
@NonnullAfterInit
private StatusListStore statusListStore;
+ /** Strategy used to obtain the client ID. */
+ @Nonnull
+ private Function<ProfileRequestContext, String> relyingPartyIdLookupStrategy;
+
+ /** Allocator handing out the slots. */
+ @NonnullAfterInit
+ private StatusListIndexAllocator indexAllocator;
+
/** The list the slot belongs to. */
- @NonnullBeforeExec
+ @Nullable
private StatusListBucket bucket;
/** The slot to revoke. */
private long index;
+ /** Constructor. */
+ public RevokeStatusListIndex() {
+ relyingPartyIdLookupStrategy = new RelyingPartyIdLookupFunction();
+ }
+
+ /**
+ * Set the strategy used to obtain the client ID.
+ *
+ * @param strategy lookup strategy
+ */
+ public void setRelyingPartyIdLookupStrategy(@Nonnull final Function<ProfileRequestContext, String> strategy) {
+ checkSetterPreconditions();
+ relyingPartyIdLookupStrategy = Constraint.isNotNull(strategy,
+ "Relying party ID lookup strategy cannot be null");
+ }
+
/**
* Set the store of the published status lists.
*
@@ -73,6 +95,16 @@ public class RevokeStatusListIndex extends AbstractProfileAction {
statusListStore = Constraint.isNotNull(store, "StatusListStore cannot be null");
}
+ /**
+ * Set the allocator handing out the slots.
+ *
+ * @param allocator The allocator to use.
+ */
+ public void setIndexAllocator(@Nonnull final StatusListIndexAllocator allocator) {
+ checkSetterPreconditions();
+ indexAllocator = Constraint.isNotNull(allocator, "StatusListIndexAllocator cannot be null");
+ }
+
/** {@inheritDoc} */
@Override
protected void doInitialize() throws ComponentInitializationException {
@@ -80,6 +112,9 @@ public class RevokeStatusListIndex extends AbstractProfileAction {
if (statusListStore == null) {
throw new ComponentInitializationException("StatusListStore cannot be null");
}
+ if (indexAllocator == null) {
+ throw new ComponentInitializationException("StatusListIndexAllocator cannot be null");
+ }
}
/** {@inheritDoc} */
@@ -96,17 +131,16 @@ public class RevokeStatusListIndex extends AbstractProfileAction {
return false;
}
- // The bucket alone keys storage, a tag the credential carries is stripped.
bucket = MonthlyBucketStrategy.parse(StatusListIssuerTag.bucketOf(request.getId()));
if (bucket == null) {
- log.error("{} '{}' does not name a status list", getLogPrefix(), request.getId());
+ log.warn("{} '{}' does not name a status list", getLogPrefix(), request.getId());
ActionSupport.buildEvent(profileRequestContext, EventIds.INVALID_MSG_CTX);
return false;
}
index = request.getIndex();
if (index < 0 || index >= StatusListParameters.CAPACITY) {
- log.error("{} Slot {} lies outside a status list of {}", getLogPrefix(), index,
+ log.warn("{} Slot {} lies outside a status list of {}", getLogPrefix(), index,
StatusListParameters.CAPACITY);
ActionSupport.buildEvent(profileRequestContext, EventIds.INVALID_MSG_CTX);
return false;
@@ -118,11 +152,19 @@ public class RevokeStatusListIndex extends AbstractProfileAction {
/** {@inheritDoc} */
@Override
protected void doExecute(@Nonnull final ProfileRequestContext profileRequestContext) {
- assert bucket != null;
+ final StatusListBucket list = bucket;
+ assert list != null;
try {
- statusListStore.revoke(bucket, index);
+ if (!indexAllocator.isAllocated(list, index)) {
+ log.warn("{} Slot {} of status list {} has not been allocated", getLogPrefix(), index, list.id());
+ ActionSupport.buildEvent(profileRequestContext, EventIds.INVALID_MSG_CTX);
+ return;
+ }
+ statusListStore.revoke(list, index);
+ log.info("{} Client {} revoked slot {} of status list {}", getLogPrefix(),
+ relyingPartyIdLookupStrategy.apply(profileRequestContext), index, list.id());
} catch (final IOException e) {
- log.error("{} Failed to revoke slot {} of status list {}: {}", getLogPrefix(), index, bucket.id(),
+ log.error("{} Failed to revoke slot {} of status list {}: {}", getLogPrefix(), index, list.id(),
e.getMessage());
ActionSupport.buildEvent(profileRequestContext, EventIds.IO_ERROR);
}
diff --git a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/statuslist/storage/FeistelIndexPermutation.java b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/statuslist/storage/FeistelIndexPermutation.java
index 294547b..65f740d 100644
--- a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/statuslist/storage/FeistelIndexPermutation.java
+++ b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/statuslist/storage/FeistelIndexPermutation.java
@@ -90,6 +90,28 @@ public class FeistelIndexPermutation {
return ((long) left << halfBits) | right;
}
+ /**
+ * Invert {@link #permute(long, String)}.
+ *
+ * @param index index returned by {@link #permute(long, String)}
+ * @param tweak tweak the index was permuted with
+ * @return counter value that permutes into the index
+ */
+ public long invert(final long index, @Nonnull final String tweak) {
+ Constraint.isNotNull(tweak, "Tweak cannot be null");
+
+ int left = (int) ((index >>> halfBits) & halfMask);
+ int right = (int) (index & halfMask);
+
+ for (int round = ROUNDS - 1; round >= 0; round--) {
+ final int previous = right ^ roundFunction(tweak, round, left);
+ right = left;
+ left = previous;
+ }
+
+ return ((long) left << halfBits) | right;
+ }
+
/**
* Keyed round function, reduced to one half of the permuted space.
*
diff --git a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/statuslist/storage/StatusListIndexAllocator.java b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/statuslist/storage/StatusListIndexAllocator.java
index 69970b9..56b315b 100644
--- a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/statuslist/storage/StatusListIndexAllocator.java
+++ b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/statuslist/storage/StatusListIndexAllocator.java
@@ -240,6 +240,26 @@ public class StatusListIndexAllocator extends AbstractIdentifiableInitializableC
}
}
+ /**
+ * Whether a slot of a bucket has been allocated.
+ *
+ * @param bucket bucket of the slot
+ * @param index slot to check
+ * @return whether the slot has been allocated
+ * @throws IOException if the storage backend fails
+ */
+ public boolean isAllocated(@Nonnull final StatusListBucket bucket, final long index) throws IOException {
+ checkComponentActive();
+ Constraint.isNotNull(bucket, "Bucket cannot be null");
+ Constraint.isTrue(index >= 0 && index < CAPACITY, "Slot " + index + " outside a list of " + CAPACITY);
+
+ final StorageRecord<String> current = storage.read(CONTEXT, bucket.id());
+ if (current == null) {
+ return false;
+ }
+ return permutation.invert(index, bucket.id()) < Long.parseLong(current.getValue());
+ }
+
/**
* Advance a bucket's counter with an optimistic update and map the consumed counter values to indices.
*
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 634e969..7902541 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
@@ -54,6 +54,13 @@
p:id="openidvci.status-list.Store"
p:storage-ref="#{'%{openidvci.status-list.StorageService:shibboleth.StorageService}'.trim()}" />
+ <bean id="openidvci.status-list.IndexAllocator"
+ class="org.geant.shibboleth.plugin.openidvci.statuslist.storage.StatusListIndexAllocator"
+ lazy-init="true" depends-on="shibboleth.LoggingService"
+ p:id="openidvci.status-list.IndexAllocator"
+ p:storage-ref="#{'%{openidvci.status-list.index.StorageService:shibboleth.StorageService}'.trim()}"
+ p:permutationKey="%{openidvci.status-list.index.permutationKey:}" />
+
<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 f892fc3..9756e3d 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
@@ -11,13 +11,6 @@
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"
default-init-method="initialize" default-destroy-method="destroy">
- <bean id="openidvci.status-list.IndexAllocator"
- class="org.geant.shibboleth.plugin.openidvci.statuslist.storage.StatusListIndexAllocator"
- depends-on="shibboleth.LoggingService"
- p:id="openidvci.status-list.IndexAllocator"
- p:storage-ref="#{'%{openidvci.status-list.index.StorageService:shibboleth.StorageService}'.trim()}"
- p:permutationKey="%{openidvci.status-list.index.permutationKey:}" />
-
<bean id="openidvci.status-list.InclusionCondition"
class="org.geant.shibboleth.plugin.openidvci.profile.logic.StatusListInclusionPredicate"
p:defaultInclusion="%{openidvci.status-list.includeByDefault:true}" />
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 f91e5ab..11b7885 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
@@ -24,7 +24,7 @@
</bean>
<bean id="InitializeAuthenticationContext"
- class="org.geant.shibboleth.plugin.openidvci.profile.impl.InitializeAuthenticationContext"
+ class="net.shibboleth.idp.saml.profile.impl.InitializeAuthenticationContext"
scope="prototype" />
<bean id="shibboleth.ClientIDLookupStrategy"
diff --git a/openid-vci-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/oauth/status-list/revoke/revoke-beans.xml b/openid-vci-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/oauth/status-list/revoke/revoke-beans.xml
index febb71e..b69fdb8 100644
--- a/openid-vci-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/oauth/status-list/revoke/revoke-beans.xml
+++ b/openid-vci-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/oauth/status-list/revoke/revoke-beans.xml
@@ -21,25 +21,28 @@
<bean id="OpenIDVCIDecodeMessage" class="org.opensaml.profile.action.impl.DecodeMessage" scope="prototype">
<constructor-arg>
<bean class="org.geant.shibboleth.plugin.openidvci.statuslist.decoding.impl.StatusListRevokeRequestDecoder"
- scope="prototype" p:httpServletRequestSupplier-ref="shibboleth.HttpServletRequestSupplier" />
+ scope="prototype" p:httpServletRequestSupplier-ref="shibboleth.HttpServletRequestSupplier"
+ p:removeIpAddressFromEndpointUri="%{idp.oidc.logging.removeIpAddressFromProtocolMessage:false}" />
</constructor-arg>
</bean>
<bean id="InitializeAuthenticationContext"
- class="org.geant.shibboleth.plugin.openidvci.profile.impl.InitializeAuthenticationContext"
+ class="net.shibboleth.idp.saml.profile.impl.InitializeAuthenticationContext"
scope="prototype" />
<bean id="shibboleth.ClientIDLookupStrategy"
- class="net.shibboleth.idp.plugin.oidc.op.messaging.context.navigate.TokenRequestClientIDLookupFunction" />
+ class="net.shibboleth.idp.plugin.oidc.op.messaging.context.navigate.TokenRequestClientIDLookupFunction"
+ scope="prototype" />
<bean id="RevokeStatusListIndex"
class="org.geant.shibboleth.plugin.openidvci.statuslist.profile.impl.RevokeStatusListIndex"
scope="prototype"
- p:statusListStore-ref="openidvci.status-list.Store" />
+ p:statusListStore-ref="openidvci.status-list.Store"
+ p:indexAllocator-ref="openidvci.status-list.IndexAllocator" />
<bean id="OpenIDVCIFormOutboundMessage"
class="org.geant.shibboleth.plugin.openidvci.statuslist.profile.impl.FormOutboundStatusListRevokeResponseMessage"
- scope="prototype" />
+ scope="prototype" p:httpServletResponseSupplier-ref="shibboleth.HttpServletResponseSupplier" />
<bean id="OpenIDVCIBuildErrorResponseFromEvent" class="net.shibboleth.oidc.profile.impl.BuildJSONErrorResponseFromEvent"
scope="prototype" p:defaultStatusCode="400" p:defaultCode="invalid_request"
@@ -69,7 +72,8 @@
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}" />
- <!-- Storage refused the write, so the slot is not revoked and the caller has to retry. -->
+ <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/main/resources/META-INF/net/shibboleth/idp/flows/openid/vci/credential-offer/credential-offer-beans.xml b/openid-vci-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/openid/vci/credential-offer/credential-offer-beans.xml
index 7740aec..441d0b6 100644
--- a/openid-vci-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/openid/vci/credential-offer/credential-offer-beans.xml
+++ b/openid-vci-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/openid/vci/credential-offer/credential-offer-beans.xml
@@ -22,7 +22,7 @@
</constructor-arg>
</bean>
- <bean id="InitializeAuthenticationContext" class="org.geant.shibboleth.plugin.openidvci.profile.impl.InitializeAuthenticationContext"
+ <bean id="InitializeAuthenticationContext" class="net.shibboleth.idp.saml.profile.impl.InitializeAuthenticationContext"
scope="prototype"/>
<bean id="ValidateCredentialOffering" class="org.geant.shibboleth.plugin.openidvci.profile.impl.ValidateCredentialOffering"
diff --git a/openid-vci-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/openid/vci/credentials/credentials-beans.xml b/openid-vci-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/openid/vci/credentials/credentials-beans.xml
index aeed6a9..59a7afa 100644
--- a/openid-vci-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/openid/vci/credentials/credentials-beans.xml
+++ b/openid-vci-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/openid/vci/credentials/credentials-beans.xml
@@ -113,7 +113,7 @@
<bean id="ValidateExpectedGrantType" class="org.geant.shibboleth.plugin.openidvci.profile.impl.ValidateExpectedGrantType"
scope="prototype"/>
- <bean id="InitializeAuthenticationContext" class="org.geant.shibboleth.plugin.openidvci.profile.impl.InitializeAuthenticationContext"
+ <bean id="InitializeAuthenticationContext" class="net.shibboleth.idp.saml.profile.impl.InitializeAuthenticationContext"
scope="prototype" />
<bean id="PopulateCredentialsSignatureSigningParameters"
diff --git a/openid-vci-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/openid/vci/token/token-beans.xml b/openid-vci-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/openid/vci/token/token-beans.xml
index 36bce61..75984df 100644
--- a/openid-vci-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/openid/vci/token/token-beans.xml
+++ b/openid-vci-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/openid/vci/token/token-beans.xml
@@ -46,9 +46,6 @@
</property>
</bean>
- <bean id="InitializeAuthenticationContext"
- class="org.geant.shibboleth.plugin.openidvci.profile.impl.InitializeAuthenticationContext" scope="prototype" />
-
<!--
REPLACED, KEEPING THE BEAN ID.
APIRequestClientIDLookupFunction in place of TokenRequestClientIDLookupFunction.
diff --git a/openid-vci-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/openid/vci/token/token-flow.xml b/openid-vci-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/openid/vci/token/token-flow.xml
index 4abedbe..543bbfd 100644
--- a/openid-vci-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/openid/vci/token/token-flow.xml
+++ b/openid-vci-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/openid/vci/token/token-flow.xml
@@ -42,9 +42,10 @@
BuildTokensForThirdPartyAccess
BEANS NAMED BY THE PARENT FLOWS
- OpenIDVCIDecodeMessage, OpenIDVCIFormOutboundMessage, OpenIDVCIBuildErrorResponseFromEvent and
- InitializeAuthenticationContext of openid/vci/abstract-api; shibboleth.ClientIDLookupStrategy of
- oidc/metadata-lookup, replaced keeping the bean id. In token-beans.xml.
+ OpenIDVCIDecodeMessage, OpenIDVCIFormOutboundMessage and OpenIDVCIBuildErrorResponseFromEvent of
+ openid/vci/abstract-api; shibboleth.ClientIDLookupStrategy of oidc/metadata-lookup, replaced keeping
+ the bean id. In token-beans.xml. InitializeAuthenticationContext of openid/vci/abstract-api is the
+ one of the imported oidc/abstract-api beans.
-->
<flow xmlns="http://www.springframework.org/schema/webflow" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
diff --git a/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/profile/impl/InitializeAuthenticationContextTest.java b/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/profile/impl/InitializeAuthenticationContextTest.java
deleted file mode 100644
index c7e627f..0000000
--- a/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/profile/impl/InitializeAuthenticationContextTest.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * 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.profile.impl;
-
-import org.geant.shibboleth.plugin.openidvci.profile.impl.InitializeAuthenticationContext;
-import org.opensaml.messaging.decoder.MessageDecodingException;
-import org.opensaml.profile.context.ProfileRequestContext;
-import org.springframework.webflow.execution.RequestContext;
-import org.testng.Assert;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-import net.shibboleth.idp.authn.context.AuthenticationContext;
-import net.shibboleth.idp.profile.testing.ActionTestingSupport;
-import net.shibboleth.idp.profile.testing.RequestContextBuilder;
-import net.shibboleth.idp.profile.context.navigate.WebflowRequestContextProfileRequestContextLookup;
-
-/**
- * Unit tests for {@link InitializeAuthenticationContext}.
- */
-public class InitializeAuthenticationContextTest {
-
- protected RequestContext requestCtx;
-
- protected ProfileRequestContext profileRequestCtx;
-
- private InitializeAuthenticationContext action;
-
- @BeforeMethod
- protected void setUp() throws Exception {
- requestCtx = new RequestContextBuilder().buildRequestContext();
- profileRequestCtx = new WebflowRequestContextProfileRequestContextLookup().apply(requestCtx);
- action = new InitializeAuthenticationContext();
- action.initialize();
- }
-
- @Test
- public void testSuccess() throws MessageDecodingException {
- ActionTestingSupport.assertProceedEvent(action.execute(requestCtx));
- Assert.assertNotNull(profileRequestCtx.getSubcontext(AuthenticationContext.class));
- }
-
-}
\ No newline at end of file
diff --git a/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/statuslist/decoding/impl/StatusListRevokeRequestDecoderTest.java b/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/statuslist/decoding/impl/StatusListRevokeRequestDecoderTest.java
new file mode 100644
index 0000000..78f62a7
--- /dev/null
+++ b/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/statuslist/decoding/impl/StatusListRevokeRequestDecoderTest.java
@@ -0,0 +1,108 @@
+/*
+ * 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.StatusListRevokeRequest;
+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 StatusListRevokeRequestDecoder}. */
+public class StatusListRevokeRequestDecoderTest {
+
+ private MockHttpServletRequest httpRequest;
+
+ private StatusListRevokeRequestDecoder 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/revoke");
+ httpRequest.setContentType("application/json");
+ httpRequest.setContent("{\"id\": \"2027-03\", \"idx\": 41337}".getBytes());
+ decoder = new StatusListRevokeRequestDecoder();
+ 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 StatusListRevokeRequest request = (StatusListRevokeRequest) decoder.getMessageContext().getMessage();
+ Assert.assertEquals(request.getClientAuthentication().getClientID().getValue(), "client");
+ Assert.assertEquals(request.getId(), "2027-03");
+ Assert.assertEquals(request.getIndex(), 41337L);
+ }
+
+ @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((StatusListRevokeRequest) decoder.getMessageContext().getMessage());
+ Assert.assertTrue(logged.contains("2027-03"));
+ Assert.assertTrue(logged.contains("41337"));
+ 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((StatusListRevokeRequest) decoder.getMessageContext().getMessage());
+ Assert.assertTrue(logged.contains("/idp/profile/oauth/status-list/revoke"));
+ 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/profile/impl/FormOutboundStatusListRevokeResponseMessageTest.java b/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/statuslist/profile/impl/FormOutboundStatusListRevokeResponseMessageTest.java
new file mode 100644
index 0000000..c34030d
--- /dev/null
+++ b/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/statuslist/profile/impl/FormOutboundStatusListRevokeResponseMessageTest.java
@@ -0,0 +1,97 @@
+/*
+ * 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.impl;
+
+import org.geant.shibboleth.plugin.openidvci.statuslist.messaging.impl.StatusListRevokeSuccessResponse;
+import org.opensaml.profile.context.ProfileRequestContext;
+import org.springframework.mock.web.MockHttpServletResponse;
+import org.springframework.webflow.execution.RequestContext;
+import org.testng.Assert;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+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.component.ComponentInitializationException;
+import net.shibboleth.shared.primitive.NonnullSupplier;
+
+/** Tests for {@link FormOutboundStatusListRevokeResponseMessage}. */
+public class FormOutboundStatusListRevokeResponseMessageTest {
+
+ private RequestContext requestCtx;
+
+ private ProfileRequestContext profileRequestCtx;
+
+ private MockHttpServletResponse httpResponse;
+
+ @BeforeMethod
+ public void setUp() throws ComponentInitializationException {
+ requestCtx = new RequestContextBuilder().buildRequestContext();
+ profileRequestCtx = new WebflowRequestContextProfileRequestContextLookup().apply(requestCtx);
+ httpResponse = new MockHttpServletResponse();
+ }
+
+ private FormOutboundStatusListRevokeResponseMessage newAction(final boolean withResponse)
+ throws ComponentInitializationException {
+ final FormOutboundStatusListRevokeResponseMessage action = new FormOutboundStatusListRevokeResponseMessage();
+ if (withResponse) {
+ action.setHttpServletResponseSupplier(new NonnullSupplier<>() {
+ public HttpServletResponse get() {
+ return httpResponse;
+ }
+ });
+ }
+ action.initialize();
+ return action;
+ }
+
+ @Test
+ public void testSuccessResponse() throws ComponentInitializationException {
+ ActionTestingSupport.assertProceedEvent(newAction(true).execute(requestCtx));
+
+ Assert.assertTrue(
+ profileRequestCtx.getOutboundMessageContext().getMessage() instanceof StatusListRevokeSuccessResponse);
+ Assert.assertEquals(
+ ((StatusListRevokeSuccessResponse) profileRequestCtx.getOutboundMessageContext().getMessage())
+ .toHTTPResponse().getStatusCode(), 204);
+ }
+
+ @Test
+ public void testCacheControlOnce() throws ComponentInitializationException {
+ httpResponse.addHeader("Cache-Control", "no-store");
+
+ ActionTestingSupport.assertProceedEvent(newAction(true).execute(requestCtx));
+
+ 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() {
+ Assert.assertNull(new StatusListRevokeSuccessResponse().toHTTPResponse().getCacheControl());
+ }
+
+ @Test
+ public void testNoServletResponse() throws ComponentInitializationException {
+ ActionTestingSupport.assertEvent(newAction(false).execute(requestCtx), IdPEventIds.INVALID_PROFILE_CONFIG);
+ }
+
+}
diff --git a/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/statuslist/profile/impl/RevokeStatusListIndexTest.java b/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/statuslist/profile/impl/RevokeStatusListIndexTest.java
new file mode 100644
index 0000000..eb126df
--- /dev/null
+++ b/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/statuslist/profile/impl/RevokeStatusListIndexTest.java
@@ -0,0 +1,202 @@
+/*
+ * 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.impl;
+
+import java.io.ByteArrayOutputStream;
+import java.net.URI;
+import java.util.zip.Inflater;
+
+import org.geant.shibboleth.plugin.openidvci.statuslist.MonthlyBucketStrategy;
+import org.geant.shibboleth.plugin.openidvci.statuslist.StatusListBucket;
+import org.geant.shibboleth.plugin.openidvci.statuslist.StatusListCodec;
+import org.geant.shibboleth.plugin.openidvci.statuslist.StatusListParameters;
+import org.geant.shibboleth.plugin.openidvci.statuslist.messaging.impl.StatusListRevokeRequest;
+import org.geant.shibboleth.plugin.openidvci.statuslist.storage.StatusListIndexAllocator;
+import org.geant.shibboleth.plugin.openidvci.statuslist.storage.StatusListStore;
+import org.opensaml.messaging.context.MessageContext;
+import org.opensaml.profile.action.EventIds;
+import org.opensaml.profile.context.ProfileRequestContext;
+import org.opensaml.storage.impl.MemoryStorageService;
+import org.springframework.webflow.execution.RequestContext;
+import org.testng.Assert;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import com.nimbusds.jose.util.Base64URL;
+import com.nimbusds.oauth2.sdk.http.HTTPRequest;
+
+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.component.ComponentInitializationException;
+
+/** Tests for {@link RevokeStatusListIndex}. */
+public class RevokeStatusListIndexTest {
+
+ private static final String LIST = "2027-02";
+
+ private RequestContext requestCtx;
+
+ private ProfileRequestContext profileRequestCtx;
+
+ private MemoryStorageService storageService;
+
+ private StatusListIndexAllocator allocator;
+
+ private StatusListStore store;
+
+ private RevokeStatusListIndex action;
+
+ private StatusListBucket bucket;
+
+ @BeforeMethod
+ public void setUp() throws Exception {
+ storageService = new MemoryStorageService();
+ storageService.setId("test");
+ storageService.initialize();
+
+ allocator = new StatusListIndexAllocator();
+ allocator.setId("test");
+ allocator.setStorage(storageService);
+ allocator.setPermutationKey("test-permutation-key");
+ allocator.initialize();
+
+ store = new StatusListStore();
+ store.setId("test");
+ store.setStorage(storageService);
+ store.initialize();
+
+ bucket = MonthlyBucketStrategy.parse(LIST);
+
+ requestCtx = new RequestContextBuilder().buildRequestContext();
+ profileRequestCtx = new WebflowRequestContextProfileRequestContextLookup().apply(requestCtx);
+
+ action = new RevokeStatusListIndex();
+ action.setStatusListStore(store);
+ action.setIndexAllocator(allocator);
+ action.initialize();
+ }
+
+ @AfterMethod
+ public void tearDown() {
+ store.destroy();
+ allocator.destroy();
+ storageService.destroy();
+ }
+
+ private void request(final String id, final long idx) throws Exception {
+ final HTTPRequest httpRequest = new HTTPRequest(HTTPRequest.Method.POST, new URI("http://example.com"));
+ httpRequest.setAuthorization("Basic dGVzdDp0ZXN0");
+ httpRequest.setContentType("application/json");
+ httpRequest.setBody("{\"id\": \"" + id + "\", \"idx\": " + idx + "}");
+ final MessageContext messageContext = new MessageContext();
+ messageContext.setMessage(StatusListRevokeRequest.parse(httpRequest));
+ profileRequestCtx.setInboundMessageContext(messageContext);
+ }
+
+ private byte[] published() throws Exception {
+ final Inflater inflater = new Inflater();
+ try {
+ inflater.setInput(new Base64URL(store.read(bucket)).decode());
+ final ByteArrayOutputStream inflated = new ByteArrayOutputStream();
+ final byte[] buffer = new byte[8192];
+ while (!inflater.finished()) {
+ inflated.write(buffer, 0, inflater.inflate(buffer));
+ }
+ return inflated.toByteArray();
+ } finally {
+ inflater.end();
+ }
+ }
+
+ @Test
+ public void testRevokesAllocatedSlot() throws Exception {
+ final long idx = allocator.allocate(bucket, 1).get(0);
+ request(LIST, idx);
+
+ ActionTestingSupport.assertProceedEvent(action.execute(requestCtx));
+ Assert.assertFalse(StatusListCodec.isValid(published(), idx));
+ }
+
+ @Test
+ public void testRevokesAllocatedSlotWithIssuerTag() throws Exception {
+ final long idx = allocator.allocate(bucket, 1).get(0);
+ request(LIST + "~url", idx);
+
+ ActionTestingSupport.assertProceedEvent(action.execute(requestCtx));
+ Assert.assertFalse(StatusListCodec.isValid(published(), idx));
+ }
+
+ @Test
+ public void testRefusesUnallocatedSlot() throws Exception {
+ final long allocated = allocator.allocate(bucket, 1).get(0);
+ final long idx = allocated == 0 ? 1 : 0;
+ request(LIST, idx);
+
+ ActionTestingSupport.assertEvent(action.execute(requestCtx), EventIds.INVALID_MSG_CTX);
+ Assert.assertNull(store.read(bucket), "A refused revocation writes nothing");
+ }
+
+ @Test
+ public void testRefusesSlotOfUnusedList() throws Exception {
+ request(LIST, 0);
+
+ ActionTestingSupport.assertEvent(action.execute(requestCtx), EventIds.INVALID_MSG_CTX);
+ Assert.assertNull(store.read(bucket), "A refused revocation writes nothing");
+ }
+
+ @Test
+ public void testRefusedSlotStaysValidBesideRevokedOne() throws Exception {
+ final long allocated = allocator.allocate(bucket, 1).get(0);
+ final long idx = allocated == 0 ? 1 : 0;
+ request(LIST, allocated);
+ ActionTestingSupport.assertProceedEvent(action.execute(requestCtx));
+
+ request(LIST, idx);
+ ActionTestingSupport.assertEvent(action.execute(requestCtx), EventIds.INVALID_MSG_CTX);
+ Assert.assertTrue(StatusListCodec.isValid(published(), idx));
+ Assert.assertFalse(StatusListCodec.isValid(published(), allocated));
+ }
+
+ @Test
+ public void testRefusesUnknownList() throws Exception {
+ request("not-a-month", 0);
+
+ ActionTestingSupport.assertEvent(action.execute(requestCtx), EventIds.INVALID_MSG_CTX);
+ }
+
+ @Test
+ public void testRefusesSlotOutsideList() throws Exception {
+ request(LIST, StatusListParameters.CAPACITY);
+
+ ActionTestingSupport.assertEvent(action.execute(requestCtx), EventIds.INVALID_MSG_CTX);
+ }
+
+ @Test
+ public void testNoRequest() {
+ ActionTestingSupport.assertEvent(action.execute(requestCtx), EventIds.INVALID_MSG_CTX);
+ }
+
+ @Test(expectedExceptions = ComponentInitializationException.class)
+ public void testNoAllocator() throws ComponentInitializationException {
+ final RevokeStatusListIndex other = new RevokeStatusListIndex();
+ other.setStatusListStore(store);
+ other.initialize();
+ }
+
+}
diff --git a/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/statuslist/storage/FeistelIndexPermutationTest.java b/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/statuslist/storage/FeistelIndexPermutationTest.java
index f521281..1b11d90 100644
--- a/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/statuslist/storage/FeistelIndexPermutationTest.java
+++ b/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/statuslist/storage/FeistelIndexPermutationTest.java
@@ -159,4 +159,23 @@ public class FeistelIndexPermutationTest {
Assert.assertTrue(adjacent < TEST_SPACE / 8, "Indices track allocation order, adjacent pairs: " + adjacent);
}
+ @Test
+ public void testInvertReversesPermuteOverWholeSpace() {
+ FeistelIndexPermutation permutation = new FeistelIndexPermutation(TEST_BITS, KEY);
+
+ for (long counter = 0; counter < TEST_SPACE; counter++) {
+ Assert.assertEquals(permutation.invert(permutation.permute(counter, TWEAK), TWEAK), counter);
+ }
+ }
+
+ @Test
+ public void testInvertAtListWidth() {
+ FeistelIndexPermutation permutation = new FeistelIndexPermutation(StatusListParameters.INDEX_BITS, KEY);
+
+ for (long counter = 0; counter < StatusListParameters.CAPACITY; counter += 997) {
+ Assert.assertEquals(permutation.invert(permutation.permute(counter, TWEAK), TWEAK), counter);
+ Assert.assertEquals(permutation.invert(permutation.permute(counter, "2027-03"), "2027-03"), counter);
+ }
+ }
+
}
diff --git a/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/statuslist/storage/StatusListIndexAllocatorTest.java b/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/statuslist/storage/StatusListIndexAllocatorTest.java
index ad09df3..6f6c3be 100644
--- a/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/statuslist/storage/StatusListIndexAllocatorTest.java
+++ b/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/statuslist/storage/StatusListIndexAllocatorTest.java
@@ -234,4 +234,31 @@ public class StatusListIndexAllocatorTest {
Long.toString(allocations));
}
+ @Test
+ public void testIsAllocated() throws IOException {
+ Assert.assertFalse(allocator.isAllocated(BUCKET, 0), "No slot of an unused bucket is allocated");
+
+ List<Long> indices = allocator.allocate(BUCKET, 3);
+ Set<Long> allocated = new HashSet<>(indices);
+ for (long index : indices) {
+ Assert.assertTrue(allocator.isAllocated(BUCKET, index));
+ Assert.assertFalse(allocator.isAllocated(OTHER_BUCKET, index));
+ }
+
+ int unallocated = 0;
+ for (long index = 0; index < 64; index++) {
+ if (!allocated.contains(index)) {
+ Assert.assertFalse(allocator.isAllocated(BUCKET, index));
+ unallocated++;
+ }
+ }
+ Assert.assertTrue(unallocated > 0);
+ }
+
+ @Test
+ public void testIsAllocatedBounds() {
+ Assert.assertThrows(() -> allocator.isAllocated(BUCKET, -1));
+ Assert.assertThrows(() -> allocator.isAllocated(BUCKET, allocator.getCapacity()));
+ }
+
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list