[java-idp-plugin-vci] 02/08: DefaultChainRevocationLifetimeLookupStrategy and RequestUtil imported from upstream

Codeberg noreply at shibboleth.net
Fri Sep 4 08:37:31 UTC 2026


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

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

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

commit 535c1970717c037cacbaff6801e899a59d6c1855
Author: Janne Lauros <janne.lauros at csc.fi>
AuthorDate: Fri Sep 4 09:34:11 2026 +0300

    DefaultChainRevocationLifetimeLookupStrategy and RequestUtil imported from upstream
---
 .../impl/StatusListAssignmentsRequestDecoder.java  |   2 +-
 .../impl/StatusListRevokeRequestDecoder.java       |   2 +-
 .../impl/CredentialOfferRequestDecoder.java        |   2 +
 .../impl/OpenIDVCICredentialsRequestDecoder.java   |   2 +
 .../impl/OpenIDVCITokenRequestDecoder.java         |   2 +
 .../openidvci/decoding/impl/RequestUtil.java       | 151 ---------------------
 .../openidvci/profile/impl/ValidateGrant.java      |  16 ++-
 ...faultChainRevocationLifetimeLookupStrategy.java |  75 ----------
 8 files changed, 18 insertions(+), 234 deletions(-)

diff --git a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/oauth/statuslist/decoding/impl/StatusListAssignmentsRequestDecoder.java b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/oauth/statuslist/decoding/impl/StatusListAssignmentsRequestDecoder.java
index 17156ef..ccfa594 100644
--- a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/oauth/statuslist/decoding/impl/StatusListAssignmentsRequestDecoder.java
+++ b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/oauth/statuslist/decoding/impl/StatusListAssignmentsRequestDecoder.java
@@ -22,7 +22,7 @@ import javax.annotation.Nonnull;
 
 import org.geant.shibboleth.plugin.oauth.statuslist.messaging.impl.StatusListAssignmentsRequest;
 import org.geant.shibboleth.plugin.openidvci.decoding.impl.BaseOpenIDVCIRequestDecoder;
-import org.geant.shibboleth.plugin.openidvci.decoding.impl.RequestUtil;
+import net.shibboleth.idp.plugin.oidc.op.decoding.impl.RequestUtil;
 import org.opensaml.messaging.decoder.MessageDecodingException;
 
 import com.google.common.base.MoreObjects;
diff --git a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/oauth/statuslist/decoding/impl/StatusListRevokeRequestDecoder.java b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/oauth/statuslist/decoding/impl/StatusListRevokeRequestDecoder.java
index 5bacc74..dd8d144 100644
--- a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/oauth/statuslist/decoding/impl/StatusListRevokeRequestDecoder.java
+++ b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/oauth/statuslist/decoding/impl/StatusListRevokeRequestDecoder.java
@@ -23,7 +23,7 @@ import javax.annotation.Nonnull;
 import org.geant.shibboleth.plugin.oauth.statuslist.StatusListParameters;
 import org.geant.shibboleth.plugin.oauth.statuslist.messaging.impl.StatusListRevokeRequest;
 import org.geant.shibboleth.plugin.openidvci.decoding.impl.BaseOpenIDVCIRequestDecoder;
-import org.geant.shibboleth.plugin.openidvci.decoding.impl.RequestUtil;
+import net.shibboleth.idp.plugin.oidc.op.decoding.impl.RequestUtil;
 import org.opensaml.messaging.decoder.MessageDecodingException;
 
 import com.google.common.base.MoreObjects;
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 1ab8a54..e49120c 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
@@ -27,6 +27,8 @@ 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 com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.google.common.base.MoreObjects;
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 5992f5d..75587d2 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
@@ -25,6 +25,8 @@ 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 com.google.common.base.MoreObjects;
 import com.nimbusds.oauth2.sdk.http.HTTPRequest;
 import com.nimbusds.oauth2.sdk.http.JakartaServletUtils;
