Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Harden Your Wireless Apps with MIDP 2.0 Protection Domains : Page 4

Security has always been central to the MIDP specification, but the new MIDP 2.0 goes well beyond the first version's sandbox method. Find out how to use the new protection domains in 2.0.


advertisement
Detecting Permissions at Runtime
So far, I've covered how you go about setting up permissions and authenticating to a valid protection domain. But how do you know when a resource is not available to you? You could just wait and see if a SecurityException is thrown when your code attempts to use the resource. After all, you should be handling this condition gracefully anyway. Or, you could be a bit more proactive and check to see if you have the permission before you attempt to access the protected resource or make a feature available to the user.

The MIDlet class in MIDP 2.0 includes a method checkPermission() that allows you to pass the permission name as a parameter. An int is returned indicating the status of the permission.



Value

Description

0

The permission is denied

1

The permission is allowed

-1

The permission status is unknown

In some cases, the device may not support an API capable of providing the resource indicated by the permission. An example would be asking for permission to capture photo image input using javax.microedition.media.control.VideoControl.getSnapshot when the device does not support the necessary multimedia APIs to do this. In this case, 0 would be returned, indicating permission has been denied. An unknown status (-1) is returned in the case where a user must be prompted to grant the permission. Where user interaction is concerned, the status of the permission will not be known until the MIDlet attempts to access the resource and the user is prompted, in which case a SecurityException may be thrown.

The security enhancements of MIDP 2.0 provide an environment that breaks MIDP out of the sandbox security model and opens access to some of the more sensitive operations on a device. In some cases, permission must still be granted explicitly by the user. In other cases, such as when a MIDlet suite is signed and can gain trusted status on a device, some sensitive operations can be allowed without any user interaction. You should note, however, that these security precautions are designed to make the manufactures and the carriers more comfortable about running your code.

In order to fully secure your application, you will need to consider how you move data over the network and how you keep it safe on the device and so forth. Much of this is considered to be application-level security and is left as an exercise for the developer.



David Hemphill is the Lead Architect at Gearworks, a Minn.-based company that specializes in wireless workforce automation. He is also the co-author of "Java 2 Micro Edition" (Manning). David is also a member of the Sun-Certified J2ME Exam expert group.
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date