Skip to content

Commit

Permalink
Merge branch 'eu-digital-green-certificates:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
mschulte-tsi authored Jun 28, 2021
2 parents fc149d9 + 6e87451 commit f55367e
Show file tree
Hide file tree
Showing 50 changed files with 2,618 additions and 103 deletions.
13 changes: 11 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<bcpkix.version>1.68</bcpkix.version>
<okhttp.version>4.9.1</okhttp.version>
<shedlock.version>4.23.0</shedlock.version>
<dgc.lib.version>0.5.0</dgc.lib.version>
<dgc.lib.version>1.1.1</dgc.lib.version>
<!-- plugins -->
<plugin.checkstyle.version>3.1.2</plugin.checkstyle.version>
<plugin.sonar.version>3.6.1.1688</plugin.sonar.version>
Expand Down Expand Up @@ -134,7 +134,11 @@
</dependencyManagement>

<dependencies>

<dependency>
<groupId>eu.europa.ec.dgc</groupId>
<artifactId>dgc-lib</artifactId>
<version>${dgc.lib.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
Expand Down Expand Up @@ -265,6 +269,11 @@
<groupId>com.sap.hcp.cf.logging</groupId>
<artifactId>cf-java-logging-support-logback</artifactId>
</dependency>
<dependency>
<groupId>com.nimbusds</groupId>
<artifactId>nimbus-jose-jwt</artifactId>
<version>9.9.2</version>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*-
* ---license-start
* eu-digital-green-certificates / dgca-verifier-service
* eu-digital-green-certificates / dgca-businessrule-service
* ---
* Copyright (C) 2021 T-Systems International GmbH and all other contributors
* ---
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*-
* ---license-start
* eu-digital-green-certificates / dgca-verifier-service
* eu-digital-green-certificates / dgca-businessrule-service
* ---
* Copyright (C) 2021 T-Systems International GmbH and all other contributors
* ---
Expand Down Expand Up @@ -29,12 +29,18 @@
@ConfigurationProperties("dgc")
public class DgcConfigProperties {

private final CertificatesDownloader certificatesDownloader = new CertificatesDownloader();
private final GatewayDownload businessRulesDownload = new GatewayDownload();

private final GatewayDownload valueSetsDownload = new GatewayDownload();

private final GatewayDownload countryListDownload = new GatewayDownload();

@Getter
@Setter
public static class CertificatesDownloader {
public static class GatewayDownload {
private Integer timeInterval;
private Integer lockLimit;
}


}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*-
* ---license-start
* eu-digital-green-certificates / dgca-verifier-service
* eu-digital-green-certificates / dgca-businessrule-service
* ---
* Copyright (C) 2021 T-Systems International GmbH and all other contributors
* ---
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
/*-
* ---license-start
* eu-digital-green-certificates / dgca-businessrule-service
* ---
* Copyright (C) 2021 T-Systems International GmbH and all other contributors
* ---
* 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.
* ---license-end
*/

package eu.europa.ec.dgc.businessrule.config;

import io.swagger.v3.oas.models.OpenAPI;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*-
* ---license-start
* eu-digital-green-certificates / dgca-verifier-service
* eu-digital-green-certificates / dgca-businessrule-service
* ---
* Copyright (C) 2021 T-Systems International GmbH and all other contributors
* ---
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*-
* ---license-start
* eu-digital-green-certificates / dgca-verifier-service
* eu-digital-green-certificates / dgca-businessrule-service
* ---
* Copyright (C) 2021 T-Systems International GmbH and all other contributors
* ---
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package eu.europa.ec.dgc.businessrule.config.btp;

import io.pivotal.cfenv.core.CfCredentials;
import io.pivotal.cfenv.core.CfService;
import io.pivotal.cfenv.spring.boot.CfEnvProcessor;
import io.pivotal.cfenv.spring.boot.CfEnvProcessorProperties;
import java.util.Map;

/**
* Custom implementation of {@link CfEnvProcessor} for reading the SAP credential store parameters from the <code>
* VCAP_SERVICES</code> environment variable and making them available as properties in the spring context.
* <br/><br/>
* The following properties are available in the context after the processor is done:
* <code>
* <ul>
* <li>sap.btp.credstore.url</li>
* <li>sap.btp.credstore.password</li>
* <li>sap.btp.credstore.username</li>
* <li>sap.btp.credstore.clientPrivateKey</li>
* <li>sap.btp.credstore.serverPublicKey</li>
* </ul>
* </code>
*
* @see CfEnvProcessor
*/
public class SapCredentialStoreCfEnvProcessor implements CfEnvProcessor {

private static final String CRED_STORE_SCHEME = "credstore";
private static final String CRED_STORE_PROPERTY_PREFIX = "sap.btp.credstore";

@Override
public boolean accept(CfService service) {
return service.existsByTagIgnoreCase(CRED_STORE_SCHEME, "securestore", "keystore", "credentials")
|| service.existsByLabelStartsWith(CRED_STORE_SCHEME)
|| service.existsByUriSchemeStartsWith(CRED_STORE_SCHEME);
}

@Override
public void process(CfCredentials cfCredentials, Map<String, Object> properties) {
properties.put(CRED_STORE_PROPERTY_PREFIX + ".url", cfCredentials.getString("url"));
properties.put(CRED_STORE_PROPERTY_PREFIX + ".password", cfCredentials.getString("password"));
properties.put(CRED_STORE_PROPERTY_PREFIX + ".username", cfCredentials.getString("username"));

@SuppressWarnings("unchecked")
Map<String, Object> encryption = (Map<String, Object>) cfCredentials.getMap().get("encryption");
if (encryption == null) {
// Encryption features have been disabled on this BTP instance.
properties.put(CRED_STORE_PROPERTY_PREFIX + ".clientPrivateKey", "encryption-disabled");
properties.put(CRED_STORE_PROPERTY_PREFIX + ".serverPublicKey", "encryption-disabled");
return;
}

String clientPrivateKey = encryption.get("client_private_key").toString();
String serverPublicKey = encryption.get("server_public_key").toString();

properties.put(CRED_STORE_PROPERTY_PREFIX + ".clientPrivateKey", clientPrivateKey);
properties.put(CRED_STORE_PROPERTY_PREFIX + ".serverPublicKey", serverPublicKey);
}

@Override
public CfEnvProcessorProperties getProperties() {
return CfEnvProcessorProperties.builder()
.propertyPrefixes(CRED_STORE_PROPERTY_PREFIX)
.serviceName("CredentialStore")
.build();
}

}
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
/*-
* ---license-start
* eu-digital-green-certificates / dgca-businessrule-service
* ---
* Copyright (C) 2021 T-Systems International GmbH and all other contributors
* ---
* 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.
* ---license-end
*/

package eu.europa.ec.dgc.businessrule.entity;

import javax.persistence.Column;
Expand Down Expand Up @@ -31,7 +51,7 @@ public class BusinessRuleEntity {
private String identifier;

@Column(name = "version", nullable = false)
String version = "1.0.0";
String version;

@Column(name = "country_code", nullable = false, length = 2)
String country;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
/*-
* ---license-start
* eu-digital-green-certificates / dgca-businessrule-service
* ---
* Copyright (C) 2021 T-Systems International GmbH and all other contributors
* ---
* 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.
* ---license-end
*/

package eu.europa.ec.dgc.businessrule.entity;

import javax.persistence.Column;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*-
* ---license-start
* eu-digital-green-certificates / dgca-verifier-service
* eu-digital-green-certificates / dgca-businessrule-service
* ---
* Copyright (C) 2021 T-Systems International GmbH and all other contributors
* ---
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
/*-
* ---license-start
* eu-digital-green-certificates / dgca-businessrule-service
* ---
* Copyright (C) 2021 T-Systems International GmbH and all other contributors
* ---
* 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.
* ---license-end
*/

package eu.europa.ec.dgc.businessrule.entity;

import javax.persistence.Column;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
/*-
* ---license-start
* eu-digital-green-certificates / dgca-businessrule-service
* ---
* Copyright (C) 2021 T-Systems International GmbH and all other contributors
* ---
* 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.
* ---license-end
*/

package eu.europa.ec.dgc.businessrule.exception;

import lombok.Getter;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package eu.europa.ec.dgc.businessrule.model;

import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public class BusinessRuleItem {

private String hash;

private String identifier;

private String version;

private String country;

private String rawData;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package eu.europa.ec.dgc.businessrule.model;

import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public class ValueSetItem {

private String hash;

private String id;

private String rawData;
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
/*-
* ---license-start
* eu-digital-green-certificates / dgca-businessrule-service
* ---
* Copyright (C) 2021 T-Systems International GmbH and all other contributors
* ---
* 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.
* ---license-end
*/

package eu.europa.ec.dgc.businessrule.repository;

import eu.europa.ec.dgc.businessrule.entity.BusinessRuleEntity;
Expand All @@ -14,4 +34,6 @@ public interface BusinessRuleRepository extends JpaRepository<BusinessRuleEntity
List<BusinessRuleListItemDto> findAllByCountryOrderByIdentifierAsc(String country);

BusinessRuleEntity findOneByCountryAndHash(String country, String hash);

void deleteByHashNotIn(List<String> hashes);
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
/*-
* ---license-start
* eu-digital-green-certificates / dgca-businessrule-service
* ---
* Copyright (C) 2021 T-Systems International GmbH and all other contributors
* ---
* 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.
* ---license-end
*/

package eu.europa.ec.dgc.businessrule.repository;

import eu.europa.ec.dgc.businessrule.entity.CountryListEntity;
Expand Down
Loading

0 comments on commit f55367e

Please sign in to comment.