diff options
Diffstat (limited to 'sandbox/com/sun')
28 files changed, 0 insertions, 4296 deletions
diff --git a/sandbox/com/sun/star/lib/sandbox/AudioProxy.java b/sandbox/com/sun/star/lib/sandbox/AudioProxy.java deleted file mode 100644 index 07a0dce1d5..0000000000 --- a/sandbox/com/sun/star/lib/sandbox/AudioProxy.java +++ /dev/null @@ -1,74 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: AudioProxy.java,v $ - * $Revision: 1.3 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -package com.sun.star.lib.sandbox; - -import java.applet.AudioClip; - -import java.util.Vector; - -class AudioProxy implements AudioClip, Holder { - private static final boolean DEBUG = false; - private static int instances; - - private AudioClip audioClip; - private Vector cargo = new Vector(); - - AudioProxy(AudioClip audioClip) { - this.audioClip = audioClip; - instances ++; - } - - public void play() { - audioClip.play(); - } - - public void loop() { - audioClip.loop(); - } - - public void stop() { - audioClip.stop(); - } - - public void addCargo(Object object) { - cargo.addElement(object); - } - - public void removeCargo(Object object) { - cargo.removeElement(object); - } - - public void finalize() { - if(DEBUG) System.err.println("#### AudioProxy.finalize"); - instances --; - } -} - diff --git a/sandbox/com/sun/star/lib/sandbox/Cachable.java b/sandbox/com/sun/star/lib/sandbox/Cachable.java deleted file mode 100644 index 607124c011..0000000000 --- a/sandbox/com/sun/star/lib/sandbox/Cachable.java +++ /dev/null @@ -1,37 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: Cachable.java,v $ - * $Revision: 1.3 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -package com.sun.star.lib.sandbox; - -public interface Cachable { - Object getHardObject(); - void setWeakRef(WeakRef weakRef); -} - diff --git a/sandbox/com/sun/star/lib/sandbox/ClassContext.java b/sandbox/com/sun/star/lib/sandbox/ClassContext.java deleted file mode 100644 index 8027485eeb..0000000000 --- a/sandbox/com/sun/star/lib/sandbox/ClassContext.java +++ /dev/null @@ -1,58 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: ClassContext.java,v $ - * $Revision: 1.4 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -package com.sun.star.lib.sandbox; - -import java.io.InputStream; - -import java.net.URL; - -public interface ClassContext { - public URL getBase(); - - public boolean hasThreadGroup(); - - public ThreadGroup getThreadGroup(); - - public InputStream getResourceAsStream(String name); - - public URL getResource(String name); - - public Class findClass(String className) throws ClassNotFoundException; - - public Class loadClass(String className) throws ClassNotFoundException; - - public void dispose(); - - public ClassLoader getClassLoader(); - - public void addCargo( Object cargo ); -} - diff --git a/sandbox/com/sun/star/lib/sandbox/ClassContextImpl.java b/sandbox/com/sun/star/lib/sandbox/ClassContextImpl.java deleted file mode 100644 index 5eed4a85ab..0000000000 --- a/sandbox/com/sun/star/lib/sandbox/ClassContextImpl.java +++ /dev/null @@ -1,356 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: ClassContextImpl.java,v $ - * $Revision: 1.14 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -package com.sun.star.lib.sandbox; - -import java.awt.Toolkit; -import java.awt.Image; - -import java.io.IOException; -import java.io.InputStream; -import java.io.BufferedInputStream; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; - -import java.net.URL; -import java.net.URLConnection; -import java.net.MalformedURLException; - -import java.util.Hashtable; - -import java.util.zip.ZipEntry; - -final class ClassContextImpl extends ClassLoader implements ClassContext { - private static int instances; - private static final boolean DEBUG = false; - - private URL codeBase; - private ProtectionDomain protectionDomain; - private boolean _bSecure; - private java.util.Vector _cargoVector = new java.util.Vector(); - - private java.util.Vector m_class_path_jars; - - // HACKHACK!!!: java.lang.Thread fragt bei erzeugen eines Threads den - // HACKHACK!!!: SECURITYMANAGER nach der THREADGROUP - private ThreadGroup threadGroup; - - public ClassContextImpl(URL codeBase, ProtectionDomain protectionDomain, ThreadGroup threadGroup, boolean bSecure) { - this(codeBase, protectionDomain, threadGroup); - - _bSecure = bSecure; - } - - public ClassContextImpl(URL codeBase, ProtectionDomain protectionDomain, ThreadGroup threadGroup) { - if(DEBUG)System.err.println("#### ClassContextImpl.<init>:" + codeBase + " " + protectionDomain + " " + threadGroup); - - instances ++; - - this.codeBase = codeBase; - this.protectionDomain = protectionDomain; - this.threadGroup = threadGroup; - } - - public void finalize() { - instances --; - } - - public URL getBase() { - return codeBase; - } - - public void addCargo( Object cargo ) { - _cargoVector.addElement( cargo ); - } - - // For OS/2 - public URL getCodeBase() - { - return getBase(); - } - - public boolean hasThreadGroup() { - return threadGroup != null && !threadGroup.isDestroyed(); - } - - public ThreadGroup getThreadGroup() { - if(threadGroup == null || threadGroup.isDestroyed()) { - threadGroup = new ThreadGroup(codeBase.toString()); - threadGroup.setDaemon(true); - } - - return threadGroup; - } - - boolean checkSecurity() { - return !_bSecure; - } - - public InputStream getResourceAsStream(String name) { - if(DEBUG) System.err.println("#### ClassContext.getResourceAsStream:" + name); - - InputStream inputStream = getSystemResourceAsStream(name); - if(inputStream == null) { - try { - URL url = new URL(codeBase, name); - if(ResourceProxy.isResource(url)) { // VALID URL? - ResourceProxy resourceProxy = ResourceProxy.load(url, protectionDomain); - inputStream = resourceProxy.getInputStream(); - } - } - catch(MalformedURLException me) { - } - catch(IOException ioe) { - } - } - - return inputStream; - } - - public URL getResource(String name) { - if(DEBUG) System.err.println("#### ClassContext.getResource:" + name); - - URL url = getSystemResource(name); - if(url == null) { - try { - url = new URL(codeBase, name); - if(!ResourceProxy.isResource(url)) // VALID URL? - url = null; - else - url = new URL("appletresource:" + codeBase + "/+/" + name); - } - catch(MalformedURLException malformedURLException) { - if(DEBUG) System.err.println("#### ClassContext.getResource - exception: " + malformedURLException); - } - } - - return url; - } - - public Class findClass(String className) throws ClassNotFoundException { - Class xClass = findLoadedClass(className); - - // It is a nasty hack to test if want to generate - // a proxy, but exception throw here sometimes - // kills the java vm (jdk1.2.2) - if(xClass == null && !className.startsWith("JSGen")) - xClass = getClass().forName(className); - - // see above, throwing the exception here - // kills sometimes the javavm -// if(xClass == null) { -// throw new ClassNotFoundException(); -// } - - return xClass; - } - - public Class loadClass(String className) throws ClassNotFoundException { - return loadClass(className, true); - } - - synchronized protected Class loadClass(String className, boolean resolve) throws ClassNotFoundException { - if(DEBUG) System.err.println("#### ClassContext.loadClass:" + className + " " + resolve); - - // ???SECURITY???? - SecurityManager security = System.getSecurityManager(); - if(security != null) { - int i = className.lastIndexOf('.'); - if(i >= 0) - security.checkPackageAccess(className.substring(0, i)); - } - - - Class xClass = null; - - try { - xClass = findClass(className); - } - catch(ClassNotFoundException e) { - } - - if(xClass == null) - { - try - { - try - { - ResourceProxy resourceProxy = null; - resourceProxy = - ResourceProxy.load( - new URL( codeBase, className.replace('.', '/') + ".class" ), protectionDomain ); - byte bytes[] = resourceProxy.getBytes(); - // if(DEBUG) printHeader(bytes); - - xClass = defineClass(className, bytes, 0, bytes.length); - // xClass = defineClass(className, bytes, 0, bytes.length, protectionDomain); - } - catch (IOException exc) // if not found - { - // try further Class-Path jars - if (null == m_class_path_jars) - { - java.util.Vector class_path_jars = new java.util.Vector(); - try - { - java.net.URL manifest_url = new java.net.URL( - codeBase, "META-INF/MANIFEST.MF" ); - // read Class-Path from manifest file - ResourceProxy resource= ResourceProxy.load( manifest_url, null ); - java.io.InputStream inManifest = resource.getInputStream(); - java.util.jar.Manifest manifest = - new java.util.jar.Manifest( inManifest ); - java.util.jar.Attributes attributes = manifest.getMainAttributes(); - String class_path = attributes.getValue( "Class-Path" ); - - if (class_path != null) - { - java.util.Enumeration tokens = - new java.util.StringTokenizer( class_path ); - while (tokens.hasMoreElements()) - { - try - { - java.net.URL url; - String str_url = (String)tokens.nextElement(); - if (str_url.charAt( 0 ) != '/' && - str_url.indexOf( ':' ) < 0) - { - // relative path - url = new java.net.URL( codeBase, str_url ); - } - else - { - url = new java.net.URL( str_url ); - } - ClassContext context = - ClassContextProxy.create( - url, protectionDomain, threadGroup, true ); - Resource res = ResourceProxy.load(url, null); - res.loadJar(url); - context.addCargo( resource ); - class_path_jars.add( context ); - } - catch (MalformedURLException e) // ignoring - { - } - } - } - } - catch (IOException e2) - { - } - m_class_path_jars = class_path_jars; - } - - java.util.Enumeration enum_elements = m_class_path_jars.elements(); - while (enum_elements.hasMoreElements()) - { - ClassContext context = (ClassContext)enum_elements.nextElement(); - try - { - xClass = context.loadClass( className ); - } - catch (ClassNotFoundException e) // if not found, try next - { - } - } - if (null == xClass) - { - throw new ClassNotFoundException( - "ClassContext.loadClass - class not found: " - + className + " " + codeBase ); - } - } - -// Object objects[] = new Object[2]; -// objects[0] = resourceProxy.getProtectionDomain(); -// setSigners(xClass, objects); - } - catch(ClassFormatError classFormatError) { - if(DEBUG) System.err.println("#### ClassContext.loadClass - ClassFormat exception:" + classFormatError); - throw new ClassNotFoundException("ClassContext.loadClass - ClassFormatError:" - + " " + classFormatError - + " " + className - + " " + codeBase); - } - } - - if (xClass != null && resolve) - resolveClass(xClass); - - return xClass; - } - - static class ThreadGroupKiller implements Runnable { - ThreadGroup threadGroup = null; - - ThreadGroupKiller(ThreadGroup threadGroup) { - this.threadGroup = threadGroup; - } - - public void run() { - try { - if (DEBUG) System.err.println("#### ClassContext - killerThread start"); - threadGroup.stop(); - threadGroup.destroy(); - if (DEBUG) System.err.println("#### ClassContext - killerThread succeeded"); - } - catch(Exception exception) { - if (DEBUG) System.err.println("ClassContext.dispose:" + exception); - } - } - }; - - synchronized public void dispose() { - if(DEBUG)System.err.println("#### ClassContext.dispose:" + threadGroup); - - if(threadGroup != null) { - threadGroup.list(); - - new Thread(new ThreadGroupKiller(threadGroup), codeBase.toString() + " killer thread").start(); - - threadGroup = null; - } - } - - private void printHeader(byte bytes[]) { - System.err.print("#### ClassContext.loadClass - bytes header:"); - for(int x =0 ; x < 4; x++) { - System.err.print(" " + Integer.toHexString(((int)bytes[x]) & 0xff)); - } - System.err.println(); - } - - public ClassLoader getClassLoader() { - return this; - } -} - diff --git a/sandbox/com/sun/star/lib/sandbox/ClassContextProxy.java b/sandbox/com/sun/star/lib/sandbox/ClassContextProxy.java deleted file mode 100644 index 6c90cbe899..0000000000 --- a/sandbox/com/sun/star/lib/sandbox/ClassContextProxy.java +++ /dev/null @@ -1,152 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: ClassContextProxy.java,v $ - * $Revision: 1.5 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -package com.sun.star.lib.sandbox; - -import java.awt.Toolkit; -import java.awt.Image; - -import java.io.IOException; -import java.io.InputStream; -import java.io.BufferedInputStream; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; - -import java.net.URL; -import java.net.URLConnection; -import java.net.MalformedURLException; - -import java.util.Hashtable; -import java.util.zip.ZipEntry; - -public final class ClassContextProxy implements ClassContext, Cachable { - private static int instances; - private static final boolean DEBUG = false; - - /* - ** interface cachable methods - */ - private ClassContext classContext; - private WeakRef weakRef; - - public ClassContextProxy() { - instances ++; - } - - public Object getHardObject() { - return classContext; - } - - public void setWeakRef(WeakRef weakRef) { - classContext = (ClassContext)weakRef.getRef(); - base = classContext.getBase(); - - this.weakRef = weakRef; - weakRef.incRefCnt(); - } - - public void finalize() { - weakRef.decRefCnt(); - - instances --; - } - - /* - ** ClassContext methods - */ - private URL base; - - - public static ClassContext create(URL base, ProtectionDomain protectionDomain, ThreadGroup threadGroup) { - return create(base, protectionDomain, threadGroup, false); - } - - public static ClassContext create(URL base, ProtectionDomain protectionDomain, ThreadGroup threadGroup, boolean bSecure) { - Object object = WeakTable.get("ClassContxt: " + base); - if(DEBUG) System.err.println("#### ClassContextProxy.create:" + object); - ClassContextProxy classContextProxy = (ClassContextProxy)object; - - if(classContextProxy == null) { - classContextProxy = new ClassContextProxy(base, protectionDomain, threadGroup, bSecure); - WeakTable.put("ClassContxt: " + base, classContextProxy); - } - - return classContextProxy; - } - - private ClassContextProxy(URL base, ProtectionDomain protectionDomain, ThreadGroup threadGroup, boolean bSecure) { - this(); - - this.base = base; - - classContext = new ClassContextImpl(base, protectionDomain, threadGroup, bSecure); - } - - public ClassLoader getClassLoader() { - return classContext.getClassLoader(); - } - - public boolean hasThreadGroup() { - return classContext.hasThreadGroup(); - } - - public ThreadGroup getThreadGroup() { - return classContext.getThreadGroup(); - } - - public URL getBase() { - return classContext.getBase(); - } - - public InputStream getResourceAsStream(String name) { - return classContext.getResourceAsStream(name); - } - - public URL getResource(String name) { - return classContext.getResource(name); - } - - public void addCargo( Object cargo ) { - classContext.addCargo( cargo ); - } - - public void dispose() { // HIER SOLLTE VIELLEICHT NOCH MEHR GETAN WERDEN? - classContext.dispose(); - } - - public synchronized Class findClass(String className) throws ClassNotFoundException { - return classContext.findClass(className); - } - - public synchronized Class loadClass(String className) throws ClassNotFoundException { - return classContext.loadClass(className); - } -} - diff --git a/sandbox/com/sun/star/lib/sandbox/CodeSource.java b/sandbox/com/sun/star/lib/sandbox/CodeSource.java deleted file mode 100644 index acbbacaa29..0000000000 --- a/sandbox/com/sun/star/lib/sandbox/CodeSource.java +++ /dev/null @@ -1,52 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: CodeSource.java,v $ - * $Revision: 1.3 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -package com.sun.star.lib.sandbox; - -import java.net.URL; - -import java.util.Vector; - -public final class CodeSource { - URL url; - java.security.Identity identities[]; - - public CodeSource(URL url) { - this(url, new java.security.Identity[0]); - } - - public CodeSource(URL url, java.security.Identity identities[]) { - SecurityManager security = System.getSecurityManager(); -// if(security != null) security.checkSecurityAccess("CodeSource"); - - this.url = url; - } -} - diff --git a/sandbox/com/sun/star/lib/sandbox/Disposable.java b/sandbox/com/sun/star/lib/sandbox/Disposable.java deleted file mode 100644 index ed06774997..0000000000 --- a/sandbox/com/sun/star/lib/sandbox/Disposable.java +++ /dev/null @@ -1,36 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: Disposable.java,v $ - * $Revision: 1.3 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -package com.sun.star.lib.sandbox; - -public interface Disposable { - void dispose(); -} - diff --git a/sandbox/com/sun/star/lib/sandbox/ExecutionContext.java b/sandbox/com/sun/star/lib/sandbox/ExecutionContext.java deleted file mode 100644 index a534ec2ff7..0000000000 --- a/sandbox/com/sun/star/lib/sandbox/ExecutionContext.java +++ /dev/null @@ -1,473 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: ExecutionContext.java,v $ - * $Revision: 1.5 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -package com.sun.star.lib.sandbox; - -import java.awt.Image; -import java.awt.Dimension; -import java.awt.Container; -import java.awt.BorderLayout; - -import java.applet.Applet; -import java.applet.AppletStub; -import java.applet.AppletContext; -import java.applet.AudioClip; - -import java.io.IOException; -import java.io.InputStream; -import java.io.ByteArrayOutputStream; - -import java.net.URL; -import java.net.MalformedURLException; - -import java.text.MessageFormat; - -import java.util.Hashtable; -import java.util.Observable; -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -public abstract class ExecutionContext extends Observable { - private static final boolean DEBUG = false; - - private static int instances; - - /* message ids */ - protected final static int CMD_LOAD = 1; - protected final static int CMD_INIT = 2; - protected final static int CMD_START = 3; - protected final static int CMD_STOP = 4; - protected final static int CMD_DESTROY = 5; - protected final static int CMD_DISPOSE = 6; - - protected final static int LOADED = 1; - protected final static int INITED = 2; - protected final static int STARTED = 3; - protected final static int STOPPED = 4; - protected final static int DESTROYED = 5; - protected final static int DISPOSED = 6; - - private int status = DISPOSED; - private Object statusLock= new Object(); - private boolean bDispatchException; - - protected ClassContext classContext; - - private Thread dispatchThread = null; - private SandboxThreadGroup threadGroup = null; - - private String name; - - protected ResourceBundle resourceBundle; - - private Object synObj = new Object(); - private Message head; - private Message tail; - private boolean loop = true; - - protected ExecutionContext() { - instances ++; - } - - public void finalize() { - instances --; - } - - public int getStatus() { - return status; - } - - Object getSynObject() { - return synObj; - } - - class Message { - Message next; - int id; - - Message(int id) { - this.id = id; - } - } - - public void init(String name, ClassContext classContext) throws MissingResourceException { - this.name = name; - - resourceBundle = ResourceBundle.getBundle("sun.applet.resources.MsgAppletViewer"); - - this.classContext = classContext; - - threadGroup = new SandboxThreadGroup(classContext.getThreadGroup(), name, classContext.getClassLoader()); - threadGroup.setDaemon(true); - - dispatchThread = new Thread( threadGroup, new Runnable() { - public void run() { - while( loop ) { - if( head != null) { - if (DEBUG) System.err.println("#### ExecutionContext dispatchThread " + dispatchThread.toString() + " -dispatching: " + head.id); - dispatch( head.id ); - if (DEBUG) System.err.println("#### ExecutionContext dispatchThread " + dispatchThread.toString() + " get next head - current state is " +head.id ); - synchronized( getSynObject() ) { - head = head.next; - getSynObject().notify(); - } - } - - synchronized( getSynObject() ) { - if (head == null) { - try { - getSynObject().wait(); - } - catch (InterruptedException e ) { - if (DEBUG) System.err.println("#### ExecutionContext - dispatchThread " + dispatchThread.toString() + " -interrupted"); - break; - } - } - } - } - if(DEBUG) System.err.println("#### ExecutionContext - dispatchThread -terminating"); - } - }); - - dispatchThread.setDaemon(true); - dispatchThread.start(); - } - public void sendEvent(int id) { - sendEvent(id, 0); - } - - public void sendEvent(int id, int timeout) { - synchronized( getSynObject() ) { - try { - Message message = new Message(id); - if(tail != null) - tail.next = message; - - tail = message; - - if(head == null) - head = tail; - - getSynObject().notify(); - - if ( timeout != 0 ) - getSynObject().wait( timeout ); - } - catch( InterruptedException e ) { - } - } - } - - public void dispose() { - //if(DEBUG) System.err.println("#### ExecutionContext.disposing"); - dispose(1000); - } - - public void dispose( long timeout ) { - if(DEBUG) System.err.println("#### ExecutionContext "+ dispatchThread.toString() +"disposing:" + timeout); - try { - try { - synchronized( getSynObject() ) { - while( head != null ) - getSynObject().wait( timeout ); // wait at most one second for each queued command - loop = false; - getSynObject().notifyAll(); - } - dispatchThread.join(timeout); - } - catch(InterruptedException ee) { - if(DEBUG) System.err.println("#### ExecutionContext " + dispatchThread.toString() + " - dispose 1:" + ee); - } - - if(DEBUG) threadGroup.list(); - if ( !threadGroup.isDestroyed() ) - threadGroup.destroy(); - } - catch (Exception ie) { - if(DEBUG) System.err.println("#### ExecutionContext "+ threadGroup.toString() + " - destroyThreadGroup:" + ie); - try { - threadGroup.stop(); - } catch (Exception se) { - if(DEBUG) System.err.println("#### ExecutionContext "+ threadGroup.toString() + " - stop ThreadGroup:" + se); - } - } - - classContext = null; - - dispatchThread = null; - threadGroup.dispose(); - threadGroup = null; - - name = null; - - resourceBundle = null; - - synObj = null; - head = null; - tail = null; - } - - - protected void showStatus(String status) { - if (DEBUG) System.err.println("#### ExecutionContext.showStatus:" + status); - setChanged(); - notifyObservers(resourceBundle.getString("appletpanel." + status)); - } - - protected void showStatus(String status, String arg1) { - if(DEBUG) System.err.println("#### ExecutionContext.showStatus" + status + " " + arg1); - try { - Object args[] = new Object[1]; - args[0] = arg1; - setChanged(); - try { - notifyObservers(MessageFormat.format(resourceBundle.getString("appletpanel." + status), args)); - } - catch(MissingResourceException me) {} - } - catch(Exception ee) { - if(DEBUG)System.err.println("#### ExecutionContext.showStatus:" + ee); - } - } - - - public ThreadGroup getThreadGroup() { - return threadGroup; - } - - /** - * Send an event. Queue it for execution by the handler thread. - */ - public void dispatch(int id) { - try { - switch(id) { - case CMD_LOAD: - if (status == DISPOSED) { - xload(); - setStatus(LOADED); - showStatus("loaded"); - } - else - showStatus("notdisposed"); - break; - - case CMD_INIT: - if(status == LOADED || status == DESTROYED) { - xinit(); - setStatus(INITED); - showStatus("inited"); - } - else - showStatus("notloaded"); - break; - - case CMD_START: - if (status == INITED || status == STOPPED) { - xstart(); - setStatus(STARTED); - showStatus("started"); - } - else - showStatus("notinited"); - break; - - case CMD_STOP: - if (status == STARTED) { - xstop(); - setStatus(STOPPED); - showStatus("stopped"); - } - else - showStatus("notstarted"); - break; - - case CMD_DESTROY: - if(status == INITED || status == STOPPED) { - xdestroy(); - setStatus(DESTROYED); - showStatus("destroyed"); - } - else - showStatus("notstopped"); - break; - - case CMD_DISPOSE: - if (status == LOADED || status == DESTROYED) { - xdispose(); - // baseResourceLoader.flush(); - showStatus("disposed"); - setStatus(DISPOSED); - } - else - showStatus("notdestroyed"); - break; - - default: - xExtended(id); - } - } - catch (ClassNotFoundException classNotFoundException) { - setDispatchException(); - showStatus("notfound", name); - if(DEBUG) classNotFoundException.printStackTrace(); - } - catch (InstantiationException instantiationException) { - setDispatchException(); - showStatus("nocreate", name); - if(DEBUG) instantiationException.printStackTrace(); - } - catch (IllegalAccessException illegalAccessException) { - setDispatchException(); - showStatus("noconstruct", name); - if(DEBUG) illegalAccessException.printStackTrace(); - } - catch (Exception exception) { - setDispatchException(); - showStatus("exception", exception.getMessage()); - if(DEBUG) exception.printStackTrace(); - } - catch (ThreadDeath threadDeath) { - setDispatchException(); - showStatus("death"); - if(DEBUG) threadDeath.printStackTrace(); - - throw threadDeath; - } - catch (Error error) { - setDispatchException(); - showStatus("error", error.getMessage()); - if(DEBUG) error.printStackTrace(); - } - } - - protected abstract void xload() throws ClassNotFoundException, InstantiationException, IllegalAccessException; - protected abstract void xinit(); - protected abstract void xstart(); - protected abstract void xstop(); - protected abstract void xdestroy(); - protected abstract void xdispose(); - - protected void xExtended(int id) { - } - - /* - ** - */ - public void sendLoad() { - sendEvent(CMD_LOAD); - } - - public void sendInit() { - sendEvent(CMD_INIT); - } - - public void sendStart() { - sendEvent(CMD_START); - } - - public void sendStop() { - sendEvent(CMD_STOP); - } - - public void sendDestroy() { - sendEvent(CMD_DESTROY); - } - - public void sendDispose() { - sendEvent(CMD_DISPOSE); - } - - public void startUp() { - sendLoad(); - sendInit(); - sendStart(); - } - - public void shutdown() { - sendStop(); - sendDestroy(); - sendDispose(); - } - - public void restart() { - sendStop(); - sendDestroy(); - sendInit(); - sendStart(); - } - - public void reload() { - sendStop(); - sendDestroy(); - sendDispose(); - sendLoad(); - sendInit(); - sendStart(); - } - - /** This function blocks until the status of ExecutionContext is DISPOSED or - * an Exeption occurred during a call to the AppletExecutionContext in dispatch. - * @see #dispatch - * @see #setStatus - * @see #setDispatchException - */ - public void waitForDispose() { - if (status == DISPOSED || bDispatchException) - return; - else - { - // wait until status is disposed - synchronized (statusLock) { - while (status != DISPOSED && !bDispatchException) { - try { - statusLock.wait(); - } catch (java.lang.InterruptedException e) { - } - } - } - } - System.err.println("exit"); - } - - protected void setStatus( int newStatus) { - synchronized (statusLock) { - status= newStatus; - statusLock.notifyAll(); - } - } - - protected void setDispatchException() { - synchronized (statusLock) { - bDispatchException= true; - statusLock.notifyAll(); - } - } -} - diff --git a/sandbox/com/sun/star/lib/sandbox/Holder.java b/sandbox/com/sun/star/lib/sandbox/Holder.java deleted file mode 100644 index d65efb856a..0000000000 --- a/sandbox/com/sun/star/lib/sandbox/Holder.java +++ /dev/null @@ -1,38 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: Holder.java,v $ - * $Revision: 1.3 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -package com.sun.star.lib.sandbox; - - -public interface Holder { - void addCargo(Object object); - void removeCargo(Object object); -} - diff --git a/sandbox/com/sun/star/lib/sandbox/ImageProducerProxy.java b/sandbox/com/sun/star/lib/sandbox/ImageProducerProxy.java deleted file mode 100644 index a05abf71db..0000000000 --- a/sandbox/com/sun/star/lib/sandbox/ImageProducerProxy.java +++ /dev/null @@ -1,77 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: ImageProducerProxy.java,v $ - * $Revision: 1.3 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -package com.sun.star.lib.sandbox; - -import java.awt.image.ImageConsumer; -import java.awt.image.ImageProducer; - -import java.util.Vector; - -class ImageProducerProxy implements ImageProducer, Holder { - ImageProducer imageProducer; - - ImageProducerProxy(ImageProducer imageProducer) { - this.imageProducer = imageProducer; - } - - public void addConsumer(ImageConsumer imageConsumer) { - imageProducer.addConsumer(imageConsumer); - } - - public boolean isConsumer(ImageConsumer imageConsumer) { - return imageProducer.isConsumer(imageConsumer); - } - - public void removeConsumer(ImageConsumer imageConsumer) { - imageProducer.removeConsumer(imageConsumer); - } - - public void startProduction(ImageConsumer imageConsumer) { - imageProducer.startProduction(imageConsumer); - } - - public void requestTopDownLeftRightResend(ImageConsumer imageConsumer) { - imageProducer.requestTopDownLeftRightResend(imageConsumer); - } - - - /* Holder methods */ - private Vector cargo = new Vector(); - - public void addCargo(Object object) { - cargo.addElement(object); - } - - public void removeCargo(Object object) { - cargo.removeElement(object); - } -} - diff --git a/sandbox/com/sun/star/lib/sandbox/JarEntry.java b/sandbox/com/sun/star/lib/sandbox/JarEntry.java deleted file mode 100644 index 90f2584575..0000000000 --- a/sandbox/com/sun/star/lib/sandbox/JarEntry.java +++ /dev/null @@ -1,95 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: JarEntry.java,v $ - * $Revision: 1.3 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -package com.sun.star.lib.sandbox; - -import java.security.Identity; - -import java.util.zip.ZipEntry; - -import java.lang.reflect.Method; -import java.lang.reflect.InvocationTargetException; - -import sun.tools.jar.JarVerifierStream; - -public class JarEntry { - private static final boolean DEBUG = false; - - private ZipEntry zipEntry = null; - private JarVerifierStream jvs = null; - - public JarEntry(ZipEntry zipEntry, JarVerifierStream jvs) { - this.zipEntry = zipEntry; - this.jvs = jvs; - } - - public Identity[] getIdentities() { - Identity identities[] = null; - - if(jvs != null) { - Class classes[] = new Class[1]; - classes[0] = String.class; - - try { - Method method = JarVerifierStream.class.getMethod("getIdentities", classes); - - Object objects[] = new Object[1]; - objects[0] = zipEntry.getName(); - - identities = (Identity[])method.invoke(jvs, objects); - } - catch(IllegalAccessException illegalAccessException) { - if(DEBUG)System.err.println("#### JarEntry.getIdentities:" + illegalAccessException); - } - catch(IllegalArgumentException illegalArgumentException) { - if(DEBUG)System.err.println("#### JarEntry.getIdentities:" + illegalArgumentException); - } - catch(InvocationTargetException invocationTargetException ) { - if(DEBUG)System.err.println("#### JarEntry.getIdentities:" + invocationTargetException); - } - catch(NoSuchMethodException noSuchMethodException) { - if(DEBUG)System.err.println("#### JarEntry.getIdentities:" + noSuchMethodException); - } - catch(SecurityException securityException) { - if(DEBUG)System.err.println("#### JarEntry.getIdentities:" + securityException); - } - } - return identities; - } - - public String getName() { - return zipEntry.getName(); - } - - public long getSize() { - return zipEntry.getSize(); - } -} - diff --git a/sandbox/com/sun/star/lib/sandbox/JarInputStream.java b/sandbox/com/sun/star/lib/sandbox/JarInputStream.java deleted file mode 100644 index e7d78fa7a6..0000000000 --- a/sandbox/com/sun/star/lib/sandbox/JarInputStream.java +++ /dev/null @@ -1,107 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: JarInputStream.java,v $ - * $Revision: 1.4 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -package com.sun.star.lib.sandbox; - -import java.io.InputStream; -import java.io.IOException; - -import java.util.Hashtable; - -import java.util.zip.ZipEntry; -import java.util.zip.ZipInputStream; - - -class JarInputStream { -// JarVerifierStream jvs = null; - ZipInputStream jvs = null; - - ZipEntry ent = null; - - // mapping of names to objects that have been loaded from the jar - Hashtable nameToObject = new Hashtable(); - - public JarInputStream(InputStream inputStream) throws IOException { -// try { - jvs = new ZipInputStream(inputStream); -// jvs = new JarVerifierStream(inputStream); -// } -// catch(JarException e) { -// throw new IOException("JarInputStream"); -// } - } - - - public int available() throws IOException { - return jvs.available(); - } - - - public JarEntry getNextJarEntry() throws IOException { - ent = jvs.getNextEntry(); - -// if(ent != null && isManifest(ent.getName())) -// ent = jvs.getNextEntry(); - - return (ent != null) ? new JarEntry(ent, null/*jvs*/) : null; - } - - public int read(byte bytes[]) throws IOException { - return jvs.read(bytes,0, bytes.length); - } - - public void close() throws IOException { - jvs.close(); - } - - - static boolean isManifest(String name) { - boolean isManifest = false; - - name = name.toUpperCase(); - - /* ignore leading slash */ - if (name.startsWith("/")) - name = name.substring(1); - - /* a manifest file or signature file at all? */ - if (name.startsWith("META-INF/")) { - /* the manifest? */ - isManifest = name.equalsIgnoreCase("META-INF/MANIFEST.MF"); - isManifest = isManifest || name.endsWith("DSA"); - isManifest = isManifest || name.endsWith("PK7"); - isManifest = isManifest || name.endsWith("PGP"); - isManifest = isManifest || name.endsWith("SF"); - } - - return isManifest; - } -} - diff --git a/sandbox/com/sun/star/lib/sandbox/Permission.java b/sandbox/com/sun/star/lib/sandbox/Permission.java deleted file mode 100644 index a9b05e2811..0000000000 --- a/sandbox/com/sun/star/lib/sandbox/Permission.java +++ /dev/null @@ -1,36 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: Permission.java,v $ - * $Revision: 1.3 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -package com.sun.star.lib.sandbox; - -interface Permission { - boolean implies(Permission permission); -} - diff --git a/sandbox/com/sun/star/lib/sandbox/PermissionCollection.java b/sandbox/com/sun/star/lib/sandbox/PermissionCollection.java deleted file mode 100644 index 71b542d6fa..0000000000 --- a/sandbox/com/sun/star/lib/sandbox/PermissionCollection.java +++ /dev/null @@ -1,86 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: PermissionCollection.java,v $ - * $Revision: 1.3 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -package com.sun.star.lib.sandbox; - -import java.util.Vector; - -public final class PermissionCollection { - private Vector permissions = new Vector(); - - public PermissionCollection() { - SecurityManager security = System.getSecurityManager(); - if(security != null) security.checkSecurityAccess("PermissionCollection"); - } - - public PermissionCollection(PermissionCollection permissionCollection) { - SecurityManager security = System.getSecurityManager(); - if(security != null) security.checkSecurityAccess("PermissionCollection"); - - permissions = (Vector)permissionCollection.permissions.clone(); - } - -// public PermissionCollection(PermissionCollection p1, PermissionCollection p2) { -// SecurityManager security = System.getSecurityManager(); -// if(security != null) security.checkSecurityAccess("PermissionCollection"); - -// if(p1 != null) -// this.permissions = (Vector)p1.permissions.clone(); - -// if(p2 != null) -// for(int i = 0; i < p2.permissions.size(); i ++) -// this.permissions.addElement(p2.permissions.elementAt(i)); -// } - - public void reset() { - SecurityManager security = System.getSecurityManager(); - if(security != null) security.checkSecurityAccess("PermissionCollection"); - - permissions.removeAllElements(); - } - - public void add(Permission permission) { - SecurityManager security = System.getSecurityManager(); - if(security != null) security.checkSecurityAccess("PermissionCollection"); - - permissions.addElement(permission); - } - - public boolean implies(Permission permission) { - boolean granted = false; - - for(int i = 0; i < permissions.size() && !granted; i++) { - granted = ((Permission)permissions.elementAt(i)).implies(permission); - } - - return granted; - } -} - diff --git a/sandbox/com/sun/star/lib/sandbox/ProtectionDomain.java b/sandbox/com/sun/star/lib/sandbox/ProtectionDomain.java deleted file mode 100644 index d5b6dd036e..0000000000 --- a/sandbox/com/sun/star/lib/sandbox/ProtectionDomain.java +++ /dev/null @@ -1,87 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: ProtectionDomain.java,v $ - * $Revision: 1.3 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -package com.sun.star.lib.sandbox; - -import java.security.Identity; - -import sun.security.provider.SystemIdentity; -import sun.security.provider.SystemSigner; - -public final class ProtectionDomain { - private PermissionCollection permissionCollection; - private CodeSource codeSource; - - public ProtectionDomain(CodeSource codeSource, PermissionCollection permissionCollection) { -// this.permissionCollection = new PermissionCollection(codeSource.getPermissionCollection(), permissionCollection); - SecurityManager security = System.getSecurityManager(); - if(security != null) security.checkSecurityAccess("ProtectionDomain"); - - this.permissionCollection = permissionCollection; - this.codeSource = codeSource; - } - - public PermissionCollection getPermissions() { - SecurityManager security = System.getSecurityManager(); - if(security != null) security.checkSecurityAccess("ProtectionDomain"); - - return permissionCollection; - } - - boolean isTrusted() { - Identity identities[] = codeSource.identities; - - boolean trusted = false; - - if(identities != null) { - for(int i = 0; i < identities.length && !trusted; i++) - System.out.println("XXX:" + identities[i].toString(true)); - - for(int i = 0; i < identities.length; i ++) { - if(identities[i] instanceof SystemIdentity) { - SystemIdentity systemIdentity = (SystemIdentity)identities[i]; - - trusted = systemIdentity.isTrusted(); - } - else if(identities[i] instanceof SystemSigner) { - SystemSigner systemSigner = (SystemSigner)identities[i]; - - trusted = systemSigner.isTrusted(); - } - } - } - return trusted; - } - - boolean implies(Permission permission) { - return isTrusted() || permissionCollection.implies(permission); - } -} - diff --git a/sandbox/com/sun/star/lib/sandbox/Resource.java b/sandbox/com/sun/star/lib/sandbox/Resource.java deleted file mode 100644 index 3228f2b2e3..0000000000 --- a/sandbox/com/sun/star/lib/sandbox/Resource.java +++ /dev/null @@ -1,52 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: Resource.java,v $ - * $Revision: 1.4 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -package com.sun.star.lib.sandbox; - -import java.applet.AudioClip; - -import java.awt.image.ImageProducer; - -import java.io.InputStream; -import java.io.IOException; - -import java.net.URL; - -public interface Resource { - public ProtectionDomain getProtectionDomain(); - public URL getURL(); - public InputStream getInputStream() throws IOException; - public byte[] getBytes() throws IOException; - public ImageProducer getImageProducer(); - public AudioClip getAudioClip(); - public Object getContent() throws IOException; - public void loadJar(URL baseURL) throws IOException; -} - diff --git a/sandbox/com/sun/star/lib/sandbox/ResourceImpl.java b/sandbox/com/sun/star/lib/sandbox/ResourceImpl.java deleted file mode 100644 index 10a53a7296..0000000000 --- a/sandbox/com/sun/star/lib/sandbox/ResourceImpl.java +++ /dev/null @@ -1,317 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: ResourceImpl.java,v $ - * $Revision: 1.5 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -package com.sun.star.lib.sandbox; - -import java.applet.AudioClip; - -import java.awt.image.ImageProducer; - -import java.io.InputStream; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; - -import java.net.URL; -import java.net.URLConnection; -import java.net.MalformedURLException; - -import java.util.Enumeration; -import java.util.Vector; -import java.security.AccessController; -import java.security.PrivilegedAction; - -import sun.awt.image.ByteArrayImageSource; -import sun.awt.image.URLImageSource; - -import sun.applet.AppletAudioClip; - -class ResourceImpl implements Resource { - private static int instances; - private static final boolean DEBUG = false; - - private Object object; - private byte bytes[]; - private URL url; - private String type; - private ProtectionDomain protectionDomain; - - public ResourceImpl(URL url, byte bytes[], ProtectionDomain protectionDomain) { - if(DEBUG)System.err.println("#### ResourceImpl.<init>:" + url + " " + bytes + " " + protectionDomain); - - instances ++; - - this.protectionDomain = protectionDomain; - this.url = url; - this.bytes = bytes; - } - - public void finalize() { - instances --; - } - - public ProtectionDomain getProtectionDomain() { - return protectionDomain; - } - - public URL getURL() { - return url; - } - - public synchronized InputStream getInputStream() throws IOException { - if(DEBUG) System.err.print("#### ResourceImpl.getInputStream:" + url); - InputStream inputStream = null; - - if(bytes == null) { - if(DEBUG)System.err.println(" - from url"); - URLConnection c = url.openConnection(); - c.setAllowUserInteraction(false); - inputStream = c.getInputStream(); - } - else { - if(DEBUG)System.err.println(" - from bytes"); - inputStream = new ByteArrayInputStream(bytes); - } - - return inputStream; - } - - public synchronized byte[] getBytes() throws IOException { - final int chunkSize = 4096; - - if(bytes == null) { - InputStream inputStream = getInputStream(); - - int read = 0; - int total = 0; - Vector chunks = new Vector(); - - byte chunk[] = new byte[chunkSize]; - read = inputStream.read(chunk, 0, chunkSize); - while(read != -1) { // until end of file - if(read < chunkSize) { - byte tmpChunk[] = new byte[read]; - System.arraycopy(chunk, 0, tmpChunk, 0, tmpChunk.length); - chunk = tmpChunk; - } - - chunks.addElement(chunk); - chunk = new byte[chunkSize]; - total += read; - - read = inputStream.read(chunk, 0, chunkSize); - } - - inputStream.close(); - - byte tmpBytes[] = new byte[total]; - int index = 0; - for(int i = 0; i < chunks.size(); i++) { - chunk = (byte [])chunks.elementAt(i); - - System.arraycopy(chunk, 0, tmpBytes, index, chunk.length); - index += chunk.length; - } - - bytes = tmpBytes; - } - return bytes; - } - - public synchronized ImageProducer getImageProducer() { - if(DEBUG) System.err.println("#### Resource.getImageProducer:"); - - ImageProducer imageProducer = null; - - if(object != null) - imageProducer = (ImageProducer)object; - else { - // we use a PrivilegedAction here because otherwise the system classloader - // will call our SecurityManager's checkPackageAccess method which will - // refuse to access sun.* packages and hence ByteArrayInputStream and - // URLImageSource - imageProducer= (ImageProducer) - AccessController.doPrivileged( new PrivilegedAction() { - public Object run() { - if(bytes != null) - return new ByteArrayImageSource(bytes, 0, bytes.length); - else - return new URLImageSource(url); - }}); - object = imageProducer; - } - - return imageProducer; - } - - public synchronized AudioClip getAudioClip() { - AudioClip audioClip = null; - - if(object != null) - audioClip = (AudioClip)object; - else { - // we use a PrivilegedAction here because otherwise the system classloader - // will call our SecurityManager's checkPackageAccess method which will - // refuse to access sun.* packages and hence AppletAudioClip - audioClip= (AppletAudioClip) - AccessController.doPrivileged( new PrivilegedAction() { - public Object run() { - if(bytes != null) - return new AppletAudioClip(bytes); - else - return new AppletAudioClip(url); - } - }); - object = audioClip; - } - - return audioClip; - } - - public synchronized void loadJar(URL baseURL) throws IOException { - if(object == null) { - Vector jarResourceProxys = new Vector(); - JarInputStream jar = null; - byte[] rbuf = new byte[4096]; - - try { - jar = new JarInputStream(getInputStream()); - - JarEntry jarEntry = jar.getNextJarEntry(); - while(jarEntry != null) { - String extension = null; - String fileName = jarEntry.getName(); - int extensionIndex = fileName.lastIndexOf('.'); - - if(extensionIndex != -1) { - extension = jarEntry.getName().substring(extensionIndex); - fileName = fileName.substring(0, extensionIndex); - } - // System.out.println("AEC entry:" + fileName + " " + extension); - fileName = fileName.replace('.', '/'); - - if(extension != null) - fileName += extension; - - - // Workaround: available funktioniert nicht!!! - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - - int nread; - while((nread = jar.read(rbuf)) > 0) - baos.write(rbuf, 0, nread); - - byte bytes[] = baos.toByteArray(); //new byte[jar.available()]; - // jar.read(bytes); - - ProtectionDomain tmpProtectionDomain = null; - - if(protectionDomain != null) { - PermissionCollection permissionCollection = protectionDomain.getPermissions(); - CodeSource codeSource = new CodeSource(baseURL, jarEntry.getIdentities()); - tmpProtectionDomain = new ProtectionDomain(codeSource, permissionCollection); - } - - jarResourceProxys.addElement(ResourceProxy.create(new URL(baseURL, fileName), bytes, tmpProtectionDomain)); - jarResourceProxys.addElement(ResourceProxy.create(new URL(baseURL + "/" + fileName), bytes, tmpProtectionDomain)); - - jarEntry = jar.getNextJarEntry(); - } - } - finally { - if(jar != null) - jar.close(); - } - - object = jarResourceProxys; - } - } - - private void guessType() { - /* Parse entries which have special names, like the - manifest. We invent "mime types" local to this class */ -// if (type == null) { -// type = guessManifestType(name); -// } - - if (type == null) { - /* REMIND Get this from MANIFEST.MF. This should - be changed as soon as manifest support is - fixed. Because jvs must support mark, and it - isn't always obvious since it's a - FilterInputStream and whatever it used to - build it is what would give it mark. */ - try { - InputStream tmpStream = new ByteArrayInputStream(getBytes()); - type = URLConnection.guessContentTypeFromStream(tmpStream); - } - catch(IOException iOException) { - if(DEBUG) System.err.println("#### Resource.guessType - exception:" + iOException); - } - } - - if (type == null) { - // REMIND - this canbe cleaned up if we don't mind - // exporting access to MANIFEST data. - epll - type = "input-stream/input-stream"; - } - - if(DEBUG) System.err.println("#### Resource.guessType - guessed:" + type); - } - - - public Object getContent() throws IOException { - Object content = null; - - guessType(); - - if (type.startsWith("image")) { - content = getImageProducer(); - } - else if (type.startsWith("audio")) { - content = getAudioClip(); - } - else if (type.startsWith("application/java-vm") || type.startsWith("application/x-java-vm")) { - - } - else if (type.equals("manifest/manifest") || type.equals("manifest/signature-bin")) { - /* We know what it is. It is handled by JarVerifierStream */ - - } - else { - content = getInputStream(); - } - - if(DEBUG) System.err.println("#### Resource.getContent:" + content); - - return content; - } -} - diff --git a/sandbox/com/sun/star/lib/sandbox/ResourceProxy.java b/sandbox/com/sun/star/lib/sandbox/ResourceProxy.java deleted file mode 100644 index 1834590088..0000000000 --- a/sandbox/com/sun/star/lib/sandbox/ResourceProxy.java +++ /dev/null @@ -1,217 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: ResourceProxy.java,v $ - * $Revision: 1.6 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -package com.sun.star.lib.sandbox; - -import java.applet.AudioClip; - -import java.awt.image.ImageProducer; - -import java.io.InputStream; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; - -import java.net.URL; -import java.net.URLConnection; -import java.net.MalformedURLException; - -import java.util.Enumeration; -import java.util.Vector; - -public class ResourceProxy implements Resource, Cachable { - private static final boolean DEBUG = false; - private static int instances; - - static boolean isResource(URL url) { - boolean exists = false; - - ResourceProxy resourceProxy = (ResourceProxy)WeakTable.get(url); - exists = resourceProxy != null; - - if(!exists) { // not cache - // Check if the resource exists. - // It almost works to just try to do an openConnection() but - // HttpURLConnection will return true on HTTP_BAD_REQUEST - // when the requested name ends in ".html", ".htm", and ".txt" - // and we want to be able to handle these - // - // Also, cannot just open a connection for things like FileURLConnection, - // because they suceed when connecting to a non-existant file. - // So, in those cases we open and close an input stream. - - - try { - URLConnection conn = url.openConnection(); - if (conn instanceof java.net.HttpURLConnection) { - java.net.HttpURLConnection hconn = (java.net.HttpURLConnection) conn; - int code = hconn.getResponseCode(); - - exists = (code == java.net.HttpURLConnection.HTTP_OK) || (code < java.net.HttpURLConnection.HTTP_BAD_REQUEST); - } - else { - // our best guess for the other cases - InputStream is = url.openStream(); - is.close(); - exists = true; - } - } - catch (Exception ex) { - } - } - - return exists; - } - - static public ResourceProxy load(URL url, ProtectionDomain protectionDomain) { - if(DEBUG) System.err.println("#### ResourceProxy.loadResource:" + url); - -// protectionDomain = (protectionDomain == null) -// ? new ProtectionDomain(new CodeSource(url), new PermissionCollection()) -// : protectionDomain; - - ResourceProxy resourceProxy = (ResourceProxy)WeakTable.get(url); - - if(resourceProxy == null) { - resourceProxy = new ResourceProxy(url, null, protectionDomain); - WeakTable.put(url, resourceProxy); - } - - return resourceProxy; - } - - static public ResourceProxy create(URL url, byte bytes[], ProtectionDomain protectionDomain) { - ResourceProxy resourceProxy = (ResourceProxy)WeakTable.get(url); - - if(resourceProxy == null) { - resourceProxy = new ResourceProxy(url, bytes, protectionDomain); - WeakTable.put(url, resourceProxy); - } - else - System.err.println("WARNING! ResourceProxy.create - resource already loaded:" + resourceProxy); - - return resourceProxy; - } - - /* - ** Members - */ - private Resource resource; - private WeakRef weakRef; - - /* - ** interface cachable methods - */ - public ResourceProxy() { - instances ++; - } - - public Object getHardObject() { - return resource; - } - - public void setWeakRef(WeakRef weakRef) { - this.resource = (Resource)weakRef.getRef(); - this.weakRef = weakRef; - - weakRef.incRefCnt(); - } - - public void finalize(){ - weakRef.decRefCnt(); - instances --; - } - - /* - ** resource methods - */ - private ResourceProxy(URL url, byte bytes[], ProtectionDomain protectionDomain) { - this(); - resource = new ResourceImpl(url, bytes, protectionDomain); - } - - public ProtectionDomain getProtectionDomain() { - return resource.getProtectionDomain(); - } - - public synchronized URL getURL() { - return resource.getURL(); - } - - public synchronized InputStream getInputStream() throws IOException { - return resource.getInputStream(); - } - - public synchronized byte[] getBytes() throws IOException { - return resource.getBytes(); - } - - public synchronized ImageProducer getImageProducer() { - ImageProducer imageProducer = resource.getImageProducer(); - - - // This is due to a stupid bug in ImageConsumerQueue, - // which seems to be introduced in jdk1.3, which - // forbids me to use my own ImageProducer implementation. -// imageProducer = new ImageProducerProxy(imageProducer); - -// Holder holder = (Holder)imageProducer; -// holder.addCargo(this); - - return imageProducer; - } - - public synchronized AudioClip getAudioClip() { - AudioClip audioClip = resource.getAudioClip(); - - audioClip = new AudioProxy(audioClip); - - if(audioClip instanceof Holder) { - Holder holder = (Holder)audioClip; - holder.addCargo(this); - } - - return audioClip; - } - - public Object getContent() throws IOException { - Object content = resource.getContent(); - - if(content instanceof Holder) - ((Holder)content).addCargo(this); - - return content; - } - - public void loadJar(URL url) throws IOException { - resource.loadJar(url); - } -} - diff --git a/sandbox/com/sun/star/lib/sandbox/ResourceViewer.java b/sandbox/com/sun/star/lib/sandbox/ResourceViewer.java deleted file mode 100644 index 0df5ba8620..0000000000 --- a/sandbox/com/sun/star/lib/sandbox/ResourceViewer.java +++ /dev/null @@ -1,101 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: ResourceViewer.java,v $ - * $Revision: 1.3 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -package com.sun.star.lib.sandbox; - -import java.applet.Applet; - -import java.awt.BorderLayout; -import java.awt.Button; -import java.awt.Frame; -import java.awt.Graphics; -import java.awt.List; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import java.util.Enumeration; - -import java.util.Observable; -import java.util.Observer; - -public class ResourceViewer extends Frame implements Observer { - List list; - boolean refill; - - public ResourceViewer() { - super("ResourceViewer"); - list = new List(); - - setLayout(new BorderLayout()); - add("Center", list); - - Button clearCashButton = new Button("clear the cache"); - clearCashButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent actionEvent) { - WeakTable.clear(); - } - }); - add("South", clearCashButton); - - setSize(500, 200); - - refill = true; - - WeakTable.AddObserver(this); - - setVisible(true); - } - - void refresh() { - list.removeAll(); - - Enumeration elements = WeakTable.elements(); - while(elements.hasMoreElements()) { - WeakRef weakRef = ((WeakEntry)elements.nextElement()).weakRef; - list.add(weakRef.getRefCount() + " " + weakRef.getKey().toString()); - } - } - - public void update(Observable observable, Object arg) { - refill = true; - repaint(500); - } - - public void paint(Graphics g) { - if(refill) { - refill = false; - refresh(); - - } - super.paint(g); - } -} - diff --git a/sandbox/com/sun/star/lib/sandbox/SandboxMessageHandler.java b/sandbox/com/sun/star/lib/sandbox/SandboxMessageHandler.java deleted file mode 100644 index 846aa1560a..0000000000 --- a/sandbox/com/sun/star/lib/sandbox/SandboxMessageHandler.java +++ /dev/null @@ -1,119 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: SandboxMessageHandler.java,v $ - * $Revision: 1.3 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -package com.sun.star.lib.sandbox; - -import java.util.ResourceBundle; -import java.util.MissingResourceException; -import java.text.MessageFormat; - -/** - * An hanlder of localized messages. - * - * @version 1.8, 03/03/97 - * @author Koji Uno - */ -class SandboxMessageHandler { - private static ResourceBundle rb; - private String baseKey = null; - - static { - try { - rb = ResourceBundle.getBundle("stardiv.security.resources.MsgAppletViewer"); - } catch (MissingResourceException e) - { - System.out.println(e.getMessage()); - } - }; - - SandboxMessageHandler(String baseKey) { - this.baseKey = baseKey; - } - - String getMessage(String key) { - return (String)rb.getString(getQualifiedKey(key)); - } - - String getMessage(String key, Object arg){ - String basemsgfmt = (String)rb.getString(getQualifiedKey(key)); - MessageFormat msgfmt = new MessageFormat(basemsgfmt); - Object msgobj[] = new Object[1]; - if (arg == null) { - arg = "null"; // mimic java.io.PrintStream.print(String) - } - msgobj[0] = arg; - return msgfmt.format(msgobj); - } - - String getMessage(String key, Object arg1, Object arg2) { - String basemsgfmt = (String)rb.getString(getQualifiedKey(key)); - MessageFormat msgfmt = new MessageFormat(basemsgfmt); - Object msgobj[] = new Object[2]; - if (arg1 == null) { - arg1 = "null"; - } - if (arg2 == null) { - arg2 = "null"; - } - msgobj[0] = arg1; - msgobj[1] = arg2; - return msgfmt.format(msgobj); - } - - String getMessage(String key, Object arg1, Object arg2, Object arg3) { - String basemsgfmt = (String)rb.getString(getQualifiedKey(key)); - MessageFormat msgfmt = new MessageFormat(basemsgfmt); - Object msgobj[] = new Object[3]; - if (arg1 == null) { - arg1 = "null"; - } - if (arg2 == null) { - arg2 = "null"; - } - if (arg3 == null) { - arg3 = "null"; - } - msgobj[0] = arg1; - msgobj[1] = arg2; - msgobj[2] = arg3; - return msgfmt.format(msgobj); - } - - String getMessage(String key, Object arg[]) { - String basemsgfmt = (String)rb.getString(getQualifiedKey(key)); - MessageFormat msgfmt = new MessageFormat(basemsgfmt); - return msgfmt.format(arg); - } - - String getQualifiedKey(String subKey) { - return baseKey + "." + subKey; - } -} - diff --git a/sandbox/com/sun/star/lib/sandbox/SandboxSecurity.java b/sandbox/com/sun/star/lib/sandbox/SandboxSecurity.java deleted file mode 100644 index b05de12fa1..0000000000 --- a/sandbox/com/sun/star/lib/sandbox/SandboxSecurity.java +++ /dev/null @@ -1,1160 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: SandboxSecurity.java,v $ - * $Revision: 1.7 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -package com.sun.star.lib.sandbox; - -import java.io.File; -import java.io.IOException; -import java.io.FileDescriptor; -import java.net.URL; -import java.net.InetAddress; -import java.net.UnknownHostException; -import java.util.StringTokenizer; -import java.util.Vector; -import java.util.Hashtable; -import java.security.*; -import sun.security.provider.*; - -/** - * This class defines an applet security policy - * - * @version 1.68, 01/27/97 - */ -public class SandboxSecurity extends SecurityManager //implements SecurityManagerExtension -{ - - private static boolean debug = false; - - public final static int NETWORK_NONE = 1; - public final static int NETWORK_HOST = 2; - public final static int NETWORK_UNRESTRICTED = 3; - - private final static int PRIVELEGED_PORT = 1024; - - boolean bNoExit; - boolean initACL; - String readACL[]; - String writeACL[]; - int networkMode; - boolean bCheckSecurity; - RecursionCounter InCheck = new RecursionCounter(); - RecursionCounter InIsSecureLoader = new RecursionCounter(); - RecursionCounter InInClassLoader = new RecursionCounter(); - RecursionCounter InClassLoaderDepth = new RecursionCounter(); - java.security.AllPermission allPerm = new java.security.AllPermission(); - - // where we look for identities - IdentityScope scope; - // local cache for network-loaded classes - Hashtable loadedClasses; - - public int getNetworkMode(){ return networkMode; } - - /** - * Construct and initialize. - */ - public SandboxSecurity() { - reset(); - } - - /** - * Construct and initialize. - */ - public SandboxSecurity( boolean bNoExit_ ) { - reset(); - bNoExit = bNoExit_; - } - - /** - * Reset from Properties - */ - public void reset() { - String str = System.getProperty("appletviewer.security.mode"); -// System.err.println("#### SandboxSecurity.reset:" + str); - if( str == null ) - networkMode = NETWORK_HOST; - else if( str.equals("unrestricted") ) - networkMode = NETWORK_UNRESTRICTED; - else if( str.equals("none") ) - networkMode = NETWORK_NONE; - else - networkMode = NETWORK_HOST; - - bCheckSecurity = !Boolean.getBoolean( "stardiv.security.disableSecurity" ); - // see if security is disabled -// String prop = System.getProperty("Security", "1" ); -// bCheckSecurity = true; -// if(prop.equals("0")) -// bCheckSecurity = false; - - // see if the system scope is one we know. - IdentityScope scope = IdentityScope.getSystemScope(); - - if (scope instanceof IdentityDatabase) { - this.scope = (IdentityDatabase)scope; - debug("installing " + scope + " as the scope for signers."); - } else { - debug("no signer scope found."); - } - loadedClasses = new Hashtable(); - } - -// /** -// * True if called directly from an applet. -// */ -// boolean fromApplet() { -// return classLoaderDepth() == 1; -// } - -// /** -// * This method takes a set of signers and returns true if -// * this set of signers implies that a class is trusted. -// * In this implementation, it returns true if any of the -// * signers is a SystemIdentity which is trusted. -// */ -// protected boolean assessTrust(Object[] signers) { -// /* Remind: do we want to actually look into the scope here? */ - -// for (int i = 0; i < signers.length; i++) { - -// if (signers[i] instanceof SystemIdentity) { -// SystemIdentity sysid = (SystemIdentity)signers[i]; -// if (sysid.isTrusted()) { -// return true; -// } - -// } else if (signers[i] instanceof SystemSigner) { -// SystemSigner sysid = (SystemSigner)signers[i]; -// if (sysid.isTrusted()) { -// return true; -// } -// } -// } - -// return false; -// } - -// /** -// * True if called indirectly from an <it>untrusted</it> applet. -// */ - synchronized boolean inApplet() { - boolean ret = false; - try { - InCheck.acquire(); - ret = inClassLoader(); - } finally { - InCheck.release(); - } - return ret; - } - - /** - * The only variable that currently affects whether an applet can - * perform certain operations is the host it came from. - */ - public synchronized Object getSecurityContext() { - Object ret = null; - try { - InCheck.acquire(); - ClassLoader loader = currentClassLoader(); - - if (loader != null) { - if (loader instanceof ClassContextImpl) { - ClassContext appletLoader = (ClassContextImpl)loader; - ret = appletLoader.getBase(); - } else { - throw(new SandboxSecurityException("getsecuritycontext.unknown")); - } - } - } - finally { - InCheck.release(); - } - return ret; - } - - /** - * Applets are not allowed to create class loaders, or even execute any - * of ClassLoader's methods. The name of this method should be changed to - * checkClassLoaderOperation or somesuch. - */ - public synchronized void checkCreateClassLoader() { - try { - InCheck.acquire(); - if( bCheckSecurity && !isSecureLoader() ) { - if (classLoaderDepth() == 2) - throw(new SandboxSecurityException("checkcreateclassloader")); - } - } finally { - InCheck.release(); - } - } - - /** - * Returns true if this threadgroup is in the applet's own thread - * group. This will return false if there is no current class - * loader. - */ - protected synchronized boolean inThreadGroup(ThreadGroup g) { - boolean ret = false; - try { - InCheck.acquire(); - ClassLoader loader = currentClassLoader(); - - /* If this class wasn't loaded by an AppletClassLoader, we have - not eay of telling, for now. */ - - if (loader instanceof ClassContextImpl) { - ClassContext appletLoader = (ClassContextImpl)loader; - ThreadGroup appletGroup = appletLoader.getThreadGroup(); - ret = appletGroup.parentOf(g); - } - } finally { - InCheck.release(); - } - return ret; - } - - /** - * Returns true of the threadgroup of thread is in the applet's - * own threadgroup. - */ - protected synchronized boolean inThreadGroup(Thread thread) { - boolean ret = false; - try { - InCheck.acquire(); - ret = inThreadGroup(thread.getThreadGroup()); - } - finally { - InCheck.release(); - } - return ret; - } - - /** - * Applets are not allowed to manipulate threads outside - * applet thread groups. - */ - public synchronized void checkAccess(Thread t) { - try { - InCheck.acquire(); - if( bCheckSecurity && !isSecureLoader() ) { - if (classLoaderDepth()==3 && (! inThreadGroup(t))) { - throw(new SandboxSecurityException("checkaccess.thread")); - } - } - } finally { - InCheck.release(); - } - } - - /** - * Applets are not allowed to manipulate thread groups outside - * applet thread groups. - */ - public synchronized void checkAccess(ThreadGroup g) { - try { - InCheck.acquire(); - if( bCheckSecurity && !isSecureLoader() ) { - if (classLoaderDepth() == 4 && (! inThreadGroup(g))) { - throw(new SandboxSecurityException("checkaccess.threadgroup", g.toString())); - } - } - } finally { - InCheck.release(); - } - - } - - /** - * Applets are not allowed to exit the VM. - */ - public synchronized void checkExit(int status) { - try { - InCheck.acquire(); - if( bNoExit ) { - throw(new SandboxSecurityException("checkexit", String.valueOf(status))); - } - if( bCheckSecurity && !isSecureLoader() ) { - if( inApplet() ) { - throw(new SandboxSecurityException("checkexit", String.valueOf(status))); - } - } - } finally { - InCheck.release(); - } - } - - /** - * Applets are not allowed to fork processes. - */ - public synchronized void checkExec(String cmd) { - try { - InCheck.acquire(); - if( bCheckSecurity && !isSecureLoader()) { - if (inApplet()) { - throw(new SandboxSecurityException("checkexec", cmd)); - } - } - } finally { - InCheck.release(); - } - } - - /** - * Applets are not allowed to link dynamic libraries. - */ - public synchronized void checkLink(String lib) { - try { - InCheck.acquire(); - if( bCheckSecurity && !isSecureLoader() ) { - switch (classLoaderDepth()) { - case 2: // Runtime.load - case 3: // System.loadLibrary - throw(new SandboxSecurityException("checklink", lib)); - default: - break; - } - } - } finally { - InCheck.release(); - } - } - - /** - * Applets are not allowed to access the entire system properties - * list, only properties explicitly labeled as accessible to applets. - */ - public synchronized void checkPropertiesAccess() { - try { - InCheck.acquire(); - if( bCheckSecurity && !isSecureLoader() ) { - if (classLoaderDepth() == 2) { - throw(new SandboxSecurityException("checkpropsaccess")); - } - } - } finally { - InCheck.release(); - } - } - - /** - * Applets can access the system property named by <i>key</i> - * only if its twin <i>key.applet</i> property is set to true. - * For example, the property <code>java.home</code> can be read by - * applets only if <code>java.home.applet</code> is <code>true</code>. - */ - public synchronized void checkPropertyAccess(String key) { - try { - InCheck.acquire(); - if( bCheckSecurity && !isSecureLoader() ) { - if (classLoaderDepth() == 2) { - String prop = System.getProperty(key + ".applet"); - boolean allow = new Boolean(prop).booleanValue(); - if ( !allow ) { - throw(new SandboxSecurityException("checkpropsaccess.key", prop)); - } - } - } - } finally { - InCheck.release(); - } - } - - /** - * Parse an ACL. Deals with "~" and "+" - */ - void parseACL(Vector v, String path, String defaultPath) { - String sep = System.getProperty("path.separator"); - StringTokenizer t = new StringTokenizer(path, sep); - - while (t.hasMoreTokens()) { - String dir = t.nextToken(); - if (dir.startsWith("~")) { - v.addElement(System.getProperty("user.home") + - dir.substring(1)); - } else if (dir.equals("+")) { - if (defaultPath != null) { - parseACL(v, defaultPath, null); - } - } else { - v.addElement(dir); - } - } - } - - /** - * Parse an ACL. - */ - String[] parseACL(String path, String defaultPath) { - if (path == null) { - return new String[0]; - } - if (path.equals("*")) { - return null; - } - Vector v = new Vector(); - parseACL(v, path, defaultPath); - - String acl[] = new String[v.size()]; - v.copyInto(acl); - return acl; - } - - /** - * Initialize ACLs. Called only once. - */ - void initializeACLs() { - readACL = parseACL(System.getProperty("acl.read"), - System.getProperty("acl.read.default")); - writeACL = parseACL(System.getProperty("acl.write"), - System.getProperty("acl.write.default")); - initACL = true; - } - - /** - * Check if an applet can read a particular file. - */ - public synchronized void checkRead(String file) { - try { - InCheck.acquire(); - if( bCheckSecurity && !isSecureLoader() ) { - ClassLoader loader = currentClassLoader(); - - /* If no class loader, it's a system class. */ - if (loader != null) - { - /* If not an AppletClassLoader, we don't know what to do */ - if (! (loader instanceof ClassContextImpl)) - throw(new SandboxSecurityException("checkread.unknown", file)); - ClassContext appletLoader = (ClassContextImpl)loader; - URL base = appletLoader.getBase(); - checkRead(file, base); - } - } - } finally { - InCheck.release(); - } - } - - public synchronized void checkRead(String file, URL base) { - try { - InCheck.acquire(); - if( bCheckSecurity && (base != null) && !isSecureLoader() ) { - if (!initACL) - initializeACLs(); - if (readACL == null) - { - InCheck.release(); - return; - } - - String realPath = null; - try { - realPath = (new File(file)).getCanonicalPath(); - } catch (IOException e) { - throw(new SandboxSecurityException("checkread.exception1", e.getMessage(), file)); - } - - for (int i = readACL.length ; i-- > 0 ;) { - if (realPath.startsWith(readACL[i])) - { - InCheck.release(); - return; - } - } - - // if the applet is loaded from a file URL, allow reading - // in that directory - if (base.getProtocol().equals("file")) { - String dir = null; - try { - // If the file url contains spaces (i.e. %20) then URL.getFile() still contains %20 - // File.getCanonicalPath does not replace %20 - // create a string with real spaces instead of %20 - StringBuffer buf= new StringBuffer(256); - String sSpace= "%20"; - String sFile= base.getFile(); - int begin= 0; - int end= 0; - while((end= sFile.indexOf(sSpace, begin)) != -1) { - buf.append( sFile.substring(begin, end)); - buf.append(" "); - begin= end + sSpace.length(); - } - buf.append(sFile.substring(begin)); - - String sWithSpaces= buf.toString(); - dir = (new File(sWithSpaces).getCanonicalPath()); - } catch (IOException e) { // shouldn't happen - throw(new SandboxSecurityException("checkread.exception2", e.toString())); - } - if (realPath.startsWith(dir)) - { - InCheck.release(); - return; - } - } - throw new SandboxSecurityException("checkread", file, realPath); - } - } finally { - InCheck.release(); - } - - } - /** - * Checks to see if the current context or the indicated context are - * both allowed to read the given file name. - * @param file the system dependent file name - * @param context the alternate execution context which must also - * be checked - * @exception SecurityException If the file is not found. - */ - public synchronized void checkRead(String file, Object context) { - try { - InCheck.acquire(); - checkRead(file); - if (context != null) - checkRead(file, (URL) context); - } finally { - InCheck.release(); - } - } - - /** - * Check if an applet can write a particular file. - */ - public synchronized void checkWrite(String file) { - try { - InCheck.acquire(); - if( bCheckSecurity && inApplet() && !isSecureLoader() ) { - if (!initACL) - initializeACLs(); - if (writeACL == null) - { - InCheck.release(); - return; - } - - String realPath = null; - try { - realPath = (new File(file)).getCanonicalPath(); - } catch (IOException e) { - throw(new SandboxSecurityException("checkwrite.exception", e.getMessage(), file)); - } - - for (int i = writeACL.length ; i-- > 0 ;) { - if (realPath.startsWith(writeACL[i])) - { - InCheck.release(); - return; - } - } - throw(new SandboxSecurityException("checkwrite", file, realPath)); - } - } finally { - InCheck.release(); - } - } - - /** - * Applets are not allowed to open file descriptors unless - * it is done through a socket, in which case other access - * restrictions still apply. - */ - public synchronized void checkRead(FileDescriptor fd) { - try { - InCheck.acquire(); - if( bCheckSecurity && !isSecureLoader() ) { - if( (inApplet() && !inClass("java.net.SocketInputStream") ) || (!fd.valid()) ) - throw(new SandboxSecurityException("checkread.fd")); - } - } finally { - InCheck.release(); - } - } - - /** - * Applets are not allowed to open file descriptors unless - * it is done through a socket, in which case other access - * restrictions still apply. - */ - public synchronized void checkWrite(FileDescriptor fd) { - try { - InCheck.acquire(); - if( bCheckSecurity && !isSecureLoader() ) { - if( (inApplet() && !inClass("java.net.SocketOutputStream")) || (!fd.valid()) ) - throw(new SandboxSecurityException("checkwrite.fd")); - } - } finally { - InCheck.release(); - } - } - - /** - * Applets can only listen on unpriveleged ports > 1024 - * A port of 0 denotes an ephemeral system-assigned port - * Which will be outside this range. Note that java sockets - * take an int and ports are really a u_short, but range - * checking is done in ServerSocket & DatagramSocket, so the port policy - * cannot be subverted by ints that wrap around to an illegal u_short. - */ - public synchronized void checkListen(int port) { - try { - InCheck.acquire(); - if( bCheckSecurity && !isSecureLoader() ) { - if (inApplet() && port > 0 && port < PRIVELEGED_PORT) - throw(new SandboxSecurityException("checklisten", String.valueOf(port))); - } - } finally { - InCheck.release(); - } - } - - /** - * Applets can accept connectionions on unpriveleged ports, from - * any hosts they can also connect to (typically host-of-origin - * only, depending on the network security setting). - */ - public synchronized void checkAccept(String host, int port) { - try { - InCheck.acquire(); - if( bCheckSecurity && !isSecureLoader() ) { - if( inApplet() && port < PRIVELEGED_PORT ) - throw(new SandboxSecurityException("checkaccept", host, String.valueOf(port))); - checkConnect(host, port); - } - } finally { - InCheck.release(); - } - } - - /** - * Check if an applet can connect to the given host:port. - */ - public synchronized void checkConnect(String host, int port) { - try { - InCheck.acquire(); - if(bCheckSecurity && !isSecureLoader() ) { - ClassLoader loader = currentClassLoader(); - if (loader == null) - { - InCheck.release(); - return; // Not called from an applet, so it is ok - } - - // REMIND: This is only appropriate for our protocol handlers. - int depth = classDepth("sun.net.www.http.HttpClient"); - if (depth > 1) - { - InCheck.release(); - return; // Called through our http protocol handler - } - - if(getInCheck()) - { - InCheck.release(); - return; - } - - if (loader instanceof ClassContextImpl) { - ClassContext appletLoader = (ClassContextImpl)loader; - checkConnect(appletLoader.getBase().getHost(), host); - } else { - throw(new SandboxSecurityException("checkconnect.unknown")); - } - } - } finally { - InCheck.release(); - } - } - - /** - * Checks to see if the applet and the indicated execution context - * are both allowed to connect to the indicated host and port. - */ - public synchronized void checkConnect(String host, int port, Object context) { - try { - InCheck.acquire(); - checkConnect(host, port); - if (context != null) - checkConnect(((URL) context).getHost(), host); - } finally { - InCheck.release(); - } - } - - public synchronized void checkConnect(String fromHost, String toHost, boolean trustP) { - try { - InCheck.acquire(); - if( bCheckSecurity && !isSecureLoader() ) { - if (fromHost == null) - { - InCheck.release(); - return; - } - - switch (networkMode) { - case NETWORK_NONE: - throw(new SandboxSecurityException("checkconnect.networknone", fromHost, toHost)); - - case NETWORK_HOST: - /* - * The policy here is as follows: - * - * - if the strings match, and we know the IP address for it - * we allow the connection. The calling code downstream will - * substitute the IP in their request to the proxy if needed. - * - if the strings don't match, and we can get the IP of - * both hosts then - * - if the IPs match, we allow the connection - * - if they don't we throw(an exception - * - if the string match works and we don't know the IP address - * then we consult the trustProxy property, and if that is true, - * we allow the connection. - * set inCheck so InetAddress knows it doesn't have to - * check security. - */ - try { - inCheck = true; - InetAddress toHostAddr, fromHostAddr; - if (!fromHost.equals(toHost)) { - try { - // the only time we allow non-matching strings - // is when IPs and the IPs match. - toHostAddr = InetAddress.getByName(toHost); - fromHostAddr = InetAddress.getByName(fromHost); - - if( fromHostAddr.equals(toHostAddr) ) - { - InCheck.release(); - return; - } - else - { - throw(new SandboxSecurityException( - "checkconnect.networkhost1", toHost, fromHost)); - } - - } catch (UnknownHostException e) { - throw(new SecurityException("checkconnect.networkhost2" + toHost + fromHost)); -// throw(new SandboxSecurityException("checkconnect.networkhost2", toHost, fromHost)); - } - } else { - try { - toHostAddr = InetAddress.getByName(toHost); - InCheck.release(); - // strings match: if we have IP, we're homefree, - // otherwise we check the properties. - return; - // getBoolean really defaults to false. - } catch (UnknownHostException e) { - if( trustP ) - { - InCheck.release(); - return; - } - else - { - throw(new SandboxSecurityException( - "checkconnect.networkhost3", toHost)); - } - } - } - } finally { - inCheck = false; - } - - case NETWORK_UNRESTRICTED: - InCheck.release(); - return; - } - throw(new SandboxSecurityException("checkconnect", fromHost, toHost)); - } - } finally { - InCheck.release(); - } - } - - - - /** - * check if an applet from a host can connect to another - * host. This usually means that you need to determine whether - * the hosts are inside or outside the firewall. For now applets - * can only access the host they came from. - */ - public synchronized void checkConnect(String fromHost, String toHost) { - try { - InCheck.acquire(); - checkConnect(fromHost, toHost, Boolean.getBoolean("trustProxy")); - } finally { - InCheck.release(); - } - } - - /** - * Checks to see if top-level windows can be created by the caller. - */ - public synchronized boolean checkTopLevelWindow(Object window) { - boolean ret = true; - try { - InCheck.acquire(); - if( bCheckSecurity && inClassLoader() && !isSecureLoader() ) { - /* XXX: this used to return depth > 3. However, this lets */ - /* some applets create frames without warning strings. */ - ret = false; - } - } finally { - InCheck.release(); - } - return ret; - } - - /** - * Check if an applet can access a package. - */ - public synchronized void checkPackageAccess(String pkg) { - try { - InCheck.acquire(); - - if( bCheckSecurity && inClassLoader() && !isSecureLoader() ) { - if( pkg.equals( "stardiv.applet" ) - // Das AWT von StarDivision - || pkg.equals( "stardiv.look" ) - || pkg.equals( "netscape.javascript" ) ) - { - InCheck.release(); - return; - } - - final String forbidden[] = new String[]{ - "com.sun.star.uno", - "com.sun.star.lib.uno", - "com.sun.star.comp.connections", - "com.sun.star.comp.loader", - "com.sun.star.comp.servicemanager" - }; - - - for(int j = 0; j < forbidden.length; ++ j) { - if(pkg.startsWith(forbidden[j])) - throw(new SandboxSecurityException("checkpackageaccess2", pkg)); - } - - int i = pkg.indexOf('.'); - while (i > 0) { - String subpkg = pkg.substring(0,i); - if( Boolean.getBoolean("package.restrict.access." + subpkg) ) - throw(new SandboxSecurityException("checkpackageaccess", pkg)); - i = pkg.indexOf('.',i+1); - } - } - } finally { - InCheck.release(); - } - } - - /** - * Check if an applet can define classes in a package. - */ - public synchronized void checkPackageDefinition(String pkg) { - try { - InCheck.acquire(); - } finally { - InCheck.release(); - } - return; -/* - if (!inClassLoader()) - return; - int i = pkg.indexOf('.'); - - while (i > 0) { - String subpkg = pkg.substring(0,i); - if (Boolean.getBoolean("package.restrict.definition." + subpkg)) { - throw(new SandboxSecurityException("checkpackagedefinition", pkg); - } - i = pkg.indexOf('.',i+1); - } -*/ - } - - - /** - * Check if an applet can set a networking-related object factory. - */ - public synchronized void checkSetFactory() { - try { - InCheck.acquire(); - if( bCheckSecurity && inApplet() && !isSecureLoader() ) - throw(new SandboxSecurityException("cannotsetfactory")); - } finally { - InCheck.release(); - } - } - - /** - * Check if client is allowed to reflective access to a member or - * a set of members for the specified class. Once initial access - * is granted, the reflected members can be queried for - * identifying information, but can only be <strong>used</strong> - * (via get, set, invoke, or newInstance) with standard Java - * language access control. - * - * <p>The policy is to deny <em>untrusted</em> clients access to - * <em>declared</em> members of classes other than those loaded - * via the same class loader. All other accesses are granted. - * - * XXX: Should VerifyClassAccess here? Should Class.forName do it? - */ - public synchronized void checkMemberAccess(Class clazz, int which) { - try { - InCheck.acquire(); - - if( bCheckSecurity && !isSecureLoader() ) { - if( which != java.lang.reflect.Member.PUBLIC ) { - ClassLoader currentLoader = currentClassLoader(); - if( currentLoader != null && (classLoaderDepth() <= 3) ) - /* Client is an untrusted class loaded by currentLoader */ - if( currentLoader != clazz.getClassLoader() ) - throw(new SandboxSecurityException("checkmemberaccess")); - } - } - } finally { - InCheck.release(); - } - } - - /** - * Checks to see if an applet can initiate a print job request. - */ - public synchronized void checkPrintJobAccess() { - try { - InCheck.acquire(); - if( bCheckSecurity && inApplet() && !isSecureLoader() ) - throw(new SandboxSecurityException("checkgetprintjob")); - } finally { - InCheck.release(); - } - } - - /** - * Checks to see if an applet can get System Clipboard access. - */ - public synchronized void checkSystemClipboardAccess() { - try { - InCheck.acquire(); - - if( bCheckSecurity && inApplet() && !isSecureLoader() ) - throw(new SandboxSecurityException("checksystemclipboardaccess")); - } finally { - InCheck.release(); - } - } - - /** - * Checks to see if an applet can get EventQueue access. - */ - public synchronized void checkAwtEventQueueAccess() { - try { - InCheck.acquire(); - if( bCheckSecurity && inClassLoader() && !isSecureLoader() ) { -// throw(new SandboxSecurityException("checkawteventqueueaccess")); - } - } finally { - InCheck.release(); - } - } - - /** - * Checks to see if an applet can perform a given operation. - */ - public synchronized void checkSecurityAccess(String action) { - try { - InCheck.acquire(); - if( bCheckSecurity && inApplet() && !isSecureLoader() ) - throw(new SandboxSecurityException("checksecurityaccess", action)); - } finally { - InCheck.release(); - } - } - - /** - * Returns the thread group of the applet. We consult the classloader - * if there is one. - */ - public synchronized ThreadGroup getThreadGroup() { - ThreadGroup group = null; - try { - InCheck.acquire(); - /* First we check if any classloaded thing is on the stack. */ - ClassLoader loader = currentClassLoader(); - if (loader != null && (loader instanceof ClassContextImpl)) - { - if( inThreadGroup( Thread.currentThread() ) ) - { - group = Thread.currentThread().getThreadGroup(); - } - else - { - ClassContextImpl appletLoader = (ClassContextImpl)loader; - group = appletLoader.getThreadGroup(); - } - } - else - { - group = super.getThreadGroup(); - } - } finally { - InCheck.release(); - } - return group; - } - - public void debug(String s) { - if( debug ) - System.err.println(s); - } - - // This method is called from within the checkXXX method which - //already track if this class is on the stack by using InCheck. - private synchronized boolean isSecureLoader() { - InIsSecureLoader.acquire(); - try { - boolean bReturn = false; - ClassLoader loader = currentClassLoader(); - if (loader != null) { - if (loader instanceof ClassContextImpl) { - bReturn = !((ClassContextImpl) loader).checkSecurity(); - } else { - bReturn = true; // fremder ClassLoader: kann machen was er will - } - } else { - bReturn = true; - } - return bReturn; - } finally { - InIsSecureLoader.release(); - } - } - - - - /* In checkPermission we trap calls which are not covered by the old - (1.1) SecurityManager functions. This is necessary, because whenever - applets are used then the SecurityManager is set and Java components - may cause a checkPermission call. Then, if a user has not specified - permissions for this component, a SecurityException will be thrown - and the component fails to work. - - Calls to java.lang.SecurityManager.inClassLoader result in - a call to this function. For example, a checkPackageAccess with the - package java.text resulted in a call to this function with the permission - All_Permission. We use the member InCheck in order to determine if we - are in one of the check functions. If we are then checkPermissions does - nothing. The calling checkXXX does the required check anyway. - - We cannot override - void checkPermission(Permission perm, Object context) - because we do not know if in the thread, which is represented by context, - one of our security functions has been called. That is, we have no - access to InCheck or the class loaders to dertime if we grant permission. - - */ - public synchronized void checkPermission(java.security.Permission perm) - { - //isSecureClassLoader calls SecurityManager.currentClassLoader, which then - //calls this function to check if we have AllPermission. If so, then currentClassLoader - //returns null. Therefore we must throw and exception here. This is similar with - //the functions inClassLoader and classLoaderDepth. - if (InIsSecureLoader.inRecursion() - || InInClassLoader.inRecursion() - || InClassLoaderDepth.inRecursion()) - { - if (perm.implies(allPerm)) - throw(new SandboxSecurityException("checkPermission ", perm.toString())); - } - if (InCheck.inRecursion() == false - && isSecureLoader() == false) - { - throw(new SandboxSecurityException("checkPermission ", perm.toString())); - } - } - - protected boolean inClassLoader() - { - InInClassLoader.acquire(); - try - { - return super.inClassLoader(); - } finally { - InInClassLoader.release(); - } - } - - protected int classLoaderDepth() - { - InClassLoaderDepth.acquire(); - try - { - return super.classLoaderDepth(); - } finally { - InClassLoaderDepth.release(); - } - - } -} - -class RecursionCounter -{ - void acquire() - { - int count = ((Integer)refCount.get()).intValue(); - refCount.set(new Integer(++count)); - } - - void release() - { - int count = ((Integer)refCount.get()).intValue(); - refCount.set(new Integer(--count)); - } - - boolean inRecursion() { - int count = ((Integer)refCount.get()).intValue(); - return count > 0; - } - - private ThreadLocal refCount = new ThreadLocal() { - protected synchronized Object initialValue() { - return new Integer(0); - } - }; -} diff --git a/sandbox/com/sun/star/lib/sandbox/SandboxSecurityException.java b/sandbox/com/sun/star/lib/sandbox/SandboxSecurityException.java deleted file mode 100644 index 8312dd2792..0000000000 --- a/sandbox/com/sun/star/lib/sandbox/SandboxSecurityException.java +++ /dev/null @@ -1,71 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: SandboxSecurityException.java,v $ - * $Revision: 1.4 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -package com.sun.star.lib.sandbox; - -/** - * An applet security exception. - * - * @version 1.6, 11/23/96 - * @author Arthur van Hoff - */ -public class SandboxSecurityException extends SecurityException { - private String key = null; - private Object msgobj[] = null; - - public SandboxSecurityException(String name) { - super(name); - this.key = name; - } - - public SandboxSecurityException(String name, String arg) { - this(name); - msgobj = new Object[1]; - msgobj[0] = (Object)arg; - } - - public SandboxSecurityException(String name, String arg1, String arg2) { - this(name); - msgobj = new Object[2]; - msgobj[0] = (Object)arg1; - msgobj[1] = (Object)arg2; - } - - - //The loading of the static member amh caused a deadlock: - //Thread 1 holds a monitor on SandboxSecuritymethod and tries to get hold of - //a lock of the class loader. - //Thread 2 is the finalizer which holds the class loader monitor an needs the - //SandboxSecurity monitor. - //Therefor the method getLocalizedMessage and the member amh have been removed. -// private static SandboxMessageHandler amh = new SandboxMessageHandler("appletsecurityexception"); - -} - diff --git a/sandbox/com/sun/star/lib/sandbox/SandboxThreadGroup.java b/sandbox/com/sun/star/lib/sandbox/SandboxThreadGroup.java deleted file mode 100644 index 18dfe58006..0000000000 --- a/sandbox/com/sun/star/lib/sandbox/SandboxThreadGroup.java +++ /dev/null @@ -1,63 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: SandboxThreadGroup.java,v $ - * $Revision: 1.3 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -package com.sun.star.lib.sandbox; - -public class SandboxThreadGroup extends ThreadGroup { - private static int instances; - private Object context = null; - - public SandboxThreadGroup(String name, Object context) { - this(Thread.currentThread().getThreadGroup(), name, context); - } - - public SandboxThreadGroup(ThreadGroup parent, String name, Object context) { - super(parent, name); - - instances ++; - - setMaxPriority(Thread.NORM_PRIORITY - 1); - - this.context = context; - } - - public Object getContext() { - return context; - } - - public void dispose() { - context = null; - } - - public void finalize() { - instances --; - } -} - diff --git a/sandbox/com/sun/star/lib/sandbox/WeakEntry.java b/sandbox/com/sun/star/lib/sandbox/WeakEntry.java deleted file mode 100644 index 999a011fd4..0000000000 --- a/sandbox/com/sun/star/lib/sandbox/WeakEntry.java +++ /dev/null @@ -1,46 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: WeakEntry.java,v $ - * $Revision: 1.3 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -package com.sun.star.lib.sandbox; - -class WeakEntry { - Class weakClass; - WeakRef weakRef; - - public WeakEntry(Class weakClass, WeakRef weakRef) { - this.weakClass = weakClass; - this.weakRef = weakRef; - } - - public String toString() { - return (weakRef == null) ? "null" : weakRef.toString(); - } -} - diff --git a/sandbox/com/sun/star/lib/sandbox/WeakRef.java b/sandbox/com/sun/star/lib/sandbox/WeakRef.java deleted file mode 100644 index fe38dc07b6..0000000000 --- a/sandbox/com/sun/star/lib/sandbox/WeakRef.java +++ /dev/null @@ -1,80 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: WeakRef.java,v $ - * $Revision: 1.3 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -package com.sun.star.lib.sandbox; - -public class WeakRef { - static private final boolean DEBUG = false; - - private int refCnt; - private Object ref; - private Object key; - - WeakRef(Object key, Object ref) { - this.key = key; - this.ref = ref; - } - - public Object getRef() { - return ref; - } - - public Object getKey() { - return key; - } - - int getRefCount() { - return refCnt; - } - - // the following two methods where synchronized, but need not to be - public void incRefCnt() { - refCnt ++; - } - - public synchronized void decRefCnt() { - refCnt --; - if(refCnt <= 0) { - WeakTable.remove(key); - - if(DEBUG)System.err.println("#### WeakRef - object freeed:" + key + " " + ref); - if(ref instanceof Disposable) { - ((Disposable)ref).dispose(); - } - - ref = null; - } - } - - public String toString() { - return "WeakRef - " + key + " " + ((ref == null) ? "null" : ref.toString()); - } -} - diff --git a/sandbox/com/sun/star/lib/sandbox/WeakTable.java b/sandbox/com/sun/star/lib/sandbox/WeakTable.java deleted file mode 100644 index df0e379b90..0000000000 --- a/sandbox/com/sun/star/lib/sandbox/WeakTable.java +++ /dev/null @@ -1,147 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: WeakTable.java,v $ - * $Revision: 1.3 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -package com.sun.star.lib.sandbox; - -import java.lang.reflect.Method; - -import java.util.Hashtable; -import java.util.Observable; -import java.util.Observer; - -public class WeakTable extends Observable { - private static final boolean DEBUG = false; - - private static final void DEBUG(String dbg) { - if (DEBUG) - System.err.println(">>> com.sun.star.lib.sandbox.WeakTable - " + dbg); - } - - static WeakTable weakTable = new WeakTable(); - - public Hashtable hash = new Hashtable(); - - synchronized private void pput(Object key, Cachable cachable) { - DEBUG("put:" + key + " " + cachable); - - synchronized(hash) { - Object hardObject = cachable.getHardObject(); - Class weakClass = cachable.getClass(); - - WeakRef weakRef = new WeakRef(key, hardObject); - cachable.setWeakRef(weakRef); - - hash.put(key, new WeakEntry(weakClass, weakRef)); - } - setChanged(); - notifyObservers(); - } - - synchronized private Cachable pget(Object key) { - DEBUG("get:" + key); - - String error = null; - - Cachable cachable = null; - - synchronized(hash) { - WeakEntry weakEntry = (WeakEntry)hash.get(key); - if(weakEntry != null) { - try { - // Class sig[] = new Class[1]; - // sig[0] = weakRef.getClass(); - // Method method = weakClass.getMethod("<init>", sig); - - cachable = (Cachable)weakEntry.weakClass.newInstance(); - cachable.setWeakRef(weakEntry.weakRef); - } - catch(IllegalAccessException e) { - error = "#### WeakTable.get:" + e; - } - catch(InstantiationException e) { - error = "#### WeakTable.get:" + e; - } - } - } - if(error != null) - System.err.println(error); - - return cachable; - } - - synchronized private void premove(Object key) { - hash.remove(key); - - setChanged(); - notifyObservers(); - } - - synchronized private void pclear() { - hash.clear(); - - setChanged(); - notifyObservers(); - } - - public void addObserver(Observer observer) { - super.addObserver(observer); - - observer.update(this, null); - } - - public static void put(Object key, Cachable cachable) { - weakTable.pput(key, cachable); - } - - public static Cachable get(Object key) { - return weakTable.pget(key); - } - - public static void remove(Object key) { - weakTable.premove(key); - } - - public static void AddObserver(Observer observer) { - weakTable.addObserver(observer); - } - - public static void DeleteObserver(Observer observer) { - weakTable.deleteObserver(observer); - } - - static void clear() { - weakTable.pclear(); - } - - static java.util.Enumeration elements() { - return weakTable.hash.elements(); - } -} - diff --git a/sandbox/com/sun/star/lib/sandbox/XImage.java b/sandbox/com/sun/star/lib/sandbox/XImage.java deleted file mode 100644 index 3f3a7c04c8..0000000000 --- a/sandbox/com/sun/star/lib/sandbox/XImage.java +++ /dev/null @@ -1,70 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: XImage.java,v $ - * $Revision: 1.3 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -package com.sun.star.lib.sandbox; - -import java.awt.Color; -import java.awt.Graphics; -import java.awt.Rectangle; - -import java.awt.image.ImageObserver; -import java.awt.image.ImageProducer; - -public interface XImage { - public void addWatcher(ImageObserver observer); - public boolean isWatcher(ImageObserver observer); - public void removeWatcher(ImageObserver observer); - public void notifyWatchers(Rectangle refreshed); - - public int getWidth(ImageObserver observer); - public int getHeight(ImageObserver observer); - public Object getProperty(String name, ImageObserver observer); - public boolean prepare(int w, int h, ImageObserver o); - public int check(int w, int h, ImageObserver o); - - public Graphics getGraphics(); - - public ImageProducer getSource(); - - public void flush(); - - public boolean drawOn(int xGraphicsRef, int xDeviceRef, - Color bgColor, - ImageObserver observer, - int dx1, int dy1, int dx2, int dy2, - int sx1, int sy1, int sx2, int sy2); - - public boolean drawOn(int xGraphicsRef, int xDeviceRef, int x, int y, ImageObserver observer); - - public boolean drawOn(int xGraphicsRef, int xDeviceRef, int x, int y, java.awt.Color bgColor, ImageObserver observer); - public boolean drawOn(int xGraphicsRef, int xDeviceRef, int x, int y, int width, int height, Color bgColor, ImageObserver observer); - public boolean drawOn(int xGraphicsRef, int xDeviceRef, int x, int y, int width, int height, ImageObserver observer); -} - diff --git a/sandbox/com/sun/star/lib/sandbox/makefile.mk b/sandbox/com/sun/star/lib/sandbox/makefile.mk deleted file mode 100644 index 81e7fdcace..0000000000 --- a/sandbox/com/sun/star/lib/sandbox/makefile.mk +++ /dev/null @@ -1,89 +0,0 @@ -#************************************************************************* -# -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# Copyright 2008 by Sun Microsystems, Inc. -# -# OpenOffice.org - a multi-platform office productivity suite -# -# $RCSfile: makefile.mk,v $ -# -# $Revision: 1.8 $ -# -# This file is part of OpenOffice.org. -# -# OpenOffice.org is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 -# only, as published by the Free Software Foundation. -# -# OpenOffice.org is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License version 3 for more details -# (a copy is included in the LICENSE file that accompanied this code). -# -# You should have received a copy of the GNU Lesser General Public License -# version 3 along with OpenOffice.org. If not, see -# <http://www.openoffice.org/license.html> -# for a copy of the LGPLv3 License. -# -#************************************************************************* - -PRJ = ..$/..$/..$/..$/.. -PRJNAME = sandbox -TARGET = lib_sandbox -PACKAGE = com$/sun$/star$/lib$/sandbox - -# --- Settings ----------------------------------------------------- - -.INCLUDE : settings.mk -.IF "$(L10N_framework)"=="" - -.IF "$(JDK)" == "gcj" -all: - @echo This dir cannot be build with gcj because of sun.applet.AppletAudioClip -.ELSE - -JARFILES= - -# --- Files -------------------------------------------------------- - -JAVAFILES= \ - AudioProxy.java \ - Cachable.java \ - ClassContext.java \ - ClassContextImpl.java \ - ClassContextProxy.java \ - CodeSource.java \ - Disposable.java \ - ExecutionContext.java \ - Holder.java \ - ImageProducerProxy.java \ - JarEntry.java \ - JarInputStream.java \ - Permission.java \ - PermissionCollection.java \ - ProtectionDomain.java \ - Resource.java \ - ResourceImpl.java \ - ResourceProxy.java \ - ResourceViewer.java \ - SandboxMessageHandler.java \ - SandboxThreadGroup.java \ - SandboxSecurity.java \ - SandboxSecurityException.java \ - WeakRef.java \ - WeakTable.java \ - WeakEntry.java \ - XImage.java - -JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class) - -RC_SUBDIRSDEPS=$(JAVATARGET) - -# --- Targets ------------------------------------------------------ -.ENDIF -.ENDIF - -.INCLUDE : target.mk - |