Submit Your Article
Home Articles News Tutorials Videos Add An Article
Topics: Design Photoshop Programming PHP CSS Java Database Web Development Javascript Ajax
– Close + Open

Find Out More About DevWebPro!

Sign up for the newsletter


» Terms & Conditions

Welcome to the New DevWebPro!

DevWebPro Includes:
  Hundreds Of Tutorials   Developer News
  Unique Gadget Videos   Tons of Topics to Discuss
  Expert Advice   We Will Publish Your Articles

Learning To Use The Java Sandbox

By: Vaibhav Pandey
Tuesday, December 8th, 2009
Text: Decrease Font Size Increase Font Size | Print Print Article | Share: Delicious Digg StumbleUpon Post to Twitter Post to Facebook

The sandbox allows code to be downloaded from any source,but applies restriction on it upon execution. You can also say sandbox isolates particular code during execution to apply the restrictions. A Java sandbox is an area in memory outside which the Java program cannot make calls. This prevents Java programs from being able to call low level system functions that may cause data corruption or other damages. The Java sandbox is used by Java to discourage unsafe applets from accessing the resources. It applies several restrictions on the applets.

The Java sandbox has three components:-

  1. The Bytecode verifier
  2. The applet class loader
  3. The security Manager

The Bytecode Verifier

The first level of Java security is the Java Bytecode verifier. The Bytecode is verified before it is allowed to run on the users machine. It is checked to authenticate its creation by the Java compiler ,and its access is restricted accordingly. The Bytecode verifier makes sure that the format of the bytecode fragment is correct. A built-in theorem is applied on each fragment to make sure that the bytecode does not violate access restrictions or try to access objects using incorrect information. The bytecode is checked in two phases. The first phase takes place when the bytecode is loaded. The verifier checks for the structure of the . class file. Phase two occurs when the bytecode is executed . The verifier checks the validity of the classes,the variables and the methods used in the program. This is done because Java programs are dynamically linked.

The Applet class loader

The second level of security defense id the Java Applet class loader. All Java objects belong to classes and the applet class loader determines how and when an applet is allowed to add classes to a running Java environment. It also makes sure that important parts of the Java Runtime Environment(JRE) are not replaced by any applet code. In a Java environment ,there can be many active class loaders and at the same time ,each class loader can create its own runtime environment . The applet class loader loads all the applets and their references.

The Security Manager

The third level ,and a very important part of the Java sandbox ,is the security manager . The security Manager defines the boundaries of the sandbox. The Java API refers to the security manager before it allows any access to the resource. It restricts the way in which the applet uses visible interfaces. While loading classes,the class loader always compiles with the security manager’s decision . Built -in classes are given preference over classes loaded over the net. The sandbox can be used to run untrusted code on the users machine.

NOTE:-A Java protected domain is an extension of the Java sandbox in a file system. Java protected domains enable the use of permission or use a default setting for providing access to function calls outside the sandbox.

Comments

Topics: ,

About the Author:
Vaibhav Pandey got offered employment from an Indian Multinational IT Company. He is 21 years old. He has a huge interest in Java programming and has liked it from his study days. Vaibhav loves to blog and share his experiences and thoughts. He now resides in Lucknow, a state capital in India. Check out his blog at http://javatutorialsworld.blogspot.com.
DevWebPro is an iEntry Network ® publication - © 1998-2010 All Rights Reserved