| 1 | package Hadoop::Oozie::DelegationTokenContainer; | ||||||||||||||||||||||||||||
| 2 | 1 | $Hadoop::Oozie::DelegationTokenContainer::VERSION = '0.002'; | |||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use MIME::Base64 qw( encode_base64url ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use Hadoop::IO::DelegationToken::Reader qw( | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | parseTokenStorageStream | ||||||||||||||||||||||||||||
| 11 | vlong | ||||||||||||||||||||||||||||
| 12 | 1 | ); | |||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use namespace::clean; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 0 | ▶ | sub new_from_file { | ||||||||||||||||||||||||||
|
Subroutine
new_from_file: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 17 | 0 | my ($class, $file) = @_; | |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 0 | ▶ | open my $fh, '<', $file or croak "Can't open $file for reading: $!"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 20 | 0 | binmode($fh); | |||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 0 | return bless parseTokenStorageStream( $fh ), $class; | |||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 0 | ▶ | sub tokens { return keys %{ shift->{token} }; } | ||||||||||||||||||||||||||
|
Subroutine
tokens: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 0 | ▶ | sub base64token_for { | ||||||||||||||||||||||||||
|
Subroutine
base64token_for: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 28 | 0 | my ( $self, $query ) = @_; | |||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 0 | my $token = $self->token_for($query); | |||||||||||||||||||||||||||
| 31 | return encode_base64url( | ||||||||||||||||||||||||||||
| 32 | join '', | ||||||||||||||||||||||||||||
| 33 | map vlong(length) . $_, | ||||||||||||||||||||||||||||
| 34 | 0 | map $token->{$_}, | |||||||||||||||||||||||||||
| 35 | qw( identifier password kind service ) | ||||||||||||||||||||||||||||
| 36 | ); | ||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 0 | ▶ | sub token_for { | ||||||||||||||||||||||||||
|
Subroutine
token_for: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 40 | 0 | my ( $self, $query ) = @_; | |||||||||||||||||||||||||||
| 41 | 0 | ▶ | croak "Query can't be empty" if !defined $query || !length $query; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $query and length $query
MC/DC0%0/2
defined $query and length $query
defined $query
length $query
Truth table0%0/3
A and B
A= defined $queryB= length $query
| |||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | # pick the first matching key if given an non-existing key | ||||||||||||||||||||||||||||
| 44 | my $key = exists $self->{token}{$query} | ||||||||||||||||||||||||||||
| 45 | ? $query | ||||||||||||||||||||||||||||
| 46 | 0 | ▶ | : ( grep /$query/, sort keys %{ $self->{token} } )[0]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 0 | ▶ | croak "No token found for '$query'" if !defined $key; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 49 | 0 | my $token = $self->{token}{$key}; | |||||||||||||||||||||||||||
| 50 | 0 | return $token; | |||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 1 | 1; | |||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | __END__ | ||||||||||||||||||||||||||||