@Test(expected = IllegalArgumentException.class) public void testEvaluatePolicyForTrying_Given_Null_XacmlPolicy_Throws_Exception() { final String xacmlPolicy = null; pdp.evaluatePolicyForTrying(xacmlPolicy, null); }
@Override public synchronized PdpRequestResponse evaluatePolicyForTrying( String xacmlPolicy, String purposeOfUse) { Assert.hasText(xacmlPolicy, "Xacml policy is not set"); Node resourceNode = null; NodeList senderNodeList = null; NodeList recipientNodeList = null; try { final Document xmlDoc = documentXmlConverter .loadDocument(xacmlPolicy); resourceNode = documentAccessor .getNode( xmlDoc, " senderNodeList = documentAccessor .getNodeList( xmlDoc, " recipientNodeList = documentAccessor .getNodeList( xmlDoc, " final NodeList currentDateNodeList = documentAccessor .getNodeList( xmlDoc, " for (int i = 0; i < currentDateNodeList.getLength(); i++) { final Node node = currentDateNodeList.item(i); node.getParentNode().removeChild(node); } xacmlPolicy = documentXmlConverter.convertXmlDocToString(xmlDoc); } catch (final Exception e) { logger.error( "Exception occured when trying to query and manipulate xaml policy string", e); } final XacmlRequest xacmlRequest = new XacmlRequest(); final String resourceId = resourceNode.getTextContent(); xacmlRequest.setPatientId(resourceId); final String intermediarySubjectNPI = senderNodeList.item(0) .getTextContent(); xacmlRequest.setIntermediarySubjectNPI(intermediarySubjectNPI); final String recipientSubjectNPI = recipientNodeList.item(0) .getTextContent(); xacmlRequest.setRecipientSubjectNPI(recipientSubjectNPI); xacmlRequest.setPurposeOfUse(purposeOfUse); final RequestType request = requestGenerator.generateRequest( xacmlRequest.getRecipientSubjectNPI(), xacmlRequest.getIntermediarySubjectNPI(), xacmlRequest.getPurposeOfUse(), xacmlRequest.getPatientId()); final InputSource source = new InputSource( new StringReader(xacmlPolicy)); Evaluatable policy = null; try { policy = PolicyMarshaller.unmarshal(source); } catch (final Exception e) { logger.error( "Exception occured when trying to unmarshal xaml policy to be used by PDP engine", e); } final List<Evaluatable> policies = new ArrayList<Evaluatable>(); policies.add(policy); final XacmlResponse xacmlResponse = managePoliciesAndEvaluateRequest( policies, xacmlRequest, request); final PdpRequestResponse pdpRequestResponse = new PdpRequestResponse(); pdpRequestResponse.setXacmlRequest(xacmlRequest); pdpRequestResponse.setXacmlResponse(xacmlResponse); return pdpRequestResponse; }
PolicyDecisionPointImpl implements PolicyDecisionPoint { @Override public synchronized PdpRequestResponse evaluatePolicyForTrying( String xacmlPolicy, String purposeOfUse) { Assert.hasText(xacmlPolicy, "Xacml policy is not set"); Node resourceNode = null; NodeList senderNodeList = null; NodeList recipientNodeList = null; try { final Document xmlDoc = documentXmlConverter .loadDocument(xacmlPolicy); resourceNode = documentAccessor .getNode( xmlDoc, " senderNodeList = documentAccessor .getNodeList( xmlDoc, " recipientNodeList = documentAccessor .getNodeList( xmlDoc, " final NodeList currentDateNodeList = documentAccessor .getNodeList( xmlDoc, " for (int i = 0; i < currentDateNodeList.getLength(); i++) { final Node node = currentDateNodeList.item(i); node.getParentNode().removeChild(node); } xacmlPolicy = documentXmlConverter.convertXmlDocToString(xmlDoc); } catch (final Exception e) { logger.error( "Exception occured when trying to query and manipulate xaml policy string", e); } final XacmlRequest xacmlRequest = new XacmlRequest(); final String resourceId = resourceNode.getTextContent(); xacmlRequest.setPatientId(resourceId); final String intermediarySubjectNPI = senderNodeList.item(0) .getTextContent(); xacmlRequest.setIntermediarySubjectNPI(intermediarySubjectNPI); final String recipientSubjectNPI = recipientNodeList.item(0) .getTextContent(); xacmlRequest.setRecipientSubjectNPI(recipientSubjectNPI); xacmlRequest.setPurposeOfUse(purposeOfUse); final RequestType request = requestGenerator.generateRequest( xacmlRequest.getRecipientSubjectNPI(), xacmlRequest.getIntermediarySubjectNPI(), xacmlRequest.getPurposeOfUse(), xacmlRequest.getPatientId()); final InputSource source = new InputSource( new StringReader(xacmlPolicy)); Evaluatable policy = null; try { policy = PolicyMarshaller.unmarshal(source); } catch (final Exception e) { logger.error( "Exception occured when trying to unmarshal xaml policy to be used by PDP engine", e); } final List<Evaluatable> policies = new ArrayList<Evaluatable>(); policies.add(policy); final XacmlResponse xacmlResponse = managePoliciesAndEvaluateRequest( policies, xacmlRequest, request); final PdpRequestResponse pdpRequestResponse = new PdpRequestResponse(); pdpRequestResponse.setXacmlRequest(xacmlRequest); pdpRequestResponse.setXacmlResponse(xacmlResponse); return pdpRequestResponse; } }
PolicyDecisionPointImpl implements PolicyDecisionPoint { @Override public synchronized PdpRequestResponse evaluatePolicyForTrying( String xacmlPolicy, String purposeOfUse) { Assert.hasText(xacmlPolicy, "Xacml policy is not set"); Node resourceNode = null; NodeList senderNodeList = null; NodeList recipientNodeList = null; try { final Document xmlDoc = documentXmlConverter .loadDocument(xacmlPolicy); resourceNode = documentAccessor .getNode( xmlDoc, " senderNodeList = documentAccessor .getNodeList( xmlDoc, " recipientNodeList = documentAccessor .getNodeList( xmlDoc, " final NodeList currentDateNodeList = documentAccessor .getNodeList( xmlDoc, " for (int i = 0; i < currentDateNodeList.getLength(); i++) { final Node node = currentDateNodeList.item(i); node.getParentNode().removeChild(node); } xacmlPolicy = documentXmlConverter.convertXmlDocToString(xmlDoc); } catch (final Exception e) { logger.error( "Exception occured when trying to query and manipulate xaml policy string", e); } final XacmlRequest xacmlRequest = new XacmlRequest(); final String resourceId = resourceNode.getTextContent(); xacmlRequest.setPatientId(resourceId); final String intermediarySubjectNPI = senderNodeList.item(0) .getTextContent(); xacmlRequest.setIntermediarySubjectNPI(intermediarySubjectNPI); final String recipientSubjectNPI = recipientNodeList.item(0) .getTextContent(); xacmlRequest.setRecipientSubjectNPI(recipientSubjectNPI); xacmlRequest.setPurposeOfUse(purposeOfUse); final RequestType request = requestGenerator.generateRequest( xacmlRequest.getRecipientSubjectNPI(), xacmlRequest.getIntermediarySubjectNPI(), xacmlRequest.getPurposeOfUse(), xacmlRequest.getPatientId()); final InputSource source = new InputSource( new StringReader(xacmlPolicy)); Evaluatable policy = null; try { policy = PolicyMarshaller.unmarshal(source); } catch (final Exception e) { logger.error( "Exception occured when trying to unmarshal xaml policy to be used by PDP engine", e); } final List<Evaluatable> policies = new ArrayList<Evaluatable>(); policies.add(policy); final XacmlResponse xacmlResponse = managePoliciesAndEvaluateRequest( policies, xacmlRequest, request); final PdpRequestResponse pdpRequestResponse = new PdpRequestResponse(); pdpRequestResponse.setXacmlRequest(xacmlRequest); pdpRequestResponse.setXacmlResponse(xacmlResponse); return pdpRequestResponse; } PolicyDecisionPointImpl(PolicyProvider policyProvider,
			RequestGenerator requestGenerator,
			DocumentAccessor documentAccessor,
			DocumentXmlConverter documentXmlConverter, AuditService auditService);  PolicyDecisionPointImpl(RequestGenerator requestGenerator,
			DocumentAccessor documentAccessor,
			DocumentXmlConverter documentXmlConverter); }
PolicyDecisionPointImpl implements PolicyDecisionPoint { @Override public synchronized PdpRequestResponse evaluatePolicyForTrying( String xacmlPolicy, String purposeOfUse) { Assert.hasText(xacmlPolicy, "Xacml policy is not set"); Node resourceNode = null; NodeList senderNodeList = null; NodeList recipientNodeList = null; try { final Document xmlDoc = documentXmlConverter .loadDocument(xacmlPolicy); resourceNode = documentAccessor .getNode( xmlDoc, " senderNodeList = documentAccessor .getNodeList( xmlDoc, " recipientNodeList = documentAccessor .getNodeList( xmlDoc, " final NodeList currentDateNodeList = documentAccessor .getNodeList( xmlDoc, " for (int i = 0; i < currentDateNodeList.getLength(); i++) { final Node node = currentDateNodeList.item(i); node.getParentNode().removeChild(node); } xacmlPolicy = documentXmlConverter.convertXmlDocToString(xmlDoc); } catch (final Exception e) { logger.error( "Exception occured when trying to query and manipulate xaml policy string", e); } final XacmlRequest xacmlRequest = new XacmlRequest(); final String resourceId = resourceNode.getTextContent(); xacmlRequest.setPatientId(resourceId); final String intermediarySubjectNPI = senderNodeList.item(0) .getTextContent(); xacmlRequest.setIntermediarySubjectNPI(intermediarySubjectNPI); final String recipientSubjectNPI = recipientNodeList.item(0) .getTextContent(); xacmlRequest.setRecipientSubjectNPI(recipientSubjectNPI); xacmlRequest.setPurposeOfUse(purposeOfUse); final RequestType request = requestGenerator.generateRequest( xacmlRequest.getRecipientSubjectNPI(), xacmlRequest.getIntermediarySubjectNPI(), xacmlRequest.getPurposeOfUse(), xacmlRequest.getPatientId()); final InputSource source = new InputSource( new StringReader(xacmlPolicy)); Evaluatable policy = null; try { policy = PolicyMarshaller.unmarshal(source); } catch (final Exception e) { logger.error( "Exception occured when trying to unmarshal xaml policy to be used by PDP engine", e); } final List<Evaluatable> policies = new ArrayList<Evaluatable>(); policies.add(policy); final XacmlResponse xacmlResponse = managePoliciesAndEvaluateRequest( policies, xacmlRequest, request); final PdpRequestResponse pdpRequestResponse = new PdpRequestResponse(); pdpRequestResponse.setXacmlRequest(xacmlRequest); pdpRequestResponse.setXacmlResponse(xacmlResponse); return pdpRequestResponse; } PolicyDecisionPointImpl(PolicyProvider policyProvider,
			RequestGenerator requestGenerator,
			DocumentAccessor documentAccessor,
			DocumentXmlConverter documentXmlConverter, AuditService auditService);  PolicyDecisionPointImpl(RequestGenerator requestGenerator,
			DocumentAccessor documentAccessor,
			DocumentXmlConverter documentXmlConverter); @Override synchronized PdpRequestResponse evaluatePolicyForTrying(
			String xacmlPolicy, String purposeOfUse); @Override @Deprecated XacmlResponse evaluateRequest(PDP pdp, RequestType request,
			List<Evaluatable> policies, XacmlRequest xacmlRequest); @Override @Deprecated XacmlResponse evaluateRequest(PDP pdp, RequestType request,
			XacmlRequest xacmlRequest); @Override @Deprecated XacmlResponse evaluateRequest(RequestType request,
			List<Evaluatable> policies, XacmlRequest xacmlRequest); @Override XacmlResponse evaluateRequest(RequestType request,
			XacmlRequest xacmlRequest); @Override XacmlResponse evaluateRequest(XacmlRequest xacmlRequest); }
PolicyDecisionPointImpl implements PolicyDecisionPoint { @Override public synchronized PdpRequestResponse evaluatePolicyForTrying( String xacmlPolicy, String purposeOfUse) { Assert.hasText(xacmlPolicy, "Xacml policy is not set"); Node resourceNode = null; NodeList senderNodeList = null; NodeList recipientNodeList = null; try { final Document xmlDoc = documentXmlConverter .loadDocument(xacmlPolicy); resourceNode = documentAccessor .getNode( xmlDoc, " senderNodeList = documentAccessor .getNodeList( xmlDoc, " recipientNodeList = documentAccessor .getNodeList( xmlDoc, " final NodeList currentDateNodeList = documentAccessor .getNodeList( xmlDoc, " for (int i = 0; i < currentDateNodeList.getLength(); i++) { final Node node = currentDateNodeList.item(i); node.getParentNode().removeChild(node); } xacmlPolicy = documentXmlConverter.convertXmlDocToString(xmlDoc); } catch (final Exception e) { logger.error( "Exception occured when trying to query and manipulate xaml policy string", e); } final XacmlRequest xacmlRequest = new XacmlRequest(); final String resourceId = resourceNode.getTextContent(); xacmlRequest.setPatientId(resourceId); final String intermediarySubjectNPI = senderNodeList.item(0) .getTextContent(); xacmlRequest.setIntermediarySubjectNPI(intermediarySubjectNPI); final String recipientSubjectNPI = recipientNodeList.item(0) .getTextContent(); xacmlRequest.setRecipientSubjectNPI(recipientSubjectNPI); xacmlRequest.setPurposeOfUse(purposeOfUse); final RequestType request = requestGenerator.generateRequest( xacmlRequest.getRecipientSubjectNPI(), xacmlRequest.getIntermediarySubjectNPI(), xacmlRequest.getPurposeOfUse(), xacmlRequest.getPatientId()); final InputSource source = new InputSource( new StringReader(xacmlPolicy)); Evaluatable policy = null; try { policy = PolicyMarshaller.unmarshal(source); } catch (final Exception e) { logger.error( "Exception occured when trying to unmarshal xaml policy to be used by PDP engine", e); } final List<Evaluatable> policies = new ArrayList<Evaluatable>(); policies.add(policy); final XacmlResponse xacmlResponse = managePoliciesAndEvaluateRequest( policies, xacmlRequest, request); final PdpRequestResponse pdpRequestResponse = new PdpRequestResponse(); pdpRequestResponse.setXacmlRequest(xacmlRequest); pdpRequestResponse.setXacmlResponse(xacmlResponse); return pdpRequestResponse; } PolicyDecisionPointImpl(PolicyProvider policyProvider,
			RequestGenerator requestGenerator,
			DocumentAccessor documentAccessor,
			DocumentXmlConverter documentXmlConverter, AuditService auditService);  PolicyDecisionPointImpl(RequestGenerator requestGenerator,
			DocumentAccessor documentAccessor,
			DocumentXmlConverter documentXmlConverter); @Override synchronized PdpRequestResponse evaluatePolicyForTrying(
			String xacmlPolicy, String purposeOfUse); @Override @Deprecated XacmlResponse evaluateRequest(PDP pdp, RequestType request,
			List<Evaluatable> policies, XacmlRequest xacmlRequest); @Override @Deprecated XacmlResponse evaluateRequest(PDP pdp, RequestType request,
			XacmlRequest xacmlRequest); @Override @Deprecated XacmlResponse evaluateRequest(RequestType request,
			List<Evaluatable> policies, XacmlRequest xacmlRequest); @Override XacmlResponse evaluateRequest(RequestType request,
			XacmlRequest xacmlRequest); @Override XacmlResponse evaluateRequest(XacmlRequest xacmlRequest);  }