Java security: How to install the security manager and customize your security policy
Learn about the security manager and the Java API, what remains unprotected by the security manager, and security beyond the
JVM architecture
By Bill Venners, JavaWorld.com, 11/01/97
- Digg
- Reddit
- SlashDot
- Stumble
- del.icio.us
- Technorati
- dzone
This month's article continues the discussion of Java's security model that began in August's "
Under the Hood." In that article, I sketched overview of the security mechanisms built into the Java virtual machine (JVM). I also looked
closely at one aspect of those security mechanisms: the JVM's built-in safety features. In
September's column I examined the class loader architecture, and in the
October column, the class verifier. In this installment of the security series, I describe the security manager -- the fourth and final
piece of the JVM's core security architecture -- and I finish up with a brief discussion of the ways in which Java's security
strategy extends beyond the JVM's architecture.
The security manager and the Java API
As described in last month's "Under the Hood," you can prevent code loaded by different class loaders from interfering with
one another inside the JVM by using a class-file verifier. But to protect assets external to the Java virtual machine, you
must use a security manager. The security manager defines the outer boundaries of the sandbox. (For a refresher on the Java
sandbox, see the first section of my August "Under the Hood" column.)
A security manager is any class that descends from class java.lang.SecurityManager. Because they are written in Java, security managers are customizable. A security manager allows you to establish a custom
security policy for an application.
The Java API enforces the custom security policy by asking the security manager for permission to take any action before it
does something that potentially is unsafe. For each potentially unsafe action, there is a method in the security manager that
defines whether or not that action is allowed by the sandbox. Each method's name starts with "check," so, for example, checkRead() defines whether or not a thread is allowed to read to a specified file, and checkWrite() defines whether or not a thread is allowed to write to a specified file. The implementation of these methods is what defines
the custom security policy of the application.
Most of the activities that are regulated by a "check" method are listed below. The classes of the Java API check with the
security manager before they:
- Accept a socket connection from a specified host and port number
- Modify a thread (change its priority, stop it, and so on)
- Open a socket connection to a specified host and port number
- Create a new class loader
- Delete a specified file
- Create a new process
- Cause the application to exit
- Load a dynamic library that contains native methods
- Wait for a connection on a specified local port number
- Load a class from a specified package (used by class loaders)
- Add a new class to a specified package (used by class loaders)
- Access or modify system properties
- Access a specified system property
- Read from a specified file
- Write to a specified file
Because the Java API always checks with the security manager before it performs any of the activities listed above, the Java
API will not perform any action forbidden under the security policy established by the security manager.
- Digg
- Reddit
- SlashDot
- Stumble
- del.icio.us
- Technorati
- dzone
Resources
- The book The Java virtual machine Specification (http://www.aw.com/cp/lindholm-yellin.html), by Tim Lindholm and Frank Yellin (ISBN 0-201-63452-X), part of The Java Series (http://www.aw.com/cp/javaseries.html), from Addison-Wesley, is the definitive Java virtual machine reference.
- Secure Computing with JavaNow and the Future (a whitepaper) http://www.javasoft.com/marketing/collateral/security.html
- Applet Security FAQ http://www.javasoft.com/sfaq/
- Low Level Security in Java, by Frank Yellin http://www.javasoft.com/sfaq/verifier.html
- The Java Security Home Page http://www.javasoft.com/security/
- See the Hostile Applets Home Page http://www.math.gatech.edu/~mladue/HostileApplets.html
- For more information about authentication in JDK 1.1, see http://www.javasoft.com/products/jdk/1.1/docs/guide/security/index.html.
- A whitepaper that describes the various aspects of Java's overall security strategy is http://www.javasoft.com/security/whitepaper.html.
- The book Java SecurityHostile Applets, Holes, and Antidotes, by Dr. Gary McGraw and Ed Felton, gives a thorough analysis of security issues surrounding Java. http://www.rstcorp.com/java-security.html
- Previous "Under The Hood" articles
- The Lean, Mean Virtual Machine -- Gives an introduction to the Java virtual machine.
- The Java Class File Lifestyle -- Gives an overview of the Java class file, the file format into which all Java programs are compiled.
- Java's Garbage- Collected Heap -- Gives an overview of garbage collection in general and the garbage-collected heap of the Java virtual machine in particular.
- Bytecode Basics -- Introduces the bytecodes of the Java virtual machine, and discusses primitive types, conversion operations, and stack
operations in particular.
- Floating Point Arithmetic -- Describes the Java virtual machine's floating-point support and the bytecodes that perform floating point operations.
- Logic and Arithmetic -- Describes the Java virtual machine's support for logical and integer arithmetic, and the related bytecodes.
- Objects and Arrays -- Describes how the Java virtual machine deals with objects and arrays, and discusses the relevant bytecodes.
- Exceptions -- Describes how the Java virtual machine deals with exceptions, and discusses the relevant bytecodes.
- Try-Finally -- Describes how the Java virtual machine implements try-finally clauses, and discusses the relevant bytecodes.
- Control Flow -- Describes how the Java virtual machine implements control flow and discusses the relevant bytecodes.
- The Architecture of Aglets -- Describes the inner workings of aglets, IBM's autonomous Java-based software agent technology.
- The Point of Aglets -- Analyzes the real-world utility of mobile agents such as aglets, IBM's autonomous Java- based software agent technology.
- Method Invocation and Return -- Describes the four ways the Java virtual machine invokes methods, including the relevant bytecodes.
- Thread Synchronization -- Shows how thread synchronization works in the Java virtual machine. Discusses the bytecodes for entering and exiting monitors.
- Java's Security Architecture -- Gives an overview of the security model built into the JVM and looks at the JVM's built-in safety features.
- Security and Class Loaders -- Shows how the JVM's class loader architecture contributes to Java's overall security strategy.
- Security and the Class Verifier -- Explains how the class verifier fits into the JVM's security architecture.