Powered by AppSignal & Oban Pro
Would you like to see your link here? Contact us

Smee Workbook

notebooks/smee.livemd

Smee Workbook

Mix.install([{:smee, ">= 0.4.1"}, {:rambo, "~> 0.3.4"}])
alias Smee.{Metadata, Entity, Source, MDQ, Filter, Sigil, Publish, Transform, Extract, Fetch}

Requirements - Please Read!

Backend tools Please note: Smee does not do all processing itself using Elixir - it sometimes cheats (OK, it often cheats) by sending data to external programs for processing. At the moment it requires the following commandline utilities:

  • xmlsec1
  • xmllint
  • xsltproc

On Debian: sudo apt-get install xmlsec1 libxml2-utils xsltproc On RedHat: sudo yum install xmlsec1 libxml2 libxslt On Macs: brew install xmlsec1 libxml2 libxslt

Grabbing some metadata with Smee

This may take awhile, it’s a large file, but the download will be cached making later runs much quicker

metadata =
  Smee.source("http://metadata.ukfederation.org.uk/ukfederation-metadata.xml")
  |> Smee.fetch!()

Viewing metadata XML

Assuming you’ve downloaded the metadata into a variable called metadata

  Smee.Metadata.xml(metadata)
  |> IO.puts()

Using MDQ

This should be very quick, as only one entity record is downloaded

cern_idp =
  MDQ.source("http://mdq.ukfederation.org.uk/")
  |> MDQ.lookup!("https://cern.ch/login")

List the EntityIDs of all IdPs in a federation

An example of streaming entities from a Metadata struct and passing the stream through filters


"http://metadata.ukfederation.org.uk/ukfederation-metadata.xml"
|> Source.new()
|> Fetch.remote!()
|> Metadata.stream_entities()
|> Filter.idp()
|> Stream.map(fn e -> e.uri end)
|> Enum.to_list()

Create an aggregate that only contains SPs with SIRTFI, that were registered over the previous 12 months

Another contrived streaming and filtering example, this time to build a new metadata file.

alias Smee.{Source, Fetch, Filter, Metadata, Publish}

"http://metadata.ukfederation.org.uk/ukfederation-metadata.xml"
|> Source.new()
|> Fetch.remote!()
|> Metadata.stream_entities()
|> Filter.days(365)
|> Filter.sp()
|> Filter.assurance("https://refeds.org/sirtfi")
|> Publish.xml()
|> IO.puts()