line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package OMA::Download::DRM::REL; |
2
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
51
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
OMA::Download::DRM::REL - Perl extension for packing REL objects according to the OMA DRM 1.0 specification. |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 DESCRIPTION |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Open Mobile Alliance Digital Rights Management Rights Expression Language implementation |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
This is a partial implementation - Needs to be completed |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=cut |
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
532
|
BEGIN { |
16
|
1
|
|
|
1
|
|
14
|
use 5.8.7; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
35
|
|
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head2 new |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# $class can be OMA::Download::DRM::REL::XML or OMA::Download::DRM::REL::WBXML |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my $rel=$class->new( |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
### Mandatory |
27
|
|
|
|
|
|
|
'uid' => 'cid:image239872@example.com', |
28
|
|
|
|
|
|
|
'permission' => 'display', # Can be either 'display', 'play', 'execute' or 'print' |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
### Optional |
31
|
|
|
|
|
|
|
'key' => 'im9aazbjfgsorehf', |
32
|
|
|
|
|
|
|
'count' => 3 |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=cut |
36
|
|
|
|
|
|
|
### Class constructor ---------------------------------------------------------- |
37
|
|
|
|
|
|
|
sub new { |
38
|
2
|
|
|
2
|
1
|
10
|
my ($class, %arg)=@_; |
39
|
2
|
50
|
|
|
|
8
|
die "Need Permission argument" unless $arg{'permission'}; |
40
|
2
|
|
100
|
|
|
14
|
my $self={ |
41
|
|
|
|
|
|
|
'uid' => $arg{'uid'}, |
42
|
|
|
|
|
|
|
'permission' => $arg{'permission'}, |
43
|
|
|
|
|
|
|
'count' => $arg{'count'}, |
44
|
|
|
|
|
|
|
'key' => $arg{'key'} || undef, |
45
|
|
|
|
|
|
|
}; |
46
|
2
|
|
|
|
|
6
|
$self=bless $self, $class; |
47
|
2
|
|
|
|
|
18
|
$self->_init; |
48
|
2
|
|
|
|
|
8
|
$self; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
### Properties ----------------------------------------------------------------- |
51
|
|
|
|
|
|
|
=head1 PROPERTIES |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head2 uid |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Returns the unique identifier |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
print $rel->uid; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=cut |
60
|
|
|
|
|
|
|
sub uid { |
61
|
0
|
|
|
0
|
1
|
0
|
my ($self, $val)=@_; |
62
|
0
|
0
|
|
|
|
0
|
$self->{uid} = $val if $val; |
63
|
0
|
|
|
|
|
0
|
$self->{uid} |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head2 permission |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Get or set permission type. Can be either 'display', 'play', 'execute' or 'print' |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
print $rel->permission; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
$rel->permission('display'); |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=cut |
75
|
|
|
|
|
|
|
sub permission { |
76
|
0
|
|
|
0
|
1
|
0
|
my ($self, $val)=@_; |
77
|
0
|
0
|
|
|
|
0
|
$self->{permission} = $val if $val; |
78
|
0
|
|
|
|
|
0
|
$self->{permission} |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head2 key |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Get or set the encryption key |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
print $rel->key; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
$rel->key('0123456789ABCDEF'); |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=cut |
90
|
|
|
|
|
|
|
sub key { |
91
|
0
|
|
|
0
|
1
|
0
|
my ($self, $val)=@_; |
92
|
0
|
0
|
|
|
|
0
|
$self->{uid} = $val if defined $val; |
93
|
0
|
|
|
|
|
0
|
$self->{uid} |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head2 count |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Get or set accesses count limit |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
print $rel->count; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
$rel->count(3); |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=cut |
105
|
|
|
|
|
|
|
sub count { |
106
|
0
|
|
|
0
|
1
|
0
|
my ($self, $val)=@_; |
107
|
0
|
0
|
|
|
|
0
|
$self->{count} = $val if defined $val; |
108
|
0
|
|
|
|
|
0
|
$self->{count} |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
### Private methods -------------------------------------------------------------------- |
111
|
|
|
|
|
|
|
sub _packin { |
112
|
2
|
|
|
2
|
|
5
|
my $self=$_[0]; |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
# version |
115
|
2
|
|
|
|
|
8
|
my $context=$self->_in_element('context', $self->_in_element('version', $self->_in_string('1.0'))); |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
# agreement |
118
|
|
|
|
|
|
|
## asset |
119
|
2
|
|
|
|
|
12
|
my $assetcontext=$self->_in_element('context', $self->_in_element('uid', $self->_in_string($self->{uid}))); |
120
|
2
|
100
|
|
|
|
19
|
my $assetkeyinfo = $self->{key} ? $self->_in_element('KeyInfo', $self->_in_element('KeyValue', $self->_in_opaque($self->{key}))) : ''; |
121
|
2
|
|
|
|
|
9
|
my $asset=$self->_in_element('asset', $assetcontext.$assetkeyinfo); |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
## permission |
124
|
2
|
|
|
|
|
9
|
my $count=$self->_in_element('count', $self->_in_string($self->{count})); |
125
|
2
|
100
|
|
|
|
18
|
my $constraint = $self->_in_element('constraint', $count) if $self->{count}; |
126
|
2
|
|
|
|
|
8
|
my $permission=$self->_in_element('permission', $self->_in_element($self->{'permission'}, $constraint)); |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
|
129
|
2
|
|
|
|
|
10
|
my $agreement=$self->_in_element('agreement', $asset.$permission); |
130
|
|
|
|
|
|
|
|
131
|
2
|
|
|
|
|
13
|
return $context.$agreement; |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
1; |
135
|
|
|
|
|
|
|
__END__ |