问题
I'm writing a Java ME app that will use privileged operations such as messaging. By default the user is prompted to confirm each of these operations, but I would like to run it as a background service.
Documentation says to request permission in the jad file, I have done so and presume it will work on a device. However I would like to test this on the Netbeans mobility emulator first.
I tried signing the app as "trusted" but my emulated execution still prompts the user for permission.
回答1:
The MIDP security model needs to be explained in 2 parts:
The phone (or the emulator) contains a security policy.
The security policy is made of several domains.
each domain defines function groups and root certificates.
a function group decides which protection options (auto agree always, user agree always, user agree once...) are available in the domain for which protected API (i.e. messaging).
The domain that applies to your MIDlet depends on which of the root certificates trusts the certificate you signed your MIDlet with.
Your problem is that there is a mismatch between what you think the protection options should be for the API you want in the domain you think your MIDlet belongs too and what is actually defined in the emulator security policy.
EDIT:
how-to for WTK-based emulators:
There are 3 _policy.txt*
files in the ${netbeans_installation_folder}\mobility8\WTK2.5.2\j2mewtk_template\appdb\
folder.
They each contain a list of "alias" definitions and a list of "domain" definitions.
Make every domain have the same content as the "maximum" domain.
After this, Your emulator will never again ask for any user permission.
If you have already used the emulator contained in Netbeans, you probably want to make the same changes to the ${netbeans_installation_folder}\mobility8\WTK2.5.2\appdb\
folder.
来源:https://stackoverflow.com/questions/1710423/privileged-operations-in-netbeans-mobility