Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change payload type to byte[] #873

Merged
merged 1 commit into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}
Loading