org.apache.lenya.ac.file
Class FilePolicyManager

java.lang.Object
  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by org.apache.lenya.ac.file.FilePolicyManager
All Implemented Interfaces:
org.apache.avalon.framework.activity.Disposable, org.apache.avalon.framework.component.Component, org.apache.avalon.framework.logger.LogEnabled, org.apache.avalon.framework.parameters.Parameterizable, org.apache.avalon.framework.service.Serviceable, InheritingPolicyManager, PolicyManager

public class FilePolicyManager
extends org.apache.avalon.framework.logger.AbstractLogEnabled
implements InheritingPolicyManager, org.apache.avalon.framework.parameters.Parameterizable, org.apache.avalon.framework.activity.Disposable, org.apache.avalon.framework.service.Serviceable

A PolicyBuilder is used to build policies.


Field Summary
protected static java.lang.String DIRECTORY_PARAMETER
           
protected static java.lang.String SUBTREE_FILENAME
           
protected static java.lang.String URL_FILENAME
           
protected static java.lang.String USER_ADMIN_URL
           
 
Fields inherited from interface org.apache.lenya.ac.PolicyManager
ROLE
 
Constructor Summary
FilePolicyManager()
          Creates a new FilePolicyManager.
 
Method Summary
 void accreditableAdded(AccreditableManager manager, Accreditable accreditable)
          Called when an accreditable was added.
 void accreditableRemoved(AccreditableManager manager, Accreditable accreditable)
          Called when an accreditable was removed.
protected  DefaultPolicy buildPolicy(AccreditableManager controller, java.lang.String url, java.lang.String policyFilename)
          Builds a policy from a file.
 DefaultPolicy buildSubtreePolicy(AccreditableManager controller, java.lang.String url)
          Builds a subtree policy from a file.
 DefaultPolicy buildURLPolicy(AccreditableManager controller, java.lang.String url)
          Builds the URL policy for a URL from a file.
 void dispose()
           
protected  SourceCache getCache()
          Returns the source cache.
 DefaultPolicy[] getPolicies(AccreditableManager controller, java.lang.String url)
          Returns the existing policies for all URL steps, beginning with the root policy.
 java.io.File getPoliciesDirectory()
          Get the path to the policies directory.
 Policy getPolicy(AccreditableManager controller, java.lang.String url)
          Returns the policy for a given page.
protected  java.io.File getPolicyFile(java.lang.String url, java.lang.String policyFilename)
          Returns the policy file for a certain URL.
protected  java.lang.String getPolicySourceURI(java.lang.String url, java.lang.String policyFilename)
          Returns the policy file URI for a URL and a policy filename.
protected  org.apache.avalon.framework.service.ServiceManager getServiceManager()
          Returns the service manager.
 void parameterize(org.apache.avalon.framework.parameters.Parameters parameters)
           
protected  void removeAccreditable(AccreditableManager manager, Accreditable accreditable, java.io.File policyDirectory)
          Removes an accreditable from all policies within a certain directory tree.
protected  void savePolicy(DefaultPolicy policy, java.io.File file)
          Saves a policy to a file.
protected  void savePolicy(java.lang.String url, DefaultPolicy policy, java.lang.String filename)
          Saves a policy to a file.
 void saveSubtreePolicy(java.lang.String url, DefaultPolicy policy)
          Saves a Subtree policy.
 void saveURLPolicy(java.lang.String url, DefaultPolicy policy)
          Saves a URL policy.
 void service(org.apache.avalon.framework.service.ServiceManager manager)
           
 void setPoliciesDirectory(java.io.File directory)
          Sets the policies directory.
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

URL_FILENAME

protected static final java.lang.String URL_FILENAME
See Also:
Constant Field Values

SUBTREE_FILENAME

protected static final java.lang.String SUBTREE_FILENAME
See Also:
Constant Field Values

USER_ADMIN_URL

protected static final java.lang.String USER_ADMIN_URL
See Also:
Constant Field Values

DIRECTORY_PARAMETER

