Class PropertyLists

java.lang.Object
com.codename1.backend.xml.PropertyLists

public final class PropertyLists extends Object

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 Type
    Method
    Description
    static byte[]
    extractXml(byte[] data)
    Finds the XML property list embedded in binary data and answers its bytes, from <?xml (or <plist when there is no declaration) through the end of the first </plist> after it; null when there is none.
    static Object
    parse(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 a Map<String, Object>.
    static Object
    Parses an XML property list held in a string.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • parse

      public static Object parse(byte[] data) throws XmlException

      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

      public static Object parse(String xml) throws XmlException

      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 <plist when 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.