|
To access the contents, click the chapter and section titles.
Platinum Edition Using HTML 4, XML, and Java 1.2
The third rule prevents someone from accessing non-local hard drives, such as those on a local area network or intranet. Like the first rule, this provision closes many opportunities the malicious programmer might have for stealing confidential information or for planting malicious programs.
Sun provides sample applets at http://java.sun.com/sfaq/#examples to test your browsers security. Your browser should catch security exceptions when you attempt to run these applets from the Internet. You shouldnt get exceptions when you run http://java.sun.com/sfaq/example/getOpenProperties.html, which demonstrates the 10 system properties untrusted applets are allowed to read, or http://java.sun.com/sfaq/example/myWindow.html, which opens a standalone window (although you should see the Untrusted Applet message). Note that Sun recommends somewhat tighter restrictions for applets downloaded from the Web versus those loaded from the local file system. For full details see http://java.sun.com/sfaq/. Although no one has suggested that its impossible to build malicious appletssomeone is probably working on one right nowSun has certainly gone to great lengths to make it difficult. If someone wants to attack your system, its far easier for them to attack through a mechanism such as an ActiveX control than through a Java applet. As long as most users are downloading both, malicious programmers will continue to favor ActiveX controls.
The Security of Compiled CodeThe Java compiler checks Java code for security violations. It is a thorough, stringent compiler that enforces the restrictions previously listed. However, it is possible that Java code could be compiled with a fixed compiler that allows illegal operations. This is where the Java class loader and bytecode verifier come into play. Various types of security are enforced by the runtime system on compiled code. Java .class File StructureJava applets and applications are made up of .class files that are compiled bytecode. All public classes used in a Java applet or application reside in their own separate .class file. They may be transferred over the network a file at a time or bundled into a .zip or .jar file. The .class file is a series of bytes. Longer values are formed by reading two or four of these bytes and joining them together. Each .class file contains
The constant pool is how constant information about the class is stored. It can be any of the following:
As previously mentioned, all references to variables and classes in the Java language are done through symbolic names, not pointers. This is true in the .class file as well. Elsewhere in the .class file, references to variables, methods, and objects are accomplished by referring to indices in this constant pool. Security is thus maintained inside the .class file.
The class loader of most current Java implementations, including Suns own HotJava browser, considers any code that comes from a remote source to be potentially hostile and will not use any native code contained in a Java .class file unless the user designates the applet as trusted. Some of these browsers will run native code loaded from local .class files, however. More About BytecodesIn addition to the actual bytecodes that execute a method, the CODE attribute also supplies other information about the method. This information is for the memory manager, the bytecode verifier, and the JVMs exception handling mechanism:
Six primitive types are available in the JVM:
The Java VM also recognizes several array types:
In the case of an array of handles, an additional type field indicates the class of object that the array can store. Each method has its own expression-evaluation stack and set of local registers. The registers must be 32-bit and hold any of the primitive types other than the double floats and the long integers. These are stored in two consecutive registers, and the JVM instructions, opcodes, address them using the index of the lower-numbered register.
|
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement. |