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

shorter variable names

parent 41ea869a
No related branches found
No related tags found
No related merge requests found
......@@ -39,23 +39,23 @@ sub new {
sub parse {
my ($self, %args) = @_;
my @extracted_array;
my @array;
foreach my $EntityDescriptor (
@{ $self->{doc}->getElementsByLocalName('EntityDescriptor') })
{
my $extracted_data = {};
my $data = {};
if ($EntityDescriptor->hasAttributes()) {
foreach my $attr ($EntityDescriptor->getAttribute('entityID')) {
$extracted_data->{entityid} = $attr;
$data->{entityid} = $attr;
}
}
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());
foreach my $child ($EntityDescriptor->childNodes()) {
......@@ -65,7 +65,7 @@ sub parse {
if ($child->nodeName =~ /IDPSSODescriptor$/) {
$extracted_data->{type} = 'idp';
$data->{type} = 'idp';
foreach my $sso (
$child->getElementsByLocalName('SingleSignOnService'))
......@@ -75,7 +75,7 @@ sub parse {
#next unless ($sso->getAttribute('Binding') && defined $supported_saml_bindings{$sso->getAttribute('Binding')});
## On extrait les infos sur les endpoints
push @{ $extracted_data->{idp_endpoints} }, {
push @{ $data->{idp_endpoints} }, {
type => 'SingleSignOnService',
binding => $sso->getAttribute('Binding'),
location => $sso->getAttribute('Location'),
......@@ -85,12 +85,12 @@ sub parse {
## Getting domains declared for scoped attributes
foreach my $scope ($child->getElementsByLocalName('Scope')) {
push @{ $extracted_data->{domain} }, $scope->textContent();
push @{ $data->{domain} }, $scope->textContent();
}
} 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 also check the index to select the ACS that has the lower index
......@@ -100,7 +100,7 @@ sub parse {
{
## Extracting endpoints information
push @{ $extracted_data->{sp_endpoints} }, {
push @{ $data->{sp_endpoints} }, {
type => 'AssertionConsumerService',
binding => $sso->getAttribute('Binding'),
location => $sso->getAttribute('Location'),
......@@ -117,7 +117,7 @@ sub parse {
{
## Requested attributes information
push @{ $extracted_data->{requested_attribute} },
push @{ $data->{requested_attribute} },
{
'friendly_name' =>
IdPAccountManager::Tools::encode_utf8(
......@@ -139,10 +139,10 @@ sub parse {
$child->getElementsByLocalName('RegistrationInfo'))
{
$extracted_data->{registration_info}
$data->{registration_info}
{registration_authority} =
$registrationinfo->getAttribute('registrationAuthority');
$extracted_data->{registration_info}
$data->{registration_info}
{registration_instant} =
$registrationinfo->getAttribute('registrationInstant');
foreach my $registrationpolicy (
......@@ -151,7 +151,7 @@ sub parse {
)
{
if ($registrationpolicy->getAttribute('lang') eq 'en') {
$extracted_data->{registration_info}
$data->{registration_info}
{registration_policy} =
IdPAccountManager::Tools::encode_utf8(
$registrationpolicy->textContent());
......@@ -167,7 +167,7 @@ sub parse {
IdPAccountManager::Tools::encode_utf8(
$contact_child->textContent());
}
push @{ $extracted_data->{contacts} }, \%contact_details;
push @{ $data->{contacts} }, \%contact_details;
}
}
......@@ -175,7 +175,7 @@ sub parse {
my $displayname ($child->getElementsByLocalName('DisplayName'))
{
$extracted_data->{display_name}
$data->{display_name}
{ $displayname->getAttribute('xml:lang') } =
IdPAccountManager::Tools::encode_utf8(
$displayname->textContent());
......@@ -183,10 +183,10 @@ sub parse {
## Set a default displayName in case no English version is provided
## However there is no way to determine the native displayName
## We take the first one as default
if ( !$extracted_data->{default_display_name}
if ( !$data->{default_display_name}
|| $displayname->getAttribute('xml:lang'))
{
$extracted_data->{default_display_name} =
$data->{default_display_name} =
IdPAccountManager::Tools::encode_utf8(
$displayname->textContent());
}
......@@ -197,7 +197,7 @@ sub parse {
my $description ($child->getElementsByLocalName('Description'))
{
$extracted_data->{description}
$data->{description}
{ $description->getAttribute('xml:lang') } =
IdPAccountManager::Tools::encode_utf8(
$description->textContent());
......@@ -215,20 +215,20 @@ sub parse {
IdPAccountManager::Tools::encode_utf8(
$contact_child->textContent());
}
push @{ $extracted_data->{contacts} }, \%contact_details;
push @{ $data->{contacts} }, \%contact_details;
}
foreach my $sso (
$child->getElementsByLocalName('OrganizationDisplayName'))
{
$extracted_data->{organization} =
$data->{organization} =
IdPAccountManager::Tools::encode_utf8($sso->textContent());
}
## Getting X.509 certificates
foreach my $cert ($child->getElementsByLocalName('X509Certificate'))
{
$extracted_data->{certificate} =
$data->{certificate} =
IdPAccountManager::Tools::encode_utf8($cert->textContent());
}
}
......@@ -236,17 +236,17 @@ sub parse {
## Filter entities based on type
next
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
my $domains = join(',', @{ $extracted_data->{domain} })
if ($extracted_data->{domain});
$extracted_data->{domain} = $domains;
my $domains = join(',', @{ $data->{domain} })
if ($data->{domain});
$data->{domain} = $domains;
push @extracted_array, $extracted_data;
push @array, $data;
}
return \@extracted_array;
return \@array;
}
## 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