Skip to content
Snippets Groups Projects
Commit 372350a0 authored by Guillaume ROUSSE's avatar Guillaume ROUSSE
Browse files

shorter variable names

parent 41ea869a
Branches
Tags
No related merge requests found
...@@ -39,23 +39,23 @@ sub new { ...@@ -39,23 +39,23 @@ sub new {
sub parse { sub parse {
my ($self, %args) = @_; my ($self, %args) = @_;
my @extracted_array; my @array;
foreach my $EntityDescriptor ( foreach my $EntityDescriptor (
@{ $self->{doc}->getElementsByLocalName('EntityDescriptor') }) @{ $self->{doc}->getElementsByLocalName('EntityDescriptor') })
{ {
my $extracted_data = {}; my $data = {};
if ($EntityDescriptor->hasAttributes()) { if ($EntityDescriptor->hasAttributes()) {
foreach my $attr ($EntityDescriptor->getAttribute('entityID')) { foreach my $attr ($EntityDescriptor->getAttribute('entityID')) {
$extracted_data->{entityid} = $attr; $data->{entityid} = $attr;
} }
} }
next if ($args{entity_id} next if ($args{entity_id}
&& ($args{entity_id} ne $extracted_data->{entityid})); && ($args{entity_id} ne $data->{entityid}));
$extracted_data->{xml_md} = $data->{xml_md} =
IdPAccountManager::Tools::escape_xml($EntityDescriptor->toString()); IdPAccountManager::Tools::escape_xml($EntityDescriptor->toString());
foreach my $child ($EntityDescriptor->childNodes()) { foreach my $child ($EntityDescriptor->childNodes()) {
...@@ -65,7 +65,7 @@ sub parse { ...@@ -65,7 +65,7 @@ sub parse {
if ($child->nodeName =~ /IDPSSODescriptor$/) { if ($child->nodeName =~ /IDPSSODescriptor$/) {
$extracted_data->{type} = 'idp'; $data->{type} = 'idp';
foreach my $sso ( foreach my $sso (
$child->getElementsByLocalName('SingleSignOnService')) $child->getElementsByLocalName('SingleSignOnService'))
...@@ -75,7 +75,7 @@ sub parse { ...@@ -75,7 +75,7 @@ sub parse {
#next unless ($sso->getAttribute('Binding') && defined $supported_saml_bindings{$sso->getAttribute('Binding')}); #next unless ($sso->getAttribute('Binding') && defined $supported_saml_bindings{$sso->getAttribute('Binding')});
## On extrait les infos sur les endpoints ## On extrait les infos sur les endpoints
push @{ $extracted_data->{idp_endpoints} }, { push @{ $data->{idp_endpoints} }, {
type => 'SingleSignOnService', type => 'SingleSignOnService',
binding => $sso->getAttribute('Binding'), binding => $sso->getAttribute('Binding'),
location => $sso->getAttribute('Location'), location => $sso->getAttribute('Location'),
...@@ -85,12 +85,12 @@ sub parse { ...@@ -85,12 +85,12 @@ sub parse {
## Getting domains declared for scoped attributes ## Getting domains declared for scoped attributes
foreach my $scope ($child->getElementsByLocalName('Scope')) { foreach my $scope ($child->getElementsByLocalName('Scope')) {
push @{ $extracted_data->{domain} }, $scope->textContent(); push @{ $data->{domain} }, $scope->textContent();
} }
} elsif ($child->nodeName =~ /SPSSODescriptor$/) { } elsif ($child->nodeName =~ /SPSSODescriptor$/) {
$extracted_data->{type} = 'sp'; $data->{type} = 'sp';
## We check the Binding of the ACS that should match "urn:oasis:names:tc:SAML:1.0:profiles:browser-post" ## We check the Binding of the ACS that should match "urn:oasis:names:tc:SAML:1.0:profiles:browser-post"
## We also check the index to select the ACS that has the lower index ## We also check the index to select the ACS that has the lower index
...@@ -100,7 +100,7 @@ sub parse { ...@@ -100,7 +100,7 @@ sub parse {
{ {
## Extracting endpoints information ## Extracting endpoints information
push @{ $extracted_data->{sp_endpoints} }, { push @{ $data->{sp_endpoints} }, {
type => 'AssertionConsumerService', type => 'AssertionConsumerService',
binding => $sso->getAttribute('Binding'), binding => $sso->getAttribute('Binding'),
location => $sso->getAttribute('Location'), location => $sso->getAttribute('Location'),
...@@ -117,7 +117,7 @@ sub parse { ...@@ -117,7 +117,7 @@ sub parse {
{ {
## Requested attributes information ## Requested attributes information
push @{ $extracted_data->{requested_attribute} }, push @{ $data->{requested_attribute} },
{ {
'friendly_name' => 'friendly_name' =>
IdPAccountManager::Tools::encode_utf8( IdPAccountManager::Tools::encode_utf8(
...@@ -139,10 +139,10 @@ sub parse { ...@@ -139,10 +139,10 @@ sub parse {
$child->getElementsByLocalName('RegistrationInfo')) $child->getElementsByLocalName('RegistrationInfo'))
{ {
$extracted_data->{registration_info} $data->{registration_info}
{registration_authority} = {registration_authority} =
$registrationinfo->getAttribute('registrationAuthority'); $registrationinfo->getAttribute('registrationAuthority');
$extracted_data->{registration_info} $data->{registration_info}
{registration_instant} = {registration_instant} =
$registrationinfo->getAttribute('registrationInstant'); $registrationinfo->getAttribute('registrationInstant');
foreach my $registrationpolicy ( foreach my $registrationpolicy (
...@@ -151,7 +151,7 @@ sub parse { ...@@ -151,7 +151,7 @@ sub parse {
) )
{ {
if ($registrationpolicy->getAttribute('lang') eq 'en') { if ($registrationpolicy->getAttribute('lang') eq 'en') {
$extracted_data->{registration_info} $data->{registration_info}
{registration_policy} = {registration_policy} =
IdPAccountManager::Tools::encode_utf8( IdPAccountManager::Tools::encode_utf8(
$registrationpolicy->textContent()); $registrationpolicy->textContent());
...@@ -167,7 +167,7 @@ sub parse { ...@@ -167,7 +167,7 @@ sub parse {
IdPAccountManager::Tools::encode_utf8( IdPAccountManager::Tools::encode_utf8(
$contact_child->textContent()); $contact_child->textContent());
} }
push @{ $extracted_data->{contacts} }, \%contact_details; push @{ $data->{contacts} }, \%contact_details;
} }
} }
...@@ -175,7 +175,7 @@ sub parse { ...@@ -175,7 +175,7 @@ sub parse {
my $displayname ($child->getElementsByLocalName('DisplayName')) my $displayname ($child->getElementsByLocalName('DisplayName'))
{ {
$extracted_data->{display_name} $data->{display_name}
{ $displayname->getAttribute('xml:lang') } = { $displayname->getAttribute('xml:lang') } =
IdPAccountManager::Tools::encode_utf8( IdPAccountManager::Tools::encode_utf8(
$displayname->textContent()); $displayname->textContent());
...@@ -183,10 +183,10 @@ sub parse { ...@@ -183,10 +183,10 @@ sub parse {
## Set a default displayName in case no English version is provided ## Set a default displayName in case no English version is provided
## However there is no way to determine the native displayName ## However there is no way to determine the native displayName
## We take the first one as default ## We take the first one as default
if ( !$extracted_data->{default_display_name} if ( !$data->{default_display_name}
|| $displayname->getAttribute('xml:lang')) || $displayname->getAttribute('xml:lang'))
{ {
$extracted_data->{default_display_name} = $data->{default_display_name} =
IdPAccountManager::Tools::encode_utf8( IdPAccountManager::Tools::encode_utf8(
$displayname->textContent()); $displayname->textContent());
} }
...@@ -197,7 +197,7 @@ sub parse { ...@@ -197,7 +197,7 @@ sub parse {
my $description ($child->getElementsByLocalName('Description')) my $description ($child->getElementsByLocalName('Description'))
{ {
$extracted_data->{description} $data->{description}
{ $description->getAttribute('xml:lang') } = { $description->getAttribute('xml:lang') } =
IdPAccountManager::Tools::encode_utf8( IdPAccountManager::Tools::encode_utf8(
$description->textContent()); $description->textContent());
...@@ -215,20 +215,20 @@ sub parse { ...@@ -215,20 +215,20 @@ sub parse {
IdPAccountManager::Tools::encode_utf8( IdPAccountManager::Tools::encode_utf8(
$contact_child->textContent()); $contact_child->textContent());
} }
push @{ $extracted_data->{contacts} }, \%contact_details; push @{ $data->{contacts} }, \%contact_details;
} }
foreach my $sso ( foreach my $sso (
$child->getElementsByLocalName('OrganizationDisplayName')) $child->getElementsByLocalName('OrganizationDisplayName'))
{ {
$extracted_data->{organization} = $data->{organization} =
IdPAccountManager::Tools::encode_utf8($sso->textContent()); IdPAccountManager::Tools::encode_utf8($sso->textContent());
} }
## Getting X.509 certificates ## Getting X.509 certificates
foreach my $cert ($child->getElementsByLocalName('X509Certificate')) foreach my $cert ($child->getElementsByLocalName('X509Certificate'))
{ {
$extracted_data->{certificate} = $data->{certificate} =
IdPAccountManager::Tools::encode_utf8($cert->textContent()); IdPAccountManager::Tools::encode_utf8($cert->textContent());
} }
} }
...@@ -236,17 +236,17 @@ sub parse { ...@@ -236,17 +236,17 @@ sub parse {
## Filter entities based on type ## Filter entities based on type
next next
if (defined $args{filter_entity_type} if (defined $args{filter_entity_type}
&& ($args{filter_entity_type} ne $extracted_data->{type})); && ($args{filter_entity_type} ne $data->{type}));
## Merge domains in a single string ## Merge domains in a single string
my $domains = join(',', @{ $extracted_data->{domain} }) my $domains = join(',', @{ $data->{domain} })
if ($extracted_data->{domain}); if ($data->{domain});
$extracted_data->{domain} = $domains; $data->{domain} = $domains;
push @extracted_array, $extracted_data; push @array, $data;
} }
return \@extracted_array; return \@array;
} }
## Dumps the SAML metadata content ## Dumps the SAML metadata content
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment