[java-idp-plugin-duo] branch main updated: Fix flow builder to use absolute as well as relative resources
Phil Smart
philip.smart at jisc.ac.uk
Thu Feb 16 21:19:38 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-duo.
View the commit online:
http://git.shibboleth.net/view/?p=java-idp-plugin-duo.git;a=commit;h=8b95e01910eb73c194ae1a274e4019592b79b93c
The following commit(s) were added to refs/heads/main by this push:
new 8b95e01 Fix flow builder to use absolute as well as relative resources
8b95e01 is described below
commit 8b95e01910eb73c194ae1a274e4019592b79b93c
Author: Phil Smart <philip.smart at jisc.ac.uk>
AuthorDate: Thu Feb 16 21:19:35 2023 +0000
Fix flow builder to use absolute as well as relative resources
- Taken from the IdP's FlowModelFlowBuilder
---
.../impl/AbstractAuthnXmlFlowExecutionTests.java | 29 +++++++++++-
.../authn/spring/CustomFlowModelFlowBuilder.java | 51 ++++++++++++++--------
.../spring/CustomFlowRelativeResourceLoader.java | 20 +++++----
3 files changed, 70 insertions(+), 30 deletions(-)
diff --git a/idp-duo-impl/src/test/java/net/shibboleth/idp/plugin/authn/duo/impl/AbstractAuthnXmlFlowExecutionTests.java b/idp-duo-impl/src/test/java/net/shibboleth/idp/plugin/authn/duo/impl/AbstractAuthnXmlFlowExecutionTests.java
index 3d4b107..5c8be05 100644
--- a/idp-duo-impl/src/test/java/net/shibboleth/idp/plugin/authn/duo/impl/AbstractAuthnXmlFlowExecutionTests.java
+++ b/idp-duo-impl/src/test/java/net/shibboleth/idp/plugin/authn/duo/impl/AbstractAuthnXmlFlowExecutionTests.java
@@ -85,8 +85,6 @@ import net.shibboleth.idp.ui.context.RelyingPartyUIContext;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
import net.shibboleth.utilities.java.support.net.HttpServletRequestResponseContext;
-import net.shibboleth.utilities.java.support.net.ThreadLocalHttpServletRequestProxy;
-import net.shibboleth.utilities.java.support.net.ThreadLocalHttpServletResponseProxy;
import net.shibboleth.utilities.java.support.security.impl.SecureRandomIdentifierGenerationStrategy;
@@ -407,6 +405,33 @@ public abstract class AbstractAuthnXmlFlowExecutionTests extends CustomAbstractX
conversationService.afterPropertiesSet();
builderContext.registerBean("conversionService", conversationService.getObject());
+ addBeanDefinition(builderContext, "shibboleth.RelyingPartyIdLookup.Simple",BeanDefinitionBuilder.
+ genericBeanDefinition(net.shibboleth.idp.profile.context.navigate.RelyingPartyIdLookupFunction.class)
+ .getBeanDefinition());
+
+ addBeanDefinition(builderContext, "shibboleth.MessageContextLookup.Inbound",BeanDefinitionBuilder.
+ genericBeanDefinition(org.opensaml.profile.context.navigate.InboundMessageContextLookup.class)
+ .getBeanDefinition());
+
+ addBeanDefinition(builderContext, "shibboleth.ChildLookup.SessionContext",BeanDefinitionBuilder.
+ genericBeanDefinition(org.opensaml.messaging.context.navigate.ChildContextLookup.class)
+ .addConstructorArgValue(net.shibboleth.idp.session.context.SessionContext.class)
+ .getBeanDefinition());
+
+ addBeanDefinition(builderContext, "shibboleth.ChildLookupOrCreate.SAMLMessageInfoContext",BeanDefinitionBuilder.
+ genericBeanDefinition(org.opensaml.messaging.context.navigate.ChildContextLookup.class)
+ .addConstructorArgValue(org.opensaml.saml.common.messaging.context.SAMLMessageInfoContext.class)
+ .addConstructorArgValue(true)
+ .getBeanDefinition());
+
+ 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());
+
//register shibboleth function constants.
addBeanDefinition(builderContext, "shibboleth.Functions.Constant",BeanDefinitionBuilder.
genericBeanDefinition(net.shibboleth.utilities.java.support.logic.FunctionSupport.class)
diff --git a/idp-duo-impl/src/test/java/net/shibboleth/idp/plugin/authn/spring/CustomFlowModelFlowBuilder.java b/idp-duo-impl/src/test/java/net/shibboleth/idp/plugin/authn/spring/CustomFlowModelFlowBuilder.java
index c61423c..68a2568 100644
--- a/idp-duo-impl/src/test/java/net/shibboleth/idp/plugin/authn/spring/CustomFlowModelFlowBuilder.java
+++ b/idp-duo-impl/src/test/java/net/shibboleth/idp/plugin/authn/spring/CustomFlowModelFlowBuilder.java
@@ -21,6 +21,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import java.util.stream.Collectors;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
@@ -339,30 +340,42 @@ public class CustomFlowModelFlowBuilder extends AbstractFlowBuilder {
// internal helpers
private void initLocalFlowContext() {
- final Resource[] contextResources = parseContextResources(getFlowModel().getBeanImports());
+ final String[] contextResources = parseContextResources(getFlowModel().getBeanImports());
final GenericApplicationContext flowContext = createFlowApplicationContext(contextResources);
setLocalContext(new CustomLocalFlowBuilderContext(getContext(), flowContext));
}
-
- private Resource[] parseContextResources(final List<BeanImportModel> beanImports) {
+
+ /* Shibboleth change - pull out the resources as Strings and let the regular Spring logic resolve them */
+ private String[] parseContextResources(final List<BeanImportModel> beanImports) {
if (beanImports != null && !beanImports.isEmpty()) {
- final Resource flowResource = flowModelHolder.getFlowModelResource();
- final List<Resource> resources = new ArrayList<>(beanImports.size());
- for (final BeanImportModel beanImport : getFlowModel().getBeanImports()) {
- try {
- resources.add(flowResource.createRelative(beanImport.getResource()));
- } catch (final IOException e) {
- throw new FlowBuilderException(
- "Could not access flow-relative artifact resource '" + beanImport.getResource() + "'", e);
- }
- }
- return resources.toArray(new Resource[resources.size()]);
- } else {
- return new Resource[0];
+ final String[] resources = new String[beanImports.size()];
+ return beanImports.stream()
+ .map(BeanImportModel::getResource)
+ .collect(Collectors.toUnmodifiableList())
+ .toArray(resources);
}
- }
-
- private GenericApplicationContext createFlowApplicationContext(final Resource[] resources) {
+ return new String[0];
+ }
+//
+// private Resource[] parseContextResources(final List<BeanImportModel> beanImports) {
+// if (beanImports != null && !beanImports.isEmpty()) {
+// final Resource flowResource = flowModelHolder.getFlowModelResource();
+// final List<Resource> resources = new ArrayList<>(beanImports.size());
+// for (final BeanImportModel beanImport : getFlowModel().getBeanImports()) {
+// try {
+// resources.add(flowResource.createRelative(beanImport.getResource()));
+// } catch (final IOException e) {
+// throw new FlowBuilderException(
+// "Could not access flow-relative artifact resource '" + beanImport.getResource() + "'", e);
+// }
+// }
+// return resources.toArray(new Resource[resources.size()]);
+// } else {
+// return new Resource[0];
+// }
+// }
+
+ private GenericApplicationContext createFlowApplicationContext(final String[] resources) {
final ApplicationContext parent = getContext().getApplicationContext();
GenericApplicationContext flowContext;
if (parent instanceof WebApplicationContext) {
diff --git a/idp-duo-impl/src/test/java/net/shibboleth/idp/plugin/authn/spring/CustomFlowRelativeResourceLoader.java b/idp-duo-impl/src/test/java/net/shibboleth/idp/plugin/authn/spring/CustomFlowRelativeResourceLoader.java
index 957c4f0..44ed42b 100644
--- a/idp-duo-impl/src/test/java/net/shibboleth/idp/plugin/authn/spring/CustomFlowRelativeResourceLoader.java
+++ b/idp-duo-impl/src/test/java/net/shibboleth/idp/plugin/authn/spring/CustomFlowRelativeResourceLoader.java
@@ -34,26 +34,28 @@ public class CustomFlowRelativeResourceLoader implements ResourceLoader {
private final Set<ProtocolResolver> protocolResolvers = new LinkedHashSet<>(4);
- private Resource flowResource;
+ private final Resource flowResource;
- public void addProtocolResolver(ProtocolResolver resolver) {
+ public void addProtocolResolver(final ProtocolResolver resolver) {
Assert.notNull(resolver, "ProtocolResolver must not be null");
this.protocolResolvers.add(resolver);
}
- public CustomFlowRelativeResourceLoader(Resource resource) {
+ public CustomFlowRelativeResourceLoader(final Resource resource) {
this.flowResource = resource;
}
+ @Override
public ClassLoader getClassLoader() {
return flowResource.getClass().getClassLoader();
}
- public Resource getResource(String location) {
+ @Override
+ public Resource getResource(final String location) {
Assert.notNull(location, "Location must not be null");
- for (ProtocolResolver protocolResolver : protocolResolvers) {
- Resource resource = protocolResolver.resolve(location, this);
+ for (final ProtocolResolver protocolResolver : protocolResolvers) {
+ final Resource resource = protocolResolver.resolve(location, this);
if (resource != null) {
return resource;
}
@@ -67,11 +69,11 @@ public class CustomFlowRelativeResourceLoader implements ResourceLoader {
}
}
- private Resource createFlowRelativeResource(String location) {
+ private Resource createFlowRelativeResource(final String location) {
try {
return flowResource.createRelative(location);
- } catch (IOException e) {
- IllegalArgumentException iae = new IllegalArgumentException(
+ } catch (final IOException e) {
+ final IllegalArgumentException iae = new IllegalArgumentException(
"Unable to access a flow relative resource at location '" + location + "'");
iae.initCause(e);
throw iae;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list