Skip Headers
Oracle® Java Micro Edition Software Development Kit Developer's Guide
Release 3.2 for Eclipse on Windows
  Go To Table Of Contents
Go To Index


10 Security and MIDlet Signing

The SDK provides tools to sign MIDlet suites, manage keys, and manage root certificates.

MIDP 2.0 (JSR 118) includes a comprehensive security model based on protection domains. MIDlet suites are installed into a protection domain that determines access to protected functions. The MIDP 2.0 specification also includes a recommended practice for using public key cryptography to verify and authenticate MIDlet suites.

The general process to create a cryptographically signed MIDlet suite is as follows:

  1. The MIDlet author, probably a software company, buys a signing key pair from a certificate authority (the CA).

  2. The author signs the MIDlet suite with the signing key pair and distributes their certificate with the MIDlet suite.

  3. When the MIDlet suite is installed on the emulator or on a device, the implementation verifies the author's certificate using its own copy of the CA's root certificate. Then it uses the author's certificate to verify the signature on the MIDlet suite.

  4. After verification, the device or emulator installs the MIDlet suite into the security domain that is associated with the CA's root certificate.

For definitive information, consult the MIDP 2.0 specification. For an overview of MIDlet signing using the Oracle Java ME SDK, read the article Understanding MIDP 2.0's Security Architecture.

If you need more background on public key cryptography, see MIDP Application Security 1: Design Concerns and Cryptography and the Java Cryptography Architecture Specification.

See the following topics:

10.1 Security Domains

The SDK supports the following security domains:

minimum. All permissions are denied to MIDlets in this domain.

maximum. All permissions are granted to MIDlets in this domain. Maximum is the default setting.

unidentified_third_party. Provides a high level of security for applications whose origins and authenticity cannot be determined. The user is prompted frequently when the application attempts a sensitive operation.

identified_third_party. Intended for MIDlets whose origins were determined using cryptographic certificates. Permissions are not granted automatically, but the user is prompted less often than for the unidentified_third_party domain.

operator. All permissions are denied to MIDlets in this domain.

manufacturer. Intended for MIDlet suites whose credentials originate from the manufacturer's root certificate.

10.2 Setting Security Domains

In the SDK, when you use Run Project via OTA your packaged MIDlet suite is installed directly into the emulator where it is placed in a security domain. The emulator uses public key cryptography to determine the appropriate security domain.

10.2.1 Specify the Security Domain for an Emulator

Follow these steps to specify the security domain for an emulated device.

  1. Select the device in the device selector.

  2. In the Properties Window, expand the General properties, and for the Security Domain option, choose a domain from the dropdown list.

10.2.2 Specify the Security Domain for a Project

Follow these steps to set a MIDlet Suite's security domain at runtime.

  1. Right-click on the package and select Run As > Run Configurations... from the context menu.

  2. Choose the project's JAD file, then select the Emulation tab.

  3. Specify the device and the security domain, and click Run.

You can also sign your MIDlet or IMlet with JADtool (Section 11.6.2, "Sign MIDlet Suites (jadtool)".

10.3 Signing a Project With a Key Pair

Devices use signing information to check an application's source and validity before allowing it to access protected APIs. For test purposes, you can create a signing key pair to sign an application. A key pair consists of the following:

You can create a key pair as described in Section 10.4, "Managing Keystores and Key Pairs."

Follow these steps to sign a Java ME package in Eclipse.

  1. In the Package view right-click on a package and select Properties to open the Properties dialog.

  2. In the Java ME category, select Signing. For help with this page, view the following help topic: Java ME Development User Guide > Reference > Property Pages > Java ME.

  3. Click Enable project specific settings. Specify a keystore and a password option.

  4. Click OK.

To obfuscate code, see Section 4.4.4, "Obfuscating."

10.4 Managing Keystores and Key Pairs

The Oracle Java ME SDK command line tools described in Section 11.6.3, "Manage Certificates (MEKeyTool)" manage an emulator's list of root certificates.

Oracle Java ME SDK ships a default keystore named _main.ks in installdir\runtimes\cldc-hi\appdb. This keystore is automatically copied from your installation's default location to each instance of the default devices (the emulators). These instances are typically stored in:

C:\Documents and Settings\username\javame-sdk\3.2\work\devicename

Real devices have similar lists of root certificates, although you typically cannot modify them. When you deploy your application on a real device, you must use signing keys issued by a certificate authority whose root certificate is present on the device. This makes it possible for the device to verify your application.

In Eclipse you can also use MTJ utilities to manage keystores as described in Section 10.3, "Signing a Project With a Key Pair." You can also use the -import option to import certificates from these keystores as described in Section 11.6.3, "Manage Certificates (MEKeyTool)."

10.5 Command Line Samples

This section is a summary of command line samples for keystore and certificate tasks. For the full syntax of keytool, see:

These samples show literal paths on a sample system. You can replace the paths and options as you see fit. These samples contain linefeeds to accommodate the book format. In practice they commands should be entered on a single line.

Generate a keypair.

As mentioned in Section 10.4, "Managing Keystores and Key Pairs," Java ME includes a default keystore used for the emulators. For test purposes you can also make your own keypair containing a new keystore and a certificate. For example:

"C:\Program Files\Java\jdk1.6.0_35\bin\keytool" -genkeypair -alias mykp 
-keyalg RSA -keysize 1024 -validity 365 -dname "cn=dlp, L=Santa Clara, S=CA"
-keypass 123456 -keystore D:/temp/mykeystore.ks -storepass 654321

List the keypair.

C:\Progra~1\Java\jdk1.6.0_35\bin\keytool -list -alias mykp 
-keystore mykeystore.ks -storepass 654321

Export a certificate to a file.

C:\Progra~1\Java\jdk1.6.0_35\bin\keytool -exportcert -alias mykp 
-keystore mykeystore.ks -storepass 654321 -file d:\temp\mykpcert

Print the certificate file.

C:\Progra~1\Java\jdk1.6.0_35\bin\keytool -printcert -file d:\temp\mykpcert

Import the keystore (including your certificate) into the default keystore.

For a description of MEKeyTool, see Section 11.6.3, "Manage Certificates (MEKeyTool)." In this example mekeytool is launched from the Java ME SDK installation bin directory.

mekeytool -import -alias mykp -keystore D:\temp\mykeystore.ks -MEkeystore D:\temp\_main.ks -storepass 654321