This repository has been archived by the owner. It is now read-only.
forked from InCommon/inc-meta
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Archive tools used to inject orgID values
- Loading branch information
Showing
5 changed files
with
116 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| # `utilities/2016-09-16` | ||
|
|
||
| These transforms and scripts were used to add an `orgID` attribute to the | ||
| `UKFederationMember` elements on all currently registered entities. | ||
|
|
||
| ## Step 1 | ||
|
|
||
| Generate `id-to-name.txt` as follows: | ||
|
|
||
| xsltproc --output=id-to-name.txt gen-id-to-name.xsl members/members.xml | ||
|
|
||
| This file contains a mapping between organization IDs and canonical | ||
| organization names, like this: | ||
|
|
||
| ukforg4590 Ian A. Young | ||
|
|
||
| The first field is separated from the second by a single tab character. | ||
|
|
||
| ## Step 2 | ||
|
|
||
| Generate `ukid-to-name.txt` as follows: | ||
|
|
||
| xsltproc gen-ukid-to-name.xsl entities/uk*.xml >ukid-to-name.txt | ||
|
|
||
| This file contains a mapping between entity `ID` attributes and canonical | ||
| organization names, like this: | ||
|
|
||
| uk000006 Ian A. Young | ||
|
|
||
| Again, the separator between the first and second fields is a single tab character. | ||
|
|
||
| ## Step 3 | ||
|
|
||
| Combining the results of steps 1 and 2, we can generate a list of all entity | ||
| files (named after entity `ID` values as in `ukid-to-name.txt`), via | ||
| the canonical organization name, to the organization ID values found in | ||
| `members.xml`. | ||
|
|
||
| This is then applied to all entity fragment files by executing `./doall.pl`. | ||
|
|
||
| `doall` reads both data files, then iterates across all fragment files calling | ||
| `patch.pl` to inject the appropriate `orgID` value. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| #!/usr/bin/env perl -W | ||
|
|
||
| open(F, "id-to-name.txt") || die "could not open id-to-name map"; | ||
| while (<F>) { | ||
| my ($orgid, $name) = split /[\t\n]/; | ||
| # print "name='$name' --> orgid='$orgid'\n"; | ||
| $name_to_orgid{$name} = $orgid; | ||
| } | ||
| close(F); | ||
|
|
||
| open(F, "ukid-to-name.txt") || die "could not open ukid-to-name map"; | ||
| while (<F>) { | ||
| my ($ukid, $name) = split /[\t\n]/; | ||
| # print "ukid='$ukid' --> name='$name'\n"; | ||
| if (defined $name_to_orgid{$name}) { | ||
| # print " --> orgid='$name_to_orgid{$name}'\n" | ||
| my $orgid = $name_to_orgid{$name}; | ||
| $command = "perl -i patch.pl $orgid entities/$ukid.xml"; | ||
| print "$ukid --> $orgid $command\n"; | ||
| system($command); | ||
| } else { | ||
| die "'$name' unmapped"; | ||
| # print " --> undefined\n"; | ||
| } | ||
| } | ||
| close(F); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <xsl:stylesheet version="1.0" | ||
| xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | ||
| xmlns:members="http://ukfederation.org.uk/2007/01/members" | ||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
|
|
||
| <xsl:output method="text" encoding="UTF-8"/> | ||
|
|
||
| <xsl:template match="members:Member"> | ||
| <xsl:value-of select="@ID"/> | ||
| <xsl:text>	</xsl:text> | ||
| <xsl:value-of select="members:Name"/> | ||
| <xsl:text> </xsl:text> | ||
| </xsl:template> | ||
|
|
||
| <xsl:template match="text()"> | ||
| <!-- do nothing --> | ||
| </xsl:template> | ||
| </xsl:stylesheet> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <xsl:stylesheet version="1.0" | ||
| xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | ||
| xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata" | ||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
|
|
||
| <xsl:output method="text" encoding="UTF-8"/> | ||
|
|
||
| <xsl:template match="md:EntityDescriptor"> | ||
| <xsl:value-of select="@ID"/> | ||
| <xsl:text>	</xsl:text> | ||
| <xsl:value-of select="md:Organization/md:OrganizationName"/> | ||
| <xsl:text> </xsl:text> | ||
| </xsl:template> | ||
|
|
||
| <xsl:template match="text()"> | ||
| <!-- do nothing --> | ||
| </xsl:template> | ||
| </xsl:stylesheet> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| #!/usr/bin/env perl -W | ||
|
|
||
| my $orgID = shift @ARGV; | ||
|
|
||
| while (<>) { | ||
| if (/UKFederationMember/ && !/orgID/) { | ||
| s/UKFederationMember/UKFederationMember orgID="$orgID"/; | ||
| } | ||
| print $_; | ||
| } |