private boolean checkPolicy(Notify notify, AssertionType assertion) { log.debug("In NhinHiemNotifyWebServiceProxy.checkPolicy"); boolean policyIsValid = false; NotifyEventType policyCheckReq = new NotifyEventType(); policyCheckReq.setDirection(NhincConstants.POLICYENGINE_OUTBOUND_DIRECTION); gov.hhs.fha.nhinc.common.eventcommon.NotifyMessageType request = new gov.hhs.fha.nhinc.common.eventcommon.NotifyMessageType(); request.setAssertion(assertion); request.setNotify(notify); policyCheckReq.setMessage(request); PolicyEngineChecker policyChecker = new PolicyEngineChecker(); CheckPolicyRequestType policyReq = policyChecker.checkPolicyNotify(policyCheckReq); policyReq.setAssertion(assertion); PolicyEngineProxyObjectFactory policyEngFactory = new PolicyEngineProxyObjectFactory(); PolicyEngineProxy policyProxy = policyEngFactory.getPolicyEngineProxy(); CheckPolicyResponseType policyResp = policyProxy.checkPolicy(policyReq, assertion); if (policyResp.getResponse() != null && NullChecker.isNotNullish(policyResp.getResponse().getResult()) && policyResp.getResponse().getResult().get(0).getDecision() == DecisionType.PERMIT) { policyIsValid = true; } log.debug("Finished NhinHiemNotifyWebServiceProxy.checkPolicy - valid: " + policyIsValid); return policyIsValid; }
public static CheckPolicyRequestType transformSubscribeToCheckPolicy(SubscribeEventType event) { CheckPolicyRequestType genericPolicyRequest = new CheckPolicyRequestType(); RequestType request = new RequestType(); if (InboundOutboundChecker.isInbound(event.getDirection())) { request.setAction(ActionHelper.actionFactory(ActionInValue)); } if (InboundOutboundChecker.isOutbound(event.getDirection())) { request.setAction(ActionHelper.actionFactory(ActionOutValue)); } SubjectHelper subjHelp = new SubjectHelper(); SubjectType subject = subjHelp.subjectFactory(event.getSendingHomeCommunity(), event.getMessage().getAssertion()); request.getSubject().add(subject); AdhocQueryRequest adhocReq = new AdhocQueryRequest(); AdhocQueryType adhocQuery = null; adhocQuery = getAdhocQuery(event.getMessage().getSubscribe()); adhocReq.setAdhocQuery(adhocQuery); String patId = AdhocQueryTransformHelper.extractPatientIdentifierId(adhocReq); String assignAuth = AdhocQueryTransformHelper.extractPatientIdentifierAssigningAuthority(adhocReq); ResourceType resource = new ResourceType(); AttributeHelper attrHelper = new AttributeHelper(); if (NullChecker.isNotNullish(assignAuth)) { resource .getAttribute() .add( attrHelper.attributeFactory( PatientAssigningAuthorityAttributeId, Constants.DataTypeString, assignAuth)); } if (NullChecker.isNotNullish(patId)) { String sStrippedPatientId = PatientIdFormatUtil.parsePatientId(patId); LOG.debug("transformSubscribeToCheckPolicy: sStrippedPatientId = " + sStrippedPatientId); resource .getAttribute() .add( attrHelper.attributeFactory( PatientIdAttributeId, Constants.DataTypeString, sStrippedPatientId)); } setTopic(event, resource); request.getResource().add(resource); AssertionHelper assertHelp = new AssertionHelper(); assertHelp.appendAssertionDataToRequest(request, event.getMessage().getAssertion()); genericPolicyRequest.setRequest(request); genericPolicyRequest.setAssertion(event.getMessage().getAssertion()); return genericPolicyRequest; }