Fix bugs in TicketUtils class

This commit is contained in:
Maschell 2020-07-10 17:55:24 +02:00
parent 962ebf68a9
commit f3a1457518

View File

@ -10,8 +10,10 @@ import de.mas.wiiu.jnus.utils.FileUtils;
public class TicketUtils { public class TicketUtils {
public static Optional<Ticket> getTicket(File folder, File keyFolder, long titleID, byte[] commonKey) { public static Optional<Ticket> getTicket(File folder, File keyFolder, long titleID, byte[] commonKey) {
File ticketFile = FileUtils.getFileIgnoringFilenameCases(folder.getAbsolutePath(), "title.tik"); File ticketFile = null;
if (folder != null) {
ticketFile = FileUtils.getFileIgnoringFilenameCases(folder.getAbsolutePath(), "title.tik");
}
Ticket ticket = null; Ticket ticket = null;
if (ticketFile != null && ticketFile.exists()) { if (ticketFile != null && ticketFile.exists()) {
try { try {
@ -19,9 +21,10 @@ public class TicketUtils {
} catch (IOException e) { } catch (IOException e) {
} }
} }
if (ticket == null && keyFolder != null) { if (ticket == null && keyFolder != null) {
File keyFile = FileUtils.getFileIgnoringFilenameCases(keyFolder.getAbsolutePath(), String.format("%016X", titleID) + ".key"); File keyFile = FileUtils.getFileIgnoringFilenameCases(keyFolder.getAbsolutePath(), String.format("%016X", titleID) + ".key");
if (keyFile.exists()) { if (keyFile != null && keyFile.exists()) {
byte[] key; byte[] key;
try { try {
key = Files.readAllBytes(keyFile.toPath()); key = Files.readAllBytes(keyFile.toPath());