[java-idp-plugin-oidc-rp] branch main updated: Improve response mode and response type lookup
Phil Smart
philip.smart at jisc.ac.uk
Tue Jun 14 13:52:01 UTC 2022
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=253657b5b962bdae43460962137f87499108b5b9
The following commit(s) were added to refs/heads/main by this push:
new 253657b Improve response mode and response type lookup
253657b is described below
commit 253657b5b962bdae43460962137f87499108b5b9
Author: Phil Smart <philip.smart at jisc.ac.uk>
AuthorDate: Tue Jun 14 14:51:52 2022 +0100
Improve response mode and response type lookup
Taken from the profile config
---
.../rp/impl/DefaultResponseModeLookupFunction.java | 60 +++++++--
.../rp/impl/DefaultResponseTypeLookupFunction.java | 49 ++++---
.../impl/PopulateResponseTypeAndModeContext.java | 150 ++++++++++++++++-----
.../PopulateResponseTypeAndModeContextTest.java | 102 ++++++++++++++
4 files changed, 300 insertions(+), 61 deletions(-)
diff --git a/idp-oidc-rp-impl/src/main/java/net/shibboleth/idp/plugin/authn/oidc/rp/impl/DefaultResponseModeLookupFunction.java b/idp-oidc-rp-impl/src/main/java/net/shibboleth/idp/plugin/authn/oidc/rp/impl/DefaultResponseModeLookupFunction.java
index ed531df..a23711a 100644
--- a/idp-oidc-rp-impl/src/main/java/net/shibboleth/idp/plugin/authn/oidc/rp/impl/DefaultResponseModeLookupFunction.java
+++ b/idp-oidc-rp-impl/src/main/java/net/shibboleth/idp/plugin/authn/oidc/rp/impl/DefaultResponseModeLookupFunction.java
@@ -18,39 +18,81 @@
package net.shibboleth.idp.plugin.authn.oidc.rp.impl;
import java.util.function.BiFunction;
+import java.util.function.Function;
import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import org.opensaml.messaging.context.navigate.ChildContextLookup;
import org.opensaml.profile.context.ProfileRequestContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.nimbusds.oauth2.sdk.ParseException;
import com.nimbusds.oauth2.sdk.ResponseMode;
import com.nimbusds.oauth2.sdk.ResponseType;
+import net.shibboleth.idp.profile.config.ProfileConfiguration;
+import net.shibboleth.idp.profile.context.RelyingPartyContext;
+import net.shibboleth.oidc.profile.config.OIDCAuthorizationConfiguration;
+import net.shibboleth.utilities.java.support.logic.Constraint;
+
/**
* A lookup function that returns a response_mode compatible with the response_type described.
* The response_mode can be overriden by the profile configuration.
*/
+ at Deprecated
public class DefaultResponseModeLookupFunction
implements BiFunction<ProfileRequestContext, ResponseType, ResponseMode> {
/** Class logger. */
@Nonnull
private final Logger log = LoggerFactory.getLogger(DefaultResponseModeLookupFunction.class);
+
+ /**
+ * Strategy used to locate the {@link RelyingPartyContext} associated with a given {@link ProfileRequestContext}.
+ */
+ @Nonnull private Function<ProfileRequestContext,RelyingPartyContext> relyingPartyContextLookupStrategy;
+
+ /** Constructor. */
+ public DefaultResponseModeLookupFunction() {
+ relyingPartyContextLookupStrategy = new ChildContextLookup<>(RelyingPartyContext.class);
+ }
+
+ /**
+ * Set the strategy used to locate the {@link RelyingPartyContext} associated with a given
+ * {@link ProfileRequestContext}.
+ *
+ * @param strategy lookup strategy
+ */
+ public void setRelyingPartyContextLookupStrategy(
+ @Nonnull final Function<ProfileRequestContext,RelyingPartyContext> strategy) {
+ relyingPartyContextLookupStrategy =
+ Constraint.isNotNull(strategy, "RelyingPartyContext lookup strategy cannot be null");
+ }
@Override
- @Nonnull public ResponseMode apply(@Nonnull final ProfileRequestContext profileRequestContext,
+ @Nonnull public ResponseMode apply(@Nullable final ProfileRequestContext profileRequestContext,
@Nonnull final ResponseType responseType) {
-// final RelyingPartyContext rpCtx = profileRequestContext.getSubcontext(RelyingPartyContext.class);
-// OIDCAuthorizationConfiguration profileConfiguration = null;
-//
-// if (rpCtx != null && rpCtx.getProfileConfig() instanceof OIDCAuthorizationConfiguration) {
-// profileConfiguration = (OIDCAuthorizationConfiguration) rpCtx.getProfileConfig();
-//
-// final OIDCHttpRequestMethod requestMethodFromConfig =
-// profileConfiguration.getHttpRequestMethod(profileRequestContext);
+// if (profileRequestContext != null) {
+// final RelyingPartyContext rpc = relyingPartyContextLookupStrategy.apply(profileRequestContext);
+// if (rpc != null) {
+// final ProfileConfiguration pc = rpc.getProfileConfig();
+// if (pc instanceof OIDCAuthorizationConfiguration) {
+// final String responseMode =
+// ((OIDCAuthorizationConfiguration) pc).getResponseMode(profileRequestContext);
+// try {
+// final ResponseType responseTypeParsed = ResponseType.parse(responseType);
+// log.debug("Returning response_type '{}' from profile configuration", responseTypeParsed);
+// return responseTypeParsed;
+// } catch (final ParseException e) {
+// log.warn("Configured response_type '{}' is not valid, returning default '{}'",
+// responseType, DEFAULT_RESPONSE_TYPE);
+// return DEFAULT_RESPONSE_TYPE;
+// }
+// }
+// }
// }
//TODO extract possible response mode from profile config as well. Must be compatible with the response_type
final ResponseMode compatibleMode = ResponseMode.resolve(null, responseType);
diff --git a/idp-oidc-rp-impl/src/main/java/net/shibboleth/idp/plugin/authn/oidc/rp/impl/DefaultResponseTypeLookupFunction.java b/idp-oidc-rp-impl/src/main/java/net/shibboleth/idp/plugin/authn/oidc/rp/impl/DefaultResponseTypeLookupFunction.java
index 7536bfa..6c9c0f2 100644
--- a/idp-oidc-rp-impl/src/main/java/net/shibboleth/idp/plugin/authn/oidc/rp/impl/DefaultResponseTypeLookupFunction.java
+++ b/idp-oidc-rp-impl/src/main/java/net/shibboleth/idp/plugin/authn/oidc/rp/impl/DefaultResponseTypeLookupFunction.java
@@ -17,26 +17,27 @@
package net.shibboleth.idp.plugin.authn.oidc.rp.impl;
-import java.util.function.Function;
-
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-import org.opensaml.messaging.context.MessageContext;
import org.opensaml.profile.context.ProfileRequestContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.nimbusds.oauth2.sdk.ParseException;
import com.nimbusds.oauth2.sdk.ResponseType;
-import net.shibboleth.oidc.metadata.context.OIDCMetadataContext;
+import net.shibboleth.idp.profile.config.ProfileConfiguration;
+import net.shibboleth.idp.profile.context.RelyingPartyContext;
+import net.shibboleth.idp.profile.context.navigate.AbstractRelyingPartyLookupFunction;
+import net.shibboleth.oidc.profile.config.OIDCAuthorizationConfiguration;
/**
- * A lookup function that returns a response_type from the 'first' described in a client's metadata.
- * If none are found, the default response type of 'code' is returned.
+ * A lookup function that returns a response_type from that specified in the profile configuration. If none
+ * are configured, or the one configured is invalid, the default 'code' will be returned.
*/
-//TODO move to checking profile config!
-public class DefaultResponseTypeLookupFunction implements Function<ProfileRequestContext, ResponseType> {
+ at Deprecated
+public class DefaultResponseTypeLookupFunction extends AbstractRelyingPartyLookupFunction<ResponseType> {
/** The Default response type if none is selected.*/
@Nonnull private static final ResponseType DEFAULT_RESPONSE_TYPE = ResponseType.CODE;
@@ -52,21 +53,25 @@ public class DefaultResponseTypeLookupFunction implements Function<ProfileReques
return DEFAULT_RESPONSE_TYPE;
}
- final MessageContext inboundMessageCtx = profileRequestContext.getInboundMessageContext();
- final OIDCMetadataContext clientMetadataCtx =
- inboundMessageCtx.getSubcontext(OIDCMetadataContext.class);
- if (clientMetadataCtx != null &&
- clientMetadataCtx.getClientInformation() != null &&
- clientMetadataCtx.getClientInformation().getOIDCMetadata() != null &&
- clientMetadataCtx.getClientInformation().getOIDCMetadata().getResponseTypes() != null) {
-
- final ResponseType selectedResponseType =
- clientMetadataCtx.getClientInformation().getOIDCMetadata().getResponseTypes().iterator().next();
- log.debug("Response_type has been determined from client metadata as '{}'", selectedResponseType);
- return selectedResponseType;
- }
+ final RelyingPartyContext rpc = getRelyingPartyContextLookupStrategy().apply(profileRequestContext);
+ if (rpc != null) {
+ final ProfileConfiguration pc = rpc.getProfileConfig();
+ if (pc instanceof OIDCAuthorizationConfiguration) {
+ final String responseType =
+ ((OIDCAuthorizationConfiguration) pc).getResponseType(profileRequestContext);
+ try {
+ final ResponseType responseTypeParsed = ResponseType.parse(responseType);
+ log.debug("Returning response_type '{}' from profile configuration", responseTypeParsed);
+ return responseTypeParsed;
+ } catch (final ParseException e) {
+ log.warn("Configured response_type '{}' is not valid, returning default '{}'",
+ responseType, DEFAULT_RESPONSE_TYPE);
+ return DEFAULT_RESPONSE_TYPE;
+ }
+ }
+ }
- log.debug("Client metadata did not contain any configured response_types, "
+ log.debug("No response_types configured, "
+ "returning the default '{}' type", DEFAULT_RESPONSE_TYPE);
return DEFAULT_RESPONSE_TYPE;
}
diff --git a/idp-oidc-rp-impl/src/main/java/net/shibboleth/idp/plugin/authn/oidc/rp/impl/PopulateResponseTypeAndModeContext.java b/idp-oidc-rp-impl/src/main/java/net/shibboleth/idp/plugin/authn/oidc/rp/impl/PopulateResponseTypeAndModeContext.java
index f4148bd..27aed36 100644
--- a/idp-oidc-rp-impl/src/main/java/net/shibboleth/idp/plugin/authn/oidc/rp/impl/PopulateResponseTypeAndModeContext.java
+++ b/idp-oidc-rp-impl/src/main/java/net/shibboleth/idp/plugin/authn/oidc/rp/impl/PopulateResponseTypeAndModeContext.java
@@ -17,14 +17,16 @@
package net.shibboleth.idp.plugin.authn.oidc.rp.impl;
-import java.util.function.BiFunction;
import java.util.function.Function;
import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import org.opensaml.messaging.context.navigate.ChildContextLookup;
import org.opensaml.profile.action.ActionSupport;
import org.opensaml.profile.action.EventIds;
import org.opensaml.profile.context.ProfileRequestContext;
+import org.opensaml.profile.context.navigate.OutboundMessageContextLookup;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -33,6 +35,9 @@ import com.nimbusds.oauth2.sdk.ResponseType;
import net.shibboleth.idp.plugin.authn.oidc.rp.context.ResponseTypeAndModeContext;
import net.shibboleth.idp.profile.AbstractProfileAction;
+import net.shibboleth.idp.profile.IdPEventIds;
+import net.shibboleth.idp.profile.context.RelyingPartyContext;
+import net.shibboleth.oidc.profile.config.OIDCAuthorizationConfiguration;
import net.shibboleth.utilities.java.support.component.ComponentSupport;
import net.shibboleth.utilities.java.support.logic.Constraint;
@@ -50,41 +55,47 @@ public class PopulateResponseTypeAndModeContext extends AbstractProfileAction {
/** Class logger. */
@Nonnull private final Logger log = LoggerFactory.getLogger(PopulateResponseTypeAndModeContext.class);
+ /**
+ * Strategy used to locate the {@link RelyingPartyContext} associated with a given {@link ProfileRequestContext}.
+ */
+ @Nonnull private Function<ProfileRequestContext, RelyingPartyContext> relyingPartyContextLookupStrategy;
+
+ /**
+ * Strategy used to locate the {@link ResponseTypeAndModeContext} associated with a
+ * given {@link ProfileRequestContext}.
+ */
+ @Nonnull
+ private final Function<ProfileRequestContext, ResponseTypeAndModeContext> responseTypeAndModeContextLookupStrategy;
- /** Function to lookup the response type given the profile request context.*/
- @Nonnull private Function<ProfileRequestContext, ResponseType> responseTypeLookup;
+ /** Applicable stashed profile configuration. */
+ @Nullable private OIDCAuthorizationConfiguration profileConfiguration;
- /** Function to lookup the response mode given the profile request context.*/
- @Nonnull private BiFunction<ProfileRequestContext, ResponseType, ResponseMode> responseModeLookup;
+ /** The stashed response type and mode context.*/
+ @Nullable private ResponseTypeAndModeContext responseTypeAndModeContext;
/** Constructor.*/
public PopulateResponseTypeAndModeContext() {
- responseTypeLookup = new DefaultResponseTypeLookupFunction();
- responseModeLookup = new DefaultResponseModeLookupFunction();
- }
-
- /**
- * Set the response_type lookup function.
- *
- * @param lookup the function.
- */
- public void setResponseTypeLookup(@Nonnull final Function<ProfileRequestContext, ResponseType> lookup) {
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
- ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- responseTypeLookup = Constraint.isNotNull(lookup, "Response Type lookup can not be null");
+ // Default under the outbound message context, create is true
+ responseTypeAndModeContextLookupStrategy =
+ new ChildContextLookup<>(ResponseTypeAndModeContext.class, true).compose(
+ new OutboundMessageContextLookup());
+
+ relyingPartyContextLookupStrategy = new ChildContextLookup<>(RelyingPartyContext.class);
}
/**
- * Set the response_mode lookup function. Accepts both a chosen response_mode, and the profile request
- * context.
+ * Set the strategy used to locate the {@link RelyingPartyContext} associated with a given
+ * {@link ProfileRequestContext}.
*
- * @param lookup the function.
+ * @param strategy lookup strategy
*/
- public void setResponseModeLookup(
- @Nonnull final BiFunction<ProfileRequestContext, ResponseType, ResponseMode> lookup) {
+ public void setRelyingPartyContextLookupStrategy(
+ @Nonnull final Function<ProfileRequestContext,RelyingPartyContext> strategy) {
ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- responseModeLookup = Constraint.isNotNull(lookup, "Response Mode lookup can not be null");
+
+ relyingPartyContextLookupStrategy =
+ Constraint.isNotNull(strategy, "RelyingPartyContext lookup strategy cannot be null");
}
@@ -100,7 +111,26 @@ public class PopulateResponseTypeAndModeContext extends AbstractProfileAction {
log.debug("{} Inbound message context was null", getLogPrefix());
ActionSupport.buildEvent(profileRequestContext, EventIds.INVALID_MSG_CTX);
return false;
- }
+ }
+
+ responseTypeAndModeContext = responseTypeAndModeContextLookupStrategy.apply(profileRequestContext);
+ if (responseTypeAndModeContext == null) {
+ log.error("{} No response type and mode context found or created", getLogPrefix());
+ ActionSupport.buildEvent(profileRequestContext, EventIds.INVALID_PROFILE_CTX);
+ return false;
+ }
+
+ final RelyingPartyContext rpCtx = relyingPartyContextLookupStrategy.apply(profileRequestContext);
+ if (rpCtx != null && rpCtx.getConfiguration() != null &&
+ rpCtx.getProfileConfig() instanceof OIDCAuthorizationConfiguration) {
+ profileConfiguration = (OIDCAuthorizationConfiguration) rpCtx.getProfileConfig();
+ }
+ if (profileConfiguration == null) {
+ log.error("{} Profile configuration not found", getLogPrefix());
+ ActionSupport.buildEvent(profileRequestContext, IdPEventIds.INVALID_PROFILE_CONFIG);
+ return false;
+ }
+
return true;
}
@@ -108,12 +138,72 @@ public class PopulateResponseTypeAndModeContext extends AbstractProfileAction {
/** {@inheritDoc} */
@Override protected void doExecute(@Nonnull final ProfileRequestContext profileRequestContext) {
- final ResponseTypeAndModeContext ctx = new ResponseTypeAndModeContext();
- ctx.setResponseType(responseTypeLookup.apply(profileRequestContext));
- ctx.setResponseMode(responseModeLookup.apply(profileRequestContext, ctx.getResponseType()));
- profileRequestContext.getOutboundMessageContext().addSubcontext(ctx);
-
+ final String responseTypeFromProfile = profileConfiguration.getResponseType(profileRequestContext);
+
+ if (responseTypeFromProfile == null) {
+ log.error("{} Response_type was null, must specify a response_type", getLogPrefix());
+ ActionSupport.buildEvent(profileRequestContext, IdPEventIds.INVALID_RELYING_PARTY_CONFIG);
+ return;
+ }
+ ResponseType responseType = null;
+ if (responseTypeFromProfile.equals(ResponseType.CODE.toString())) {
+ responseType = ResponseType.CODE;
+ } else if (responseTypeFromProfile.equals(ResponseType.CODE_IDTOKEN.toString())) {
+ responseType = ResponseType.CODE_IDTOKEN;
+ } else if (responseTypeFromProfile.equals(ResponseType.CODE_IDTOKEN_TOKEN.toString())) {
+ responseType = ResponseType.CODE_IDTOKEN_TOKEN;
+ } else if (responseTypeFromProfile.equals(ResponseType.CODE_TOKEN.toString())) {
+ responseType = ResponseType.CODE_TOKEN;
+ } else if (responseTypeFromProfile.equals(ResponseType.IDTOKEN.toString())) {
+ responseType = ResponseType.IDTOKEN;
+ } else if (responseTypeFromProfile.equals(ResponseType.IDTOKEN_TOKEN.toString())) {
+ responseType = ResponseType.IDTOKEN_TOKEN;
+ } else {
+ log.error("{} Response_type '{}' is not supported", getLogPrefix(), responseTypeFromProfile);
+ ActionSupport.buildEvent(profileRequestContext, IdPEventIds.INVALID_RELYING_PARTY_CONFIG);
+ return;
+ }
+
+ final String responseModeFromProfile = profileConfiguration.getResponseMode(profileRequestContext);
+
+ final ResponseMode compatibleMode = ResponseMode.resolve(null, responseType);
+ log.trace("{} Compatible response mode '{}' resolved from response type '{}'", getLogPrefix(), compatibleMode,
+ responseTypeFromProfile);
+
+ ResponseMode responseModeOverride = null;
+ if (responseModeFromProfile != null) {
+
+ if (responseModeFromProfile.equals(ResponseMode.FORM_POST.getValue())) {
+ responseModeOverride = ResponseMode.FORM_POST;
+ } else if (responseModeFromProfile.equals(ResponseMode.FORM_POST_JWT.getValue())) {
+ responseModeOverride = ResponseMode.FORM_POST_JWT;
+ } else if (responseModeFromProfile.equals(ResponseMode.QUERY.getValue())) {
+ responseModeOverride = ResponseMode.QUERY;
+ } else if (responseModeFromProfile.equals(ResponseMode.FRAGMENT.getValue())) {
+ responseModeOverride = ResponseMode.FRAGMENT;
+ } else if (responseModeFromProfile.equals(ResponseMode.FRAGMENT_JWT.getValue())) {
+ responseModeOverride = ResponseMode.FRAGMENT_JWT;
+ } else if (responseModeFromProfile.equals(ResponseMode.JWT.getValue())) {
+ responseModeOverride = ResponseMode.JWT;
+ } else if (responseModeFromProfile.equals(ResponseMode.QUERY_JWT.getValue())) {
+ responseModeOverride = ResponseMode.QUERY_JWT;
+ }
+
+ if (responseModeOverride != null && !responseModeOverride.equals(compatibleMode)) {
+ log.debug("{} Response_mode override '{}' exists in the profile configuration and is different than the"
+ + " default mode '{}' for response_type '{}'",
+ getLogPrefix(), responseModeFromProfile, compatibleMode, responseType);
+ }
+ }
+
+ responseTypeAndModeContext.setResponseType(responseType);
+ responseTypeAndModeContext.setResponseMode(
+ responseModeOverride == null ? compatibleMode : responseModeOverride);
+
+ log.debug("{} Response_type '{}' selected", getLogPrefix(), responseTypeAndModeContext.getResponseType());
+ log.debug("{} Response_mode '{}' selected", getLogPrefix(), responseTypeAndModeContext.getResponseMode());
}
+
}
diff --git a/idp-oidc-rp-impl/src/test/java/net/shibboleth/idp/plugin/authn/oidc/rp/impl/PopulateResponseTypeAndModeContextTest.java b/idp-oidc-rp-impl/src/test/java/net/shibboleth/idp/plugin/authn/oidc/rp/impl/PopulateResponseTypeAndModeContextTest.java
new file mode 100644
index 0000000..40ce278
--- /dev/null
+++ b/idp-oidc-rp-impl/src/test/java/net/shibboleth/idp/plugin/authn/oidc/rp/impl/PopulateResponseTypeAndModeContextTest.java
@@ -0,0 +1,102 @@
+package net.shibboleth.idp.plugin.authn.oidc.rp.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertNull;
+
+import org.opensaml.messaging.context.navigate.ChildContextLookup;
+import org.opensaml.profile.context.ProfileRequestContext;
+import org.springframework.webflow.execution.Event;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import com.nimbusds.oauth2.sdk.ResponseMode;
+import com.nimbusds.oauth2.sdk.ResponseType;
+
+import net.shibboleth.idp.authn.context.AuthenticationContext;
+import net.shibboleth.idp.plugin.authn.oidc.rp.context.ResponseTypeAndModeContext;
+import net.shibboleth.idp.profile.context.RelyingPartyContext;
+import net.shibboleth.idp.profile.context.navigate.WebflowRequestContextProfileRequestContextLookup;
+import net.shibboleth.idp.relyingparty.RelyingPartyConfiguration;
+import net.shibboleth.oidc.profile.config.OIDCAuthorizationConfiguration;
+import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
+
+/** Tests for the PopulateResponseTypeAndModeContext action.*/
+public class PopulateResponseTypeAndModeContextTest extends AbstractOIDCTest {
+
+ private PopulateResponseTypeAndModeContext action;
+
+ private RelyingPartyContext rpc;
+
+ private OIDCAuthorizationConfiguration oidcAuthzConfig;
+
+
+ @Override
+ @BeforeMethod
+ public void setup() throws Exception {
+ super.setup();
+ action = new PopulateResponseTypeAndModeContext();
+ rpc = prc.getSubcontext(RelyingPartyContext.class, true);
+ oidcAuthzConfig = new OIDCAuthorizationConfiguration();
+ final RelyingPartyConfiguration rpConfig = new RelyingPartyConfiguration();
+ rpc.setProfileConfig(oidcAuthzConfig);
+ rpc.setConfiguration(rpConfig);
+
+
+ action.setProfileContextLookupStrategy(new ChildContextLookup<>(ProfileRequestContext.class).compose(
+ new ChildContextLookup<>(AuthenticationContext.class)
+ .compose(new WebflowRequestContextProfileRequestContextLookup())));
+ }
+
+ @Test
+ public void testResponseModeOverride() throws ComponentInitializationException {
+
+ oidcAuthzConfig.setResponseType(ResponseType.CODE.toString());
+ oidcAuthzConfig.setResponseMode(ResponseMode.FORM_POST.toString());
+ action.initialize();
+
+ final Event event = action.execute(src);
+ assertNull(event);
+ assertNotNull(prc.getOutboundMessageContext().getSubcontext(ResponseTypeAndModeContext.class));
+ assertNotNull(prc.getOutboundMessageContext()
+ .getSubcontext(ResponseTypeAndModeContext.class).getResponseMode());
+ assertNotNull(prc.getOutboundMessageContext()
+ .getSubcontext(ResponseTypeAndModeContext.class).getResponseType());
+ assertEquals(ResponseMode.FORM_POST, prc.getOutboundMessageContext()
+ .getSubcontext(ResponseTypeAndModeContext.class).getResponseMode());
+ assertEquals(ResponseType.CODE, prc.getOutboundMessageContext()
+ .getSubcontext(ResponseTypeAndModeContext.class).getResponseType());
+ }
+
+ @Test
+ public void testResponseModeDefault() throws ComponentInitializationException {
+
+ oidcAuthzConfig.setResponseType(ResponseType.CODE.toString());
+ action.initialize();
+
+ final Event event = action.execute(src);
+ assertNull(event);
+
+ assertNotNull(prc.getOutboundMessageContext().getSubcontext(ResponseTypeAndModeContext.class));
+ assertNotNull(prc.getOutboundMessageContext()
+ .getSubcontext(ResponseTypeAndModeContext.class).getResponseMode());
+ assertNotNull(prc.getOutboundMessageContext()
+ .getSubcontext(ResponseTypeAndModeContext.class).getResponseType());
+ assertEquals(ResponseMode.QUERY, prc.getOutboundMessageContext()
+ .getSubcontext(ResponseTypeAndModeContext.class).getResponseMode());
+ assertEquals(ResponseType.CODE, prc.getOutboundMessageContext()
+ .getSubcontext(ResponseTypeAndModeContext.class).getResponseType());
+ }
+
+ @Test
+ public void testUnknownResponseType() throws ComponentInitializationException {
+
+ oidcAuthzConfig.setResponseType("unknown");
+ action.initialize();
+
+ final Event event = action.execute(src);
+ assertNotNull(event);
+ assertEquals("InvalidRelyingPartyConfiguration", event.getId());
+ }
+
+}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list