Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/oehf/ipf
Browse files Browse the repository at this point in the history
  • Loading branch information
ohr committed Jun 14, 2018
2 parents 6fbeb0a + 708f6d8 commit 177c049
Show file tree
Hide file tree
Showing 197 changed files with 21,118 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,18 @@
package org.openehealth.ipf.commons.ihe.core.atna.event;

import org.openehealth.ipf.commons.audit.AuditContext;
import org.openehealth.ipf.commons.audit.codes.ParticipantObjectTypeCode;
import org.openehealth.ipf.commons.audit.codes.ParticipantObjectTypeCodeRole;
import org.openehealth.ipf.commons.audit.event.BaseAuditMessageBuilder;
import org.openehealth.ipf.commons.audit.event.DelegatingAuditMessageBuilder;
import org.openehealth.ipf.commons.audit.model.TypeValuePairType;
import org.openehealth.ipf.commons.audit.types.ParticipantObjectIdType;
import org.openehealth.ipf.commons.ihe.core.atna.AuditDataset;

import java.util.ArrayList;
import java.util.List;

import static java.util.Objects.requireNonNull;
import static org.openehealth.ipf.commons.audit.utils.AuditUtils.getHostFromUrl;
import static org.openehealth.ipf.commons.audit.utils.AuditUtils.getProcessId;

Expand Down Expand Up @@ -123,4 +127,40 @@ public static List<TypeValuePairType> makeDocumentDetail(String repositoryId, St
}
return tvp;
}

/**
* Adds a Participant Object representing a Security Resource involved in the event
*
* @param participantObjectIdType transaction-specific participant object type code
* @param securityResourceId security resource ID
* @return this
*/
public T addSecurityResourceParticipantObject(ParticipantObjectIdType participantObjectIdType, String securityResourceId) {
delegate.addParticipantObjectIdentification(
participantObjectIdType,
null,
null,
null,
requireNonNull(securityResourceId),
ParticipantObjectTypeCode.System,
ParticipantObjectTypeCodeRole.SecurityResource,
null,
null);
return self();
}

/**
* Adds a list Participant Objects representing Security Resources involved in the event
*
* @param participantObjectIdType transaction-specific participant object type code
* @param securityResourceIds list security resource IDs
* @return this
*/
public T addSecurityResourceParticipantObjects(ParticipantObjectIdType participantObjectIdType, List<String> securityResourceIds) {
for (String securityResourceId : securityResourceIds) {
addSecurityResourceParticipantObject(participantObjectIdType, securityResourceId);
}
return self();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,26 @@ public T setQueryParameters(
return self();
}

public T setQueryParameters(
String queryMessageIdentifier,
ParticipantObjectIdType participantObjectIdType,
String queryMessage,
ParticipantObjectTypeCode participantObjectTypeCode,
ParticipantObjectTypeCodeRole participantObjectTypeCodeRole,
List<TypeValuePairType> details) {
delegate.addParticipantObjectIdentification(
participantObjectIdType,
null,
Base64.getEncoder().encode(queryMessage.getBytes(StandardCharsets.UTF_8)),
details,
queryMessageIdentifier,
participantObjectTypeCode,
participantObjectTypeCodeRole,
null,
null);
return self();
}

@Override
public void validate() {
super.validate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,14 @@
*/
package org.openehealth.ipf.commons.ihe.hpd;

import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.ClassUtils;
import org.apache.commons.lang3.StringUtils;
import org.openehealth.ipf.commons.core.modules.api.ValidationException;
import org.openehealth.ipf.commons.ihe.hpd.stub.chpidd.DownloadRequest;
import org.openehealth.ipf.commons.ihe.hpd.stub.chpidd.DownloadResponse;
import org.openehealth.ipf.commons.ihe.hpd.stub.dsmlv2.BatchRequest;
import org.openehealth.ipf.commons.ihe.hpd.stub.dsmlv2.BatchResponse;
import org.openehealth.ipf.commons.ihe.hpd.stub.dsmlv2.DsmlMessage;
import org.openehealth.ipf.commons.ihe.hpd.stub.dsmlv2.*;
import org.openehealth.ipf.commons.ihe.hpd.stub.dsmlv2.ErrorResponse.ErrorType;
import org.openehealth.ipf.commons.ihe.hpd.stub.dsmlv2.SearchRequest;
import org.openehealth.ipf.commons.xml.XsdValidator;

import javax.naming.InvalidNameException;
Expand All @@ -33,6 +32,7 @@
import javax.xml.bind.JAXBException;
import javax.xml.bind.util.JAXBSource;
import javax.xml.transform.Source;
import java.util.function.Consumer;

/**
* @author Dmytro Rud
Expand All @@ -45,13 +45,13 @@ public class HpdValidator {
org.openehealth.ipf.commons.ihe.hpd.stub.dsmlv2.ObjectFactory.class,
org.openehealth.ipf.commons.ihe.hpd.stub.chpidd.ObjectFactory.class);
} catch (JAXBException e) {
throw new RuntimeException(e);
throw new ExceptionInInitializerError(e);
}
}

private static final XsdValidator XSD_VALIDATOR = new XsdValidator();

private void check(boolean condition, String message) {
private static void check(boolean condition, String message) {
if (! condition) {
throw new HpdException(message, ErrorType.MALFORMED_REQUEST);
}
Expand All @@ -68,17 +68,21 @@ private static void validateWithXsd(Object object, String schemaName) {
}
}

public void validateBatchRequest(BatchRequest request) {
validateWithXsd(request, "/schema/DSMLv2.xsd");
check(request.getBatchRequests() != null, "Request list is null");
check(!request.getBatchRequests().isEmpty(), "Request list is empty");
for(DsmlMessage dsml : request.getBatchRequests()) {
check(dsml instanceof SearchRequest, "Only SearchRequests are supported");
validateSearchRequest((SearchRequest) dsml);
private static void validateBatchRequest(
BatchRequest batch,
Class<? extends DsmlMessage>[] allowedElementTypes,
Consumer<DsmlMessage> requestValidator)
{
check(batch.getBatchRequests() != null, "Batch is null");
check(!batch.getBatchRequests().isEmpty(), "Batch is empty");
for(DsmlMessage dsml : batch.getBatchRequests()) {
check(dsml != null, "Batch element is null");
check(ArrayUtils.contains(allowedElementTypes, dsml.getClass()), "Bad batch element type " + ClassUtils.getSimpleName(dsml));
requestValidator.accept(dsml);
}
}

private void validateSearchRequest(SearchRequest request) {
private static void validateSearchRequest(SearchRequest request) {
try {
LdapName ldapName = new LdapName(request.getDn());
boolean oCheck = false;
Expand All @@ -101,15 +105,40 @@ private void validateSearchRequest(SearchRequest request) {
}
}

public void validateBatchResponse(BatchResponse response) {
validateWithXsd(response, "/schema/DSMLv2.xsd");
public static void validateIti58Request(BatchRequest batchRequest) {
validateWithXsd(batchRequest, "/schema/DSMLv2.xsd");
validateBatchRequest(batchRequest,
new Class[] {SearchRequest.class},
element -> validateSearchRequest((SearchRequest) element));
}

public void validateDownloadRequest(DownloadRequest request) {
validateWithXsd(request, "/schema/PIDD.xsd");
public static void validateIti58Response(BatchResponse batchResponse) {
validateWithXsd(batchResponse, "/schema/DSMLv2.xsd");
}

public void validateDownloadResponse(DownloadResponse response) {
validateWithXsd(response, "/schema/PIDD.xsd");
public static void validateIti59Request(BatchRequest batchRequest) {
validateWithXsd(batchRequest, "/schema/DSMLv2.xsd");
validateBatchRequest(batchRequest,
new Class[] {AddRequest.class, ModifyRequest.class, ModifyDNRequest.class, DelRequest.class},
element -> { /* TODO */ });
}

