line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Connector::Wrapper |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# Wrapper class to filter access to a connector by a prefix |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# Written by Oliver Welter for the OpenXPKI project 2012 |
6
|
|
|
|
|
|
|
# |
7
|
|
|
|
|
|
|
# TODO: To make this really transparent it need to be inherited |
8
|
|
|
|
|
|
|
# from Connector and implement the prefix stuff |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use strict; |
12
|
13
|
|
|
13
|
|
84
|
use warnings; |
|
13
|
|
|
|
|
25
|
|
|
13
|
|
|
|
|
360
|
|
13
|
13
|
|
|
13
|
|
62
|
use English; |
|
13
|
|
|
|
|
24
|
|
|
13
|
|
|
|
|
274
|
|
14
|
13
|
|
|
13
|
|
71
|
use Moose; |
|
13
|
|
|
|
|
25
|
|
|
13
|
|
|
|
|
72
|
|
15
|
13
|
|
|
13
|
|
3969
|
use Data::Dumper; |
|
13
|
|
|
|
|
23
|
|
|
13
|
|
|
|
|
81
|
|
16
|
13
|
|
|
13
|
|
72026
|
|
|
13
|
|
|
|
|
5854
|
|
|
13
|
|
|
|
|
8044
|
|
17
|
|
|
|
|
|
|
extends 'Connector'; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has 'BASECONNECTOR' => ( |
20
|
|
|
|
|
|
|
is => 'ro', |
21
|
|
|
|
|
|
|
required => 1, |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
has '+LOCATION' => ( required => 0 ); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# Build arrayref from target the first time it is required |
27
|
|
|
|
|
|
|
has _target => ( is => 'rw', isa => 'ArrayRef|Undef', writer => '__target' ); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
has TARGET => ( |
30
|
|
|
|
|
|
|
is => 'ro', |
31
|
|
|
|
|
|
|
isa => 'Connector::Types::Key|ArrayRef|Undef', |
32
|
|
|
|
|
|
|
trigger => sub { |
33
|
|
|
|
|
|
|
my ($self, $target) = @_; |
34
|
|
|
|
|
|
|
my @target = $self->_build_path( $target ); |
35
|
|
|
|
|
|
|
$self->__target( \@target ); |
36
|
|
|
|
|
|
|
# Force rebuild of prefix |
37
|
|
|
|
|
|
|
$self->PREFIX( $self->PREFIX() ); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# override the prefix trigger to prepend the wrapper prefix |
42
|
|
|
|
|
|
|
has '+PREFIX' => ( |
43
|
|
|
|
|
|
|
trigger => sub { |
44
|
|
|
|
|
|
|
my ($self, $prefix, $old_prefix) = @_; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
if (not $self->TARGET) { |
47
|
|
|
|
|
|
|
$self->log()->debug( 'prefix before target - skipping!' ) ; |
48
|
|
|
|
|
|
|
return; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
if (defined $prefix) { |
52
|
|
|
|
|
|
|
my @path = $self->_build_path($prefix); |
53
|
|
|
|
|
|
|
$self->__prefix_path( [ @{$self->_target()}, @path ]); |
54
|
|
|
|
|
|
|
} else { |
55
|
|
|
|
|
|
|
$self->__prefix_path( $self->_target() ); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
); |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
my $self = shift; |
63
|
|
|
|
|
|
|
my $call = shift; |
64
|
26
|
|
|
26
|
|
31
|
my $path = shift; |
65
|
26
|
|
|
|
|
31
|
my @args = @_; |
66
|
26
|
|
|
|
|
33
|
|
67
|
26
|
|
|
|
|
37
|
my @fullpath = $self->_build_path_with_prefix( $path ); |
68
|
|
|
|
|
|
|
|
69
|
26
|
|
|
|
|
57
|
unshift @args, \@fullpath; |
70
|
|
|
|
|
|
|
|
71
|
26
|
|
|
|
|
50
|
return $self->BASECONNECTOR()->$call( @args ); |
72
|
|
|
|
|
|
|
} |
73
|
26
|
|
|
|
|
662
|
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
# Proxy calls |
76
|
|
|
|
|
|
|
my $self = shift; |
77
|
|
|
|
|
|
|
unshift @_, 'get'; |
78
|
|
|
|
|
|
|
return $self->_route_call( @_ ); |
79
|
22
|
|
|
22
|
1
|
55
|
} |
80
|
22
|
|
|
|
|
40
|
|
81
|
22
|
|
|
|
|
42
|
my $self = shift; |
82
|
|
|
|
|
|
|
unshift @_, 'get_list'; |
83
|
|
|
|
|
|
|
return $self->_route_call( @_ ); |
84
|
|
|
|
|
|
|
} |
85
|
2
|
|
|
2
|
1
|
4
|
|
86
|
2
|
|
|
|
|
4
|
my $self = shift; |
87
|
2
|
|
|
|
|
5
|
unshift @_, 'get_size'; |
88
|
|
|
|
|
|
|
return $self->_route_call( @_ ); |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
92
|
0
|
|
|
|
|
0
|
unshift @_, 'get_hash'; |
93
|
0
|
|
|
|
|
0
|
return $self->_route_call( @_ ); |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
my $self = shift; |
97
|
2
|
|
|
2
|
1
|
3
|
unshift @_, 'get_keys'; |
98
|
2
|
|
|
|
|
5
|
return $self->_route_call( @_ ); |
99
|
2
|
|
|
|
|
4
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
my $self = shift; |
102
|
|
|
|
|
|
|
unshift @_, 'set'; |
103
|
0
|
|
|
0
|
1
|
|
return $self->_route_call( @_ ); |
104
|
0
|
|
|
|
|
|
} |
105
|
0
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
my $self = shift; |
107
|
|
|
|
|
|
|
unshift @_, 'get_meta'; |
108
|
|
|
|
|
|
|
return $self->_route_call( @_ ); |
109
|
0
|
|
|
0
|
1
|
|
} |
110
|
0
|
|
|
|
|
|
|
111
|
0
|
|
|
|
|
|
my $self = shift; |
112
|
|
|
|
|
|
|
unshift @_, 'exists'; |
113
|
|
|
|
|
|
|
return $self->_route_call( @_ ); |
114
|
|
|
|
|
|
|
} |
115
|
0
|
|
|
0
|
1
|
|
|
116
|
0
|
|
|
|
|
|
no Moose; |
117
|
0
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
1; |
120
|
|
|
|
|
|
|
|
121
|
0
|
|
|
0
|
1
|
|
=head1 Name |
122
|
0
|
|
|
|
|
|
|
123
|
0
|
|
|
|
|
|
Connector |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head1 Description |
126
|
13
|
|
|
13
|
|
118
|
|
|
13
|
|
|
|
|
34
|
|
|
13
|
|
|
|
|
72
|
|
127
|
|
|
|
|
|
|
This provides a wrapper to the connector with a fixed prefix. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head2 Supported methods |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
get, get_list, get_size, get_hash, get_keys, set, meta |