Skip to content

Commit

Permalink
✨ MDAS-500 Download statical P+R data from mobilithek-info to S3 buck…
Browse files Browse the repository at this point in the history
…et. (#18)

* ✨ MDAS-500 Download statical P+R data from mobilithek-info to S3 bucket.

* ♻️ Refactoring pull request #18

* ♻️ Refactoring pull request #18

* ♻️ Refactoring pull request #18

* ♻️ Refactoring pull request #18

* ♻️ Refactoring II pull request #18

* ♻️ Refactoring II pull request #18
  • Loading branch information
sfi2022 committed Jun 13, 2024
1 parent 7e9aeae commit 48bcded
Show file tree
Hide file tree
Showing 37 changed files with 1,767 additions and 231 deletions.
105 changes: 0 additions & 105 deletions .gitlab-ci.yml

This file was deleted.

23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
#
# The MIT License
# Copyright © 2024 Landeshauptstadt München | it@M
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#

# Dockerfiles may only contain a FROM and the application data.
# For Java applications use /ubi9/openjdk-11-runtime or /ubi9/openjdk-17-runtime as Base Image, for documentation
# please see https://access.redhat.com/documentation/en-us/red_hat_jboss_middleware_for_openshift/3/html/red_hat_java_s2i_for_openshift/
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Dieses Projekt verwendet die folgenden Technologien:

- Spring Boot
- Apache Camel
- S3 Client

<p align="right">(<a href="#top">nach oben</a>)</p>

Expand Down
4 changes: 4 additions & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release-Notes

## Sprint 11 + 12 (08.05.2024 - 18.06.2024)
### Hinzugefügt
- Anbindung Mobilithek, S3 und SST-Management erstellt.

## Sprint 10 (16.04.2024 - 07.05.2024)
### Hinzugefügt
- Workflows erstellt
Expand Down
24 changes: 24 additions & 0 deletions checkstyle.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,28 @@
<?xml version="1.0"?>
<!--
The MIT License
Copyright © 2024 Landeshauptstadt München | it@M
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->
<!DOCTYPE module PUBLIC
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">
Expand Down
187 changes: 187 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
# Dokumentation

- Die Enterprise Application Integration Komponente (EAI) kopiert Dateien aus einem angegebenen Konto der [Mobilithek.Info](https://mobilithek.info/) in einen S3 Bucket.

- Die Zugriffsaktivtäten werden im [Mobidam-Sst-Management](https://github.com/it-at-m/mobidam-sst-management) per logging dokumentiert. Dafür stellt das [Mobidam-Sst-Management](https://github.com/it-at-m/mobidam-sst-management) eine [Integrationskomponente](https://github.com/it-at-m/mobidam-sst-management/tree/sprint/mobidam-sst-management-integration) zur Verfügung.

- Pro Mobilithek Schnittstelle wird ein Cronjob mit einem Downloadintervall konfiguriert.

Github-Repo: https://github.com/it-at-m/mobidam-mobilithek-eai

## Technisches Setup
- Für jede herunter zu ladende Datei aus einem Mobilithek Konto müssen deren Zugangskontodaten angegeben werden.
- Für den Zugriff auf mobidam-sst-management müssen die Schnittstellen und die Authentifizierung bekannt sein.
- Für die Ablage im S3 müssen alle erforderlichen Zugangsdaten zum S3 Bucket verfügbar sein.

### [Mobidam-Sst-Management](https://github.com/it-at-m/mobidam-sst-management)
Alle Mobilithek Schnittstellen werden in der Mobidam-SST-Management Komponente verwaltet und müssen dort angelegt bzw. registriert sein.
Über das Mobidam-SST-Management können Mobilithek Schnittstellen aktiviert und deaktiviert werden. Alle relevanten Logging Informationen zu den Schnittstellen werden im Mobidam-SST-Management zentral gesammelt.

Die _baseUrl_ ist die allgemeine Mobidam-SST-Management URL.

_interfaces_ ist eine Schnittstellen Liste, d.h. es können mehrere Mobilithek Info Schnittellen konfiguriert werden.

Der Bezeichner _interfaces-1_ ist frei wählbar und dient der Identifizierung der Mobilithek Schnittstelle. Siehe unten die Beispielkonfiguration.

Um aus der mobidam-mobilithek-eai eine Schnittstelle im Mobidam-SST-Management ansprechen zu können muss deren individuelle _mobidam-sst-id_ bekannt sein.

```
de.muenchen.mobidam.integration:
baseUrl: ...
interfaces:
interface-1:
mobidam-sst-id: ...
...
interface-2:
mobidam-sst-id: ...
...
```

Für den erfolgreichen Mobidam-SST-Management Zugriff muss eine valide OAuth2 Authenthifizierung eingerichtet sein.
Die Angaben sind für eine erfolgreiche Initialisierung der [Integrationskomponente](https://github.com/it-at-m/mobidam-sst-management/tree/sprint/mobidam-sst-management-integration) erforderlich.

```
spring:
...
security:
oauth2:
client:
registration:
custom:
provider: ...
client-id: ...
client-secret: ...
authorization-grant-type: ...
provider:
custom:
token-uri: ..
```

### [Mobilithek.Info](https://mobilithek.info/)

Jede Mobilithek Schnittstelle hat eine individuelle _mobilithek-subscription-id_ und _mobilithek-url_.

```
de.muenchen.mobidam.integration:
...
interfaces:
interface-1:
...
mobilithek-subscription-id: ...
mobilithek-url: ...
...
```

Für den Zugriff auf die Mobilithek stellt diese ein individuelles Zertifikat _certificate.p12_ inkl. Password zur Verfügung.
Das Zertifikat muss in einer Datei Namens _mobilithek.jks_ im Classpath der mobilithek-info-eai liegen.
Die _mobilithek.jks_ kann mit folgendem Befehl erzeugt werden. Dabei muss das Mobilithek Password für
'certificate.p12' und das Password für den zu erzeugenden Keystore 'mobilithek.jks' von Hand eingegeben werden:
```
keytool -importkeystore -srckeystore [certificate.p12] -srcstoretype PKCS12 -keystore mobilithek.jks
```

Das von Hand eingegebene Keystore Password muss als _jks_password_ in einem Secret in der Openshift Konfiguration angegeben werden.

Kubernetes/Openshift Secret:
```
mobidam:
mobilithek:
jks-password: changeit
```


### S3 Bucket

Pro Mobilithek Schnittstelle muss die Ablage im S3 Bucket _s3-bucket_ definiert werden.

Die Download Datei aus der Mobilithek wird unter einen individuellen Namen inkl. Zeitstempel im angebenen S3 Bucket angelegt.
Dazu dienen _s3-object-path_ und _s3-date-format_. Z.Bsp. wird mit den Angaben

- s3-object-path: _MDAS/Mobilithek/PR-statisch/%s-pr-daten.xml_
- s3-date-format: _yyyyMMdd_HHmmss_

folgender S3 Bucket Path/Dateiname generiert, wobei das _s3-date-format_ an der Possition %s eingefügt wird:

- _MDAS/Mobilithek/PR-statisch/20240513_165114-pr-daten.xml_

Der _s3-bucket_ Name aus der Mobidam Schnittstelle muss zu den Angaben in der _bucket-credential-config_ Liste passen, sonst können der S3 _access-key-env-var_ und _secret-key-env-var_ nicht korrekt ermittelt werden. Sie auch die Beschreibung [mobidam-s3-eai](https://github.com/it-at-m/mobidam-s3-eai/blob/sprint/docs/README.md#konfiguration).



```
de.muenchen.mobidam.integration:
...
interfaces:
interface-1:
...
s3-object-path: ...
s3-date-format: ...
s3-bucket: s3-bucket-1
mobidam:
s3:
bucket-credential-config:
s3-bucket-1:
access-key-env-var: ...
secret-key-env-var: ...
```




### Cronjob
Last but not least muss der Cronjob pro Schnittstelle auch noch ausgelöst werden:

```
de.muenchen.mobidam.integration:
...
interfaces:
interface-1:
...
cron-expression: ...
...
```



### Beispielkonfiguration:

```
de.muenchen.mobidam.integration:
baseUrl: https://mobidam-sst-management...
interfaces:
parkRideData:
mobidam-sst-id: 999fcf2d-25bb-4fa9-85ff-f7ed12349999
mobilithek-subscription-id: 123456789
mobilithek-url: https://mobilithek.info:8443/mobilithek/api/v1.0/subscription/123456789/clientPullService?subscriptionID=123456789
cron-expression: '0 * * ? * *'
s3-object-path: MDAS/Mobilithek/PR-statisch/%s-pr-daten.xml
s3-date-format: yyyyMMdd_HHmmss
s3-bucket: my-bucket-name
spring:
security:
oauth2:
client:
registration:
custom:
provider: custom
client-id: my-client-id
client-secret: my-client-secret
authorization-grant-type: client_credentials
provider:
custom:
token-uri: https://.../realms/[my-realm]]/protocol/openid-connect/token
mobidam:
s3:
bucket-credential-config:
my-bucket-name:
access-key-env-var: MY_ACCESS_KEY
secret-key-env-var: MY_SECRET_KEY
```
Loading

0 comments on commit 48bcded

Please sign in to comment.