Skip to content

Commit

Permalink
Merge branch 'main' into ci/security
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-rm-meyer-ISST committed Dec 3, 2023
2 parents 8c85b57 + fa4b736 commit c063cac
Show file tree
Hide file tree
Showing 49 changed files with 3,932 additions and 1,547 deletions.
6 changes: 6 additions & 0 deletions NOTICE.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ This project leverages the following third party content.
See `DEPENDENCIES_FRONTEND` and `DEPENDENCIES_BACKEND` file. Further, the following third-party content is used that
isn't listed in any DEPENDENCIES file:

Keycloak initial realm setup
* SPDX-License-Identifier: Apache-2.0
* SPDX-FileCopyrightText: https://github.com/eclipse-tractusx/managed-identity-wallet/blob/main/LICENSE
* Source URL: https://github.com/eclipse-tractusx/managed-identity-wallet


feather (4.29)
* License: MIT License
* Licence Path: https://github.com/feathericons/feather/blob/master/LICENSE
Expand Down
46 changes: 22 additions & 24 deletions backend/INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,26 @@ The first steps are always the same:

Depending on your needs of deployment, follow the following steps

### Running using mvn (local develpment)
3. Change the `src/main/resources/application.properties` or the respective environment
### Running using mvn (local development) and infrastructure services in kubernetes
1. Change the `src/main/resources/application.properties` or the respective environment
variables to configure the port, the URL of the EDC control plane, backend application etc.
4. Run the application:
```shell
# build and run the generated .jar file
mvn install
2. Run the application:
mvn spring-boot:run -Dspring-boot.run.arguments=--spring.config.location="./src/main/resources/application.properties"

3. It is highly suggested to install, configure and run the PURIS frontend afterward

# run for demo or development puroposes
# customer role
mvn spring-boot:run -Dspring-boot.run.arguments=--spring.config.location="./src/main/resources/application-customer.properties"
### Running using docker (deployment)

# supplier role
mvn spring-boot:run -Dspring-boot.run.arguments=--spring.config.location="./src/main/resources/application-supplier.properties"
1. First build a docker image:
```
5. Done! The Swagger UI should be available at
- (Java & Docker) `http://YOURIP:8081/catena/swagger-ui/index.html`
- (Kubernetes) `http://CLUSTERIP:30001/catena/swagger-ui/index.html`
6. It is highly suggested to install and run the PURIS frontend afterward
cd backend
### Running using docker (deployment)
3. Optional (one can set properties via environment variables to docker): Change the `src/main/resources/application.properties` or the respective environment
docker build -t puris-backend:dev .
```

2. Optionally (one can set properties via environment variables to docker): Change the `src/main/resources/application.properties` or the respective environment
variables to configure the port, the URL of the EDC control plane, backend application etc.
4. Run the application:
3. Run the application:
```shell
cd backend

Expand All @@ -39,21 +35,23 @@ docker build -t puris-backend:dev .
docker run -d --rm -p 8081:8081 --name backend -e server.port=8082 puris-backend:dev CONTAINERID

