[java-identity-provider] 04/11: IDP-1464 Node Processor for mdui:UIInfo

Rod Widdowson rdw at steadingsoftware.com
Tue Jun 11 09:38:22 EDT 2019


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

rdw pushed a commit to branch master
in repository java-identity-provider.

View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=4a6ce0a5b43287aadc1ec83a945ac8044e00ad24

commit 4a6ce0a5b43287aadc1ec83a945ac8044e00ad24
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Sat Jun 8 16:39:24 2019 +0100

    IDP-1464 Node Processor for mdui:UIInfo
    
    https://issues.shibboleth.net/jira/browse/IDP-1464
---
 .../NodeProcessingAttachingBeanPostProcessor.java  |  9 ++-
 .../saml/metadata/impl/UIInfoNodeProcessor.java    | 44 +++++++++++++++
 .../saml/metadata/impl/BaseNodeProcessorTest.java  | 60 ++++++++++++++++++++
 .../metadata/impl/ScopesNodeProcessorTest.java     | 38 ++-----------
 .../metadata/impl/UIInfoNodeProcessorTest.java     | 65 ++++++++++++++++++++++
 ...sor-metadata.xml => NodeProcessor-metadata.xml} | 15 ++++-
 6 files changed, 194 insertions(+), 37 deletions(-)

diff --git a/idp-profile-spring/src/main/java/net/shibboleth/idp/profile/spring/relyingparty/metadata/impl/NodeProcessingAttachingBeanPostProcessor.java b/idp-profile-spring/src/main/java/net/shibboleth/idp/profile/spring/relyingparty/metadata/impl/NodeProcessingAttachingBeanPostProcessor.java
index 8b305ae..ac8da77 100644
--- a/idp-profile-spring/src/main/java/net/shibboleth/idp/profile/spring/relyingparty/metadata/impl/NodeProcessingAttachingBeanPostProcessor.java
+++ b/idp-profile-spring/src/main/java/net/shibboleth/idp/profile/spring/relyingparty/metadata/impl/NodeProcessingAttachingBeanPostProcessor.java
@@ -37,6 +37,7 @@ import net.shibboleth.idp.attribute.transcoding.AttributeTranscoderRegistry;
 import net.shibboleth.idp.saml.metadata.RelyingPartyMetadataProvider;
 import net.shibboleth.idp.saml.metadata.impl.AttributeMappingNodeProcessor;
 import net.shibboleth.idp.saml.metadata.impl.ScopesNodeProcessor;
+import net.shibboleth.idp.saml.metadata.impl.UIInfoNodeProcessor;
 import net.shibboleth.idp.saml.security.impl.KeyAuthorityNodeProcessor;
 import net.shibboleth.utilities.java.support.annotation.ParameterName;
 import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
