// Path: src/main/java/net/datenwerke/sandbox/securitypermissions/SandboxRuntimePermission.java
// public class SandboxRuntimePermission extends BasicPermission {
// 
// 	/**
// 	 * 
// 	 */
// 	private static final long serialVersionUID = 6914720697570769005L;
// 
// 	public SandboxRuntimePermission(String name) {
// 		super(name);
// 	}
// 
// }


import java.security.AccessControlException;
import java.security.Permission;
import java.util.Arrays;
import net.datenwerke.sandbox.securitypermissions.SandboxRuntimePermission;
				
				Class stack[] = getClassContext();
				
				if(! rs.checkPackageAccess(pkg, stack)){
					if(debug)
						rs.debugDeniedPackageAccess(pkg, stack);
					
					throw new AccessControlException("No package access allowed for package: " + pkg);
				}
			} finally {
				setInCheck(false);
			}
		}
	}
	
	Class[] getCurrentClassContext() {
		if(isRestricted())
			throw new AccessControlException("no classContext during sandbox");
		return super.getClassContext();
	}

	public void checkPackageDefinition(String pkg) {
		if(codesourceSecurityChecks)
			super.checkPackageDefinition(pkg);
		
		if(isRestricted())
			throw new AccessControlException("no package definition: " + pkg);
	}

	void setCodesourceSecurityChecks(boolean enable) {
// Path: src/main/java/net/datenwerke/sandbox/securitypermissions/SandboxRuntimePermission.java
// public class SandboxRuntimePermission extends BasicPermission {
// 
// 	/**
// 	 * 
// 	 */
// 	private static final long serialVersionUID = 6914720697570769005L;
// 
// 	public SandboxRuntimePermission(String name) {
// 		super(name);
// 	}
// 
// }


// Path: src/main/java/net/datenwerke/sandbox/SandboxSecurityManager.java
import java.security.AccessControlException;
import java.security.Permission;
import java.util.Arrays;
import net.datenwerke.sandbox.securitypermissions.SandboxRuntimePermission;

				
				Class stack[] = getClassContext();
				
				if(! rs.checkPackageAccess(pkg, stack)){
					if(debug)
						rs.debugDeniedPackageAccess(pkg, stack);
					
					throw new AccessControlException("No package access allowed for package: " + pkg);
				}
			} finally {
				setInCheck(false);
			}
		}
	}
	
	Class[] getCurrentClassContext() {
		if(isRestricted())
			throw new AccessControlException("no classContext during sandbox");
		return super.getClassContext();
	}

	public void checkPackageDefinition(String pkg) {
		if(codesourceSecurityChecks)
			super.checkPackageDefinition(pkg);
		
		if(isRestricted())
			throw new AccessControlException("no package definition: " + pkg);
	}

	void setCodesourceSecurityChecks(boolean enable) {
		checkPermission(new SandboxRuntimePermission("enableCodesourceSecurity"));