| 1 | # Copyrights 2012-2016 by [Mark Overmeer]. | ||||||||||||||||||||||||||||
| 2 | # For other contributors see ChangeLog. | ||||||||||||||||||||||||||||
| 3 | # See the manual pages for details on the licensing terms. | ||||||||||||||||||||||||||||
| 4 | # Pod stripped from pm file by OODoc 2.02. | ||||||||||||||||||||||||||||
| 5 | 5 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | package XML::Compile::WSS::KeyInfo; | ||||||||||||||||||||||||||||
| 9 | 5 | ▶ | use vars '$VERSION'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 5 | $VERSION = '2.02'; | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 5 | ▶ | use Log::Report 'xml-compile-wss-sig'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 5 | ▶ | use XML::Compile::WSS::Util qw/:wsm10 :wsm11 :xtp10/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | 5 | ▶ | use XML::Compile::WSS::SecToken::X509v3 (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | 5 | ▶ | use Crypt::OpenSSL::X509 qw/FORMAT_ASN1/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 5 | ▶ | sub new(@) { my $class = shift; (bless {}, $class)->init({@_}) } | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 21 | sub init($) | ||||||||||||||||||||||||||||
| 22 | 5 | ▶ | { my ($self, $args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
init: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 23 | 5 | $self->{XCWK_tokens} = []; | |||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | # It's too large to create accessors, so for this hack. | ||||||||||||||||||||||||||||
| 26 | 5 | $self->{XCWK_config} = $args; | |||||||||||||||||||||||||||
| 27 | 5 | $self; | |||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | sub fromConfig(@) | ||||||||||||||||||||||||||||
| 32 | 4 | ▶ | { my $class = shift; | ||||||||||||||||||||||||||
|
Subroutine
fromConfig: called CC=2 SCAR=8.1
Pod
documented
| |||||||||||||||||||||||||||||
| 33 | 4 | ▶ | $class->new(@_==1 ? %{$_[0]} : @_); # also clones the HASH | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | #----------------- | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 8 | ▶ | sub config() { my $c = shift->{XCWK_config}; wantarray ? %$c : $c } | ||||||||||||||||||||||||||
|
Subroutine
config: called CC=2 SCAR=7.2
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | #----------------------------- | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | sub addToken($) | ||||||||||||||||||||||||||||
| 43 | 3 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
addToken: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 44 | 3 | push @{$self->{XCWK_tokens}}, @_; | |||||||||||||||||||||||||||
| 45 | 3 | $self; | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | sub findToken(%) | ||||||||||||||||||||||||||||
| 50 | 4 | ▶ | { my ($self, %args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
findToken: called CC=13 SCAR=30.9
Pod
documented
| |||||||||||||||||||||||||||||
| 51 | 4 | ▶ | if(my $fu = $args{uri}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 52 | 2 | { foreach my $token ($self->tokens) | |||||||||||||||||||||||||||
| 53 | 1 | ▶ | { my $tu = $token->uri or next; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 54 | 1 | ▶ | return $token if $tu eq $fu; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | 4 | ▶ | if(my $fp = $args{fingerprint}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 58 | 2 | { foreach my $token ($self->tokens) | |||||||||||||||||||||||||||
| 59 | 2 | ▶ | { my $tp = $token->fingerprint or next; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 60 | 2 | ▶ | return $token if $tp eq $fp; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||
| 63 | 2 | ▶ | if(my $fn = $args{name}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 64 | 0 | { foreach my $token ($self->tokens) | |||||||||||||||||||||||||||
| 65 | 0 | ▶ | { my $tn = $token->fingerprint or next; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 66 | 0 | ▶ | return $token if $tn eq $fn; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||
| 69 | 2 | (); | |||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 7 | ▶ | sub tokens() { @{shift->{XCWK_tokens}} } | ||||||||||||||||||||||||||
|
Subroutine
tokens: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | #----------------- | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | # See dump/keyinfo/template | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | sub getTokens($%) | ||||||||||||||||||||||||||||
| 80 | 3 | ▶ | { my ($self, $wss) = (shift, shift); | ||||||||||||||||||||||||||
|
Subroutine
getTokens: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 81 | 3 | my %args = ($self->config, @_); | |||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | 3 | my %keyinfo_handlers = | |||||||||||||||||||||||||||
| 84 | ( ds_KeyName => $self->_get_by_keyname($wss, \%args) | ||||||||||||||||||||||||||||
| 85 | , ds_KeyValue => undef | ||||||||||||||||||||||||||||
| 86 | , ds_RetrievalMethod => undef | ||||||||||||||||||||||||||||
| 87 | , ds_X509Data => $self->_get_as_x509data($wss, \%args) | ||||||||||||||||||||||||||||
| 88 | , ds_PGPData => undef | ||||||||||||||||||||||||||||
| 89 | , ds_SPKIData => undef | ||||||||||||||||||||||||||||
| 90 | , ds_MgmtData => undef | ||||||||||||||||||||||||||||
| 91 | , wsse_SecurityTokenReference | ||||||||||||||||||||||||||||
| 92 | => $self->_get_by_sectokref($wss, \%args) | ||||||||||||||||||||||||||||
| 93 | ); | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | sub { | ||||||||||||||||||||||||||||
| 96 | 5 | ▶ | my ($h, $sec, $up_id) = @_; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.2
| |||||||||||||||||||||||||||||
| 97 | 5 | ▶ | my $id = $h->{Id} || $up_id; | ||||||||||||||||||||||||||
|
Condition100%3/3
$h->{'Id'} || $up_id
MC/DC100%2/2
$h->{'Id'} || $up_id
$h->{'Id'}
$up_id
Truth table100%3/3
A || B
A= $h->{'Id'}B= $up_id
| |||||||||||||||||||||||||||||
| 98 | 5 | my @tokens; | |||||||||||||||||||||||||||
| 99 | 5 | ▶ | foreach (@{$h->{cho_ds_KeyName} ||[]}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 100 | 5 | { my ($way, $how) = %$_; # hash of one pair | |||||||||||||||||||||||||||
| 101 | 5 | ▶ | my $handler = $keyinfo_handlers{$way} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 102 | or error __x"unsupported key-info type {type} for {id}" | ||||||||||||||||||||||||||||
| 103 | , type => $way, id => $id; | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | 5 | push @tokens, $handler->($id, $sec, $how); | |||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||
| 107 | 5 | @tokens; | |||||||||||||||||||||||||||
| 108 | 3 | }; | |||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | # ds_keyname | ||||||||||||||||||||||||||||
| 112 | sub _get_by_keyname($$) | ||||||||||||||||||||||||||||
| 113 | 3 | ▶ | { my ($self, $wss, $args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_get_by_keyname: called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||
| 114 | 3 | ▶ | sub { my ($id, $sec, $h) = @_; $self->findToken(name => $h) }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=2.6
| |||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | # ds_X509Data | ||||||||||||||||||||||||||||
| 118 | sub _get_as_x509data($$) | ||||||||||||||||||||||||||||
| 119 | 3 | ▶ | { my ($self, $wss, $args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_get_as_x509data: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | sub { | ||||||||||||||||||||||||||||
| 122 | 1 | ▶ | my ($id, $sec, $h) = @_; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=14.1
| |||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | 1 | my @tokens; | |||||||||||||||||||||||||||
| 125 | 1 | ▶ | foreach my $rec ( @{$h->{seq_ds_X509IssuerSerial} || []} ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 126 | 2 | ▶ | { my $bin_cert = $rec->{ds_X509Certificate} or next; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 127 | 2 | push @tokens, XML::Compile::WSS::SecToken::X509v3 | |||||||||||||||||||||||||||
| 128 | ->new(id => $id, binary => $bin_cert); | ||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||
| 130 | 1 | @tokens; | |||||||||||||||||||||||||||
| 131 | 3 | }; | |||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | # wsse_SecurityTokenReference | ||||||||||||||||||||||||||||
| 135 | sub _get_by_sectokref($$$) | ||||||||||||||||||||||||||||
| 136 | 3 | ▶ | { my ($self, $wss, $args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_get_by_sectokref: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | 3 | my %str_handlers = | |||||||||||||||||||||||||||
| 139 | ( wsse_KeyIdentifier => $self->_get_str_keyid($wss, $args) | ||||||||||||||||||||||||||||
| 140 | , wsse_Reference => $self->_get_str_uri($wss, $args) | ||||||||||||||||||||||||||||
| 141 | ); | ||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | sub { | ||||||||||||||||||||||||||||
| 144 | 4 | ▶ | my ($id, $sec, $h) = @_; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 145 | 4 | my @tokens; | |||||||||||||||||||||||||||
| 146 | 4 | foreach (@{$h->{cho_any}}) | |||||||||||||||||||||||||||
| 147 | 4 | { my ($ref, $d) = %$_; # one pair | |||||||||||||||||||||||||||
| 148 | 4 | ▶ | my $handler = $str_handlers{$ref} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 149 | or error __x"Keyinfo {id}: {type} not supported" | ||||||||||||||||||||||||||||
| 150 | , id => $id, type => $ref; | ||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | 4 | push @tokens, $handler->($id, $sec, $d); | |||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||
| 155 | 4 | @tokens; | |||||||||||||||||||||||||||
| 156 | 3 | }; | |||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | sub _get_str_keyid($$) # SECTOKREF_KEYID | ||||||||||||||||||||||||||||
| 160 | 3 | ▶ | { my ($self, $wss, $args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_get_str_keyid: called CC=1 SCAR=0.1
| |||||||||||||||||||||||||||||
| 161 | sub { | ||||||||||||||||||||||||||||
| 162 | 2 | ▶ | my ($id, $sec, $d) = @_; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.2
| |||||||||||||||||||||||||||||
| 163 | 2 | my $valuet = $d->{ValueType}; | |||||||||||||||||||||||||||
| 164 | 2 | ▶ | if($valuet eq WSM11_PRINT_SHA1) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 165 | 2 | { my $p = wsm_decoded $d->{EncodingType}, $d->{_}; | |||||||||||||||||||||||||||
| 166 | 2 | return $self->findToken(fingerprint => $p); | |||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||
| 169 | 0 | error __x"Keyinfo {id}: {type} not supported", id => $id, type => $valuet; | |||||||||||||||||||||||||||
| 170 | 3 | }; | |||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||
| 173 | sub _get_str_uri($$) # SECTOKREF_URI | ||||||||||||||||||||||||||||
| 174 | 3 | ▶ | { my ($self, $wss, $args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_get_str_uri: called CC=1 SCAR=0.1
| |||||||||||||||||||||||||||||
| 175 | sub { | ||||||||||||||||||||||||||||
| 176 | 2 | ▶ | my ($id, $sec, $d) = @_; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=6 SCAR=18.8
| |||||||||||||||||||||||||||||
| 177 | 2 | my $uri = $d->{URI}; | |||||||||||||||||||||||||||
| 178 | 2 | my $token = $self->findToken(uri => $uri); | |||||||||||||||||||||||||||
| 179 | 2 | ▶ | return $token if $token; # already taken | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||
| 181 | 2 | my $valuet = $d->{ValueType}; | |||||||||||||||||||||||||||
| 182 | 2 | ▶ | if($valuet eq XTP10_X509v3) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 183 | 2 | ▶ | { substr($uri, 0, 1) eq '#' | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 184 | or error __x"Keyinfo {id}: only inlined token references supported, got {uri}" | ||||||||||||||||||||||||||||
| 185 | , id => $id, uri => $uri; | ||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||
| 187 | my $binsec = $sec->{wsse_BinarySecurityToken} | ||||||||||||||||||||||||||||
| 188 | 2 | ▶ | or error __x"Keyinfo {id}: cannot find BinarySecurityToken" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 189 | , id => $id; | ||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||
| 191 | 2 | my $have_id = '#'.$binsec->{wsu_Id}; | |||||||||||||||||||||||||||
| 192 | 2 | ▶ | $have_id eq $uri | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 193 | or error __x"Keyinfo {id}: wrong BinarySecurityToken {uri}, expected {expect}" | ||||||||||||||||||||||||||||
| 194 | , id => $id, uri => $have_id, expect => $uri; | ||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||
| 196 | my $token = XML::Compile::WSS::SecToken::X509v3->new | ||||||||||||||||||||||||||||
| 197 | ( id => $binsec->{wsu_Id}, uri => $uri, type => $valuet | ||||||||||||||||||||||||||||
| 198 | , binary => wsm_decoded($binsec->{EncodingType}, $binsec->{_}) | ||||||||||||||||||||||||||||
| 199 | 2 | ); | |||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||
| 201 | 2 | $self->addToken($token); | |||||||||||||||||||||||||||
| 202 | 2 | return $token; | |||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||
| 205 | 0 | panic "Keyinfo $id: $valuet not supported"; | |||||||||||||||||||||||||||
| 206 | 3 | }; | |||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||
| 210 | sub builder($%) | ||||||||||||||||||||||||||||
| 211 | 5 | ▶ | { my ($self, $wss) = @_; | ||||||||||||||||||||||||||
|
Subroutine
builder: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 212 | 5 | my %args = ($self->config, @_); | |||||||||||||||||||||||||||
| 213 | 5 | ▶ | my $type = $args{publish_token} || 'SECTOKREF_URI'; | ||||||||||||||||||||||||||
|
Condition100%2/2
$args{'publish_token'} || 'SECTOKREF_URI'
MC/DC100%1/1
$args{'publish_token'} || 'SECTOKREF_URI'
$args{'publish_token'}
Truth table100%2/2
A
A= $args{'publish_token'}
| |||||||||||||||||||||||||||||
| 214 | 5 | ▶ | return undef if $type eq 'NO'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||
| 216 | 5 | my %str_handlers = | |||||||||||||||||||||||||||
| 217 | ( KEYNAME => '_make_keyname' | ||||||||||||||||||||||||||||
| 218 | , SECTOKREF_KEYID => '_make_sectokref_keyid' | ||||||||||||||||||||||||||||
| 219 | , SECTOKREF_URI => '_make_sectokref_uri' | ||||||||||||||||||||||||||||
| 220 | , INCLUDE_BY_REF => '_make_sectokref_uri' # name is pre 2.00 | ||||||||||||||||||||||||||||
| 221 | , X509DATA => '_make_x509data' | ||||||||||||||||||||||||||||
| 222 | ); | ||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||
| 224 | 5 | ▶ | my $handler = $str_handlers{$type} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 225 | or panic "unknown keyinfo type $type"; | ||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||
| 227 | 5 | my $nest = $self->$handler($wss, \%args); | |||||||||||||||||||||||||||
| 228 | 5 | my $ki_id = $args{keyinfo_id}; | |||||||||||||||||||||||||||
| 229 | sub { | ||||||||||||||||||||||||||||
| 230 | 4 | ▶ | my ($doc, $token, $sec) = @_; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 231 | 4 | +{ cho_ds_KeyName => [ $nest->($doc, $token, $sec) ] | |||||||||||||||||||||||||||
| 232 | , Id => $ki_id | ||||||||||||||||||||||||||||
| 233 | }; | ||||||||||||||||||||||||||||
| 234 | 5 | }; | |||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||
| 237 | sub _make_keyname($$$) | ||||||||||||||||||||||||||||
| 238 | 1 | ▶ | { my ($self, $wss, $args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_make_keyname: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 239 | sub { | ||||||||||||||||||||||||||||
| 240 | 1 | ▶ | my ($doc, $token, $sec) = @_; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||
| 241 | 1 | ▶ | my $name = $token->name | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 242 | or panic "token $token has no name for KEYNAME"; | ||||||||||||||||||||||||||||
| 243 | 1 | +{ ds_KeyName => $name }; | |||||||||||||||||||||||||||
| 244 | 1 | }; | |||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||
| 247 | sub _make_x509data($$$) | ||||||||||||||||||||||||||||
| 248 | 0 | ▶ | { my ($self, $wss, $args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_make_x509data: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||
| 249 | 0 | ▶ | my $as = $args->{x509data_type} || 'ASN1DER'; | ||||||||||||||||||||||||||
|
Condition0%0/2
$args->{'x509data_type'} || 'ASN1DER'
MC/DC0%0/1
$args->{'x509data_type'} || 'ASN1DER'
$args->{'x509data_type'}
Truth table0%0/2
A
A= $args->{'x509data_type'}
| |||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||
| 251 | my $put | ||||||||||||||||||||||||||||
| 252 | = $as eq 'ASN1DER' | ||||||||||||||||||||||||||||
| 253 | 0 | ▶ | ? sub { ds_X509Certificate => $_[0]->as_string(FORMAT_ASN1) } | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 254 | : $as eq 'SERIAL' | ||||||||||||||||||||||||||||
| 255 | 0 | ▶ | ? sub { ds_X509IssuerSerial => | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 256 | { ds_X509IssuerName => $_[0]->issuer | ||||||||||||||||||||||||||||
| 257 | , ds_X509SerialNumber => $_[0]->serial } | ||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||
| 259 | 0 | ▶ | : $as eq 'SKI' ? sub { ds_X509SKI => $_[0]->hash} | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 260 | 0 | ▶ | : $as eq 'SUBJECT' ? sub { ds_X509SubjectName => $_[0]->subject } | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 261 | 0 | ▶ | : error __x"write key-info as X509Data, unknown format `{name}'" | ||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||
| 262 | , name => $as; | ||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||
| 264 | # No idea how we can use this Cert Revocation List, ds_X509CRL | ||||||||||||||||||||||||||||
| 265 | # Other elements, not in ds:, not (yet) supported for writing | ||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||
| 267 | # This routine can handle an ARRAY, but the rest of the module | ||||||||||||||||||||||||||||
| 268 | # probably not. | ||||||||||||||||||||||||||||
| 269 | sub { | ||||||||||||||||||||||||||||
| 270 | 0 | ▶ | my ($doc, $token, $sec) = @_; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 271 | 0 | ▶ | my @data = map $put->($_) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 272 | , ref $token eq 'ARRAY' ? @$token : $token; | ||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||
| 274 | 0 | +{ seq_ds_X509IssuerSerial => \@data } | |||||||||||||||||||||||||||
| 275 | 0 | }; | |||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||
| 278 | sub _make_sectokref($$$) | ||||||||||||||||||||||||||||
| 279 | 4 | ▶ | { my ($self, $wss, $args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_make_sectokref: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 280 | 4 | my $refid = $args->{sectokref_id}; | |||||||||||||||||||||||||||
| 281 | 4 | my $usage = $args->{usage}; | |||||||||||||||||||||||||||
| 282 | 4 | my $refw = $wss->schema->writer('wsse:SecurityTokenReference' | |||||||||||||||||||||||||||
| 283 | , include_namespaces => 0); | ||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||
| 285 | sub { | ||||||||||||||||||||||||||||
| 286 | 3 | ▶ | my ($doc, $token, $sec, $payload) = @_; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 287 | 3 | my $ref = $refw->($doc, +{wsu_Id => $refid, wsse_Usage => $usage | |||||||||||||||||||||||||||
| 288 | , cho_any => $payload}); | ||||||||||||||||||||||||||||
| 289 | 3 | +{ 'wsse:SecurityTokenReference' => $ref }; | |||||||||||||||||||||||||||
| 290 | 4 | }; | |||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||
| 293 | sub _make_sectokref_keyid($$$) | ||||||||||||||||||||||||||||
| 294 | 1 | ▶ | { my ($self, $wss, $args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_make_sectokref_keyid: called CC=4 SCAR=14.2
| |||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||
| 296 | 1 | ▶ | my $valuet = $args->{keyid_value} || WSM11_PRINT_SHA1; | ||||||||||||||||||||||||||
|
Condition50%1/2
$args->{'keyid_value'} || 'http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1#ThumbprintSHA1'
MC/DC0%0/1
$args->{'keyid_value'} || 'http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1#ThumbprintSHA1'
$args->{'keyid_value'}
Truth table50%1/2
A
A= $args->{'keyid_value'}
| |||||||||||||||||||||||||||||
| 297 | 1 | ▶ | my $enct = $args->{keyid_encoding} || WSM10_BASE64; | ||||||||||||||||||||||||||
|
Condition50%1/2
$args->{'keyid_encoding'} || 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary'
MC/DC0%0/1
$args->{'keyid_encoding'} || 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary'
$args->{'keyid_encoding'}
Truth table50%1/2
A
A= $args->{'keyid_encoding'}
| |||||||||||||||||||||||||||||
| 298 | 1 | my $keyid = $args->{keyident_id}; | |||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||
| 300 | 1 | my $valuep; # first param is call is $token | |||||||||||||||||||||||||||
| 301 | 1 | ▶ | if($valuet eq WSM11_PRINT_SHA1) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 302 | 1 | ▶ | { $valuep = sub {shift->fingerprint or panic "token has no fingerprint" }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.2
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||
| 304 | 0 | else { panic "unsupported security token reference value type '$valuet'" } | |||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||
| 306 | 1 | ▶ | my $encp = sub { wsm_encoded $enct, $valuep->($_[0]) }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 307 | 1 | my $kidw = $wss->schema->writer('wsse:KeyIdentifier' | |||||||||||||||||||||||||||
| 308 | , include_namespaces=>0); | ||||||||||||||||||||||||||||
| 309 | 1 | my $refer = $self->_make_sectokref($wss, $args); | |||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||
| 311 | sub { | ||||||||||||||||||||||||||||
| 312 | 1 | ▶ | my ($doc, $token, $sec) = @_; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 313 | 1 | my $elem = $kidw->($doc | |||||||||||||||||||||||||||
| 314 | , +{ wsu_Id => $keyid, ValueType => $valuet, EncodingType => $enct | ||||||||||||||||||||||||||||
| 315 | , _ => $encp->($token) }); | ||||||||||||||||||||||||||||
| 316 | 1 | $refer->($doc, $token, $sec, +{'wsse:KeyIdentifier' => $elem}); | |||||||||||||||||||||||||||
| 317 | 1 | }; | |||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||
| 320 | sub _make_sectokref_uri($$$) | ||||||||||||||||||||||||||||
| 321 | 3 | ▶ | { my ($self, $wss, $args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_make_sectokref_uri: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||
| 323 | 3 | my $schema = $wss->schema; | |||||||||||||||||||||||||||
| 324 | 3 | ▶ | my $binenc = $args->{binsec_encoding} || WSM10_BASE64; | ||||||||||||||||||||||||||
|
Condition50%1/2
$args->{'binsec_encoding'} || 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary'
MC/DC0%0/1
$args->{'binsec_encoding'} || 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary'
$args->{'binsec_encoding'}
Truth table50%1/2
A
A= $args->{'binsec_encoding'}
| |||||||||||||||||||||||||||||
| 325 | 3 | my $kidw = $schema->writer('wsse:Reference', include_namespaces => 0); | |||||||||||||||||||||||||||
| 326 | 3 | my $refer = $self->_make_sectokref($wss, $args); | |||||||||||||||||||||||||||
| 327 | 3 | my $bstw = $schema->writer('wsse:BinarySecurityToken'); | |||||||||||||||||||||||||||
| 328 | 3 | my $default_uri = $args->{sectokref_uri}; | |||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||
| 330 | sub { | ||||||||||||||||||||||||||||
| 331 | 2 | ▶ | my ($doc, $token, $sec) = @_; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.8
| |||||||||||||||||||||||||||||
| 332 | 2 | ▶ | my $uri = $default_uri || $token->uri || '#abc'; | ||||||||||||||||||||||||||
|
Condition60%3/5
$default_uri || $token->uri || '#abc'
$default_uri or $token->uri
MC/DC0%0/2
$default_uri || $token->uri || '#abc'
$default_uri
$token->uri
Truth table66%2/3
A or B
A= $default_uriB= $token->uri
| |||||||||||||||||||||||||||||
| 333 | 2 | my $intern = $uri !~ m!^\w+://!; | |||||||||||||||||||||||||||
| 334 | 2 | my $type = $token->type; | |||||||||||||||||||||||||||
| 335 | 2 | my $elem = $kidw->($doc, +{ValueType => $type, URI => $uri} ); | |||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||
| 337 | 2 | ▶ | if($intern && $token->can('asBinary')) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$intern and $token->can("asBinary")
MC/DC0%0/2
$intern and $token->can("asBinary")
$intern
$token->can("asBinary")
Truth table33%1/3
A and B
A= $internB= $token->can("asBinary")
| |||||||||||||||||||||||||||||
| 338 | 2 | { (my $id = $uri) =~ s/^#//; | |||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||
| 340 | 2 | my $bst = $bstw->($doc, | |||||||||||||||||||||||||||
| 341 | +{ wsu_Id => $id | ||||||||||||||||||||||||||||
| 342 | , ValueType => $type | ||||||||||||||||||||||||||||
| 343 | , EncodingType => $binenc | ||||||||||||||||||||||||||||
| 344 | , _ => wsm_encoded($binenc, $token->asBinary) | ||||||||||||||||||||||||||||
| 345 | } ); | ||||||||||||||||||||||||||||
| 346 | 2 | $sec->appendChild($bst); | |||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||
| 348 | 2 | $refer->($doc, $token, $sec, +{'wsse:Reference' => $elem}); | |||||||||||||||||||||||||||
| 349 | 3 | }; | |||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||
| 352 | #----------------- | ||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||
| 354 | 5 | 1; | |||||||||||||||||||||||||||