Class SecurityPolicy

java.lang.Object
com.ultikits.ultitools.utils.SecurityPolicy

public class SecurityPolicy extends Object
Validates module JAR structure before a classloader consumes it. The archive must be a readable regular JAR file within the 100 MB and 10,000-entry limits. This is not a sandbox and does not constrain what loaded module code can do.
  • Field Details

    • LOGGER

      private static final Logger LOGGER
  • Constructor Details

    • SecurityPolicy

      public SecurityPolicy()
  • Method Details

    • isSafeFileStructure

      public static boolean isSafeFileStructure(long fileSize, int entryCount)
      Validate file size and structure for security.
      Parameters:
      fileSize - file size in bytes
      entryCount - number of entries in archive
      Returns:
      true if safe, false otherwise
    • isValidModuleJar

      public static boolean isValidModuleJar(File jarFile)
      Validate that a module JAR is safe to hand to a classloader: it must exist, be a regular file, have a .jar suffix (case-insensitive), open as a readable archive, and pass the size/entry-count limits enforced by isSafeFileStructure(long, int).

      This is a static, instance-free rule with no dependency on Bukkit — it must be callable before the plugin's onEnable() has built any manager, and from a plain JUnit test with no server running. Callers are responsible for skipping (not adding) a JAR this method rejects; this method never throws for a JAR it judges unsafe, it only returns false.

      Parameters:
      jarFile - candidate module jar file
      Returns:
      true if the jar may be handed to a classloader, false otherwise
      Since:
      6.3.0
    • logSecurityViolation

      private static void logSecurityViolation(String reason, String details)
      Log security violation for monitoring and audit purposes.
      Parameters:
      reason - violation reason
      details - violation details