CODE EXAMPLE 4-19Test Description That Grants Permissions for a Security Test

javax.microedition.io.Connector.file.write </TD> </TR>

</TABLE>

</BODY>

</HTML>

Denying Security Permissions

When writing security tests, a test writer can specify the permissions that the security policy must not grant in the protection domain for this test application to execute and pass. Test writers can specify the denied security permissions by including a deny attribute in the test description. If the security policy grants the specified permissions, the test must be filtered out of the test run.

For example, suppose a test application is written to expect that a security exception is thrown because the javax.microedition.io.Connector.file.read permission is not granted. If the security policy grants the javax.microedition.io.Connector.file.read permission to the test application, the test must be filtered out and not run.

The following is an example of the deny attribute and permission added to a test description file.

CODE EXAMPLE 4-20deny Attribute in the Test Description

<TR>

<TD SCOPE="row"> <B>deny</B> </TD>

<TD> javax.microedition.io.Connector.file.read </TD> </TR>

The value of the deny attribute is a list of space-separated permissions that must be denied by the security policy for this test application to execute and pass. If the permissions are granted in the protection domain for the test application, the test application must be filtered out and not run.

The following is an example of a test description file that includes the deny attribute and permissions.

CODE EXAMPLE 4-21Test Description That Denies Permissions for a Security Test

<TITLE>Test Specifications and Descriptions for Test</TITLE> </HEAD>

<BODY>

<H1>Test Specifications and Descriptions for Test</H1>

66 Java ME TCK Framework Developer’s Guide • July 2007

Page 86
Image 86
Sun Microsystems 1.2 manual Denying Security Permissions, Code Example 4-20deny Attribute in the Test Description