//-------------------------------------------------------------------------------------------------- // // @ CopyRight Roberti & Parau Enterprises, Inc. 2021-2023 // // This work is licensed under the Creative Commons Attribution-NoDerivatives 4.0 International License. // To view a copy of this license, visit http://creativecommons.org/licenses/by-nd/4.0/ // or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. // //-------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------- // // Implement security manager to control macro execution // //-------------------------------------------------------------------------------------------------- package framework; import java.io.FileDescriptor; import java.io.PrintStream; public class DVSecurityManager extends SecurityManager { // // Socket security // @Override public void checkAccept(String host, int port) { if (Thread.currentThread().getName().equals("Script")) throwException(); } @Override public void checkConnect(String host, int port) { if (Thread.currentThread().getName().equals("Script")) throwException(); } @Override public void checkConnect(String host, int port, Object exContext) { if (Thread.currentThread().getName().equals("Script")) throwException(); } @Override public void checkListen(int port) { if (Thread.currentThread().getName().equals("Script")) throwException(); } // // Check access // @Override public void checkAccess(Thread thread) { if (Thread.currentThread().getName().equals("Script")) throwException(); } @Override public void checkAccess(ThreadGroup threadGroup) { if (Thread.currentThread().getName().equals("Script")) throwException(); } // // Check create class loader // @Override public void checkCreateClassLoader() { } // // Check I/O // @Override public void checkDelete(String fileName) { if (Thread.currentThread().getName().equals("Script")) throwException(); } @Override public void checkLink(String libName) { if (Thread.currentThread().getName().equals("Script")) throwException(); } @Override public void checkRead(FileDescriptor fileDescriptor) { if (Thread.currentThread().getName().equals("Script")) throwException(); } @Override public void checkRead(String fileName) { if (Thread.currentThread().getName().equals("Script")) throwException(); } @Override public void checkRead(String fileName, Object exContext) { if (Thread.currentThread().getName().equals("Script")) throwException(); } @Override public void checkWrite(FileDescriptor fileDescriptor) { if (Thread.currentThread().getName().equals("Script")) throwException(); } @Override public void checkWrite(String fileName) { if (Thread.currentThread().getName().equals("Script")) throwException(); } // // Check command execution // @Override public void checkExec(String cmdName) { if (Thread.currentThread().getName().equals("Script")) throwException(); } // // Check interpreter exit // @Override public void checkExit(int status) { if (Thread.currentThread().getName().equals("Script")) throwException(); } // // Check package access // @Override public void checkPackageAccess(String packageName) { } // // Check property access // @Override public void checkPropertiesAccess() { if (Thread.currentThread().getName().equals("Script")) throwException(); } @Override public void checkPropertyAccess(String key) { } // // Check networking // @Override public void checkSetFactory() { if (Thread.currentThread().getName().equals("Script")) throwException(); } // // Throw exception // void throwException() { throw new SecurityException(); } }