Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
zembrowski committed May 31, 2024
0 parents commit 9ecf564
Show file tree
Hide file tree
Showing 18 changed files with 1,509 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true

# 4 space indentation
[*.{cpp,h}]
indent_style = space
indent_size = 4

# Tab indentation (no size specified)
[Makefile]
indent_style = tab
10 changes: 10 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
DEVELOPER_ID=_____ # Please replace with your Developer-ID

#PATH_CERTIFICATE=/path/to/CEZ # Optional [default: "CEZ"]
#PATH_DOWNLOAD=/path/to/download # Optional [default: "."]
#PATH_LOG=/path/to/log # Optional [default: "."]
#PATH_VENDOR=/path/to/vendor # Optional [default: "vendor"]

# Warning:
# Docker interprets double quotes " literally, use single quotes ' instead.
# You could escape whitespaces with backslashes \ or explicitly escape a double quote with a backslash \"
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.DS_Store
.vscode
.idea
.env
cotto
otto.log*
*.txt
download
4 changes: 4 additions & 0 deletions CEZ/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*
!.gitignore
!.gitkeep
!*.sh
1 change: 1 addition & 0 deletions CEZ/.gitkeep
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Run `./get-test-cez-certificate.sh` or copy Test-CEZ manually here.
5 changes: 5 additions & 0 deletions CEZ/get-test-cez-certificate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

curl -sS -O https://download.elster.de/download/schnittstellen/Test_Zertifikate.zip && \
unzip -j Test_Zertifikate.zip eric-zertifikate-bescheidabholung/PSE/eric_private.p12 eric-zertifikate-bescheidabholung/PSE/eric_public.cer && \
rm Test_Zertifikate.zip
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Changelog

All notable changes to `cotto` will be documented in this file.

## v1.0.0 - 2024-05-31
- Initial version
- Utilizes Otto 40.1.8

**Full Changelog**: https://github.com/rechtlogisch/cotto/commits/v1.0.0
19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM --platform=linux/amd64 gcc as build
COPY . /app
WORKDIR /app
RUN make

