[java-idp-plugin-oidc-rp] branch main updated: IDP-1793 - Use Suppliers for HttpServletRequest/Response
Phil Smart
philip.smart at jisc.ac.uk
Tue Apr 25 15:47:31 UTC 2023
This is an automated email from the git hooks/post-receive script.
philsmart pushed a commit to branch main
in repository java-idp-plugin-oidc-rp.
View the commit online:
http://git.shibboleth.net/view/?p=java-idp-plugin-oidc-rp.git;a=commit;h=84987a9f557326b8c72c0b0c592f6f6303c71b3e
The following commit(s) were added to refs/heads/main by this push:
new 84987a9 IDP-1793 - Use Suppliers for HttpServletRequest/Response
84987a9 is described below
commit 84987a9f557326b8c72c0b0c592f6f6303c71b3e
Author: Phil Smart <philip.smart at jisc.ac.uk>
AuthorDate: Tue Apr 25 16:47:29 2023 +0100
IDP-1793 - Use Suppliers for HttpServletRequest/Response
- Reverse internal supplier decision, as RP now targeting IdP 4.3
https://shibboleth.atlassian.net/browse/IDP-1793
---
...CAuthenticationRequestActionMessageHandler.java | 33 ++++++++++++----------
.../oidc-relying-party-authn-beans.xml | 16 +++++------
.../idp/flows/oidc/rp/keyset/keyset-beans.xml | 8 +++---
.../authn/oidc-rp-providermetadata-resolvers.xml | 3 --
.../flow/AbstractAuthnXmlFlowExecutionTests.java | 12 ++++++++
5 files changed, 42 insertions(+), 30 deletions(-)
diff --git a/idp-oidc-rp-impl/src/main/java/net/shibboleth/idp/plugin/authn/oidc/rp/messaging/impl/AbstractOIDCAuthenticationRequestActionMessageHandler.java b/idp-oidc-rp-impl/src/main/java/net/shibboleth/idp/plugin/authn/oidc/rp/messaging/impl/AbstractOIDCAuthenticationRequestActionMessageHandler.java
index 695dd2e..8813274 100644
--- a/idp-oidc-rp-impl/src/main/java/net/shibboleth/idp/plugin/authn/oidc/rp/messaging/impl/AbstractOIDCAuthenticationRequestActionMessageHandler.java
+++ b/idp-oidc-rp-impl/src/main/java/net/shibboleth/idp/plugin/authn/oidc/rp/messaging/impl/AbstractOIDCAuthenticationRequestActionMessageHandler.java
@@ -44,6 +44,7 @@ import net.shibboleth.oidc.profile.config.OIDCAuthenticationRelyingPartyProfileC
import net.shibboleth.oidc.profile.core.OIDCAuthenticationRequest;
import net.shibboleth.utilities.java.support.component.ComponentSupport;
import net.shibboleth.utilities.java.support.logic.Constraint;
+import net.shibboleth.utilities.java.support.primitive.NonnullSupplier;
/**
* An abstract message handler that runs inside an {@link WebFlowMessageHandlerAdaptor}
@@ -78,7 +79,7 @@ public abstract class AbstractOIDCAuthenticationRequestActionMessageHandler exte
@Nullable private OIDCAuthenticationRelyingPartyProfileConfiguration profileConfiguration;
/** Current HTTP request, if available. */
- @Nullable private HttpServletRequest httpServletRequest;
+ @Nullable private NonnullSupplier<HttpServletRequest> httpServletRequestSupplier;
/** Constructor.*/
protected AbstractOIDCAuthenticationRequestActionMessageHandler() {
@@ -88,25 +89,27 @@ public abstract class AbstractOIDCAuthenticationRequestActionMessageHandler exte
relyingPartyContextLookupStrategy = new ChildContextLookup<>(RelyingPartyContext.class);
}
- /**
- * Get the current HTTP request if available.
- *
- * @return current HTTP request
- */
+ public void setHttpServletRequestSupplier(@Nullable final NonnullSupplier<HttpServletRequest> requestSupplier) {
+ ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+
+ httpServletRequestSupplier = requestSupplier;
+ }
+
@Nullable public HttpServletRequest getHttpServletRequest() {
- return httpServletRequest;
+ if (httpServletRequestSupplier == null) {
+ return null;
+ }
+ return httpServletRequestSupplier.get();
}
/**
- * Set the current HTTP request.
- *
- * @param request current HTTP request
+ * Get the supplier for HTTP request if available.
+ *
+ * @return current HTTP request
*/
- public void setHttpServletRequest(@Nullable final HttpServletRequest request) {
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
- httpServletRequest = request;
- }
+ @Nullable public NonnullSupplier<HttpServletRequest> getHttpServletRequestSupplier() {
+ return httpServletRequestSupplier;
+ }
/**
* Returns the authentication request build by this IdP. Should never be
diff --git a/idp-oidc-rp-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/authn/OIDCRelyingParty/oidc-relying-party-authn-beans.xml b/idp-oidc-rp-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/authn/OIDCRelyingParty/oidc-relying-party-authn-beans.xml
index 998bd7e..55cafb3 100644
--- a/idp-oidc-rp-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/authn/OIDCRelyingParty/oidc-relying-party-authn-beans.xml
+++ b/idp-oidc-rp-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/authn/OIDCRelyingParty/oidc-relying-party-authn-beans.xml
@@ -126,7 +126,7 @@
p:requestedClaimsHook="#{getObject('shibboleth.authn.oidc.rp.RequestedClaimsHook')}" />
<bean id="AddRedirectURI" scope="prototype"
class="net.shibboleth.idp.plugin.authn.oidc.rp.messaging.impl.AddRedirectURIHandler"
- p:httpServletRequest-ref="shibboleth.authn.oidc.rp.internal.HttpServletRequest"
+ p:httpServletRequestSupplier-ref="shibboleth.HttpServletRequestSupplier"
p:redirectUriCreationStrategy="#{getObject('shibboleth.authn.oidc.rp.RedirectUriCreationStrategy') ?:
getObject('DefaultRedirectUriCreationStrategy')}" />
<bean id="AddAuthenticationContextClassReferences" scope="prototype"
@@ -151,7 +151,7 @@
p:formattingMap-ref="shibboleth.AuditFormattingMap"
p:dateTimeFormat="#{getObject('shibboleth.AuditDateTimeFormat')}"
p:useDefaultTimeZone="#{getObject('shibboleth.AuditDefaultTimeZone') ?: false}"
- p:httpServletRequest-ref="shibboleth.authn.oidc.rp.internal.HttpServletRequest" />
+ p:httpServletRequestSupplier-ref="shibboleth.HttpServletRequestSupplier" />
<bean id="RequestObjectRequiredAndSupportedPredicate"
class="net.shibboleth.idp.plugin.authn.oidc.rp.messaging.context.logic.RequestObjectRequiredAndSupported" />
@@ -244,16 +244,16 @@
<bean id="HTTPRedirectAuthnRequestEncoder"
class="net.shibboleth.oidc.profile.encoding.impl.HTTPRedirectAuthnRequestEncoder" init-method=""
- scope="prototype" p:httpServletResponse-ref="shibboleth.authn.oidc.rp.internal.HttpServletResponse"
+ scope="prototype" p:httpServletResponseSupplier-ref="shibboleth.HttpServletResponseSupplier"
p:authorizationParamsAreValidPredicate="#{getObject('shibboleth.authn.oidc.rp.AuthzParamsValidPredicate')}" />
<bean id="HTTPPostAuthnRequestEncoder"
class="net.shibboleth.oidc.profile.encoding.impl.HTTPPostAuthnRequestEncoder" init-method="" scope="prototype"
- p:velocityEngine-ref="shibboleth.VelocityEngine" p:httpServletResponse-ref="shibboleth.authn.oidc.rp.internal.HttpServletResponse"
+ p:velocityEngine-ref="shibboleth.VelocityEngine" p:httpServletResponseSupplier-ref="shibboleth.HttpServletResponseSupplier"
p:authorizationParamsAreValidPredicate="#{getObject('shibboleth.authn.oidc.rp.AuthzParamsValidPredicate')}" />
<bean id="EncodeMessage" class="org.opensaml.profile.action.impl.EncodeMessage" scope="prototype"
- p:messageEncoderFactory-ref="messageEncoderFactory" p:httpServletResponse-ref="shibboleth.authn.oidc.rp.internal.HttpServletResponse" />
+ p:messageEncoderFactory-ref="messageEncoderFactory" p:httpServletResponseSupplier-ref="shibboleth.HttpServletResponseSupplier" />
<bean id="PreEncodeMessageHandler" class="org.opensaml.messaging.handler.impl.BasicMessageHandlerChain"
scope="prototype">
@@ -314,11 +314,11 @@
<bean id="OIDCRedirectAuthnResponseDecoder"
class="net.shibboleth.oidc.profile.decoding.impl.HTTPRedirectAuthnResponseDecoder" init-method=""
- scope="prototype" p:httpServletRequest-ref="shibboleth.authn.oidc.rp.internal.HttpServletRequest" />
+ scope="prototype" p:httpServletRequestSupplier-ref="shibboleth.HttpServletRequestSupplier" />
<bean id="OIDCPostAuthnResponseDecoder"
class="net.shibboleth.oidc.profile.decoding.impl.HTTPPostAuthnResponseDecoder" init-method="" scope="prototype"
- p:httpServletRequest-ref="shibboleth.authn.oidc.rp.internal.HttpServletRequest" />
+ p:httpServletRequestSupplier-ref="shibboleth.HttpServletRequestSupplier" />
<!-- After authentication response -->
<bean id="ValidateExternalAuthenticationContext" scope="prototype"
@@ -839,7 +839,7 @@
p:formattingMap-ref="shibboleth.AuditFormattingMap"
p:dateTimeFormat="#{getObject('shibboleth.AuditDateTimeFormat')}"
p:useDefaultTimeZone="#{getObject('shibboleth.AuditDefaultTimeZone') ?: false}"
- p:httpServletRequest-ref="shibboleth.authn.oidc.rp.internal.HttpServletRequest" />
+ p:httpServletRequestSupplier-ref="shibboleth.HttpServletRequestSupplier" />
<!-- Can override one or more of the beans above. Note, the property override is mostly to allow tests to change the
diff --git a/idp-oidc-rp-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/oidc/rp/keyset/keyset-beans.xml b/idp-oidc-rp-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/oidc/rp/keyset/keyset-beans.xml
index ce33c2d..8dcb65b 100644
--- a/idp-oidc-rp-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/oidc/rp/keyset/keyset-beans.xml
+++ b/idp-oidc-rp-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/oidc/rp/keyset/keyset-beans.xml
@@ -50,7 +50,7 @@
<bean id="EncodeMessage" class="org.opensaml.profile.action.impl.EncodeMessage" scope="prototype"
p:messageEncoderFactory-ref="shibboleth.authn.oidc.rp.keyset.messageEncoderFactory"
- p:httpServletResponse-ref="shibboleth.authn.oidc.rp.internal.HttpServletResponse" />
+ p:httpServletResponseSupplier-ref="shibboleth.HttpServletResponseSupplier" />
<bean id="shibboleth.authn.oidc.rp.keyset.messageEncoderFactory"
class="net.shibboleth.oidc.profile.encoding.impl.OIDCResponseEncoderFactory"
@@ -58,7 +58,7 @@
<bean id="shibboleth.authn.oidc.rp.keyset.nimbusEncoder"
class="net.shibboleth.oidc.profile.encoding.impl.SimpleNimbusResponseEncoder" scope="prototype"
- p:httpServletResponse-ref="shibboleth.authn.oidc.rp.internal.HttpServletResponse" init-method="" />
+ p:httpServletResponseSupplier-ref="shibboleth.HttpServletResponseSupplier" init-method="" />
<bean id="RecordResponseComplete" class="net.shibboleth.idp.profile.impl.RecordResponseComplete"
scope="prototype" />
@@ -70,12 +70,12 @@
p:formattingMap-ref="shibboleth.AuditFormattingMap"
p:dateTimeFormat="#{getObject('shibboleth.AuditDateTimeFormat')}"
p:useDefaultTimeZone="#{getObject('shibboleth.AuditDefaultTimeZone') ?: false}"
- p:httpServletRequest-ref="shibboleth.authn.oidc.rp.internal.HttpServletRequest" />
+ p:httpServletRequestSupplier-ref="shibboleth.HttpServletRequestSupplier" />
<bean id="BuildErrorResponseFromEvent"
class="net.shibboleth.oidc.profile.impl.BuildJSONErrorResponseFromEvent" scope="prototype"
p:defaultStatusCode="500" p:defaultCode="server_error"
- p:httpServletResponse-ref="shibboleth.authn.oidc.rp.internal.HttpServletResponse">
+ p:httpServletResponseSupplier-ref="shibboleth.HttpServletResponseSupplier">
<property name="eventContextLookupStrategy">
<bean class="net.shibboleth.idp.profile.context.navigate.WebFlowCurrentEventLookupFunction" />
</property>
diff --git a/idp-oidc-rp-impl/src/main/resources/net/shibboleth/idp/plugin/authn/oidc/rp/conf/authn/oidc-rp-providermetadata-resolvers.xml b/idp-oidc-rp-impl/src/main/resources/net/shibboleth/idp/plugin/authn/oidc/rp/conf/authn/oidc-rp-providermetadata-resolvers.xml
index fb3dadd..7d10e4f 100644
--- a/idp-oidc-rp-impl/src/main/resources/net/shibboleth/idp/plugin/authn/oidc/rp/conf/authn/oidc-rp-providermetadata-resolvers.xml
+++ b/idp-oidc-rp-impl/src/main/resources/net/shibboleth/idp/plugin/authn/oidc/rp/conf/authn/oidc-rp-providermetadata-resolvers.xml
@@ -31,7 +31,4 @@
</constructor-arg>
</bean>
-
-
-
</beans>
\ No newline at end of file
diff --git a/idp-oidc-rp-impl/src/test/java/net/shibboleth/idp/plugin/authn/test/flow/AbstractAuthnXmlFlowExecutionTests.java b/idp-oidc-rp-impl/src/test/java/net/shibboleth/idp/plugin/authn/test/flow/AbstractAuthnXmlFlowExecutionTests.java
index 2e46101..9f04867 100644
--- a/idp-oidc-rp-impl/src/test/java/net/shibboleth/idp/plugin/authn/test/flow/AbstractAuthnXmlFlowExecutionTests.java
+++ b/idp-oidc-rp-impl/src/test/java/net/shibboleth/idp/plugin/authn/test/flow/AbstractAuthnXmlFlowExecutionTests.java
@@ -292,8 +292,20 @@ public abstract class AbstractAuthnXmlFlowExecutionTests extends CustomAbstractX
builderContext.registerBean("shibboleth.DefaultIdentifierGenerationStrategy",
new SecureRandomIdentifierGenerationStrategy());
+
+ // register http servlet suppliers
+ addBeanDefinition(builderContext, "shibboleth.HttpServletRequestSupplier",BeanDefinitionBuilder.
+ genericBeanDefinition(
+ net.shibboleth.utilities.java.support.net.ThreadLocalHttpServletRequestSupplier.class)
+ .getBeanDefinition());
+ addBeanDefinition(builderContext, "shibboleth.HttpServletResponseSupplier",BeanDefinitionBuilder.
+ genericBeanDefinition(
+ net.shibboleth.utilities.java.support.net.ThreadLocalHttpServletResponseSupplier.class)
+ .getBeanDefinition());
+
// Load the request and final response context into the holder.
HttpServletRequestResponseContext.loadCurrent(mockRequest, mockResponse);
+
builderContext.registerBean("shibboleth.PostLoginSubjectCanonicalizationFlows", Collections.emptyList());
//create a real JSON parser
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list