NAME
Mojo::SAML::Entity - Extract information from an entity
SYNOPSIS
DESCRIPTION
Mojo::SAML::Entity is a convenience class for extracting information from Entity entity descriptor metadata. This module is especially fragile and will change as its usefulness is assessed and improved.
ATTRIBUTES
Mojo::SAML::Entity inherits all of the attributes from Mojo::Base and implements the following new ones.
entity_id
The entity id (entityID
) of the entity to be inspected. If the "metadata" contains only one entity descriptor, it will default to that id. Otherwise, it must be specified manually otherwise it will throw an exception.
metadata
The metadata of the entity, as a Mojo::DOM object. Note that there are several methods which can be used to populate this values. Otherwise accessing it without it being set will throw an exception.
role_type
Required. The role that this enitty will be used for. Special cases IdP
or SP
relate to SAML metadata tags. Other values relate to protocolSupportEnumeration
RoleDescriptor values.
ua
An instance of Mojo::UserAgent used to fetch remote metadata.
METHODS
Mojo::SAML::Entity inherits all of the methods from Mojo::Base and implements the following new ones.
certificate_for
my $cert = $entity->certificate_for($use);
Returns a Crypt::OpenSSL::X509
instance for the "entity" and "role" and a given use. Note that a certificate without a use will match any use.
default_id_format
my $format = $entity->default_id_format;
Returns the first nameid format.
entity
my $entity = $entity->entity;
Get the Mojo::DOM instance for the entity identified by the "entity_id". This is used by many other methods for picking the entity information.
from
my $entity = Mojo::SAML::Entity->new->from($input);
Load "metadata" from a generic input. Delegates to "from_file", "from_url", and "from_xml" depending on the input.
from_file
my $entity = Mojo::SAML::Entity->new->from_file($path);
Load "metadata" from a given file. Return the instance, designed to chain with new
.
from_url
my $entity = Mojo::SAML::Entity->new->from_url($url);
Load "metadata" from a given url using the "ua". Return the instance, designed to chain with new
.
from_xml
my $entity = Mojo::SAML::Entity->new->from_xml($xml);
Load "metadata" from a given string. Return the instance, designed to chain with new
.
location_for
my $url = $entity->location_for($service, $binding);
Extract a Mojo::URL for the "entity" and "role"'s given service and binding. The binding may be shortend in a manner that can be fully qualified via "binding" in Mojo::SAML::Names.
name_id_format
$format = $entity->name_id_format($format);
Return the nameid format for the "entity" if the nameid format given is accepted. The format may be shortend in a manner that can be fully qualified via "nameid_format" in Mojo::SAML::Names.
public_key_for
my $pub = $entity->public_key_for($use);
A wrapper for "certificate_for" which returns a Crypt::OpenSSL::RSA public key instance for the certificate.
role
Get the Mojo::DOM instance for the element identified by the "role_type". This is used by many other methods for picking the role information.
verify_signature
my $verified = $entity->verify_signature;
my $verified = $entity->verify_signature($pub);
Verify the metadata file's signature, either against itself or against a passed in public key. Returns undef if no signature is found or a boolean signifying verification.