Contents

EntitlementsQuery

A constraint that tests values in the entitlements dictionary associated with a process or code file.

Declaration

class EntitlementsQuery

Overview

Entitlements dictionaries use strings for keys. The value of each key could be a bool, integer, string, array or another dictionary. Arrays are homogenous. Entitlements queries are a chain of operations that allow matching against arbitrarily nested values in the dictionary.

Example entitlements dictionary:

<dict>
    <key>com.apple.application-identifier</key>
    <string>com.apple.TextEdit</string>
    <key>com.apple.developer.ubiquity-container-identifiers</key>
    <array>
        <string>com.apple.TextEdit</string>
    </array>
    <key>com.apple.private.hid.client.event-dispatch.internal</key>
    <true/>
</dict>

Example query to match the first entitlement exactly

EntitlementsQuery.key("com.apple.application-identifier").matchSingle(com.apple.TextEdit)

Example query to match the second entitlement exactly.

EntitlementsQuery.key("com.apple.developer.ubiquity-container-identifiers").elementAtIndex(0).matchSingle("com.apple.TextEdit")

or to match the second entitlement less specifically

EntitlementsQuery.key("com.apple.developer.ubiquity-container-identifiers").match("com.apple.TextEdit")

The following query will detect the presence of the com.apple.private.hid.client.event-dispatch.internal key without checking its value.

EntitlementsQuery.key("com.apple.private.hid.client.event-dispatch.internal")

To match its value add a match() call to the chain.

EntitlementsQuery.key("com.apple.private.hid.client.event-dispatch.internal").match(true)

The following example demonstrate the keyPrefix query.

EntitlementsQuery.keyPrefix("com.apple.").match(true)

The keyPrefix query will match the “com.apple.application-identifier” only. Then the match query will fail because true does not match “com.apple.TextEdit”.

This constraint will cause a matching failure if the process or file being matched does not include entitlements.

Topics

Initializers

Instance Methods

Type Methods

Enumerations

See Also

Testing properties of executable code