Matthias Andreas Benkard | b5d657a | 2022-02-03 21:14:30 +0100 | [diff] [blame] | 1 | // SPDX-FileCopyrightText: © 2021 Matthias Andreas Benkard <code@mail.matthias.benkard.de> |
| 2 | // |
| 3 | // SPDX-License-Identifier: LGPL-3.0-or-later |
| 4 | |
Matthias Andreas Benkard | 4e8423d | 2021-12-19 22:56:09 +0100 | [diff] [blame] | 5 | package eu.mulk.jgvariant.ostree; |
| 6 | |
Matthias Andreas Benkard | 91dbd74 | 2022-10-17 19:38:56 +0200 | [diff] [blame] | 7 | import static java.nio.charset.StandardCharsets.UTF_8; |
| 8 | |
Matthias Andreas Benkard | 4e8423d | 2021-12-19 22:56:09 +0100 | [diff] [blame] | 9 | import eu.mulk.jgvariant.core.Decoder; |
| 10 | import eu.mulk.jgvariant.core.Variant; |
Matthias Andreas Benkard | 329168c | 2021-12-28 01:20:05 +0100 | [diff] [blame] | 11 | import java.util.Map; |
Matthias Andreas Benkard | 4e8423d | 2021-12-19 22:56:09 +0100 | [diff] [blame] | 12 | |
| 13 | /** |
| 14 | * A collection of cryptographic signatures for a {@link Summary}. |
| 15 | * |
| 16 | * <p>Stored as a file named {@code summary.sig} in the OSTree repository root. |
| 17 | * |
| 18 | * <p>Reference: {@code ostree-repo-static-delta-private.h#OSTREE_SUMMARY_SIG_GVARIANT_STRING} |
Matthias Andreas Benkard | 0511464 | 2021-12-29 21:51:29 +0100 | [diff] [blame] | 19 | * |
| 20 | * @param signatures a list of signatures, indexed by type. |
Matthias Andreas Benkard | 4e8423d | 2021-12-19 22:56:09 +0100 | [diff] [blame] | 21 | */ |
Matthias Andreas Benkard | 329168c | 2021-12-28 01:20:05 +0100 | [diff] [blame] | 22 | public record SummarySignature(Map<String, Variant> signatures) { |
Matthias Andreas Benkard | 4e8423d | 2021-12-19 22:56:09 +0100 | [diff] [blame] | 23 | |
| 24 | private static final Decoder<SummarySignature> DECODER = |
Matthias Andreas Benkard | aa11d82 | 2023-12-10 09:20:48 +0100 | [diff] [blame^] | 25 | Decoder.ofDictionary(Decoder.ofString(UTF_8), Decoder.ofVariant()) |
| 26 | .map(SummarySignature::new, SummarySignature::signatures); |
Matthias Andreas Benkard | 4e8423d | 2021-12-19 22:56:09 +0100 | [diff] [blame] | 27 | |
Matthias Andreas Benkard | 0511464 | 2021-12-29 21:51:29 +0100 | [diff] [blame] | 28 | /** |
| 29 | * Acquires a {@link Decoder} for the enclosing type. |
| 30 | * |
| 31 | * @return a possibly shared {@link Decoder}. |
| 32 | */ |
Matthias Andreas Benkard | 4e8423d | 2021-12-19 22:56:09 +0100 | [diff] [blame] | 33 | public static Decoder<SummarySignature> decoder() { |
| 34 | return DECODER; |
| 35 | } |
| 36 | } |