[java-idp-plugin-vci] branch dev/REVIEWOFFERCALLERFLOW updated: credential offer validation, mandatory claim accepted in deep request path. calller faults are now ERROR -> WARN, javadoc trimmed
Codeberg
noreply at shibboleth.net
Mon Nov 16 09:46:13 UTC 2026
This is an automated email from the git hooks/post-receive script.
codeberg pushed a commit to branch dev/REVIEWOFFERCALLERFLOW
in repository java-idp-plugin-vci.
View the commit online:
https://codeberg.org/Shibboleth/java-idp-plugin-vci/commit/4ea0f02cd3995a7c380dd62dc4b4cc786f31e49b
The following commit(s) were added to refs/heads/dev/REVIEWOFFERCALLERFLOW by this push:
new 4ea0f02 credential offer validation, mandatory claim accepted in deep request path. calller faults are now ERROR -> WARN, javadoc trimmed
4ea0f02 is described below
commit 4ea0f02cd3995a7c380dd62dc4b4cc786f31e49b
Author: Janne Lauros <janne.lauros at csc.fi>
AuthorDate: Mon Nov 16 11:45:49 2026 +0200
credential offer validation, mandatory claim accepted in deep request path. calller faults are now ERROR -> WARN, javadoc trimmed
---
.../impl/AbstractCredentialValidationAction.java | 19 +++++----
.../profile/impl/ValidateCredentialOffering.java | 34 ++++++++--------
.../impl/ValidateCredentialOfferingTest.java | 46 +++++++++++++++++++++-
3 files changed, 70 insertions(+), 29 deletions(-)
diff --git a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/AbstractCredentialValidationAction.java b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/AbstractCredentialValidationAction.java
index 4852310..0e15847 100644
--- a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/AbstractCredentialValidationAction.java
+++ b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/AbstractCredentialValidationAction.java
@@ -19,6 +19,7 @@ package org.geant.shibboleth.plugin.openidvci.profile.impl;
import java.util.Map;
import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import org.geant.shibboleth.plugin.openidvci.credential.CredentialConfiguration;
import org.geant.shibboleth.plugin.openidvci.credential.CredentialConfigurations;
@@ -31,30 +32,25 @@ import org.slf4j.LoggerFactory;
import net.shibboleth.idp.profile.AbstractProfileAction;
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.resolver.ResolverException;
/**
- * Abstract class for actions performing actions on
- * {@link CredentialConfigurations} resolved for the request.
- *
- * The configurations come from a resolver shared with every other flow reading
- * them, including the one publishing Credential Issuer metadata.
+ * Abstract class for actions performing actions on {@link CredentialConfigurations} resolved for the request.
*/
abstract class AbstractCredentialValidationAction extends AbstractProfileAction {
/** Class logger. */
@Nonnull
- private Logger log = LoggerFactory.getLogger(AbstractCredentialValidationAction.class);
+ private final Logger log = LoggerFactory.getLogger(AbstractCredentialValidationAction.class);
/** Resolver of the supported credentials. */
@NonnullAfterInit
private CredentialConfigurationsResolver credentialConfigurationsResolver;
/** The supported credentials resolved for this request. */
- @NonnullBeforeExec
+ @Nullable
private CredentialConfigurations credentialConfigurations;
/**
@@ -81,13 +77,16 @@ abstract class AbstractCredentialValidationAction extends AbstractProfileAction
* @return Supported credentials resolved for this request
*/
public Map<String, CredentialConfiguration> getCredentialConfigurations() {
+ assert credentialConfigurations != null;
return credentialConfigurations.getCredentialConfigurations();
}
/** {@inheritDoc} */
@Override
protected boolean doPreExecute(@Nonnull final ProfileRequestContext profileRequestContext) {
-
+ if (!super.doPreExecute(profileRequestContext)) {
+ return false;
+ }
try {
credentialConfigurations = credentialConfigurationsResolver.resolveSingle(profileRequestContext);
} catch (final ResolverException e) {
@@ -100,7 +99,7 @@ abstract class AbstractCredentialValidationAction extends AbstractProfileAction
ActionSupport.buildEvent(profileRequestContext, OpenIDVCIEventIds.NO_CREDENTIAL_CONFIGURATION);
return false;
}
- return super.doPreExecute(profileRequestContext);
+ return true;
}
}
diff --git a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/ValidateCredentialOffering.java b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/ValidateCredentialOffering.java
index 10e9d36..d2620a5 100644
--- a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/ValidateCredentialOffering.java
+++ b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/ValidateCredentialOffering.java
@@ -32,19 +32,13 @@ import org.geant.shibboleth.plugin.openidvci.messaging.impl.CredentialOfferReque
import org.geant.shibboleth.plugin.openidvci.messaging.impl.CredentialOfferRequestedCredential;
import org.geant.shibboleth.plugin.openidvci.profile.OpenIDVCIEventIds;
import org.opensaml.profile.action.ActionSupport;
+import org.opensaml.profile.action.EventIds;
import org.opensaml.profile.context.ProfileRequestContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import net.shibboleth.shared.annotation.constraint.NonnullBeforeExec;
/**
- * Action validates that there is a credential offering matching the request.
- * For both pre-authorized and code flows the credential configuration id must
- * be a supported one. Additionally, for the pre-authorized flow, every claim
- * marked {@code mandatory: true} in the configuration's
- * {@code credential_metadata.claims} must be present in the requested claims.
- * If validation is successful a {@link CredentialOfferContext} is created and
- * requested credentials and possible tx code is stored there.
+ * Action validates the offered credentials and stores them in a {@link CredentialOfferContext}.
*/
public class ValidateCredentialOffering extends AbstractCredentialValidationAction {
@@ -58,21 +52,22 @@ public class ValidateCredentialOffering extends AbstractCredentialValidationActi
/** Class logger. */
@Nonnull
- private Logger log = LoggerFactory.getLogger(ValidateCredentialOffering.class);
+ private final Logger log = LoggerFactory.getLogger(ValidateCredentialOffering.class);
- /**
- * Inbound {@link CredentialOfferRequest}.
- */
- @NonnullBeforeExec
+ /** Inbound {@link CredentialOfferRequest}. */
+ @Nullable
private CredentialOfferRequest request;
/** {@inheritDoc} */
@Override
protected boolean doPreExecute(@Nonnull final ProfileRequestContext profileRequestContext) {
+ if (!super.doPreExecute(profileRequestContext)) {
+ return false;
+ }
if (profileRequestContext.getInboundMessageContext() == null
|| !(profileRequestContext.getInboundMessageContext().getMessage() instanceof CredentialOfferRequest)) {
log.error("{} No CredentialOfferRequest as inbound message", getLogPrefix());
- ActionSupport.buildEvent(profileRequestContext, OpenIDVCIEventIds.NO_CREDENTIAL_REQUEST);
+ ActionSupport.buildEvent(profileRequestContext, EventIds.INVALID_MSG_CTX);
return false;
}
request = (CredentialOfferRequest) profileRequestContext.getInboundMessageContext().getMessage();
@@ -81,24 +76,25 @@ public class ValidateCredentialOffering extends AbstractCredentialValidationActi
ActionSupport.buildEvent(profileRequestContext, OpenIDVCIEventIds.NO_CREDENTIALS_REQUEST);
return false;
}
- return super.doPreExecute(profileRequestContext);
+ return true;
}
/** {@inheritDoc} */
@Override
protected void doExecute(@Nonnull final ProfileRequestContext profileRequestContext) {
+ assert request != null;
for (final Map.Entry<String, List<CredentialDataset>> entry : request.getPreAuthorizedCredentials()
.entrySet()) {
final CredentialConfiguration configuration = getCredentialConfigurations().get(entry.getKey());
if (configuration == null) {
- log.error("{} Requested credential configuration id {} is not supported", getLogPrefix(),
+ log.warn("{} Requested credential configuration id {} is not supported", getLogPrefix(),
entry.getKey());
ActionSupport.buildEvent(profileRequestContext, OpenIDVCIEventIds.NO_CREDENTIALS_REQUEST);
return;
}
for (final CredentialDataset dataset : entry.getValue()) {
if (!hasAllMandatoryClaims(configuration, dataset.getContent())) {
- log.error("{} Requested credential {} is missing one or more mandatory claims", getLogPrefix(),
+ log.warn("{} Requested credential {} is missing one or more mandatory claims", getLogPrefix(),
entry.getKey());
ActionSupport.buildEvent(profileRequestContext, OpenIDVCIEventIds.NO_CREDENTIALS_REQUEST);
return;
@@ -155,6 +151,10 @@ public class ValidateCredentialOffering extends AbstractCredentialValidationActi
@Nonnull final List<Object> configPath) {
for (final CredentialOfferRequestedClaim requestedClaim : requestedCredential.getRequestedCredential()) {
final List<String> requestPath = requestedClaim.getPath();
+ if (requestPath.size() > configPath.size()
+ && requestPath.subList(0, configPath.size()).equals(configPath)) {
+ return true;
+ }
if (requestPath.size() <= configPath.size()
&& configPath.subList(0, requestPath.size()).equals(requestPath)
&& selects(requestedClaim.getValue(), configPath.subList(requestPath.size(), configPath.size()))) {
diff --git a/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/profile/impl/ValidateCredentialOfferingTest.java b/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/profile/impl/ValidateCredentialOfferingTest.java
index aec351f..8f78d29 100644
--- a/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/profile/impl/ValidateCredentialOfferingTest.java
+++ b/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/profile/impl/ValidateCredentialOfferingTest.java
@@ -27,6 +27,7 @@ import org.geant.shibboleth.plugin.openidvci.messaging.context.CredentialOfferCo
import org.geant.shibboleth.plugin.openidvci.messaging.impl.CredentialOfferRequest;
import org.geant.shibboleth.plugin.openidvci.profile.OpenIDVCIEventIds;
import org.opensaml.messaging.context.MessageContext;
+import org.opensaml.profile.action.EventIds;
import org.opensaml.profile.context.ProfileRequestContext;
import org.springframework.core.io.ClassPathResource;
import org.springframework.util.Assert;
@@ -85,13 +86,13 @@ public class ValidateCredentialOfferingTest {
@Test
public void testNoInboundMsgCtx() {
profileRequestCtx.setInboundMessageContext(null);
- ActionTestingSupport.assertEvent(action.execute(requestCtx), OpenIDVCIEventIds.NO_CREDENTIAL_REQUEST);
+ ActionTestingSupport.assertEvent(action.execute(requestCtx), EventIds.INVALID_MSG_CTX);
}
@Test
public void testNoInboundMsg() {
profileRequestCtx.getInboundMessageContext().setMessage(null);
- ActionTestingSupport.assertEvent(action.execute(requestCtx), OpenIDVCIEventIds.NO_CREDENTIAL_REQUEST);
+ ActionTestingSupport.assertEvent(action.execute(requestCtx), EventIds.INVALID_MSG_CTX);
}
private CredentialConfigurationsResolver resolverOf(final String path) throws Exception {
@@ -166,6 +167,47 @@ public class ValidateCredentialOfferingTest {
ActionTestingSupport.assertEvent(action.execute(requestCtx), OpenIDVCIEventIds.NO_CREDENTIALS_REQUEST);
}
+ @Test
+ public void testMandatoryClaimInDeeperPath() throws Exception {
+ HTTPRequest httpRequest = new HTTPRequest(HTTPRequest.Method.POST, new URI("http://example.com"));
+ httpRequest.setAuthorization("Basic dGVzdDp0ZXN0");
+ httpRequest.setContentType("application/json");
+ httpRequest.setBody(
+ "{\"preAuthorizedCredentials\":{\"GeantIncubatorDiploma\":[{\"path\":[\"mail\",\"work\"],\"value\":\"incubatorUser at example.org\"},{\"path\":[\"givenName\"],\"value\":\"Gemma\"}]}}");
+ profileRequestCtx.getInboundMessageContext().setMessage(CredentialOfferRequest.parse(httpRequest));
+ ActionTestingSupport.assertProceedEvent(action.execute(requestCtx));
+ }
+
+ @Test
+ public void testMandatoryClaimInDeeperPathOfOtherClaim() throws Exception {
+ HTTPRequest httpRequest = new HTTPRequest(HTTPRequest.Method.POST, new URI("http://example.com"));
+ httpRequest.setAuthorization("Basic dGVzdDp0ZXN0");
+ httpRequest.setContentType("application/json");
+ httpRequest.setBody(
+ "{\"preAuthorizedCredentials\":{\"GeantIncubatorDiploma\":[{\"path\":[\"edu\",\"mail\"],\"value\":\"incubatorUser at example.org\"},{\"path\":[\"givenName\"],\"value\":\"Gemma\"}]}}");
+ profileRequestCtx.getInboundMessageContext().setMessage(CredentialOfferRequest.parse(httpRequest));
+ ActionTestingSupport.assertEvent(action.execute(requestCtx), OpenIDVCIEventIds.NO_CREDENTIALS_REQUEST);
+ }
+
+ @Test
+ public void testMandatoryClaimInDeeperPathVcSdJwt() throws Exception {
+ HTTPRequest httpRequest = new HTTPRequest(HTTPRequest.Method.POST, new URI("http://example.com"));
+ httpRequest.setAuthorization("Basic dGVzdDp0ZXN0");
+ httpRequest.setContentType("application/json");
+ httpRequest.setBody(
+ "{\"preAuthorizedCredentials\":{\"GeantIncubatorDiploma2\":[{\"path\":[\"mail\",\"work\"],\"value\":\"incubatorUser at example.org\"}]}}");
+ profileRequestCtx.getInboundMessageContext().setMessage(CredentialOfferRequest.parse(httpRequest));
+ ActionTestingSupport.assertProceedEvent(action.execute(requestCtx));
+ }
+
+ @Test
+ public void testMandatoryDeeperRequestPathThanPointer() throws Exception {
+ ActionTestingSupport.assertProceedEvent(executeMandatory("["
+ + "{\"path\":[\"nationalities\"],\"value\":[\"DE\"]},"
+ + "{\"path\":[\"place_of_birth\",\"locality\",\"name\"],\"value\":\"Reykjavik\"},"
+ + "{\"path\":[\"evidence\"],\"value\":[{\"document\":{\"number\":\"53554554\"}}]}]"));
+ }
+
@Test(expectedExceptions = ParseException.class)
public void testCodeFlowRejected() throws Exception {
HTTPRequest httpRequest = new HTTPRequest(HTTPRequest.Method.POST, new URI("http://example.com"));
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list