diff --git a/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/jpav/ActivatorAppletContext.java b/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/jpav/ActivatorAppletContext.java deleted file mode 100644 index efd14d3cbb7..00000000000 --- a/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/jpav/ActivatorAppletContext.java +++ /dev/null @@ -1,223 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * The contents of this file are subject to the Mozilla Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is The Waterfall Java Plugin Module - * - * The Initial Developer of the Original Code is Sun Microsystems Inc - * Portions created by Sun Microsystems Inc are Copyright (C) 2001 - * All Rights Reserved. - * - * $Id: ActivatorAppletContext.java,v 1.1.1.1 2001-05-10 18:12:27 edburns%acm.org Exp $ - * - * - * Contributor(s): - * - * Nikolay N. Igotti - */ - -package sun.jvmp.jpav; - -import sun.jvmp.applet.*; -import java.applet.*; -import java.util.*; -import sun.applet.*; -import java.awt.*; -import java.net.*; -import java.io.*; -import java.lang.reflect.*; -import sun.misc.Ref; - -public abstract class ActivatorAppletContext implements AppletContext -{ - - /* - * Get an audio clip. - * - * @param url url of the desired audio clip - */ - public AudioClip getAudioClip(URL url) { - System.getSecurityManager().checkConnect(url.getHost(), url.getPort()); - synchronized (audioClips) { - AudioClip clip = (AudioClip)audioClips.get(url); - if (clip == null) { - clip = new AppletAudioClip(url); - audioClips.put(url, clip); - } - return clip; - } - } - - /* - * Get an image. - * - * @param url of the desired image - */ - public Image getImage(URL url) { - //sun.jvmp.PluggableJVM.trace("Ask for image: "+url); - return getCachedImage(url); - } - - static Image getCachedImage(URL url) { - System.getSecurityManager().checkConnect(url.getHost(), url.getPort()); - return (Image)getCachedImageRef(url).get(); - } - - /** - * Get an image ref. - */ - static Ref getCachedImageRef(URL url) { - synchronized (imageRefs) { - AppletImageRef ref = (AppletImageRef)imageRefs.get(url); - if (ref == null) { - ref = new AppletImageRef(url); - imageRefs.put(url, ref); - } - return ref; - } - } - - - /** - * Get an applet by name. - */ - public Applet getApplet(String name) { - name = name.toLowerCase(); - for (Enumeration e = appletPanels.elements() ; e.hasMoreElements() ;) { - AppletPanel p = (AppletPanel)e.nextElement(); - String param = p.getParameter("name"); - if (param != null) { - param = param.toLowerCase(); - } - if (name.equals(param) && - p.getDocumentBase().equals(appletPanel.getDocumentBase())) { - try { - if (checkConnect(appletPanel.getCodeBase().getHost(), - p.getCodeBase().getHost())==false) - return null; - } catch (InvocationTargetException ee) { - showStatus(ee.getTargetException().getMessage()); - return null; - } catch (Exception ee) { - showStatus(ee.getMessage()); - return null; - } - return p.getApplet(); - } - } - return null; - } - - /** - * Return an enumeration of all the accessible - * applets on this page. - */ - public Enumeration getApplets() { - Vector v = new Vector(); - for (Enumeration e = appletPanels.elements() ; e.hasMoreElements() ;) { - AppletPanel p = (AppletPanel)e.nextElement(); - if (p.getDocumentBase().equals(appletPanel.getDocumentBase())) { - try { - checkConnect(appletPanel.getCodeBase().getHost(), - p.getCodeBase().getHost()); - v.addElement(p.getApplet()); - } catch (InvocationTargetException ee) { - showStatus(ee.getTargetException().getMessage()); - } catch (Exception ee) { - showStatus(ee.getMessage()); - } - } - } - return v.elements(); - } - - /* - *

- * Check that a particular applet is authorized to connect to - * the target applet. - * This code is JDK 1.1 and 1.2 dependent - *

- * - * @param source Source applet host name requesting the connect - * @param target Target applet host name to connect to - * - * @return true if the connection is granted - */ - private boolean checkConnect(String sourceHostName, String targetHostName) - throws SecurityException, InvocationTargetException, Exception - { - SocketPermission panelSp = - new SocketPermission(sourceHostName, - "connect"); - SocketPermission sp = - new SocketPermission(targetHostName, - "connect"); - if (panelSp.implies(sp)) { - return true; - } - return false; - } - - /* - * Replaces the Web page currently being viewed with the given URL - * - * @param url the address to transfer to - */ - abstract public void showDocument(URL url); - - /* - * Requests that the browser or applet viewer show the Web page - * indicated by the url argument. - * - * @param url the address to transfer to - * @param target One of the value - * "_self" show in the current frame - * "_parent"show in the parent frame - * "_top" show in the topmost frame - * "_blank" show in a new unnamed top-level windownameshow in a - * new top-level window named name - */ - abstract public void showDocument(URL url, String target); - - /* - * Show status. - * - * @param status status message - */ - abstract public void showStatus(String status); - - /* - * Add a applet in this applet context - * - * @param applet the applet to add - */ - void addAppletInContext(AppletPanel appletPanel) { - this.appletPanel = appletPanel; - appletPanels.addElement(appletPanel); - } - - /* - * Remove applet from this applet context - * - * @param applet applet to remove - */ - void removeAppletFromContext(AppletPanel applet) { - appletPanels.removeElement(applet); - } - - private AppletPanel appletPanel; - - private static Vector appletPanels = new Vector(); - - private static Hashtable audioClips = new Hashtable(); - private static Hashtable imageRefs = new Hashtable(); -} - diff --git a/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/jpav/ActivatorAppletPanel.java b/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/jpav/ActivatorAppletPanel.java deleted file mode 100644 index ba2bcde2aa2..00000000000 --- a/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/jpav/ActivatorAppletPanel.java +++ /dev/null @@ -1,737 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * The contents of this file are subject to the Mozilla Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is The Waterfall Java Plugin Module - * - * The Initial Developer of the Original Code is Sun Microsystems Inc - * Portions created by Sun Microsystems Inc are Copyright (C) 2001 - * All Rights Reserved. - * - * $Id: ActivatorAppletPanel.java,v 1.1.1.1 2001-05-10 18:12:27 edburns%acm.org Exp $ - * - * - * Contributor(s): - * - * Nikolay N. Igotti - */ - -package sun.jvmp.jpav; -import java.applet.*; -import java.io.*; -import sun.applet.*; -import java.net.URL; -import java.net.MalformedURLException; -import java.util.*; -import java.awt.*; -import sun.jvmp.*; -import sun.jvmp.applet.*; -import java.lang.reflect.*; - -public class ActivatorAppletPanel extends AppletPanel implements ProxyType -{ - - // Network Access Level - public static final int NETWORK_ACCESS_NONE = 0; - public static final int NETWORK_ACCESS_HOST = 1; - public static final int NETWORK_ACCESS_UNRESTRICTED = 2; - - PluggableJVM m_jvm; - - /* - * are we initialized - */ - public static boolean javaEnabled = true; - private boolean inited = false; - - /** - * Some constants... - */ - private static String propertiesFileName = "properties"; - - /** - * Look here for the properties file - */ - public static File theUserPropertiesFile; - public static File theAppletViewerPropsFile; - - URL documentURL = null; - URL baseURL = null; - Frame m_f = null; - private int width; - private int height; - - private static AppletMessageHandler amh = - new AppletMessageHandler("appletpanel"); - - // Parameters handler - protected java.util.Hashtable atts; - - // Localization strings. - private static ResourceBundle rb; - - // JAR files that have not yet been loaded. - private String cookedJars; - - public static void loadPropertiesFiles() { - - String sep = File.separator; - theUserPropertiesFile = new File(System.getProperty("user.home") + - sep + ".java" + - sep + propertiesFileName); - // ensure the props folder can be made - new File(theUserPropertiesFile.getParent()).mkdirs(); - theAppletViewerPropsFile = new File(System.getProperty("java.home") + - sep + "lib" + - sep + "appletviewer.properties"); - } - - - private class Initer extends Thread { - ActivatorAppletPanel that; - - Initer(ActivatorAppletPanel that) { - super(Thread.currentThread().getThreadGroup(), "IniterThread"); - this.that = that; - } - - /** - * Main body of thread. Call init on our AppletViewer. - */ - public void run() { - init_run_wrapper(); // To identify this thread's stack - } - - private void init_run_wrapper() - { - m_jvm.trace("real Init()", PluggableJVM.LOG_DEBUG); - that.init(); - that.sendEvent(sun.applet.AppletPanel.APPLET_INIT); - that.sendEvent(sun.applet.AppletPanel.APPLET_START); - } - } - - /** - * Construct a new applet viewer. - * Restricted to subclasses for security reasons, - * - * @param appletContext the AppletContext to use - */ - public ActivatorAppletPanel(PluggableJVM jvm, - WFAppletContext appletContext, - Hashtable atts) { - if (appletContext == null) - throw new IllegalArgumentException("AppletContext"); - this.appletContext = appletContext; - appletContext.addAppletInContext(this); - this.atts = atts; - m_jvm = jvm; - } - - public void sendEvent(int id) { - super.sendEvent(id); - } - - /** - * Init the applet, called once to start the download of the applet - */ - public void init() { - ClassLoaderInfo cli = ClassLoaderInfo.find(this); - cli.addReference(); - synchronized(AppletViewer.class) { - super.init(); - } - sendEvent(sun.applet.AppletPanel.APPLET_LOAD); - //sendEvent(sun.applet.AppletPanel.APPLET_INIT); - } - - /** - * Start the applet. - */ - public void appletStart() { - if (inited) - sendEvent(sun.applet.AppletPanel.APPLET_START); - } - - /** - * Stop the applet. - */ - public void appletStop() { - sendEvent(sun.applet.AppletPanel.APPLET_STOP); - } - - public int getLoadingStatus() - { - return status; - } - - /** - * Notification that the applet is being closed - * - * @param timeOut max time we are waiting for the applet to die - * in milliseconds. - */ - public void onClose(final int timeOut) { - - // Just make sure we are destroying the thread from a utility - // thread to not block the main thread for that. - - Runnable work = new Runnable() { - public void run() { - onPrivateClose(timeOut); - } - }; - Thread closingThread = new Thread(work); - closingThread.start(); - } - - /** - * Notification that the applet is being closed - * - * @param timeOut max time we are waiting for the applet to die - * in milliseconds. - */ - protected void onPrivateClose(int timeOut) { - appletContext.removeAppletFromContext(this); - if (status==APPLET_LOAD) { - stopLoading(); - } - sendEvent(APPLET_STOP); - sendEvent(APPLET_DESTROY); - sendEvent(APPLET_DISPOSE); - sendEvent(APPLET_QUIT); - ClassLoaderInfo cli = ClassLoaderInfo.find(this); - cli.removeReference(); - } - - /** - * Initialized the properties for this AppletViewer like the Applet - * codebase and document base. - */ - protected void initProperties() { - String att = getParameter("java_codebase"); - if (att == null) - att = getParameter("codebase"); - if (att != null) { - if (!att.endsWith("/")) { - att += "/"; - } - try { - baseURL = new URL(documentURL, att); - } catch (MalformedURLException e) { - } - } - if (baseURL == null) { - String file = documentURL.getFile(); - int i = file.lastIndexOf('/'); - if (i > 0 && i < file.length() - 1) { - try { - baseURL = new URL(documentURL, file.substring(0, i + 1)); - } catch (MalformedURLException e) { - } - } - } - - // when all is said & done, baseURL shouldn't be null - if (baseURL == null) - baseURL = documentURL; - } - - /** - * Get an applet parameter. - */ - public String getParameter(String name) { - name = name.toLowerCase(); - if (atts.get(name) != null) { - return (String) atts.get(name); - } else { - String value=null; - try { - value = getParameterFromHTML(name); - } catch (Throwable e) { - m_jvm.trace(e, PluggableJVM.LOG_WARNING); - } - if (value != null) - atts.put(name.toLowerCase(), value); - return value; - } - } - - - /** - * Get applet's parameters. - */ - public Hashtable getParameters() - { - return (Hashtable) atts.clone(); - } - - - /** - * Method to retrieve the parameter from the HTML tags - * - * @param name the parameter name - * - * @return the parameter value, null if undefined - */ - protected String getParameterFromHTML(String name) - { - return null; - } - - /** - * Set an applet parameter. - */ - public void setParameter(String name, Object value) { - name = name.toLowerCase(); - atts.put(name, value.toString()); - } - - /** - * Get the document url. - */ - public URL getDocumentBase() { - return documentURL; - - } - - public void setWindow(Frame f) - { - if (f == null) - { - m_jvm.trace("Got zero Frame for SetWindow", - PluggableJVM.LOG_ERROR); - return; - } - f.setLayout(null); - Applet a = getApplet(); - if (a == null) { - try { - int wd = Integer.parseInt(getParameter("width")); - int ht = Integer.parseInt(getParameter("height")); - this.width = wd; - this.height = ht; - } catch (NumberFormatException e) { - // Try and maintain consistency between the parameters and - // our width/height. If the parameters are not properly - // set to be integers, then reset them to our w, h - setParameter("width", new Integer(width)); - setParameter("height", new Integer(height)); - this.width = width; - this.height = height; - } - } else { - // The applet exists, so resize it and its frame, and - // have the width/height parameters reflect these values - setParameter("width", new Integer(width)); - setParameter("height", new Integer(height)); - this.width = width; - this.height = height; - - setSize(width, height); - a.resize(width, height); - a.setVisible(true); - } - setBounds(0, 0, width, height); - if (m_f == f) return; - m_f = f; - f.add(this); - f.show(); - f.setBounds(0, 0, width, height); - maybeInit(); - } - - private void maybeInit() { - m_jvm.trace("maybeInit()", PluggableJVM.LOG_DEBUG); - if (!inited && m_f != null && getDocumentBase() != null) - { - inited = true; - Initer initer = new Initer(this); - initer.start(); - } - } - - /** - * Set the document url. - * This must be done early, before initProperties is called. - */ - public void setDocumentBase(URL url) - { - documentURL = url; - initProperties(); - // If the window has already been set, we can init the applet. - maybeInit(); - } - - /** - * Get the base url. - */ - public URL getCodeBase() { - return baseURL; - } - /** - * Get the width. - */ - public int getWidth() { - String w = getParameter("width"); - if (w != null) { - return Integer.valueOf(w).intValue(); - } - return 0; - } - - /** - * Get the height. - */ - public int getHeight() { - String h = getParameter("height"); - if (h != null) { - return Integer.valueOf(h).intValue(); - } - return 0; - } - - /** - * Get the code parameter - */ - public String getCode() { - - // Support HTML 4.0 style of OBJECT tag. - // - // - // - // - // - // In this case, the CODE will be inside the classid - // attribute. - // - String moniker = getParameter("classid"); - String code = null; - - if (moniker != null) - { - int index = moniker.indexOf("java:"); - - if (index > -1) - { - code = moniker.substring(5 + index); - - if (code != null || !code.equals("")) - return code; - } - } - - code = getParameter("java_code"); - if (code==null) - code=getParameter("code"); - return code; - } - - /** - * Return the list of jar files if specified. - * Otherwise return null. - */ - public String getJarFiles() { - return cookedJars; - } - - - /* - * Allow pre-loading of local .jar files in plug-in lib/app directory - * These .jar files are loaded with the PluginClassLoader so they - * run in the applet's sandbox thereby saving developers the trouble - * of writing trusted support classes. - * The ClassLoaderInfo cli should be locked. - */ - protected Vector getLocalJarFiles() { - - String fSep = File.separator; - String libJarPath = - System.getProperty("java.home") + fSep + "lib"; - - String appJarPath = libJarPath + fSep + "applet"; - return(getJarFilesFromPath(appJarPath)); - - } - - - private Vector getJarFilesFromPath (String basePath) { - File dir = new File(basePath); - if (!dir.exists()) { - return(null); - } - - String[] jarList = dir.list(new FilenameFilter() { - public boolean accept(File f, String s) { - return(s.endsWith(".jar")); - } - }); - - Vector jars = new Vector(); - - String fSep = File.separator; - for (int i = 0; i < jarList.length; i++) { - String fullJarPath = basePath + fSep + jarList[i]; - jars.add(new File(fullJarPath)); - } - - return(jars); - } - - - - /** - * Return the value of the object param - */ - public String getSerializedObject() { - String object = getParameter("java_object"); - if (object==null) - object=getParameter("object");// another name? - return object; - } - -/** - * Get the applet context. For now this is - * also implemented by the AppletPanel class. - */ - public AppletContext getAppletContext() - { - return appletContext; - } - - public Object getViewedObject() - { - Applet applet = super.getApplet(); - return applet; - } - - - /** - * Paint this panel while visible and loading an applet to entertain - * the user. - * - * @param g the graphics context - */ - public void paint(Graphics g) - { - if (getViewedObject() == null && g != null) { - setBackground(Color.lightGray); - g.setColor(Color.black); - Dimension d = getSize(); - Font fontOld = g.getFont(); - FontMetrics fm = null; - if (fontOld != null) - fm = g.getFontMetrics(fontOld); - String str = getWaitingMessage(); - - // Display message on the screen if the applet is not started yet. - if (d != null && fm != null) - g.drawString(str, (d.width - fm.stringWidth(str))/ 2, - (d.height + fm.getAscent())/ 2); - } - } - - public String getWaitingMessage() { - return "loading applet..."; - //return getMessage("loading") + getHandledType() + " ..."; - } - - /* - *

- * Load an applet from a serialized stream. This is likely to happen - * when the user uses the Back/Forward buttons - *

- * - * @param is Input stream of the serialized applet - */ - protected void load(java.io.InputStream is) { - this.is = is; - } - - - /* - * @return the applet name - */ - public String getName() { - - String name = getParameter("name"); - if (name!=null) - return name; - - // Remove .class extension - name = getCode(); - if (name != null){ - int index = name.lastIndexOf(".class"); - if (index != -1) - name = name.substring(0, index); - } else{ - // Remove .object extension - name = getSerializedObject(); - - if (name != null) { - int index = name.lastIndexOf(".ser"); - if (index != -1) - name = name.substring(0, index); - } - } - - return name; - } - - - /** - * @return the java component displayed by this viewer class - */ - protected String getHandledType() { - return getMessage("java_applet"); - } - - public void setStatus(int status) { - this.status = status; - } - - public void showActivatorAppletStatus(String msg) { - showAppletStatus(msg); - } - - public void showActivatorAppletLog(String msg) { - showAppletLog(msg); - } - - public void setDoInit(boolean doInit) { - this.doInit = doInit; - } - - private WFAppletContext appletContext; - - - /** - * Method to get an internationalized string from the Activator resource. - */ - public static String getMessage(String key) { - return key; - } - - - /** - * Method to get an internationalized string from the Activator resource. - */ - public static String[] getMessageArray(String key) { - return new String[] { key }; - } - - private java.io.InputStream is; - - /** - * This method actually creates an AppletClassLoader. - * - * It can be override by subclasses (such as the Plug-in) - * to provide different classloaders. This method should be - * called only when running inside JDK 1.2. - */ - protected AppletClassLoader createClassLoader(final URL codebase) { - return new ActivatorClassLoader(codebase); - } - - /* - * We overload our parent loadJarFiles so tht we can avoid - * reloading JAR files that are already loaded. - * KGH Mar 98 - */ - protected void loadJarFiles(AppletClassLoader loader) - throws IOException, InterruptedException - { - - - // Cache option as read from the Html page tag - String copt; - - // Cache Archive value as read from the Html page tag - String carch; - - // Cache Version value as read from the Html page tag - String cver; - - // Vector to store the names of the jar files to be cached - Vector jname = new Vector(); - - // Vector to store actual version numbers - Vector jVersion = new Vector(); - - - // Figure out the list of all required JARs. - String raw = getParameter("java_archive"); - if (raw == null) - { - raw = getParameter("archive"); - } - - - ClassLoaderInfo cli = ClassLoaderInfo.find(this); - - try - { - // Prevent two applets trying to load JARS from the same - // classloader at the same time. - cli.lock(); - - // If there are no JARs, this is easy. - if (raw == null) - { - return; - } - - // Figure out which JAR files still need to be loaded. - String cooked = ""; - StringTokenizer st = new StringTokenizer(raw, ",", false); - while(st.hasMoreTokens()) - { - String tok = st.nextToken().trim(); - if (cli.hasJar(tok)) - { - continue; - } - - cli.addJar(tok); - - if (cooked.equals("")) - { - cooked = tok; - } - else - { - cooked = cooked + "," + tok; - } - } - - cookedJars = cooked; - - // Now call into our superlcass to do the actual JAR loading. - // It will call back to our getJarFiles method to find which - // JARs need to be loaded, and we will give it the cooked list. - super.loadJarFiles(loader); - - } - finally - { - // Other people can load JARs now. - cli.unlock(); - } - } - - -}; - - - - - - diff --git a/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/jpav/ActivatorClassLoader.java b/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/jpav/ActivatorClassLoader.java deleted file mode 100644 index ab649c4a2ed..00000000000 --- a/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/jpav/ActivatorClassLoader.java +++ /dev/null @@ -1,38 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * The contents of this file are subject to the Mozilla Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is The Waterfall Java Plugin Module - * - * The Initial Developer of the Original Code is Sun Microsystems Inc - * Portions created by Sun Microsystems Inc are Copyright (C) 2001 - * All Rights Reserved. - * - * $Id: ActivatorClassLoader.java,v 1.1.1.1 2001-05-10 18:12:27 edburns%acm.org Exp $ - * - * - * Contributor(s): - * - * Nikolay N. Igotti - */ - -package sun.jvmp.jpav; - -import java.net.URL; - -public class ActivatorClassLoader extends sun.jvmp.applet.WFAppletClassLoader -{ - private URL base; - public ActivatorClassLoader(URL base) { - super(base); - this.base = base; - } -}; diff --git a/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/jpav/ActivatorProxyHandler.java b/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/jpav/ActivatorProxyHandler.java deleted file mode 100644 index a73026e51ac..00000000000 --- a/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/jpav/ActivatorProxyHandler.java +++ /dev/null @@ -1,398 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * The contents of this file are subject to the Mozilla Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is The Waterfall Java Plugin Module - * - * The Initial Developer of the Original Code is Sun Microsystems Inc - * Portions created by Sun Microsystems Inc are Copyright (C) 2001 - * All Rights Reserved. - * - * $Id: ActivatorProxyHandler.java,v 1.1.1.1 2001-05-10 18:12:28 edburns%acm.org Exp $ - * - * - * Contributor(s): - * - * Nikolay N. Igotti - */ - -package sun.jvmp.jpav; - -import java.net.URL; -import java.util.HashMap; -import java.util.StringTokenizer; -import sun.jvmp.*; -import sun.jvmp.applet.*; - - -public class ActivatorProxyHandler implements ProxyHandler, ProxyType { - - private int proxyType = PROXY_TYPE_NO_PROXY; - - /* proxyList contains all the proxy information in the form of - * "http=webcache1-cup:8080;ftp=webcache2-cup;gopher=javaweb:9090". Proxy - * information for a particular protocol is seperated by ';'. If a port - * number is specified, it is specified by using ':' following the proxy - * host. If a specified protocol is not specified in the list, no proxy - * is assumed. There is another form of this string which is "webcache-cup:8080". - * In this case, it means all protocol will use this proxy (Apply-all). - * Notice that no '=' is in the string in this case. - */ - private String proxyList = null; - - /* proxyOverride contains all the domain which no proxy should be used when - * a connection is made. For example, "a.eng,b.eng,c.*.eng". In this case, - * if the host name is a.eng, b.eng, or c.c.eng, no proxy is used. Otherwise, - * proxy information will be returned according to the protocol in the URL. - * Note that wildcard can be used. If all local address should be bypassed, - * a special string '' is used. - */ - private String proxyOverride = null; - - /** - *

Proxy info cache. - *

- */ - private HashMap proxyTable = null; - - private BrowserSupport support = null; - - public ActivatorProxyHandler(int proxyType, - String proxyList, - String proxyOverride, - BrowserSupport sup) - { - this.proxyType = proxyType; - this.proxyList = proxyList; - this.proxyOverride = proxyOverride; - this.support = sup; - proxyTable = new HashMap(); - } - - - /* getProxyInfo is a function which takes a proxy-info-list, a - * proxy-bypass-list, a URL, and returns the corresponding proxy information - * with respect to the given URL. - * - * parameters : - * u [in] a string which contains all the proxy information - * - * out: - * ProxyInfo [out] ProxyInfo contains the corresponding proxy result. - * - */ - public synchronized ProxyInfo getProxyInfo(URL u) - { - ProxyInfo pinfo = null; - - try { - pinfo = (ProxyInfo) proxyTable.get(u.getProtocol() - + u.getHost() - + u.getPort()); - - // XXX: is it OK? - if (pinfo != null) - return pinfo; - - if (proxyType == PROXY_TYPE_NO_PROXY || - (proxyType == PROXY_TYPE_MANUAL && isProxyBypass(proxyOverride, u))) - // Check if it is direct connect - pinfo = new ProxyInfo(null, -1); - else if (proxyType == PROXY_TYPE_MANUAL) - { - String socksInfo = null; - - // Extract info about SOCKS - int i = proxyList.indexOf("socks="); - if (i != -1) - { - int j = proxyList.indexOf(";", i); - if (j == -1) - socksInfo = proxyList.substring(i + 6); - else - socksInfo = proxyList.substring(i + 6, j); - } - - - if (proxyList.indexOf("=") == -1) - { - // Apply all option - pinfo = new ProxyInfo(proxyList); - } - else - { - // Parse proxy list - String protocol = u.getProtocol(); - - i = proxyList.indexOf(protocol + "="); - if (i == -1) - // Cannot find the protocol proxy - pinfo = new ProxyInfo(null, socksInfo); - else - { - int j = proxyList.indexOf(";", i); - - if (j == -1) { - pinfo = new ProxyInfo(proxyList.substring(i + protocol.length() + 1), socksInfo); - } - else { - pinfo = new ProxyInfo(proxyList.substring(i + protocol.length() + 1, j), socksInfo); - } - } - } - } - else - { - if (support == null) - pinfo = null; - else - pinfo = support.getProxyInfoForURL(u); - } - - proxyTable.put(u.getProtocol() + u.getHost() + u.getPort(), pinfo); - } - catch (Exception e) { - PluggableJVM.trace("Proxy is not configured", - PluggableJVM.LOG_ERROR); - PluggableJVM.trace(e, PluggableJVM.LOG_ERROR); - pinfo = new ProxyInfo(null, -1); - } - - return pinfo; - } - - - /* isProxyBypass is a function which takes a proxy override list and a URL - * , and returns true if the hostname matches the proxy override list; - * otherwise, false is returned. - * - * parameters : - * proxyOverride [in] a string which contains the proxy override list - * u [in] a URL which contains the hostname - * - * out: - * boolean [out] if the proxy override list matches the hostname, - * true is returned. Otherwise, false is returned. - * - * Notes: i) proxyOverride contains all the domain which no proxy should be - * used when a connection is made. For example, "a.eng,b.eng,c.*.eng". - * In this case, if the host name is a.eng, b.eng, or c.c.eng, no - * proxy is used. Otherwise, proxy information will be returned - * according to the protocol in the URL. Note that wildcard can be - * used. If all local address should be bypassed, a special string - * '' is used. - * - */ - private boolean isProxyBypass(String proxyOverride, URL u) - { - if (proxyOverride == null || proxyOverride.equals("")) - return false; - - String host = u.getHost(); - - // Extract proxy-override list - StringTokenizer st = new StringTokenizer(proxyOverride, ",", false); - while (st.hasMoreTokens()) - { - String pattern = st.nextToken(); - - if (pattern.equals("") && host.indexOf(".") == -1) - return true; - else if (shExpMatch(host, pattern)) - return true; - } - - return false; - } - - - /* shExpMatch is a function which takes a string and a pattern, and returns - * true if the string matches the pattern; otherwise, false is returned. - * - * parameters : - * str [in] a string which is used for pattern matching - * shexp [in] a string which contains the pattern - * - * out: - * boolean [out] if the string match the pattern, true is returned. - * otherwise, false is returned. - * - * Notes: i) shexp contains the pattern which may include the wildcard '*'. - * ii) The pattern matching is case-insensitive. - * - */ - private boolean shExpMatch(String str, String shexp) - { - try { - // Convert the string to lower case - str = str.toLowerCase(); - shexp = shexp.toLowerCase(); - - return shExpMatch2(str, shexp); - } catch (Throwable e) { - - // Error recovery - PluggableJVM.trace(e, PluggableJVM.LOG_WARNING); - return false; - } - } - - /* shExpMatch2 is a function which takes a string and a pattern, and returns - * true if the string matches the pattern; otherwise, false is returned. - * - * parameters : - * str [in] a string which is used for pattern matching - * shexp [in] a string which contains the pattern - * - * out: - * boolean [out] if the string match the pattern, true is returned. - * otherwise, false is returned. - * - * Notes: i) shexp contains the pattern which may include the wildcard '*'. - * - * ii) This is the actual implementation of the pattern matching - * algorithm. - * - */ - private boolean shExpMatch2(String str, String shexp) - { - // NULL is not a valid input. - // - if (str == null || shexp == null) - return false; - - if (shexp.equals("*")) - return true; - - // Check the position of the wildcard - int index = shexp.indexOf('*'); - - if (index == -1) - { - // No wildcard anymore - return str.equals(shexp); - } - else if (index == 0) - { - // Wildcard at the beginning of the pattern - - for (int i=0; i <= str.length(); i++) - { - // Loop through the string to see if anything match. - if (shExpMatch2(str.substring(i), shexp.substring(1))) - return true; - } - - return false; - } - else - { - // index > 0 - String sub = null, sub2 = null; - - sub = shexp.substring(0, index); - - if (index <= str.length()) - sub2 = str.substring(0, index); - - if (sub != null && sub2 != null && sub.equals(sub2)) - return shExpMatch2(str.substring(index), shexp.substring(index)); - else - return false; - } - } - - /* extractAutoProxySetting is a function which takes a proxy-info-string - * which returned from the JavaScript function FindProxyForURL, and returns - * the corresponding proxy information. - * - * parameters : - * s [in] a string which contains all the proxy information - * - * out: - * ProxyInfo [out] ProxyInfo contains the corresponding proxy result. - * - * Notes: i) s contains all the proxy information in the form of - * "PROXY webcache1-cup:8080;SOCKS webcache2-cup". There are three - * possible values inside the string: - * a) "DIRECT" -- no proxy is used. - * b) "PROXY" -- Proxy is used. - * c) "SOCKS" -- SOCKS support is used. - * Information for each proxy settings are seperated by ';'. If a - * port number is specified, it is specified by using ':' following - * the proxy host. - * - */ - private ProxyInfo extractAutoProxySetting(String s) - { - if (s != null) - { - StringTokenizer st = new StringTokenizer(s, ";", false); - if (st.hasMoreTokens()) - { - String pattern = st.nextToken(); - - int i = pattern.indexOf("PROXY"); - - if (i != -1) { - // "PROXY" is specified - return new ProxyInfo(pattern.substring(i + 6)); - } - - i = pattern.indexOf("SOCKS"); - - if (i != -1) - { - // "SOCKS" is specified - return new ProxyInfo(null, pattern.substring(i + 6)); - } - } - } - - // proxy string contains 'DIRECT' or unrecognized text - return new ProxyInfo(null, -1); - } - - // The current default proxy handler - private static ProxyHandler handler; - - /* - *

- * @return the default proxy handler installed - *

- * - */ - public static ProxyHandler getDefaultProxyHandler() { - return handler; - } - - /** - *

- * Set the default proxy handler reference - *

- * - * @paran newDefault new default proxy handler - */ - public static void setDefaultProxyHandler(ProxyHandler newDefault) { - handler = newDefault; - } -} - - - - - - - - - - - diff --git a/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/jpav/AppletMessageHandler.java b/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/jpav/AppletMessageHandler.java deleted file mode 100644 index f33bd0224ef..00000000000 --- a/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/jpav/AppletMessageHandler.java +++ /dev/null @@ -1,113 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * The contents of this file are subject to the Mozilla Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is The Waterfall Java Plugin Module - * - * The Initial Developer of the Original Code is Sun Microsystems Inc - * Portions created by Sun Microsystems Inc are Copyright (C) 2001 - * All Rights Reserved. - * - * $Id: AppletMessageHandler.java,v 1.1.1.1 2001-05-10 18:12:28 edburns%acm.org Exp $ - * - * - * Contributor(s): - * - * Nikolay N. Igotti - */ - -package sun.jvmp.jpav; - -import java.util.ResourceBundle; -import java.util.MissingResourceException; -import java.text.MessageFormat; - -/** - * An hanlder of localized messages. - * - * @version 1.8, 03 Mar 1997 - * @author Koji Uno - */ -public class AppletMessageHandler { - private static ResourceBundle rb; - private String baseKey = null; - - static { - try { - rb = ResourceBundle.getBundle - ("sun.jvmp.resources.MsgAppletViewer"); - } catch (MissingResourceException e) { - //System.err.println(e.getMessage()); - //System.exit(1); - } - }; - - public AppletMessageHandler(String baseKey) { - this.baseKey = baseKey; - } - - public String getMessage(String key) { - return (String)rb.getString(getQualifiedKey(key)); - } - - public 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"; - msgobj[0] = arg; - return msgfmt.format(msgobj); - } - - public 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); - } - - public 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); - } - - public 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/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/jpav/ClassLoaderInfo.java b/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/jpav/ClassLoaderInfo.java deleted file mode 100644 index b5de69a8307..00000000000 --- a/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/jpav/ClassLoaderInfo.java +++ /dev/null @@ -1,187 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * The contents of this file are subject to the Mozilla Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is The Waterfall Java Plugin Module - * - * The Initial Developer of the Original Code is Sun Microsystems Inc - * Portions created by Sun Microsystems Inc are Copyright (C) 2001 - * All Rights Reserved. - * - * $Id: ClassLoaderInfo.java,v 1.1.1.1 2001-05-10 18:12:28 edburns%acm.org Exp $ - * - * - * Contributor(s): - * - * Nikolay N. Igotti - */ - -package sun.jvmp.jpav; - -/** - * This class keps track of information about active applet class loaders. - * The classloaders are identified by their codebase URL. - * - * We keep around a pool of recently used class loaders. - * - * @author Graham Hamilton - */ - -import sun.applet.*; -import java.util.Hashtable; -import java.util.Vector; -import java.net.URL; - -class ClassLoaderInfo { - private URL codebase; - private int references; - private Hashtable jars; - private boolean locked; - private static boolean initialized; - - // "infos" is a list of ClassLoaderInfos that are available for use. - private static Hashtable infos = new Hashtable(); - - // "zombies" is a list of ClassLoaderInfos that currently have - // a reference count of zero. We keep up to zombieLimit of these - // guys available for resurrection. The least recently used is - // at the front, the more recently used at the end. - // All entries in zombies are also in infos. - private static int zombieLimit; - private static Vector zombies = new Vector(); - - private static synchronized void initialize() { - if (initialized) { - return; - } - initialized = true; - zombieLimit = Integer.getInteger("javaplugin.jar.cache.size", 100).intValue(); - if (zombieLimit > 0) { - System.err.println("java_cache_enabled"); - } else { - System.err.println("java_cache_disabled"); - } - } - - /** - * Find ClassLoaderInfo for the given AppletPanel. - * - * If we don't have any active information, a new ClassLoaderInfo is - * created with an initial reference count of zero. - */ - static synchronized ClassLoaderInfo find(AppletPanel panel) { - initialize(); - URL codebase = panel.getCodeBase(); - //System.err.println("looking classloader for codebase:"+codebase); - ClassLoaderInfo result = (ClassLoaderInfo)infos.get(codebase); - if (result == null) { - // System.out.println("ClassLoaderCache: adding " + codebase); - result = new ClassLoaderInfo(codebase); - infos.put(codebase, result); - } else { - // We make sure this loader isn't on the zombies list. - zombies.removeElement(result); - } - return result; - } - - /** - * Add a retaining reference. - */ - synchronized void addReference() { - references++; - } - - /** - * Remove a retaining reference. If there are no references left - * then we put it on the zombies list. - */ - synchronized void removeReference() { - references--; - if (references < 0) { - throw new Error("negative ref count???"); - } - if (references == 0) { - addZombie(this); - } - } - - /** - * Add the given ClassLoaderInfo to the zomboies list. - * If there are too many zombies we get rid of some. - */ - private static synchronized void addZombie(ClassLoaderInfo cli) { - // Add the ClassLoaderInfo to the end of the zombies list. - zombies.addElement(cli); - // If there are too many zombies, kill the first one. - if (zombies.size() > zombieLimit) { - ClassLoaderInfo victim = (ClassLoaderInfo)zombies.elementAt(0); - // System.out.println("ClassLoaderCache: discarding " + victim.codebase); - zombies.removeElementAt(0); - infos.remove(victim.codebase); - AppletPanel.flushClassLoader(victim.codebase); - } - } - - private ClassLoaderInfo(URL codebase) { - references = 0; - this.codebase = codebase; - jars = new Hashtable(); - } - - synchronized void addJar(String name) { - jars.put(name, name); - } - - synchronized boolean hasJar(String name) { - if (jars.get(name) != null) { - return true; - } else { - return false; - } - } - - /* - * Flag and utility routines for recording whether local .jar files in lib/app/ - * have been loaded or not. This is used as a performance optimization - * so that hasJar() does not need to be checked against the filesystem - * each time an applet is loaded. - */ - - private boolean localJarsLoaded = false; - - public boolean getLocalJarsLoaded() { - return(localJarsLoaded); - } - - public void setLocalJarsLoaded(boolean loadedFlag) { - localJarsLoaded = loadedFlag; - } - - /** - * Acquire the lock. This is used to prevent two AppletPanels - * trying to classload JARs at the same time. - */ - public final synchronized void lock() throws InterruptedException { - while (locked) { - wait(); - } - locked = true; - } - - /** - * Release the lock. This allows other people do to classloading. - */ - public final synchronized void unlock() { - locked = false; - notifyAll(); - } -} diff --git a/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/jpav/CookieHandler.java b/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/jpav/CookieHandler.java deleted file mode 100644 index f7096d1ec3f..00000000000 --- a/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/jpav/CookieHandler.java +++ /dev/null @@ -1,39 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * The contents of this file are subject to the Mozilla Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is The Waterfall Java Plugin Module - * - * The Initial Developer of the Original Code is Sun Microsystems Inc - * Portions created by Sun Microsystems Inc are Copyright (C) 2001 - * All Rights Reserved. - * - * $Id: CookieHandler.java,v 1.1.1.1 2001-05-10 18:12:28 edburns%acm.org Exp $ - * - * - * Contributor(s): - * - * Nikolay N. Igotti - */ - -package sun.jvmp.jpav; - -import java.net.URL; - -public interface CookieHandler { - - /* getCookieInfo takes a particular URL and returns its cookie info. - */ - String getCookieInfo(URL u); -} - - - diff --git a/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/jpav/JavaPluginAVFactory.java b/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/jpav/JavaPluginAVFactory.java deleted file mode 100644 index 06208b68b81..00000000000 --- a/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/jpav/JavaPluginAVFactory.java +++ /dev/null @@ -1,287 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * The contents of this file are subject to the Mozilla Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is The Waterfall Java Plugin Module - * - * The Initial Developer of the Original Code is Sun Microsystems Inc - * Portions created by Sun Microsystems Inc are Copyright (C) 2001 - * All Rights Reserved. - * - * $Id: JavaPluginAVFactory.java,v 1.1.1.1 2001-05-10 18:12:28 edburns%acm.org Exp $ - * - * - * Contributor(s): - * - * Nikolay N. Igotti - */ - -package sun.jvmp.jpav; - -import sun.jvmp.*; -import sun.jvmp.applet.*; -import java.util.*; -import java.security.*; -import java.net.URL; -import java.awt.Frame; -import java.applet.Applet; -import java.rmi.server.RMISocketFactory; -import java.io.*; - -public class JavaPluginAVFactory implements sun.jvmp.ObjectFactory -{ - Vector cids; - Hashtable permsHash; - Permissions permsForAll; - boolean inited=false; - CodeSource codesource; - PluggableJVM jvm; - static JavaPluginAVFactory instance = null; - - - public static ObjectFactory getFactory(PluggableJVM jvm, - CodeSource codesource) - throws ComponentException - { - if (instance == null) - instance = new JavaPluginAVFactory(jvm, codesource); - return instance; - } - - protected JavaPluginAVFactory(PluggableJVM jvm, CodeSource codesource) - throws ComponentException - { - cids = new Vector(); - cids.add(WFAppletViewer.CID); - permsHash = new Hashtable(); - this.jvm = jvm; - this.codesource = codesource; - /* Permissions p = new Permissions(); - // XXX: correct? - //p.add(new java.security.AllPermission()); - permsHash.put(codesource, p); - */ - // XXX: rewrite with policy file - permsForAll = new Permissions(); - permsForAll.add(new java.lang.RuntimePermission("accessClassInPackage.sun.jvmp.jpav")); - permsForAll.add(new java.lang.RuntimePermission("accessClassInPackage.sun.jvmp.jpav.protocol.jdk12.http")); - permsForAll.add(new java.lang.RuntimePermission("accessClassInPackage.sun.jvmp.jpav.protocol.jdk12.ftp")); - permsForAll.add(new java.lang.RuntimePermission("accessClassInPackage.sun.jvmp.jpav.protocol.jdk12.jar")); - permsForAll.add(new java.lang.RuntimePermission("accessClassInPackage.sun.jvmp.jpav.protocol.jdk12.https")); - permsForAll.add(new java.lang.RuntimePermission("accessClassInPackage.sun.jvmp.jpav.protocol.jdk12.gopher")); - } - - public String getName() - { - return "Java Plugin applet viewer"; - } - - public Enumeration getCIDs() - { - return cids.elements(); - } - - public boolean handleConflict(String cid, - ObjectFactory f) - { - return false; - } - - public Object instantiate(String cid, Object arg) - { - AppletViewerArgs a; - try { - a = (AppletViewerArgs)arg; - } catch (ClassCastException e) { - return null; - } - if (!inited) initEnvironment(a.support); - if ((cid == null) || (!WFAppletViewer.CID.equals(cid)) || (a == null)) - return null; - return new TempAV(a.jvm, a.ctx, a.support, a.atts); - } - - public PermissionCollection getPermissions(CodeSource codesource) - { - // pity, but no clone() here - Permissions p = new Permissions(); - for (Enumeration e=permsForAll.elements(); e.hasMoreElements(); ) - p.add((Permission)e.nextElement()); - if (codesource != null) - { - Permissions p1 = (Permissions)permsHash.get(codesource); - if (p1 != null) - { - for (Enumeration e=p1.elements(); e.hasMoreElements(); ) - p.add((Permission)e.nextElement()); - } - } - return p; - } - - /** - * Prepare the enviroment for executing applets. - */ - void initEnvironment(BrowserSupport support) - { - // if we are already initialized, just return - if (inited) return; - // Get our internationalization resources. (Make sure this is - // done before calling showConsoleWindow.) - //rb = ResourceBundle.getBundle("sun.plugin.resources.Activator"); - //rb = null; - /** - * maybe move all this stuff to plugin.policy file - **/ - Properties props = new Properties(System.getProperties()); - // Define a number of standard properties - props.put("acl.read", "+"); - props.put("acl.read.default", ""); - props.put("acl.write", "+"); - props.put("acl.write.default", ""); - // Standard browser properties - props.put("browser", "sun.jvmp"); - //props.put("browser.version", theVersion); - props.put("browser.vendor", "Sun Microsystems Inc."); - props.put("http.agent", "Waterfall Applet Viewer/1.0"); - // Define which packages can NOT be accessed by applets - props.put("package.restrict.access.sun", "true"); - // - // This is important to set the netscape package access to "false". - // Some applets running in IE and NS will access - // netscape.javascript.JSObject sometimes. If we set this - // restriction to "true", these applets will not run at all. - // However, if we set it to "false", the applet may continue - // to run by catching an exception. - props.put("package.restrict.access.netscape", "false"); - - // Define which packages can NOT be extended by applets - props.put("package.restrict.definition.java", "true"); - props.put("package.restrict.definition.sun", "true"); - props.put("package.restrict.definition.netscape", "true"); - - // Define which properties can be read by applets. - // A property named by "key" can be read only when its twin - // property "key.applet" is true. The following ten properties - // are open by default. Any other property can be explicitly - // opened up by the browser user setting key.applet=true in - // ~/.java/properties. Or vice versa, any of the following can - // be overridden by the user's properties. - props.put("java.version.applet", "true"); - props.put("java.vendor.applet", "true"); - props.put("java.vendor.url.applet", "true"); - props.put("java.class.version.applet", "true"); - props.put("os.name.applet", "true"); - props.put("os.version.applet", "true"); - props.put("os.arch.applet", "true"); - props.put("file.separator.applet", "true"); - props.put("path.separator.applet", "true"); - props.put("line.separator.applet", "true"); - props.remove("proxyHost"); - props.remove("proxyPort"); - props.remove("http.proxyHost"); - props.remove("http.proxyPort"); - props.remove("https.proxyHost"); - props.remove("https.proxyPort"); - props.remove("ftpProxyHost"); - props.remove("ftpProxyPort"); - props.remove("ftpProxySet"); - props.remove("gopherProxyHost"); - props.remove("gopherProxyPort"); - props.remove("gopherProxySet"); - props.remove("socksProxyHost"); - props.remove("socksProxyPort"); - - // Set allow default user interaction in HTTP/HTTPS - java.net.URLConnection.setDefaultAllowUserInteraction(true); - - // Make sure proxy is detected on the fly in http, ftp and gopher. - ProxyHandler handler - = getDefaultProxyHandler(ActivatorAppletPanel.PROXY_TYPE_AUTOCONFIG, - null, - null, - support); - - try { - ActivatorProxyHandler.setDefaultProxyHandler(handler); - } catch(Throwable e) { - PluggableJVM.trace(e, PluggableJVM.LOG_WARNING); - } - - // Set RMI socket factory for proxy. - try { - RMISocketFactory.setSocketFactory(new RMIActivatorSocketFactory()); - } - catch (IOException e) { - } - System.setProperties(props); - inited=true; - } - - protected static ProxyHandler - getDefaultProxyHandler(int proxyType, - String proxyList, - String proxyOverride, - BrowserSupport ctx) - { - return new ActivatorProxyHandler(proxyType, - proxyList, - proxyOverride, - ctx); - } -} - -class TempAV implements WFAppletViewer -{ - ActivatorAppletPanel av; - TempAV(PluggableJVM jvm, WFAppletContext ctx, - BrowserSupport support, Hashtable atts) - { - av = new ActivatorAppletPanel(jvm, ctx, atts); - } - - public void startApplet() - { - av.appletStart(); - } - - public void stopApplet() - { - av.appletStop(); - } - - public void destroyApplet(int timeout) - { - av.onClose(timeout); - } - - public int getLoadingStatus() - { - return av.getLoadingStatus(); - } - - public void setDocumentBase(URL docbase) - { - av.setDocumentBase(docbase); - } - - public void setWindow(Frame f) - { - av.setWindow(f); - } - - public Applet getApplet() - { - return av.getApplet(); - } -}; - - diff --git a/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/jpav/ProxyHandler.java b/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/jpav/ProxyHandler.java deleted file mode 100644 index 534a25d69b7..00000000000 --- a/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/jpav/ProxyHandler.java +++ /dev/null @@ -1,41 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * The contents of this file are subject to the Mozilla Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is The Waterfall Java Plugin Module - * - * The Initial Developer of the Original Code is Sun Microsystems Inc - * Portions created by Sun Microsystems Inc are Copyright (C) 2001 - * All Rights Reserved. - * - * $Id: ProxyHandler.java,v 1.1.1.1 2001-05-10 18:12:28 edburns%acm.org Exp $ - * - * - * Contributor(s): - * - * Nikolay N. Igotti - */ - -package sun.jvmp.jpav; - -import java.net.URL; -import sun.jvmp.applet.ProxyInfo; - - -public interface ProxyHandler { - - /* getProxyInfo takes a particular URL and returns its proxy setting. - */ - ProxyInfo getProxyInfo(URL u); -} - - - diff --git a/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/jpav/RMIActivatorSocketFactory.java b/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/jpav/RMIActivatorSocketFactory.java deleted file mode 100644 index 1ebbecf8de4..00000000000 --- a/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/jpav/RMIActivatorSocketFactory.java +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * The contents of this file are subject to the Mozilla Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is The Waterfall Java Plugin Module - * - * The Initial Developer of the Original Code is Sun Microsystems Inc - * Portions created by Sun Microsystems Inc are Copyright (C) 2001 - * All Rights Reserved. - * - * $Id: RMIActivatorSocketFactory.java,v 1.1.1.1 2001-05-10 18:12:28 edburns%acm.org Exp $ - * - * - * Contributor(s): - * - * Nikolay N. Igotti - */ - -/* - * @(#)RMIPluginSocketFactory.java 1.8 97/01/22 - * - * Copyright (c) 1995, 1996 Sun Microsystems, Inc. All Rights Reserved. - * - * This software is the confidential and proprietary information of Sun - * Microsystems, Inc. ("Confidential Information"). You shall not - * disclose such Confidential Information and shall use it only in - * accordance with the terms of the license agreement you entered into - * with Sun. - * - * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE - * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE - * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES - * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING - * THIS SOFTWARE OR ITS DERIVATIVES. - * - * CopyrightVersion 1.1_beta - */ -package sun.jvmp.jpav; - -import sun.rmi.transport.proxy.RMIMasterSocketFactory; -import sun.rmi.transport.proxy.RMIHttpToPortSocketFactory; -import sun.rmi.transport.proxy.RMIHttpToCGISocketFactory; - -/** - * RMIPluginSocketFactory attempts to create a socket connection to the - * specified host using successively less efficient mechanisms - * until one succeeds. If the host is successfully connected to, - * the factory for the successful mechanism is stored in an internal - * hash table keyed by the host name, so that future attempts to - * connect to the same host will automatically use the same - * mechanism. - */ -public class RMIActivatorSocketFactory extends RMIMasterSocketFactory { - - /** - * Create a RMIActivatorSocketFactory object. Establish order of - * connection mechanisms to attempt on createSocket, if a direct - * socket connection fails. - */ - public RMIActivatorSocketFactory() - { - altFactoryList.addElement(new RMIHttpToPortSocketFactory()); - altFactoryList.addElement(new RMIHttpToCGISocketFactory()); - } -} - diff --git a/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/jpav/protocol/jdk12/ftp/Handler.java b/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/jpav/protocol/jdk12/ftp/Handler.java deleted file mode 100644 index c3ca20076ab..00000000000 --- a/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/jpav/protocol/jdk12/ftp/Handler.java +++ /dev/null @@ -1,94 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * The contents of this file are subject to the Mozilla Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is The Waterfall Java Plugin Module - * - * The Initial Developer of the Original Code is Sun Microsystems Inc - * Portions created by Sun Microsystems Inc are Copyright (C) 2001 - * All Rights Reserved. - * - * $Id: Handler.java,v 1.1.1.1 2001-05-10 18:12:29 edburns%acm.org Exp $ - * - * - * Contributor(s): - * - * Nikolay N. Igotti - */ - -package sun.jvmp.jpav.protocol.jdk12.ftp; - -import java.net.URL; -import java.io.IOException; -import sun.jvmp.jpav.protocol.jdk12.http.HttpURLConnection; -import java.util.Map; -import java.util.HashMap; -import sun.net.ftp.FtpClient; -import sun.net.www.protocol.ftp.*; -import sun.jvmp.applet.*; -import sun.jvmp.jpav.*; - -/** - * Open an ftp connection given a URL - */ -public class Handler extends java.net.URLStreamHandler { - - - public java.net.URLConnection openConnection(URL u) { - /* if set for proxy usage then go through the gopher code to get - * the url connection. - */ - ProxyHandler handler = ActivatorProxyHandler.getDefaultProxyHandler(); - ProxyInfo pinfo = null; - - if (handler != null) - pinfo = handler.getProxyInfo(u); - - try { - if (pinfo != null && pinfo.isProxyUsed()) - { - return new HttpURLConnection(u, pinfo.getProxy(), pinfo.getPort()); - } - else - { - /* make a direct ftp connection */ - return superOpenConnection(u); - } - } catch(IOException e) { - return superOpenConnection(u); - } - } - - - protected java.net.URLConnection superOpenConnection(URL u) { - /* if set for proxy usage then go through the http code to get */ - /* the url connection. Bad things will happen if a user and - * password are specified in the ftp url */ - try { - if (FtpClient.getUseFtpProxy()) { - String host = FtpClient.getFtpProxyHost(); - if (host != null && - host.length() > 0) { - return new sun.jvmp.jpav.protocol.jdk12.http.HttpURLConnection(u, host, - FtpClient.getFtpProxyPort()); - } - } - } catch(IOException e) { - } - - /* make a direct ftp connection */ - return new FtpURLConnection(u); - } - - protected int getDefaultPort() { - return 21; - } -} diff --git a/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/jpav/protocol/jdk12/gopher/Handler.java b/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/jpav/protocol/jdk12/gopher/Handler.java deleted file mode 100644 index f9191c2d836..00000000000 --- a/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/jpav/protocol/jdk12/gopher/Handler.java +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * The contents of this file are subject to the Mozilla Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is The Waterfall Java Plugin Module - * - * The Initial Developer of the Original Code is Sun Microsystems Inc - * Portions created by Sun Microsystems Inc are Copyright (C) 2001 - * All Rights Reserved. - * - * $Id: Handler.java,v 1.1.1.1 2001-05-10 18:12:30 edburns%acm.org Exp $ - * - * - * Contributor(s): - * - * Nikolay N. Igotti - */ - -package sun.jvmp.jpav.protocol.jdk12.gopher; - -import java.net.URL; -import java.io.IOException; -import sun.jvmp.jpav.protocol.jdk12.http.HttpURLConnection; -import sun.jvmp.applet.*; -import sun.jvmp.jpav.*; - -/** - * A class to handle the gopher protocol. - */ - -public class Handler extends sun.net.www.protocol.gopher.Handler { - - public java.net.URLConnection openConnection(URL u) throws IOException { - /* if set for proxy usage then go through the gopher code to get - * the url connection. - */ - ProxyHandler handler = ActivatorProxyHandler.getDefaultProxyHandler(); - ProxyInfo pinfo = null; - - if (handler != null) - pinfo = handler.getProxyInfo(u); - - try { - if (pinfo != null && pinfo.isProxyUsed()) - { - return new HttpURLConnection(u, pinfo.getProxy(), pinfo.getPort()); - } - else - { - /* make a direct gopher connection */ - return super.openConnection(u); - } - } catch(IOException e) { - return super.openConnection(u); - } - } -} - - diff --git a/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/jpav/protocol/jdk12/http/Handler.java b/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/jpav/protocol/jdk12/http/Handler.java deleted file mode 100644 index 9d04cc2067d..00000000000 --- a/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/jpav/protocol/jdk12/http/Handler.java +++ /dev/null @@ -1,49 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * The contents of this file are subject to the Mozilla Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is The Waterfall Java Plugin Module - * - * The Initial Developer of the Original Code is Sun Microsystems Inc - * Portions created by Sun Microsystems Inc are Copyright (C) 2001 - * All Rights Reserved. - * - * $Id: Handler.java,v 1.1.1.1 2001-05-10 18:12:30 edburns%acm.org Exp $ - * - * - * Contributor(s): - * - * Nikolay N. Igotti - */ - -package sun.jvmp.jpav.protocol.jdk12.http; - -import java.io.IOException; -import java.net.URL; - - -/** - * Open an http input stream given a URL - */ -public class Handler extends sun.net.www.protocol.http.Handler { - - /* - *

- * We use our protocol handler for JDK 1.2 to open the connection for - * the specified URL - *

- * - * @param URL the url to open - */ - public java.net.URLConnection openConnection(URL u) throws IOException { - return new HttpURLConnection(u, this); - } -} diff --git a/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/jpav/protocol/jdk12/http/HttpClient.java b/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/jpav/protocol/jdk12/http/HttpClient.java deleted file mode 100644 index c1c83c400f6..00000000000 --- a/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/jpav/protocol/jdk12/http/HttpClient.java +++ /dev/null @@ -1,97 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * The contents of this file are subject to the Mozilla Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is The Waterfall Java Plugin Module - * - * The Initial Developer of the Original Code is Sun Microsystems Inc - * Portions created by Sun Microsystems Inc are Copyright (C) 2001 - * All Rights Reserved. - * - * $Id: HttpClient.java,v 1.1.1.1 2001-05-10 18:12:30 edburns%acm.org Exp $ - * - * - * Contributor(s): - * - * Nikolay N. Igotti - */ - -package sun.jvmp.jpav.protocol.jdk12.http; - -import java.io.*; -import java.net.*; -import java.util.*; -import sun.net.NetworkClient; -import sun.net.ProgressEntry; -import sun.net.ProgressData; -import sun.net.www.MessageHeader; -import sun.net.www.HeaderParser; -import sun.net.www.MeteredStream; -import sun.misc.Regexp; -import sun.misc.RegexpPool; -import sun.jvmp.applet.ProxyInfo; -import sun.jvmp.jpav.*; - -public class HttpClient extends sun.net.www.http.HttpClient { - - /* This package-only CTOR should only be used for FTP piggy-backed on HTTP - * HTTP URL's that use this won't take advantage of keep-alive. - * Additionally, this constructor may be used as a last resort when the - * first HttpClient gotten through New() failed (probably b/c of a - * Keep-Alive mismatch). - * - * XXX That documentation is wrong ... it's not package-private any more - */ - public HttpClient(URL url, String proxy, int proxyPort) - throws IOException { - super (url, proxy, proxyPort); - } - - /* This class has no public constructor for HTTP. This method is used to - * get an HttpClient to the specifed URL. If there's currently an - * active HttpClient to that server/port, you'll get that one. - */ - public static HttpClient New(URL url, String proxy, int proxyPort) - throws IOException { - /* see if one's already around */ - HttpClient ret = (HttpClient) kac.get(url); - if (ret == null) { - ret = new HttpClient (url, proxy, proxyPort); // CTOR called openServer() - } else { - ret.url = url; - } - // don't know if we're keeping alive until we parse the headers - // for now, keepingAlive is false - return ret; - } - - /** - * Return a socket connected to the server, with any - * appropriate options pre-established - */ - protected Socket doConnect (String server, int port) - throws IOException, UnknownHostException { - - ProxyHandler handler = sun.jvmp.jpav.ActivatorProxyHandler.getDefaultProxyHandler(); - if (handler != null) - { - ProxyInfo pinfo = handler.getProxyInfo(url); - - if (pinfo != null && pinfo.isSocksUsed()) - { - // Use SOCKS !! - return new SocksSocket(server, port, pinfo.getSocksProxy(), pinfo.getSocksPort()); - } - } - - return super.doConnect(server, port); - } -} diff --git a/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/jpav/protocol/jdk12/http/HttpURLConnection.java b/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/jpav/protocol/jdk12/http/HttpURLConnection.java deleted file mode 100644 index af42ae99ddc..00000000000 --- a/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/jpav/protocol/jdk12/http/HttpURLConnection.java +++ /dev/null @@ -1,292 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * The contents of this file are subject to the Mozilla Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is The Waterfall Java Plugin Module - * - * The Initial Developer of the Original Code is Sun Microsystems Inc - * Portions created by Sun Microsystems Inc are Copyright (C) 2001 - * All Rights Reserved. - * - * $Id: HttpURLConnection.java,v 1.1.1.1 2001-05-10 18:12:30 edburns%acm.org Exp $ - * - * - * Contributor(s): - * - * Nikolay N. Igotti - */ - -package sun.jvmp.jpav.protocol.jdk12.http; - -import java.net.URL; -import java.net.ProtocolException; -import java.net.InetAddress; -import java.net.UnknownHostException; -import java.io.ByteArrayOutputStream; -import java.io.*; -import java.util.*; -import java.security.AccessController; -import java.security.PrivilegedExceptionAction; -import java.security.PrivilegedActionException; -import sun.net.*; -import sun.net.www.*; -import sun.jvmp.applet.*; -import sun.jvmp.jpav.*; - -public class HttpURLConnection extends - sun.net.www.protocol.http.HttpURLConnection { - - protected String proxy = null; - protected int proxyPort = -1; - - // This is to keep trace of the failedOnce value in the super class. Since failedOnce - // in the super one are declared private, we do some hack to get this value. - boolean failedOnce = false; - - public HttpURLConnection(URL u, Handler handler) - throws IOException { - super(u, handler); - } - - /** this constructor is used by other protocol handlers such as ftp - that want to use http to fetch urls on their behalf. */ - public HttpURLConnection(URL u, String host, int port) - throws IOException { - super(u, host, port); - this.proxy = host; - this.proxyPort = port; - } - - static CookieHandler handler = null; - - /* setCookieHandler is used only when a particular CookieHandler is required - * to determine the cookie value of a particular URL on the fly. - */ - public static void setCookieHandler(CookieHandler h) { - handler = h; - } - - protected boolean fromClassLoader() { - Exception e = new Exception(); - ByteArrayOutputStream ba = new ByteArrayOutputStream(); - PrintStream pos = new PrintStream(ba); - //e.printStackTrace(pos); - String trace = ba.toString(); - StringTokenizer tok = new StringTokenizer(trace); - String s = null; - while(tok.hasMoreTokens()) { - s = tok.nextToken(); - if ((s.startsWith("sun.applet.AppletClassLoader")) || - (s.startsWith("sun.applet.AppletResourceLoader")) || - (s.startsWith("sun.jvmp.jpav.ActivatorClassLoader"))) { - return true; - } - } - return false; - } - - protected boolean rightExt() { - String fname = url.getFile(); - return (fname.endsWith(".jar") || fname.endsWith(".class")); - } - - void privBlock() throws Exception { - try { - if ("http".equals(url.getProtocol()) && !failedOnce) { - http = HttpClient.New(url, proxy, proxyPort); - } else { - // make sure to construct new connection if first attempt failed - http = getProxiedClient(url, proxy, proxyPort); - } - ps = (PrintStream)http.getOutputStream(); - } catch (IOException e) { - throw e; - } - } - - // overridden in HTTPS subclass - - public synchronized void connect() throws IOException { - if (connected) - return; - - // Determine proxy setting for the connection - - if (proxy == null) { - ProxyInfo pinfo = null; - ProxyHandler proxyHandler = ActivatorProxyHandler.getDefaultProxyHandler(); - - if (proxyHandler!=null) { - pinfo = proxyHandler.getProxyInfo(url); - - if (pinfo != null) - { - proxy = pinfo.getProxy(); - proxyPort = pinfo.getPort(); - } - } - } - - // Check whether the applet is allowed to connect to the host. - // This is necessary because we will enable privilege to - // connect to the proxy - SecurityManager m = System.getSecurityManager(); - if (m != null) { - m.checkConnect(url.getHost(), url.getPort()); - } - - // Determine cookie value - if (handler != null) - { - // Use browser cookie only if the cookie has not - // been set by the applet. - if (getRequestProperty("cookie") == null) - { - String cookie = handler.getCookieInfo(url); - - if (cookie != null) - setRequestProperty("cookie", cookie); - } - } - - try { - AccessController.doPrivileged(new PrivilegedBlockAction(this)); - } catch (PrivilegedActionException e) { - IOException ioe = (IOException)e.getException(); - throw ioe; - } - - // Workaround for Mozilla bugs - String workaround = (String) java.security.AccessController.doPrivileged( - new sun.security.action.GetPropertyAction("mozilla.workaround")); - - if (workaround != null && workaround.equalsIgnoreCase("true")) - { - // Disable browser caching in Mozilla - setUseCaches(false); - } - else - { - // constructor to HTTP client calls openserver - setUseCaches(getUseCaches() && rightExt()); - } - - connected = true; - } - - private InputStream cacheStream = null; - - public synchronized InputStream getInputStream() throws IOException{ - if (!connected) - connect(); - if (useCaches) { - try { - // check if we are allowed to read files. If not, there is - // no point to caching. Now, we have no idea where the - // browser will put the file, so lets try to read - // java.home property - if (cacheStream != null) - return cacheStream; - - cacheStream = (InputStream) - AccessController.doPrivileged(new FileCreator(this)); - if (cacheStream==null) { - useCaches = false; - } else { - return cacheStream; - } - } catch (PrivilegedActionException e) { //IOException. fall through, and try - //remote - System.out.println("IO Exception, using remote copy"); - //e.printStackTrace(); - useCaches = false; - } catch (SecurityException e1) { - System.out.println("Security exception, using remote copy"); - useCaches = false; - } - } - return super.getInputStream(); - } - - /** - * Create a new HttpClient object, bypassing the cache of - * HTTP client objects/connections. - * - * @param url the URL being accessed - */ - protected sun.net.www.http.HttpClient getNewClient (URL url) - throws IOException { - - // This is a hack to get the failedOnce value. Since getNewClient is only called by the - // super class when failedOnce is true, we can obtain the failedOnce value this way. - failedOnce = true; - - return getProxiedClient(url, proxy, proxyPort); - } - - - /** - * Create a new HttpClient object, set up so that it uses - * per-instance proxying to the given HTTP proxy. This - * bypasses the cache of HTTP client objects/connections. - * - * @param url the URL being accessed - * @param proxyHost the proxy host to use - * @param proxyPort the proxy port to use - */ - protected sun.net.www.http.HttpClient getProxiedClient (URL url, String proxyHost, int proxyPort) - throws IOException { - return new HttpClient (url, proxyHost, proxyPort); - } - - /** - * Method to get an internationalized string from the Activator resource. - */ - public static String getMessage(String key) { - return key; - } - - // Localization strings. - private static ResourceBundle rb; - - class FileCreator implements PrivilegedExceptionAction { - HttpURLConnection conn; - - FileCreator(HttpURLConnection c) { - conn = c; - } - - public Object run() throws Exception { - - String fileName = null; //sun.plugin.CacheHandler.getCacheFile(conn.getURL()); - if (fileName!=null) - return new BufferedInputStream(new FileInputStream(fileName)); - else - return null; - } - } - - class PrivilegedBlockAction implements PrivilegedExceptionAction { - HttpURLConnection conn; - PrivilegedBlockAction(HttpURLConnection c) - { - conn = c; - } - - public Object run() throws Exception { - conn.privBlock(); - return null; - } - } - -} - - diff --git a/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/jpav/protocol/jdk12/http/SocksSocket.java b/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/jpav/protocol/jdk12/http/SocksSocket.java deleted file mode 100644 index 5f0264907c3..00000000000 --- a/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/jpav/protocol/jdk12/http/SocksSocket.java +++ /dev/null @@ -1,407 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * The contents of this file are subject to the Mozilla Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is The Waterfall Java Plugin Module - * - * The Initial Developer of the Original Code is Sun Microsystems Inc - * Portions created by Sun Microsystems Inc are Copyright (C) 2001 - * All Rights Reserved. - * - * $Id: SocksSocket.java,v 1.1.1.1 2001-05-10 18:12:31 edburns%acm.org Exp $ - * - * - * Contributor(s): - * - * Nikolay N. Igotti - */ - -/* - * @(#)SocksSocket.java 1.4 00/02/16 - * - * Copyright (c) 1995, 1996 Sun Microsystems, Inc. All Rights Reserved. - * - * This software is the confidential and proprietary information of Sun - * Microsystems, Inc. ("Confidential Information"). You shall not - * disclose such Confidential Information and shall use it only in - * accordance with the terms of the license agreement you entered into - * with Sun. - * - * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE - * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE - * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES - * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING - * THIS SOFTWARE OR ITS DERIVATIVES. - * - * CopyrightVersion 1.1_beta - * - * @author Stanley Man-Kit Ho - */ - -package sun.jvmp.jpav.protocol.jdk12.http; - -import java.io.ByteArrayOutputStream; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.IOException; -import java.net.InetAddress; -import java.net.UnknownHostException; -import java.net.Socket; -import java.net.SocketException; - -/** - * This class implements client sockets (also called just - * "sockets") through SOCKS. A socket is an endpoint for communication - * between two machines. - *

- * The actual work of the socket is performed by an instance of the - * SocketImpl class. An application, by changing - * the socket factory that creates the socket implementation, - * can configure itself to create sockets appropriate to the local - * firewall. - * - * @author Stanley Man-Kit Ho - * @version 1.00, 04/23/98 - * @see java.net.Socket - * @since JDK1.0 - */ -public class SocksSocket extends Socket { - - private Socket socket = null; - - /* SOCKS related constants */ - - private static final int SOCKS_PROTO_VERS = 4; - private static final int SOCKS_REPLY_VERS = 4; - - private static final int COMMAND_CONNECT = 1; - private static final int COMMAND_BIND = 2; - - private static final int REQUEST_GRANTED = 90; - private static final int REQUEST_REJECTED = 91; - private static final int REQUEST_REJECTED_NO_IDENTD = 92; - private static final int REQUEST_REJECTED_DIFF_IDENTS = 93; - - public static final int socksDefaultPort = 1080; - - InetAddress address = null; - int port = -1; - - /** - * Creates a stream socket and connects it to the specified port - * number on the named host using SOCKS. - *

- * If the application has specified a server socket factory, that - * factory's createSocketImpl method is called to create - * the actual socket implementation. Otherwise a "plain" socket is created. - * - * @param host the host name. - * @param port the port number. - * @param socksAddress the host name of the SOCKS server. - * @param socksPort the port number of the SOCKS server. - * @exception IOException if an I/O error occurs when creating the socket. - * @since JDK1.0 - */ - public SocksSocket(String host, int port, String socksAddress, int socksPort) - throws UnknownHostException, IOException - { - this(InetAddress.getByName(host), port, InetAddress.getByName(socksAddress), socksPort); - } - - /** - * Creates a stream socket and connects it to the specified port - * number at the specified IP address using SOCKS. - *

- * If the application has specified a socket factory, that factory's - * createSocketImpl method is called to create the - * actual socket implementation. Otherwise a "plain" socket is created. - * - * @param address the IP address. - * @param port the port number. - * @param socksAddress the IP address of the SOCKS server. - * @param socksPort the port number of the SOCKS server. - * @exception IOException if an I/O error occurs when creating the socket. - * @since JDK1.0 - */ - public SocksSocket(InetAddress address, int port, InetAddress socksAddress, int socksPort) throws IOException { - connect(address, port, socksAddress, socksPort); - } - - - /** - * Creates a socket and connects it to the specified address on - * the specified port using SOCKS v4. - * @param address the address - * @param port the specified port - * @param socksAddress the address of the SOCKS proxy - * @param socksPort the specified port of the SOCKS proxy - */ - private void connect(InetAddress address, int port, InetAddress socksAddress, int socksPort) throws IOException { - - if (socksPort == -1) - socksPort = socksDefaultPort; - - this.address = address; - this.port = port; - - if (socksAddress != null) - { - socket = new Socket(socksAddress, socksPort); - - /** - * Connect to the SOCKS server using the SOCKS connection protocol. - */ - sendSOCKSCommandPacket(COMMAND_CONNECT, address, port); - - int protoStatus = getSOCKSReply(); - - switch (protoStatus) { - case REQUEST_GRANTED: - // connection set up, return control to the socket client - return; - - case REQUEST_REJECTED: - case REQUEST_REJECTED_NO_IDENTD: - throw new SocketException("SOCKS server cannot conect to identd"); - - case REQUEST_REJECTED_DIFF_IDENTS: - throw new SocketException("User name does not match identd name"); - } - } - else - { - socket = new Socket(address, port); - } - } - - - /** - * Read the response from the socks server. Return the result code. - */ - private int getSOCKSReply() throws IOException { - InputStream in = getInputStream(); - byte response[] = new byte[8]; - int bytesReceived = 0; - int len = response.length; - - for (int attempts = 0; bytesReceived> 8) & 0xff); - byteStream.write((port >> 0) & 0xff); - - byte addressBytes[] = address.getAddress(); - byteStream.write(addressBytes, 0, addressBytes.length); - - String userName = (String) java.security.AccessController.doPrivileged( - new sun.security.action.GetPropertyAction("user.name")); - - byte userNameBytes[] = new byte[userName.length()]; - userName.getBytes(0, userName.length(), userNameBytes, 0); - - byteStream.write(userNameBytes, 0, userNameBytes.length); - byteStream.write(0); // null termination for user name - - return byteStream.toByteArray(); - } - - - /** - * Returns the address to which the socket is connected. - * - * @return the remote IP address to which this socket is connected. - * @since JDK1.0 - */ - public InetAddress getInetAddress() { - return address; - } - - /** - * Gets the local address to which the socket is bound. - * - * @since JDK1.1 - */ - public InetAddress getLocalAddress() { - return socket.getLocalAddress(); - } - - /** - * Returns the remote port to which this socket is connected. - * - * @return the remote port number to which this socket is connected. - * @since JDK1.0 - */ - public int getPort() { - return port; - } - - /** - * Returns the local port to which this socket is bound. - * - * @return the local port number to which this socket is connected. - * @since JDK1.0 - */ - public int getLocalPort() { - return socket.getLocalPort(); - } - - /** - * Returns an input stream for this socket. - * - * @return an input stream for reading bytes from this socket. - * @exception IOException if an I/O error occurs when creating the - * input stream. - * @since JDK1.0 - */ - public InputStream getInputStream() throws IOException { - return socket.getInputStream(); - } - - /** - * Returns an output stream for this socket. - * - * @return an output stream for writing bytes to this socket. - * @exception IOException if an I/O error occurs when creating the - * output stream. - * @since JDK1.0 - */ - public OutputStream getOutputStream() throws IOException { - return socket.getOutputStream(); - } - - /** - * Enable/disable TCP_NODELAY (disable/enable Nagle's algorithm). - * - * @since JDK1.1 - */ - public void setTcpNoDelay(boolean on) throws SocketException { - socket.setTcpNoDelay(on); - } - - /** - * Tests if TCP_NODELAY is enabled. - * - * @since JDK1.1 - */ - public boolean getTcpNoDelay() throws SocketException { - return socket.getTcpNoDelay(); - } - - /** - * Enable/disable SO_LINGER with the specified linger time. - * - * @since JDK1.1 - */ - public void setSoLinger(boolean on, int val) throws SocketException { - socket.setSoLinger(on, val); - } - - /** - * Returns setting for SO_LINGER. -1 returns implies that the - * option is disabled. - * - * @since JDK1.1 - */ - public int getSoLinger() throws SocketException { - return socket.getSoLinger(); - } - - /** - * Enable/disable SO_TIMEOUT with the specified timeout, in - * milliseconds. With this option set to a non-zero timeout, - * a read() call on the InputStream associated with this Socket - * will block for only this amount of time. If the timeout expires, - * a java.io.InterruptedIOException is raised, though the - * Socket is still valid. The option must be enabled - * prior to entering the blocking operation to have effect. The - * timeout must be > 0. - * A timeout of zero is interpreted as an infinite timeout. - * - * @since JDK 1.1 - */ - public synchronized void setSoTimeout(int timeout) throws SocketException { - socket.setSoTimeout(timeout); - } - - /** - * Returns setting for SO_TIMEOUT. 0 returns implies that the - * option is disabled (i.e., timeout of infinity). - * - * @since JDK1.1 - */ - public synchronized int getSoTimeout() throws SocketException { - return socket.getSoTimeout(); - } - - /** - * Closes this socket. - * - * @exception IOException if an I/O error occurs when closing this socket. - * @since JDK1.0 - */ - public synchronized void close() throws IOException { - socket.close(); - } - - /** - * Converts this socket to a String. - * - * @return a string representation of this socket. - * @since JDK1.0 - */ - public String toString() { - return "SocksSocket[addr=" + getInetAddress() + - ",port=" + getPort() + - ",localport=" + getLocalPort() + "]"; - } -} diff --git a/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/jpav/protocol/jdk12/https/BrowserHttpsInputStream.java b/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/jpav/protocol/jdk12/https/BrowserHttpsInputStream.java deleted file mode 100644 index 2fb819cf442..00000000000 --- a/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/jpav/protocol/jdk12/https/BrowserHttpsInputStream.java +++ /dev/null @@ -1,294 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * The contents of this file are subject to the Mozilla Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is The Waterfall Java Plugin Module - * - * The Initial Developer of the Original Code is Sun Microsystems Inc - * Portions created by Sun Microsystems Inc are Copyright (C) 2001 - * All Rights Reserved. - * - * $Id: BrowserHttpsInputStream.java,v 1.1.1.1 2001-05-10 18:12:32 edburns%acm.org Exp $ - * - * - * Contributor(s): - * - * Nikolay N. Igotti - */ - -/* - * @(#)BrowserHttpsInputStream.java 1.2 00/04/27 - * - * Copyright (c) 1996-1999 Sun Microsystems, Inc. All Rights Reserved. - * - * This software is the confidential and proprietary information of Sun - * Microsystems, Inc. ("Confidential Information"). You shall not - * disclose such Confidential Information and shall use it only in - * accordance with the terms of the license agreement you entered into - * with Sun. - * - * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE - * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE - * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES - * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING - * THIS SOFTWARE OR ITS DERIVATIVES. - * - * CopyrightVersion 1.0 - */ - -package sun.jvmp.jpav.protocol.jdk12.https; - -import java.net.URLConnection; -import java.io.IOException; -import java.io.InputStream; - - /** - * HTTPS URL input stream support. The intention here is to allow input from the - * server to be flushed prior to being closed. The browser API is used for reading - * https response input. - * - * @author R.H. Yang - */ -public -class BrowserHttpsInputStream extends java.io.InputStream -{ - // parent URLConnection - - BrowserHttpsURLConnection urlConnection; - - // seek pointer - - long seekPos; - - // "cookie" for native connection (handle/ptr/whatever) - - long nativeConnection; - - // stream state - - boolean open; - - - // Construct input stream attached to specified Https URL Connection - - public BrowserHttpsInputStream( BrowserHttpsURLConnection uc ) - throws IOException { - urlConnection = uc; - openStream(); - open = true; - } - - /** - * Reads the next byte of data from the input stream. The value byte is - * returned as an int in the range 0 to - * 255. If no byte is available because the end of the stream - * has been reached, the value -1 is returned. This method - * blocks until input data is available, the end of the stream is detected, - * or an exception is thrown. - * - *

A subclass must provide an implementation of this method. - * - * @return the next byte of data, or -1 if the end of the - * stream is reached. - * @exception IOException if an I/O error occurs. - */ - public synchronized int read() throws IOException { - ensureOpen(); - - if ( 0 == nativeConnection ) - return -1; - - - // Read from native code - - int numRead = readStream( temp, 0, 1 ); - - if ( 1 == numRead ) { - ++seekPos; - - return temp[0] & 0xff; - } else { - return numRead; - } - } - - /** - * Reads up to len bytes of data from the input stream into - * an array of bytes. An attempt is made to read as many as - * len bytes, but a smaller number may be read, possibly - * zero. The number of bytes actually read is returned as an integer. - * - *

This method blocks until input data is available, end of file is - * detected, or an exception is thrown. - * - *

If b is null, a - * NullPointerException is thrown. - * - *

If off is negative, or len is negative, or - * off+len is greater than the length of the array - * b, then an IndexOutOfBoundsException is - * thrown. - * - *

If len is zero, then no bytes are read and - * 0 is returned; otherwise, there is an attempt to read at - * least one byte. If no byte is available because the stream is at end of - * file, the value -1 is returned; otherwise, at least one - * byte is read and stored into b. - * - *

The first byte read is stored into element b[off], the - * next one into b[off+1], and so on. The number of bytes read - * is, at most, equal to len. Let k be the number of - * bytes actually read; these bytes will be stored in elements - * b[off] through b[off+k-1], - * leaving elements b[off+k] through - * b[off+len-1] unaffected. - * - *

In every case, elements b[0] through - * b[off] and elements b[off+len] through - * b[b.length-1] are unaffected. - * - *

If the first byte cannot be read for any reason other than end of - * file, then an IOException is thrown. In particular, an - * IOException is thrown if the input stream has been closed. - * - * @param b the buffer into which the data is read. - * @param off the start offset in array b - * at which the data is written. - * @param len the maximum number of bytes to read. - * @return the total number of bytes read into the buffer, or - * -1 if there is no more data because the end of - * the stream has been reached. - * @exception IOException if an I/O error occurs. - * @see java.io.InputStream#read() - */ - public synchronized int read(byte b[], int off, int len) throws IOException { - ensureOpen(); - - // Check for boundary conditions - - if (b == null) { - throw new NullPointerException(); - } else if ((off < 0) || (off > b.length) || (len < 0) || - ((off + len) > b.length) || ((off + len) < 0)) { - throw new IndexOutOfBoundsException(); - } else if (len == 0) { - return 0; - } - - if ( 0 == nativeConnection ) - return -1; - - - // Read from native code - - int numRead = readStream( b, off, len ); - - if ( numRead > 0 ) { - seekPos += numRead; - } - - return ( numRead > 0 ? numRead : -1 ); - } - - /** - * Skips n bytes of input. - * @param n the number of bytes to skip - * @return the actual number of bytes skipped. - * @exception IOException If an I/O error has occurred. - */ - // (Stolen from SocketInputStream) - public long skip(long numbytes) throws IOException { - synchronized( this ) { - ensureOpen(); - } - - if (numbytes <= 0) { - return 0; - } - long n = numbytes; - int buflen = (int) Math.min(1024, n); - byte data[] = new byte[buflen]; - while (n > 0) { - int r = read(data, 0, (int) Math.min((long) buflen, n)); - if (r < 0) { - break; - } - n -= r; - } - - synchronized( this ) { - seekPos += ( numbytes - n ); - } - return numbytes - n; - } - - /** - * Returns the number of bytes that can be read (or skipped over) from - * this input stream without blocking by the next caller of a method for - * this input stream. The next caller might be the same thread or or - * another thread. - * - * @return the number of bytes that can be read from this input stream - * without blocking. - * @exception IOException if an I/O error occurs. - */ - public synchronized int available() throws IOException { - ensureOpen(); - - return ( 0 == nativeConnection ? 0 : bytesAvailable() ); - } - - /** - * Closes this input stream and releases any system resources associated - * with the stream. - * - * @exception IOException if an I/O error occurs. - */ - public synchronized void close() throws IOException { - if (this.open == true) - { - closeStream(); - this.open = false; - } - } - - /** - * Check to make sure that this stream has not been closed - */ - private void ensureOpen() throws IOException { - if ( !this.open ) - throw new IOException("Stream closed"); - } - - protected void finalize() { - try { - close(); - } catch( IOException e ) { - } - } - - private byte temp[] = new byte[1]; // for single-byte reads - - - ////////////////////////////////////////////////////////////////////////// - // native implementation - - private native void openStream() throws IOException; - - private native int readStream( byte[] buf, int offs, int len ) - throws IOException; - - private native int bytesAvailable() throws IOException; - - private native void closeStream() throws IOException; -} - diff --git a/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/jpav/protocol/jdk12/https/BrowserHttpsOutputStream.java b/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/jpav/protocol/jdk12/https/BrowserHttpsOutputStream.java deleted file mode 100644 index 74866a12bd2..00000000000 --- a/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/jpav/protocol/jdk12/https/BrowserHttpsOutputStream.java +++ /dev/null @@ -1,134 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * The contents of this file are subject to the Mozilla Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is The Waterfall Java Plugin Module - * - * The Initial Developer of the Original Code is Sun Microsystems Inc - * Portions created by Sun Microsystems Inc are Copyright (C) 2001 - * All Rights Reserved. - * - * $Id: BrowserHttpsOutputStream.java,v 1.1.1.1 2001-05-10 18:12:32 edburns%acm.org Exp $ - * - * - * Contributor(s): - * - * Nikolay N. Igotti - */ - -/* - * @(#)BrowserHttpsOutputStream.java 1.5 00/04/27 - * - * Copyright (c) 1996-1997 Sun Microsystems, Inc. All Rights Reserved. - * - * This software is the confidential and proprietary information of Sun - * Microsystems, Inc. ("Confidential Information"). You shall not - * disclose such Confidential Information and shall use it only in - * accordance with the terms of the license agreement you entered into - * with Sun. - * - * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE - * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE - * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES - * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING - * THIS SOFTWARE OR ITS DERIVATIVES. - * - * CopyrightVersion 1.0 - */ - -package sun.jvmp.jpav.protocol.jdk12.https; - -import java.net.URLConnection; -import java.io.IOException; -import java.io.OutputStream; -import java.io.ByteArrayOutputStream; - -/** - * HTTPS URL POST support. This class buffers all the output stream - * until the stream is closed, then it will do a POST on the web - * server through the browser API. - * - * @author Stanley Man-Kit Ho - */ -public -class BrowserHttpsOutputStream extends java.io.ByteArrayOutputStream -{ - // URLConnection of the HTTPS connection. - BrowserHttpsURLConnection urlConnection = null; - - // Determine if the HTTPS output stream has been closed. - private boolean bConnected = false; - - /** - *

Create BrowserHttpsOutputStream object. - *

- * - * @param url URL of the HTTPS connection. - */ - public BrowserHttpsOutputStream(BrowserHttpsURLConnection urlConnection) - { - super(); - this.urlConnection = urlConnection; - this.bConnected = true; - } - - - /** - *

Create BrowserHttpsOutputStream object. - *

- * - * @param url URL of the HTTPS connection. - * @param size Size of the output stream buffer. - */ - public BrowserHttpsOutputStream(BrowserHttpsURLConnection urlConnection, int size) - { - super(size); - this.urlConnection = urlConnection; - this.bConnected = true; - } - - /** - *

Closes this output stream. - *

- */ - public synchronized void close() throws IOException - { - // Make sure the stream has not been closed multiple times - if (bConnected) - { - bConnected = false; - super.close(); - - byte[] postResponse; - byte[] buf = toByteArray(); - - if (buf == null) - postResponse = postHttpsURL(urlConnection, urlConnection.getURL().toString(), null, 0); - else - postResponse = postHttpsURL(urlConnection, urlConnection.getURL().toString(), buf, buf.length); - - if (urlConnection.getDoInput()) { - urlConnection.postResponse = postResponse; - urlConnection.postResponseReady = true; - } - } - } - - /** - *

Native code to call back into the browser to do a POST. - *

- * - * @param url URL of the HTTPS connection - * @param buf Data to post. - */ - private native byte[] postHttpsURL(URLConnection urlConnection, String url, byte[] buf, int length); -} diff --git a/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/jpav/protocol/jdk12/https/BrowserHttpsURLConnection.java b/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/jpav/protocol/jdk12/https/BrowserHttpsURLConnection.java deleted file mode 100644 index dbf3184af0d..00000000000 --- a/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/jpav/protocol/jdk12/https/BrowserHttpsURLConnection.java +++ /dev/null @@ -1,378 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * The contents of this file are subject to the Mozilla Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is The Waterfall Java Plugin Module - * - * The Initial Developer of the Original Code is Sun Microsystems Inc - * Portions created by Sun Microsystems Inc are Copyright (C) 2001 - * All Rights Reserved. - * - * $Id: BrowserHttpsURLConnection.java,v 1.1.1.1 2001-05-10 18:12:32 edburns%acm.org Exp $ - * - * - * Contributor(s): - * - * Nikolay N. Igotti - */ - -package sun.jvmp.jpav.protocol.jdk12.https; - -import java.net.*; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.PrintStream; -import sun.net.www.http.*; -import sun.net.www.MessageHeader; -import sun.net.www.protocol.http.*; -import java.util.Date; -import java.text.SimpleDateFormat; -import java.util.TimeZone; -import java.io.FileNotFoundException; -import java.io.BufferedInputStream; -import java.security.*; -import java.security.Permission; -import java.net.SocketPermission; - - -public -class BrowserHttpsURLConnection extends java.net.URLConnection -{ - /* - * Message Headers hold the request and response headers send along - * this HTTP request. This is currently available only in all IE version - */ - private MessageHeader responseHeaders = null; - private MessageHeader requestHeaders = null; - - /* - * Native object reference - */ - private long nativeConnection = 0; - - /* - * Initialize an HTTPS URLConnection ... could check that the URL - * is an "https" URL, and that the handler is also an HTTPS one, - * but that's established by other code in this package. - */ - - public Permission getPermission() throws IOException { - int port = url.getPort(); - port = port < 0 ? 80 : port; - String host = url.getHost() + ":" + port; - Permission permission = new SocketPermission(host, "connect"); - return permission; - } - - /* - * Initialize an HTTPS URLConnection ... could check that the URL - * is an "https" URL, and that the handler is also an HTTPS one, - * but that's established by other code in this package. - */ - public BrowserHttpsURLConnection (URL url) throws IOException { - super (url); - } - /** - * Implements the HTTP protocol handler's "connect" method, - * establishing an SSL connection to the server as necessary. - */ - public synchronized void connect () throws IOException { - if (connected) - return; - - // Check whether the applet is allowed to connect to the host. - // This is necessary because we will enable privilege to - // connect to the proxy - SecurityManager m = System.getSecurityManager(); - if (m != null) { - m.checkConnect(url.getHost(), url.getPort()); - } - - // Add the necessary headers if necessary - java.security.AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - packageRequestHeaders(); - return null; - } - }); - connected = true; - } - - /* - * @return the raw request headers for this URL connection - * - */ - private byte[] getRequestHeaders() { - - // Send the request headers - byte[] rawRequestHeaders = null; - if (requestHeaders!=null) { - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - PrintStream ps = new PrintStream(bos); - requestHeaders.print(ps); - ps.flush(); - rawRequestHeaders = bos.toByteArray(); - } - return rawRequestHeaders; - } - - /* - *

- * Sets the response headers from this URLConnection - *

- * - * @param rawResponseHeaders Response headers - */ - private void setResponseHeaders(byte[] rawResponseHeaders) { - - // Extract the response headers - if (rawResponseHeaders!=null) { - ByteArrayInputStream bis = - new ByteArrayInputStream(rawResponseHeaders); - try { - responseHeaders = new MessageHeader(bis); - } catch(IOException e) { - e.printStackTrace(); - } - } - } - - /** - *

- * Package the necessary request headers for this connection - *

- * - * @param mh MessageHeader that will contain all the request headers - * - */ - protected void packageRequestHeaders() { - - // Set the if modified since flag - if (getIfModifiedSince()!=0) { - TimeZone tz = TimeZone.getTimeZone("GMT"); - Date modTime = new Date(getIfModifiedSince()); - SimpleDateFormat df = new SimpleDateFormat(); - df.setTimeZone(tz); - setRequestProperty("If-Modified-Since", df.format(modTime)); - } - setRequestPropertyIfNotSet("Content-Type", "application/x-www-form-urlencoded"); - } - - /** - * Returns the value of the specified header field. Names of - * header fields to pass to this method can be obtained from - * getHeaderFieldKey. - * - * @param name the name of a header field. - * @return the value of the named header field, or null - * if there is no such field in the header. - * @see java.net.URLConnection#getHeaderFieldKey(int) - * @since JDK1.0 - */ - public String getHeaderField(String name) { - if (responseHeaders!=null) - return responseHeaders.findValue(name); - return null; - } - - /** - * Returns the key for the nth header field. - * - * @param n an index. - * @return the key for the nth header field, - * or null if there are fewer than n - * fields. - * @since JDK1.0 - */ - public String getHeaderFieldKey(int n) { - if (responseHeaders!=null) - return responseHeaders.getKey(n); - return null; - } - - /** - * Returns the value for the nth header field. - * It returns null if there are fewer than - * n fields. - *

- * This method can be used in conjunction with the - * getHeaderFieldKey method to iterate through all - * the headers in the message. - * - * @param n an index. - * @return the value of the nth header field. - * @see java.net.URLConnection#getHeaderFieldKey(int) - * @since JDK1.0 - */ - public String getHeaderField(int n) { - if (responseHeaders!=null) - return responseHeaders.getValue(n); - return null; - } - - /** - * Sets the general request property. - * - * @param key the keyword by which the request is known - * (e.g., "accept"). - * @param value the value associated with it. - */ - public synchronized void setRequestProperty(String key, String value) { - if (connected) - throw new IllegalAccessError("Already connected"); - // Create the requests holder if necessary - if (requestHeaders==null) { - requestHeaders= new MessageHeader(); - } - requestHeaders.set(key, value); - } - - public synchronized void setRequestPropertyIfNotSet(String key, String value -) { - if (connected) - throw new IllegalAccessError("Already connected"); - - // Create the requests holder if necessary - if (requestHeaders==null) { - requestHeaders= new MessageHeader(); - } - requestHeaders.setIfNotSet(key, value); - } - - /** - * Returns the value of the named general request property for this - * connection. - * - * @return the value of the named general request property for this - * connection. - */ - public String getRequestProperty(String key) { - if (connected) - throw new IllegalAccessError("Already connected"); - - if (requestHeaders!=null) - return requestHeaders.findValue(key); - return null; - } - - /** - * Returns an input stream that reads from this open connection. - * - * @return an input stream that reads from this open connection. - * @exception IOException if an I/O error occurs while - * creating the input stream. - * @exception UnknownServiceException if the protocol does not support - * input. - * @since JDK1.0 - */ - public InputStream getInputStream() throws IOException - { - if (!doInput) - throw new ProtocolException("Cannot read from URLConnection" - + " if doInput=false (call setDoInput(true))"); - - if (!connected) - connect(); - - if (ins == null) - { - byte buffer[] = null; - - // If we are in input/output mode, we might just want the response - // from a POST. - if (doOutput) { - if (!postResponseReady) - throw new UnknownServiceException("Input from HTTPS not expected until OutputStream is closed"); - - buffer = postResponse; - postResponse=null; - - // If null comes back then probably the URL wasn't found. - - if ( null == buffer ) - throw new FileNotFoundException( getURL().toString() ); - - ins = new ByteArrayInputStream( buffer ); - } else { - ins = new BufferedInputStream( new BrowserHttpsInputStream( this - ) ); - } - - // Check if we have response headers, if we don't we are going to - // enter some heuristic values for the headers we can - if (responseHeaders == null) - responseHeaders = new MessageHeader(); - - String contentType= getHeaderField("Content-Type"); - - if (contentType==null) { - try { - contentType = guessContentTypeFromStream(ins); - } catch(java.io.IOException e) { - } - if (contentType == null) { - if (url.getFile().endsWith("/")) { - contentType = "text/html"; - } else { - contentType = guessContentTypeFromName(url.getFile()); - } - if (contentType == null) - contentType = "content/unknown"; - } - responseHeaders.add("Content-Type", contentType); - } - - if ( null != buffer ) - responseHeaders.setIfNotSet("Content-Length",String.valueOf(buffer.length)); - } - - return ins; - } - - InputStream ins = null; - - OutputStream outs = null; - - /** - * Returns an output stream that writes to this connection. - * - * @return an output stream that writes to this connection. - * @exception IOException if an I/O error occurs while - * creating the output stream. - * @exception UnknownServiceException if the protocol does not support - * output. - * @since JDK1.0 - */ - public OutputStream getOutputStream() throws IOException { - - if (!doOutput) - throw new ProtocolException("cannot write to a URLConnection" - + " if doOutput=false - call setDoOutput(true)"); - - if (ins!=null) - throw new ProtocolException("Cannot write output after reading input."); - - if (!connected) - connect(); - - if (outs == null) - outs = new BrowserHttpsOutputStream(this); - - return outs; - } - - - byte[] postResponse = null; - boolean postResponseReady = false; -} diff --git a/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/jpav/protocol/jdk12/https/Handler.java b/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/jpav/protocol/jdk12/https/Handler.java deleted file mode 100644 index 054f64ffe47..00000000000 --- a/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/jpav/protocol/jdk12/https/Handler.java +++ /dev/null @@ -1,84 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * The contents of this file are subject to the Mozilla Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is The Waterfall Java Plugin Module - * - * The Initial Developer of the Original Code is Sun Microsystems Inc - * Portions created by Sun Microsystems Inc are Copyright (C) 2001 - * All Rights Reserved. - * - * $Id: Handler.java,v 1.1.1.1 2001-05-10 18:12:32 edburns%acm.org Exp $ - * - * - * Contributor(s): - * - * Nikolay N. Igotti - */ - -/* - * @(#)Handler.java 1.44 96/11/24 - * - * Copyright (c) 1995, 1996 Sun Microsystems, Inc. All Rights Reserved. - * - * This software is the confidential and proprietary information of Sun - * Microsystems, Inc. ("Confidential Information"). You shall not - * disclose such Confidential Information and shall use it only in - * accordance with the terms of the license agreement you entered into - * with Sun. - * - * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE - * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE - * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES - * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING - * THIS SOFTWARE OR ITS DERIVATIVES. - * - * CopyrightVersion 1.3 - * - * Java Plug-in - * - * @author Jerome Dochez - */ - -/*- - * HTTP stream opener - */ - -package sun.jvmp.jpav.protocol.jdk12.https; - -import java.io.IOException; -import java.net.URL; - -/** open an http input stream given a URL */ -public class Handler extends sun.jvmp.jpav.protocol.jdk12.http.Handler { - - /* - *

- * Delegate to the Https connection - *

- */ - public java.net.URLConnection openConnection(URL u) throws IOException { - - /* for now, SSL export is legal, so this extension can be presented */ - /* - try { - // Try if SSL extension is installed. - Class sslSession = Class.forName("javax.net.ssl.SSLSession"); - return new HttpsURLConnection(u, this); - } - catch (Throwable e) { - // else use browser HTTPS support. - return new BrowserHttpsURLConnection(u); - } */ - return new BrowserHttpsURLConnection(u); - } -} diff --git a/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/jpav/protocol/jdk12/jar/Handler.java b/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/jpav/protocol/jdk12/jar/Handler.java deleted file mode 100644 index da0e91b986f..00000000000 --- a/mozilla/java/pluggable-jvm/wf/java/sun/jvmp/jpav/protocol/jdk12/jar/Handler.java +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * The contents of this file are subject to the Mozilla Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is The Waterfall Java Plugin Module - * - * The Initial Developer of the Original Code is Sun Microsystems Inc - * Portions created by Sun Microsystems Inc are Copyright (C) 2001 - * All Rights Reserved. - * - * $Id: Handler.java,v 1.1.1.1 2001-05-10 18:12:32 edburns%acm.org Exp $ - * - * - * Contributor(s): - * - * Nikolay N. Igotti - */ - -/* - * @(#)Handler.java 1.1 99/08/17 - * - * Copyright © 1999 by Sun Microsystems, Inc., - * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. - * All rights reserved. - * - * This software is the confidential and proprietary information - * of Sun Microsystems, Inc. ("Confidential Information"). You - * shall not disclose such Confidential Information and shall use - * it only in accordance with the terms of the license agreement - * you entered into with Sun. - */ - -package sun.jvmp.jpav.protocol.jdk12.jar; - -/* - * Jar URL Handler for plugin - */ -public class Handler extends sun.net.www.protocol.jar.Handler { -}