blib/lib/Config/Apple/Profile/Payload/Types.pm

filter: Statementstmt 100% 28 / 28 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 100% 33 / 33 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« blib/lib/Config/Apple/Profile/Payload/Certificate/Root.pm ↑ Summary blib/lib/Config/Apple/Profile/Targets.pm »
1 package Config::Apple::Profile::Payload::Types;
2  
3 11 ▶use 5.14.4;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 11 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 11 ▶use warnings FATAL => 'all';
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 11 our $VERSION = '0.55';
8  
9 use Exporter::Easy (
10 11 OK => [qw(
11 $ProfileString $ProfileNumber $ProfileData $ProfileBool
12 $ProfileReal $ProfileDate $ProfileDict $ProfileArray
13 $ProfileNSDataBlob $ProfileUUID $ProfileIdentifier
14 )],
15 TAGS => [
16 'all' => [qw(
17 $ProfileString $ProfileNumber $ProfileData $ProfileBool
18 $ProfileReal $ProfileDate $ProfileDict $ProfileArray
19 $ProfileNSDataBlob $ProfileUUID $ProfileIdentifier $ProfileClass
20 )],
21 ],
22 11 ▶);
Subroutine BEGIN: called CC=1 SCAR=0.0
23 11 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25  
26 =encoding utf8
27  
28 =head1 NAME
29  
30 Config::Apple::Profile::Payload::Types - Data types for payload keys.
31  
32 =head1 DESCRIPTION
33  
34 Apple Configuration Profiles contain one or more I<payloads>. Each payload
35 contains a dictionary, which can be thought of like a Perl hash. Within a
36 payload's dictionary, each key's value is restricted to a specific type.
37 One key might require a number; a different key might require a string, or some
38 binary data.
39  
40 Provided in this module are a number of Readonly scalars that will be used
41 (instead of strings) to identify the data types for configuration profile keys.
42 The scalars are all OK for import into your local namespace, or you can simply
43 import C<:all> to get all of them at once.
44  
45 =head1 TYPES
46  
47 Apple Configuration Profile payloads use the following types:
48  
49 =head2 String (C<$ProfileString>)
50  
51 A UTF-8 string. The client should simply provide a Perl string (NOT a binary
52 string). Multi-line strings are allowed, although specific payload keys may
53 not allow this. Empty strings are B<not> allowed.
54  
55 B<NOTE:> If your source data was not ASCII, and not UTF-8, then please make
56 sure you have converted it before doing anything else! "converted it" normally
57 means using C<Encode::decode> to convert from the original encoding. Your
58 string will not be valid unless it can be encoded as UTF-8.
59  
60 =cut
61  
62 11 Readonly our $ProfileString => 1;
63  
64  
65 =head2 Number (C<$ProfileNumber>)
66  
67 An Integer, which may be positive, zero, or negative. The plist standard
68 doesn't specify a range, but one may be imposed by specific keys.
69  
70 =cut
71  
72 11 Readonly our $ProfileNumber => 2;
73  
74  
75 =head2 Real (C<$ProfileReal>)
76  
77 A real number, which may be positive, zero, or negative. It may also have
78 an exponent. The plist standard doesn't specify a range, but one may be
79 imposed by specific keys.
80  
81 =cut
82  
83 11 Readonly our $ProfileReal => 5;
84  
85  
86 =head2 Data (C<$ProfileData>)
87  
88 Binary data.
89  
90 Binary data may be provided by the client in multiple ways.
91 Clients can provide an open filehandle, or an open C<IO> object.
92 C<Scalar::Util::openhandle> is used to make sure the handle/object is open.
93  
94 The file needs to be open for reading.
95  
96 The client may also provide a string. If a string is provided, then it must be
97 a I<non-empty>, I<binary> string. In other words, C<utf8::is_utf8> needs to
98 return C<false>. If the flag is C<true>, then you probably need to use
99 C<Encode::encode> (or maybe C<Encode::encode_utf8>) to get a binary string.
100  
101 =cut
102  
103 11 Readonly our $ProfileData => 3;
104  
105  
106 =head2 Boolean (C<$ProfileBool>)
107  
108 Either True for False. When reading a boolean from a payload's contents, a 1
109 is used to represent true, and 0 is returned for false. When setting a boolean,
110 the value provided is filtered using the code C<($value) ? 1 : 0>. As long as
111 you aren't providing C<undef> as the input, your input will probably be
112 accepted!
113  
114 =cut
115  
116 11 Readonly our $ProfileBool => 4;
117  
118  
119 =head2 Date (C<$ProfileDate>)
120  
121 A date. This is stored internally as a C<DateTime> object, and when read a
122 C<DateTime> object will be returned. When serialized into plist form, the
123 time will be in UTC, but no other guarantees are made about the timezone when
124 the object is stored internally, so if you read a Date, be sure to call
125 C<< ->set_time_zone() >> before outputting it yourself.
126  
127 If a string is provided, L<DateTime::Format::Flexible> will be used to parse it.
128 For best results, parse it yourself, and provide the resulting C<DateTime>
129 object!
130  
131 =cut
132  
133 11 Readonly our $ProfileDate => 5;
134  
135  
136 =head2 Dictionary (C<$ProfileDict>)
137  
138 A dictionary is the plist equivalent to a Perl hash, and that is what will be
139 made available. The client should expect the hash to restrict what key names,
140 and what values, are accepted. For more information, see the
141 documentation for the specific payload key.
142  
143 =cut
144  
145 11 Readonly our $ProfileDict => 10;
146  
147  
148 =head2 Array (C<$ProfileArray>)
149  
150 An array, similar to a Perl array. The client should expect the array to only
151 accept certain data types. For more information, see the documentation for the
152 specific payload key.
153  
154 =cut
155  
156 11 Readonly our $ProfileArray => 11;
157  
158  
159 =head2 NSData Blob
160  
161 This is a weird type. The only place it appears in the I<Configuration Profile
162 Reference> (the edition dated 2014-03-20) is in the C<Certificate> key in the
163 Exchange payload. I don't really understand this, though I'm guessing it's
164 really a Data type, and the I<NSData Blob> is referring to the contents.
165  
166 Until I get more information on what exactly this is, this type will likely go
167 unimplemnented. Right now, the same checks are performed as for the
168 C<Data> type.
169  
170 =cut
171  
172 11 Readonly our $ProfileNSDataBlob => 20;
173  
174  
175 =head1 CUSTOM TYPES
176  
177 The following types are not defined in the plist standard, but they are being
178 treated specially here.
179  
180 =head2 UUID (C<$ProfileUUID>)
181  
182 I<Also known as a GUID>
183  
184 Although the plist format does not have a special type for UUIDs (a simple
185 String is used), these modules designate a special type for UUIDs as a
186 convenience to the client. All payloads have a UUID as one of the required
187 keys. If the client does not specify a UUID when creating a payload, then
188 one will be lazily auto-generated.
189  
190 If you would like to set an explicit UUID, you may provide a C<Data::UUID>
191 object, a C<Data::GUID> object, or a string that C<Data::GUID> can parse. When
192 reading, a C<Data::GUID> object is returned, but that can be converted into a
193 string very easily:
194  
195 $uuid = "$uuid";
196  
197 =cut
198  
199 11 Readonly our $ProfileUUID => 21;
200  
201  
202 =head2 Identifier (C<$ProfileIdentifier>)
203  
204 This is another convenience type. All payloads require an identifier,
205 which is a reverse-DNS-style (Java-style) string. If the client does not
206 specify an identifier, then one will be lazily auto-generated.
207  
208 See RFC 1035 for the standard relating to host and domain names, but please note
209 that spaces are I<not> acceptable here, even though they may be in RFC 1035.
210  
211 =cut
212  
213 11 Readonly our $ProfileIdentifier => 22;
214  
215  
216 =head2 Class (C<$ProfileClass>)
217  
218 This profile type is used to indicate that the value is an instance of a class.
219 The class is a sub-class of C<Config::Apple::Profile::Payload::Common>, so the
220 methods implemented in that class are all available. More information about
221 what specific sub-class is used can be found in the documentation for the
222 specific payload key.
223  
224 =cut
225  
226 11 Readonly our $ProfileClass => 24;
227  
228  
229 =head1 SEE ALSO
230  
231 L<Data::GUID>, L<Data::UUID>, L<Encode>, L<Scalar::Util>, L<utf8>,
232 L<https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man5/plist.5.html>,
233 L<http://www.apple.com/DTDs/PropertyList-1.0.dtd>
234  
235 =head1 ACKNOWLEDGEMENTS
236  
237 Refer to L<Config::Apple::Profile> for acknowledgements.
238  
239 =head1 AUTHOR
240  
241 A. Karl Kornel, C<< <karl at kornel.us> >>
242  
243 =head1 COPYRIGHT AND LICENSE
244  
245 Copyright © 2014 A. Karl Kornel.
246  
247 This program is free software; you can redistribute it and/or modify it
248 under the terms of either: the GNU General Public License as published
249 by the Free Software Foundation; or the Artistic License.
250  
251 See L<http://dev.perl.org/licenses/> for more information.
252  
253 =cut
254  
255 11 1;
« blib/lib/Config/Apple/Profile/Payload/Certificate/Root.pm ↑ Summary blib/lib/Config/Apple/Profile/Targets.pm »