From f8146ce56b1fa7d0e88c96f58f932d12b4a9b215 Mon Sep 17 00:00:00 2001 From: Maschell Date: Thu, 18 Apr 2019 23:25:20 +0200 Subject: [PATCH] Make SHA2 attribute of ContentInfo Optional --- .../mas/wiiu/jnus/entities/content/ContentInfo.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/de/mas/wiiu/jnus/entities/content/ContentInfo.java b/src/de/mas/wiiu/jnus/entities/content/ContentInfo.java index 188984a..87c8752 100644 --- a/src/de/mas/wiiu/jnus/entities/content/ContentInfo.java +++ b/src/de/mas/wiiu/jnus/entities/content/ContentInfo.java @@ -19,6 +19,7 @@ package de.mas.wiiu.jnus.entities.content; import java.nio.ByteBuffer; import java.text.ParseException; import java.util.Arrays; +import java.util.Optional; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -37,7 +38,7 @@ public class ContentInfo { @Getter private final short indexOffset; @Getter private final short commandCount; - @Getter private final byte[] SHA2Hash; + @Getter private final Optional SHA2Hash; public ContentInfo() { this((short) 0); @@ -54,7 +55,11 @@ public class ContentInfo { public ContentInfo(short indexOffset, short commandCount, byte[] SHA2Hash) { this.indexOffset = indexOffset; this.commandCount = commandCount; - this.SHA2Hash = SHA2Hash; + if (SHA2Hash == null) { + this.SHA2Hash = Optional.empty(); + } else { + this.SHA2Hash = Optional.of(SHA2Hash); + } } /** @@ -63,7 +68,7 @@ public class ContentInfo { * @param input * 0x24 byte of data from the TMD (starting at 0x208) * @return ContentFSTInfo object - * @throws ParseException + * @throws ParseException */ public static ContentInfo parseContentInfo(byte[] input) throws ParseException { if (input == null || input.length != CONTENT_INFO_SIZE) { @@ -86,6 +91,6 @@ public class ContentInfo { @Override public String toString() { - return "ContentInfo [indexOffset=" + indexOffset + ", commandCount=" + commandCount + ", SHA2Hash=" + Arrays.toString(SHA2Hash) + "]"; + return "ContentInfo [indexOffset=" + indexOffset + ", commandCount=" + commandCount + ", SHA2Hash=" + SHA2Hash + "]"; } }