protected PermissionCollection getPermissions(CodeSource codesource) { if (RobocodeProperties.isSecurityOn()) { return EMPTY_PERMISSIONS; } return super.getPermissions(codesource); }
public RobocodeSecurityManager(IThreadManager threadManager) { super(); this.threadManager = threadManager; ThreadGroup tg = Thread.currentThread().getThreadGroup(); while (tg != null) { threadManager.addSafeThreadGroup(tg); tg = tg.getParent(); } // We need to exercise it in order to load all used classes on this thread isSafeThread(Thread.currentThread()); if (RobocodeProperties.isSecurityOn()) { System.setSecurityManager(this); } }
private void testPackages(String name) throws ClassNotFoundException { if (name.startsWith("net.sf.robocode")) { String message = "Robots are not allowed to reference Robocode engine in package: net.sf.robocode"; punishSecurityViolation(message); throw new ClassNotFoundException(message); } if (name.startsWith("robocode.control")) { String message = "Robots are not allowed to reference Robocode engine in package: robocode.control"; punishSecurityViolation(message); throw new ClassNotFoundException(message); } if (RobocodeProperties.isSecurityOn() && name.startsWith("javax.swing")) { String message = "Robots are not allowed to reference Robocode engine in package: javax.swing"; punishSecurityViolation(message); throw new ClassNotFoundException(message); } }
public synchronized Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException { if (name.startsWith("java.lang")) { // we always delegate java.lang stuff to parent loader return super.loadClass(name, resolve); } if (RobocodeProperties.isSecurityOn()) { testPackages(name); } if (!name.startsWith("robocode")) { Class<?> result = loadRobotClassLocaly(name, resolve); if (result != null) { // yes, it is in robot's class path // we loaded it locally return result; } } // it is robot API // or java class // or security is off // so we delegate to parent class loader return parent.loadClass(name); }
public RobocodeSecurityPolicy(IThreadManager threadManager) { this.parentPolicy = Policy.getPolicy(); this.allPermissions = new Permissions(); this.allPermissions.add(new AllPermission()); this.threadManager = threadManager; allowedPackages.add("robocode.util"); allowedPackages.add("robocode.robotinterfaces"); allowedPackages.add("robocode.robotpaint"); allowedPackages.add("robocode.robocodeGL"); if (isExperimental) { allowedPackages.add("robocode.robotinterfaces.peer"); } initUrls(); if (RobocodeProperties.isSecurityOn()) { Policy.setPolicy(this); } }
if (RobocodeProperties.isSecurityOn()) { logError("Robot " + robotProxy.getStatics().getName() + " is not stopping. Forcing a stop.");
realBattle.setBattleThread(battleThread); if (RobocodeProperties.isSecurityOn()) { hostManager.addSafeThread(battleThread);