@Test public void testFilterByNPI_Policy2() throws Exception { sut.filterByNPI(policyList, "22222", "11111"); assertTrue(!policyList.contains(policy1)); assertTrue(policyList.contains(policy2)); }
public void filterByNPI(List<String> policies, String recipientSubjectNPI, String intermediarySubjectNPI) throws Exception { LinkedList<String> removeList = new LinkedList<String>(); for (String policy : policies) { Document policyDoc = documentXmlConverter.loadDocument(policy); String xPathExprIntermediary = XPATH_CONDITION_ATTRIBUTE_VALUE .replace("$", URN_XACML_1_INTERMEDIARY_SUBJECT); NodeList nodeListIntermediaryNPI = this.documentAccessor .getNodeList(policyDoc, xPathExprIntermediary); boolean containsIntermediaryNPI = containsInValue( nodeListIntermediaryNPI, intermediarySubjectNPI); if (containsIntermediaryNPI == false) { removeList.add(policy); } else { String xPathExprRecipient = XPATH_CONDITION_ATTRIBUTE_VALUE .replace("$", URN_XACML_1_RECIPIENT_SUBJECT); NodeList nodeListRecipientNPI = this.documentAccessor .getNodeList(policyDoc, xPathExprRecipient); boolean containsRecipientNPI = containsInValue( nodeListRecipientNPI, recipientSubjectNPI); if (containsRecipientNPI == false) { removeList.add(policy); } } } policies.removeAll(removeList); }
XacmlPolicyListFilter { public void filterByNPI(List<String> policies, String recipientSubjectNPI, String intermediarySubjectNPI) throws Exception { LinkedList<String> removeList = new LinkedList<String>(); for (String policy : policies) { Document policyDoc = documentXmlConverter.loadDocument(policy); String xPathExprIntermediary = XPATH_CONDITION_ATTRIBUTE_VALUE .replace("$", URN_XACML_1_INTERMEDIARY_SUBJECT); NodeList nodeListIntermediaryNPI = this.documentAccessor .getNodeList(policyDoc, xPathExprIntermediary); boolean containsIntermediaryNPI = containsInValue( nodeListIntermediaryNPI, intermediarySubjectNPI); if (containsIntermediaryNPI == false) { removeList.add(policy); } else { String xPathExprRecipient = XPATH_CONDITION_ATTRIBUTE_VALUE .replace("$", URN_XACML_1_RECIPIENT_SUBJECT); NodeList nodeListRecipientNPI = this.documentAccessor .getNodeList(policyDoc, xPathExprRecipient); boolean containsRecipientNPI = containsInValue( nodeListRecipientNPI, recipientSubjectNPI); if (containsRecipientNPI == false) { removeList.add(policy); } } } policies.removeAll(removeList); } }
XacmlPolicyListFilter { public void filterByNPI(List<String> policies, String recipientSubjectNPI, String intermediarySubjectNPI) throws Exception { LinkedList<String> removeList = new LinkedList<String>(); for (String policy : policies) { Document policyDoc = documentXmlConverter.loadDocument(policy); String xPathExprIntermediary = XPATH_CONDITION_ATTRIBUTE_VALUE .replace("$", URN_XACML_1_INTERMEDIARY_SUBJECT); NodeList nodeListIntermediaryNPI = this.documentAccessor .getNodeList(policyDoc, xPathExprIntermediary); boolean containsIntermediaryNPI = containsInValue( nodeListIntermediaryNPI, intermediarySubjectNPI); if (containsIntermediaryNPI == false) { removeList.add(policy); } else { String xPathExprRecipient = XPATH_CONDITION_ATTRIBUTE_VALUE .replace("$", URN_XACML_1_RECIPIENT_SUBJECT); NodeList nodeListRecipientNPI = this.documentAccessor .getNodeList(policyDoc, xPathExprRecipient); boolean containsRecipientNPI = containsInValue( nodeListRecipientNPI, recipientSubjectNPI); if (containsRecipientNPI == false) { removeList.add(policy); } } } policies.removeAll(removeList); } XacmlPolicyListFilter(DocumentXmlConverter documentXmlConverter,
			DocumentAccessor documentAccessor); }
XacmlPolicyListFilter { public void filterByNPI(List<String> policies, String recipientSubjectNPI, String intermediarySubjectNPI) throws Exception { LinkedList<String> removeList = new LinkedList<String>(); for (String policy : policies) { Document policyDoc = documentXmlConverter.loadDocument(policy); String xPathExprIntermediary = XPATH_CONDITION_ATTRIBUTE_VALUE .replace("$", URN_XACML_1_INTERMEDIARY_SUBJECT); NodeList nodeListIntermediaryNPI = this.documentAccessor .getNodeList(policyDoc, xPathExprIntermediary); boolean containsIntermediaryNPI = containsInValue( nodeListIntermediaryNPI, intermediarySubjectNPI); if (containsIntermediaryNPI == false) { removeList.add(policy); } else { String xPathExprRecipient = XPATH_CONDITION_ATTRIBUTE_VALUE .replace("$", URN_XACML_1_RECIPIENT_SUBJECT); NodeList nodeListRecipientNPI = this.documentAccessor .getNodeList(policyDoc, xPathExprRecipient); boolean containsRecipientNPI = containsInValue( nodeListRecipientNPI, recipientSubjectNPI); if (containsRecipientNPI == false) { removeList.add(policy); } } } policies.removeAll(removeList); } XacmlPolicyListFilter(DocumentXmlConverter documentXmlConverter,
			DocumentAccessor documentAccessor); void filterByNPI(List<String> policies, String recipientSubjectNPI,
			String intermediarySubjectNPI); boolean containsInValue(NodeList nodeList, String value); }
XacmlPolicyListFilter { public void filterByNPI(List<String> policies, String recipientSubjectNPI, String intermediarySubjectNPI) throws Exception { LinkedList<String> removeList = new LinkedList<String>(); for (String policy : policies) { Document policyDoc = documentXmlConverter.loadDocument(policy); String xPathExprIntermediary = XPATH_CONDITION_ATTRIBUTE_VALUE .replace("$", URN_XACML_1_INTERMEDIARY_SUBJECT); NodeList nodeListIntermediaryNPI = this.documentAccessor .getNodeList(policyDoc, xPathExprIntermediary); boolean containsIntermediaryNPI = containsInValue( nodeListIntermediaryNPI, intermediarySubjectNPI); if (containsIntermediaryNPI == false) { removeList.add(policy); } else { String xPathExprRecipient = XPATH_CONDITION_ATTRIBUTE_VALUE .replace("$", URN_XACML_1_RECIPIENT_SUBJECT); NodeList nodeListRecipientNPI = this.documentAccessor .getNodeList(policyDoc, xPathExprRecipient); boolean containsRecipientNPI = containsInValue( nodeListRecipientNPI, recipientSubjectNPI); if (containsRecipientNPI == false) { removeList.add(policy); } } } policies.removeAll(removeList); } XacmlPolicyListFilter(DocumentXmlConverter documentXmlConverter,
			DocumentAccessor documentAccessor); void filterByNPI(List<String> policies, String recipientSubjectNPI,
			String intermediarySubjectNPI); boolean containsInValue(NodeList nodeList, String value); static final String URN_XACML_1_INTERMEDIARY_SUBJECT; static final String URN_XACML_1_RECIPIENT_SUBJECT; static final String XPATH_CONDITION_ATTRIBUTE_VALUE; }