|  line  | 
 stmt  | 
 bran  | 
 cond  | 
 sub  | 
 pod  | 
 time  | 
 code  | 
| 
1
 | 
  
 
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #+##############################################################################  | 
| 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #                                                                              #  | 
| 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 # File: Authen/Credential.pm                                                   #  | 
| 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #                                                                              #  | 
| 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 # Description: abstraction of a credential                                     #  | 
| 
6
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #                                                                              #  | 
| 
7
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #-##############################################################################  | 
| 
8
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
9
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #  | 
| 
10
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 # module definition  | 
| 
11
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #  | 
| 
12
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
13
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 package Authen::Credential;  | 
| 
14
 | 
1
 | 
 
 | 
 
 | 
  
1
  
 | 
 
 | 
69957
 | 
 use strict;  | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
2
 | 
    | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
31
 | 
    | 
| 
15
 | 
1
 | 
 
 | 
 
 | 
  
1
  
 | 
 
 | 
5
 | 
 use warnings;  | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
2
 | 
    | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
72
 | 
    | 
| 
16
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 our $VERSION  = "1.2";  | 
| 
17
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 our $REVISION = sprintf("%d.%02d", q$Revision: 1.12 $ =~ /(\d+)\.(\d+)/);  | 
| 
18
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
19
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #  | 
| 
20
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 # used modules  | 
| 
21
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #  | 
| 
22
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
23
 | 
1
 | 
 
 | 
 
 | 
  
1
  
 | 
 
 | 
504
 | 
 use No::Worries::Die qw(dief);  | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
18421
 | 
    | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
6
 | 
    | 
| 
24
 | 
1
 | 
 
 | 
 
 | 
  
1
  
 | 
 
 | 
106
 | 
 use Params::Validate qw(validate_with validate_pos :types);  | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
2
 | 
    | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
153
 | 
    | 
| 
25
 | 
1
 | 
 
 | 
 
 | 
  
1
  
 | 
 
 | 
474
 | 
 use URI::Escape qw(uri_escape uri_unescape);  | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
1459
 | 
    | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
1059
 | 
    | 
