Skip to content

Commit

Permalink
if this fixes the "java.lang.SecurityException: class XXX signer info…
Browse files Browse the repository at this point in the history
…rmation does not match signer information of other classes in the same package" I'll flip shit.
  • Loading branch information
dries007 committed Oct 28, 2014
1 parent 7097f44 commit ef5eed0
Show file tree
Hide file tree
Showing 13 changed files with 892 additions and 9 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Expand Up @@ -37,7 +37,7 @@ archivesBaseName = 'D3Core'
def githuborg = 'DoubleDoorDevelopment'
def description = 'DoubleDoor Development Core'
minecraft {
version = "1.7.10-10.13.0.1190"
version = "1.7.10-10.13.1.1226"
runDir = "jars"
}

Expand Down
53 changes: 46 additions & 7 deletions src/main/java/net/doubledoordev/d3core/D3Core.java
Expand Up @@ -38,24 +38,30 @@
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerStartingEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.PlayerEvent;
import cpw.mods.fml.common.registry.LanguageRegistry;
import cpw.mods.fml.common.versioning.ArtifactVersion;
import cpw.mods.fml.common.versioning.DefaultArtifactVersion;
import net.doubledoordev.d3core.permissions.PermissionsDB;
import net.doubledoordev.d3core.permissions.cmd.CommandGroup;
import net.doubledoordev.d3core.util.CoreHelper;
import net.doubledoordev.d3core.util.DevPerks;
import net.doubledoordev.d3core.util.ID3Mod;
import net.doubledoordev.libs.org.mcstats.Metrics;
import net.doubledoordev.d3core.util.libs.org.mcstats.Metrics;
import net.minecraft.util.IChatComponent;
import net.minecraftforge.common.config.ConfigElement;
import net.minecraftforge.common.config.Configuration;
import org.apache.commons.io.FileUtils;
import org.apache.logging.log4j.Logger;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
Expand All @@ -71,19 +77,20 @@ public class D3Core implements ID3Mod
{
@Mod.Instance(MODID)
public static D3Core instance;
private File folder;

@Mod.Metadata
private ModMetadata metadata;

private Logger logger;
private DevPerks devPerks;
private Logger logger;
private DevPerks devPerks;
private Configuration configuration;

private boolean debug = false;
private boolean sillyness = true;
private boolean debug = false;
private boolean sillyness = true;
private boolean updateWarning = true;

private List<ModContainer> d3Mods = new ArrayList<>();
private List<ModContainer> d3Mods = new ArrayList<>();
private List<CoreHelper.ModUpdateDate> updateDateList = new ArrayList<>();

@Mod.EventHandler
Expand All @@ -92,8 +99,27 @@ public void preInit(FMLPreInitializationEvent event)
FMLCommonHandler.instance().bus().register(this);

logger = event.getModLog();
configuration = new Configuration(event.getSuggestedConfigurationFile());

folder = new File(event.getModConfigurationDirectory(), MODID);
folder.mkdir();

File configFile = new File(folder, event.getSuggestedConfigurationFile().getName());
if (event.getSuggestedConfigurationFile().exists())
{
try
{
FileUtils.copyFile(event.getSuggestedConfigurationFile(), configFile);
event.getSuggestedConfigurationFile().delete();
}
catch (IOException e)
{
e.printStackTrace();
}
}
configuration = new Configuration(configFile);
syncConfig();

PermissionsDB.load();
}

@Mod.EventHandler
Expand Down Expand Up @@ -188,6 +214,14 @@ public void postInit(FMLPostInitializationEvent event)
{
logger.warn(String.format("Update available for %s (%s)! Current version: %s New version: %s. Please update ASAP!", updateDate.getName(), updateDate.getModId(), updateDate.getCurrentVersion(), updateDate.getLatestVersion()));
}

PermissionsDB.save();
}

@Mod.EventHandler
public void serverStarting(FMLServerStartingEvent event)
{
event.registerServerCommand(new CommandGroup());
}

