-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #378 from NUM-Forschungsdatenplattform/develop
Release 1.12.0
- Loading branch information
Showing
58 changed files
with
1,851 additions
and
956 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
src/main/java/de/vitagroup/num/config/FttpClientConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package de.vitagroup.num.config; | ||
|
||
import ca.uhn.fhir.context.FhirContext; | ||
import de.vitagroup.num.properties.FttpProperties; | ||
import java.security.KeyStore; | ||
import javax.net.ssl.HostnameVerifier; | ||
import javax.net.ssl.SSLContext; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.apache.http.auth.AuthScope; | ||
import org.apache.http.auth.UsernamePasswordCredentials; | ||
import org.apache.http.conn.ssl.NoopHostnameVerifier; | ||
import org.apache.http.conn.ssl.SSLConnectionSocketFactory; | ||
import org.apache.http.impl.client.BasicCredentialsProvider; | ||
import org.apache.http.impl.client.CloseableHttpClient; | ||
import org.apache.http.impl.client.HttpClients; | ||
import org.apache.http.ssl.SSLContextBuilder; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Slf4j | ||
@Configuration | ||
@RequiredArgsConstructor | ||
public class FttpClientConfig { | ||
|
||
private static final String CERTIFICATE_TYPE = "PKCS12"; | ||
|
||
private final FttpProperties fttpProperties; | ||
|
||
@Bean | ||
public FhirContext fhirContext() { | ||
return FhirContext.forR4(); | ||
} | ||
|
||
@Bean | ||
public CloseableHttpClient httpClient() { | ||
try { | ||
var keyStore = KeyStore.getInstance(CERTIFICATE_TYPE); | ||
|
||
keyStore.load(getClass().getResourceAsStream(fttpProperties.getCertificatePath()), | ||
fttpProperties.getCertificateKey().toCharArray()); | ||
|
||
SSLContext sslContext = | ||
SSLContextBuilder.create().loadKeyMaterial(keyStore, fttpProperties.getCertificateKey().toCharArray()).build(); | ||
|
||
HostnameVerifier hostnameVerifier = NoopHostnameVerifier.INSTANCE; | ||
SSLConnectionSocketFactory sslFactory = | ||
new SSLConnectionSocketFactory(sslContext, hostnameVerifier); | ||
|
||
CloseableHttpClient client; | ||
|
||
if (fttpProperties.isUseBasicAuth()) { | ||
var provider = new BasicCredentialsProvider(); | ||
provider.setCredentials(AuthScope.ANY, | ||
new UsernamePasswordCredentials(fttpProperties.getUsername(), fttpProperties.getPassword()) | ||
); | ||
|
||
client = HttpClients.custom().setSSLSocketFactory(sslFactory).setDefaultCredentialsProvider(provider).build(); | ||
} else { | ||
client = HttpClients.custom().setSSLSocketFactory(sslFactory).build(); | ||
} | ||
|
||
return client; | ||
} catch (Exception e) { | ||
log.error("Failed to create http client for fttp communication with cause [{}]", e.getLocalizedMessage()); | ||
} | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package de.vitagroup.num.domain; | ||
|
||
public enum EntityGroup { | ||
|
||
PROJECT_STATUS; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package de.vitagroup.num.domain; | ||
|
||
import de.vitagroup.num.domain.dto.Language; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
import org.hibernate.annotations.Cache; | ||
import org.hibernate.annotations.CacheConcurrencyStrategy; | ||
|
||
import javax.persistence.*; | ||
|
||
@Entity | ||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Cacheable | ||
@Cache(usage = CacheConcurrencyStrategy.READ_ONLY) | ||
public class Translation { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@Column(name = "entity_group", nullable = false) | ||
@Enumerated(EnumType.STRING) | ||
private EntityGroup entityGroup; | ||
|
||
@Column(name = "entity_id") | ||
private Long entityId; | ||
|
||
@Column(nullable = false) | ||
private String property; | ||
|
||
@Column(nullable = false) | ||
private String value; | ||
|
||
@Column(name = "language_code", nullable = false) | ||
@Enumerated(EnumType.STRING) | ||
private Language language; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.