[java-idp-plugin-oidc-op-oidfed] branch main updated: Wired access and refresh token claims set decorators
Henri Mikkonen
henri.mikkonen at iki.fi
Fri Oct 10 10:09:20 UTC 2025
This is an automated email from the git hooks/post-receive script.
hjmikkon pushed a commit to branch main
in repository java-idp-plugin-oidc-op-oidfed.
View the commit online:
http://git.shibboleth.net/view/?p=java-idp-plugin-oidc-op-oidfed.git;a=commit;h=e4b91a6eff15ade87790d9b9903f96b9e3ff0ba1
The following commit(s) were added to refs/heads/main by this push:
new e4b91a6 Wired access and refresh token claims set decorators
e4b91a6 is described below
commit e4b91a6eff15ade87790d9b9903f96b9e3ff0ba1
Author: Henri Mikkonen <henri.mikkonen at iki.fi>
AuthorDate: Fri Oct 10 13:08:34 2025 +0300
Wired access and refresh token claims set decorators
They populate the automatically registered trust chain to the claims set.
---
...redTrustChainAccessTokenClaimsSetDecorator.java | 75 ++++++++++++++++++++++
...edTrustChainRefreshTokenClaimsSetDecorator.java | 75 ++++++++++++++++++++++
.../META-INF/net.shibboleth.idp/postconfig.xml | 6 ++
.../oidfed/TokenFlowAutomaticRegistrationTest.java | 13 ++++
4 files changed, 169 insertions(+)
diff --git a/idp-oidfed-op-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/oidfed/profile/impl/AutoRegisteredTrustChainAccessTokenClaimsSetDecorator.java b/idp-oidfed-op-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/oidfed/profile/impl/AutoRegisteredTrustChainAccessTokenClaimsSetDecorator.java
new file mode 100644
index 0000000..0200d3e
--- /dev/null
+++ b/idp-oidfed-op-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/oidfed/profile/impl/AutoRegisteredTrustChainAccessTokenClaimsSetDecorator.java
@@ -0,0 +1,75 @@
+/*
+ * 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 net.shibboleth.idp.plugin.oidc.op.oidfed.profile.impl;
+
+import java.util.List;
+import java.util.Map;
+import java.util.function.Function;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+import org.opensaml.profile.context.ProfileRequestContext;
+
+import net.shibboleth.idp.plugin.oidc.op.oidfed.profile.navigate.DefaultSelectedTrustChainIDsLookupStrategy;
+import net.shibboleth.idp.plugin.oidc.op.oidfed.support.ClaimsSetExtensionSupport;
+import net.shibboleth.idp.plugin.oidc.op.profile.AccessTokenClaimsSetDecorator;
+import net.shibboleth.shared.component.AbstractIdentifiableInitializableComponent;
+import net.shibboleth.shared.logic.Constraint;
+
+/**
+ * The decorator that adds a custom claim {@link ClaimsSetExtensionSupport#KEY_AUTO_REGISTERED_TRUST_CHAIN} to the
+ * access token claims set if a value was resolved via {@link #selectedTrustChainIDsLookupStrategy}.
+ */
+public class AutoRegisteredTrustChainAccessTokenClaimsSetDecorator extends AbstractIdentifiableInitializableComponent
+ implements AccessTokenClaimsSetDecorator {
+
+ /** The strategy used to locate IDs for the selected trust chain. */
+ @Nonnull private Function<ProfileRequestContext,List<String>> selectedTrustChainIDsLookupStrategy;
+
+ /**
+ * Constructor.
+ */
+ public AutoRegisteredTrustChainAccessTokenClaimsSetDecorator() {
+ selectedTrustChainIDsLookupStrategy = new DefaultSelectedTrustChainIDsLookupStrategy();
+ }
+
+ /**
+ * Set the lookup strategy used to locate IDs for the selected trust chain.
+ *
+ * @param strategy What to set
+ */
+ public void setSelectedTrustChainIDsLookupStrategy(
+ @Nonnull final Function<ProfileRequestContext, List<String>> strategy) {
+ checkSetterPreconditions();
+
+ selectedTrustChainIDsLookupStrategy = Constraint.isNotNull(strategy,
+ "SelectedTrustChainIDsLookupStrategy lookup strategy cannot be null");
+ }
+ /** {@inheritDoc} */
+ @Override
+ public void accept(@Nullable final Map<String, Object> claimsSet,
+ @Nullable final ProfileRequestContext profileRequestContext) {
+ checkComponentActive();
+ if (claimsSet != null) {
+ final List<String> trustChainIds = selectedTrustChainIDsLookupStrategy.apply(profileRequestContext);
+ if (trustChainIds != null && !trustChainIds.isEmpty()) {
+ claimsSet.put(ClaimsSetExtensionSupport.KEY_AUTO_REGISTERED_TRUST_CHAIN, trustChainIds);
+ }
+
+ }
+ }
+
+}
diff --git a/idp-oidfed-op-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/oidfed/profile/impl/AutoRegisteredTrustChainRefreshTokenClaimsSetDecorator.java b/idp-oidfed-op-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/oidfed/profile/impl/AutoRegisteredTrustChainRefreshTokenClaimsSetDecorator.java
new file mode 100644
index 0000000..b3c59d7
--- /dev/null
+++ b/idp-oidfed-op-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/oidfed/profile/impl/AutoRegisteredTrustChainRefreshTokenClaimsSetDecorator.java
@@ -0,0 +1,75 @@
+/*
+ * 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 net.shibboleth.idp.plugin.oidc.op.oidfed.profile.impl;
+
+import java.util.List;
+import java.util.Map;
+import java.util.function.Function;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+import org.opensaml.profile.context.ProfileRequestContext;
+
+import net.shibboleth.idp.plugin.oidc.op.oidfed.profile.navigate.DefaultSelectedTrustChainIDsLookupStrategy;
+import net.shibboleth.idp.plugin.oidc.op.oidfed.support.ClaimsSetExtensionSupport;
+import net.shibboleth.idp.plugin.oidc.op.profile.RefreshTokenClaimsSetDecorator;
+import net.shibboleth.shared.component.AbstractIdentifiableInitializableComponent;
+import net.shibboleth.shared.logic.Constraint;
+
+/**
+ * The decorator that adds a custom claim {@link ClaimsSetExtensionSupport#KEY_AUTO_REGISTERED_TRUST_CHAIN} to the
+ * refresh token claims set if a value was resolved via {@link #selectedTrustChainIDsLookupStrategy}.
+ */
+public class AutoRegisteredTrustChainRefreshTokenClaimsSetDecorator extends AbstractIdentifiableInitializableComponent
+ implements RefreshTokenClaimsSetDecorator {
+
+ /** The strategy used to locate IDs for the selected trust chain. */
+ @Nonnull private Function<ProfileRequestContext,List<String>> selectedTrustChainIDsLookupStrategy;
+
+ /**
+ * Constructor.
+ */
+ public AutoRegisteredTrustChainRefreshTokenClaimsSetDecorator() {
+ selectedTrustChainIDsLookupStrategy = new DefaultSelectedTrustChainIDsLookupStrategy();
+ }
+
+ /**
+ * Set the lookup strategy used to locate IDs for the selected trust chain.
+ *
+ * @param strategy What to set
+ */
+ public void setSelectedTrustChainIDsLookupStrategy(
+ @Nonnull final Function<ProfileRequestContext, List<String>> strategy) {
+ checkSetterPreconditions();
+
+ selectedTrustChainIDsLookupStrategy = Constraint.isNotNull(strategy,
+ "SelectedTrustChainIDsLookupStrategy lookup strategy cannot be null");
+ }
+ /** {@inheritDoc} */
+ @Override
+ public void accept(@Nullable final Map<String, Object> claimsSet,
+ @Nullable final ProfileRequestContext profileRequestContext) {
+ checkComponentActive();
+ if (claimsSet != null) {
+ final List<String> trustChainIds = selectedTrustChainIDsLookupStrategy.apply(profileRequestContext);
+ if (trustChainIds != null && !trustChainIds.isEmpty()) {
+ claimsSet.put(ClaimsSetExtensionSupport.KEY_AUTO_REGISTERED_TRUST_CHAIN, trustChainIds);
+ }
+
+ }
+ }
+
+}
diff --git a/idp-oidfed-op-impl/src/main/resources/META-INF/net.shibboleth.idp/postconfig.xml b/idp-oidfed-op-impl/src/main/resources/META-INF/net.shibboleth.idp/postconfig.xml
index 2bae86d..69e01a8 100644
--- a/idp-oidfed-op-impl/src/main/resources/META-INF/net.shibboleth.idp/postconfig.xml
+++ b/idp-oidfed-op-impl/src/main/resources/META-INF/net.shibboleth.idp/postconfig.xml
@@ -441,6 +441,12 @@
<bean id="AutoRegisteredTrustChainAuthorizationCodeClaimsSetDecorator"
class="net.shibboleth.idp.plugin.oidc.op.oidfed.profile.impl.AutoRegisteredTrustChainAuthorizationCodeClaimsSetDecorator" />
+ <bean id="AutoRegisteredTrustChainAccessTokenClaimsSetDecorator"
+ class="net.shibboleth.idp.plugin.oidc.op.oidfed.profile.impl.AutoRegisteredTrustChainAccessTokenClaimsSetDecorator" />
+
+ <bean id="AutoRegisteredTrustChainRefreshTokenClaimsSetDecorator"
+ class="net.shibboleth.idp.plugin.oidc.op.oidfed.profile.impl.AutoRegisteredTrustChainRefreshTokenClaimsSetDecorator" />
+
<bean id="AutoRegisteredTrustChainRequestUriClaimsSetDecorator"
class="net.shibboleth.idp.plugin.oidc.op.oidfed.profile.impl.AutoRegisteredTrustChainRequestUriClaimsSetDecorator" />
diff --git a/idp-oidfed-op-impl/src/test/java/net/shibboleth/idp/plugin/oidc/op/profile/flow/oidfed/TokenFlowAutomaticRegistrationTest.java b/idp-oidfed-op-impl/src/test/java/net/shibboleth/idp/plugin/oidc/op/profile/flow/oidfed/TokenFlowAutomaticRegistrationTest.java
index 0c5928b..ad89015 100644
--- a/idp-oidfed-op-impl/src/test/java/net/shibboleth/idp/plugin/oidc/op/profile/flow/oidfed/TokenFlowAutomaticRegistrationTest.java
+++ b/idp-oidfed-op-impl/src/test/java/net/shibboleth/idp/plugin/oidc/op/profile/flow/oidfed/TokenFlowAutomaticRegistrationTest.java
@@ -39,6 +39,7 @@ import com.nimbusds.openid.connect.sdk.OIDCTokenResponse;
import net.shibboleth.idp.plugin.oidc.op.oidfed.support.ClaimsSetExtensionSupport;
import net.shibboleth.idp.plugin.oidc.op.profile.flow.TokenFlowTest;
+import net.shibboleth.idp.plugin.oidc.op.token.support.AccessTokenClaimsSet;
import net.shibboleth.idp.plugin.oidc.op.token.support.AuthorizeCodeClaimsSet;
import net.shibboleth.shared.security.impl.SecureRandomIdentifierGenerationStrategy;
@@ -67,6 +68,10 @@ public class TokenFlowAutomaticRegistrationTest extends AbstractFederationFlowTe
ClientAuthenticationMethod.PRIVATE_KEY_JWT, null, requestParameters);
final OIDCTokenResponse response = parseSuccessResponse(result, OIDCTokenResponse.class);
Assert.assertNotNull(response.getTokens().getAccessToken());
+ final AccessTokenClaimsSet tokenClaims =
+ AccessTokenClaimsSet.parse(response.getTokens().getAccessToken().getValue(), getDataSealer());
+ Assert.assertEquals(tokenClaims.getClaimsSet().getStringListClaim(ClaimsSetExtensionSupport
+ .KEY_AUTO_REGISTERED_TRUST_CHAIN), List.of(clientId, anchorId));
Assert.assertNotNull(response.getOIDCTokens().getIDToken());
Assert.assertNotNull(response.getOIDCTokens().getIDToken().getJWTClaimsSet().getClaim("at_hash"));
}
@@ -87,6 +92,10 @@ public class TokenFlowAutomaticRegistrationTest extends AbstractFederationFlowTe
ClientAuthenticationMethod.PRIVATE_KEY_JWT, null, requestParameters);
final OIDCTokenResponse response = parseSuccessResponse(result, OIDCTokenResponse.class);
Assert.assertNotNull(response.getTokens().getAccessToken());
+ final AccessTokenClaimsSet tokenClaims =
+ AccessTokenClaimsSet.parse(response.getTokens().getAccessToken().getValue(), getDataSealer());
+ Assert.assertEquals(tokenClaims.getClaimsSet().getStringListClaim(ClaimsSetExtensionSupport
+ .KEY_AUTO_REGISTERED_TRUST_CHAIN), List.of(clientId, anchorId));
Assert.assertNotNull(response.getOIDCTokens().getIDToken());
Assert.assertNotNull(response.getOIDCTokens().getIDToken().getJWTClaimsSet().getClaim("at_hash"));
}
@@ -143,6 +152,10 @@ public class TokenFlowAutomaticRegistrationTest extends AbstractFederationFlowTe
ClientAuthenticationMethod.PRIVATE_KEY_JWT, null, requestParameters);
final OIDCTokenResponse response = parseSuccessResponse(result, OIDCTokenResponse.class);
Assert.assertNotNull(response.getTokens().getAccessToken());
+ final AccessTokenClaimsSet tokenClaims =
+ AccessTokenClaimsSet.parse(response.getTokens().getAccessToken().getValue(), getDataSealer());
+ Assert.assertEquals(tokenClaims.getClaimsSet().getStringListClaim(ClaimsSetExtensionSupport
+ .KEY_AUTO_REGISTERED_TRUST_CHAIN), List.of(clientId, anchorId));
Assert.assertNotNull(response.getOIDCTokens().getIDToken());
Assert.assertNotNull(response.getOIDCTokens().getIDToken().getJWTClaimsSet().getClaim("at_hash"));
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list