FROM --platform=linux/amd64 ubuntu as final
WORKDIR /app
RUN mkdir -p /app/vendor
RUN mkdir -p /app/CEZ
COPY --from=build \
/app/cotto \
./
COPY --from=build \
/app/vendor/*.so \
./vendor/
COPY --from=build \
/app/CEZ/*.p12 \
/app/CEZ/*.cer \
./CEZ/
9 changes: 9 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
The MIT License (MIT)

Copyright (c) RL Recht logisch GmbH & Co. KG open-source@rechtlogisch.de

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.
49 changes: 49 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
.PHONY: all cotto clean

PATH_VENDOR ?= $(PWD)/vendor
ENV_FILE ?= .env
image := rechtlogisch/cotto

all: clean cotto

cotto:
@if [ -z "$(PATH_VENDOR)" ]; then \
echo "Error: PATH_VENDOR is not set"; \
exit 1; \
elif [ ! -d "$(PATH_VENDOR)" ]; then \
echo "Error: Directory $(PATH_VENDOR) does not exist"; \
exit 2; \
fi

@if [ -z "$$(find $(PATH_VENDOR) -name '*otto.*' -print -quit)" ]; then \
echo "Error: No file matching *otto.{dll,dylib,so} found in $(PATH_VENDOR)"; \
exit 3; \
fi

g++ -ldl -L"$(PATH_VENDOR)" -Wl,-rpath,"$(PATH_VENDOR)" -lotto -o cotto cotto.cpp

clean:
rm -f cotto otto.log*

docker-build:
docker build \
-t $(image) \
.

docker-cmd:
docker run \
-it --rm \
--env-file=$(ENV_FILE) \
--platform=linux/amd64 \
-v $(PATH_DOWNLOAD):/app/download/ \
$(image)

docker-cotto:
docker run \
-it --rm \
--env-file=$(ENV_FILE) \
--platform=linux/amd64 \
--name=cotto \
-v $(PATH_DOWNLOAD):/app/download/ \
$(image) \
./cotto $(input)
93 changes: 93 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
![Recht logisch cotto banner image](rechtlogisch-cotto-banner.png)

# cotto

> Unofficial C++ Otto download demo
A working example of the Otto library implementation in C++.

Notice: This demo is **not intended for productive usage**!

ELSTER introduced on May 27th, 2024, a new library called Otto, which can be used to download objects from OTTER (Object Storage in ELSTER). The reason why ELSTER introduced the project and library is, that the current solution hit its limits. Otto was introduced together with Datenabholung v30. The currently available way of data retrieval with ERiC will be replaced client-side with ERiC version 41 (end November 2024; only Datenabholung v30 will be available) and server-side with the planned yearly minimal version increase mid-April 2025 (exact date TBA in 2025).

## Usage

```bash
./cotto
-u objectUuid UUID of object to download (mandatory)
-e extension Set filename extension of downloaded content [default: "txt"]
-p password Password for certificate [default: "123456"]
-f Force file overwriting [default: false]
```

Examples:

```bash
cotto -u 2b884e20-779d-4094-a1de-8304a6fc00c9 # ESB 2014
cotto -u 131517ff-4516-418a-9167-f7e35fb32864 # ELOProtokoll
```

Notice: The code and scripts have been tested so far only on Linux and macOS. Windows is pending tests.

Hint: Currently, a limited list of object UUIDs is available. You can get a list of them using `PostfachAnfrage` with the Test-CEZ.

## Vendor

You need the official ELSTER Otto library. Download the ERiC package v40 for your platform from the [ELSTER developer area](https://www.elster.de/elsterweb/entwickler/infoseite/eric), unzip it and place it at a desired path. Feel free to place it in `./vendor/`. Currently, you only need one library: `(lib)otto.{so,dylib,dll}`, as Otto supports only client-side generated certificates (German abbreviation: CEZ).

Hint: Choose the right library for the platform you compile and run on.

## Compile

You can compile the code with:

```bash
make
```

Hints: provide `PATH_VENDOR` environment variable to point the path where the ELSTER `otto` library is placed on your system or place the needed libraries in `./vendor/`.

Follow the steps to run `cotto` locally:

```bash
git clone git@github.com:rechtlogisch/cotto.git
cd cotto
./CEZ/get-test-cez-certificate.sh
PATH_VENDOR="/path/to/otto-library/" make
DEVELOPER_ID="_____" ./cotto -u 2b884e20-779d-4094-a1de-8304a6fc00c9
```

Notice: You should set your five-digit Developer-ID (German: Hersteller-ID) as the environment variable `DEVELOPER_ID`. You could source it from for example `.env` or pass it inline to `cotto`, as shown in the steps above.

Hint: The downloaded result will be saved in the same directory as `cotto`, unless you provide a different `PATH_DOWNLOAD`.

## Environment variables

All supported environment variables are listed in [`.env.example`](.env.example). Feel free to copy them to `.env`, adjust accordingly and source for usage.

## Docker

A simple [Dockerfile](Dockerfile) is included. You can use `make docker-build` and `make docker-cotto` to build and run `cotto` in a container.

Hint: Set `PATH_DOWNLOAD` and `PATH_LOG` environment variables to expose data outside the container.

## Changelog

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

## Contributing

Please see [CONTRIBUTING](https://github.com/rechtlogisch/.github/blob/main/CONTRIBUTING.md) for details.

## Security Vulnerabilities

If you discover any security-related issues, please email open-source@rechtlogisch.de instead of using the issue tracker.

## Credits

- [Krzysztof Tomasz Zembrowski](https://github.com/rechtlogisch)
- [All Contributors](../../contributors)

## License

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
Loading

0 comments on commit 9ecf564

Please sign in to comment.