@@ -95,9 +96,11 @@ public class NodeProcessingAttachingBeanPostProcessor implements BeanPostProcess
 
         if (!filterAttached) {
             final NodeProcessingMetadataFilter filterToAttach = new NodeProcessingMetadataFilter();
-            final List<MetadataNodeProcessor> processors = new ArrayList<>(
-                    Arrays.asList(new EntitiesDescriptorNameProcessor(),
-                            new KeyAuthorityNodeProcessor(), new ScopesNodeProcessor()));
+            final List<MetadataNodeProcessor> processors = new ArrayList<>(List.of(
+                            new EntitiesDescriptorNameProcessor(),
+                            new KeyAuthorityNodeProcessor(), 
+                            new ScopesNodeProcessor(),
+                            new UIInfoNodeProcessor()));
             if (null != transcoderRegistry) {
                 processors.add(new AttributeMappingNodeProcessor(transcoderRegistry));
             }
diff --git a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/metadata/impl/UIInfoNodeProcessor.java b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/metadata/impl/UIInfoNodeProcessor.java
new file mode 100644
index 0000000..3a4ead1
--- /dev/null
+++ b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/metadata/impl/UIInfoNodeProcessor.java
@@ -0,0 +1,44 @@
+/*
+ * 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.idp.saml.metadata.impl;
+
+import javax.annotation.concurrent.NotThreadSafe;
+
+import org.opensaml.core.xml.XMLObject;
+import org.opensaml.saml.ext.saml2mdui.UIInfo;
+import org.opensaml.saml.metadata.resolver.filter.FilterException;
+import org.opensaml.saml.metadata.resolver.filter.MetadataNodeProcessor;
+
+import net.shibboleth.idp.saml.metadata.IdPUIInfo;
+
+/**
+ * An implementation of {@link MetadataNodeProcessor} which processes any {@link UIInfo}s from any
+ * and processes them into an {@link IdPUIInfo}.
+ */
+ at NotThreadSafe
+public class UIInfoNodeProcessor implements MetadataNodeProcessor {
+  
+    /** {@inheritDoc} */
+    @Override public void process(final XMLObject metadataNode) throws FilterException {
+        
+        if (metadataNode instanceof UIInfo) {
+            metadataNode.getObjectMetadata().put(new IdPUIInfo((UIInfo) metadataNode));
+        }
+    }
+
+}
\ No newline at end of file
diff --git a/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/metadata/impl/BaseNodeProcessorTest.java b/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/metadata/impl/BaseNodeProcessorTest.java
new file mode 100644
index 0000000..ae7db4d
--- /dev/null
+++ b/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/metadata/impl/BaseNodeProcessorTest.java
@@ -0,0 +1,60 @@
+/*
+ * 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.idp.saml.metadata.impl;
+
+import java.io.File;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.List;
+
+import org.opensaml.core.xml.XMLObjectBaseTestCase;
+import org.opensaml.saml.metadata.resolver.MetadataResolver;
+import org.opensaml.saml.metadata.resolver.filter.MetadataNodeProcessor;
+import org.opensaml.saml.metadata.resolver.filter.impl.NodeProcessingMetadataFilter;
+import org.opensaml.saml.metadata.resolver.impl.FilesystemMetadataResolver;
+import org.testng.annotations.BeforeClass;
+
+import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
+import net.shibboleth.utilities.java.support.resolver.ResolverException;
+
+public abstract class BaseNodeProcessorTest extends XMLObjectBaseTestCase {
+    
+    protected MetadataResolver resolver;
+    
+    @BeforeClass
+    public void getMetadataResolver() throws URISyntaxException, ComponentInitializationException, ResolverException {
+        final URL mdURL = BaseNodeProcessorTest.class
+                .getResource("/net/shibboleth/idp/saml/impl/metadata/NodeProcessor-metadata.xml");
+        final File mdFile = new File(mdURL.toURI());
+
+        final List<MetadataNodeProcessor> processors = List.of(getProcessor());
+        
+        final NodeProcessingMetadataFilter metadataFilter = new NodeProcessingMetadataFilter();
+        metadataFilter.setNodeProcessors(processors);
+        metadataFilter.initialize();
+        
+        final FilesystemMetadataResolver fileResolver = new FilesystemMetadataResolver(mdFile);
+        fileResolver.setParserPool(parserPool);
+        fileResolver.setMetadataFilter(metadataFilter);
+        fileResolver.setId("test");
+        fileResolver.initialize();
+        resolver = fileResolver;
+    }
+
+    protected abstract MetadataNodeProcessor getProcessor(); 
+}
diff --git a/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/metadata/impl/ScopesNodeProcessorTest.java b/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/metadata/impl/ScopesNodeProcessorTest.java
index c03a5c2..227ec64 100644
--- a/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/metadata/impl/ScopesNodeProcessorTest.java
+++ b/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/metadata/impl/ScopesNodeProcessorTest.java
@@ -21,51 +21,20 @@ import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertFalse;
 import static org.testng.Assert.assertTrue;
 
-import java.io.File;
-import java.net.URISyntaxException;
-import java.net.URL;
 import java.util.List;
 
 import org.opensaml.core.criterion.EntityIdCriterion;
-import org.opensaml.core.xml.XMLObjectBaseTestCase;
-import org.opensaml.saml.metadata.resolver.MetadataResolver;
 import org.opensaml.saml.metadata.resolver.filter.MetadataNodeProcessor;
-import org.opensaml.saml.metadata.resolver.filter.impl.NodeProcessingMetadataFilter;
-import org.opensaml.saml.metadata.resolver.impl.FilesystemMetadataResolver;
 import org.opensaml.saml.saml2.metadata.AttributeAuthorityDescriptor;
 import org.opensaml.saml.saml2.metadata.EntityDescriptor;
 import org.opensaml.saml.saml2.metadata.IDPSSODescriptor;
-import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 
 import net.shibboleth.idp.saml.metadata.ScopesContainer;
-import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
 import net.shibboleth.utilities.java.support.resolver.CriteriaSet;
 import net.shibboleth.utilities.java.support.resolver.ResolverException;
 
-public final class ScopesNodeProcessorTest extends XMLObjectBaseTestCase {
-    
-    private MetadataResolver resolver;
-    
-    @BeforeClass
-    public void getMetadataResolver() throws URISyntaxException, ComponentInitializationException, ResolverException {
-        final URL mdURL = ScopesNodeProcessorTest.class
-                .getResource("/net/shibboleth/idp/saml/impl/metadata/Scopes-NodeProcessor-metadata.xml");
-        final File mdFile = new File(mdURL.toURI());
-
-        final List<MetadataNodeProcessor> processors = List.of(new ScopesNodeProcessor());
-        
-        final NodeProcessingMetadataFilter metadataFilter = new NodeProcessingMetadataFilter();
-        metadataFilter.setNodeProcessors(processors);
-        metadataFilter.initialize();
-        
-        final FilesystemMetadataResolver fileResolver = new FilesystemMetadataResolver(mdFile);
-        fileResolver.setParserPool(parserPool);
-        fileResolver.setMetadataFilter(metadataFilter);
-        fileResolver.setId("test");
-        fileResolver.initialize();
-        resolver = fileResolver;
-    }
+public final class ScopesNodeProcessorTest extends BaseNodeProcessorTest {
     
     @Test
     public void noScopes() throws ResolverException {
@@ -123,4 +92,9 @@ public final class ScopesNodeProcessorTest extends XMLObjectBaseTestCase {
         
     }
 
+    /** {@inheritDoc} */
+    protected MetadataNodeProcessor getProcessor() {
+        return new ScopesNodeProcessor();
+    }
+
 }
