org.fcrepo.server.security.xacml.pdp.data
Class DbXmlPolicyIndex

java.lang.Object
  extended by org.fcrepo.server.security.xacml.pdp.data.PolicyIndexBase
      extended by org.fcrepo.server.security.xacml.pdp.data.XPathPolicyIndex
          extended by org.fcrepo.server.security.xacml.pdp.data.DbXmlPolicyIndex
All Implemented Interfaces:
PolicyIndex

public class DbXmlPolicyIndex
extends XPathPolicyIndex
implements PolicyIndex

Encapsulates indexed access to policies stored in DbXml. See DbXmlPolicyStore for CRUD operations on policies in DbXml.

Version:
$Id$
Author:
Stephen Bayliss

Field Summary
 
Fields inherited from class org.fcrepo.server.security.xacml.pdp.data.PolicyIndexBase
ACTION_KEY, ENVIRONMENT_KEY, indexed, indexMap, m_policyReader, METADATA_POLICY_NS, namespaces, RESOURCE_KEY, SUBJECT_KEY
 
Fields inherited from interface org.fcrepo.server.security.xacml.pdp.data.PolicyIndex
XACML_RESOURCE_ID, XACML20_POLICY_NS
 
Constructor Summary
DbXmlPolicyIndex(PolicyReader policyReader)
           
 
Method Summary
 String addPolicy(String name, String document)
          Generates a policy based on the string data provided and the name.
 boolean clear()
          Clear the policy index completely
 void close()
           
 boolean contains(String policyName)
          Check if the policy identified by policyName exists.
 boolean deletePolicy(String name)
          Removes the policy given by name from the data store.
 long getLastUpdate()
           
 Map<String,com.sun.xacml.AbstractPolicy> getPolicies(com.sun.xacml.EvaluationCtx eval, com.sun.xacml.finder.PolicyFinder policyFinder)
          Extracts a list of policies from the Policy Index that are relevant to the given Evaluation Context.
 com.sun.xacml.AbstractPolicy getPolicy(String name, com.sun.xacml.finder.PolicyFinder policyFinder)
          Obtains the policy with the provided name from the Policy Store.
 void init()
           
 void setContainer(String container)
           
 void setDatabaseDirectory(String databaseDirectory)
           
 void setLastUpdate(long lastUpdate)
           
 boolean updatePolicy(String name, String newDocument)
          Generates a new policy based for the given policy name and replaces the old policy in the Policy Store with it.
 
Methods inherited from class org.fcrepo.server.security.xacml.pdp.data.XPathPolicyIndex
getXpath, getXpathVariables
 
Methods inherited from class org.fcrepo.server.security.xacml.pdp.data.PolicyIndexBase
getAttributeMap, handleDocument, makeComponents, setActionAttributes, setAttributeMap, setEnvironmentAttributes, setResourceAttributes, setSubjectAttributes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DbXmlPolicyIndex

public DbXmlPolicyIndex(PolicyReader policyReader)
                 throws PolicyIndexException
Throws:
PolicyIndexException
Method Detail

setDatabaseDirectory

public void setDatabaseDirectory(String databaseDirectory)

setContainer

public void setContainer(String container)

init

public void init()
          throws PolicyIndexException
Throws:
PolicyIndexException

close

public void close()

getPolicies

public Map<String,com.sun.xacml.AbstractPolicy> getPolicies(com.sun.xacml.EvaluationCtx eval,
                                                            com.sun.xacml.finder.PolicyFinder policyFinder)
                                                     throws PolicyIndexException
Description copied from interface: PolicyIndex
Extracts a list of policies from the Policy Index that are relevant to the given Evaluation Context. Note that this returns a set that still has to be further filtered by the PolicyFinder to find policies that match 100%. This merely eliminates the need to match every policy, just the most likely ones to apply.

Specified by:
getPolicies in interface PolicyIndex
Parameters:
eval - the Evaluation Context from which to match policies against
Returns:
the List of potential policies
Throws:
PolicyIndexException

addPolicy

public String addPolicy(String name,
                        String document)
                 throws PolicyIndexException
Description copied from interface: PolicyIndex
Generates a policy based on the string data provided and the name. The policy is then added to the Policy Store.

Specified by:
addPolicy in interface PolicyIndex
document - the policy as a String
Returns:
the name of the added policy
Throws:
PolicyIndexException

deletePolicy

public boolean deletePolicy(String name)
                     throws PolicyIndexException
Description copied from interface: PolicyIndex
Removes the policy given by name from the data store.

Specified by:
deletePolicy in interface PolicyIndex
Parameters:
name - the name of the policy
Returns:
true if policy was deleted
Throws:
PolicyIndexException

updatePolicy

public boolean updatePolicy(String name,
                            String newDocument)
                     throws PolicyIndexException
Description copied from interface: PolicyIndex
Generates a new policy based for the given policy name and replaces the old policy in the Policy Store with it. An exception is thrown if the policy with the given name cannot be found.

Specified by:
updatePolicy in interface PolicyIndex
Parameters:
name - the name of the policy to update
newDocument - the new policy as a String
Returns:
true if policy was updated
Throws:
PolicyIndexException

getPolicy

public com.sun.xacml.AbstractPolicy getPolicy(String name,
                                              com.sun.xacml.finder.PolicyFinder policyFinder)
                                       throws PolicyIndexException
Description copied from interface: PolicyIndex
Obtains the policy with the provided name from the Policy Store.

Specified by:
getPolicy in interface PolicyIndex
Parameters:
name - the name of the policy to return
Returns:
the policy as an array of bytes
Throws:
PolicyIndexException

contains

public boolean contains(String policyName)
                 throws PolicyIndexException
Check if the policy identified by policyName exists.

Specified by:
contains in interface PolicyIndex
Parameters:
policyName -
Returns:
true iff the policy store contains a policy identified as policyName
Throws:
PolicyStoreException
PolicyIndexException

getLastUpdate

public long getLastUpdate()

setLastUpdate

public void setLastUpdate(long lastUpdate)
Parameters:
lastUpdate - the lastUpdate to set

clear

public boolean clear()
              throws PolicyIndexException
Description copied from interface: PolicyIndex
Clear the policy index completely

Specified by:
clear in interface PolicyIndex
Returns:
Throws:
PolicyIndexException


Copyright © 2012 DuraSpace. All Rights Reserved.