[java-idp-plugin-vci] 03/06: status-list list flow review, inbound intercept, profile counter, 500 default, OP nimbus encoder, response headers set by the action
Codeberg
noreply at shibboleth.net
Thu Nov 12 14:29:38 UTC 2026
This is an automated email from the git hooks/post-receive script.
codeberg pushed a commit to branch main
in repository java-idp-plugin-vci.
View the commit online:
https://codeberg.org/Shibboleth/java-idp-plugin-vci/commit/f1f842787068e0d7663330a41c41d06dd6fe1293
commit f1f842787068e0d7663330a41c41d06dd6fe1293
Author: Janne Lauros <janne.lauros at csc.fi>
AuthorDate: Thu Nov 12 15:24:19 2026 +0200
status-list list flow review, inbound intercept, profile counter, 500 default, OP nimbus encoder, response headers set by the action
---
.../impl/DefaultStatusListConfiguration.java | 11 +-
.../FormOutboundStatusListResponseMessage.java | 54 ++++++-
.../flows/oauth/status-list/list/list-beans.xml | 35 ++---
.../idp/flows/oauth/status-list/list/list-flow.xml | 7 +
.../idp/service/relying-party/postconfig.xml | 1 +
.../impl/DefaultStatusListConfigurationTest.java | 59 ++++++++
.../FormOutboundStatusListResponseMessageTest.java | 160 +++++++++++++++++++++
7 files changed, 292 insertions(+), 35 deletions(-)
diff --git a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/statuslist/profile/config/impl/DefaultStatusListConfiguration.java b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/statuslist/profile/config/impl/DefaultStatusListConfiguration.java
index 52e6c2c..0a88abc 100644
--- a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/statuslist/profile/config/impl/DefaultStatusListConfiguration.java
+++ b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/statuslist/profile/config/impl/DefaultStatusListConfiguration.java
@@ -47,6 +47,11 @@ public class DefaultStatusListConfiguration extends AbstractInterceptorAwareProf
@NotEmpty
public static final String PROFILE_ID = "http://geant.org/ns/profiles/oauth/status-list";
+ /** Status list profile counter name. */
+ @Nonnull
+ @NotEmpty
+ public static final String PROFILE_COUNTER = "net.shibboleth.idp.profiles.oauth.status-list.list";
+
/** Signing of Status List Tokens. */
@Nonnull
private Function<ProfileRequestContext, SignatureSigningConfiguration>
@@ -62,12 +67,6 @@ public class DefaultStatusListConfiguration extends AbstractInterceptorAwareProf
* Get the {@link SignatureSigningConfiguration} used for signing Status List
* Tokens.
*
- * <p>
- * Status List Token names same issuer as tokens referring to it. While issuer is
- * derived from signing key, like did:jwk is, this must resolve to same key those
- * tokens are signed with.
- * </p>
- *
* @param profileRequestContext current profile request context
*
* @return the signature signing configuration to use
diff --git a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/statuslist/profile/impl/FormOutboundStatusListResponseMessage.java b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/statuslist/profile/impl/FormOutboundStatusListResponseMessage.java
index b14cd0e..7134355 100644
--- a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/statuslist/profile/impl/FormOutboundStatusListResponseMessage.java
+++ b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/statuslist/profile/impl/FormOutboundStatusListResponseMessage.java
@@ -19,7 +19,11 @@ package org.geant.shibboleth.plugin.openidvci.statuslist.profile.impl;
import java.util.function.Function;
import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import jakarta.servlet.http.HttpServletResponse;
+
+import org.geant.shibboleth.plugin.openidvci.profile.impl.HttpHeaderSupport;
import org.geant.shibboleth.plugin.openidvci.statuslist.context.StatusListTokenContext;
import org.geant.shibboleth.plugin.openidvci.statuslist.messaging.impl.StatusListCwtResponse;
import org.geant.shibboleth.plugin.openidvci.statuslist.messaging.impl.StatusListSuccessResponse;
@@ -30,8 +34,11 @@ import org.opensaml.profile.context.ProfileRequestContext;
import org.opensaml.profile.context.navigate.OutboundMessageContextLookup;
import org.slf4j.Logger;
+import com.google.common.net.HttpHeaders;
+
import net.shibboleth.idp.profile.AbstractProfileAction;
-import net.shibboleth.shared.annotation.constraint.NonnullBeforeExec;
+import net.shibboleth.idp.profile.IdPEventIds;
+import net.shibboleth.shared.annotation.constraint.NotEmpty;
import net.shibboleth.shared.logic.Constraint;
import net.shibboleth.shared.primitive.LoggerFactory;
@@ -41,14 +48,33 @@ import net.shibboleth.shared.primitive.LoggerFactory;
*/
public class FormOutboundStatusListResponseMessage extends AbstractProfileAction {
+ /** Value of the X-Content-Type-Options header. */
+ @Nonnull
+ @NotEmpty
+ public static final String NOSNIFF = "nosniff";
+
+ /** Value of the Access-Control-Allow-Origin header. */
+ @Nonnull
+ @NotEmpty
+ public static final String ALLOW_ANY_ORIGIN = "*";
+
+ /** Name of the claim stating how long the token may be cached. */
+ @Nonnull
+ @NotEmpty
+ private static final String TTL_CLAIM = "ttl";
+
/** Class logger. */
@Nonnull
- private Logger log = LoggerFactory.getLogger(FormOutboundStatusListResponseMessage.class);
+ private final Logger log = LoggerFactory.getLogger(FormOutboundStatusListResponseMessage.class);
/** Status list token context. */
- @NonnullBeforeExec
+ @Nullable
private StatusListTokenContext ctx;
+ /** Seconds the token may be cached. */
+ @Nullable
+ private Long maxAge;
+
/** Strategy used to locate the status list token context. */
@Nonnull
private Function<ProfileRequestContext, StatusListTokenContext> statusListTokenContextLookupStrategy;
@@ -88,12 +114,34 @@ public class FormOutboundStatusListResponseMessage extends AbstractProfileAction
return false;
}
+ maxAge = ctx.getClaims() != null && ctx.getClaims().getClaim(TTL_CLAIM) instanceof Number ttl
+ ? Long.valueOf(ttl.longValue()) : null;
+ if (maxAge == null) {
+ log.error("{} Status list token states no ttl", getLogPrefix());
+ ActionSupport.buildEvent(profileRequestContext, EventIds.INVALID_PROFILE_CTX);
+ return false;
+ }
+
return true;
}
/** {@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;
+ }
+ assert ctx != null;
+
+ response.setHeader(HttpHeaders.CACHE_CONTROL, "max-age=" + maxAge);
+ HttpHeaderSupport.addVary(response, HttpHeaders.ACCEPT);
+ response.setHeader(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN, ALLOW_ANY_ORIGIN);
+ response.setHeader(HttpHeaders.X_CONTENT_TYPE_OPTIONS, NOSNIFF);
+
if (ctx.getSignedCwt() != null) {
profileRequestContext.ensureOutboundMessageContext()
.setMessage(new StatusListCwtResponse(ctx.getSignedCwt()));
diff --git a/openid-vci-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/oauth/status-list/list/list-beans.xml b/openid-vci-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/oauth/status-list/list/list-beans.xml
index a47ff06..1aedc66 100644
--- a/openid-vci-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/oauth/status-list/list/list-beans.xml
+++ b/openid-vci-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/oauth/status-list/list/list-beans.xml
@@ -11,10 +11,13 @@
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.profileId" class="java.lang.String" c:_0="http://geant.org/ns/profiles/oauth/status-list"/>
+ <bean id="openidvci.profileId" class="java.lang.String"
+ c:_0="#{T(org.geant.shibboleth.plugin.openidvci.statuslist.profile.config.impl.DefaultStatusListConfiguration).PROFILE_ID}"/>
<bean id="openidvci.loggingId" class="java.lang.String"
c:_0="%{openidvci.logging.status-list.list:OAuth.StatusList}"/>
-
+ <util:constant id="shibboleth.metrics.ProfileCounter"
+ static-field="org.geant.shibboleth.plugin.openidvci.statuslist.profile.config.impl.DefaultStatusListConfiguration.PROFILE_COUNTER"/>
+
<bean id="InitializeUnverifiedRelyingPartyContext"
class="net.shibboleth.idp.plugin.oidc.op.profile.impl.InitializeUnverifiedRelyingPartyContext" scope="prototype" />
@@ -23,24 +26,13 @@
scope="prototype" p:noResultIsError="true"
c:strategy-ref="shibboleth.MessageContextLookup.Outbound">
<property name="configurationLookupStrategy">
- <bean lazy-init="true"
- class="org.geant.shibboleth.plugin.openidvci.statuslist.profile.config.navigate.StatusListSignatureSigningConfigurationLookupFunction" />
+ <bean class="org.geant.shibboleth.plugin.openidvci.statuslist.profile.config.navigate.StatusListSignatureSigningConfigurationLookupFunction" />
</property>
- <!--
- Status List Token is signed with issuer's own key. Basic resolver is used, client
- information aware one would offer client secret as signing credential. There is no
- client to ask algorithm from either, endpoint is unauthenticated and serves verifiers.
- -->
<property name="signatureSigningParametersResolver">
<bean class="net.shibboleth.oidc.security.jose.impl.BasicSignatureSigningParametersResolver" />
</property>
</bean>
- <bean id="openidvci.IssuerLookupStrategy"
- class="org.geant.shibboleth.plugin.openidvci.profile.logic.CredentialIssuerLookupFunction"
- p:issuer="%{openidvci.issuer:}"
- p:deploymentIssuer="#{getObject('shibboleth.oidc.issuer')}" />
-
<bean id="FormStatusListToken"
class="org.geant.shibboleth.plugin.openidvci.statuslist.profile.impl.FormStatusListToken"
scope="prototype"
@@ -62,7 +54,7 @@
<bean id="OpenIDVCIFormOutboundMessage"
class="org.geant.shibboleth.plugin.openidvci.statuslist.profile.impl.FormOutboundStatusListResponseMessage"
- scope="prototype" />
+ scope="prototype" p:httpServletResponseSupplier-ref="shibboleth.HttpServletResponseSupplier" />
<!-- Encoders of CommitStatusListResponse, JWT and CWT. -->
<bean id="EncodeStatusListResponse" class="org.opensaml.profile.action.impl.EncodeMessage" scope="prototype"
@@ -70,37 +62,28 @@
<property name="messageEncoderFactory">
<bean class="org.geant.shibboleth.plugin.openidvci.statuslist.encoding.impl.StatusListResponseEncoderFactory"
scope="prototype"
- p:messageEncoder-ref="openidvci.status-list.NimbusEncoder"
+ p:messageEncoder-ref="oidc.nimbusEncoder"
p:cwtMessageEncoder-ref="openidvci.status-list.CwtEncoder" />
</property>
</bean>
- <bean id="openidvci.status-list.NimbusEncoder"
- class="net.shibboleth.idp.plugin.oidc.op.encoding.impl.NimbusResponseEncoder" scope="prototype"
- init-method="" p:httpServletResponseSupplier-ref="shibboleth.HttpServletResponseSupplier"
- p:velocityEngine-ref="shibboleth.VelocityEngine"
- p:objectMapper-ref="#{'%{idp.oidc.logging.objectMapper:shibboleth.oidc.JSONObjectMapper}'.trim()}" />
-
<bean id="openidvci.status-list.CwtEncoder"
class="org.geant.shibboleth.plugin.openidvci.statuslist.encoding.impl.StatusListCwtResponseEncoder"
scope="prototype" init-method=""
p:httpServletResponseSupplier-ref="shibboleth.HttpServletResponseSupplier" />
<bean id="OpenIDVCIBuildErrorResponseFromEvent" class="net.shibboleth.oidc.profile.impl.BuildJSONErrorResponseFromEvent"
- scope="prototype" p:defaultStatusCode="400" p:defaultCode="invalid_request"
+ scope="prototype" p:defaultStatusCode="500" p:defaultCode="server_error"
p:httpServletResponseSupplier-ref="shibboleth.HttpServletResponseSupplier">
<property name="eventContextLookupStrategy">
<bean class="net.shibboleth.idp.profile.context.navigate.WebFlowCurrentEventLookupFunction" />
</property>
<property name="mappedErrors">
<map value-type="com.nimbusds.oauth2.sdk.ErrorObject">
- <!-- Unknown list is 404 and a retired list is 410, so a verifier can tell them apart. -->
<entry key="#{T(org.geant.shibboleth.plugin.openidvci.statuslist.profile.StatusListEventIds).NO_STATUS_LIST}"
value="#{T(org.geant.shibboleth.plugin.openidvci.statuslist.messaging.error.StatusListError).UNKNOWN_STATUS_LIST}" />
<entry key="#{T(org.geant.shibboleth.plugin.openidvci.statuslist.profile.StatusListEventIds).STATUS_LIST_RETIRED}"
value="#{T(org.geant.shibboleth.plugin.openidvci.statuslist.messaging.error.StatusListError).RETIRED_STATUS_LIST}" />
- <entry key="#{T(org.opensaml.profile.action.EventIds).IO_ERROR}"
- value="#{T(com.nimbusds.oauth2.sdk.OAuth2Error).SERVER_ERROR}" />
</map>
</property>
</bean>
diff --git a/openid-vci-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/oauth/status-list/list/list-flow.xml b/openid-vci-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/oauth/status-list/list/list-flow.xml
index 55cc94e..d486a2e 100644
--- a/openid-vci-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/oauth/status-list/list/list-flow.xml
+++ b/openid-vci-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/oauth/status-list/list/list-flow.xml
@@ -5,6 +5,7 @@
parent="openid/vci/abstract-api">
<on-start>
+ <set name="flowScope.transitionAfterInboundIntercept" value="'BuildStatusListToken'" />
<set name="flowScope.transitionAfterOutboundIntercept" value="'CommitStatusListResponse'" />
</on-start>
@@ -16,6 +17,12 @@
<evaluate expression="InitializeUnverifiedRelyingPartyContext" />
<evaluate expression="SelectRelyingPartyConfiguration" />
<evaluate expression="SelectProfileConfiguration" />
+ <evaluate expression="PopulateInboundInterceptContext"/>
+ <evaluate expression="'proceed'"/>
+ <transition on="proceed" to="CheckInboundInterceptContext"/>
+ </action-state>
+
+ <action-state id="BuildStatusListToken">
<evaluate expression="PopulateStatusListSignatureSigningParameters" />
<evaluate expression="FormStatusListToken" />
<evaluate expression="SignStatusListToken" />
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 a4873ac..3a804f3 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
@@ -105,6 +105,7 @@
p:credentialSignatureSigningConfiguration="#{getObject('openidvci.SigningConfiguration')}"
p:statusListSignatureSigningConfiguration="#{getObject('openidvci.status-list.SigningConfiguration')}" />
+ <!-- Endpoint publishing Status List Tokens. -->
<bean id="OAuth.StatusList" lazy-init="true"
class="org.geant.shibboleth.plugin.openidvci.statuslist.profile.config.impl.DefaultStatusListConfiguration"
p:securityConfiguration-ref="%{idp.security.oidc.config:shibboleth.oidc.DefaultSecurityConfiguration}"
diff --git a/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/statuslist/profile/config/impl/DefaultStatusListConfigurationTest.java b/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/statuslist/profile/config/impl/DefaultStatusListConfigurationTest.java
new file mode 100644
index 0000000..6b9016c
--- /dev/null
+++ b/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/statuslist/profile/config/impl/DefaultStatusListConfigurationTest.java
@@ -0,0 +1,59 @@
+/*
+ * 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.config.impl;
+
+import java.util.List;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import net.shibboleth.oidc.security.jose.impl.BasicSignatureSigningConfiguration;
+
+/** Tests for {@link DefaultStatusListConfiguration}. */
+public class DefaultStatusListConfigurationTest {
+
+ @Test
+ public void testId() {
+ Assert.assertEquals(new DefaultStatusListConfiguration().getId(),
+ "http://geant.org/ns/profiles/oauth/status-list");
+ }
+
+ @Test
+ public void testCounter() {
+ Assert.assertEquals(DefaultStatusListConfiguration.PROFILE_COUNTER,
+ "net.shibboleth.idp.profiles.oauth.status-list.list");
+ }
+
+ @Test
+ public void testNoInterceptorFlowsByDefault() {
+ final DefaultStatusListConfiguration configuration = new DefaultStatusListConfiguration();
+
+ Assert.assertEquals(configuration.getInboundInterceptorFlows(null), List.of());
+ Assert.assertEquals(configuration.getOutboundInterceptorFlows(null), List.of());
+ }
+
+ @Test
+ public void testSigningConfiguration() {
+ final DefaultStatusListConfiguration configuration = new DefaultStatusListConfiguration();
+ Assert.assertNull(configuration.getStatusListSignatureSigningConfiguration(null));
+
+ final BasicSignatureSigningConfiguration signing = new BasicSignatureSigningConfiguration();
+ configuration.setStatusListSignatureSigningConfiguration(signing);
+ Assert.assertSame(configuration.getStatusListSignatureSigningConfiguration(null), signing);
+ }
+
+}
diff --git a/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/statuslist/profile/impl/FormOutboundStatusListResponseMessageTest.java b/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/statuslist/profile/impl/FormOutboundStatusListResponseMessageTest.java
new file mode 100644
index 0000000..46932a1
--- /dev/null
+++ b/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/statuslist/profile/impl/FormOutboundStatusListResponseMessageTest.java
@@ -0,0 +1,160 @@
+/*
+ * 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.util.List;
+
+import org.geant.shibboleth.plugin.openidvci.statuslist.context.StatusListTokenContext;
+import org.geant.shibboleth.plugin.openidvci.statuslist.messaging.impl.StatusListCwtResponse;
+import org.geant.shibboleth.plugin.openidvci.statuslist.messaging.impl.StatusListSuccessResponse;
+import org.opensaml.messaging.context.MessageContext;
+import org.opensaml.profile.action.EventIds;
+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 com.nimbusds.jwt.JWTClaimsSet;
+
+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 FormOutboundStatusListResponseMessage}. */
+public class FormOutboundStatusListResponseMessageTest {
+
+ private RequestContext requestCtx;
+
+ private ProfileRequestContext profileRequestCtx;
+
+ private MockHttpServletResponse httpResponse;
+
+ private StatusListTokenContext tokenCtx;
+
+ @BeforeMethod
+ public void setUp() throws ComponentInitializationException {
+ requestCtx = new RequestContextBuilder().buildRequestContext();
+ profileRequestCtx = new WebflowRequestContextProfileRequestContextLookup().apply(requestCtx);
+ profileRequestCtx.setOutboundMessageContext(new MessageContext());
+ tokenCtx = profileRequestCtx.ensureOutboundMessageContext().ensureSubcontext(StatusListTokenContext.class);
+ tokenCtx.setClaims(new JWTClaimsSet.Builder().claim("ttl", 600L).build());
+ tokenCtx.setSignedToken("signed.status.list");
+ httpResponse = new MockHttpServletResponse();
+ }
+
+ private FormOutboundStatusListResponseMessage newAction(final boolean withResponse)
+ throws ComponentInitializationException {
+ final FormOutboundStatusListResponseMessage action = new FormOutboundStatusListResponseMessage();
+ if (withResponse) {
+ action.setHttpServletResponseSupplier(new NonnullSupplier<>() {
+ public HttpServletResponse get() {
+ return httpResponse;
+ }
+ });
+ }
+ action.initialize();
+ return action;
+ }
+
+ @Test
+ public void testJwtResponse() throws ComponentInitializationException {
+ ActionTestingSupport.assertProceedEvent(newAction(true).execute(requestCtx));
+
+ final Object message = profileRequestCtx.ensureOutboundMessageContext().getMessage();
+ Assert.assertTrue(message instanceof StatusListSuccessResponse);
+ Assert.assertEquals(((StatusListSuccessResponse) message).getToken(), "signed.status.list");
+ }
+
+ @Test
+ public void testCwtResponse() throws ComponentInitializationException {
+ tokenCtx.setSignedToken(null);
+ tokenCtx.setSignedCwt(new byte[] {1, 2, 3});
+
+ ActionTestingSupport.assertProceedEvent(newAction(true).execute(requestCtx));
+
+ final Object message = profileRequestCtx.ensureOutboundMessageContext().getMessage();
+ Assert.assertTrue(message instanceof StatusListCwtResponse);
+ Assert.assertEquals(((StatusListCwtResponse) message).getToken(), new byte[] {1, 2, 3});
+ Assert.assertEquals(httpResponse.getHeaders("Cache-Control"), List.of("max-age=600"));
+ }
+
+ @Test
+ public void testHeaders() throws ComponentInitializationException {
+ ActionTestingSupport.assertProceedEvent(newAction(true).execute(requestCtx));
+
+ Assert.assertEquals(httpResponse.getHeaders("Cache-Control"), List.of("max-age=600"));
+ Assert.assertEquals(httpResponse.getHeaders("Vary"), List.of("Accept"));
+ Assert.assertEquals(httpResponse.getHeaders("Access-Control-Allow-Origin"),
+ List.of(FormOutboundStatusListResponseMessage.ALLOW_ANY_ORIGIN));
+ Assert.assertEquals(httpResponse.getHeaders("X-Content-Type-Options"),
+ List.of(FormOutboundStatusListResponseMessage.NOSNIFF));
+ }
+
+ @Test
+ public void testHeadersReplacePreviousValues() throws ComponentInitializationException {
+ httpResponse.addHeader("Cache-Control", "no-store");
+
+ ActionTestingSupport.assertProceedEvent(newAction(true).execute(requestCtx));
+
+ Assert.assertEquals(httpResponse.getHeaders("Cache-Control"), List.of("max-age=600"));
+ }
+
+ @Test
+ public void testVaryKeepsNamedFields() throws ComponentInitializationException {
+ httpResponse.addHeader("Vary", "Accept-Encoding");
+
+ ActionTestingSupport.assertProceedEvent(newAction(true).execute(requestCtx));
+
+ Assert.assertEquals(httpResponse.getHeaders("Vary"), List.of("Accept-Encoding, Accept"));
+ }
+
+ @Test
+ public void testNoSignedToken() throws ComponentInitializationException {
+ tokenCtx.setSignedToken(null);
+
+ ActionTestingSupport.assertEvent(newAction(true).execute(requestCtx), EventIds.INVALID_PROFILE_CTX);
+ Assert.assertNull(profileRequestCtx.ensureOutboundMessageContext().getMessage());
+ }
+
+ @Test
+ public void testNoTokenContext() throws ComponentInitializationException {
+ profileRequestCtx.ensureOutboundMessageContext().removeSubcontext(StatusListTokenContext.class);
+
+ ActionTestingSupport.assertEvent(newAction(true).execute(requestCtx), EventIds.INVALID_PROFILE_CTX);
+ }
+
+ @Test
+ public void testNoTtl() throws ComponentInitializationException {
+ tokenCtx.setClaims(new JWTClaimsSet.Builder().build());
+
+ ActionTestingSupport.assertEvent(newAction(true).execute(requestCtx), EventIds.INVALID_PROFILE_CTX);
+ Assert.assertNull(httpResponse.getHeader("Cache-Control"));
+ }
+
+ @Test
+ public void testNoServletResponse() throws ComponentInitializationException {
+ ActionTestingSupport.assertEvent(newAction(false).execute(requestCtx), IdPEventIds.INVALID_PROFILE_CONFIG);
+ Assert.assertNull(profileRequestCtx.ensureOutboundMessageContext().getMessage());
+ }
+
+}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list