diff --git a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/decoding/impl/OpenIDVCITokenRequestDecoder.java b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/decoding/impl/OpenIDVCITokenRequestDecoder.java
index 0c6644e..287e5e0 100644
--- a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/decoding/impl/OpenIDVCITokenRequestDecoder.java
+++ b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/decoding/impl/OpenIDVCITokenRequestDecoder.java
@@ -25,6 +25,8 @@ 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 com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.google.common.base.MoreObjects;
diff --git a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/decoding/impl/RequestUtil.java b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/decoding/impl/RequestUtil.java
deleted file mode 100644
index 4cab159..0000000
--- a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/decoding/impl/RequestUtil.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * 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.
- */
-
-// TODO: This class is copied as is from shibboleth project. Refactoring needed.
-
-package org.geant.shibboleth.plugin.openidvci.decoding.impl;
-
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import javax.annotation.Nullable;
-
-import com.google.common.base.MoreObjects;
-import com.nimbusds.oauth2.sdk.AuthorizationCodeGrant;
-import com.nimbusds.oauth2.sdk.AuthorizationGrant;
-import com.nimbusds.oauth2.sdk.ClientCredentialsGrant;
-import com.nimbusds.oauth2.sdk.RefreshTokenGrant;
-import com.nimbusds.oauth2.sdk.auth.ClientAuthentication;
-import com.nimbusds.oauth2.sdk.http.HTTPRequest;
-import com.nimbusds.oauth2.sdk.token.AccessToken;
-import com.nimbusds.oauth2.sdk.token.RefreshToken;
-
-/** Request logging helper class. */
-public final class RequestUtil {
-    
-    /** Private constructor. */
-    private RequestUtil() {
-        
-    }
-
-    /**
-     * Helper method to print request to string for logging.
-     * 
-     * @param httpReq request to be printed
-     * @return request as formatted string.
-     */
-    @Nullable public static String toString(@Nullable final HTTPRequest httpReq) {
-        if (httpReq == null) {
-            return null;
-        }
-        final String nl = System.lineSeparator();
-        String ret = httpReq.getMethod().toString() + nl;
-        final Map<String, List<String>> headers = httpReq.getHeaderMap();
-        if (headers != null) {
-            ret += "Headers:" + nl;
-            for (final Entry<String, List<String>> entry : headers.entrySet()) {
-                ret += "\t" + entry.getKey() + ":" + entry.getValue() + nl;
-            }
-        }
-        final Map<String, List<String>> parameters = httpReq.getQueryParameters();
-        if (parameters != null) {
-            ret += "Parameters:" + nl;
-            for (final Entry<String, List<String>> entry : parameters.entrySet()) {
-                ret += "\t" + entry.getKey() + ":" + entry.getValue().get(0) + nl;
-            }
-        }
-        return ret;
-    }
-
-    /**
-     * Helper method for getting protocol log message for client authentication object.
-     * 
-     * @param authentication The client authentication object
-     * @return The log message
-     */
-    @Nullable public static String getClientAuthenticationLog(@Nullable final ClientAuthentication authentication) {
-        return authentication == null ? null : MoreObjects.toStringHelper("ClientAuthentication").omitNullValues()
-                .add("clientId", authentication.getClientID())
-                .add("method", authentication.getMethod())
-                .toString();
-    }
-
-    /**
-     * Helper method for getting protocol log message for access token object.
-     * 
-     * @param accessToken The access token object
-     * @return The log message
-     */
-    @Nullable public static String getAccessTokenLog(@Nullable final AccessToken accessToken) {
-        return accessToken == null ? null : MoreObjects.toStringHelper("AccessToken").omitNullValues()
-                .add("lifetime", accessToken.getLifetime())
-                .add("issuedTokenType", accessToken.getIssuedTokenType())
-                .add("parameterNames", accessToken.getParameterNames())
-                .add("scope", accessToken.getScope())
-                .add("value", accessToken.getValue())
-                .add("type", accessToken.getType())
-                .toString();
-    }
-
-    /**
-     * Helper method for getting protocol log message for authorization grant object.
-     * 
-     * @param grant The authorization grant object
-     * @return The log message
-     */
-    @Nullable public static String getAuthorizationGrantLog(@Nullable final AuthorizationGrant grant) {
-        if (grant == null) {
-            return null;
-        }
-        if (grant instanceof AuthorizationCodeGrant) {
-            final AuthorizationCodeGrant codeGrant = (AuthorizationCodeGrant) grant;
-            return MoreObjects.toStringHelper(codeGrant).omitNullValues()
-                    .add("authorizationCode", codeGrant.getAuthorizationCode())
-                    .add("codeVerifier", codeGrant.getCodeVerifier())
-                    .add("redirectionURI", codeGrant.getRedirectionURI())
-                    .add("type", codeGrant.getType())
-                    .toString();
-        } else if (grant instanceof RefreshTokenGrant) {
-            final RefreshTokenGrant refreshGrant = (RefreshTokenGrant) grant;
-            return MoreObjects.toStringHelper(refreshGrant).omitNullValues()
-                    .add("refreshToken", getRefreshTokenLog(refreshGrant.getRefreshToken()))
-                    .add("type", refreshGrant.getType())
-                    .toString();
-        } else if (grant instanceof ClientCredentialsGrant) {
-            final ClientCredentialsGrant credentialsGrant = (ClientCredentialsGrant) grant;
-            return MoreObjects.toStringHelper(credentialsGrant).omitNullValues()
-                    .add("type", credentialsGrant.getType())
-                    .toString();
-
-        }
-        return MoreObjects.toStringHelper(grant).omitNullValues()
-                .add("type", grant.getType())
-                .toString();
-    }
-
-    /**
-     * Helper method for getting protocol log message for refresh token object.
-     * 
-     * @param refreshToken The refresh token object
-     * @return The log message
-     */
-    @Nullable public static String getRefreshTokenLog(@Nullable final RefreshToken refreshToken) {
-        return refreshToken == null ? null : MoreObjects.toStringHelper("RefreshToken").omitNullValues()
-                .add("parameterNames", refreshToken.getParameterNames())
-                .add("value", refreshToken.getValue())
-                .toString();
-    }
-
-}
diff --git a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/ValidateGrant.java b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/ValidateGrant.java
index 399341b..f5f68af 100644
--- a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/ValidateGrant.java
+++ b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/impl/ValidateGrant.java
@@ -1,12 +1,14 @@
 /*
- * 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
+ * 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,
+ * 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.
@@ -22,7 +24,7 @@ import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 
 import org.geant.shibboleth.plugin.openidvci.messaging.impl.AbstractOpenIDVCITokenResponseAction;
-import org.geant.shibboleth.plugin.openidvci.profile.logic.DefaultChainRevocationLifetimeLookupStrategy;
+import net.shibboleth.idp.plugin.oidc.op.profile.logic.DefaultChainRevocationLifetimeLookupStrategy;
 import org.opensaml.messaging.context.navigate.ChildContextLookup;
 import org.opensaml.profile.action.ActionSupport;
 import org.opensaml.profile.context.ProfileRequestContext;
@@ -58,7 +60,9 @@ import net.shibboleth.shared.primitive.LoggerFactory;
  * 
  * <p> The validated claims from the grant are stored to response context via
  * {@link OIDCAuthenticationResponseContext#getAuthorizationGrantClaimsSet()}.</p>
- * 
+ *
+ * <p>Derived from {@code ValidateGrant} of the OpenID Connect Provider plugin, in package
+ * {@code net.shibboleth.idp.plugin.oidc.op.profile.impl}, reduced to the grant types this plugin issues.</p>
  */
 public class ValidateGrant extends AbstractOpenIDVCITokenResponseAction {
 
diff --git a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/logic/DefaultChainRevocationLifetimeLookupStrategy.java b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/logic/DefaultChainRevocationLifetimeLookupStrategy.java
deleted file mode 100644
index 3d0f4bd..0000000
--- a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/profile/logic/DefaultChainRevocationLifetimeLookupStrategy.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * 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.logic;
-
-import java.time.Duration;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
-import org.opensaml.profile.context.ProfileRequestContext;
-import org.slf4j.Logger;
-
-import net.shibboleth.oidc.profile.config.navigate.RevocationLifetimeLookupFunction;
-import net.shibboleth.shared.logic.Constraint;
-import net.shibboleth.shared.primitive.LoggerFactory;
-
-/**
- * Default lookup function for fetching the chain revocation lifetime. This inherits the functionality of
- * {@link RevocationLifetimeLookupFunction} but also adds the configurable clock skew value and additional 5 minutes
- * to the returned value.
- */
-public class DefaultChainRevocationLifetimeLookupStrategy extends RevocationLifetimeLookupFunction {
-
-    /** Class logger. */
-    @Nonnull
-    private final Logger log = LoggerFactory.getLogger(DefaultChainRevocationLifetimeLookupStrategy.class);
-
-    /** Positive clock skew adjustment to consider when calculating revocation lifetime. */
-    @Nonnull private Duration clockSkew;
-
-    /**
-     * Constructor.
-     */
-    public DefaultChainRevocationLifetimeLookupStrategy() {
-        final Duration skew = Duration.ofMinutes(5);
-        assert skew != null;
-        clockSkew = skew;
-    }
-
-    /**
-     * Set the clock skew.
-     * 
-     * @param skew clock skew to set
-     */
-    public void setClockSkew(@Nonnull final Duration skew) {
-        final Duration newValue = Constraint.isNotNull(skew, "Clock skew cannot be null").abs();
-        assert newValue != null;
-        clockSkew = newValue;
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    @Nullable
-    public Duration apply(@Nullable final ProfileRequestContext input) {
-        final Duration profileDuration = super.apply(input);
-        if (profileDuration == null || profileDuration.isZero()) {
-            log.debug("No chain expiration time could be resolved, returning null");
-            return null;            
-        }
-        return profileDuration.plus(Duration.ofMinutes(5)).plus(clockSkew);
-    }
-    
-}
\ No newline at end of file

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


More information about the commits mailing list