summaryrefslogtreecommitdiff
path: root/metadata/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'metadata/scripts')
-rwxr-xr-xmetadata/scripts/get-metadata.sh62
1 files changed, 35 insertions, 27 deletions
diff --git a/metadata/scripts/get-metadata.sh b/metadata/scripts/get-metadata.sh
index 095f391e..13148a03 100755
--- a/metadata/scripts/get-metadata.sh
+++ b/metadata/scripts/get-metadata.sh
@@ -13,7 +13,9 @@ metadataurl=$1
if [ -z "$metadataurl" ] ; then
cat <<EOF
Usage: `basename $0` <metadataurl>
-Ex: `basename $0` https://shibsp.mysite.com/Shibboleth.sso/Metadata
+Ex: `basename $0` https://metadata.swamid.se/?showEntity=5271
+ `basename $0` 5271
+ `basename $0` https://shibsp.mysite.com/Shibboleth.sso/Metadata
`basename $0` https://shibidp.mysite.com/idp/profile/Metadata/SAML
`basename $0` some-downloaded-metadata.xml
`basename $0` reep:<entityid>
@@ -23,33 +25,39 @@ EOF
fi
xmldir=swamid-2.0
-if echo "$metadataurl" | grep -qE '^http://|^https://' ; then
- metadata=`curl -L -s -k -f "$metadataurl"`
-elif echo "$metadataurl" | grep -qE '^reep:' ; then
- id=`echo -n "$metadataurl" | sed 's/^reep://' | sha1sum | awk '{print $1}'`
- metadataurl="http://md.reep.refeds.org/entities/%7Bsha1%7D$id"
- metadata=`curl -L -s -k -f "$metadataurl"`
+if [ -s "${metadataurl}" ]; then
+ metadata=`cat "$metadataurl"`
else
- if [ -s "${metadataurl}" ]; then
- metadata=`cat "$metadataurl"`
- else
- case $metadataurl in
- [0-9][0-9]*)
- xmldir=$(curl -L -m 5 -s -k -f "https://metadata.swamid.se/?show=feed&id=${metadataurl}")
- urls="https://metadata.swamid.se/?rawXML=${metadataurl}"
- ;;
- http*)
- urls="$metadataurl"
- ;;
- *)
- urls="https://${metadataurl}/idp/shibboleth https://${metadataurl}/Shibboleth.sso/Metadata https://${metadataurl}/saml/index/sp-metadata https://${metadataurl}/saml/metadata https://${metadataurl}/federationmetadata/2007-06/federationmetadata.xml"
- ;;
- esac
- for i in ${urls}; do
- metadata=`curl -L -m 5 -s -k -f "${i}"`
- [ -n "${metadata}" ] && break
- done
- fi
+ case $metadataurl in
+ [0-9][0-9]*)
+ id=$metadataurl
+ xmldir=$(curl -L -m 5 -s -k -f "https://metadata.swamid.se/?show=feed&id=${id}")
+ urls="https://metadata.swamid.se/?rawXML=${id}"
+ ;;
+ https://metadata.swamid.se/?showEntity=*)
+ id=$(echo "$metadataurl" | sed -n 's;^https://metadata.swamid.se/?showEntity=;;p')
+ xmldir=$(curl -L -m 5 -s -k -f "https://metadata.swamid.se/?show=feed&id=${id}")
+ urls="https://metadata.swamid.se/?rawXML=${id}"
+ ;;
+ http://*|https://*)
+ urls="$metadataurl"
+ ;;
+ reep://*)
+ id=`echo -n "$metadataurl" | sed 's/^reep://' | sha1sum | awk '{print $1}'`
+ metadataurl="http://md.reep.refeds.org/entities/%7Bsha1%7D$id"
+ urls="$metadataurl"
+ ;;
+ http*)
+ urls="$metadataurl"
+ ;;
+ *)
+ urls="https://${metadataurl}/idp/shibboleth https://${metadataurl}/Shibboleth.sso/Metadata https://${metadataurl}/saml/index/sp-metadata https://${metadataurl}/saml/metadata https://${metadataurl}/federationmetadata/2007-06/federationmetadata.xml"
+ ;;
+ esac
+ for i in ${urls}; do
+ metadata=`curl -L -m 5 -s -k -f "${i}"`
+ [ -n "${metadata}" ] && break
+ done
fi
[ -n "$metadata" ] || error "Failed to fetch metadata from $metadataurl"