@@ -19,17 +19,18 @@ use Net::SAML2::Protocol::LogoutRequest;
1919use Net::SAML2::Util ();
2020use URN::OASIS::SAML2 qw( :bindings :urn) ;
2121use XML::Generator;
22+ use Net::SAML2::Types qw( XsdID) ;
2223
2324# ABSTRACT: SAML Service Provider object
2425
2526=head1 SYNOPSIS
2627
27- my $sp = Net::SAML2::SP->new(
28- id => 'http://localhost:3000',
29- url => 'http://localhost:3000',
30- cert => 'sign-nopw-cert.pem',
31- key => 'sign-nopw-key.pem',
32- );
28+ my $sp = Net::SAML2::SP->new(
29+ issuer => 'http://localhost:3000',
30+ url => 'http://localhost:3000',
31+ cert => 'sign-nopw-cert.pem',
32+ key => 'sign-nopw-key.pem',
33+ );
3334
3435=head1 METHODS
3536
@@ -44,6 +45,10 @@ Arguments:
4445
4546=over
4647
48+ =item B<id >
49+
50+ The ID attribute used in the EntityDescription tag
51+
4752=item B<url >
4853
4954Base for all SP service URLs
@@ -52,7 +57,7 @@ Base for all SP service URLs
5257
5358The error URI. Can be relative to the base URI or a regular URI
5459
55- =item B<id >
60+ =item B<issuer >
5661
5762SP's identity URI.
5863
@@ -156,7 +161,10 @@ Consumer Services.
156161=cut
157162
158163has ' url' => (isa => Uri, is => ' ro' , required => 1, coerce => 1);
159- has ' id' => (isa => ' Str' , is => ' ro' , required => 1);
164+
165+ has ' id' => (isa => XsdID, is => ' ro' , builder => ' _build_id' );
166+ has ' issuer' => (isa => ' Str' , is => ' ro' , required => 1);
167+
160168has ' cert' => (isa => ' Str' , is => ' ro' , required => 1, predicate => ' has_cert' );
161169has ' key' => (isa => ' Str' , is => ' ro' , required => 1);
162170has ' cacert' => (isa => ' Str' , is => ' rw' , required => 0, predicate => ' has_cacert' );
@@ -196,6 +204,12 @@ around BUILDARGS => sub {
196204
197205 my %args = @_ ;
198206
207+ if (!exists $args {issuer } && exists $args {id }) {
208+ Net::SAML2::Util::deprecation_warning
209+ " id has been renamed to issuer and should be used instead" ;
210+ $args {issuer } = delete $args {id };
211+ }
212+
199213 if (!$args {single_logout_service }) {
200214 # warn "Deprecation warning, please upgrade your code to use ..";
201215 my @slo ;
@@ -270,6 +284,20 @@ around BUILDARGS => sub {
270284 return $self -> $orig (%args );
271285};
272286
287+ sub _build_id {
288+ my $self = shift ;
289+
290+ # This allows current clients to override the builder without changing
291+ # their code
292+ if (my $f = $self -> can(' generate_sp_desciptor_id' )) {
293+ Net::SAML2::Util::deprecation_warning
294+ " generate_sp_desciptor_id has been deprecated, please override " .
295+ " _build_id yourself or supply the ID to the constructor" ;
296+ return $f -> ();
297+ }
298+ return Net::SAML2::Util::generate_id();
299+ }
300+
273301sub _build_encryption_key_text {
274302 my ($self ) = @_ ;
275303
@@ -323,7 +351,7 @@ sub authn_request {
323351
324352 return Net::SAML2::Protocol::AuthnRequest-> new(
325353 issueinstant => DateTime-> now,
326- issuer => $self -> id ,
354+ issuer => $self -> issuer ,
327355 destination => $destination ,
328356 nameidpolicy_format => $nameid_format || ' ' ,
329357 %params ,
@@ -356,7 +384,7 @@ sub logout_request {
356384 my ($self , $destination , $nameid , $nameid_format , $session , $params ) = @_ ;
357385
358386 my $logout_req = Net::SAML2::Protocol::LogoutRequest-> new(
359- issuer => $self -> id ,
387+ issuer => $self -> issuer ,
360388 destination => $destination ,
361389 nameid => $nameid ,
362390 session => $session ,
@@ -391,7 +419,7 @@ sub logout_response {
391419
392420 my $status_uri = Net::SAML2::Protocol::LogoutResponse-> status_uri($status );
393421 my $logout_req = Net::SAML2::Protocol::LogoutResponse-> new(
394- issuer => $self -> id ,
422+ issuer => $self -> issuer ,
395423 destination => $destination ,
396424 status => $status_uri ,
397425 response_to => $response_to ,
@@ -412,7 +440,7 @@ sub artifact_request {
412440 my ($self , $destination , $artifact ) = @_ ;
413441
414442 my $artifact_request = Net::SAML2::Protocol::ArtifactResolve-> new(
415- issuer => $self -> id ,
443+ issuer => $self -> issuer ,
416444 destination => $destination ,
417445 artifact => $artifact ,
418446 issueinstant => DateTime-> now,
@@ -539,17 +567,6 @@ sub post_binding {
539567 );
540568}
541569
542- =head2 generate_sp_desciptor_id ( )
543-
544- Returns the Net::SAML2 unique ID from Net::SAML2::Util::generate_id.
545-
546- =cut
547-
548- sub generate_sp_desciptor_id {
549- my $self = shift ;
550- return Net::SAML2::Util::generate_id();
551- }
552-
553570=head2 generate_metadata( )
554571
555572Generate the metadata XML document for this SP.
@@ -572,8 +589,8 @@ sub generate_metadata {
572589 return $x -> xml( $x -> EntityDescriptor(
573590 $md ,
574591 {
575- entityID => $self -> id ,
576- ID => $self -> generate_sp_desciptor_id() ,
592+ entityID => $self -> issuer ,
593+ ID => $self -> id ,
577594 },
578595 $x -> SPSSODescriptor(
579596 $md ,
0 commit comments