Skip to content

Commit

Permalink
small refactorings
Browse files Browse the repository at this point in the history
  • Loading branch information
unixoid committed Nov 6, 2023
1 parent 1fa827d commit 9b0bd10
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class XacmlToFhirTranslator {
}

GPathResult subjectMatches = xacml.Target.Subjects.Subject.SubjectMatch
for (subjectMatch in (subjectMatches)) {
for (subjectMatch in subjectMatches) {
def cv = subjectMatch.AttributeValue.CodedValue

if ((cv.@codeSystem.text() == PpqConstants.CodingSystemIds.SWISS_PURPOSE_OF_USE) && (cv.@code.text() == 'EMER')) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,10 @@
package org.openehealth.ipf.commons.ihe.xacml20

import org.apache.commons.lang3.Validate
import org.herasaf.xacml.core.context.impl.ActionType
import org.herasaf.xacml.core.context.impl.AttributeType
import org.herasaf.xacml.core.context.impl.AttributeValueType
import org.herasaf.xacml.core.context.impl.EnvironmentType
import org.herasaf.xacml.core.context.impl.RequestType
import org.herasaf.xacml.core.context.impl.ResourceType
import org.herasaf.xacml.core.context.impl.SubjectType
import org.herasaf.xacml.core.context.impl.*
import org.herasaf.xacml.core.context.impl.ObjectFactory as XacmlContextObjectFactory
import org.herasaf.xacml.core.policy.impl.IdReferenceType
import org.herasaf.xacml.core.policy.impl.ObjectFactory as XacmlPolicyObjectFactory
import org.herasaf.xacml.core.policy.impl.PolicySetType
import org.openehealth.ipf.commons.ihe.xacml20.herasaf.types.IiDataTypeAttribute
import org.openehealth.ipf.commons.ihe.xacml20.model.PpqConstants
Expand All @@ -33,6 +29,7 @@ import org.openehealth.ipf.commons.ihe.xacml20.stub.ehealthswiss.DeletePolicyReq
import org.openehealth.ipf.commons.ihe.xacml20.stub.ehealthswiss.UpdatePolicyRequest
import org.openehealth.ipf.commons.ihe.xacml20.stub.ehealthswiss.XACMLPolicySetIdReferenceStatementType
import org.openehealth.ipf.commons.ihe.xacml20.stub.hl7v3.II
import org.openehealth.ipf.commons.ihe.xacml20.stub.hl7v3.ObjectFactory as Hl7v3ObjectFactory
import org.openehealth.ipf.commons.ihe.xacml20.stub.saml20.assertion.AssertionType
import org.openehealth.ipf.commons.ihe.xacml20.stub.saml20.assertion.NameIDType
import org.openehealth.ipf.commons.ihe.xacml20.stub.saml20.protocol.ResponseType
Expand All @@ -45,26 +42,30 @@ import javax.xml.datatype.DatatypeFactory

class ChPpqMessageCreator {

private static final HL7V3_OBJECT_FACTORY = new org.openehealth.ipf.commons.ihe.xacml20.stub.hl7v3.ObjectFactory()
private static final XACML_CONTEXT_OBJECT_FACTORY = new org.herasaf.xacml.core.context.impl.ObjectFactory()
private static final XACML_POLICY_OBJECT_FACTORY = new org.herasaf.xacml.core.policy.impl.ObjectFactory()
private static final XML_OBJECT_FACTORY = DatatypeFactory.newInstance()
private static final Hl7v3ObjectFactory HL7V3_OBJECT_FACTORY = new Hl7v3ObjectFactory()
private static final XacmlContextObjectFactory XACML_CONTEXT_OBJECT_FACTORY = new XacmlContextObjectFactory()
private static final XacmlPolicyObjectFactory XACML_POLICY_OBJECT_FACTORY = new XacmlPolicyObjectFactory()
private static final DatatypeFactory XML_OBJECT_FACTORY = DatatypeFactory.newInstance()

private final String homeCommunityId

ChPpqMessageCreator(String homeCommunityId) {
this.homeCommunityId = Validate.notEmpty(homeCommunityId as String, 'Home community ID shall be provided')
}

private AssertionType createAssertion() {
NameIDType createIssuer() {
return new NameIDType(
nameQualifier: PpqConstants.NAME_QUALIFIER_EHEALTH_SUISSSE_COMMUNITY_INDEX,
value: homeCommunityId,
)
}

AssertionType createAssertion() {
return new AssertionType(
ID: '_' + UUID.randomUUID(),
issueInstant: XML_OBJECT_FACTORY.newXMLGregorianCalendar(new GregorianCalendar()),
version: '2.0',
issuer: new NameIDType(
nameQualifier: PpqConstants.NAME_QUALIFIER_EHEALTH_SUISSSE_COMMUNITY_INDEX,
value: homeCommunityId,
),
issuer: createIssuer(),
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ public void configure() throws Exception {
var writer = new StringWriter();
marshaller.marshal(exchange.getMessage().getBody(), writer);
log.debug("PPQ output message:\n{}", writer.toString());
exchange.setProperty(HomeCommunityUtils.HOME_COMMUNITY_ID_NAME, "urn:oid:1.2.3");
})
.process(chPpq2ResponseValidator());

// sends a correct response with status "failure"
from("ch-ppq2:ch-ppq-failure?homeCommunityId=urn:oid:1.2.4")
from("ch-ppq2:ch-ppq-failure?homeCommunityId=urn:oid:1.2.777")
.process(chPpq2RequestValidator())
.setProperty(HomeCommunityUtils.HOME_COMMUNITY_ID_NAME, constant("urn:oid:1.2.4"))
.throwException(new RuntimeException("Alles schlimm..."));

}
Expand Down

0 comments on commit 9b0bd10

Please sign in to comment.