-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Parse DSSE bundles and Intoto payloads
Signed-off-by: Appu Goundan <[email protected]>
- Loading branch information
1 parent
ba87e0c
commit eb12af7
Showing
7 changed files
with
171 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
sigstore-java/src/main/java/dev/sigstore/dsse/InTotoPayload.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Copyright 2024 The Sigstore Authors. | ||
* | ||
* 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. | ||
*/ | ||
package dev.sigstore.dsse; | ||
|
||
import static dev.sigstore.json.GsonSupplier.GSON; | ||
|
||
import com.google.gson.JsonElement; | ||
import dev.sigstore.bundle.Bundle.DsseEnvelope; | ||
import java.util.List; | ||
import java.util.Map; | ||
import org.immutables.gson.Gson; | ||
import org.immutables.value.Value.Immutable; | ||
|
||
@Gson.TypeAdapters | ||
@Immutable | ||
public interface InTotoPayload { | ||
|
||
String PAYLOAD_TYPE = "application/vnd.in-toto+json"; | ||
|
||
@Gson.Named("_type") | ||
String getType(); | ||
|
||
List<Subject> getSubject(); | ||
|
||
String getPredicateType(); | ||
|
||
/** | ||
* Predicate is not processed by this library, if you want to inspect the contents of an | ||
* attestation, you want to use an attestation parser. | ||
*/ | ||
JsonElement getPredicate(); | ||
|
||
@Immutable | ||
interface Subject { | ||
|
||
String getName(); | ||
|
||
Map<String, String> getDigest(); | ||
} | ||
|
||
static InTotoPayload from(DsseEnvelope dsseEnvelope) { | ||
return GSON.get().fromJson(dsseEnvelope.getPayload(), InTotoPayload.class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 59 additions & 1 deletion
60
sigstore-java/src/test/resources/dev/sigstore/samples/bundles/bundle.dsse.sigstore
Large diffs are not rendered by default.
Oops, something went wrong.