Skip to content

Commit

Permalink
Add mailto: to e-mail addresses from Edugate, if they don't already h…
Browse files Browse the repository at this point in the history
…ave it.
  • Loading branch information
iay committed Feb 29, 2012
1 parent d53f8e7 commit 3983a23
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
16 changes: 16 additions & 0 deletions mdx/uk/beans.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Common beans for this channel.
-->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
Expand Down Expand Up @@ -99,6 +100,21 @@
</bean>


<!--
uk_fix_mailto
Adds "mailto:" to md:EmailAddress elements which don't already have it.
-->
<bean id="uk_fix_mailto" p:id="uk_fix_mailto" class="net.shibboleth.metadata.dom.XSLTransformationStage"
init-method="initialize" lazy-init="true">
<property name="xslResource">
<bean class="org.opensaml.util.resource.FilesystemResource">
<constructor-arg value="#{ systemProperties['basedir'] }/mdx/uk/fix_mailto.xsl"/>
</bean>
</property>
</bean>


<!--
check_ukreg
Expand Down
40 changes: 40 additions & 0 deletions mdx/uk/fix_mailto.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
fix_mailto.xsl
Add "mailto:" scheme to e-mail addresses if not already present.
-->
<xsl:stylesheet version="1.0"
xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata"

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"
exclude-result-prefixes="md">

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

<xsl:template match="md:EmailAddress[not(starts-with(., 'mailto:'))]">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:text>mailto:</xsl:text>
<xsl:value-of select="."/>
</xsl:copy>
</xsl:template>

<!--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>
1 change: 1 addition & 0 deletions mdx/uk/generate.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
<list>
<ref bean="ie_edugate_exportedEntities"/>
<ref bean="uk_performFixups"/>
<ref bean="uk_fix_mailto"/>
</list>
</property>
</bean>
Expand Down

0 comments on commit 3983a23

Please sign in to comment.