line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyrights 2013-2014 by [Mark Overmeer]. |
2
|
|
|
|
|
|
|
# For other contributors see ChangeLog. |
3
|
|
|
|
|
|
|
# See the manual pages for details on the licensing terms. |
4
|
|
|
|
|
|
|
# Pod stripped from pm file by OODoc 2.01. |
5
|
5
|
|
|
5
|
|
206923
|
use warnings; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
177
|
|
6
|
5
|
|
|
5
|
|
27
|
use strict; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
234
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
package Net::Domain::SMD::Schema; |
9
|
5
|
|
|
5
|
|
24
|
use vars '$VERSION'; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
294
|
|
10
|
|
|
|
|
|
|
$VERSION = '0.17'; |
11
|
|
|
|
|
|
|
|
12
|
5
|
|
|
5
|
|
25
|
use base 'Exporter'; |
|
5
|
|
|
|
|
6
|
|
|
5
|
|
|
|
|
750
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our @EXPORT_OK = qw/SMD10_NS MARK10_NS/; |
15
|
|
|
|
|
|
|
our %EXPORT_TAGS = |
16
|
|
|
|
|
|
|
( ns10 => [ qw/SMD10_NS MARK10_NS/ ] |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
|
19
|
5
|
|
|
5
|
|
746
|
use Log::Report 'net-domain-smd'; |
|
5
|
|
|
|
|
129669
|
|
|
5
|
|
|
|
|
32
|
|
20
|
5
|
|
|
5
|
|
9651
|
use XML::Compile::Cache (); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
use XML::Compile::WSS::Signature (); |
22
|
|
|
|
|
|
|
use XML::Compile::WSS::Util qw(DSIG_NS); |
23
|
|
|
|
|
|
|
use Net::Domain::SMD::File (); |
24
|
|
|
|
|
|
|
use File::Basename qw(dirname); |
25
|
|
|
|
|
|
|
use Scalar::Util qw(blessed); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
use constant |
28
|
|
|
|
|
|
|
{ SMD10_NS => 'urn:ietf:params:xml:ns:signedMark-1.0' |
29
|
|
|
|
|
|
|
, MARK10_NS => 'urn:ietf:params:xml:ns:mark-1.0' |
30
|
|
|
|
|
|
|
}; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my %prefixes = |
33
|
|
|
|
|
|
|
( ds => DSIG_NS # do not take this prefix from these schemas |
34
|
|
|
|
|
|
|
, smd => SMD10_NS |
35
|
|
|
|
|
|
|
, mark => MARK10_NS |
36
|
|
|
|
|
|
|
); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub new($%) { my ($class, %args) = @_; (bless {}, $class)->init(\%args) } |
40
|
|
|
|
|
|
|
sub init($) |
41
|
|
|
|
|
|
|
{ my ($self, $args) = @_; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
my $xsddir = (dirname __FILE__) . '/xsd'; |
44
|
|
|
|
|
|
|
my @xsds = |
45
|
|
|
|
|
|
|
( "$xsddir/mark-1.0.xsd" |
46
|
|
|
|
|
|
|
, "$xsddir/mark-1.0-bugs.xsd" |
47
|
|
|
|
|
|
|
, "$xsddir/signedMark-1.0.xsd" |
48
|
|
|
|
|
|
|
, "$xsddir/signedMark-1.0-bugs.xsd" |
49
|
|
|
|
|
|
|
); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
my $schemas = $self->{NDSS_schemas} |
52
|
|
|
|
|
|
|
= XML::Compile::Cache->new(\@xsds, prefixes => \%prefixes); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# do not prefix 'mark', because the accesses it all the time. |
55
|
|
|
|
|
|
|
$schemas->addKeyRewrite('PREFIXED(smd)'); |
56
|
|
|
|
|
|
|
my $sig = XML::Compile::WSS::Signature->new |
57
|
|
|
|
|
|
|
( schema => $schemas |
58
|
|
|
|
|
|
|
, prepare => ($args->{prepare} || 'READER') |
59
|
|
|
|
|
|
|
, sign_types => [ 'smd:signedMarkType', 'ds:KeyInfoType' ] |
60
|
|
|
|
|
|
|
, sign_put => 'smd:signedMarkType' |
61
|
|
|
|
|
|
|
, sign_when => 'smd:signedMarkType' |
62
|
|
|
|
|
|
|
); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
if($args->{auto_datetime}) |
65
|
|
|
|
|
|
|
{ $schemas->addHook |
66
|
|
|
|
|
|
|
( action => 'READER', type => 'xsd:dateTime' |
67
|
|
|
|
|
|
|
, after => sub { Net::Domain::SMD->date2time($_[1]) } |
68
|
|
|
|
|
|
|
); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
$self; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
#------------------------- |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub schemas() {shift->{NDSS_schemas}} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
#------------------------- |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub from($%) |
83
|
|
|
|
|
|
|
{ my ($self, $xml, %args) = @_; |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
return ($self->read($xml, %args), $xml) |
86
|
|
|
|
|
|
|
if $xml !~ m/\n/ && -f $xml; |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
my $source; |
89
|
|
|
|
|
|
|
unless(blessed $xml && $xml->isa('XML::LibXML::Node')) |
90
|
|
|
|
|
|
|
{ $xml = XML::LibXML->load_xml(string => $xml); |
91
|
|
|
|
|
|
|
$source = 'string'; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
if($xml->isa('XML::LibXML::Document')) |
95
|
|
|
|
|
|
|
{ $xml = $xml->documentElement; |
96
|
|
|
|
|
|
|
$source ||= 'document'; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
my $smd = Net::Domain::SMD->fromNode($xml, schemas => $self->schemas); |
100
|
|
|
|
|
|
|
$source ||= 'element'; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
($smd, $source); |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub read($) |
107
|
|
|
|
|
|
|
{ my ($self, $fn) = @_; |
108
|
|
|
|
|
|
|
Net::Domain::SMD::File->fromFile($fn, schemas => $self->schemas); |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
1; |