net.sf.container.imp
Class CodebaseFactory

java.lang.Object
  extended by net.sf.container.imp.AbstractParseListener
      extended by net.sf.container.imp.AbstractPolicyFactory
          extended by net.sf.container.imp.CodebaseFactory
All Implemented Interfaces:
ContainerFactory, PolicyParseListener

public class CodebaseFactory
extends AbstractPolicyFactory

Container factory providing Container creation where container policies are based on "codeBase" identification.

The factory is instantiated with list of policies and consequent container instantiations are resolved by looking up java.security.CodeSource.getLocation() for matching permission sets.

Example:

 if the policy file contains:
 grant codeBase "file://no.domain/sandbox" {
                permission java.util.PropertyPermission "java.version", "read";
 };
 grant codeBase "file://${java.home}/no.domain/trusted" {
                permission java.util.PropertyPermission "java.path", "read";
                permission java.util.PropertyPermission "java.version", "read";
 };

 containerFactory.newContainer("file://no.domain/sandbox") would
 result in sandbox permissions set.

 containerFactory.newContainer("file://no.domain/trusted") would
 result in trusted permissions set.

 containerFactory.newContainer(null) would
 result in no permissions as there wasn't any default permissions set defined.
 
created on Jun 10, 2005

Since:
Version:
$Revision: 1.1 $
Author:
fiykov

Nested Class Summary
 
Nested classes/interfaces inherited from class net.sf.container.imp.AbstractParseListener
AbstractParseListener.GrantEntry
 
Constructor Summary
CodebaseFactory()
          instantiate a factory with policies defined in the policy file
CodebaseFactory(java.net.URL policyFile)
          instantiate a factory with policies defined in the policy file
CodebaseFactory(java.net.URL policyFile, PolicyParser parser)
          instantiate a factory with policies defined in the policy file
 
Method Summary
 ContainerFactory getContainerFactory()
           
 Container newContainer(java.lang.Object permissionsCriteria)
          create new container based on codeBase permission set criteria
 Container newContainer(java.lang.String codeBase)
          create new container based on the url it is supposed that there is only one policy "codeBase" matching to that URL.
 
Methods inherited from class net.sf.container.imp.AbstractPolicyFactory
newContainer, setPolicies, setPolicies
 
Methods inherited from class net.sf.container.imp.AbstractParseListener
beginParsing, endGrant, endParsing, endPolicyFile, getAllKeyStores, getAllPolicies, getKeyStores, getProtectionDomains, lookupCertificate, lookupCertificatesList, newGrant, newKeystore, newPermission, newPolicyFile, newUrlInputSteam, parseEnvVars, replaceCurrentUrlPosition, resolveKsInputSteam, spreadDefaultGrants, toExternalForm
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CodebaseFactory

public CodebaseFactory()
instantiate a factory with policies defined in the policy file

See Also:
AbstractPolicyFactory.AbstractPolicyFactory()

CodebaseFactory

public CodebaseFactory(java.net.URL policyFile)
                throws java.io.FileNotFoundException,
                       PolicyParseException,
                       java.io.IOException
instantiate a factory with policies defined in the policy file

Parameters:
policyFile -
Throws:
java.io.FileNotFoundException
PolicyParseException
java.io.IOException
See Also:
AbstractPolicyFactory.AbstractPolicyFactory(URL)

CodebaseFactory

public CodebaseFactory(java.net.URL policyFile,
                       PolicyParser parser)
                throws java.io.FileNotFoundException,
                       PolicyParseException,
                       java.io.IOException
instantiate a factory with policies defined in the policy file

Parameters:
policyFile -
parser -
Throws:
java.io.FileNotFoundException
PolicyParseException
java.io.IOException
See Also:
AbstractPolicyFactory.AbstractPolicyFactory(URL,PolicyParser)
Method Detail

getContainerFactory

public ContainerFactory getContainerFactory()
Returns:
the associated with this listener container factory

newContainer

public Container newContainer(java.lang.Object permissionsCriteria)
create new container based on codeBase permission set criteria

Parameters:
permissionsCriteria -
Returns:
new Container object

newContainer

public Container newContainer(java.lang.String codeBase)
create new container based on the url

it is supposed that there is only one policy "codeBase" matching to that URL.

If "codeBase" is null, default permissions set is added.

If no default permissions set exists then the Container is created with no permissions at all.

Examples: "file://no.domain/sandbox", "file://${java.home}/no.domain/trusted", null

Parameters:
codeBase -
Returns:
new Container object


Copyright © 2007 Nikolay Fiykov. All Rights Reserved.