| 1 | package Mojo::SAML::Document::Organization; | ||
| 2 | |||
| 3 | use Mojo::Base 'Mojo::SAML::Document'; | ||
| 4 | |||
| 5 | has [qw/display_names names urls/] => sub { [] }; | ||
| 6 | |||
| 7 | has template => sub { shift->build_template(<<'XML') }; | ||
| 8 | <Organization xmlns="urn:oasis:names:tc:SAML:2.0:metadata"> | ||
| 9 | % for my $name (@{ $self->names }) { | ||
| 10 | <OrganizationName xml:lang="en"><%= $name %></OrganizationName> | ||
| 11 | % } | ||
| 12 | % for my $dn (@{ $self->display_names }) { | ||
| 13 | <OrganizationDisplayName xml:lang="en"><%= $dn %></OrganizationDisplayName> | ||
| 14 | % } | ||
| 15 | % for my $url(@{ $self->urls }) { | ||
| 16 | <OrganizationURL xml:lang="en"><%= $url %></OrganizationURL> | ||
| 17 | % } | ||
| 18 | </Organization> | ||
| 19 | XML | ||
| 20 | |||
| 21 | sub before_render { | ||
| 22 | my $self = shift; | ||
| 23 | for my $method (qw/display_names names urls/) { | ||
| 24 | Carp::croak "$method cannot be empty" unless @{$self->$method}; | ||
| 25 | } | ||
| 26 | } | ||
| 27 | |||
| 28 | 1; | ||
| 29 | |||
| 30 | =head1 NAME | ||
| 31 | |||
| 32 | Mojo::SAML::Document::Organization | ||
| 33 | |||
| 34 | =head1 DESCRIPTION | ||
| 35 | |||
| 36 | Represents an Organization SAML metadata tag | ||
| 37 | |||
| 38 | =head1 ATTRIBUTES | ||
| 39 | |||
| 40 | L<Mojo::SAML::Document::Organization> inherits all attributes from L<Mojo::SAML::Document> and implements the following new ones. | ||
| 41 | |||
| 42 | =head2 display_names | ||
| 43 | |||
| 44 | An array reference containing the display names (human readable) of the organization. | ||
| 45 | Must not be empty at render time. | ||
| 46 | |||
| 47 | =head2 names | ||
| 48 | |||
| 49 | An array reference containing the machine readable name of the organization. | ||
| 50 | Must not be empty at render time. | ||
| 51 | |||
| 52 | =head2 template | ||
| 53 | |||
| 54 | A template specific to the document type. | ||
| 55 | |||
| 56 | =head2 urls | ||
| 57 | |||
| 58 | An array reference containing the urls of the organization. | ||
| 59 | Must not be empty at render time. | ||
| 60 | |||
| 61 | =head1 METHODS | ||
| 62 | |||
| 63 | L<Mojo::SAML::Document::Organization> inherits all methods from L<Mojo::SAML::Document> and implements the following new ones. | ||
| 64 | |||
| 65 | =head2 before_render | ||
| 66 | |||
| 67 | Enforces that L</display_names>, L</names>, and L</urls> are not empty at render time. | ||
| 68 |