View Source SmeeView.EntityAttributes (SmeeView v0.2.1)

This module can extracts the <mdattr:EntityAttributes> elements in entity metadata as "aspect" structs, and then process and filter the results.

Aspects can be extracted with three functions:

  • Views, via view/3 are lists of aspects
  • Prisms, via prism/3 are maps of entity IDs to views
  • There is also view_one/3 which returns the first aspect found

Aspects can be extracted from Smee.Metadata structs, Smee.Entity structs, or lists of aspects, Metadata and Entity structs.

The other functions in this module are intended to be applied to collections of aspect structs - for working with individual aspects, please look at the appropriate Aspect module.

Summary

Functions

Lists the values for urn:oasis:names:tc:SAML:attribute:assurance-certification entity attributes

Returns true if any of the attributes contains the entity category

Returns true if any of the attributes indicate CoCo (Code of Conduct) status

Returns true if the aspects contain the specified attribute name

Returns true if the aspects contain the specified attribute type/name and value

Lists all values for entity category (http://macedir.org/entity-category) entity attributes

Returns true if any of the attributes indicate Hide From Discovery status

Removes any non-IdP aspects from a list (view) or map (prism)

Returns a list of all attribute names.

Returns a map of Elixir.SmeeView.Aspects.EntityAttribute aspect structs extracted from the input data, with entity IDs as keys.

Returns true if any of the attributes indicate Research And Scholarship status

Lists all nameid types marked as required with the urn:oasis:names:tc:SAML:profiles:subject-id:req attribute

Returns true if any of the attributes indicate SIRTFI status

Removes any non-SP aspects from a list (view) or map (prism)

Returns true if any of the attributes show support for the specified entity category

Lists all values for entity category support attributes (http://macedir.org/entity-category-support)

Returns a list of all attribute values - every value for every attribute.

Lists all attribute values for the specified attribute name

Returns a list of Elixir.SmeeView.Aspects.EntityAttribute aspect structs extracted from the input data.

Returns a single Elixir.SmeeView.Aspects.EntityAttribute aspect struct extracted from one record in the input data.

Functions

Link to this function

assurance_certifications(aspects)

View Source
@spec assurance_certifications(aspects :: list() | map()) :: list() | map()

Lists the values for urn:oasis:names:tc:SAML:attribute:assurance-certification entity attributes

SmeeView.EntityAttributes.assurance_certifications(ent_attrs)
# => ["http://refeds.org/sirtfi", "http://www.swamid.se/policy/assurance/al1",
# "https://refeds.org/sirtfi2"]
Link to this function

category?(aspects, category)

View Source
@spec category?(aspects :: list() | map(), category :: binary()) :: boolean() | map()

Returns true if any of the attributes contains the entity category

SmeeView.EntityAttributes.category?(ent_attrs, "https://myacademicid.org/entity-categories/esi")
# => false
@spec coco?(aspects :: list() | map()) :: boolean() | map()

Returns true if any of the attributes indicate CoCo (Code of Conduct) status

SmeeView.EntityAttributes.coco?(ent_attrs)
# => true
@spec contain?(aspects :: list() | map(), name :: binary()) :: boolean() | map()

Returns true if the aspects contain the specified attribute name

SmeeView.EntityAttributes.contain?(ent_attrs, "urn:oasis:names:tc:SAML:attribute:assurance-certification")
# => true

Link to this function

contain?(aspects, name, value)

View Source
@spec contain?(aspects :: list() | map(), name :: binary(), value :: binary()) ::
  boolean() | map()

Returns true if the aspects contain the specified attribute type/name and value

SmeeView.EntityAttributes.contain?(ent_attrs, "urn:oasis:names:tc:SAML:attribute:assurance-certification", "https://refeds.org/sirtfi2")
# => true
Link to this function

entity_categories(aspects)

View Source
@spec entity_categories(aspects :: list() | map()) :: list() | map()

Lists all values for entity category (http://macedir.org/entity-category) entity attributes

SmeeView.EntityAttributes.entity_categories(ent_attrs)
# => ["http://aai.dfn.de/category/bwidm-member",
# "http://eduid.cz/uri/idp-group/university",
# "http://refeds.org/category/hide-from-discovery",
# "http://refeds.org/category/research-and-scholarship",
# "http://www.geant.net/uri/dataprotection-code-of-conduct/v1",
# "https://edugate.heanet.ie/rr3/p/page/HEAnetInternalEC",
# "https://federation.renater.fr/category/collaboratif",
# "https://myacademicid.org/entity-categories/esi",
# "https://refeds.org/category/anonymous",
# "https://refeds.org/category/code-of-conduct/v2",
# "https://refeds.org/category/hide-from-discovery",
# "https://refeds.org/category/personalized",
# ... ]
@spec hide?(aspects :: list() | map()) :: boolean() | map()

Returns true if any of the attributes indicate Hide From Discovery status

SmeeView.EntityAttributes.hide?(ent_attrs)
# => true
@spec idp_filter(aspects :: map() | list()) :: map() | list()

Removes any non-IdP aspects from a list (view) or map (prism)

EntityAttributes.idp_filter(view)
# => []
@spec names(aspects :: list() | map()) :: list() | map()

Returns a list of all attribute names.

The results are sorted and each value is unique.

SmeeView.EntityAttributes.names(ent_attrs)
# => ["http://kafe.kreonet.net/jurisdiction", "http://macedir.org/entity-category",
# "http://macedir.org/entity-category-support",
# "https://federation.renater.fr/member-of",
# "urn:oasis:names:tc:SAML:attribute:assurance-certification",
# "urn:oasis:names:tc:SAML:profiles:subject-id:req",
# "urn:oid:2.16.756.1.2.5.1.1.4", "urn:oid:2.16.756.1.2.5.1.1.5"]
Link to this function

prism(various, role \\ :all, options \\ [])

View Source
@spec prism(
  various :: Smee.Entity.t() | Smee.Metadata.t() | list(),
  role :: atom(),
  options :: keyword()
) :: map()

Returns a map of Elixir.SmeeView.Aspects.EntityAttribute aspect structs extracted from the input data, with entity IDs as keys.

Input data can be a Smee.Entity or Smee.Metadata struct, or a list containing Smee.Entity and/or Smee.Metadata structs. Only appropriate aspect records will be returned.

prism/3 is useful for extracting specific types of aspects from lists of entity records, or metadata. If you are only interested in one aspect from a single Smee.Entity struct then you should probably use view/3 instead.

The optional role parameter will optimize the results to only search for either :idp or :sp aspects. The default is :all.

EntityAttributes.prism(entity)
# => %{"https://example.com/shibboleth" =>  [%Elixir.SmeeView.Aspects.EntityAttribute{}, %Elixir.SmeeView.Aspects.EntityAttribute{},]}
@spec ras?(aspects :: list() | map()) :: boolean() | map()

Returns true if any of the attributes indicate Research And Scholarship status

SmeeView.EntityAttributes.ras?(ent_attrs)
# => true
Link to this function

required_subject_ids(aspects)

View Source
@spec required_subject_ids(aspects :: list() | map()) :: list() | map()

Lists all nameid types marked as required with the urn:oasis:names:tc:SAML:profiles:subject-id:req attribute

SmeeView.EntityAttributes.required_subject_ids(ent_attrs)
# => ["pairwise-id", "subject-id"]
@spec sirtfi?(aspects :: list() | map()) :: boolean() | map()

Returns true if any of the attributes indicate SIRTFI status

SmeeView.EntityAttributes.sirtfi?(ent_attrs)
# => false
@spec sp_filter(aspects :: map() | list()) :: map() | list()

Removes any non-SP aspects from a list (view) or map (prism)

EntityAttributes.sp_filter(view)
# => []
Link to this function

supports?(aspects, category)

View Source
@spec supports?(aspects :: list() | map(), category :: binary()) :: boolean() | map()

Returns true if any of the attributes show support for the specified entity category

SmeeView.EntityAttributes.supports?(ent_attrs, "https://refeds.org/category/anonymous")
# => false
Link to this function

supports_entity_categories(aspects)

View Source
@spec supports_entity_categories(aspects :: list() | map()) :: list() | map()

Lists all values for entity category support attributes (http://macedir.org/entity-category-support)

SmeeView.EntityAttributes.supports_entity_categories(ent_attrs)
# => ["http://clarin.eu/category/clarin-member",
# "http://refeds.org/category/research-and-scholarship",
# "http://www.geant.net/uri/dataprotection-code-of-conduct/v1",
# "https://idp.lit.ie/saml2", "https://login.dcu.ie",
# "https://myacademicid.org/entity-categories/esi",
# "https://refeds.org/category/anonymous",
# "https://refeds.org/category/code-of-conduct/v2",
# "https://refeds.org/category/personalized", "https://refeds.org/sirtfi"]
@spec values(aspects :: list() | map()) :: list() | map()

Returns a list of all attribute values - every value for every attribute.

The results are sorted and each value is unique.

SmeeView.EntityAttributes.values(ent_attrs)
# => ["KR", "any", "hospital",  "http://aai.dfn.de/category/bwidm-member",
# "http://aai.dfn.de/category/campus-lsa-member",
# "http://clarin.eu/category/clarin-member", "http://eduid.cz/uri/group/mefanet",
# "http://refeds.org/category/hide-from-discovery",
# "http://refeds.org/category/research-and-scholarship", ...]
Link to this function

values_for(aspects, name)

View Source
@spec values_for(aspects :: list() | map(), name :: binary()) :: list() | map()

Lists all attribute values for the specified attribute name

The results are sorted and each value is unique.

SmeeView.EntityAttributes.values_for(ent_attrs, "urn:oasis:names:tc:SAML:attribute:assurance-certification")
# => ["http://refeds.org/sirtfi", "http://www.swamid.se/policy/assurance/al1",
# "https://refeds.org/sirtfi", "https://refeds.org/sirtfi2"]
Link to this function

view(list, role \\ :all, options \\ [])

View Source
@spec view(
  list :: Smee.Entity.t() | Smee.Metadata.t() | list(),
  role :: atom(),
  options :: keyword()
) ::
  list()

Returns a list of Elixir.SmeeView.Aspects.EntityAttribute aspect structs extracted from the input data.

Input data can be a Smee.Entity or Smee.Metadata struct, or a list containing Smee.Entity, Smee.Metadata or any aspects. Only appropriate aspect records will be returned.

view/3 is useful for extracting specific types of aspects from one Entity, but because it has no entity ID information it's often not the best choice for handling Metadata. When extracting information from entire metadata it's often better to use prism/3 which returns the same data in a map, associated with each entity's ID.

The optional role parameter will optimize the results to only search for either :idp or :sp aspects. The default is :all.

EntityAttributes.view(entity)
# => [%Elixir.SmeeView.Aspects.EntityAttribute{}, %Elixir.SmeeView.Aspects.EntityAttribute{}]
Link to this function

view_one(smee_data, role \\ :all, options \\ [])

View Source
@spec view_one(
  list :: Smee.Entity.t() | Smee.Metadata.t() | list(),
  role :: atom(),
  options :: keyword()
) :: SmeeView.Aspects.EntityAttribute.t() | nil

Returns a single Elixir.SmeeView.Aspects.EntityAttribute aspect struct extracted from one record in the input data.

Input data can be a Smee.Entity or Smee.Metadata struct, or a list containing Smee.Entity, Smee.Metadata or any aspects.

Only one entity will be processed and then only one aspect will be returned. If you pass one Entity struct as the input, it will be that entity (obviously). If you pass metadata structs or lists one entity will be chosen at random. The first suitable entity will be returned.

view_one/3 is intended for use with a single entity record and aspects like SmeeView.Aspect.Entity, SmeeView.Aspect.SP' orSmeeView.Aspect.Organization' but will work with any aspect.

The optional role parameter will optimize the results to only search for either :idp or :sp aspects. The default is :all.

EntityAttributes.view_one(entity)
# => %Elixir.SmeeView.Aspects.EntityAttribute{}