[java-oidc-common] branch main updated: JCOMOIDC-7 Move RP-metadata handling from the OIDC plugin

Henri Mikkonen henri.mikkonen at iki.fi
Wed Dec 30 10:37:10 UTC 2020


This is an automated email from the git hooks/post-receive script.

hjmikkon pushed a commit to branch main
in repository java-oidc-common.

View the commit online:
http://git.shibboleth.net/view/?p=java-oidc-common.git;a=commit;h=97309e5d72342f6c620db088edbf247d76647c00

The following commit(s) were added to refs/heads/main by this push:
       new  97309e5   JCOMOIDC-7 Move RP-metadata handling from the OIDC plugin
97309e5 is described below

commit 97309e5d72342f6c620db088edbf247d76647c00
Author: Henri Mikkonen <henri.mikkonen at iki.fi>
AuthorDate: Wed Dec 30 12:33:06 2020 +0200

    JCOMOIDC-7 Move RP-metadata handling from the OIDC plugin
    
    https://issues.shibboleth.net/jira/browse/JCOMOIDC-7
    
    The final RP-metadata handling code from java-idp-oidc. The service
    configuration still remains in java-idp-oidc (postconfig.xml) for
    time being.
---
 .../filter/impl/ClientInformationParser.java       |  70 +++++++++
 .../metadata/filter/impl/package-info.java         |  21 +++
 .../ClientInformationResolverServiceStrategy.java  |  92 ++++++++++++
 .../metadata/impl/MetadataNamespaceHandler.java    |  40 ++++++
 .../relyingparty/metadata/impl/package-info.java   |  21 +++
 .../src/main/resources/META-INF/spring.handlers    |   1 +
 .../src/main/resources/META-INF/spring.schemas     |   1 +
 .../schema/idp-oidc-extension-metadata-ext.xsd     |  22 +++
 ...loadClientResolverServiceConfigurationTest.java | 158 +++++++++++++++++++++
 .../oidc/metadata/impl/oidc-metadata-providers.xml |  42 ++++++
 .../metadata/impl/oidc-metadata-providers2.xml     |  61 ++++++++
 11 files changed, 529 insertions(+)

