Class PropertyLists
Reads Apple XML property lists: provisioning profiles, entitlements,
Info.plist files.
Map<String, Object> profile = (Map<String, Object>) PropertyLists.parse(mobileprovisionBytes);
String team = (String) ((List<Object>) profile.get("TeamIdentifier")).get(0);
Date expires = (Date) profile.get("ExpirationDate");
Values map to Java types as follows:
| plist | Java |
|---|---|
<dict> |
Map<String, Object>, in document order |
<array> |
List<Object> |
<string> |
String |
<integer> |
Long |
<real> |
Double |
<true/> <false/> |
Boolean |
<data> |
byte[], base64 decoded |
<date> |
java.util.Date (UTC, as 2025-01-31T12:00:00Z is written) |
Check a value's type with instanceof before casting it.
A provisioning profile (.mobileprovision) is not a plist itself but a
CMS/PKCS#7 signed envelope with the XML plist inside it. [#parse(byte[])]
accepts it as it is, by locating the plist with [#extractXml(byte[])]; the
signature is not verified. Binary property lists (bplist00) are not
supported and are reported as such.
Parsing goes through XmlPullParser, so a document type declaration is never
interpreted and nesting is bounded: a hostile plist cannot fetch a URL,
expand entities or exhaust the stack.
-
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]extractXml(byte[] data) Finds the XML property list embedded in binary data and answers its bytes, from<?xml(or<plistwhen there is no declaration) through the end of the first</plist>after it; null when there is none.static Objectparse(byte[] data) Parses a property list -- an XML plist, or any binary blob that wraps one, such as a signed provisioning profile -- and answers its top-level value, usually aMap<String, Object>.static ObjectParses an XML property list held in a string.
-
Method Details
-
parse
Parses a property list -- an XML plist, or any binary blob that wraps one, such as a signed provisioning profile -- and answers its top-level value, usually a
Map<String, Object>.Throws
XmlException: when no XML plist is found, the data is a binary plist, or the plist is malformed (an unknown element, a<dict>key with no value, an integer that does not parse).
- Throws:
XmlException
-
parse
Parses an XML property list held in a string.
Throws
XmlException: when the plist is malformed.
- Throws:
XmlException
-
extractXml
public static byte[] extractXml(byte[] data) Finds the XML property list embedded in binary data and answers its bytes, from
<?xml(or<plistwhen there is no declaration) through the end of the first</plist>after it; null when there is none.This is how the plist is read out of a provisioning profile, which stores it unencrypted inside a signed CMS envelope. The bytes before and after the span are not examined.
-