public static void validateIti59Response(BatchResponse batchResponse) {
validateWithXsd(batchResponse, "/schema/DSMLv2.xsd");
}

public static void validateChPiddRequest(DownloadRequest downloadRequest) {
validateWithXsd(downloadRequest, "/schema/PIDD.xsd");
}

public static void validateChpiddResponse(DownloadResponse downloadResponse) {
validateWithXsd(downloadResponse, "/schema/PIDD.xsd");
if (downloadResponse.getBatchRequest() != null) {
for (BatchRequest batchRequest : downloadResponse.getBatchRequest()) {
validateBatchRequest(batchRequest,
new Class[] {AddRequest.class, ModifyRequest.class, ModifyDNRequest.class, DelRequest.class},
element -> { /* TODO */ });
}
}
}
}
1 change: 1 addition & 0 deletions commons/ihe/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<module>fhir</module>
<module>xua</module>
<module>hpd</module>
<module>xacml20</module>
</modules>

<distributionManagement>
Expand Down
79 changes: 79 additions & 0 deletions commons/ihe/xacml20/impl/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<!--
Copyright 2018 the original author or authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=" http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>
<artifactId>ipf-commons-ihe-xacml20-impl</artifactId>
<name>ipf-commons-ihe-xacml20-impl</name>
<description>Support for XACML 2.0-based integration profiles: implementation</description>
<url>${site.url}/${project.artifactId}</url>

<parent>
<groupId>org.openehealth.ipf.commons</groupId>
<artifactId>ipf-commons-ihe-xacml20</artifactId>
<version>3.6-SNAPSHOT</version>
</parent>

<dependencies>
<!-- Dependencies for main -->
<dependency>
<groupId>org.openehealth.ipf.commons</groupId>
<artifactId>ipf-commons-ihe-xacml20-model</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openehealth.ipf.commons</groupId>
<artifactId>ipf-commons-ihe-ws</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openehealth.ipf.commons</groupId>
<artifactId>ipf-commons-xml</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.herasaf.xacml.core</groupId>
<artifactId>herasaf-xacml-core</artifactId>
</dependency>

<!-- Dependencies for test -->
<dependency>
<groupId>org.openehealth.ipf.commons</groupId>
<artifactId>ipf-commons-ihe-ws</artifactId>
<version>${project.version}</version>
<scope>test</scope>
<type>test-jar</type>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
Loading

0 comments on commit 177c049

Please sign in to comment.