protected static final java.lang.String DIRECTORY_PARAMETER
See Also:
Constant Field Values
Constructor Detail

FilePolicyManager

public FilePolicyManager()
Creates a new FilePolicyManager.

Method Detail

getCache

protected SourceCache getCache()
Returns the source cache.

Returns:
A source cache.

buildURLPolicy

public DefaultPolicy buildURLPolicy(AccreditableManager controller,
                                    java.lang.String url)
                             throws AccessControlException
Builds the URL policy for a URL from a file. When the file is not present, an empty policy is returned.

Specified by:
buildURLPolicy in interface InheritingPolicyManager
Parameters:
controller - The access controller to use.
url - The URL inside the web application.
Returns:
A policy.
Throws:
AccessControlException - when something went wrong.

buildSubtreePolicy

public DefaultPolicy buildSubtreePolicy(AccreditableManager controller,
                                        java.lang.String url)
                                 throws AccessControlException
Builds a subtree policy from a file. When the file is not present, an empty policy is returned.

Specified by:
buildSubtreePolicy in interface InheritingPolicyManager
Parameters:
controller - The access controller to use.
url - The URL inside the web application.
Returns:
A policy.
Throws:
AccessControlException - when something went wrong.

buildPolicy

protected DefaultPolicy buildPolicy(AccreditableManager controller,
                                    java.lang.String url,
                                    java.lang.String policyFilename)
                             throws AccessControlException
Builds a policy from a file. When the file is not present, an empty policy is returned.

Parameters:
controller - The access controller to use.
url - The url.
policyFilename - The policy filename.
Returns:
A policy.
Throws:
AccessControlException - when something went wrong.

getPolicySourceURI

protected java.lang.String getPolicySourceURI(java.lang.String url,
                                              java.lang.String policyFilename)
                                       throws AccessControlException
Returns the policy file URI for a URL and a policy filename.

Parameters:
url - The url to get the file for.
policyFilename - The name of the policy file.
Returns:
A String.
Throws:
AccessControlException - if an error occurs

getPolicyFile

protected java.io.File getPolicyFile(java.lang.String url,
                                     java.lang.String policyFilename)
                              throws AccessControlException
Returns the policy file for a certain URL.

Parameters:
url - The URL to get the policy for.
policyFilename - The policy filename.
Returns:
A file.
Throws:
AccessControlException - when an error occurs.

saveURLPolicy

public void saveURLPolicy(java.lang.String url,
                          DefaultPolicy policy)
                   throws AccessControlException
Saves a URL policy.

Specified by:
saveURLPolicy in interface InheritingPolicyManager
Parameters:
url - The URL to save the policy for.
policy - The policy to save.
Throws:
AccessControlException - when something went wrong.

saveSubtreePolicy

public void saveSubtreePolicy(java.lang.String url,
                              DefaultPolicy policy)
                       throws AccessControlException
Saves a Subtree policy.

Specified by:
saveSubtreePolicy in interface InheritingPolicyManager
Parameters:
url - The url to save the policy for.
policy - The policy to save.
Throws:
AccessControlException - when something went wrong.

savePolicy

protected void savePolicy(java.lang.String url,
                          DefaultPolicy policy,
                          java.lang.String filename)
                   throws AccessControlException
Saves a policy to a file.

Parameters:
url - The URL to save the policy for.
policy - The policy.
filename - The file.
Throws:
AccessControlException - if something goes wrong.

savePolicy

protected void savePolicy(DefaultPolicy policy,
                          java.io.File file)
                   throws AccessControlException
Saves a policy to a file.

Parameters:
policy - The policy to save.
file - The file.
Throws:
AccessControlException - when an error occurs.

getPolicy

public Policy getPolicy(AccreditableManager controller,
                        java.lang.String url)
                 throws AccessControlException
Description copied from interface: PolicyManager
Returns the policy for a given page.

Specified by:
getPolicy in interface PolicyManager
Parameters:
controller - The access controller.
url - The url inside the web application.
Returns:
The policy.
Throws:
AccessControlException - when something went wrong.
See Also:
PolicyManager.getPolicy(org.apache.lenya.ac.AccreditableManager, java.lang.String)

