|
|
Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs
FileInputStream class, and hands it to the consumer. The consumer can immediately use the resource, hold on to it, or hand it to another
consumer. How do you ensure that the consumer thread doesn't use resources it should not have access to?
When confronted with situations like the two outlined above, you should develop solutions that take advantage of the security
features provided by the Java programming language and class library. This will save you work and prevent you from making
mistakes. This month I'll take you on a tour of the AccessControlContext and the GuardedObject classes, two tools that will help you solve problems like those above.
Although the two preceding problems differ slightly, both share a common characteristic. They both involve making security-related decisions outside the bounds of Java's standard security machinery.
In order to understand what that means, it's worth taking a few moments to learn about Java security. Let's dive in.
Every method is part of a class. Every class is associated with a protection domain. A protection domain is a collection of classes that share critical security-related features -- they originate from the same place, and the same entity signs them. Every protection domain is associated with a set of permissions that define the security-sensitive operations that classes in the protection domain can perform.
That makes up only part of the picture. The decision whether or not to allow a security-sensitive operation to proceed depends not only on the permissions held by the current method but also on the permissions held by the method that called the current method, and by the method that called the method that called the current method, and so on, all the way back to the first method invocation by the Java Virtual Machine (VM).

Figure 1. A thread's execution context
If you imagine the chain of method calls as a stack of blocks, it would look something like Figure 1, which I refer to as the execution context. Every thread has its own execution context.
By examining the execution context, the AccessController class decides whether or not to allow a method to execute a piece of security-critical code. More specifically, it makes
the determination by examining the protection domains associated with the methods in the execution context. The AccessController class permits the operation if and only if every protection domain in the current execution context holds the appropriate
permission. This "principle of least privilege" is a key characteristic of the Java security model.
AccessControlConttext API documentation http://java.sun.com/j2se/1.3/docs/api/java/security/AccessControlContext.html
GuardedObject API documentationGuardedObject classAccessControlContext class