# B use docker-compose
cd ..
cd local
docker-compose up
```
5. Done! The Swagger UI should be available at
4. Done! The Swagger UI should be available at
- (Java & Docker) `http://YOURIP:8081/catena/swagger-ui/index.html`
- (Kubernetes) `http://CLUSTERIP:30001/catena/swagger-ui/index.html`
6. It is highly suggested to install and run the PURIS frontend afterward
5. It is highly suggested to install and run the PURIS frontend afterward (unless you're using local/docker-compose.yaml)

### Running using helm (deployment)
3. Run the application:
1. Run the application:

```shell
cd charts/puris/charts/backend

helm install backend --namespace puris --create-namespace . --set ingress.enabled=true
```
4. Done! The Swagger UI should be available at
2. Done! The Swagger UI should be available at
- (Java & Docker) `http://YOURIP:8081/catena/swagger-ui/index.html`
- (Kubernetes) `http://CLUSTERIP:30001/catena/swagger-ui/index.html`
5. It is highly suggested to install and run the PURIS frontend afterward
3. It is highly suggested to install and run the PURIS frontend afterward
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,9 @@
*/
package org.eclipse.tractusx.puris.backend;

import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.eclipse.tractusx.puris.backend.common.edc.logic.dto.CreateAssetDto;
import org.eclipse.tractusx.puris.backend.common.edc.logic.dto.datatype.DT_ApiMethodEnum;
import org.eclipse.tractusx.puris.backend.common.edc.logic.service.EdcAdapterService;
import org.eclipse.tractusx.puris.backend.common.edc.logic.util.EDCRequestBodyBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

Expand All @@ -39,49 +34,14 @@ public class AssetCreatorCommandLineRunner implements CommandLineRunner {
@Autowired
private EdcAdapterService edcAdapterService;

@Value("${request.serverendpoint}")
private String requestApiBaseUrl;

@Value("${response.serverendpoint}")
private String responseApiBaseUrl;

private ObjectMapper objectMapper;

@Autowired
private EDCRequestBodyBuilder edcRequestBodyBuilder;

public AssetCreatorCommandLineRunner(ObjectMapper objectMapper) {
this.objectMapper = objectMapper;
}

@Override
public void run(String... args) throws Exception {

registerResponseAndRequestApiAsset();

}

private void registerResponseAndRequestApiAsset() {

// Create Request Api Asset
CreateAssetDto createRequestApiAssetDto =
edcRequestBodyBuilder.buildCreateAssetDtoForApi(DT_ApiMethodEnum.REQUEST,
requestApiBaseUrl);

CreateAssetDto createResponseApiAssetDto =
edcRequestBodyBuilder.buildCreateAssetDtoForApi(DT_ApiMethodEnum.RESPONSE,
responseApiBaseUrl);

try {
edcAdapterService.publishAssetAtEDC(createResponseApiAssetDto);
edcAdapterService.publishAssetAtEDC(createRequestApiAssetDto);
log.info("Published sample RequestAndResponseAssetData");
} catch (Exception e) {
log.error("FAILED TO REGISTER REQUEST/RESPONSE ASSETS");
log.error(e.getMessage());
if (!edcAdapterService.doInitialAssetRegistration()) {
// retry
int retryDelaySeconds = 3;
log.warn("retrying initial asset registration in " + retryDelaySeconds + " seconds");
Thread.sleep(retryDelaySeconds * 1000);
log.warn("retry successful: " + edcAdapterService.doInitialAssetRegistration());
}

}


}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import org.eclipse.tractusx.puris.backend.stock.logic.service.ProductStockRequestService;
import org.eclipse.tractusx.puris.backend.stock.logic.service.ProductStockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

Expand Down Expand Up @@ -83,10 +82,6 @@ public class DataInjectionCommandLineRunner implements CommandLineRunner {
@Autowired
private VariablesService variablesService;


@Value("${puris.demonstrator.role}")
private String demoRole;

private ObjectMapper objectMapper;

private final String semiconductorMatNbrCustomer = "MNR-7307-AU340474.002";
Expand All @@ -99,11 +94,11 @@ public DataInjectionCommandLineRunner(ObjectMapper objectMapper) {

@Override
public void run(String... args) throws Exception {
//createOwnPartnerEntity();
log.info("Creating setup for " + demoRole.toUpperCase());
if (demoRole.equals("supplier")) {
createOwnPartnerEntity();
log.info("Creating setup for " + variablesService.getDemoRole().toUpperCase());
if (variablesService.getDemoRole().equals("supplier")) {
setupSupplierRole();
} else if (demoRole.equals(("customer"))) {
} else if (variablesService.getDemoRole().equals(("customer"))) {
setupCustomerRole();
createRequest();
} else {
Expand All @@ -120,7 +115,7 @@ private void createOwnPartnerEntity() {
Partner mySelf;
if(variablesService.getOwnDefaultBpns()!= null && variablesService.getOwnDefaultBpns().length()!=0) {
mySelf = new Partner(variablesService.getOwnName(),
variablesService.getOwnEdcIdsUrl(),
variablesService.getEdcProtocolUrl(),
variablesService.getOwnBpnl(),
variablesService.getOwnDefaultBpns(),
variablesService.getOwnDefaultSiteName(),
Expand All @@ -130,7 +125,7 @@ private void createOwnPartnerEntity() {
variablesService.getOwnDefaultCountry());
} else {
mySelf = new Partner(variablesService.getOwnName(),
variablesService.getOwnEdcIdsUrl(),
variablesService.getEdcProtocolUrl(),
variablesService.getOwnBpnl(),
variablesService.getOwnDefaultBpna(),
variablesService.getOwnDefaultStreetAndNumber(),
Expand Down Expand Up @@ -281,9 +276,9 @@ private void setupSupplierRole() {
private Partner createAndGetCustomerPartner() {
Partner customerPartnerEntity = new Partner(
"Scenario Customer",
"http://customer-control-plane:8184/api/v1/ids",
"http://customer-control-plane:8184/api/v1/dsp",
"BPNL4444444444XX",
"BPNS4444444444XY",
"BPNS4444444444XX",
"Hauptwerk Musterhausen",
"BPNA4444444444ZZ",
"Musterstraße 35b",
Expand All @@ -306,9 +301,9 @@ private Partner createAndGetCustomerPartner() {
private Partner createAndGetSupplierPartner() {
Partner supplierPartnerEntity = new Partner(
"Scenario Supplier",
"http://supplier-control-plane:9184/api/v1/ids",
"http://supplier-control-plane:9184/api/v1/dsp",
"BPNL1234567890ZZ",
"BPNS1234567890XY",
"BPNS1234567890ZZ",
"Konzernzentrale Dudelsdorf",
"BPNA1234567890AA",
"Heinrich-Supplier-Straße 1",
Expand All @@ -331,7 +326,7 @@ private Partner createAndGetSupplierPartner() {
private Partner createAndGetNonScenarioCustomer() {
Partner nonScenarioCustomer = new Partner(
"Non-Scenario Customer",
"http://nonscenario-customer.com/api/v1/ids",
"http://nonscenario-customer.com/api/v1/dsp",
"BPNL2222222222RR",
"BPNA2222222222XZ",
"Fichtenweg 23",
Expand Down Expand Up @@ -383,8 +378,7 @@ private void createRequest() throws JsonProcessingException {
messageHeader.setRespondAssetId("product-stock-response-api");
messageHeader.setContractAgreementId("some cid");
messageHeader.setSender("BPNL1234567890ZZ");
//messageHeader.setSenderEdc("http://plato-controlplane:8084/api/v1/ids");
messageHeader.setSenderEdc("http://supplier-control-plane:9184/api/v1/ids");
messageHeader.setSenderEdc("http://supplier-controlplane:8084/api/v1/dsp");
messageHeader.setReceiver("BPNL4444444444XX");
messageHeader.setUseCase(DT_UseCaseEnum.PURIS);
messageHeader.setCreationDate(new Date());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,43 +29,129 @@

@Getter
@Service
/**
* This class contains the relevant
*/
public class VariablesService {

@Value("${server.port}")
/**
* The port used by this apps server application.
*/
private String serverPort;
@Value("${puris.demonstrator.role}")
/**
* Must be set to "CUSTOMER" or "SUPPLIER" if
* you want to start with some initial settings
* defined in the DataInjectionCommandLineRunner
*/
private String demoRole;
@Value("${puris.apiversion}")
/**
* The current version number
*/
private String purisApiVersion;

@Value("${puris.demonstrator.role}")
private String purisDemonstratorRole;

@Value("${request.apiassetid}")
@Value("${puris.edr.endpoint}")
/**
* The edrEndpoint to be used during consumer pull asset transfers.
*/
private String edrEndpoint;
@Value("${puris.edr.deletiontimer}")
/**
* The number of minutes before received authentication data
* in the context of a consumer pull is removed from memory
*/
private long edrTokenDeletionTimer;
@Value("${puris.request.serverendpoint}")
/**
* The url under which this application's request endpoint can
* be reached by external machines.
*/
private String requestServerEndpoint;
@Value("${puris.request.apiassetid}")
/**
* The assetId that shall be assigned to the request API
* during asset creation.
*/
private String requestApiAssetId;

@Value("${response.apiassetid}")
@Value("${puris.response.serverendpoint}")
/**
* The url under which this application's response endpoint can
* be reached by external machines.
*/
private String responseServerEndpoint;
@Value("${puris.response.apiassetid}")
/**
* The assetId that shall be assigned to the request API
* during asset creation.
*/
private String responseApiAssetId;

@Value("${edc.controlplane.key}")
/**
* The api key of your control plane
*/
private String edcApiKey;
@Value("${edc.controlplane.management.url}")
/**
* Your control plane's management url
*/
private String edcManagementUrl;
@Value("${edc.controlplane.protocol.url}")
/**
* Your control plane's protocol url
*/
private String edcProtocolUrl;

@Value("${own.bpnl}")
/**
* The BPNL that was assigned to you.
*/
private String ownBpnl;

@Value("${own.name}")
/**
* A human-readable description of yourself, e.g.
* the name of your company.
*/
private String ownName;
@Value("${edc.idsUrl}")
private String ownEdcIdsUrl;
@Value("${own.default.bpns}")
/**
* A BPNS that was assigned to you.
*/
private String ownDefaultBpns;
@Value("${own.default.streetandnumber}")
private String ownDefaultStreetAndNumber;
@Value("${own.default.site.name}")
/**
* A human-readable description of the site that you referenced in
* the ownDefaultBpns.
*/
private String ownDefaultSiteName;
@Value("${own.default.bpna}")
/** A BPNA that was assigned to you. If you initialised the
* ownDefaultBpns variable, then it must be a BPNA that is associated
* to that BPNS.
*/
private String ownDefaultBpna;
@Value("${own.default.streetandnumber}")
/**
* The street and number associated to the ownDefaultBpna
*/
private String ownDefaultStreetAndNumber;
@Value("${own.default.zipcodeandcity}")
/**
* The zip code and name of the city associated to the ownDefaultBpna
*/
private String ownDefaultZipCodeAndCity;
@Value("${own.default.country}")
/**
* The country in which your ownDefaultBpna-address is located.
*/
private String ownDefaultCountry;
/**
* The key for accessing the api.
*/
@Value("${puris.api.key}")
private String apiKey;


/**
* Returns the asset-id as defined in the properties file for the given api method
* under request.apiassetid or response.apiassetid respectively.
Expand Down
Loading

0 comments on commit c063cac

Please sign in to comment.