| 1 | ##@file | ||||||||||||||||||||||||||||||||||||||||||
| 2 | # SAML Metadata object for Lemonldap::NG | ||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||
| 4 | ##@class | ||||||||||||||||||||||||||||||||||||||||||
| 5 | # SAML Metadata object for Lemonldap::NG | ||||||||||||||||||||||||||||||||||||||||||
| 6 | package Lemonldap::NG::Common::Conf::SAML::Metadata; | ||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use Mouse; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use Crypt::OpenSSL::RSA; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use Crypt::OpenSSL::X509; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use HTML::Template; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use MIME::Base64; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use Safe; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use Encode; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | 1 | our $VERSION = '2.22.0'; | |||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | 1 | my $dataStart = tell(DATA); | |||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | ## @method public string serviceToXML | ||||||||||||||||||||||||||||||||||||||||||
| 22 | # Return all SAML parameters in well formated XML format, corresponding to | ||||||||||||||||||||||||||||||||||||||||||
| 23 | # SAML 2 description. | ||||||||||||||||||||||||||||||||||||||||||
| 24 | # Supported options: | ||||||||||||||||||||||||||||||||||||||||||
| 25 | # * portal: override the portal URL | ||||||||||||||||||||||||||||||||||||||||||
| 26 | # * signing_keys: override the list of signing keys | ||||||||||||||||||||||||||||||||||||||||||
| 27 | # * encryption_keys override the list of encryption keys | ||||||||||||||||||||||||||||||||||||||||||
| 28 | # @return string | ||||||||||||||||||||||||||||||||||||||||||
| 29 | 5 | ▶ | sub serviceToXML { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
serviceToXML: called CC=19 SCAR=31.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | 5 | my ( $self, $conf, $type, %options ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | my $portal = | ||||||||||||||||||||||||||||||||||||||||||
| 33 | 5 | ▶ | $options{portal} || $conf->{portal} || "http://auth.example.com/"; | ||||||||||||||||||||||||||||||||||||||||
|
Condition40%2/5
$options{'portal'} || $conf->{'portal'} || 'http://auth.example.com/'
$options{"portal"} or $conf->{"portal"}
MC/DC0%0/2
$options{'portal'} || $conf->{'portal'} || 'http://auth.example.com/'
$options{"portal"}
$conf->{"portal"}
Truth table33%1/3
A or B
A= $options{"portal"}B= $conf->{"portal"}
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | 5 | $portal =~ s/\/$//; | |||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | 5 | seek DATA, $dataStart, 0; | |||||||||||||||||||||||||||||||||||||||||
| 37 | 5 | my $s = join '', <DATA>; | |||||||||||||||||||||||||||||||||||||||||
| 38 | 5 | my $template = HTML::Template->new( | |||||||||||||||||||||||||||||||||||||||||
| 39 | scalarref => \$s, | ||||||||||||||||||||||||||||||||||||||||||
| 40 | die_on_bad_params => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 41 | cache => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 42 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | # Automatic parameters | ||||||||||||||||||||||||||||||||||||||||||
| 45 | 5 | my @param_auto = qw( | |||||||||||||||||||||||||||||||||||||||||
| 46 | samlEntityID | ||||||||||||||||||||||||||||||||||||||||||
| 47 | samlOrganizationName | ||||||||||||||||||||||||||||||||||||||||||
| 48 | samlOrganizationDisplayName | ||||||||||||||||||||||||||||||||||||||||||
| 49 | samlOrganizationURL | ||||||||||||||||||||||||||||||||||||||||||
| 50 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||
| 52 | 5 | ▶ | if ( $type and $type eq 'idp' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$type and $type eq "idp"
MC/DC0%0/2
$type and $type eq "idp"
$type
$type eq "idp"
Truth table33%1/3
A and B
A= $typeB= $type eq "idp"
| |||||||||||||||||||||||||||||||||||||||||||
| 53 | 5 | $template->param( 'hideSPMetadata', 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | 5 | ▶ | if ( $type and $type eq 'sp' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$type and $type eq "sp"
MC/DC0%0/2
$type and $type eq "sp"
$type
$type eq "sp"
Truth table33%1/3
A and B
A= $typeB= $type eq "sp"
| |||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | $template->param( 'hideIDPMetadata', 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | 5 | foreach (@param_auto) { | |||||||||||||||||||||||||||||||||||||||||
| 61 | 20 | $template->param( $_, $self->_replacePortal( $conf->{$_}, $portal ) ); | |||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | # When asked to provide only IDP metadata, take into account EntityID override | ||||||||||||||||||||||||||||||||||||||||||
| 65 | 5 | ▶ | if ( $type eq "idp" and $conf->{samlOverrideIDPEntityID} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$type eq "idp" and $conf->{"samlOverrideIDPEntityID"}
MC/DC0%0/2
$type eq "idp" and $conf->{"samlOverrideIDPEntityID"}
$type eq "idp"
$conf->{"samlOverrideIDPEntityID"}
Truth table33%1/3
A and B
A= $type eq "idp"B= $conf->{"samlOverrideIDPEntityID"}
| |||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | $template->param( 'samlEntityID', $conf->{samlOverrideIDPEntityID} ); | |||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | # Boolean parameters | ||||||||||||||||||||||||||||||||||||||||||
| 70 | 5 | my @param_boolean = qw( | |||||||||||||||||||||||||||||||||||||||||
| 71 | samlSPSSODescriptorAuthnRequestsSigned | ||||||||||||||||||||||||||||||||||||||||||
| 72 | samlSPSSODescriptorWantAssertionsSigned | ||||||||||||||||||||||||||||||||||||||||||
| 73 | samlIDPSSODescriptorWantAuthnRequestsSigned | ||||||||||||||||||||||||||||||||||||||||||
| 74 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | 5 | foreach (@param_boolean) { | |||||||||||||||||||||||||||||||||||||||||
| 77 | $template->param( $_, | ||||||||||||||||||||||||||||||||||||||||||
| 78 | 15 | ▶ | $self->_replacePortal( $conf->{$_}, $portal ) ? 'true' : 'false' ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||
| 81 | my $signing_keys = | ||||||||||||||||||||||||||||||||||||||||||
| 82 | 5 | ▶ | $options{signing_keys} || [ $conf->{samlServicePublicKeySig} ]; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$options{'signing_keys'} || [$conf->{'samlServicePublicKeySig'}]
MC/DC100%1/1
$options{'signing_keys'} || [$conf->{'samlServicePublicKeySig'}]
$options{'signing_keys'}
Truth table100%2/2
A
A= $options{'signing_keys'}
| |||||||||||||||||||||||||||||||||||||||||||
| 83 | my $encryption_keys = $options{encryption_keys} | ||||||||||||||||||||||||||||||||||||||||||
| 84 | || ( | ||||||||||||||||||||||||||||||||||||||||||
| 85 | $conf->{samlServicePublicKeyEnc} | ||||||||||||||||||||||||||||||||||||||||||
| 86 | 5 | ▶ | ? [ $conf->{samlServicePublicKeyEnc} ] | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$options{'encryption_keys'} || ($conf->{'samlServicePublicKeyEnc'} ? [$conf->{'samlServicePublicKeyEnc'}] : $signing_keys)
MC/DC0%0/2
$options{'encryption_keys'} || ($conf->{'samlServicePublicKeyEnc'} ? [$conf->{'samlServicePublicKeyEnc'}] : $signing_keys)
$options{'encryption_keys'}
($conf->{'samlServicePublicKeyEnc'} ? [$conf->{'samlServicePublicKeyEnc'}] : $signing_keys)
Truth table66%2/3
A || B
A= $options{'encryption_keys'}B= ($conf->{'samlServicePublicKeyEnc'} ? [$conf->{'samlServicePublicKeyEnc'}] : $signing_keys)
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | : $signing_keys | ||||||||||||||||||||||||||||||||||||||||||
| 88 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||
| 90 | # Keys | ||||||||||||||||||||||||||||||||||||||||||
| 91 | $template->param( "signing_keys", | ||||||||||||||||||||||||||||||||||||||||||
| 92 | 5 | [ map { { keyInfo => $self->_getKeyInfoFromPem($_) } } @$signing_keys ] | |||||||||||||||||||||||||||||||||||||||||
| 93 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 94 | $template->param( | ||||||||||||||||||||||||||||||||||||||||||
| 95 | "encryption_keys", | ||||||||||||||||||||||||||||||||||||||||||
| 96 | [ | ||||||||||||||||||||||||||||||||||||||||||
| 97 | 5 | map { { keyInfo => $self->_getKeyInfoFromPem($_) } } | |||||||||||||||||||||||||||||||||||||||||
| 98 | @$encryption_keys | ||||||||||||||||||||||||||||||||||||||||||
| 99 | ] | ||||||||||||||||||||||||||||||||||||||||||
| 100 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | # Rebuilded parameters for SAML services | ||||||||||||||||||||||||||||||||||||||||||
| 103 | # A samlService value is formated like the following: | ||||||||||||||||||||||||||||||||||||||||||
| 104 | # "binding;location;responseLocation" | ||||||||||||||||||||||||||||||||||||||||||
| 105 | # The last value, responseLocation, is optional. | ||||||||||||||||||||||||||||||||||||||||||
| 106 | 5 | my @param_service = qw( | |||||||||||||||||||||||||||||||||||||||||
| 107 | samlSPSSODescriptorSingleLogoutServiceHTTPRedirect | ||||||||||||||||||||||||||||||||||||||||||
| 108 | samlSPSSODescriptorSingleLogoutServiceHTTPPost | ||||||||||||||||||||||||||||||||||||||||||
| 109 | samlSPSSODescriptorSingleLogoutServiceSOAP | ||||||||||||||||||||||||||||||||||||||||||
| 110 | samlIDPSSODescriptorSingleSignOnServiceHTTPRedirect | ||||||||||||||||||||||||||||||||||||||||||
| 111 | samlIDPSSODescriptorSingleSignOnServiceHTTPPost | ||||||||||||||||||||||||||||||||||||||||||
| 112 | samlIDPSSODescriptorSingleSignOnServiceHTTPArtifact | ||||||||||||||||||||||||||||||||||||||||||
| 113 | samlIDPSSODescriptorSingleLogoutServiceHTTPRedirect | ||||||||||||||||||||||||||||||||||||||||||
| 114 | samlIDPSSODescriptorSingleLogoutServiceHTTPPost | ||||||||||||||||||||||||||||||||||||||||||
| 115 | samlIDPSSODescriptorSingleLogoutServiceSOAP | ||||||||||||||||||||||||||||||||||||||||||
| 116 | samlAttributeAuthorityDescriptorAttributeServiceSOAP | ||||||||||||||||||||||||||||||||||||||||||
| 117 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||
| 119 | 5 | foreach (@param_service) { | |||||||||||||||||||||||||||||||||||||||||
| 120 | 50 | my @_tab = split( /;/, $self->_replacePortal( $conf->{$_}, $portal ) ); | |||||||||||||||||||||||||||||||||||||||||
| 121 | 50 | $template->param( $_ . 'Binding', $_tab[0] ); | |||||||||||||||||||||||||||||||||||||||||
| 122 | 50 | $template->param( $_ . 'Location', $_tab[1] ); | |||||||||||||||||||||||||||||||||||||||||
| 123 | 50 | $template->param( $_ . 'ResponseLocation', $_tab[2] ); | |||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||
| 126 | # Rebuilded parameters for SAML assertions | ||||||||||||||||||||||||||||||||||||||||||
| 127 | # A samlAssertion value is formated like the following: | ||||||||||||||||||||||||||||||||||||||||||
| 128 | # "default;index;binding;location" | ||||||||||||||||||||||||||||||||||||||||||
| 129 | 5 | my @param_assertion = qw( | |||||||||||||||||||||||||||||||||||||||||
| 130 | samlSPSSODescriptorAssertionConsumerServiceHTTPArtifact | ||||||||||||||||||||||||||||||||||||||||||
| 131 | samlSPSSODescriptorAssertionConsumerServiceHTTPPost | ||||||||||||||||||||||||||||||||||||||||||
| 132 | samlSPSSODescriptorArtifactResolutionServiceArtifact | ||||||||||||||||||||||||||||||||||||||||||
| 133 | samlIDPSSODescriptorArtifactResolutionServiceArtifact | ||||||||||||||||||||||||||||||||||||||||||
| 134 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||
| 136 | 5 | my %indexed_endpoints; | |||||||||||||||||||||||||||||||||||||||||
| 137 | 5 | foreach (@param_assertion) { | |||||||||||||||||||||||||||||||||||||||||
| 138 | 20 | my @_tab = split( /;/, $self->_replacePortal( $conf->{$_}, $portal ) ); | |||||||||||||||||||||||||||||||||||||||||
| 139 | 20 | ▶ | $indexed_endpoints{ $_ . 'Default' } = ( $_tab[0] ? 'true' : 'false' ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 140 | 20 | $indexed_endpoints{ $_ . 'Index' } = $_tab[1]; | |||||||||||||||||||||||||||||||||||||||||
| 141 | 20 | $indexed_endpoints{ $_ . 'Binding' } = $_tab[2]; | |||||||||||||||||||||||||||||||||||||||||
| 142 | 20 | $indexed_endpoints{ $_ . 'Location' } = $_tab[3]; | |||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||
| 144 | 5 | $template->param(%indexed_endpoints); | |||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||
| 146 | 5 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 147 | $indexed_endpoints{samlSPSSODescriptorAssertionConsumerServiceHTTPArtifactDefault} | ||||||||||||||||||||||||||||||||||||||||||
| 148 | eq 'true' | ||||||||||||||||||||||||||||||||||||||||||
| 149 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 150 | { | ||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | $template->param( "ACSArtifactDefault" => 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||
| 154 | # Return the XML metadata. | ||||||||||||||||||||||||||||||||||||||||||
| 155 | 5 | return $template->output; | |||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||
| 158 | 11 | ▶ | sub _getKeyInfoFromPem { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_getKeyInfoFromPem: called CC=10 SCAR=23.6
| |||||||||||||||||||||||||||||||||||||||||||
| 159 | 11 | my ( $self, $val ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||
| 161 | 11 | my $str; | |||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||
| 163 | 11 | ▶ | if ( defined $val and ref($val) eq "HASH" and exists $val->{public} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
defined $val and ref $val eq "HASH" and exists $val->{"public"}
defined $val and ref $val eq "HASH"
MC/DC33%1/3
defined $val and ref $val eq "HASH" and exists $val->{"public"}
defined $val
ref $val eq "HASH"
exists $val->{"public"}
Truth table50%2/4
A and B and C
A= defined $valB= ref $val eq "HASH"C= exists $val->{"public"}
| |||||||||||||||||||||||||||||||||||||||||||
| 164 | 2 | $val = $val->{public}; | |||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||
| 166 | 11 | ▶ | if ( defined $val && length $val gt 0 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $val and length $val gt 0
MC/DC0%0/2
defined $val and length $val gt 0
defined $val
length $val gt 0
Truth table33%1/3
A and B
A= defined $valB= length $val gt 0
| |||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||
| 168 | # Public Key ? | ||||||||||||||||||||||||||||||||||||||||||
| 169 | 11 | ▶ | if ( $val =~ /^-----BEGIN PUBLIC KEY-----/ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$val =~ /^-----BEGIN PUBLIC KEY-----/ and my $rsa_pub = "Crypt::OpenSSL::RSA"->new_public_key($val)
MC/DC50%1/2
$val =~ /^-----BEGIN PUBLIC KEY-----/ and my $rsa_pub = "Crypt::OpenSSL::RSA"->new_public_key($val)
$val =~ /^-----BEGIN PUBLIC KEY-----/
my $rsa_pub = "Crypt::OpenSSL::RSA"->new_public_key($val)
Truth table66%2/3
A and B
A= $val =~ /^-----BEGIN PUBLIC KEY-----/B= my $rsa_pub = "Crypt::OpenSSL::RSA"->new_public_key($val)
| |||||||||||||||||||||||||||||||||||||||||||
| 170 | and my $rsa_pub = Crypt::OpenSSL::RSA->new_public_key($val) ) | ||||||||||||||||||||||||||||||||||||||||||
| 171 | { | ||||||||||||||||||||||||||||||||||||||||||
| 172 | 6 | my @params = $rsa_pub->get_key_parameters(); | |||||||||||||||||||||||||||||||||||||||||
| 173 | 6 | my $mod = encode_base64( $params[0]->to_bin() ); | |||||||||||||||||||||||||||||||||||||||||
| 174 | 6 | my $exp = encode_base64( $params[1]->to_bin() ); | |||||||||||||||||||||||||||||||||||||||||
| 175 | 6 | $str = | |||||||||||||||||||||||||||||||||||||||||
| 176 | '<ds:KeyValue>' . "\n\t" | ||||||||||||||||||||||||||||||||||||||||||
| 177 | . '<RSAKeyValue xmlns="http://www.w3.org/2000/09/xmldsig#">' | ||||||||||||||||||||||||||||||||||||||||||
| 178 | . "\n\t\t" | ||||||||||||||||||||||||||||||||||||||||||
| 179 | . '<Modulus>' | ||||||||||||||||||||||||||||||||||||||||||
| 180 | . $mod | ||||||||||||||||||||||||||||||||||||||||||
| 181 | . '</Modulus>' | ||||||||||||||||||||||||||||||||||||||||||
| 182 | . "\n\t\t" | ||||||||||||||||||||||||||||||||||||||||||
| 183 | . '<Exponent>' | ||||||||||||||||||||||||||||||||||||||||||
| 184 | . $exp | ||||||||||||||||||||||||||||||||||||||||||
| 185 | . '</Exponent>' . "\n\t" | ||||||||||||||||||||||||||||||||||||||||||
| 186 | . '</RSAKeyValue>' . "\n" | ||||||||||||||||||||||||||||||||||||||||||
| 187 | . '</ds:KeyValue>'; | ||||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||
| 190 | # Certificate ? | ||||||||||||||||||||||||||||||||||||||||||
| 191 | 11 | ▶ | if ( $val =~ /^-----BEGIN CERTIFICATE-----/ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$val =~ /^-----BEGIN CERTIFICATE-----/ and my $certificate = "Crypt::OpenSSL::X509"->new_from_string($val)
MC/DC50%1/2
$val =~ /^-----BEGIN CERTIFICATE-----/ and my $certificate = "Crypt::OpenSSL::X509"->new_from_string($val)
$val =~ /^-----BEGIN CERTIFICATE-----/
my $certificate = "Crypt::OpenSSL::X509"->new_from_string($val)
Truth table66%2/3
A and B
A= $val =~ /^-----BEGIN CERTIFICATE-----/B= my $certificate = "Crypt::OpenSSL::X509"->new_from_string($val)
| |||||||||||||||||||||||||||||||||||||||||||
| 192 | and my $certificate = Crypt::OpenSSL::X509->new_from_string($val) ) | ||||||||||||||||||||||||||||||||||||||||||
| 193 | { | ||||||||||||||||||||||||||||||||||||||||||
| 194 | 5 | $certificate = $certificate->as_string(); | |||||||||||||||||||||||||||||||||||||||||
| 195 | 5 | $certificate =~ s/^-----BEGIN CERTIFICATE-----\n?//g; | |||||||||||||||||||||||||||||||||||||||||
| 196 | 5 | $certificate =~ s/\n?-----END CERTIFICATE-----$//g; | |||||||||||||||||||||||||||||||||||||||||
| 197 | 5 | $str = | |||||||||||||||||||||||||||||||||||||||||
| 198 | '<ds:X509Data>' . "\n\t" | ||||||||||||||||||||||||||||||||||||||||||
| 199 | . '<ds:X509Certificate>' . "\n\t" | ||||||||||||||||||||||||||||||||||||||||||
| 200 | . $certificate | ||||||||||||||||||||||||||||||||||||||||||
| 201 | . '</ds:X509Certificate>' . "\n" | ||||||||||||||||||||||||||||||||||||||||||
| 202 | . '</ds:X509Data>'; | ||||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||
| 205 | 11 | return $str; | |||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||
| 208 | # DEPRECATED, remove in 3.0 | ||||||||||||||||||||||||||||||||||||||||||
| 209 | # Get the value for a metadata configuration key | ||||||||||||||||||||||||||||||||||||||||||
| 210 | # Replace #PORTAL# macro | ||||||||||||||||||||||||||||||||||||||||||
| 211 | # @param key Configuration key | ||||||||||||||||||||||||||||||||||||||||||
| 212 | # @param conf Configuration hash ref | ||||||||||||||||||||||||||||||||||||||||||
| 213 | # @return value | ||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | sub getValue { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getValue: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | my ( $self, $key, $conf ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||
| 217 | # Get portal value | ||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | ▶ | my $portal = $conf->{portal} || "http://auth.example.com/"; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$conf->{'portal'} || 'http://auth.example.com/'
MC/DC0%0/1
$conf->{'portal'} || 'http://auth.example.com/'
$conf->{'portal'}
Truth table0%0/2
A
A= $conf->{'portal'}
| |||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | $portal =~ s/\/$//; | |||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | return $self->_replacePortal( $conf->{$key}, $portal ); | |||||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||
| 224 | #@method string replacePortal(string key, hashref conf) | ||||||||||||||||||||||||||||||||||||||||||
| 225 | # Get the value for a metadata configuration key | ||||||||||||||||||||||||||||||||||||||||||
| 226 | # Replace #PORTAL# macro | ||||||||||||||||||||||||||||||||||||||||||
| 227 | # @param key Configuration key | ||||||||||||||||||||||||||||||||||||||||||
| 228 | # @param conf Configuration hash ref | ||||||||||||||||||||||||||||||||||||||||||
| 229 | # @return value | ||||||||||||||||||||||||||||||||||||||||||
| 230 | 105 | ▶ | sub _replacePortal { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_replacePortal: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||
| 231 | 105 | my ( $self, $value, $portal ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 232 | 105 | ▶ | return unless $value; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||
| 234 | # Replace #PORTAL# macro | ||||||||||||||||||||||||||||||||||||||||||
| 235 | 105 | $value =~ s/#PORTAL#/$portal/g; | |||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||
| 237 | # Return value | ||||||||||||||||||||||||||||||||||||||||||
| 238 | 105 | return $value; | |||||||||||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||
| 241 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 242 | __DATA__ | ||||||||||||||||||||||||||||||||||||||||||