Java Reference
In-Depth Information
ACCEPT {
[ org.foo.BeforeDateCondition "1282684888" ]
( java.security.AllPermission "*" "*" )
} "DATE CONDITION"
As we mentioned previously, you need to put this condition on the class path of the
framework to use it. You can achieve this by adding it directly to your application class
path or by using a special kind of bundle called an extension bundle . Because it's more
dynamic, you'll use an extension bundle.
Extension bundles
Extension bundles can deliver optional parts of the framework implementation or pro-
vide functionality that must reside on the boot class path. For example, a framework
vendor can supply optional services like Conditional Permission Admin and Start
Level as framework-extension bundles instead of building them into the framework
for more modular framework deployments.
An extension bundle is treated as a fragment of the system bundle. The system bun-
dle has a standard bundle symbolic name, system.bundle , but it also has an imple-
mentation-specific alias. For example, the following example uses the Fragment-
Host header to specify an extension bundle for the Felix framework implementation:
Fragment-Host: org.apache.felix.framework; extension:=framework
Because extension bundles are special, there are certain restrictions on what you can
do with them. For example, extension bundles can't specify any of the following head-
ers: Import-Package , Require-Bundle , Bundle-NativeCode , DynamicImport-
Package , and Bundle-Activator . Typically, they're used to add stuff to the class
path and possibly to export additional packages from the system bundle.
To p a c k a g e t h i s c u s t o m c o n d i t i o n i n s i d e a n e x t e n s i o n b u n d l e , y o u c r e a t e a b u n d l e
with the following manifest:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.foo.beforedatecondition
Bundle-Name: Before Date Condition Extension Bundle
Bundle-Version: 1.0.0
Fragment-Host: system.bundle; extension:=framework
Export-Package: org.foo
Now you need to install this bundle into your framework, after which you can use the
condition in your security policy. That was fairly easy, so let's move on to a more
sophisticated example.
14.7.3
User-input condition
Often, the only means to determine whether some code is allowed to perform an
operation is to ask the user. We see this regularly when running Java applications from
a web browser or on a mobile phone. As you may guess, you can implement such a
 
Search WWH ::




Custom Search