File access Network access

well look at how the security manager is generally implemented. Chapter 4. The Security Manager

Chapter 5. The Access Controller

In the last chapter, we looked at the security manager, which provides the security policy interface used by the core Java API. The implementation of most security managers, however, is based entirely upon the access controller. In this chapter, were going to look at the access controller and its related classes. Along the way, well cover a number of important topics: How to implement and use your own permission classes to extend the mechanism of the Java sandbox to your own applications. • How to implement a different security policy so that permissions can be set in new ways e.g., by reading them from a central server rather than from a collection of files. • How the core Java API is able to perform certain operations that other classes cannot. • How to create objects that can only be accessed if you have the appropriate permission. • The access controller is built upon the four concepts we examined in Chapter 2 : Code sources An encapsulation of the location from which certain Java classes were obtained. Permissions An encapsulation of a request to perform a particular operation. Policies An encapsulation of all the specific permissions that should be granted to specific code sources. Protection domains An encapsulation of a particular code source and the permissions granted to that code source. Well start by examining how these concepts map to the Java API.

5.1 The CodeSource Class

A code source is a simple object that reflects the URL from which a class was loaded and the keys if any that were used to sign that class. Class loaders are responsible for creating and manipulating code source objects, as well see in the next chapter. The CodeSource class java.security.CodeSource has a few interesting methods: public CodeSourceURL url, Certificate cers[] Create a code source object for code that has been loaded from the specified URL. The optional array of certificates is the array of public keys that have signed the code that was loaded from this URL. These certificates are typically obtained from reading a signed jar file; if the code was not signed, this argument should be null . Similarly, the URL may be null . public boolean equalsObject o