C H A P T E R  15

Defining New Security Permissions

Runtime and benchmark tests that use protected APIs (as defined by the MIDP 2.0 security model) must obtain permission to use those APIs. Administrators or testers select the permissions in templates or configurations and the harness adds the permission requests to test bundles.



Note - For OTA test packs, you code permission requests for a MIDlet in its JAD file and manifest file.


FIGURE 15-1 shows how the template and configuration editors display permission categories (groups) in the left pane and, in the right pane, a check box for each permission in the category. In this example, three permissions are associated with the category Location. Test pack documentation tells users what permissions to select.

FIGURE 15-1 Example Permissions


Example Permissions

The Security Permissions section of a template or configuration lists the permissions that are known to the Java Device Test Suite. If your runtime or benchmark test pack requires unknown permissions, you define the new permissions in two files in your test pack’s root directory (the directory containing testsuite.info).



Note - Defining new permissions as described in this chapter is distinct from specifying the permissions a test pack needs in the testsuite.info TSPermissions property.


When an administrator installs your test pack, your permissions appear in new templates and configurations.

CODE EXAMPLE 15-1 shows the policy.txt file format.


CODE EXAMPLE 15-1 Format of policy.txt File
# This is a comment line
alias: permissionGroup
permission1,
...
permissionN

Lines that begin with a pound sign (#) are interpreted as comments. permissionGroup gives the permissions an identifier that entries in permissions.properties can reference. permission1 through permissionN are fully qualified permission names that are to be displayed in permissionGroup’s page.

CODE EXAMPLE 15-2 show a policy.txt file that defines the permissions shown in FIGURE 15-1.


CODE EXAMPLE 15-2 Example policy.txt File
alias: LocationPermissions
javax.microedition.location.Location,
javax.microedition.location.ProximityListener
javax.microedition.location.Orientation

To specify a category name and descriptive text for a set of permissions, create a permissions.properties file and in it name the corresponding permissionGroup in a smry and text entry. Continuing with the example shown in CODE EXAMPLE 15-2, CODE EXAMPLE 15-3 shows the smry and text items that are displayed in FIGURE 15-1.


CODE EXAMPLE 15-3 Example permissions.properties File
LocationPermissions.smry=Location
LocationPermissions.text=Please set the permissions of Location category.