{
//See if a PDP exists already
Map<String,Object> contextMap = new HashMap<String,Object>();
contextMap.put("PDP", "PDP");
PolicyDecisionPoint pdp = null;
try
{
pdp = policyRegistration.getPolicy(contextID,
PolicyRegistration.XACML, contextMap);
}
catch(Exception ignore)
{
}
if(pdp == null)
{
Set<XACMLPolicy> policies = (Set<XACMLPolicy>)policyRegistration.getPolicy(contextID,
PolicyRegistration.XACML, null);
if(policies == null)
throw new IllegalStateException("Missing xacml policy for contextid:" + contextID);
JBossPolicyLocator jpl = new JBossPolicyLocator(policies);
JBossPolicySetLocator jpsl = new JBossPolicySetLocator(policies);
HashSet<PolicyLocator> plset = new HashSet<PolicyLocator>();
plset.add(jpl);
plset.add(jpsl);
pdp = new JBossPDP();
pdp.setPolicies(policies);
pdp.setLocators(plset);
}
return pdp;
}