From 5b9e381988ca256d7fc49106c1b0feb18e32fd59 Mon Sep 17 00:00:00 2001 From: dakkar Date: Tue, 30 Dec 2014 10:45:58 +0000 Subject: whitespace fixes --- lib/Net/Hawk/Client.pm | 109 +++++++++++++++++++++++++------------------------ 1 file changed, 55 insertions(+), 54 deletions(-) diff --git a/lib/Net/Hawk/Client.pm b/lib/Net/Hawk/Client.pm index 288252c..5f649c4 100644 --- a/lib/Net/Hawk/Client.pm +++ b/lib/Net/Hawk/Client.pm @@ -64,9 +64,9 @@ package Net::Hawk::Client { %artifacts, %artifacts, ) - ~ (%artifacts ?? sprintf(', hash="%s"',%artifacts) !! '') - ~ ($has_ext ?? sprintf(', ext="%s"', %artifacts.trans(['\\','"']=>['\\\\','\\"']) ) !! '' ) - ~ sprintf(', mac="%s"',$mac); + ~ (%artifacts ?? sprintf(', hash="%s"',%artifacts) !! '') + ~ ($has_ext ?? sprintf(', ext="%s"', %artifacts.trans(['\\','"']=>['\\\\','\\"']) ) !! '' ) + ~ sprintf(', mac="%s"',$mac); if (%artifacts) { $header ~= sprintf(', app="%s"', %artifacts); @@ -79,69 +79,70 @@ package Net::Hawk::Client { field => $header, artifacts => %artifacts, }; - } + }; - my sub get_header(Str:D $key, @headers) returns Str { - @headers \ - ==> grep { .key eq $key } \ - ==> map { .value } \ - ==> join ','; - } - our sub authenticate( + my sub get_header(Str:D $key, @headers) returns Str { + @headers \ + ==> grep { .key eq $key } \ + ==> map { .value } \ + ==> join ','; + }; + our sub authenticate( Array:D $headers, Hash:D $credentials, - Hash $artifacts?, - Hash $options?, - ) returns Bool { - - my $www_auth = get_header('www-authenticate',$headers); - - if ($www_auth) { - my $attributes = try { - $attributes = parse_authorization_header( - $www_auth,, - ); - }; - return False unless $attributes; - - if ($attributes) { - my $tsm = calculate_ts_mac( - +$attributes,$credentials, - ); - return False unless $tsm eq $attributes; - } - } + Hash $artifacts?, + Hash $options?, + ) returns Bool { - my $serv_auth = get_header('server-authorization',$headers); - return True unless $serv_auth || $options; + my $www_auth = get_header('www-authenticate',$headers); + if ($www_auth) { my $attributes = try { - parse_authorization_header( - $serv_auth, - , + $attributes = parse_authorization_header( + $www_auth,, ); }; return False unless $attributes; - my $mac = calculate_mac( - 'response', - $credentials, - %( - %$artifacts, - ext => $attributes, - hash => $attributes, - ), - ); - return False unless $mac eq $attributes; + if ($attributes) { + my $tsm = calculate_ts_mac( + +$attributes,$credentials, + ); + return False unless $tsm eq $attributes; + } + } - return True unless defined $options; - return False unless $attributes; + my $serv_auth = get_header('server-authorization',$headers); + return True unless $serv_auth || $options; - my $calculated_hash = calculate_payload_hash( - $options, - $credentials, - get_header('content-type',$headers), + my $attributes = try { + parse_authorization_header( + $serv_auth, + , ); - return $calculated_hash eq $attributes; }; + return False unless $attributes; + + my $mac = calculate_mac( + 'response', + $credentials, + %( + %$artifacts, + ext => $attributes, + hash => $attributes, + ), + ); + return False unless $mac eq $attributes; + + return True unless defined $options; + return False unless $attributes; + + my $calculated_hash = calculate_payload_hash( + $options, + $credentials, + get_header('content-type',$headers), + ); + return $calculated_hash eq $attributes; + }; + } -- cgit v1.2.3