| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Net::DSML::Control; |
|
2
|
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
3303
|
use warnings; |
|
|
3
|
|
|
|
|
8
|
|
|
|
3
|
|
|
|
|
110
|
|
|
4
|
3
|
|
|
3
|
|
18
|
use strict; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
103
|
|
|
5
|
|
|
|
|
|
|
#use Carp; |
|
6
|
3
|
|
|
3
|
|
1322
|
use Class::Std::Utils; |
|
|
3
|
|
|
|
|
4829
|
|
|
|
3
|
|
|
|
|
22
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# Copyright (c) 2007 Clif Harden . All rights reserved. |
|
9
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or |
|
10
|
|
|
|
|
|
|
# modify it under the same terms as Perl itself. |
|
11
|
|
|
|
|
|
|
|
|
12
|
3
|
|
|
3
|
|
154
|
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); |
|
|
3
|
|
|
|
|
7
|
|
|
|
3
|
|
|
|
|
412
|
|
|
13
|
3
|
|
|
3
|
|
18
|
use version; $VERSION = version->new('0.002'); |
|
|
3
|
|
|
|
|
8
|
|
|
|
3
|
|
|
|
|
18
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
{ |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
BEGIN |
|
18
|
|
|
|
|
|
|
{ |
|
19
|
3
|
|
|
3
|
|
268
|
use Exporter (); |
|
|
3
|
|
|
|
|
7
|
|
|
|
3
|
|
|
|
|
133
|
|
|
20
|
|
|
|
|
|
|
|
|
21
|
3
|
|
|
3
|
|
57
|
@ISA = qw(Exporter); |
|
22
|
3
|
|
|
|
|
8
|
@EXPORT = qw(); |
|
23
|
3
|
|
|
|
|
8
|
%EXPORT_TAGS = (); |
|
24
|
3
|
|
|
|
|
5686
|
@EXPORT_OK = (); |
|
25
|
|
|
|
|
|
|
} |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my %errMsg; # no error this will be a null string. |
|
28
|
|
|
|
|
|
|
my %controls; # Actual xml data string. |
|
29
|
|
|
|
|
|
|
my %default; # will contain the initial control string if there is one. |
|
30
|
|
|
|
|
|
|
# |
|
31
|
|
|
|
|
|
|
# Method new |
|
32
|
|
|
|
|
|
|
# |
|
33
|
|
|
|
|
|
|
# The method new creates a new DSML Control oject. |
|
34
|
|
|
|
|
|
|
# |
|
35
|
|
|
|
|
|
|
# There are four possible input options. |
|
36
|
|
|
|
|
|
|
# Input option "control": Sets the oid number of the control |
|
37
|
|
|
|
|
|
|
# Input option "value": Sets the control value data. |
|
38
|
|
|
|
|
|
|
# Input option "valuetype": Sets the xsd type for the control value. |
|
39
|
|
|
|
|
|
|
# Input option "criticality": Sets the criticality variable to the input |
|
40
|
|
|
|
|
|
|
# value, either true or false. |
|
41
|
|
|
|
|
|
|
# |
|
42
|
|
|
|
|
|
|
# |
|
43
|
|
|
|
|
|
|
# $control = Net::DSML::Control->new( { control => 1.2.840.113556.1.4.619, |
|
44
|
|
|
|
|
|
|
# valuetype => base64Binary, |
|
45
|
|
|
|
|
|
|
# criticality => true, |
|
46
|
|
|
|
|
|
|
# value => RFNNTYyLJA== } ); |
|
47
|
|
|
|
|
|
|
# |
|
48
|
|
|
|
|
|
|
# Method output; Returns a new DSML object. |
|
49
|
|
|
|
|
|
|
# |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub new |
|
52
|
|
|
|
|
|
|
{ |
|
53
|
19
|
|
|
19
|
1
|
3203
|
my ($class, $opt) = @_; |
|
54
|
19
|
|
|
|
|
55
|
my $self = bless anon_scalar(),$class; |
|
55
|
19
|
|
|
|
|
105
|
my $id = ident($self); |
|
56
|
19
|
|
|
|
|
26
|
my $result; |
|
57
|
|
|
|
|
|
|
my $value; |
|
58
|
0
|
|
|
|
|
0
|
my $valuetype; |
|
59
|
0
|
|
|
|
|
0
|
my $criticality; |
|
60
|
0
|
|
|
|
|
0
|
my $control; |
|
61
|
|
|
|
|
|
|
# |
|
62
|
|
|
|
|
|
|
# Initailize data to a default values. |
|
63
|
|
|
|
|
|
|
# |
|
64
|
19
|
|
|
|
|
53
|
$errMsg{$id} = ""; # no error |
|
65
|
19
|
|
|
|
|
38
|
$controls{$id} = []; # Actual control xml data string(s). |
|
66
|
19
|
|
|
|
|
55
|
$default{$id}->{default} = ""; |
|
67
|
|
|
|
|
|
|
|
|
68
|
19
|
100
|
|
|
|
50
|
if ( $opt ) |
|
69
|
|
|
|
|
|
|
{ |
|
70
|
|
|
|
|
|
|
|
|
71
|
12
|
50
|
|
|
|
38
|
if ( !defined($opt->{control}) ) |
|
72
|
|
|
|
|
|
|
{ |
|
73
|
0
|
|
|
|
|
0
|
$errMsg{$id} = "Subroutine Control required type oid value is not defined."; |
|
74
|
0
|
|
|
|
|
0
|
return $self; |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
12
|
100
|
|
|
|
34
|
$control = (ref($opt->{control}) ? ${$opt->{control}} : $opt->{control}); |
|
|
2
|
|
|
|
|
4
|
|
|
78
|
12
|
100
|
|
|
|
40
|
$valuetype = (ref($opt->{valuetype}) ? ${$opt->{valuetype}} : $opt->{valuetype}) if ( $opt->{valuetype}); |
|
|
1
|
100
|
|
|
|
3
|
|
|
79
|
12
|
100
|
|
|
|
33
|
$criticality = (ref($opt->{criticality}) ? ${$opt->{criticality}} : $opt->{criticality}) if ( $opt->{criticality}); |
|
|
1
|
100
|
|
|
|
3
|
|
|
80
|
12
|
100
|
|
|
|
39
|
$value = (ref($opt->{value}) ? ${$opt->{value}} : $opt->{value}); |
|
|
1
|
|
|
|
|
2
|
|
|
81
|
|
|
|
|
|
|
|
|
82
|
12
|
50
|
66
|
|
|
60
|
if ( $opt->{criticality} && !($criticality =~ /^(true)||(false)$/) ) |
|
83
|
|
|
|
|
|
|
{ |
|
84
|
0
|
|
|
|
|
0
|
$errMsg{$id} = "The Control`s criticality is not defined properly."; |
|
85
|
0
|
|
|
|
|
0
|
return $self; |
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
|
|
88
|
12
|
50
|
66
|
|
|
57
|
if ( $opt->{valuetype} && !($valuetype =~ /^(string)||(anyURI)||(base64Binary)$/) ) |
|
89
|
|
|
|
|
|
|
{ |
|
90
|
0
|
|
|
|
|
0
|
$errMsg{$id} = "The Control`s valuetype is not defined properly."; |
|
91
|
0
|
|
|
|
|
0
|
return $self; |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
|
|
94
|
12
|
50
|
66
|
|
|
132
|
if ( $opt->{value} && !$opt->{valuetype}) |
|
95
|
|
|
|
|
|
|
{ |
|
96
|
0
|
|
|
|
|
0
|
$errMsg{$id} = "The value data was defined but the valuetype of the value data was not not defined."; |
|
97
|
0
|
|
|
|
|
0
|
return $self; |
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
|
|
100
|
12
|
50
|
33
|
|
|
35
|
if ( $opt->{type} && !$opt->{value}) |
|
101
|
|
|
|
|
|
|
{ |
|
102
|
0
|
|
|
|
|
0
|
$errMsg{$id} = "The valuetype was defined but the value data was not not defined."; |
|
103
|
0
|
|
|
|
|
0
|
return $self; |
|
104
|
|
|
|
|
|
|
} |
|
105
|
|
|
|
|
|
|
|
|
106
|
12
|
100
|
|
|
|
30
|
if ( $opt->{value} ) |
|
107
|
|
|
|
|
|
|
{ |
|
108
|
5
|
50
|
|
|
|
25
|
_specialChar(\$value) if ( $value =~ /(&||<||>||"||')/); |
|
109
|
|
|
|
|
|
|
} |
|
110
|
|
|
|
|
|
|
|
|
111
|
12
|
|
|
|
|
28
|
$result = "
|
|
112
|
12
|
100
|
|
|
|
34
|
$result .= " critical=\"" . $criticality . "\"" if ( $opt->{criticality}); |
|
113
|
12
|
|
|
|
|
22
|
$result .= ">"; |
|
114
|
12
|
100
|
|
|
|
26
|
$result .= "{value}); |
|
115
|
12
|
100
|
66
|
|
|
49
|
$result .= "xsi:type=\"xsd:" . $valuetype . "\"" if ( $opt->{value} && $opt->{valuetype}); |
|
116
|
12
|
100
|
66
|
|
|
41
|
$result .= ">" if ( $opt->{value} && $opt->{valuetype}); |
|
117
|
12
|
100
|
|
|
|
32
|
$result .= $value . "" if ($opt->{value}); |
|
118
|
12
|
|
|
|
|
20
|
$result .= ""; |
|
119
|
|
|
|
|
|
|
|
|
120
|
12
|
|
|
|
|
13
|
push(@{$controls{$id}}, $result); |
|
|
12
|
|
|
|
|
31
|
|
|
121
|
12
|
|
|
|
|
25
|
$default{$id}->{default} = $result; |
|
122
|
|
|
|
|
|
|
} |
|
123
|
|
|
|
|
|
|
|
|
124
|
19
|
|
|
|
|
61
|
return $self; |
|
125
|
|
|
|
|
|
|
} |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
# |
|
128
|
|
|
|
|
|
|
# inside-out classes have to have a DESTROY subrountine. |
|
129
|
|
|
|
|
|
|
# |
|
130
|
|
|
|
|
|
|
sub DESTROY |
|
131
|
|
|
|
|
|
|
{ |
|
132
|
19
|
|
|
19
|
|
1028
|
my ($dsml) = @_; |
|
133
|
19
|
|
|
|
|
45
|
my $id = ident($dsml); |
|
134
|
|
|
|
|
|
|
|
|
135
|
19
|
|
|
|
|
47
|
delete $controls{$id}; # Copy of actual xml data string. |
|
136
|
19
|
|
|
|
|
47
|
delete $default{$id}; # Copy of actual xml data string. |
|
137
|
19
|
|
|
|
|
32
|
delete $errMsg{$id}; # no error this will be a null string. |
|
138
|
19
|
|
|
|
|
229
|
return; |
|
139
|
|
|
|
|
|
|
} |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
# |
|
142
|
|
|
|
|
|
|
# The method clear sets object variables to their default values. |
|
143
|
|
|
|
|
|
|
# |
|
144
|
|
|
|
|
|
|
# Returns true on success. |
|
145
|
|
|
|
|
|
|
# |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
sub clear |
|
148
|
|
|
|
|
|
|
{ |
|
149
|
1
|
|
|
1
|
1
|
461
|
my ($dsml) = shift; |
|
150
|
1
|
|
|
|
|
5
|
my $id = ident $dsml; |
|
151
|
|
|
|
|
|
|
|
|
152
|
1
|
|
|
|
|
4
|
$controls{$id} = []; # Actual xml data string. |
|
153
|
1
|
|
|
|
|
4
|
$errMsg{$id} = ""; # error messages, no error this will be a null string. |
|
154
|
1
|
|
|
|
|
2
|
push(@{$controls{$id}}, $default{$id}->{default}); |
|
|
1
|
|
|
|
|
5
|
|
|
155
|
1
|
|
|
|
|
3
|
return 1; |
|
156
|
|
|
|
|
|
|
} |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
# 1. & - & |
|
159
|
|
|
|
|
|
|
# 2. < - < |
|
160
|
|
|
|
|
|
|
# 3. > - > |
|
161
|
|
|
|
|
|
|
# 4. " - " |
|
162
|
|
|
|
|
|
|
# 5. ' - ' |
|
163
|
|
|
|
|
|
|
# |
|
164
|
|
|
|
|
|
|
# Convert special characters to xml standards. |
|
165
|
|
|
|
|
|
|
# |
|
166
|
|
|
|
|
|
|
sub _specialChar |
|
167
|
|
|
|
|
|
|
{ |
|
168
|
8
|
|
|
8
|
|
14
|
my ($char) = @_; |
|
169
|
|
|
|
|
|
|
|
|
170
|
8
|
|
|
|
|
19
|
$$char =~ s/&/&/g; |
|
171
|
8
|
|
|
|
|
12
|
$$char =~ s/</g; |
|
172
|
8
|
|
|
|
|
11
|
$$char =~ s/>/>/g; |
|
173
|
8
|
|
|
|
|
14
|
$$char =~ s/"/"/g; |
|
174
|
8
|
|
|
|
|
329
|
$$char =~ s/'/'/g; |
|
175
|
8
|
|
|
|
|
28
|
return; |
|
176
|
|
|
|
|
|
|
} |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
# |
|
179
|
|
|
|
|
|
|
# Method error |
|
180
|
|
|
|
|
|
|
# |
|
181
|
|
|
|
|
|
|
# The method error returns the error message for the object. |
|
182
|
|
|
|
|
|
|
# $message = $dsml->error(); |
|
183
|
|
|
|
|
|
|
# |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
sub error |
|
186
|
|
|
|
|
|
|
{ |
|
187
|
0
|
|
|
0
|
1
|
0
|
my $dsml = shift; |
|
188
|
0
|
|
|
|
|
0
|
return $errMsg{ident $dsml}; |
|
189
|
|
|
|
|
|
|
} |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
# Method add |
|
192
|
|
|
|
|
|
|
# |
|
193
|
|
|
|
|
|
|
# The method Add is used in conjuction with other methods like Search. |
|
194
|
|
|
|
|
|
|
# |
|
195
|
|
|
|
|
|
|
# If there is one required input option and 3 additional optional options. |
|
196
|
|
|
|
|
|
|
# |
|
197
|
|
|
|
|
|
|
# $return = $control->Add( { control => 1.2.840.113556.1.4.619, valuetype => base64Binary, criticality => true, value => RFNNTYyLJA== } ); |
|
198
|
|
|
|
|
|
|
# |
|
199
|
|
|
|
|
|
|
# Input option "control": The control oid number. |
|
200
|
|
|
|
|
|
|
# Input option "valuetype": The xsd type for the value data. |
|
201
|
|
|
|
|
|
|
# Input option "criticality": The criticality of the control; true or false. |
|
202
|
|
|
|
|
|
|
# Input option "value": The value of the control. |
|
203
|
|
|
|
|
|
|
# |
|
204
|
|
|
|
|
|
|
# Method output; Returns true on success; false on error, error message |
|
205
|
|
|
|
|
|
|
# can be gotten with error method. |
|
206
|
|
|
|
|
|
|
# |
|
207
|
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
sub add |
|
209
|
|
|
|
|
|
|
{ |
|
210
|
8
|
|
|
8
|
1
|
2792
|
my ($dsml, $opt) = @_; |
|
211
|
8
|
|
|
|
|
24
|
my $id = ident $dsml; |
|
212
|
8
|
|
|
|
|
13
|
my $result; |
|
213
|
|
|
|
|
|
|
my $value; |
|
214
|
0
|
|
|
|
|
0
|
my $valuetype; |
|
215
|
0
|
|
|
|
|
0
|
my $criticality; |
|
216
|
0
|
|
|
|
|
0
|
my $control; |
|
217
|
|
|
|
|
|
|
|
|
218
|
8
|
|
|
|
|
20
|
$errMsg{$id} = ""; |
|
219
|
8
|
50
|
|
|
|
38
|
if ( !defined($opt->{control}) ) |
|
220
|
|
|
|
|
|
|
{ |
|
221
|
0
|
|
|
|
|
0
|
$errMsg{$id} = "Method add control required oid value is not defined."; |
|
222
|
0
|
|
|
|
|
0
|
return 0; |
|
223
|
|
|
|
|
|
|
} |
|
224
|
|
|
|
|
|
|
|
|
225
|
8
|
50
|
|
|
|
27
|
$control = (ref($opt->{control}) ? ${$opt->{control}} : $opt->{control}); |
|
|
0
|
|
|
|
|
0
|
|
|
226
|
8
|
50
|
|
|
|
29
|
$valuetype = (ref($opt->{valuetype}) ? ${$opt->{valuetype}} : $opt->{valuetype}) if ( $opt->{valuetype}); |
|
|
0
|
100
|
|
|
|
0
|
|
|
227
|
8
|
50
|
|
|
|
29
|
$criticality = (ref($opt->{criticality}) ? ${$opt->{criticality}} : $opt->{criticality}) if ( $opt->{criticality}); |
|
|
0
|
100
|
|
|
|
0
|
|
|
228
|
8
|
50
|
|
|
|
21
|
$value = (ref($opt->{value}) ? ${$opt->{value}} : $opt->{value}); |
|
|
0
|
|
|
|
|
0
|
|
|
229
|
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
|
|
231
|
8
|
50
|
66
|
|
|
48
|
if ( $opt->{criticality} && !($criticality =~ /^(true)||(false)$/) ) |
|
232
|
|
|
|
|
|
|
{ |
|
233
|
0
|
|
|
|
|
0
|
$errMsg{$id} = "Method add Control criticality is not defined properly."; |
|
234
|
0
|
|
|
|
|
0
|
return 0; |
|
235
|
|
|
|
|
|
|
} |
|
236
|
|
|
|
|
|
|
|
|
237
|
8
|
50
|
66
|
|
|
46
|
if ( $opt->{valuetype} && !($valuetype =~ /^(string)||(anyURI)||(base64Binary)$/) ) |
|
238
|
|
|
|
|
|
|
{ |
|
239
|
0
|
|
|
|
|
0
|
$errMsg{$id} = "Method add control`s valuetype is not defined properly."; |
|
240
|
0
|
|
|
|
|
0
|
return 0; |
|
241
|
|
|
|
|
|
|
} |
|
242
|
|
|
|
|
|
|
|
|
243
|
8
|
50
|
66
|
|
|
36
|
if ( $opt->{value} && ! $opt->{valuetype}) |
|
244
|
|
|
|
|
|
|
{ |
|
245
|
0
|
|
|
|
|
0
|
$errMsg{$id} = "Method control valuetype for the value data was not not defined."; |
|
246
|
0
|
|
|
|
|
0
|
return 0; |
|
247
|
|
|
|
|
|
|
} |
|
248
|
|
|
|
|
|
|
|
|
249
|
8
|
50
|
66
|
|
|
1083
|
if ( $opt->{valuetype} && !$opt->{value}) |
|
250
|
|
|
|
|
|
|
{ |
|
251
|
0
|
|
|
|
|
0
|
$errMsg{$id} = "Method add control`s valuetype was defined but the value data was not not defined."; |
|
252
|
0
|
|
|
|
|
0
|
return 0; |
|
253
|
|
|
|
|
|
|
} |
|
254
|
|
|
|
|
|
|
|
|
255
|
8
|
100
|
|
|
|
579
|
if ( $opt->{value} ) |
|
256
|
|
|
|
|
|
|
{ |
|
257
|
3
|
50
|
|
|
|
26
|
_specialChar(\$value) if ( $value =~ /(&||<||>||"||')/); |
|
258
|
|
|
|
|
|
|
} |
|
259
|
|
|
|
|
|
|
|
|
260
|
8
|
|
|
|
|
21
|
$result = "
|
|
261
|
8
|
100
|
|
|
|
31
|
$result .= " critical=\"" . $criticality . "\"" if ( $opt->{criticality}); |
|
262
|
8
|
|
|
|
|
13
|
$result .= ">"; |
|
263
|
8
|
100
|
|
|
|
23
|
$result .= "{value}); |
|
264
|
8
|
100
|
66
|
|
|
38
|
$result .= "xsi:type=\"xsd:" . $valuetype . "\"" if ( $opt->{value} && $opt->{valuetype}); |
|
265
|
8
|
100
|
66
|
|
|
1929
|
$result .= ">" if ( $opt->{value} && $opt->{valuetype}); |
|
266
|
8
|
100
|
|
|
|
28
|
$result .= $value . "" if ($opt->{value}); |
|
267
|
8
|
|
|
|
|
10
|
$result .= ""; |
|
268
|
|
|
|
|
|
|
|
|
269
|
8
|
|
|
|
|
10
|
push(@{$controls{$id}}, $result); |
|
|
8
|
|
|
|
|
189
|
|
|
270
|
8
|
|
|
|
|
25
|
return 1; |
|
271
|
|
|
|
|
|
|
} |
|
272
|
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
sub getControl |
|
274
|
|
|
|
|
|
|
{ |
|
275
|
20
|
|
|
20
|
1
|
7035
|
my ($dsml) = @_; |
|
276
|
20
|
|
|
|
|
46
|
my $id = ident $dsml; |
|
277
|
20
|
|
|
|
|
20
|
my $result; |
|
278
|
20
|
|
|
|
|
103
|
$result = ""; |
|
279
|
|
|
|
|
|
|
|
|
280
|
20
|
|
|
|
|
22
|
foreach my $var (@{$controls{$id}}) |
|
|
20
|
|
|
|
|
215
|
|
|
281
|
|
|
|
|
|
|
{ |
|
282
|
22
|
|
|
|
|
143
|
$result .= $var; |
|
283
|
|
|
|
|
|
|
} |
|
284
|
|
|
|
|
|
|
|
|
285
|
20
|
|
|
|
|
129
|
return $result; |
|
286
|
|
|
|
|
|
|
} |
|
287
|
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
} |
|
289
|
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
1; # Magic true value required at end of module |
|
291
|
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
__END__ |