From 17445d4ff983597f734a8ee92d05b0a82796076c Mon Sep 17 00:00:00 2001 From: Guillaume Rousse <guillaume.rousse@renater.fr> Date: Fri, 3 Nov 2017 15:07:58 +0100 Subject: [PATCH] cosmetics --- lib/IdPAccountManager/SAMLMetadata.pm | 68 +++++++++++++-------------- 1 file changed, 32 insertions(+), 36 deletions(-) diff --git a/lib/IdPAccountManager/SAMLMetadata.pm b/lib/IdPAccountManager/SAMLMetadata.pm index e4c455b..e47cd1d 100644 --- a/lib/IdPAccountManager/SAMLMetadata.pm +++ b/lib/IdPAccountManager/SAMLMetadata.pm @@ -51,7 +51,7 @@ sub parse { foreach my $child ($EntityDescriptor->childNodes()) { - ## Ignoringnodes of type XML::LibXML::Text or XML::LibXML::Comment + ## Ignoring nodes of type XML::LibXML::Text or XML::LibXML::Comment next unless $child->nodeType() == XML_ELEMENT_NODE; if ($child->localname() eq 'IDPSSODescriptor') { @@ -87,8 +87,8 @@ sub parse { ## We also check the index to select the ACS that has the lower index my ($index_saml1, $index_saml2); foreach my $sso ( - $child->getElementsByLocalName('AssertionConsumerService')) - { + $child->getElementsByLocalName('AssertionConsumerService') + ) { ## Extracting endpoints information push @{ $data->{sp_endpoints} }, { @@ -104,42 +104,37 @@ sub parse { } foreach my $attribute ( - $child->getElementsByLocalName('RequestedAttribute')) - { + $child->getElementsByLocalName('RequestedAttribute') + ) { ## Requested attributes information - push @{ $data->{requested_attribute} }, - { - 'friendly_name' => $attribute->getAttribute('FriendlyName'), - 'name' => $attribute->getAttribute('Name'), - 'is_required' => _boolean2integer( + push @{ $data->{requested_attribute} }, { + friendly_name => $attribute->getAttribute('FriendlyName'), + name => $attribute->getAttribute('Name'), + is_required => _boolean2integer( $attribute->getAttribute('isRequired') ) - }; + }; } } elsif ($child->localname() eq 'Extensions') { foreach my $registrationinfo ( - $child->getElementsByLocalName('RegistrationInfo')) - { + $child->getElementsByLocalName('RegistrationInfo') + ) { - $data->{registration_info} - {registration_authority} = + $data->{registration_info}->{registration_authority} = $registrationinfo->getAttribute('registrationAuthority'); - $data->{registration_info} - {registration_instant} = + $data->{registration_info}->{registration_instant} = $registrationinfo->getAttribute('registrationInstant'); foreach my $policy ( $registrationinfo->getElementsByLocalName( 'RegistrationPolicy') - ) - { + ) { my $lang = $policy->getAttribute('lang'); - if ($lang && $lang eq 'en') { - $data->{registration_info}->{registration_policy} = - $policy->textContent(); - } + next unless $lang && $lang eq 'en'; + $data->{registration_info}->{registration_policy} = + $policy->textContent(); } } } elsif ($child->localname() eq 'ContactPerson') { @@ -155,9 +150,9 @@ sub parse { } } - foreach - my $displayname ($child->getElementsByLocalName('DisplayName')) - { + foreach my $displayname ( + $child->getElementsByLocalName('DisplayName') + ) { $data->{display_name}->{ $displayname->getAttribute('xml:lang') } = $displayname->textContent(); @@ -173,17 +168,17 @@ sub parse { } - foreach - my $description ($child->getElementsByLocalName('Description')) - { + foreach my $description ( + $child->getElementsByLocalName('Description') + ) { $data->{description}->{ $description->getAttribute('xml:lang') } = $description->textContent(); } - foreach - my $contact ($child->getElementsByLocalName('ContactPerson')) - { + foreach my $contact ( + $child->getElementsByLocalName('ContactPerson') + ) { my %contact_details; $contact_details{type} = @@ -196,14 +191,15 @@ sub parse { } foreach my $sso ( - $child->getElementsByLocalName('OrganizationDisplayName')) - { + $child->getElementsByLocalName('OrganizationDisplayName') + ) { $data->{organization} = $sso->textContent(); } ## Getting X.509 certificates - foreach my $cert ($child->getElementsByLocalName('X509Certificate')) - { + foreach my $cert ( + $child->getElementsByLocalName('X509Certificate') + ) { $data->{certificate} = $cert->textContent(); } } -- GitLab