parameterize

public void parameterize(org.apache.avalon.framework.parameters.Parameters parameters)
                  throws org.apache.avalon.framework.parameters.ParameterException
Specified by:
parameterize in interface org.apache.avalon.framework.parameters.Parameterizable
Throws:
org.apache.avalon.framework.parameters.ParameterException
See Also:
Parameterizable.parameterize(org.apache.avalon.framework.parameters.Parameters)

getPoliciesDirectory

public java.io.File getPoliciesDirectory()
                                  throws AccessControlException
Get the path to the policies directory.

Returns:
the path to the policies directory
Throws:
AccessControlException - if an error occurs

service

public void service(org.apache.avalon.framework.service.ServiceManager manager)
             throws org.apache.avalon.framework.service.ServiceException
Specified by:
service in interface org.apache.avalon.framework.service.Serviceable
Throws:
org.apache.avalon.framework.service.ServiceException
See Also:
Serviceable.service(org.apache.avalon.framework.service.ServiceManager)

setPoliciesDirectory

public void setPoliciesDirectory(java.io.File directory)
                          throws AccessControlException
Sets the policies directory.

Parameters:
directory - The directory.
Throws:
AccessControlException - if the directory is not a directory

getPolicies

public DefaultPolicy[] getPolicies(AccreditableManager controller,
                                   java.lang.String url)
                            throws AccessControlException
Description copied from interface: InheritingPolicyManager
Returns the existing policies for all URL steps, beginning with the root policy.

Specified by:
getPolicies in interface InheritingPolicyManager
Parameters:
controller - The accreditable manager to use.
url - The URL inside the web application.
Returns:
An array of policies.
Throws:
AccessControlException - when something went wrong.
See Also:
InheritingPolicyManager.getPolicies(org.apache.lenya.ac.AccreditableManager, java.lang.String)

dispose

public void dispose()
Specified by:
dispose in interface org.apache.avalon.framework.activity.Disposable
See Also:
Disposable.dispose()

removeAccreditable

protected void removeAccreditable(AccreditableManager manager,
                                  Accreditable accreditable,
                                  java.io.File policyDirectory)
                           throws AccessControlException
Removes an accreditable from all policies within a certain directory tree.

Parameters:
manager - The accreditable manager which owns the accreditable.
accreditable - The accreditable to remove.
policyDirectory - The directory where the policies are located.
Throws:
AccessControlException - when an error occurs.

accreditableRemoved

public void accreditableRemoved(AccreditableManager manager,
                                Accreditable accreditable)
                         throws AccessControlException
Description copied from interface: PolicyManager
Called when an accreditable was removed. Used to clean up the policies and to remove the admin interface policy.

Specified by:
accreditableRemoved in interface PolicyManager
Parameters:
manager - The accreditable manager the accreditable belonged to.
accreditable - The accreditable that was removed.
Throws:
AccessControlException - when something went wrong.
See Also:
PolicyManager.accreditableRemoved(org.apache.lenya.ac.AccreditableManager, org.apache.lenya.ac.Accreditable)

getServiceManager

protected org.apache.avalon.framework.service.ServiceManager getServiceManager()
Returns the service manager.

Returns:
A service manager.

accreditableAdded

public void accreditableAdded(AccreditableManager manager,
                              Accreditable accreditable)
                       throws AccessControlException
Description copied from interface: PolicyManager
Called when an accreditable was added. Used to create the admin interface policy.

Specified by:
accreditableAdded in interface PolicyManager
Parameters:
manager - The accreditable manager the accreditable belonged to.
accreditable - The accreditable that was removed.
Throws:
AccessControlException - when something went wrong.
See Also:
PolicyManager.accreditableAdded(org.apache.lenya.ac.AccreditableManager, org.apache.lenya.ac.Accreditable)


Copyright © 1999-2005 Apache Software Foundation. All Rights Reserved.