@SubscribeEvent
Expand Down Expand Up @@ -254,4 +288,9 @@ public static DevPerks getDevPerks()
if (instance.devPerks == null) instance.devPerks = new DevPerks();
return instance.devPerks;
}

public static File getFolder()
{
return instance.folder;
}
}
122 changes: 122 additions & 0 deletions src/main/java/net/doubledoordev/d3core/permissions/Group.java
@@ -0,0 +1,122 @@
/*
* Copyright (c) 2014,
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* Neither the name of the {organization} nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
*/

package net.doubledoordev.d3core.permissions;

import java.util.HashSet;

/**
* Permission system stuff
*
* @author Dries007
*/
public class Group
{
private HashSet<Node> nodes = new HashSet<>();
private String name;
private String parent;

public Group()
{
}

public Group(String name)
{
this.name = name;
}

public Group(String name, String parent)
{
this.name = name;
this.parent = parent;
}

public String getName()
{
return name;
}

public String getParent()
{
return parent;
}

public void setParent(String parent)
{
this.parent = parent;
}

public boolean hasPermissionFor(Node requestNode)
{
if (parent != null && PermissionsDB.INSTANCE.getGroup(parent).hasPermissionFor(requestNode)) return true;
for (Node hadNode : nodes) if (hadNode.matches(requestNode)) return true;
return false;
}

@Override
public int hashCode()
{
int result = nodes.hashCode();
result = 31 * result + name.hashCode();
result = 31 * result + parent.hashCode();
return result;
}

@Override
public boolean equals(Object o)
{
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;

Group group = (Group) o;

return name.equals(group.name) && nodes.equals(group.nodes) && parent.equals(group.parent);

}

public void addNode(String nodeString)
{
nodes.add(new Node(nodeString));
}

public boolean removeNode(String nodeString)
{
return nodes.remove(new Node(nodeString));
}

public HashSet<String> getNodes()
{
HashSet<String> strings = new HashSet<>();
for (Node node : nodes) strings.add(node.toString());
return strings;
}
}
120 changes: 120 additions & 0 deletions src/main/java/net/doubledoordev/d3core/permissions/Node.java
@@ -0,0 +1,120 @@
/*
* Copyright (c) 2014,
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* Neither the name of the {organization} nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
*/

package net.doubledoordev.d3core.permissions;

import com.google.gson.*;
import net.doubledoordev.d3core.util.CoreConstants;
import org.apache.commons.lang3.ArrayUtils;

import java.lang.reflect.Type;
import java.util.Arrays;

import static net.doubledoordev.d3core.util.CoreConstants.JOINER_DOT;

/**
* Permission system stuff
*
* @author Dries007
*/
public class Node
{
final String[] parts;

public Node(String parts)
{
this.parts = parts.toLowerCase().split("\\.");
}

public Node(String... parts)
{
for (int i = 0; i < parts.length; i++)
{
parts[i] = parts[i].toLowerCase();
}
this.parts = parts;
}

public boolean matches(Node requestNode)
{
if (this.equals(requestNode)) return true;
for (int i = 0; i < this.parts.length && i < requestNode.parts.length; i++)
{
if (this.parts[i].equals("*")) return true;
if (!this.parts[i].equals(requestNode.parts[i])) return false;
}
return true;
}

@Override
public int hashCode()
{
return Arrays.hashCode(parts);
}

@Override
public boolean equals(Object o)
{
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;

Node node = (Node) o;

return Arrays.equals(parts, node.parts);
}

@Override
public String toString()
{
return JOINER_DOT.join(parts);
}

public Node append(String... extras)
{
return new Node(ArrayUtils.addAll(parts, extras));
}

public static class JsonHelper implements JsonSerializer<Node>, JsonDeserializer<Node>
{
@Override
public Node deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
{
return new Node((String) context.deserialize(json, String.class));
}

@Override
public JsonElement serialize(Node src, Type typeOfSrc, JsonSerializationContext context)
{
return context.serialize(src.toString());
}
}
}

0 comments on commit ef5eed0

Please sign in to comment.