Example usage for net.minecraftforge.fml.common CertificateHelper getFingerprint

List of usage examples for net.minecraftforge.fml.common CertificateHelper getFingerprint

Introduction

In this page you can find the example usage for net.minecraftforge.fml.common CertificateHelper getFingerprint.

Prototype

public static String getFingerprint(ByteBuffer buffer) 

Source Link

Usage

From source file:net.cazzar.corelib.CoreMod.java

License:Open Source License

@Override
public Void call() throws Exception {
    CodeSource source = getClass().getProtectionDomain().getCodeSource();

    if (source.getLocation().getProtocol().equals("jar")) {
        Certificate[] certificates = source.getCertificates();
        if (certificates == null)
            throw new RuntimeException(
                    "CazzarCoreLib is not signed and has been compromised, please get it from http://www.cazzar.net/");

        for (Certificate certificate : certificates) {
            String fingerprint = CertificateHelper.getFingerprint(certificate);
            if (fingerprint.equals(FINGERPRINT)) {
                LogHelper.coreLog.info("Found a valid CazzarCoreLib fingerprint");
            } else
                throw new RuntimeException(
                        "CazzarCoreLib has been compromised, please get a new version from http://www.cazzar.net/");
        }//www.  j a va2 s .  c  om
    }

    McpMappings.instance();
    return null;
}