diff --git a/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/metadata/impl/UIInfoNodeProcessorTest.java b/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/metadata/impl/UIInfoNodeProcessorTest.java
new file mode 100644
index 0000000..b89e1b5
--- /dev/null
+++ b/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/metadata/impl/UIInfoNodeProcessorTest.java
@@ -0,0 +1,65 @@
+/*
+ * 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.idp.saml.metadata.impl;
+
+import static org.testng.Assert.assertEquals;
+
+import java.util.Locale;
+
+import org.opensaml.core.criterion.EntityIdCriterion;
+import org.opensaml.core.xml.XMLObject;
+import org.opensaml.saml.ext.saml2mdui.UIInfo;
+import org.opensaml.saml.metadata.resolver.filter.MetadataNodeProcessor;
+import org.opensaml.saml.saml2.metadata.EntityDescriptor;
+import org.opensaml.saml.saml2.metadata.IDPSSODescriptor;
+import org.testng.annotations.Test;
+
+import net.shibboleth.idp.saml.metadata.IdPUIInfo;
+import net.shibboleth.utilities.java.support.resolver.CriteriaSet;
+import net.shibboleth.utilities.java.support.resolver.ResolverException;
+
+public final class UIInfoNodeProcessorTest extends BaseNodeProcessorTest {
+    
+    @Test 
+    public void test() throws ResolverException {
+        final EntityDescriptor entity  = resolver.resolveSingle(new CriteriaSet(new EntityIdCriterion("https://scopes.example.org")));
+
+        final IDPSSODescriptor idpSSO = entity.getIDPSSODescriptor("urn:oasis:names:tc:SAML:2.0:protocol");
+        IdPUIInfo uiInfo = null;
+        for (final XMLObject  x: idpSSO.getExtensions().getUnknownXMLObjects()) {
+            if (!(x instanceof UIInfo)) {
+                continue;
+            }
+            uiInfo = x.getObjectMetadata().get(IdPUIInfo.class).get(0);
+            break;
+        }
+        
+        
+        final Locale l = Locale.forLanguageTag("en");
+        assertEquals(uiInfo.getDisplayNames().get(l), "Display");
+        assertEquals(uiInfo.getDescriptions().get(l), "Desc");
+        assertEquals(uiInfo.getLocaleLogos().get(l).size(), 1);
+        assertEquals(uiInfo.getNonLocaleLogos().size(), 2);
+    }
+
+    /** {@inheritDoc} */
+    protected MetadataNodeProcessor getProcessor() {
+        return new UIInfoNodeProcessor();
+    }
+
+}
diff --git a/idp-saml-impl/src/test/resources/net/shibboleth/idp/saml/impl/metadata/Scopes-NodeProcessor-metadata.xml b/idp-saml-impl/src/test/resources/net/shibboleth/idp/saml/impl/metadata/NodeProcessor-metadata.xml
similarity index 71%
rename from idp-saml-impl/src/test/resources/net/shibboleth/idp/saml/impl/metadata/Scopes-NodeProcessor-metadata.xml
rename to idp-saml-impl/src/test/resources/net/shibboleth/idp/saml/impl/metadata/NodeProcessor-metadata.xml
index 8167928..dc1791d 100644
--- a/idp-saml-impl/src/test/resources/net/shibboleth/idp/saml/impl/metadata/Scopes-NodeProcessor-metadata.xml
+++ b/idp-saml-impl/src/test/resources/net/shibboleth/idp/saml/impl/metadata/NodeProcessor-metadata.xml
@@ -1,7 +1,10 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<EntitiesDescriptor xmlns="urn:oasis:names:tc:SAML:2.0:metadata"  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:shibmd="urn:mace:shibboleth:metadata:1.0"
+<EntitiesDescriptor xmlns="urn:oasis:names:tc:SAML:2.0:metadata"
+			xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+			xmlns:shibmd="urn:mace:shibboleth:metadata:1.0"
+			xmlns:mdui="urn:oasis:names:tc:SAML:metadata:ui"
             xsi:schemaLocation="urn:mace:shibboleth:2.0:metadata http://shibboleth.net/schema/idp/shibboleth-metadata.xsd
