Skip to content

Commit

Permalink
Populate UKf MDUI DisplayName in test, export-preview aggregates
Browse files Browse the repository at this point in the history
See ukf/ukf-meta#21.
  • Loading branch information
iay committed Oct 25, 2017
1 parent 78f9200 commit 52c3b3e
Show file tree
Hide file tree
Showing 3 changed files with 160 additions and 4 deletions.
10 changes: 6 additions & 4 deletions mdx/uk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ before being included in the `export` version consumed by interfederation partne

### Export Preview Aggregate vs. Export Aggregate

Status (2017-02-14):
Status (2017-10-25):

* These aggregates are currently identical.
* The export preview aggregate ensures that all UKf-registered identity providers have `mdui:DisplayName`
metadata by copying data from `md:OrganizationDisplayName` if required.

## Production Maturity Pipeline

Expand Down Expand Up @@ -59,9 +60,10 @@ when it appeared in the fallback aggregate, which would be too late to take corr

### Test Aggregate vs. Production Aggregate

Status (2017-03-02):
Status (2017-10-25):

* These aggregates are currently identical.
* The test aggregate ensures that all UKf-registered identity providers have `mdui:DisplayName`
metadata by copying data from `md:OrganizationDisplayName` if required.

### Fallback Aggregate vs. Production Aggregate

Expand Down
52 changes: 52 additions & 0 deletions mdx/uk/generate.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,46 @@
</bean>


<!--
*************************************
*** ***
*** M D U I H A N D L I N G ***
*** ***
*************************************
-->


<!--
odn_to_mdui
Ensure that all UKf-registered identity providers have
mdui:DisplayName elements.
-->
<bean id="odn_to_mdui" parent="mda.SplitMergeStage">

<!-- Select UKf-registered entities only. -->
<property name="selectionStrategy">
<bean parent="mda.XPathItemSelectionStrategy"
c:_0 = "/md:EntityDescriptor/md:Extensions/mdrpi:RegistrationInfo/@registrationAuthority =
'http://ukfederation.org.uk'"
c:_1-ref="commonNamespaces"
/>
</property>

<!-- Process selected entities. -->
<property name="selectedItemPipeline">
<bean parent="mda.SimplePipeline">
<property name="stages">
<list>
<bean parent="mda.XSLTransformationStage"
p:XSLResource="classpath:uk/odn_to_mdui.xsl"/>
</list>
</property>
</bean>
</property>
</bean>


<!--
*****************************************
*** ***
Expand Down Expand Up @@ -586,6 +626,12 @@
<bean id="uk_testPipeline" parent="mda.CompositeStage">
<property name="composedStages">
<list>
<!--
Ensure that all UKf-registered identity providers have
mdui:DisplayName elements.
-->
<ref bean="odn_to_mdui"/>

<!--
Enforce IdP display name uniqueness before assembling aggregate
-->
Expand Down Expand Up @@ -825,6 +871,12 @@
</property>
</bean>

<!--
Ensure that all UKf-registered identity providers have
mdui:DisplayName elements.
-->
<ref bean="odn_to_mdui"/>

<!--
Enforce IdP display name uniqueness before assembling aggregate
-->
Expand Down
102 changes: 102 additions & 0 deletions mdx/uk/odn_to_mdui.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
odn_to_mdui.xsl
If an identity provider does not have at least one MDUI-based discovery
name, give it one by copying data from its md:OrganizationDisplayName.
This transform will only be applied to UKf-registered entities.
This allows us to assume:
* The entity will have an md:Organization and therefore (by schema)
at least one md:OrganizationDisplayName
* It will either not have an mdui:UIInfo at all, or will have one
with at least one mdui:DisplayName. This means we don't need to
handle the case of filling in a partial mdui:UIInfo container,
and can always create one from scratch.
* The entity's md:IDPSSODescriptor has an md:Extensions element,
because UKf-registered IdPs are required to have
at least one shibmd:Scope element.
-->
<xsl:stylesheet version="1.0"
xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata"
xmlns:mdui="urn:oasis:names:tc:SAML:metadata:ui"

xmlns="urn:oasis:names:tc:SAML:2.0:metadata"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<!--Force UTF-8 encoding for the output.-->
<xsl:output omit-xml-declaration="no" method="xml" encoding="UTF-8" indent="yes"/>


<!--
Match the md:IDPSSODescriptor/md:Extensions element of an identity provider
which does not have mdui:UIInfo.
We must fabricate the mdui:UIInfo as well as the mdui:DisplayName
elements.
-->
<xsl:template match="/md:EntityDescriptor/md:IDPSSODescriptor/md:Extensions[not(mdui:UIInfo)]">
<xsl:variable name="odns" select="../../md:Organization/md:OrganizationDisplayName"/>
<xsl:copy>
<xsl:text>&#10;&#9;&#9;&#9;</xsl:text>
<mdui:UIInfo>
<xsl:call-template name="generateDisplayNames">
<xsl:with-param name="odns" select="$odns"/>
</xsl:call-template>
<xsl:text>&#10;&#9;&#9;&#9;</xsl:text>
</mdui:UIInfo>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>

<!--
Make a new mdui:DisplayName for each of the md:OrganizationDisplayName
elements in the $odns parameter.
Each of the new elements copies the value and xml:lang attribute of
the md:OrganizationDisplayName, and is indented appropriately to
appearing at the start of the enclosing mdui:UIInfo.
-->
<xsl:template name="generateDisplayNames">
<xsl:param name="odns"/>
<xsl:for-each select="$odns">
<xsl:text>&#10;&#9;&#9;&#9;&#9;</xsl:text>
<mdui:DisplayName>
<xsl:attribute name="xml:lang">
<xsl:value-of select="@xml:lang"/>
</xsl:attribute>
<xsl:value-of select="."/>
</mdui:DisplayName>
</xsl:for-each>
</xsl:template>


<!--
*********************************************
*** ***
*** D E F A U L T T E M P L A T E S ***
*** ***
*********************************************
-->


<!--By default, copy text blocks, comments and attributes unchanged.-->
<xsl:template match="text()|comment()|@*">
<xsl:copy/>
</xsl:template>

<!--By default, copy all elements from the input to the output, along with their attributes and contents.-->
<xsl:template match="*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>

</xsl:stylesheet>

0 comments on commit 52c3b3e

Please sign in to comment.