From 9ecd9825b5ac15a53c5de5bd77abb88cb2732dd6 Mon Sep 17 00:00:00 2001 From: Maschell Date: Wed, 10 Apr 2019 18:05:14 +0200 Subject: [PATCH] Throw a ParseException on error in the TMD. --- src/de/mas/wiiu/jnus/entities/TMD.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/de/mas/wiiu/jnus/entities/TMD.java b/src/de/mas/wiiu/jnus/entities/TMD.java index 0f9ad2f..9e6ef22 100644 --- a/src/de/mas/wiiu/jnus/entities/TMD.java +++ b/src/de/mas/wiiu/jnus/entities/TMD.java @@ -21,6 +21,7 @@ import java.io.IOException; import java.io.PrintStream; import java.nio.ByteBuffer; import java.nio.file.Files; +import java.text.ParseException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -102,17 +103,17 @@ public final class TMD { this.cert2 = param.getCert2(); } - public static TMD parseTMD(File tmd) throws IOException { + public static TMD parseTMD(File tmd) throws IOException, ParseException { if (tmd == null || !tmd.exists()) { log.info("TMD input file null or doesn't exist."); - return null; + throw new IOException("TMD input file null or doesn't exist."); } return parseTMD(Files.readAllBytes(tmd.toPath())); } - public static TMD parseTMD(byte[] input) { + public static TMD parseTMD(byte[] input) throws ParseException { if (input == null || input.length == 0) { - throw new RuntimeException("Invalid TMD file."); + throw new ParseException("Invalid TMD file.", 0); } byte[] signature = new byte[SIGNATURE_LENGTH]; byte[] issuer = new byte[ISSUER_LENGTH];