Skip to content

Commit

Permalink
Merge pull request #873 from sigstore/change_payload_type
Browse files Browse the repository at this point in the history
Change payload type to byte[]
  • Loading branch information
loosebazooka authored Dec 20, 2024
2 parents 0efb434 + a6fa3a2 commit c4c06c8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
12 changes: 9 additions & 3 deletions sigstore-java/src/main/java/dev/sigstore/bundle/Bundle.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public interface MessageDigest {
public interface DsseEnvelope {

/** An arbitrary payload that does not need to be parsed to be validated */
String getPayload();
byte[] getPayload();

/** Information on how to interpret the payload */
String getPayloadType();
Expand All @@ -158,12 +158,18 @@ default byte[] getPAE() {
+ " "
+ getPayloadType()
+ " "
+ getPayload().length()
+ getPayloadAsString().length()
+ " "
+ getPayload())
+ getPayloadAsString())
.getBytes(StandardCharsets.UTF_8);
}

@Lazy
@Gson.Ignore
default String getPayloadAsString() {
return new String(getPayload(), StandardCharsets.UTF_8);
}

@Lazy
@Gson.Ignore
default byte[] getSignature() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ static Bundle readBundle(Reader jsonReader) throws BundleParseException {
var dsseEnvelopeProto = protoBundle.getDsseEnvelope();
var dsseEnvelopeBuilder =
ImmutableDsseEnvelope.builder()
.payload(dsseEnvelopeProto.getPayload().toStringUtf8())
.payload(dsseEnvelopeProto.getPayload().toByteArray())
.payloadType(dsseEnvelopeProto.getPayloadType());
for (int sigIndex = 0; sigIndex < dsseEnvelopeProto.getSignaturesCount(); sigIndex++) {
dsseEnvelopeBuilder.addSignatures(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ interface Subject {
}

static InTotoPayload from(DsseEnvelope dsseEnvelope) {
return GSON.get().fromJson(dsseEnvelope.getPayload(), InTotoPayload.class);
return GSON.get().fromJson(dsseEnvelope.getPayloadAsString(), InTotoPayload.class);
}
}

0 comments on commit c4c06c8

Please sign in to comment.