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, org.apache.lenya.ac.InheritingPolicyManager, org.apache.lenya.ac.PolicyManager

public class FilePolicyManager
extends org.apache.avalon.framework.logger.AbstractLogEnabled
implements org.apache.lenya.ac.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
           
 
Fields inherited from interface org.apache.lenya.ac.PolicyManager
ROLE
 
Constructor Summary
FilePolicyManager()
          Creates a new FilePolicyManager.
 
Method Summary
 void accreditableAdded(org.apache.lenya.ac.AccreditableManager manager, org.apache.lenya.ac.Accreditable accreditable)
           
 void accreditableRemoved(org.apache.lenya.ac.AccreditableManager manager, org.apache.lenya.ac.Accreditable accreditable)
           
protected  DefaultPolicy buildPolicy(org.apache.lenya.ac.AccreditableManager controller, java.lang.String url, java.lang.String policyFilename)
          Builds a policy from a file.
 org.apache.lenya.ac.Policy buildSubtreePolicy(org.apache.lenya.ac.AccreditableManager controller, java.lang.String url)
          Builds a subtree policy from a file.
 void dispose()
           
protected  org.apache.lenya.ac.cache.SourceCache getCache()
          Returns the source cache.
 org.apache.lenya.ac.Credential[] getCredentials(org.apache.lenya.ac.AccreditableManager controller, java.lang.String url)
           
 org.apache.lenya.ac.Role[] getGrantedRoles(org.apache.lenya.ac.AccreditableManager accreditableManager, org.apache.lenya.ac.Identity identity, java.lang.String url)
           
 org.apache.lenya.ac.Policy[] getPolicies(org.apache.lenya.ac.AccreditableManager controller, java.lang.String url)
           
 java.io.File getPoliciesDirectory()
          Get the path to the policies directory.
 org.apache.lenya.ac.Policy getPolicy(org.apache.lenya.ac.AccreditableManager controller, java.lang.String url)
           
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(org.apache.lenya.ac.AccreditableManager manager, org.apache.lenya.ac.Accreditable accreditable, java.io.File policyDirectory)
          Removes an accreditable from all policies within a certain directory tree.
protected  void savePolicy(org.apache.lenya.ac.Policy policy, java.io.File file)
          Saves a policy to a file.
protected  void savePolicy(java.lang.String url, org.apache.lenya.ac.Policy policy, java.lang.String filename)
          Saves a policy to a file.
 void saveSubtreePolicy(java.lang.String url, org.apache.lenya.ac.Policy policy)
          Saves a Subtree 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

SUBTREE_FILENAME

protected static final java.lang.String SUBTREE_FILENAME
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 org.apache.lenya.ac.cache.SourceCache getCache()
Returns the source cache.

Returns:
A source cache.

buildSubtreePolicy

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

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

buildPolicy

protected DefaultPolicy buildPolicy(org.apache.lenya.ac.AccreditableManager controller,
                                    java.lang.String url,
                                    java.lang.String policyFilename)
                             throws org.apache.lenya.ac.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:
org.apache.lenya.ac.AccessControlException - when something went wrong.

getPolicySourceURI

protected java.lang.String getPolicySourceURI(java.lang.String url,
                                              java.lang.String policyFilename)
                                       throws org.apache.lenya.ac.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:
org.apache.lenya.ac.AccessControlException - if an error occurs

getPolicyFile

protected java.io.File getPolicyFile(java.lang.String url,
                                     java.lang.String policyFilename)
                              throws org.apache.lenya.ac.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:
org.apache.lenya.ac.AccessControlException - when an error occurs.

saveSubtreePolicy

public void saveSubtreePolicy(java.lang.String url,
                              org.apache.lenya.ac.Policy policy)
                       throws org.apache.lenya.ac.AccessControlException
Saves a Subtree policy.

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

savePolicy

protected void savePolicy(java.lang.String url,
                          org.apache.lenya.ac.Policy policy,
                          java.lang.String filename)
                   throws org.apache.lenya.ac.AccessControlException
Saves a policy to a file.

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

savePolicy

protected void savePolicy(org.apache.lenya.ac.Policy policy,
                          java.io.File file)
                   throws org.apache.lenya.ac.AccessControlException
Saves a policy to a file.

Parameters:
policy - The policy to save.
file - The file.
Throws:
org.apache.lenya.ac.AccessControlException - when an error occurs.

getPolicy

public org.apache.lenya.ac.Policy getPolicy(org.apache.lenya.ac.AccreditableManager controller,
                                            java.lang.String url)
                                     throws org.apache.lenya.ac.AccessControlException
Specified by:
getPolicy in interface org.apache.lenya.ac.PolicyManager
Throws:
org.apache.lenya.ac.AccessControlException
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 org.apache.lenya.ac.AccessControlException
Get the path to the policies directory.

Returns:
the path to the policies directory
Throws:
org.apache.lenya.ac.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 org.apache.lenya.ac.AccessControlException
Sets the policies directory.

Parameters:
directory - The directory.
Throws:
org.apache.lenya.ac.AccessControlException - if the directory is not a directory

getPolicies

public org.apache.lenya.ac.Policy[] getPolicies(org.apache.lenya.ac.AccreditableManager controller,
                                                java.lang.String url)
                                         throws org.apache.lenya.ac.AccessControlException
Specified by:
getPolicies in interface org.apache.lenya.ac.InheritingPolicyManager
Throws:
org.apache.lenya.ac.AccessControlException
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(org.apache.lenya.ac.AccreditableManager manager,
                                  org.apache.lenya.ac.Accreditable accreditable,
                                  java.io.File policyDirectory)
                           throws org.apache.lenya.ac.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:
org.apache.lenya.ac.AccessControlException - when an error occurs.

accreditableRemoved

public void accreditableRemoved(org.apache.lenya.ac.AccreditableManager manager,
                                org.apache.lenya.ac.Accreditable accreditable)
                         throws org.apache.lenya.ac.AccessControlException
Specified by:
accreditableRemoved in interface org.apache.lenya.ac.PolicyManager
Throws:
org.apache.lenya.ac.AccessControlException
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(org.apache.lenya.ac.AccreditableManager manager,
                              org.apache.lenya.ac.Accreditable accreditable)
                       throws org.apache.lenya.ac.AccessControlException
Specified by:
accreditableAdded in interface org.apache.lenya.ac.PolicyManager
Throws:
org.apache.lenya.ac.AccessControlException
See Also:
PolicyManager.accreditableAdded(org.apache.lenya.ac.AccreditableManager, org.apache.lenya.ac.Accreditable)

getCredentials

public org.apache.lenya.ac.Credential[] getCredentials(org.apache.lenya.ac.AccreditableManager controller,
                                                       java.lang.String url)
                                                throws org.apache.lenya.ac.AccessControlException
Specified by:
getCredentials in interface org.apache.lenya.ac.PolicyManager
Throws:
org.apache.lenya.ac.AccessControlException

getGrantedRoles

public org.apache.lenya.ac.Role[] getGrantedRoles(org.apache.lenya.ac.AccreditableManager accreditableManager,
                                                  org.apache.lenya.ac.Identity identity,
                                                  java.lang.String url)
                                           throws org.apache.lenya.ac.AccessControlException
Specified by:
getGrantedRoles in interface org.apache.lenya.ac.PolicyManager
Throws:
org.apache.lenya.ac.AccessControlException


Copyright $ Apache Software Foundation. All Rights Reserved.