| 
26
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
27
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #  | 
| 
28
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 # global variables  | 
| 
29
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #  | 
| 
30
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
31
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 our(  | 
| 
32
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     $_IdRe,           # regexp matching an identifier  | 
| 
33
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     $_ValChars,       # set of all allowed value characters  | 
| 
34
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     $_SepChars,       # set of all allowed separator characters  | 
| 
35
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     %_LoadedModule,   # hash of successfully loaded modules  | 
| 
36
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     %ValidationSpec,  # per-scheme Params::Validate specification  | 
| 
37
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     %Preparator,      # per-scheme and target preparator code  | 
| 
38
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 );  | 
| 
39
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
40
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 $_IdRe = qr{[a-z][a-z0-9]*};  | 
| 
41
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 $_ValChars = q{a-zA-Z0-9/\-\+\_\~\.\:};  | 
| 
42
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 $_SepChars = q{\,\ };  | 
| 
43
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
44
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #+++############################################################################  | 
| 
45
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #                                                                              #  | 
| 
46
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 # helper functions                                                             #  | 
| 
47
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #                                                                              #  | 
| 
48
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #---############################################################################  | 
| 
49
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
50
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #  | 
| 
51
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 # make sure a module is loaded  | 
| 
52
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #  | 
| 
53
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
54
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub _require ($) {  | 
| 
55
 | 
19
 | 
 
 | 
 
 | 
  
19
  
 | 
 
 | 
35
 | 
     my($module) = @_;  | 
| 
56
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
57
 | 
19
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
55
 | 
     return if $_LoadedModule{$module};  | 
| 
58
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
304
 | 
     eval("require $module"); ## no critic 'ProhibitStringyEval'  | 
| 
59
 | 
4
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
25
 | 
     if ($@) {  | 
| 
60
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
20
 | 
         $@ =~ s/\s+at\s.+?\sline\s+\d+\.?$//;  | 
| 
61
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
6
 | 
         dief("failed to load %s: %s", $module, $@);  | 
| 
62
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     } else {  | 
| 
63
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
10
 | 
         $_LoadedModule{$module} = 1;  | 
| 
64
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
65
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
66
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
67
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #  | 
| 
68
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 # check that the data matches the per-scheme specification  | 
| 
69
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #  | 
| 
70
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
71
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub _check ($@) {  | 
| 
72
 | 
27
 | 
 
 | 
 
 | 
  
27
  
 | 
 
 | 
39
 | 
     my($scheme);  | 
| 
73
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
74
 | 
27
 | 
 
 | 
 
 | 
 
 | 
 
 | 
40
 | 
     $scheme = shift(@_);  | 
| 
75
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     dief("invalid credential scheme (missing validation spec): %s", $scheme)  | 
| 
76
 | 
27
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
80
 | 
         unless $ValidationSpec{$scheme};  | 
| 
77
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     return(validate_with(  | 
| 
78
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         params => \@_,  | 
| 
79
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         spec => {  | 
| 
80
 | 
27
 | 
 
 | 
 
 | 
 
 | 
 
 | 
52
 | 
             %{ $ValidationSpec{$scheme} },  | 
| 
 
 | 
27
 | 
 
 | 
 
 | 
 
 | 
 
 | 
1018
 | 
    | 
| 
81
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             scheme => {  | 
| 
82
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                 type    => SCALAR,  | 
| 
83
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                 regex   => qr/^\Q$scheme\E$/,  | 
| 
84
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                 default => $scheme,  | 
| 
85
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             },  | 
| 
86
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         },  | 
| 
87
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         stack_skip => 2,  | 
| 
88
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     ));  | 
| 
89
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
90
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
91
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #+++############################################################################  | 
| 
92
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #                                                                              #  | 
| 
93
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 # object oriented interface                                                    #  | 
| 
94
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #                                                                              #  | 
| 
95
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #---############################################################################  | 
| 
96
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
97
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #  | 
| 
98
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 # constructors  | 
| 
99
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #  | 
| 
100
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
101
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub new : method {  | 
| 
102
 | 
37
 | 
 
 | 
 
 | 
  
37
  
 | 
  
1
  
 | 
376
 | 
     my($class, %option, $cc, $scheme);  | 
| 
103
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
104
 | 
37
 | 
 
 | 
 
 | 
 
 | 
 
 | 
65
 | 
     $class = shift(@_);  | 
| 
105
 | 
37
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
82
 | 
     if ($class eq __PACKAGE__) {  | 
| 
106
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         # toplevel constructor  | 
| 
107
 | 
19
 | 
 
 | 
 
 | 
 
 | 
 
 | 
396
 | 
         %option = validate_with(  | 
| 
108
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             params => \@_,  | 
| 
109
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             spec => {  | 
| 
110
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                 scheme => {  | 
| 
111
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                     type    => SCALAR,  | 
| 
112
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                     regex   => $_IdRe,  | 
| 
113
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                     default => "none",  | 
| 
114
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                 },  | 
| 
115
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             },  | 
| 
116
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             allow_extra => 1,  | 
| 
117
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         );  | 
| 
118
 | 
19
 | 
 
 | 
 
 | 
 
 | 
 
 | 
337
 | 
         $cc = $class . "::" . $option{scheme};  | 
| 
119
 | 
19
 | 
 
 | 
 
 | 
 
 | 
 
 | 
57
 | 
         _require($cc);  | 
| 
120
 | 
18
 | 
 
 | 
 
 | 
 
 | 
 
 | 
75
 | 
         return($cc->new(\%option));  | 
| 
121
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
122
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     # inherited constructor  | 
| 
123
 | 
18
 | 
 
 | 
 
 | 
 
 | 
 
 | 
37
 | 
     $scheme = substr($class, length(__PACKAGE__) + 2);  | 
| 
124
 | 
18
 | 
 
 | 
 
 | 
 
 | 
 
 | 
36
 | 
     return(bless({ _check($scheme, @_) }, $class));  | 
| 
125
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
126
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
127
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub parse : method {  | 
| 
128
 | 
23
 | 
 
 | 
 
 | 
  
23
  
 | 
  
1
  
 | 
8738
 | 
     my($class, $string, @list, %option);  | 
| 
129
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
130
 | 
23
 | 
 
 | 
 
 | 
 
 | 
 
 | 
50
 | 
     $class = shift(@_);  | 
| 
131
 | 
23
 | 
  
 50
  
 | 
  
 33
  
 | 
 
 | 
 
 | 
140
 | 
     validate_pos(@_, { type => SCALAR })  | 
| 
 
 | 
 
 | 
 
 | 
  
 33
  
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
132
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         unless @_ == 1 and defined($_[0]) and ref($_[0]) eq "";  | 
| 
133
 | 
23
 | 
 
 | 
 
 | 
 
 | 
 
 | 
42
 | 
     $string = shift(@_);  | 
| 
134
 | 
23
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
51
 | 
     return($class->new()) if $string eq "";  | 
| 
135
 | 
22
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
187
 | 
     dief("invalid credential string: %s", $string)  | 
| 
136
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         unless $string =~ /^[${_ValChars}${_SepChars}\%\=]+$/o;  | 
| 
137
 | 
21
 | 
 
 | 
 
 | 
 
 | 
 
 | 
113
 | 
     @list = split(/[${_SepChars}]+/o, $string);  | 
| 
138
 | 
21
 | 
  
100
  
 | 
  
100
  
 | 
 
 | 
 
 | 
157
 | 
     dief("invalid credential string: %s", $string)  | 
| 
139
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         unless @list and $list[0] =~ /^($_IdRe)$/o;  | 
| 
140
 | 
19
 | 
 
 | 
 
 | 
 
 | 
 
 | 
58
 | 
     %option = (scheme => shift(@list));  | 
| 
141
 | 
19
 | 
 
 | 
 
 | 
 
 | 
 
 | 
40
 | 
     foreach my $kv (@list) {  | 
| 
142
 | 
26
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
235
 | 
         if ($kv =~ /^($_IdRe)\=([$_ValChars\%]*)$/o) {  | 
| 
143
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             dief("duplicate credential key: %s", $1)  | 
| 
144
 | 
24
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
71
 | 
                 if exists($option{$1});  | 
| 
145
 | 
23
 | 
 
 | 
 
 | 
 
 | 
 
 | 
58
 | 
             $option{$1} = uri_unescape($2);  | 
| 
146
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         } else {  | 
| 
147
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
8
 | 
             dief("invalid credential key=value: %s", $kv);  | 
| 
148
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         }  | 
| 
149
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
150
 | 
16
 | 
 
 | 
 
 | 
 
 | 
 
 | 
150
 | 
     return($class->new(\%option));  | 
| 
151
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
152
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
153
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #  | 
| 
154
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 # transformers  | 
| 
155
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #  | 
| 
156
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
157
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub hash : method {  | 
| 
158
 | 
  
0
  
 | 
 
 | 
 
 | 
  
0
  
 | 
  
1
  
 | 
0
 | 
     my($self);  | 
| 
159
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
160
 | 
  
0
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
0
 | 
     $self = shift(@_);  | 
| 
161
 | 
  
0
  
 | 
  
  0
  
 | 
 
 | 
 
 | 
 
 | 
0
 | 
     validate_pos(@_) if @_;  | 
| 
162
 | 
  
0
  
 | 
  
  0
  
 | 
 
 | 
 
 | 
 
 | 
0
 | 
     return($self) unless wantarray();  | 
| 
163
 | 
  
0
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
0
 | 
     return(%{ $self });  | 
| 
 
 | 
  
0
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
0
 | 
    | 
| 
164
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
165
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
166
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub string : method {  | 
| 
167
 | 
3
 | 
 
 | 
 
 | 
  
3
  
 | 
  
1
  
 | 
92
 | 
     my($self, @parts);  | 
| 
168
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
169
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
4
 | 
     $self = shift(@_);  | 
| 
170
 | 
3
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
12
 | 
     validate_pos(@_) if @_;  | 
| 
171
 | 
3
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
7
 | 
     dief("invalid credential: no scheme") unless $self->{scheme};  | 
| 
172
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
8
 | 
     @parts = ($self->{scheme});  | 
| 
173
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
4
 | 
     foreach my $key (sort(keys(%{ $self }))) {  | 
| 
 
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
16
 | 
    | 
| 
174
 | 
6
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
329
 | 
         next if $key eq "scheme";  | 
| 
175
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
18
 | 
         push(@parts, $key . "=" . uri_escape($self->{$key}, "^$_ValChars"));  | 
| 
176
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
177
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
21
 | 
     return(join(" ", @parts));  | 
| 
178
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
179
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
180
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #  | 
| 
181
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 # accessors  | 
| 
182
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #  | 
| 
183
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
184
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 foreach my $name (qw(scheme)) {  | 
| 
185
 | 
1
 | 
 
 | 
 
 | 
  
1
  
 | 
 
 | 
17
 | 
     no strict "refs";  | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
3
 | 
    | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
279
 | 
    | 
| 
186
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     *{ $name } = sub {  | 
| 
187
 | 
11
 | 
 
 | 
 
 | 
  
11
  
 | 
 
 | 
16
 | 
         my($self);  | 
| 
188
 | 
11
 | 
 
 | 
 
 | 
 
 | 
 
 | 
15
 | 
         $self = shift(@_);  | 
| 
189
 | 
11
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
24
 | 
         validate_pos(@_) if @_;  | 
| 
190
 | 
11
 | 
 
 | 
 
 | 
 
 | 
 
 | 
35
 | 
         return($self->{$name});  | 
| 
191
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     };  | 
| 
192
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
193
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
194
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #  | 
| 
195
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 # generic check method using the Params::Validate specification  | 
| 
196
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #  | 
| 
197
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
198
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub check : method {  | 
| 
199
 | 
9
 | 
 
 | 
 
 | 
  
9
  
 | 
  
1
  
 | 
3031
 | 
     my($self);  | 
| 
200
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
201
 | 
9
 | 
 
 | 
 
 | 
 
 | 
 
 | 
18
 | 
     $self = shift(@_);  | 
| 
202
 | 
9
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
21
 | 
     validate_pos(@_) if @_;  | 
| 
203
 | 
9
 | 
 
 | 
 
 | 
 
 | 
 
 | 
34
 | 
     return(_check($self->scheme(), $self));  | 
| 
204
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
205
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
206
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #  | 
| 
207
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 # generic prepare method using the declared preparators  | 
| 
208
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #  | 
| 
209
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
210
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub prepare : method {  | 
| 
211
 | 
2
 | 
 
 | 
 
 | 
  
2
  
 | 
  
1
  
 | 
643
 | 
     my($self, $target, $preparator);  | 
| 
212
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
213
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
4
 | 
     $self = shift(@_);  | 
| 
214
 | 
2
 | 
  
 50
  
 | 
  
 33
  
 | 
 
 | 
 
 | 
19
 | 
     validate_pos(@_, { type => SCALAR })  | 
| 
 
 | 
 
 | 
 
 | 
  
 33
  
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
215
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         unless @_ == 1 and defined($_[0]) and ref($_[0]) eq "";  | 
| 
216
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
3
 | 
     $target = shift(@_);  | 
| 
217
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
6
 | 
     $preparator = $Preparator{$self->scheme()}{$target};  | 
| 
218
 | 
2
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
13
 | 
     return($preparator->($self)) if $preparator;  | 
| 
219
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     dief("invalid %s credential preparation target: %s",  | 
| 
220
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
          $self->scheme(), $target);  | 
| 
221
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
222
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
223
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 1;  | 
| 
224
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
225
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 __DATA__  |