@Test public void testParseWithoutSp() { List<PdpPolicy> policies = Stream.of("no.advice.deny.xml", "no.nl.advice.xml", "no.any.xml", "no" + ".assignment.deny.xml", "no.sp.xml").map(this::getPolicy).collect(toList()); policies.forEach(policy -> { try { subject.parse(policy); fail(); } catch (PdpParseException | IllegalArgumentException e) { } }); }
public PdpPolicyDefinition parse(PdpPolicy pdpPolicy) { PdpPolicyDefinition definition = new PdpPolicyDefinition(); String policyXml = pdpPolicy.getPolicyXml(); Policy policy = parsePolicy(policyXml); definition.setId(pdpPolicy.getId()); definition.setName(pdpPolicy.getName()); definition.setDescription(policy.getDescription()); definition.setCreated(pdpPolicy.getCreated()); definition.setUserDisplayName(pdpPolicy.getUserDisplayName()); definition.setRevisionNbr(pdpPolicy.getRevisionNbr()); definition.setActive(pdpPolicy.isActive()); definition.setType(pdpPolicy.getType()); definition.setAuthenticatingAuthorityName(pdpPolicy.getAuthenticatingAuthority()); parseTargets(policyXml, definition, policy); List<Rule> rules = iteratorToList(policy.getRules()); if (pdpPolicy.getType().equals("step")) { definition.setDenyRule(false); List<LoA> loas = rules.stream() .filter(rule -> rule.getObligationExpressions().hasNext()) .map(this::parseStepRule).collect(toList()); definition.setLoas(loas); definition.sortLoas(); } else { definition.setDenyRule(!isPermitRule(policyXml, rules)); parsePermit(policyXml, definition, rules); parseDeny(policyXml, definition, rules); Collections.sort(definition.getAttributes(), (a1, a2) -> a1.getName().compareTo(a2.getName())); } return definition; }
PdpPolicyDefinitionParser implements IPAddressProvider { public PdpPolicyDefinition parse(PdpPolicy pdpPolicy) { PdpPolicyDefinition definition = new PdpPolicyDefinition(); String policyXml = pdpPolicy.getPolicyXml(); Policy policy = parsePolicy(policyXml); definition.setId(pdpPolicy.getId()); definition.setName(pdpPolicy.getName()); definition.setDescription(policy.getDescription()); definition.setCreated(pdpPolicy.getCreated()); definition.setUserDisplayName(pdpPolicy.getUserDisplayName()); definition.setRevisionNbr(pdpPolicy.getRevisionNbr()); definition.setActive(pdpPolicy.isActive()); definition.setType(pdpPolicy.getType()); definition.setAuthenticatingAuthorityName(pdpPolicy.getAuthenticatingAuthority()); parseTargets(policyXml, definition, policy); List<Rule> rules = iteratorToList(policy.getRules()); if (pdpPolicy.getType().equals("step")) { definition.setDenyRule(false); List<LoA> loas = rules.stream() .filter(rule -> rule.getObligationExpressions().hasNext()) .map(this::parseStepRule).collect(toList()); definition.setLoas(loas); definition.sortLoas(); } else { definition.setDenyRule(!isPermitRule(policyXml, rules)); parsePermit(policyXml, definition, rules); parseDeny(policyXml, definition, rules); Collections.sort(definition.getAttributes(), (a1, a2) -> a1.getName().compareTo(a2.getName())); } return definition; } }
PdpPolicyDefinitionParser implements IPAddressProvider { public PdpPolicyDefinition parse(PdpPolicy pdpPolicy) { PdpPolicyDefinition definition = new PdpPolicyDefinition(); String policyXml = pdpPolicy.getPolicyXml(); Policy policy = parsePolicy(policyXml); definition.setId(pdpPolicy.getId()); definition.setName(pdpPolicy.getName()); definition.setDescription(policy.getDescription()); definition.setCreated(pdpPolicy.getCreated()); definition.setUserDisplayName(pdpPolicy.getUserDisplayName()); definition.setRevisionNbr(pdpPolicy.getRevisionNbr()); definition.setActive(pdpPolicy.isActive()); definition.setType(pdpPolicy.getType()); definition.setAuthenticatingAuthorityName(pdpPolicy.getAuthenticatingAuthority()); parseTargets(policyXml, definition, policy); List<Rule> rules = iteratorToList(policy.getRules()); if (pdpPolicy.getType().equals("step")) { definition.setDenyRule(false); List<LoA> loas = rules.stream() .filter(rule -> rule.getObligationExpressions().hasNext()) .map(this::parseStepRule).collect(toList()); definition.setLoas(loas); definition.sortLoas(); } else { definition.setDenyRule(!isPermitRule(policyXml, rules)); parsePermit(policyXml, definition, rules); parseDeny(policyXml, definition, rules); Collections.sort(definition.getAttributes(), (a1, a2) -> a1.getName().compareTo(a2.getName())); } return definition; }  }
PdpPolicyDefinitionParser implements IPAddressProvider { public PdpPolicyDefinition parse(PdpPolicy pdpPolicy) { PdpPolicyDefinition definition = new PdpPolicyDefinition(); String policyXml = pdpPolicy.getPolicyXml(); Policy policy = parsePolicy(policyXml); definition.setId(pdpPolicy.getId()); definition.setName(pdpPolicy.getName()); definition.setDescription(policy.getDescription()); definition.setCreated(pdpPolicy.getCreated()); definition.setUserDisplayName(pdpPolicy.getUserDisplayName()); definition.setRevisionNbr(pdpPolicy.getRevisionNbr()); definition.setActive(pdpPolicy.isActive()); definition.setType(pdpPolicy.getType()); definition.setAuthenticatingAuthorityName(pdpPolicy.getAuthenticatingAuthority()); parseTargets(policyXml, definition, policy); List<Rule> rules = iteratorToList(policy.getRules()); if (pdpPolicy.getType().equals("step")) { definition.setDenyRule(false); List<LoA> loas = rules.stream() .filter(rule -> rule.getObligationExpressions().hasNext()) .map(this::parseStepRule).collect(toList()); definition.setLoas(loas); definition.sortLoas(); } else { definition.setDenyRule(!isPermitRule(policyXml, rules)); parsePermit(policyXml, definition, rules); parseDeny(policyXml, definition, rules); Collections.sort(definition.getAttributes(), (a1, a2) -> a1.getName().compareTo(a2.getName())); } return definition; }  PdpPolicyDefinition parse(PdpPolicy pdpPolicy); Policy parsePolicy(String policyXml); }
PdpPolicyDefinitionParser implements IPAddressProvider { public PdpPolicyDefinition parse(PdpPolicy pdpPolicy) { PdpPolicyDefinition definition = new PdpPolicyDefinition(); String policyXml = pdpPolicy.getPolicyXml(); Policy policy = parsePolicy(policyXml); definition.setId(pdpPolicy.getId()); definition.setName(pdpPolicy.getName()); definition.setDescription(policy.getDescription()); definition.setCreated(pdpPolicy.getCreated()); definition.setUserDisplayName(pdpPolicy.getUserDisplayName()); definition.setRevisionNbr(pdpPolicy.getRevisionNbr()); definition.setActive(pdpPolicy.isActive()); definition.setType(pdpPolicy.getType()); definition.setAuthenticatingAuthorityName(pdpPolicy.getAuthenticatingAuthority()); parseTargets(policyXml, definition, policy); List<Rule> rules = iteratorToList(policy.getRules()); if (pdpPolicy.getType().equals("step")) { definition.setDenyRule(false); List<LoA> loas = rules.stream() .filter(rule -> rule.getObligationExpressions().hasNext()) .map(this::parseStepRule).collect(toList()); definition.setLoas(loas); definition.sortLoas(); } else { definition.setDenyRule(!isPermitRule(policyXml, rules)); parsePermit(policyXml, definition, rules); parseDeny(policyXml, definition, rules); Collections.sort(definition.getAttributes(), (a1, a2) -> a1.getName().compareTo(a2.getName())); } return definition; }  PdpPolicyDefinition parse(PdpPolicy pdpPolicy); Policy parsePolicy(String policyXml); static final String SP_ENTITY_ID; static final String IDP_ENTITY_ID; static final String NAME_ID; }