Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Parse out the NameIDFormat list, and make it available.

  • Loading branch information...
commit 5ee06198a4561df146f738aebb0a4e13db87d373 1 parent 5f37f24
authored February 28, 2011

Showing 1 changed file with 26 additions and 1 deletion. Show diff stats Hide diff stats

  1. 27  lib/Net/SAML2/IdP.pm
27  lib/Net/SAML2/IdP.pm
@@ -36,6 +36,7 @@ has 'sso_urls' => (isa => HashRef[Str], is => 'ro', required => 1);
36 36
 has 'slo_urls' => (isa => HashRef[Str], is => 'ro', required => 1);
37 37
 has 'art_urls' => (isa => HashRef[Str], is => 'ro', required => 1);
38 38
 has 'certs'    => (isa => HashRef[Str], is => 'ro', required => 1);
  39
+has 'formats'  => (isa => HashRef[Str], is => 'ro', required => 1);
39 40
 
40 41
 =head2 new_from_url( url => $url, cacert => $cacert )
41 42
 
@@ -89,6 +90,13 @@ sub new_from_xml {
89 90
         $data->{Art}->{$binding} = $art->getAttribute('Location');
90 91
     }
91 92
 
  93
+    for my $format ($xpath->findnodes('//md:EntityDescriptor/md:IDPSSODescriptor/md:NameIDFormat')) {
  94
+        $format = $format->string_value;
  95
+        my ($short_format) = $format =~ /urn:oasis:names:tc:SAML:(?:2.0|1.1):nameid-format:(.*)$/;
  96
+        if (defined $short_format) {
  97
+            $data->{NameIDFormat}->{$short_format} = $format;
  98
+        }
  99
+    }
92 100
 
93 101
     for my $key ($xpath->findnodes('//md:EntityDescriptor/md:IDPSSODescriptor/md:KeyDescriptor')) {
94 102
         my $use = $key->getAttribute('use');
@@ -116,6 +124,7 @@ sub new_from_xml {
116 124
         slo_urls => $data->{SLO},
117 125
         art_urls => $data->{Art},
118 126
         certs    => $data->{Cert},
  127
+        formats  => $data->{NameIDFormat},
119 128
         cacert   => $args{cacert},
120 129
     );
121 130
 
@@ -203,6 +212,22 @@ sub binding {
203 212
     return;
204 213
 }
205 214
 
  215
+=head2 format($short_name)
  216
+
  217
+Returns the full NameID Format URI for the given short name. Uses data
  218
+from the IdP metadata, and returns undef if the requested short name
  219
+is not advertised by the IdP.
  220
+
  221
+=cut
  222
+
  223
+sub format {
  224
+    my ($self, $short_name) = @_;
  225
+
  226
+    if (defined $short_name && exists $self->formats->{$short_name}) {
  227
+        return $self->formats->{$short_name};
  228
+    }
  229
+    
  230
+    return;
206 231
 }
207 232
 
208  
-1;
  233
+__PACKAGE__->meta->make_immutable;

0 notes on commit 5ee0619

Please sign in to comment.
Something went wrong with that request. Please try again.