-                                urn:mace:shibboleth:metadata:1.0 classpath:\schema\shibboleth-metadata-1.0.xsd"
+urn:oasis:names:tc:SAML:metadata:ui http://docs.oasis-open.org/security/saml/Post2.0/sstc-saml-metadata-ui/v1.0/cs01/xsd/sstc-saml-metadata-ui-v1.0.xsd                                urn:mace:shibboleth:metadata:1.0 classpath:\schema\shibboleth-metadata-1.0.xsd"
              Name="GroupTop" validUntil="2100-01-01T00:00:00Z">
 
     <EntityDescriptor entityID="https://noscopes.example.org">
@@ -25,6 +28,14 @@
             <Extensions>
                 <shibmd:Scope regexp="true">^.*IDPSSO.*reg.*Scope</shibmd:Scope>
                 <shibmd:Scope regexp="false">IDPSSOScope2</shibmd:Scope>
+   			<mdui:UIInfo>
+				<mdui:DisplayName xml:lang="en">Display</mdui:DisplayName>
+				<mdui:Description xml:lang="en">Desc</mdui:Description>
+				<mdui:Logo height="80" width="80">LOGO1</mdui:Logo>
+				<mdui:Logo height="43" width="100">LOGO2</mdui:Logo>
+				<mdui:Logo height="104" width="240" xml:lang="en">Logo3</mdui:Logo>
+			</mdui:UIInfo>
+                
             </Extensions>
             <SingleSignOnService Binding="urn:mace:shibboleth:1.0:profiles:AuthnRequest" Location="https://idp.example.org/idp/Shibboleth/SSO"/>
         </IDPSSODescriptor>

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


More information about the commits mailing list