diff --git a/oidc-common-metadata-impl/src/main/java/net/shibboleth/oidc/profile/spring/relyingparty/metadata/filter/impl/ClientInformationParser.java b/oidc-common-metadata-impl/src/main/java/net/shibboleth/oidc/profile/spring/relyingparty/metadata/filter/impl/ClientInformationParser.java
new file mode 100644
index 0000000..11702f1
--- /dev/null
+++ b/oidc-common-metadata-impl/src/main/java/net/shibboleth/oidc/profile/spring/relyingparty/metadata/filter/impl/ClientInformationParser.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the University Corporation for Advanced Internet Development,
+ * Inc. (UCAID) under one or more contributor license agreements.  See the
+ * NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The UCAID licenses this file to You 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.oidc.profile.spring.relyingparty.metadata.filter.impl;
+
+import javax.annotation.Nonnull;
+import javax.xml.namespace.QName;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.support.BeanDefinitionBuilder;
+import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.w3c.dom.Element;
+
+import net.shibboleth.oidc.metadata.impl.ClientInformationNodeProcessor;
+import net.shibboleth.oidc.profile.spring.relyingparty.metadata.impl.MetadataNamespaceHandler;
+import net.shibboleth.utilities.java.support.primitive.StringSupport;
+
+/**
+ * Parser for a <ClientInformation> node processor.
+ */
+public class ClientInformationParser extends AbstractSingleBeanDefinitionParser {
+    
+    /** Element name. */
+    @Nonnull public static final QName TYPE_NAME =
+            new QName(MetadataNamespaceHandler.NAMESPACE, "ClientInformation");
+    
+    /** Class logger. */
+    @Nonnull private final Logger log = LoggerFactory.getLogger(ClientInformationParser.class);
+    
+    /** {@inheritDoc} */
+    @Override protected Class<?> getBeanClass(final Element element) {
+        return ClientInformationNodeProcessor.class;
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    protected void doParse(final Element element, final ParserContext parserContext,
+            final BeanDefinitionBuilder builder) {
+        super.doParse(element, parserContext, builder);
+
+        if (element.hasAttributeNS(null, "keyInfoProvidersRef")) {
+            builder.addConstructorArgReference(StringSupport.trimOrNull(element.getAttributeNS(null,
+                    "keyInfoProvidersRef")));
+        } else {
+            log.error("No 'keyInfoProvidersRef' attribute defined!");
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override protected boolean shouldGenerateId() {
+        return true;
+    }
+    
+}
diff --git a/oidc-common-metadata-impl/src/main/java/net/shibboleth/oidc/profile/spring/relyingparty/metadata/filter/impl/package-info.java b/oidc-common-metadata-impl/src/main/java/net/shibboleth/oidc/profile/spring/relyingparty/metadata/filter/impl/package-info.java
new file mode 100644
index 0000000..1e72b73
--- /dev/null
+++ b/oidc-common-metadata-impl/src/main/java/net/shibboleth/oidc/profile/spring/relyingparty/metadata/filter/impl/package-info.java
@@ -0,0 +1,21 @@
+/*
+ * Licensed to the University Corporation for Advanced Internet Development,
+ * Inc. (UCAID) under one or more contributor license agreements.  See the
+ * NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The UCAID licenses this file to You 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.
+ */
+
+/**
+ * Spring-aware tools for resolving OIDC entities.
+ */
+package net.shibboleth.oidc.profile.spring.relyingparty.metadata.filter.impl;
\ No newline at end of file
diff --git a/oidc-common-metadata-impl/src/main/java/net/shibboleth/oidc/profile/spring/relyingparty/metadata/impl/ClientInformationResolverServiceStrategy.java b/oidc-common-metadata-impl/src/main/java/net/shibboleth/oidc/profile/spring/relyingparty/metadata/impl/ClientInformationResolverServiceStrategy.java
new file mode 100644
index 0000000..0860395
--- /dev/null
+++ b/oidc-common-metadata-impl/src/main/java/net/shibboleth/oidc/profile/spring/relyingparty/metadata/impl/ClientInformationResolverServiceStrategy.java
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the University Corporation for Advanced Internet Development,
+ * Inc. (UCAID) under one or more contributor license agreements.  See the
+ * NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The UCAID licenses this file to You 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.oidc.profile.spring.relyingparty.metadata.impl;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.function.Function;
+
+import javax.annotation.Nullable;
+
+import org.springframework.beans.factory.BeanCreationException;
+import org.springframework.context.ApplicationContext;
+
+import net.shibboleth.oidc.metadata.ClientInformationResolver;
+import net.shibboleth.oidc.metadata.RelyingPartyClientInformationProvider;
+import net.shibboleth.oidc.metadata.impl.ChainingClientInformationResolver;
+import net.shibboleth.utilities.java.support.component.AbstractIdentifiableInitializableComponent;
+import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
+import net.shibboleth.utilities.java.support.resolver.ResolverException;
+import net.shibboleth.utilities.java.support.service.ServiceException;
+import net.shibboleth.utilities.java.support.service.ServiceableComponent;
+
+/**
+ * Strategy for summoning up a {@link ClientInformationResolver} from a populated {@link ApplicationContext}.
+ * 
+ * <p>
+ * The logic is the same as in 
+ * net.shibboleth.idp.profile.spring.relyingparty.metadata.impl.MetadataResolverServiceStrategy.
+ * </p>
+ */
+public class ClientInformationResolverServiceStrategy extends AbstractIdentifiableInitializableComponent
+        implements Function<ApplicationContext, ServiceableComponent<ClientInformationResolver>> {
+
+    /** {@inheritDoc} */
+    @Nullable
+    public ServiceableComponent<ClientInformationResolver> apply(@Nullable final ApplicationContext appContext) {
+        final Collection<RelyingPartyClientInformationProvider> resolvers =
+                appContext.getBeansOfType(RelyingPartyClientInformationProvider.class).values();
+
+        if (resolvers.isEmpty()) {
+            throw new ServiceException(
+                    "Reload did not produce any bean of type" + RelyingPartyClientInformationProvider.class.getName());
+        }
+        if (1 == resolvers.size()) {
+            // done
+            return resolvers.iterator().next();
+        }
+        // initialize so we can sort
+        for (final RelyingPartyClientInformationProvider resolver : resolvers) {
+            try {
+                resolver.initialize();
+            } catch (final ComponentInitializationException e) {
+                throw new BeanCreationException("could not preinitialize , client information provider " 
+                        + resolver.getId(), e);
+            }
+        }
+
+        final List<RelyingPartyClientInformationProvider> resolverList = new ArrayList<>(resolvers.size());
+        resolverList.addAll(resolvers);
+        Collections.sort(resolverList);
+        final ChainingClientInformationResolver chain = new ChainingClientInformationResolver();
+        try {
+            chain.setResolvers(resolverList);
+            chain.setId("MultiFileResolverFor:" + resolvers.size() + ":Resources");
+            chain.initialize();
+            final RelyingPartyClientInformationProvider result = new RelyingPartyClientInformationProvider();
+            result.setEmbeddedResolver(chain);
+            result.setApplicationContext(appContext);
+            result.initialize();
+            return result;
+        } catch (final ResolverException | ComponentInitializationException e) {
+            throw new ServiceException("Chaining constructor create failed", e);
+        }
+    }
+}
diff --git a/oidc-common-metadata-impl/src/main/java/net/shibboleth/oidc/profile/spring/relyingparty/metadata/impl/MetadataNamespaceHandler.java b/oidc-common-metadata-impl/src/main/java/net/shibboleth/oidc/profile/spring/relyingparty/metadata/impl/MetadataNamespaceHandler.java
new file mode 100644
index 0000000..b6476df
--- /dev/null
+++ b/oidc-common-metadata-impl/src/main/java/net/shibboleth/oidc/profile/spring/relyingparty/metadata/impl/MetadataNamespaceHandler.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the University Corporation for Advanced Internet Development,
+ * Inc. (UCAID) under one or more contributor license agreements.  See the
+ * NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The UCAID licenses this file to You 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.oidc.profile.spring.relyingparty.metadata.impl;
+
+import javax.annotation.Nonnull;
+
+import net.shibboleth.ext.spring.util.BaseSpringNamespaceHandler;
+import net.shibboleth.oidc.profile.spring.relyingparty.metadata.filter.impl.ClientInformationParser;
+import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
+
+/** Namespace handler for <code>urn:mace:shibboleth:2.0:metadata:oidc</code>. */
+public class MetadataNamespaceHandler extends BaseSpringNamespaceHandler {
+
+    /** Namespace for this handler. */
+    @Nonnull
+    @NotEmpty
+    public static final String NAMESPACE = "urn:mace:shibboleth:2.0:metadata:oidc";
+
+    /** {@inheritDoc} */
+    @Override
+    public void init() {
+        registerBeanDefinitionParser(ClientInformationParser.TYPE_NAME, new ClientInformationParser());
+    }
+
+}
diff --git a/oidc-common-metadata-impl/src/main/java/net/shibboleth/oidc/profile/spring/relyingparty/metadata/impl/package-info.java b/oidc-common-metadata-impl/src/main/java/net/shibboleth/oidc/profile/spring/relyingparty/metadata/impl/package-info.java
new file mode 100644
index 0000000..0e44dc0
--- /dev/null
+++ b/oidc-common-metadata-impl/src/main/java/net/shibboleth/oidc/profile/spring/relyingparty/metadata/impl/package-info.java
@@ -0,0 +1,21 @@
+/*
+ * Licensed to the University Corporation for Advanced Internet Development,
+ * Inc. (UCAID) under one or more contributor license agreements.  See the
+ * NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The UCAID licenses this file to You 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.
+ */
+
+/**
+ * Spring-aware tools for resolving OIDC entities.
+ */
+package net.shibboleth.oidc.profile.spring.relyingparty.metadata.impl;
\ No newline at end of file
diff --git a/oidc-common-metadata-impl/src/main/resources/META-INF/spring.handlers b/oidc-common-metadata-impl/src/main/resources/META-INF/spring.handlers
new file mode 100644
index 0000000..e9e3b58
--- /dev/null
+++ b/oidc-common-metadata-impl/src/main/resources/META-INF/spring.handlers
@@ -0,0 +1 @@
+urn\:mace\:shibboleth\:2.0\:metadata\:oidc = net.shibboleth.oidc.profile.spring.relyingparty.metadata.impl.MetadataNamespaceHandler
\ No newline at end of file
diff --git a/oidc-common-metadata-impl/src/main/resources/META-INF/spring.schemas b/oidc-common-metadata-impl/src/main/resources/META-INF/spring.schemas
new file mode 100644
index 0000000..ed5778a
--- /dev/null
+++ b/oidc-common-metadata-impl/src/main/resources/META-INF/spring.schemas
@@ -0,0 +1 @@
+classpath\:/schema/idp-oidc-extension-metadata-ext.xsd = schema/idp-oidc-extension-metadata-ext.xsd
\ No newline at end of file
diff --git a/oidc-common-metadata-impl/src/main/resources/schema/idp-oidc-extension-metadata-ext.xsd b/oidc-common-metadata-impl/src/main/resources/schema/idp-oidc-extension-metadata-ext.xsd
new file mode 100644
index 0000000..607fa69
--- /dev/null
+++ b/oidc-common-metadata-impl/src/main/resources/schema/idp-oidc-extension-metadata-ext.xsd
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:shibmd="urn:mace:shibboleth:2.0:metadata"
+    targetNamespace="urn:mace:shibboleth:2.0:metadata:oidc" elementFormDefault="qualified">
+
+    <import namespace="urn:mace:shibboleth:2.0:metadata"
+        schemaLocation="http://shibboleth.net/schema/idp/shibboleth-metadata.xsd" />
+
+    <complexType name="ClientInformation">
+        <annotation>
+            <documentation>
+                A node processor that processes OAuthRP and attaches the parsed client
+                information via object metadata.
+            </documentation>
+        </annotation>
+        <complexContent>
+            <extension base="shibmd:MetadataNodeProcessorType">
+                <attribute name="keyInfoProvidersRef" type="shibmd:string" use="required" />
+            </extension>
+        </complexContent>
+    </complexType>
+
+</schema>
\ No newline at end of file
diff --git a/oidc-common-metadata-impl/src/test/java/net/shibboleth/oidc/profile/spring/relyingparty/metadata/impl/ReloadClientResolverServiceConfigurationTest.java b/oidc-common-metadata-impl/src/test/java/net/shibboleth/oidc/profile/spring/relyingparty/metadata/impl/ReloadClientResolverServiceConfigurationTest.java
new file mode 100644
index 0000000..e760cb4
--- /dev/null
+++ b/oidc-common-metadata-impl/src/test/java/net/shibboleth/oidc/profile/spring/relyingparty/metadata/impl/ReloadClientResolverServiceConfigurationTest.java
@@ -0,0 +1,158 @@
+/*
+ * Licensed to the University Corporation for Advanced Internet Development,
+ * Inc. (UCAID) under one or more contributor license agreements.  See the
+ * NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The UCAID licenses this file to You 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.oidc.profile.spring.relyingparty.metadata.impl;
+
+import java.io.IOException;
+import java.time.Instant;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.function.Function;
+
+import javax.servlet.http.HttpServletResponse;
+
+import org.opensaml.profile.context.ProfileRequestContext;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.Resource;
+import org.springframework.mock.web.MockHttpServletResponse;
+import org.springframework.webflow.execution.Event;
+import org.springframework.webflow.execution.RequestContext;
+import org.testng.Assert;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import net.shibboleth.ext.spring.service.ReloadableSpringService;
+import net.shibboleth.idp.profile.impl.ReloadServiceConfiguration;
+import net.shibboleth.idp.profile.testing.ActionTestingSupport;
+import net.shibboleth.idp.profile.testing.RequestContextBuilder;
+import net.shibboleth.oidc.metadata.ClientInformationResolver;
+import net.shibboleth.oidc.metadata.RelyingPartyClientInformationProvider;
+import net.shibboleth.oidc.metadata.impl.ChainingClientInformationResolver;
+import net.shibboleth.oidc.profile.spring.relyingparty.metadata.impl.ClientInformationResolverServiceStrategy;
+import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
+import net.shibboleth.utilities.java.support.component.ComponentSupport;
+import net.shibboleth.utilities.java.support.service.ReloadableService;
+import net.shibboleth.utilities.java.support.service.ServiceableComponent;
+
+/**
+ * Unit tests for {@link ClientInformationResolverServiceStrategy}.
+ * 
+ * Mostly based on <pre>net.shibboleth.idp.profile.spring.relyingparty.metadata.ReloadServiceConfigurationTest</pre>.
+ */
+public class ReloadClientResolverServiceConfigurationTest {
+
+    /** The service. */
+    private ReloadableSpringService<ClientInformationResolver> service;
+
+    private RequestContext src;
+    
+    private List<Resource> oneResolver;
+    
+    private List<Resource> twoResolvers;
+    
+    @BeforeClass public void setup() throws IOException, ComponentInitializationException {
+        oneResolver = new ArrayList<>();
+        oneResolver.add(new ClassPathResource("/net/shibboleth/oidc/metadata/impl/oidc-metadata-providers.xml"));
+        
+        twoResolvers = new ArrayList<>();
+        twoResolvers.add(new ClassPathResource("/net/shibboleth/oidc/metadata/impl/oidc-metadata-providers2.xml"));
+    }
+
+    public void setupResolver(final List<Resource> serviceLocations) throws ComponentInitializationException {
+        service = new ReloadableSpringService<>(ClientInformationResolver.class, new ClientInformationResolverServiceStrategy());
+        service.setFailFast(true);
+        service.setId("mockId");
+        
+        service.setServiceConfigurations(serviceLocations);
+        service.initialize();
+    }
+    
+    @BeforeMethod public void setUpAction() throws ComponentInitializationException {
+        src = new RequestContextBuilder().buildRequestContext();
+    }
+
+    @Test public void oneResource() throws ComponentInitializationException {
+        setupResolver(oneResolver);
+        final Instant time = service.getLastReloadAttemptInstant();
+        service.reload();
+        Assert.assertNotEquals(time, service.getLastReloadAttemptInstant());
+        final ServiceableComponent<ClientInformationResolver> component = service.getServiceableComponent();
+        final ClientInformationResolver resolver = component.getComponent();
+        component.unpinComponent();
+        Assert.assertEquals(getChainSize(resolver), 1);
+    }
+    
+    protected int getChainSize(final ClientInformationResolver resolver) {
+        Assert.assertTrue(resolver instanceof RelyingPartyClientInformationProvider);
+        final RelyingPartyClientInformationProvider rpProvider = (RelyingPartyClientInformationProvider) resolver;
+        final ClientInformationResolver embedded = rpProvider.getEmbeddedResolver();
+        Assert.assertTrue(embedded instanceof ChainingClientInformationResolver);
+        final ChainingClientInformationResolver chain = (ChainingClientInformationResolver) embedded;
+        return chain.getResolvers().size();
+    }
+
+    @Test public void twoResources() throws ComponentInitializationException {
+        setupResolver(twoResolvers);
+        final Instant time = service.getLastReloadAttemptInstant();
+        service.reload();
+        Assert.assertNotEquals(time, service.getLastReloadAttemptInstant());
+        final ServiceableComponent<ClientInformationResolver> component = service.getServiceableComponent();
+        final ClientInformationResolver resolver = component.getComponent();
+        component.unpinComponent();
+        Assert.assertEquals(getChainSize(resolver), 2);
+    }
+
+    @Test(expectedExceptions = ComponentInitializationException.class) public void noResources()
+            throws ComponentInitializationException {
+        setupResolver(new ArrayList<Resource>());
+    }
+
+    @Test public void serviceAction() throws ComponentInitializationException {
+        setupResolver(oneResolver);
+        final Instant time = service.getLastReloadAttemptInstant();
+
+        final MockHttpServletResponse response = new MockHttpServletResponse();
+        
+        final ReloadServiceConfiguration action = initializeAction(service, response);
+        final Event event = action.execute(src);
+        service.getServiceableComponent().unpinComponent();
+        ActionTestingSupport.assertProceedEvent(event);
+
+        Assert.assertNotEquals(time, service.getLastReloadAttemptInstant());
+        Assert.assertEquals(response.getStatus(), HttpServletResponse.SC_OK);
+    }
+
+    protected static ReloadServiceConfiguration initializeAction(final ReloadableService<?> reloadableService, 
+            final HttpServletResponse response) throws ComponentInitializationException {
+        final ReloadServiceConfiguration action = new ReloadServiceConfiguration();
+        action.setHttpServletResponse(response);
+        action.setServiceLookupStrategy(new Function<ProfileRequestContext,ReloadableService<?>>() {
+            public ReloadableService<?> apply(ProfileRequestContext input) {
+                return reloadableService;
+            }
+        });
+        action.initialize();
+        return action;
+    }
+    
+    @AfterClass public void teardown() {
+        ComponentSupport.destroy(service);
+    }
+
+}
\ No newline at end of file
diff --git a/oidc-common-metadata-impl/src/test/resources/net/shibboleth/oidc/metadata/impl/oidc-metadata-providers.xml b/oidc-common-metadata-impl/src/test/resources/net/shibboleth/oidc/metadata/impl/oidc-metadata-providers.xml
new file mode 100644
index 0000000..4af86b4
--- /dev/null
+++ b/oidc-common-metadata-impl/src/test/resources/net/shibboleth/oidc/metadata/impl/oidc-metadata-providers.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:context="http://www.springframework.org/schema/context"
+       xmlns:util="http://www.springframework.org/schema/util"
+       xmlns:p="http://www.springframework.org/schema/p"
+       xmlns:c="http://www.springframework.org/schema/c"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+                           http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
+                           http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"
+                           
+       default-init-method="initialize"
+       default-destroy-method="destroy">
+
+    <!-- Generic beans for configuring the OIDC metadata system, in most cases don't need any modifications. -->
+
+    <bean id="shibboleth.oidc.RelyingPartyClientInformationProvider"
+        class="net.shibboleth.oidc.metadata.RelyingPartyClientInformationProvider"
+        p:embeddedResolver-ref="shibboleth.oidc.ChainingClientInformationResolver">
+    </bean>
+
+    <bean id="shibboleth.oidc.ChainingClientInformationResolver"
+        class="net.shibboleth.oidc.metadata.impl.ChainingClientInformationResolver"
+        p:id="InternalEmbeddedChainResolver" 
+        p:resolvers-ref="shibboleth.oidc.ClientInformationResolvers"/>
+        
+    <!-- Generic beans end, in most cases only edit after this line. -->
+
+    <!-- The following example contains two OIDC client information resolvers: first one reading a single client information from a JSON file, and the
+         second one fetchs the OIDC client informations from the configured StorageService. -->
+
+    <util:list id="shibboleth.oidc.ClientInformationResolvers"
+        value-type="net.shibboleth.oidc.metadata.ClientInformationResolver">
+        <ref bean="ExampleFileResolver" />
+    </util:list>
+
+    <bean id="ExampleFileResolver"
+        class="net.shibboleth.oidc.metadata.impl.FilesystemClientInformationResolver" p:id="ExampleFileResolver1"
+        c:metadata="/net/shibboleth/oidc/metadata/impl/oidc-client.json" />
+    
+</beans>
+
diff --git a/oidc-common-metadata-impl/src/test/resources/net/shibboleth/oidc/metadata/impl/oidc-metadata-providers2.xml b/oidc-common-metadata-impl/src/test/resources/net/shibboleth/oidc/metadata/impl/oidc-metadata-providers2.xml
new file mode 100644
index 0000000..0722806
--- /dev/null
+++ b/oidc-common-metadata-impl/src/test/resources/net/shibboleth/oidc/metadata/impl/oidc-metadata-providers2.xml
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:context="http://www.springframework.org/schema/context"
+       xmlns:util="http://www.springframework.org/schema/util"
+       xmlns:p="http://www.springframework.org/schema/p"
+       xmlns:c="http://www.springframework.org/schema/c"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+                           http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
+                           http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"
+                           
+       default-init-method="initialize"
+       default-destroy-method="destroy">
+
+    <!-- Generic beans for configuring the OIDC metadata system, in most cases don't need any modifications. -->
+
+    <bean id="shibboleth.oidc.RelyingPartyClientInformationProvider"
+        class="net.shibboleth.oidc.metadata.RelyingPartyClientInformationProvider"
+        p:embeddedResolver-ref="shibboleth.oidc.ChainingClientInformationResolver">
+    </bean>
+
+    <bean id="shibboleth.oidc.RelyingPartyClientInformationProvider2"
+        class="net.shibboleth.oidc.metadata.RelyingPartyClientInformationProvider"
+        p:embeddedResolver-ref="shibboleth.oidc.ChainingClientInformationResolver2">
+    </bean>
+
+    <bean id="shibboleth.oidc.ChainingClientInformationResolver"
+        class="net.shibboleth.oidc.metadata.impl.ChainingClientInformationResolver"
+        p:id="InternalEmbeddedChainResolver" 
+        p:resolvers-ref="shibboleth.oidc.ClientInformationResolvers"/>
+
+    <bean id="shibboleth.oidc.ChainingClientInformationResolver2"
+        class="net.shibboleth.oidc.metadata.impl.ChainingClientInformationResolver"
+        p:id="InternalEmbeddedChainResolver" 
+        p:resolvers-ref="shibboleth.oidc.ClientInformationResolvers2"/>
+
+    <!-- Generic beans end, in most cases only edit after this line. -->
+
+    <!-- The following example contains two OIDC client information resolvers: first one reading a single client information from a JSON file, and the
+         second one fetchs the OIDC client informations from the configured StorageService. -->
+
+    <util:list id="shibboleth.oidc.ClientInformationResolvers"
+        value-type="net.shibboleth.oidc.metadata.ClientInformationResolver">
+        <ref bean="ExampleFileResolver" />
+    </util:list>
+
+    <util:list id="shibboleth.oidc.ClientInformationResolvers2"
+        value-type="net.shibboleth.oidc.metadata.ClientInformationResolver">
+        <ref bean="ExampleFileResolver2" />
+    </util:list>
+
+    <bean id="ExampleFileResolver"
+        class="net.shibboleth.oidc.metadata.impl.FilesystemClientInformationResolver" p:id="ExampleFileResolver1"
+        c:metadata="/net/shibboleth/oidc/metadata/impl/oidc-client.json"/>
+
+    <bean id="ExampleFileResolver2"
+        class="net.shibboleth.oidc.metadata.impl.FilesystemClientInformationResolver" p:id="ExampleFileResolver2"
+        c:metadata="/net/shibboleth/oidc/metadata/impl/oidc-client2.json"/>
+    
+</beans>
+

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list