Cleanup mod signature data table. Easily seperating those mods with signatures vs those with none.

This commit is contained in:
Lex Manos 2015-06-09 22:25:13 -07:00
parent d4f6e9e419
commit b94c2799ab
3 changed files with 52 additions and 1 deletions

View file

@ -19,6 +19,7 @@ import java.io.FileWriter;
import java.io.IOException;
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.LinkedHashMap;
@ -510,10 +511,30 @@ public class Loader
}
modController.transition(LoaderState.CONSTRUCTING, false);
modController.distributeStateMessage(LoaderState.CONSTRUCTING, modClassLoader, discoverer.getASMTable(), reverseDependencies);
List<ModContainer> mods = Lists.newArrayList();
mods.addAll(getActiveModList());
Collections.sort(mods, new Comparator<ModContainer>()
{
@Override
public int compare(ModContainer o1, ModContainer o2)
{
return o1.getModId().compareTo(o2.getModId());
}
});
FMLLog.fine("Mod signature data");
FMLLog.fine(" \tValid Signatures:");
for (ModContainer mod : getActiveModList())
{
FMLLog.fine("\t%s(%s:%s): %s (%s)", mod.getModId(), mod.getName(), mod.getVersion(), mod.getSource().getName(), CertificateHelper.getFingerprint(mod.getSigningCertificate()));
if (mod.getSigningCertificate() != null)
FMLLog.fine("\t\t(%s) %s\t(%s\t%s)\t%s", CertificateHelper.getFingerprint(mod.getSigningCertificate()), mod.getModId(), mod.getName(), mod.getVersion(), mod.getSource().getName());
}
FMLLog.fine(" \tMissing Signatures:");
for (ModContainer mod : getActiveModList())
{
if (mod.getSigningCertificate() == null)
FMLLog.fine("\t\t%s\t(%s\t%s)\t%s", mod.getModId(), mod.getName(), mod.getVersion(), mod.getSource().getName());
}
if (getActiveModList().isEmpty())
{

View file

@ -12,8 +12,12 @@
package cpw.mods.fml.common;
import java.security.cert.Certificate;
import cpw.mods.fml.common.versioning.VersionParser;
import cpw.mods.fml.common.versioning.VersionRange;
import cpw.mods.fml.relauncher.FMLLaunchHandler;
import cpw.mods.fml.relauncher.Side;
public class MinecraftDummyContainer extends DummyModContainer
{
@ -33,4 +37,20 @@ public class MinecraftDummyContainer extends DummyModContainer
{
return staticRange;
}
@Override
public Certificate getSigningCertificate()
{
if (FMLLaunchHandler.side() != Side.CLIENT)
return null;
try
{
Class<?> cbr = Class.forName("net.minecraft.client.ClientBrandRetriever", false, getClass().getClassLoader());
Certificate[] certificates = cbr.getProtectionDomain().getCodeSource().getCertificates();
return certificates != null ? certificates[0] : null;
}
catch (Exception e){} // Errors don't matter just return null.
return null;
}
}

View file

@ -12,6 +12,7 @@ import static net.minecraftforge.common.ForgeVersion.revisionVersion;
import static net.minecraftforge.common.config.Configuration.CATEGORY_GENERAL;
import java.io.File;
import java.security.cert.Certificate;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@ -381,4 +382,13 @@ public class ForgeModContainer extends DummyModContainer implements WorldAccessC
"net.minecraftforge.transformers"
);
}
@Override
public Certificate getSigningCertificate()
{
Certificate[] certificates = getClass().getProtectionDomain().getCodeSource().getCertificates();
return certificates != null ? certificates[0] : null;
}
}