Here is a pseudo code describing how to use it.
import org.w3c.dom.*;
import com.ibm.xml.policy.xacl.*;
public class Test{
public static void main(String[] argv)
{
//Create access request, target, policy, status
Element accessReq=.....
Document target=.....
Element policy=.....
Element status=.....
//Create hierarchy objects
Hierarchy role_hierarchy=...
Hierarchy group_hierarchy=...
//Enforce the policy
Processor xp=new Processor();
DecisionList decisionList;
try{
decisionList=xp.process(accessReq,
target,
policy,
status,
role_hierarchy,
group_hierarchy);
}catch(Exception e){
...
}
Document dl = decisionList.getDocument();
}
} |
Here is a sample code SampleXACLProcessor.java. It constructs access request, target document, policy, and status from specified files, and enforce the policy. You can compile and run it as follows:
Change the active directory to the samples directory that is just below the directory where you installed this package. For example, if you installed it in E:/xss4j, you would use the following command:
E:/xss4j>cd samplesNext, execute the following command (on one line):
E:/xss4j/samples >javac xacl/SampleXACLProcessor.javaThis compiles the source code and generates a class file SampleXACLProcessor.class. Add this class file to your classpath.
Change the active directory to the data/xacldata directory that is just below the directory where you installed this package. For example, if you installed it in E:/xss4j, you would use the following command:
E:/xss4j>cd data/xacldataNext, execute the following command (on one line):
E:/xss4j/data/xacldata >java xacl.SampleXACLProcessor ex1_request1.xml ex1_target.xml ex1_policy.xml ex1_status.xmlYou can see the decision list in your console.
How to add new functions, predicates, and provisional actions? The current version supports several functions, predicates, and provisional actions. The list of them is here. Application developers can implement application-specific functions, predicates, and provisional actions by implementing the corresponding Java interfaces, i.e., FunctionInterface, PredicateInferface, and ProvisionalActionInteraface in the com.ibm.xml.policy.xacl package, respectively.