Skip to content

Instantly share code, notes, and snippets.

@trscavo
trscavo / construct_mdq_url
Last active August 29, 2015 14:05
Bash function to construct a request URL per the Metadata Query Protocol specification
# Construct a request URL per the MDQ Protocol specification
# See: https://github.com/iay/md-query
# To construct a reference to ALL entities served by the
# metadata query server, simply omit the second argument
construct_mdq_url () {
# construct_mdq_url <base_url> <url_encoded_id>
# make sure there are one or two command-line arguments
if [ $# -lt 1 -o $# -gt 2 ]; then
echo "ERROR: $FUNCNAME: incorrect number of arguments: $# (1 or 2 required)" >&2
@trscavo
trscavo / md_inspect.sh
Last active April 12, 2024 07:25
Bash script to inspect a SAML metadata file
#!/bin/bash
###########################################################
# Inspect a SAML metadata file and report its characteristics.
#
# Usage: md_inspect.sh [-vs] [MD_FILE]
#
# Optionally takes the path to the metadata file as a command-line
# parameter. If none is given, takes its input from stdin instead.
#
@trscavo
trscavo / md_query.sh
Last active November 15, 2016 15:58
Bash script to fetch SAML metadata via the Metadata Query Protocol
#!/bin/bash
# DEPRECATED: Use mdq_url.sh instead
###########################################################
# Fetch SAML metadata via the Metadata Query Protocol
#
# usage: md_query.sh [-tvq] [IDENTIFIER]
#
# where the -t option simply outputs the computed request URL (without
@trscavo
trscavo / filter_mdattrs.sh
Last active August 29, 2015 14:07
Bash script to filter the entity attributes from a SAML metadata file
#!/bin/bash
#####################################################################
# Inspect a SAML metadata file, iterate over the entity descriptors
# in the file, and pass each entity descriptor through a filter that
# produces a list of entity attributes in metadata.
#
# Usage: filter_mdattrs.sh [-v] [MD_FILE]
#
# Optionally takes the path to the metadata file as a command-line
@trscavo
trscavo / cget.sh
Last active January 6, 2020 22:54
Shell script to retrieve a web resource via HTTP Conditional GET
#!/bin/bash
#####################################################################
# Retrieve a web resource via HTTP Conditional GET [RFC 7232] and
# output the resource on stdout. Cache the web resource and consult
# the cache on subsequent requests for the same resource. By default,
# return the cached resource (if it exists) if and only if the web
# server responds with 304 Not Modified.
#
# Usage: cget.sh [-vfcH] URL
@trscavo
trscavo / mdq_url.sh
Created July 7, 2015 16:51
Compute a request URL for the Metadata Query Protocol
#!/bin/bash
###########################################################
# Compute the request URL for the given IDENTIFIER as specified by
# the Metadata Query Protocol
#
# usage: mdq_url.sh [-vq] IDENTIFIER
#
# The -v option causes the script to produce verbose output while
# the -q option causes the script to be silent. The options are
@trscavo
trscavo / eids.sh
Created July 7, 2015 16:54
Produce a list of all entityIDs in the given SAML metadata file
#!/bin/bash
###########################################################
# Produce a list of all entityIDs in the given SAML metadata file.
#
# Usage: eids.sh [FILE]
#
# Optionally takes the path to the metadata file as a command-line
# parameter. If none is given, takes its input from stdin.
#
@trscavo
trscavo / extract_IdP_entityIDs.xsl
Last active January 5, 2016 14:01
An XSL stylesheet that extracts the entityIDs of all IdPs in a SAML 2.0 metadata file
<?xml version="1.0" encoding="UTF-8"?>
<!--
extract_IdP_entityIDs.xsl
XSL stylesheet that takes a SAML 2.0 metadata file and extracts
the IdP entityIDs as plain text.
-->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata"
@trscavo
trscavo / extract_all_entityIDs.xsl
Last active August 29, 2015 14:27
An XSL stylesheet that extracts the entityIDs of all entities in a SAML 2.0 metadata file
<?xml version="1.0" encoding="UTF-8"?>
<!--
extract_all_entityIDs.xsl
XSL stylesheet that takes a SAML 2.0 metadata file and extracts
all entityIDs (both IdP and SP) as plain text.
-->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata"
@trscavo
trscavo / extract_RandS_SP_entityIDs.xsl
Last active August 29, 2015 14:27
An XSL stylesheet that extracts the entityIDs of the SPs in a SAML 2.0 metadata file that belong to the Research & Scholarship Category
<?xml version="1.0" encoding="UTF-8"?>
<!--
extract_RandS_SP_entityIDs.xsl
XSL stylesheet that takes a SAML 2.0 metadata file and extracts
the Research & Scholarship SP entityIDs as plain text.
See: http://refeds.org/category/research-and-scholarship
-->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"