[java-idp-plugin-vci] branch dev/PROOF updated: Validate proof signature when binding method id 'did:jwk'

Codeberg noreply at shibboleth.net
Wed Apr 8 17:03:24 UTC 2026


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

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

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

The following commit(s) were added to refs/heads/dev/PROOF by this push:
     new cf561c8  Validate proof signature when binding method id 'did:jwk'
cf561c8 is described below

commit cf561c87396f4ff5d7843350ea52b816dda9be80
Author: Janne Lauros <janne.lauros at csc.fi>
AuthorDate: Wed Apr 8 20:03:05 2026 +0300

    Validate proof signature when binding method id 'did:jwk'
---
 .../openidvci/security/TokenKeyTrustEngine.java    | 78 +++++++++++++++++
 .../impl/ExtendedJOSEObjectCredentialResolver.java | 99 ++++++++++++++++++++++
 .../idp/service/relying-party/postconfig.xml       |  7 +-
 3 files changed, 182 insertions(+), 2 deletions(-)

diff --git a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/security/TokenKeyTrustEngine.java b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/security/TokenKeyTrustEngine.java
new file mode 100644
index 0000000..771e256
--- /dev/null
+++ b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/security/TokenKeyTrustEngine.java
@@ -0,0 +1,78 @@
+/*
+ * 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.security;
+
+import java.security.PublicKey;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+import org.opensaml.security.SecurityException;
+import org.opensaml.security.credential.Credential;
+import org.opensaml.security.trust.TrustEngine;
+import org.slf4j.Logger;
+
+import com.nimbusds.jwt.SignedJWT;
+
+import net.shibboleth.oidc.security.credential.JOSEObjectCredentialResolver;
+import net.shibboleth.oidc.security.impl.BaseSignedJWTTrustEngine;
+import net.shibboleth.shared.annotation.ParameterName;
+import net.shibboleth.shared.primitive.LoggerFactory;
+import net.shibboleth.shared.resolver.CriteriaSet;
+
+/**
+ * A {@link TrustEngine} implementation for Signed JSON Web Tokens. The token
+ * derived public key is used as the trust basis.
+ * 
+ * Note, trust engine does not validate the jwk in any way but lets the wired
+ * resolver to do the work.
+ * 
+ */
+public class TokenKeyTrustEngine extends BaseSignedJWTTrustEngine<Credential> {
+
+    /** Class logger. */
+    @Nonnull
+    private final Logger log = LoggerFactory.getLogger(TokenKeyTrustEngine.class);
+
+    /**
+     * Constructor.
+     * 
+     * @param joseObjectResolver resolver of credentials from JOSEObject headers.
+     */
+    protected TokenKeyTrustEngine(
+            @Nonnull final @ParameterName(name = "JOSEObjectResolver") JOSEObjectCredentialResolver joseObjectResolver) {
+        super(joseObjectResolver);
+    }
+
+    @Override
+    /** {@inheritDoc} */
+    protected boolean doValidate(@Nonnull final SignedJWT signedJWT, @Nonnull final CriteriaSet trustBasisCriteria)
+            throws SecurityException {
+        return true;
+    }
+
+    @Override
+    /** {@inheritDoc} */
+    protected boolean evaluateTrust(@Nonnull final Credential untrustedCredential,
+            @Nullable final Credential trustBasis) throws SecurityException {
+        final PublicKey publicKey = untrustedCredential.getPublicKey();
+        if (publicKey != null && trustBasis != null) {
+            return publicKey.equals(trustBasis.getPublicKey());
+        }
+        return false;
+    }
+
+}
\ No newline at end of file
diff --git a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/security/credential/impl/ExtendedJOSEObjectCredentialResolver.java b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/security/credential/impl/ExtendedJOSEObjectCredentialResolver.java
new file mode 100644
index 0000000..64e7e62
--- /dev/null
+++ b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/security/credential/impl/ExtendedJOSEObjectCredentialResolver.java
@@ -0,0 +1,99 @@
+/*
+ * 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.security.credential.impl;
+
+import java.nio.charset.StandardCharsets;
+import java.text.ParseException;
+import java.util.Base64;
+import java.util.List;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+import org.opensaml.security.credential.Credential;
+import org.slf4j.Logger;
+
+import com.nimbusds.jose.JWEHeader;
+import com.nimbusds.jose.JWSHeader;
+import com.nimbusds.jose.jwk.JWK;
+
+import net.shibboleth.shared.annotation.constraint.NonnullElements;
+import net.shibboleth.shared.primitive.LoggerFactory;
+import net.shibboleth.oidc.security.credential.impl.BasicJOSEObjectCredentialResolver;
+
+public class ExtendedJOSEObjectCredentialResolver extends BasicJOSEObjectCredentialResolver {
+
+    /** Logger. */
+    @Nonnull
+    private final Logger log = LoggerFactory.getLogger(ExtendedJOSEObjectCredentialResolver.class);
+
+    /**
+     * Process credentials indicated by a JWS header.
+     * 
+     * @param jwsHeader the JWS header to process
+     * @return the list of credentials specified by the JWS header
+     */
+    @Override
+    @Nonnull
+    @NonnullElements
+    protected List<Credential> processJWSHeader(@Nonnull final JWSHeader jwsHeader) {
+        final List<Credential> credentials = super.processJWSHeader(jwsHeader);
+        addDidJwkCredentialIfPresent(credentials, jwsHeader.getKeyID());
+        return credentials;
+    }
+
+    /**
+     * Process JWE header into a list of credentials.
+     * 
+     * @param jweHeader header object
+     * 
+     * @return list of credentials.
+     */
+    @Override
+    @Nonnull
+    @NonnullElements
+    protected List<Credential> processJWEHeader(@Nonnull final JWEHeader jweHeader) {
+        final List<Credential> credentials = super.processJWEHeader(jweHeader);
+        addDidJwkCredentialIfPresent(credentials, jweHeader.getKeyID());
+        return credentials;
+    }
+
+    /**
+     * Add did:jwk credential of format
+     * https://github.com/quartzjer/did-jwk/blob/main/spec.md#did-url-1
+     * 
+     * @param credentials list of credentials.
+     * @param kid         did:jwk url of format
+     *                    https://github.com/quartzjer/did-jwk/blob/main/spec.md#did-url-1
+     */
+    protected void addDidJwkCredentialIfPresent(@Nonnull List<Credential> credentials, @Nullable String kid) {
+        if (kid != null && kid.startsWith("did:jwk:") && kid.endsWith("#0")) {
+            String encoded = kid.substring("did:jwk:".length(), kid.indexOf('#'));
+            try {
+                final JWK didJwk = JWK
+                        .parse(new String(Base64.getUrlDecoder().decode(encoded), StandardCharsets.UTF_8));
+                final Credential cred = buildJWKCredential(didJwk, kid);
+                if (cred != null) {
+                    credentials.add(cred);
+                }
+            } catch (ParseException e) {
+                log.warn("Failed parsing kid {} as did:jwk", kid, e);
+            }
+
+        }
+
+    }
+}
diff --git a/openid-vci-impl/src/main/resources/META-INF/net/shibboleth/idp/service/relying-party/postconfig.xml b/openid-vci-impl/src/main/resources/META-INF/net/shibboleth/idp/service/relying-party/postconfig.xml
index 3979946..19e7443 100644
--- a/openid-vci-impl/src/main/resources/META-INF/net/shibboleth/idp/service/relying-party/postconfig.xml
+++ b/openid-vci-impl/src/main/resources/META-INF/net/shibboleth/idp/service/relying-party/postconfig.xml
@@ -80,7 +80,10 @@
         p:signatureTrustEngine-ref="TokenAsymmetricKeyTrustEngineForProofJWT"/>
 
     <bean id="TokenAsymmetricKeyTrustEngineForProofJWT"
-        class="net.shibboleth.oidc.security.impl.TokenAsymmetricKeyTrustEngine"
-        c:JOSEObjectResolver-ref="defaultSignedJWTJOSEHeaderCredentialResolver" />
+        class="org.geant.shibboleth.plugin.openidvci.security.TokenKeyTrustEngine">
+        <constructor-arg>
+            <bean class="org.geant.shibboleth.plugin.openidvci.security.credential.impl.ExtendedJOSEObjectCredentialResolver"/>
+        </constructor-arg>
+    </bean>
 
 </beans>

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


More information about the commits mailing list