JarURLConnection.java (getCertificates): New method from Classpath.
* java/net/JarURLConnection.java (getCertificates): New method
from Classpath.
* java/net/URLClassLoader.java (URLClassLoader): Extends
SecureClassLoader.
(definePackage): New method from Classpath.
(getPermissions): Likewise.
(newInstance): Likewise.
(findClass): Construct CodeSource for new class (from Classpath).
* java/net/SocketImpl.java (shutdownInput, shutdownOutput): New
methods.
* java/net/URL.java (getUserInfo): New method.
(set(String,String,int,String,String,String,String,String)): New
method.
* java/net/PlainSocketImpl.java (_Jv_SO_KEEPALIVE_): Define.
(shutdownInput, shutdownOutput): Declare.
* java/net/PlainDatagramSocketImpl.java (_Jv_SO_KEEPALIVE_):
Define.
* java/net/natPlainSocketImpl.cc (setOption): Handle keepalive.
(getOption): Likewise.
(shutdownInput): New method.
(shutdownOutput): Likewise.
* java/net/natPlainDatagramSocketImpl.cc (setOption): Handle
keepalive.
(getOption): Likewise.
* java/net/SocketOptions.java (SO_KEEPALIVE): New constant.
* java/net/Socket.java (setKeepAlive): New method.
(getKeepAlive): Likewise.
(shutdownInput, shutdownOutput): New methods.
From-SVN: r56685
2002-08-30 20:16:00 +02:00
|
|
|
/* Copyright (C) 1999, 2000, 2002 Free Software Foundation
|
1999-08-18 16:16:42 +02:00
|
|
|
|
|
|
|
This file is part of libgcj.
|
|
|
|
|
|
|
|
This software is copyrighted work licensed under the terms of the
|
|
|
|
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
|
|
|
|
details. */
|
|
|
|
|
|
|
|
package java.net;
|
|
|
|
|
|
|
|
import java.io.*;
|
|
|
|
import java.util.jar.*;
|
2000-11-26 04:58:56 +01:00
|
|
|
import java.util.Enumeration;
|
1999-08-18 16:16:42 +02:00
|
|
|
import java.util.Vector;
|
JarURLConnection.java (getCertificates): New method from Classpath.
* java/net/JarURLConnection.java (getCertificates): New method
from Classpath.
* java/net/URLClassLoader.java (URLClassLoader): Extends
SecureClassLoader.
(definePackage): New method from Classpath.
(getPermissions): Likewise.
(newInstance): Likewise.
(findClass): Construct CodeSource for new class (from Classpath).
* java/net/SocketImpl.java (shutdownInput, shutdownOutput): New
methods.
* java/net/URL.java (getUserInfo): New method.
(set(String,String,int,String,String,String,String,String)): New
method.
* java/net/PlainSocketImpl.java (_Jv_SO_KEEPALIVE_): Define.
(shutdownInput, shutdownOutput): Declare.
* java/net/PlainDatagramSocketImpl.java (_Jv_SO_KEEPALIVE_):
Define.
* java/net/natPlainSocketImpl.cc (setOption): Handle keepalive.
(getOption): Likewise.
(shutdownInput): New method.
(shutdownOutput): Likewise.
* java/net/natPlainDatagramSocketImpl.cc (setOption): Handle
keepalive.
(getOption): Likewise.
* java/net/SocketOptions.java (SO_KEEPALIVE): New constant.
* java/net/Socket.java (setKeepAlive): New method.
(getKeepAlive): Likewise.
(shutdownInput, shutdownOutput): New methods.
From-SVN: r56685
2002-08-30 20:16:00 +02:00
|
|
|
import java.security.CodeSource;
|
|
|
|
import java.security.SecureClassLoader;
|
|
|
|
import java.security.PermissionCollection;
|
|
|
|
import java.security.cert.Certificate;
|
1999-08-18 16:16:42 +02:00
|
|
|
|
BindException.java, [...]: add/update of some @since/@deprecated
2002-08-27 Michael Koch <konqueror@gmx.de>
* java/net/BindException.java,
java/net/JarURLConnection.java,
java/net/FileNameMap.java,
java/net/HttpURLConnection.java,
java/net/InetSocketAddress.java,
java/net/DatagramPacket.java,
java/net/DatagramSocket.java,
java/net/DatagramSocketImpl.java,
java/net/MulticastSocket.java,
java/net/PasswordAuthentication.java,
java/net/ServerSocket.java,
java/net/Socket.java,
java/net/URLClassLoader.java,
java/net/URLConnection.java: add/update of some @since/@deprecated
From-SVN: r56608
2002-08-27 19:47:27 +02:00
|
|
|
/**
|
|
|
|
* @since 1.2
|
|
|
|
*/
|
JarURLConnection.java (getCertificates): New method from Classpath.
* java/net/JarURLConnection.java (getCertificates): New method
from Classpath.
* java/net/URLClassLoader.java (URLClassLoader): Extends
SecureClassLoader.
(definePackage): New method from Classpath.
(getPermissions): Likewise.
(newInstance): Likewise.
(findClass): Construct CodeSource for new class (from Classpath).
* java/net/SocketImpl.java (shutdownInput, shutdownOutput): New
methods.
* java/net/URL.java (getUserInfo): New method.
(set(String,String,int,String,String,String,String,String)): New
method.
* java/net/PlainSocketImpl.java (_Jv_SO_KEEPALIVE_): Define.
(shutdownInput, shutdownOutput): Declare.
* java/net/PlainDatagramSocketImpl.java (_Jv_SO_KEEPALIVE_):
Define.
* java/net/natPlainSocketImpl.cc (setOption): Handle keepalive.
(getOption): Likewise.
(shutdownInput): New method.
(shutdownOutput): Likewise.
* java/net/natPlainDatagramSocketImpl.cc (setOption): Handle
keepalive.
(getOption): Likewise.
* java/net/SocketOptions.java (SO_KEEPALIVE): New constant.
* java/net/Socket.java (setKeepAlive): New method.
(getKeepAlive): Likewise.
(shutdownInput, shutdownOutput): New methods.
From-SVN: r56685
2002-08-30 20:16:00 +02:00
|
|
|
public class URLClassLoader extends SecureClassLoader
|
1999-08-18 16:16:42 +02:00
|
|
|
{
|
|
|
|
// The URLStreamHandlerFactory
|
|
|
|
URLStreamHandlerFactory factory = null;
|
|
|
|
|
|
|
|
// `path' contains simply the URL's we're using for the searching.
|
|
|
|
private Vector path;
|
|
|
|
|
2000-08-20 19:49:12 +02:00
|
|
|
// If path[n] is a zip/jar, then this holds a JarURLConnection for
|
|
|
|
// that thing, otherwise, path[n] is null.
|
1999-08-18 16:16:42 +02:00
|
|
|
private Vector info;
|
|
|
|
|
|
|
|
private URLStreamHandler getHandler0 (String protocol)
|
|
|
|
{
|
|
|
|
if (factory != null)
|
|
|
|
return factory.createURLStreamHandler(protocol);
|
|
|
|
else
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2002-09-25 Michael Koch <konqueror@gmx.de>
* java/net/DatagramPacket
(DatagramPacket): Exception documentation added.
(setData): Likewise.
(setSocketAddress): Likewise.
* java/net/DatagramSocketImpl.java
(peek): Documentation addded.
(peekData): Documentation addded.
(send): Documentation addded.
(receive): Documentation addded.
(connect): New method.
(disconnect): New method.
(joinGroup): New abstract method.
(leaveGroup): New abstract method.
* java/net/InetSocketAddress.java
(InetSocketAddress): Documentation added.
(equals): final keyword added.
(getAddress): final keyword added.
(getHostName): final keyword added.
(getPort): final keyword added.
(hashCode): final keyword added.
(isUnresolved): final keyword added.
* java/net/MulticastSocket.java
(MulticastSocket): Documentation added.
(MulticastSocket): New method.
(joinGroup): Documentation added.
(joinGroup): New method.
(leaveGroup): Documentation added.
(leaveGroup): New method.
(send): Documentation added.
* java/net/NetworkInterface.java
(getByName): Documentation added.
(getByInetAddress): Documentation added.
(getNetworkInterfaces): Documentation added.
* java/net/PlainDatagramSocketImpl.java
(connect): New method.
(disconnect): New method.
* java/net/SocketImpl.java
(create): Documentation added.
(shutdownInput): Convert public to protected, as it always was.
(shutdownOutput): Convert public to protected, as it always was.
* java/net/SocketOptions.java
(whole file): Reintented.
* java/net/URLClassLoader.java
(URLClassLoader): SecurityManager check added, documentation added.
(findResources): Documentation added.
(findClass): Documentation added.
(newInstance): More correct method arguments.
* java/net/URLConnection.java
(connect): Documentation added.
(getContent): Documentation added.
(getPermission): Documentation added.
(getInputStream): Documentation added.
(getOutputStream): Documentation added.
(setDoInput): Throw correct exception, documentation added.
(setDoOutput): Throw correct exception, documentation added.
(setAllowUserInteraction): Throw correct exception, documentation added.
(setUseCaches): Throw correct exception, documentation added.
(setIfModifiedSince): Throw correct exception, documentation added.
(setRequestProperty): Throw exception, documentation added.
(addRequestProperty): Throw exception, documentation added.
(getRequestProperty): Throw exception, documentation added.
(getRequestProperties): Documentation added.
(setContentHandlerFactory): Documentation added.
(guessContentTypeFromName): protected to public.
(setFileNameMap): Documentation added.
* java/net/URLDecoder.java
(URLDecoder): New method.
(decode): Documentation added.
(whole file): Reindented.
* java/net/URLEncoder.java
(encode): Documentation added.
* java/net/natPlainDatagramSocketImpl.cc
(connect): New method.
(disconnect): New method.
* javax/naming/RefAddr:
(addrType): addrType was never final.
(equals): Fix typo in method name.
* javax/naming/BinaryRefAddr:
(equals): Fix typo in method name.
From-SVN: r57487
2002-09-25 07:05:07 +02:00
|
|
|
/**
|
|
|
|
* Createa a new URL class loader object
|
|
|
|
*
|
|
|
|
* @exception SecurityException If a security manager exists and its
|
|
|
|
* checkCreateClassLoader method doesn't allow creation of a class loader
|
|
|
|
*/
|
1999-08-18 16:16:42 +02:00
|
|
|
public URLClassLoader (URL[] urls)
|
|
|
|
{
|
|
|
|
this (urls, null, null);
|
|
|
|
}
|
2002-09-25 Michael Koch <konqueror@gmx.de>
* java/net/DatagramPacket
(DatagramPacket): Exception documentation added.
(setData): Likewise.
(setSocketAddress): Likewise.
* java/net/DatagramSocketImpl.java
(peek): Documentation addded.
(peekData): Documentation addded.
(send): Documentation addded.
(receive): Documentation addded.
(connect): New method.
(disconnect): New method.
(joinGroup): New abstract method.
(leaveGroup): New abstract method.
* java/net/InetSocketAddress.java
(InetSocketAddress): Documentation added.
(equals): final keyword added.
(getAddress): final keyword added.
(getHostName): final keyword added.
(getPort): final keyword added.
(hashCode): final keyword added.
(isUnresolved): final keyword added.
* java/net/MulticastSocket.java
(MulticastSocket): Documentation added.
(MulticastSocket): New method.
(joinGroup): Documentation added.
(joinGroup): New method.
(leaveGroup): Documentation added.
(leaveGroup): New method.
(send): Documentation added.
* java/net/NetworkInterface.java
(getByName): Documentation added.
(getByInetAddress): Documentation added.
(getNetworkInterfaces): Documentation added.
* java/net/PlainDatagramSocketImpl.java
(connect): New method.
(disconnect): New method.
* java/net/SocketImpl.java
(create): Documentation added.
(shutdownInput): Convert public to protected, as it always was.
(shutdownOutput): Convert public to protected, as it always was.
* java/net/SocketOptions.java
(whole file): Reintented.
* java/net/URLClassLoader.java
(URLClassLoader): SecurityManager check added, documentation added.
(findResources): Documentation added.
(findClass): Documentation added.
(newInstance): More correct method arguments.
* java/net/URLConnection.java
(connect): Documentation added.
(getContent): Documentation added.
(getPermission): Documentation added.
(getInputStream): Documentation added.
(getOutputStream): Documentation added.
(setDoInput): Throw correct exception, documentation added.
(setDoOutput): Throw correct exception, documentation added.
(setAllowUserInteraction): Throw correct exception, documentation added.
(setUseCaches): Throw correct exception, documentation added.
(setIfModifiedSince): Throw correct exception, documentation added.
(setRequestProperty): Throw exception, documentation added.
(addRequestProperty): Throw exception, documentation added.
(getRequestProperty): Throw exception, documentation added.
(getRequestProperties): Documentation added.
(setContentHandlerFactory): Documentation added.
(guessContentTypeFromName): protected to public.
(setFileNameMap): Documentation added.
* java/net/URLDecoder.java
(URLDecoder): New method.
(decode): Documentation added.
(whole file): Reindented.
* java/net/URLEncoder.java
(encode): Documentation added.
* java/net/natPlainDatagramSocketImpl.cc
(connect): New method.
(disconnect): New method.
* javax/naming/RefAddr:
(addrType): addrType was never final.
(equals): Fix typo in method name.
* javax/naming/BinaryRefAddr:
(equals): Fix typo in method name.
From-SVN: r57487
2002-09-25 07:05:07 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Createa a new URL class loader object
|
|
|
|
*
|
|
|
|
* @exception SecurityException If a security manager exists and its
|
|
|
|
* checkCreateClassLoader method doesn't allow creation of a class loader
|
|
|
|
*/
|
1999-08-18 16:16:42 +02:00
|
|
|
public URLClassLoader (URL[] urls, ClassLoader parent)
|
|
|
|
{
|
|
|
|
this (urls, parent, null);
|
|
|
|
}
|
|
|
|
|
2000-11-26 04:58:56 +01:00
|
|
|
// A File URL may actually be a Jar URL. Convert if possible.
|
|
|
|
private URL jarFileize (URL url)
|
|
|
|
{
|
|
|
|
if (! url.getProtocol ().equals ("jar"))
|
|
|
|
{
|
|
|
|
String f = url.getFile ();
|
|
|
|
|
|
|
|
// If it ends with '/' we'll take it for a directory,
|
|
|
|
// otherwise it's a jar file. This is how JDK 1.2 defines
|
|
|
|
// it, so we will not try to be smart here.
|
|
|
|
if (f.charAt (f.length ()-1) != '/')
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
url = new URL ("jar", "", -1, (url.toExternalForm ())+"!/",
|
|
|
|
getHandler0 ("jar"));
|
|
|
|
}
|
|
|
|
catch (MalformedURLException x)
|
|
|
|
{
|
|
|
|
/* ignore */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return url;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void addURL (URL url)
|
|
|
|
{
|
|
|
|
JarURLConnection conn = null;
|
|
|
|
|
|
|
|
// Convert a Jar File URL into Jar URL if possible.
|
|
|
|
url = jarFileize (url);
|
|
|
|
|
|
|
|
path.addElement (url);
|
|
|
|
|
|
|
|
if (url.getProtocol ().equals ("jar"))
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
conn = (JarURLConnection) url.openConnection ();
|
|
|
|
}
|
|
|
|
catch (java.io.IOException x)
|
|
|
|
{
|
|
|
|
/* ignore */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
info.addElement (conn);
|
|
|
|
}
|
|
|
|
|
2002-09-25 Michael Koch <konqueror@gmx.de>
* java/net/DatagramPacket
(DatagramPacket): Exception documentation added.
(setData): Likewise.
(setSocketAddress): Likewise.
* java/net/DatagramSocketImpl.java
(peek): Documentation addded.
(peekData): Documentation addded.
(send): Documentation addded.
(receive): Documentation addded.
(connect): New method.
(disconnect): New method.
(joinGroup): New abstract method.
(leaveGroup): New abstract method.
* java/net/InetSocketAddress.java
(InetSocketAddress): Documentation added.
(equals): final keyword added.
(getAddress): final keyword added.
(getHostName): final keyword added.
(getPort): final keyword added.
(hashCode): final keyword added.
(isUnresolved): final keyword added.
* java/net/MulticastSocket.java
(MulticastSocket): Documentation added.
(MulticastSocket): New method.
(joinGroup): Documentation added.
(joinGroup): New method.
(leaveGroup): Documentation added.
(leaveGroup): New method.
(send): Documentation added.
* java/net/NetworkInterface.java
(getByName): Documentation added.
(getByInetAddress): Documentation added.
(getNetworkInterfaces): Documentation added.
* java/net/PlainDatagramSocketImpl.java
(connect): New method.
(disconnect): New method.
* java/net/SocketImpl.java
(create): Documentation added.
(shutdownInput): Convert public to protected, as it always was.
(shutdownOutput): Convert public to protected, as it always was.
* java/net/SocketOptions.java
(whole file): Reintented.
* java/net/URLClassLoader.java
(URLClassLoader): SecurityManager check added, documentation added.
(findResources): Documentation added.
(findClass): Documentation added.
(newInstance): More correct method arguments.
* java/net/URLConnection.java
(connect): Documentation added.
(getContent): Documentation added.
(getPermission): Documentation added.
(getInputStream): Documentation added.
(getOutputStream): Documentation added.
(setDoInput): Throw correct exception, documentation added.
(setDoOutput): Throw correct exception, documentation added.
(setAllowUserInteraction): Throw correct exception, documentation added.
(setUseCaches): Throw correct exception, documentation added.
(setIfModifiedSince): Throw correct exception, documentation added.
(setRequestProperty): Throw exception, documentation added.
(addRequestProperty): Throw exception, documentation added.
(getRequestProperty): Throw exception, documentation added.
(getRequestProperties): Documentation added.
(setContentHandlerFactory): Documentation added.
(guessContentTypeFromName): protected to public.
(setFileNameMap): Documentation added.
* java/net/URLDecoder.java
(URLDecoder): New method.
(decode): Documentation added.
(whole file): Reindented.
* java/net/URLEncoder.java
(encode): Documentation added.
* java/net/natPlainDatagramSocketImpl.cc
(connect): New method.
(disconnect): New method.
* javax/naming/RefAddr:
(addrType): addrType was never final.
(equals): Fix typo in method name.
* javax/naming/BinaryRefAddr:
(equals): Fix typo in method name.
From-SVN: r57487
2002-09-25 07:05:07 +02:00
|
|
|
/**
|
|
|
|
* Createa a new URL class loader object
|
|
|
|
*
|
|
|
|
* @exception SecurityException If a security manager exists and its
|
|
|
|
* checkCreateClassLoader method doesn't allow creation of a class loader
|
|
|
|
*/
|
1999-08-18 16:16:42 +02:00
|
|
|
public URLClassLoader (URL[] urls, ClassLoader parent,
|
|
|
|
URLStreamHandlerFactory fac)
|
|
|
|
{
|
|
|
|
super (parent);
|
|
|
|
|
2002-09-25 Michael Koch <konqueror@gmx.de>
* java/net/DatagramPacket
(DatagramPacket): Exception documentation added.
(setData): Likewise.
(setSocketAddress): Likewise.
* java/net/DatagramSocketImpl.java
(peek): Documentation addded.
(peekData): Documentation addded.
(send): Documentation addded.
(receive): Documentation addded.
(connect): New method.
(disconnect): New method.
(joinGroup): New abstract method.
(leaveGroup): New abstract method.
* java/net/InetSocketAddress.java
(InetSocketAddress): Documentation added.
(equals): final keyword added.
(getAddress): final keyword added.
(getHostName): final keyword added.
(getPort): final keyword added.
(hashCode): final keyword added.
(isUnresolved): final keyword added.
* java/net/MulticastSocket.java
(MulticastSocket): Documentation added.
(MulticastSocket): New method.
(joinGroup): Documentation added.
(joinGroup): New method.
(leaveGroup): Documentation added.
(leaveGroup): New method.
(send): Documentation added.
* java/net/NetworkInterface.java
(getByName): Documentation added.
(getByInetAddress): Documentation added.
(getNetworkInterfaces): Documentation added.
* java/net/PlainDatagramSocketImpl.java
(connect): New method.
(disconnect): New method.
* java/net/SocketImpl.java
(create): Documentation added.
(shutdownInput): Convert public to protected, as it always was.
(shutdownOutput): Convert public to protected, as it always was.
* java/net/SocketOptions.java
(whole file): Reintented.
* java/net/URLClassLoader.java
(URLClassLoader): SecurityManager check added, documentation added.
(findResources): Documentation added.
(findClass): Documentation added.
(newInstance): More correct method arguments.
* java/net/URLConnection.java
(connect): Documentation added.
(getContent): Documentation added.
(getPermission): Documentation added.
(getInputStream): Documentation added.
(getOutputStream): Documentation added.
(setDoInput): Throw correct exception, documentation added.
(setDoOutput): Throw correct exception, documentation added.
(setAllowUserInteraction): Throw correct exception, documentation added.
(setUseCaches): Throw correct exception, documentation added.
(setIfModifiedSince): Throw correct exception, documentation added.
(setRequestProperty): Throw exception, documentation added.
(addRequestProperty): Throw exception, documentation added.
(getRequestProperty): Throw exception, documentation added.
(getRequestProperties): Documentation added.
(setContentHandlerFactory): Documentation added.
(guessContentTypeFromName): protected to public.
(setFileNameMap): Documentation added.
* java/net/URLDecoder.java
(URLDecoder): New method.
(decode): Documentation added.
(whole file): Reindented.
* java/net/URLEncoder.java
(encode): Documentation added.
* java/net/natPlainDatagramSocketImpl.cc
(connect): New method.
(disconnect): New method.
* javax/naming/RefAddr:
(addrType): addrType was never final.
(equals): Fix typo in method name.
* javax/naming/BinaryRefAddr:
(equals): Fix typo in method name.
From-SVN: r57487
2002-09-25 07:05:07 +02:00
|
|
|
SecurityManager s = System.getSecurityManager();
|
|
|
|
if (s != null)
|
|
|
|
s.checkCreateClassLoader();
|
|
|
|
|
1999-08-18 16:16:42 +02:00
|
|
|
factory = fac;
|
|
|
|
|
|
|
|
if (urls == null || urls.length == 0)
|
|
|
|
{
|
|
|
|
path = new Vector (1);
|
|
|
|
info = new Vector (1);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
path = new Vector (urls.length);
|
|
|
|
info = new Vector (urls.length);
|
|
|
|
|
|
|
|
for (int i = 0; i < urls.length; i++)
|
|
|
|
{
|
2002-09-16 23:40:40 +02:00
|
|
|
// Convert a Jar File URL into a Jar URL if possible.
|
2000-11-26 04:58:56 +01:00
|
|
|
URL u = jarFileize(urls[i]);
|
1999-08-18 16:16:42 +02:00
|
|
|
|
2000-11-26 04:58:56 +01:00
|
|
|
path.addElement (u);
|
1999-08-18 16:16:42 +02:00
|
|
|
|
|
|
|
if (u.getProtocol ().equals ("jar"))
|
|
|
|
{
|
|
|
|
JarURLConnection conn = null;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
conn = (JarURLConnection) u.openConnection ();
|
|
|
|
}
|
|
|
|
catch (java.io.IOException x)
|
|
|
|
{
|
|
|
|
/* ignore */
|
|
|
|
}
|
2000-11-26 04:58:56 +01:00
|
|
|
info.addElement (conn);
|
1999-08-18 16:16:42 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2000-11-26 04:58:56 +01:00
|
|
|
info.addElement (null);
|
1999-08-18 16:16:42 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-11-26 04:58:56 +01:00
|
|
|
|
|
|
|
public URL[] getURLs ()
|
|
|
|
{
|
|
|
|
URL[] urls = new URL[path.size()];
|
|
|
|
path.copyInto (urls);
|
|
|
|
return urls;
|
|
|
|
}
|
2002-09-25 Michael Koch <konqueror@gmx.de>
* java/net/DatagramPacket
(DatagramPacket): Exception documentation added.
(setData): Likewise.
(setSocketAddress): Likewise.
* java/net/DatagramSocketImpl.java
(peek): Documentation addded.
(peekData): Documentation addded.
(send): Documentation addded.
(receive): Documentation addded.
(connect): New method.
(disconnect): New method.
(joinGroup): New abstract method.
(leaveGroup): New abstract method.
* java/net/InetSocketAddress.java
(InetSocketAddress): Documentation added.
(equals): final keyword added.
(getAddress): final keyword added.
(getHostName): final keyword added.
(getPort): final keyword added.
(hashCode): final keyword added.
(isUnresolved): final keyword added.
* java/net/MulticastSocket.java
(MulticastSocket): Documentation added.
(MulticastSocket): New method.
(joinGroup): Documentation added.
(joinGroup): New method.
(leaveGroup): Documentation added.
(leaveGroup): New method.
(send): Documentation added.
* java/net/NetworkInterface.java
(getByName): Documentation added.
(getByInetAddress): Documentation added.
(getNetworkInterfaces): Documentation added.
* java/net/PlainDatagramSocketImpl.java
(connect): New method.
(disconnect): New method.
* java/net/SocketImpl.java
(create): Documentation added.
(shutdownInput): Convert public to protected, as it always was.
(shutdownOutput): Convert public to protected, as it always was.
* java/net/SocketOptions.java
(whole file): Reintented.
* java/net/URLClassLoader.java
(URLClassLoader): SecurityManager check added, documentation added.
(findResources): Documentation added.
(findClass): Documentation added.
(newInstance): More correct method arguments.
* java/net/URLConnection.java
(connect): Documentation added.
(getContent): Documentation added.
(getPermission): Documentation added.
(getInputStream): Documentation added.
(getOutputStream): Documentation added.
(setDoInput): Throw correct exception, documentation added.
(setDoOutput): Throw correct exception, documentation added.
(setAllowUserInteraction): Throw correct exception, documentation added.
(setUseCaches): Throw correct exception, documentation added.
(setIfModifiedSince): Throw correct exception, documentation added.
(setRequestProperty): Throw exception, documentation added.
(addRequestProperty): Throw exception, documentation added.
(getRequestProperty): Throw exception, documentation added.
(getRequestProperties): Documentation added.
(setContentHandlerFactory): Documentation added.
(guessContentTypeFromName): protected to public.
(setFileNameMap): Documentation added.
* java/net/URLDecoder.java
(URLDecoder): New method.
(decode): Documentation added.
(whole file): Reindented.
* java/net/URLEncoder.java
(encode): Documentation added.
* java/net/natPlainDatagramSocketImpl.cc
(connect): New method.
(disconnect): New method.
* javax/naming/RefAddr:
(addrType): addrType was never final.
(equals): Fix typo in method name.
* javax/naming/BinaryRefAddr:
(equals): Fix typo in method name.
From-SVN: r57487
2002-09-25 07:05:07 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns an Enumeration of URLs representing all of the resources on the
|
|
|
|
* URL search path having the specified name
|
|
|
|
*
|
|
|
|
* @exception IOException If an error occurs
|
|
|
|
*/
|
2000-11-26 04:58:56 +01:00
|
|
|
public Enumeration findResources (String name)
|
1999-08-18 16:16:42 +02:00
|
|
|
{
|
2000-11-26 04:58:56 +01:00
|
|
|
Vector results = new Vector ();
|
|
|
|
|
1999-08-18 16:16:42 +02:00
|
|
|
for (int i = 0; i < path.size(); i++)
|
|
|
|
{
|
2000-11-26 04:58:56 +01:00
|
|
|
URL u = (URL)path.elementAt (i);
|
|
|
|
|
1999-08-18 16:16:42 +02:00
|
|
|
try {
|
|
|
|
JarURLConnection conn = (JarURLConnection) info.elementAt (i);
|
2000-11-26 04:58:56 +01:00
|
|
|
|
1999-08-18 16:16:42 +02:00
|
|
|
if (conn != null)
|
|
|
|
{
|
2000-08-20 19:49:12 +02:00
|
|
|
if (conn.getJarFile().getJarEntry (name) != null)
|
2002-09-13 13:39:47 +02:00
|
|
|
results.addElement (new URL(u, name,
|
|
|
|
getHandler0 (u.getProtocol())));
|
1999-08-18 16:16:42 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
URL p = new URL (u, name, getHandler0 (u.getProtocol()));
|
2000-11-26 04:58:56 +01:00
|
|
|
|
1999-08-18 16:16:42 +02:00
|
|
|
InputStream is = p.openStream();
|
|
|
|
if (is != null)
|
|
|
|
{
|
|
|
|
is.close();
|
2000-11-26 04:58:56 +01:00
|
|
|
results.addElement (p);
|
1999-08-18 16:16:42 +02:00
|
|
|
}
|
|
|
|
}
|
2000-11-26 04:58:56 +01:00
|
|
|
|
1999-08-18 16:16:42 +02:00
|
|
|
// if we get an exception ... try the next path element
|
|
|
|
} catch (IOException x) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
2000-11-26 04:58:56 +01:00
|
|
|
|
|
|
|
return results.elements ();
|
1999-08-18 16:16:42 +02:00
|
|
|
}
|
|
|
|
|
2000-11-26 04:58:56 +01:00
|
|
|
public URL findResource (String name)
|
1999-08-18 16:16:42 +02:00
|
|
|
{
|
|
|
|
for (int i = 0; i < path.size(); i++)
|
|
|
|
{
|
2000-11-26 04:58:56 +01:00
|
|
|
URL u = (URL)path.elementAt (i);
|
1999-08-18 16:16:42 +02:00
|
|
|
|
|
|
|
try {
|
|
|
|
JarURLConnection conn = (JarURLConnection) info.elementAt (i);
|
2000-11-26 04:58:56 +01:00
|
|
|
|
1999-08-18 16:16:42 +02:00
|
|
|
if (conn != null)
|
|
|
|
{
|
2000-11-26 04:58:56 +01:00
|
|
|
if (conn.getJarFile().getJarEntry (name) != null)
|
|
|
|
return new URL(u, name, getHandler0 (u.getProtocol()));
|
1999-08-18 16:16:42 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2000-11-26 04:58:56 +01:00
|
|
|
URL p = new URL (u, name, getHandler0 (u.getProtocol()));
|
|
|
|
|
|
|
|
InputStream is = p.openStream();
|
1999-08-18 16:16:42 +02:00
|
|
|
if (is != null)
|
2000-11-26 04:58:56 +01:00
|
|
|
{
|
|
|
|
is.close();
|
|
|
|
return p;
|
|
|
|
}
|
1999-08-18 16:16:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// if we get an exception ... try the next path element
|
|
|
|
} catch (IOException x) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2002-09-25 Michael Koch <konqueror@gmx.de>
* java/net/DatagramPacket
(DatagramPacket): Exception documentation added.
(setData): Likewise.
(setSocketAddress): Likewise.
* java/net/DatagramSocketImpl.java
(peek): Documentation addded.
(peekData): Documentation addded.
(send): Documentation addded.
(receive): Documentation addded.
(connect): New method.
(disconnect): New method.
(joinGroup): New abstract method.
(leaveGroup): New abstract method.
* java/net/InetSocketAddress.java
(InetSocketAddress): Documentation added.
(equals): final keyword added.
(getAddress): final keyword added.
(getHostName): final keyword added.
(getPort): final keyword added.
(hashCode): final keyword added.
(isUnresolved): final keyword added.
* java/net/MulticastSocket.java
(MulticastSocket): Documentation added.
(MulticastSocket): New method.
(joinGroup): Documentation added.
(joinGroup): New method.
(leaveGroup): Documentation added.
(leaveGroup): New method.
(send): Documentation added.
* java/net/NetworkInterface.java
(getByName): Documentation added.
(getByInetAddress): Documentation added.
(getNetworkInterfaces): Documentation added.
* java/net/PlainDatagramSocketImpl.java
(connect): New method.
(disconnect): New method.
* java/net/SocketImpl.java
(create): Documentation added.
(shutdownInput): Convert public to protected, as it always was.
(shutdownOutput): Convert public to protected, as it always was.
* java/net/SocketOptions.java
(whole file): Reintented.
* java/net/URLClassLoader.java
(URLClassLoader): SecurityManager check added, documentation added.
(findResources): Documentation added.
(findClass): Documentation added.
(newInstance): More correct method arguments.
* java/net/URLConnection.java
(connect): Documentation added.
(getContent): Documentation added.
(getPermission): Documentation added.
(getInputStream): Documentation added.
(getOutputStream): Documentation added.
(setDoInput): Throw correct exception, documentation added.
(setDoOutput): Throw correct exception, documentation added.
(setAllowUserInteraction): Throw correct exception, documentation added.
(setUseCaches): Throw correct exception, documentation added.
(setIfModifiedSince): Throw correct exception, documentation added.
(setRequestProperty): Throw exception, documentation added.
(addRequestProperty): Throw exception, documentation added.
(getRequestProperty): Throw exception, documentation added.
(getRequestProperties): Documentation added.
(setContentHandlerFactory): Documentation added.
(guessContentTypeFromName): protected to public.
(setFileNameMap): Documentation added.
* java/net/URLDecoder.java
(URLDecoder): New method.
(decode): Documentation added.
(whole file): Reindented.
* java/net/URLEncoder.java
(encode): Documentation added.
* java/net/natPlainDatagramSocketImpl.cc
(connect): New method.
(disconnect): New method.
* javax/naming/RefAddr:
(addrType): addrType was never final.
(equals): Fix typo in method name.
* javax/naming/BinaryRefAddr:
(equals): Fix typo in method name.
From-SVN: r57487
2002-09-25 07:05:07 +02:00
|
|
|
/**
|
|
|
|
* Finds and loads the class with the specified name from the
|
|
|
|
* URL search path
|
|
|
|
*
|
|
|
|
* @exception ClassNotFoundException If the class could not be found
|
|
|
|
*/
|
1999-08-18 16:16:42 +02:00
|
|
|
protected Class findClass (String name)
|
|
|
|
throws ClassNotFoundException
|
|
|
|
{
|
|
|
|
if (name == null)
|
|
|
|
throw new ClassNotFoundException ("null");
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
JarURLConnection.java (getCertificates): New method from Classpath.
* java/net/JarURLConnection.java (getCertificates): New method
from Classpath.
* java/net/URLClassLoader.java (URLClassLoader): Extends
SecureClassLoader.
(definePackage): New method from Classpath.
(getPermissions): Likewise.
(newInstance): Likewise.
(findClass): Construct CodeSource for new class (from Classpath).
* java/net/SocketImpl.java (shutdownInput, shutdownOutput): New
methods.
* java/net/URL.java (getUserInfo): New method.
(set(String,String,int,String,String,String,String,String)): New
method.
* java/net/PlainSocketImpl.java (_Jv_SO_KEEPALIVE_): Define.
(shutdownInput, shutdownOutput): Declare.
* java/net/PlainDatagramSocketImpl.java (_Jv_SO_KEEPALIVE_):
Define.
* java/net/natPlainSocketImpl.cc (setOption): Handle keepalive.
(getOption): Likewise.
(shutdownInput): New method.
(shutdownOutput): Likewise.
* java/net/natPlainDatagramSocketImpl.cc (setOption): Handle
keepalive.
(getOption): Likewise.
* java/net/SocketOptions.java (SO_KEEPALIVE): New constant.
* java/net/Socket.java (setKeepAlive): New method.
(getKeepAlive): Likewise.
(shutdownInput, shutdownOutput): New methods.
From-SVN: r56685
2002-08-30 20:16:00 +02:00
|
|
|
URL url = getResource (name.replace ('.', '/') + ".class");
|
2000-08-20 19:49:12 +02:00
|
|
|
|
JarURLConnection.java (getCertificates): New method from Classpath.
* java/net/JarURLConnection.java (getCertificates): New method
from Classpath.
* java/net/URLClassLoader.java (URLClassLoader): Extends
SecureClassLoader.
(definePackage): New method from Classpath.
(getPermissions): Likewise.
(newInstance): Likewise.
(findClass): Construct CodeSource for new class (from Classpath).
* java/net/SocketImpl.java (shutdownInput, shutdownOutput): New
methods.
* java/net/URL.java (getUserInfo): New method.
(set(String,String,int,String,String,String,String,String)): New
method.
* java/net/PlainSocketImpl.java (_Jv_SO_KEEPALIVE_): Define.
(shutdownInput, shutdownOutput): Declare.
* java/net/PlainDatagramSocketImpl.java (_Jv_SO_KEEPALIVE_):
Define.
* java/net/natPlainSocketImpl.cc (setOption): Handle keepalive.
(getOption): Likewise.
(shutdownInput): New method.
(shutdownOutput): Likewise.
* java/net/natPlainDatagramSocketImpl.cc (setOption): Handle
keepalive.
(getOption): Likewise.
* java/net/SocketOptions.java (SO_KEEPALIVE): New constant.
* java/net/Socket.java (setKeepAlive): New method.
(getKeepAlive): Likewise.
(shutdownInput, shutdownOutput): New methods.
From-SVN: r56685
2002-08-30 20:16:00 +02:00
|
|
|
if (url == null)
|
1999-08-18 16:16:42 +02:00
|
|
|
throw new ClassNotFoundException (name);
|
2000-08-20 19:49:12 +02:00
|
|
|
|
JarURLConnection.java (getCertificates): New method from Classpath.
* java/net/JarURLConnection.java (getCertificates): New method
from Classpath.
* java/net/URLClassLoader.java (URLClassLoader): Extends
SecureClassLoader.
(definePackage): New method from Classpath.
(getPermissions): Likewise.
(newInstance): Likewise.
(findClass): Construct CodeSource for new class (from Classpath).
* java/net/SocketImpl.java (shutdownInput, shutdownOutput): New
methods.
* java/net/URL.java (getUserInfo): New method.
(set(String,String,int,String,String,String,String,String)): New
method.
* java/net/PlainSocketImpl.java (_Jv_SO_KEEPALIVE_): Define.
(shutdownInput, shutdownOutput): Declare.
* java/net/PlainDatagramSocketImpl.java (_Jv_SO_KEEPALIVE_):
Define.
* java/net/natPlainSocketImpl.cc (setOption): Handle keepalive.
(getOption): Likewise.
(shutdownInput): New method.
(shutdownOutput): Likewise.
* java/net/natPlainDatagramSocketImpl.cc (setOption): Handle
keepalive.
(getOption): Likewise.
* java/net/SocketOptions.java (SO_KEEPALIVE): New constant.
* java/net/Socket.java (setKeepAlive): New method.
(getKeepAlive): Likewise.
(shutdownInput, shutdownOutput): New methods.
From-SVN: r56685
2002-08-30 20:16:00 +02:00
|
|
|
URLConnection connection = url.openConnection ();
|
2000-08-20 19:49:12 +02:00
|
|
|
InputStream is = connection.getInputStream ();
|
|
|
|
|
|
|
|
int len = connection.getContentLength ();
|
1999-08-18 16:16:42 +02:00
|
|
|
byte[] data = new byte[len];
|
|
|
|
|
|
|
|
int left = len;
|
|
|
|
int off = 0;
|
|
|
|
while (left > 0)
|
|
|
|
{
|
|
|
|
int c = is.read (data, off, len-off);
|
|
|
|
if (c == -1 || c == 0)
|
|
|
|
throw new InternalError ("premature end of file");
|
|
|
|
left -= c;
|
|
|
|
off += c;
|
|
|
|
}
|
|
|
|
|
JarURLConnection.java (getCertificates): New method from Classpath.
* java/net/JarURLConnection.java (getCertificates): New method
from Classpath.
* java/net/URLClassLoader.java (URLClassLoader): Extends
SecureClassLoader.
(definePackage): New method from Classpath.
(getPermissions): Likewise.
(newInstance): Likewise.
(findClass): Construct CodeSource for new class (from Classpath).
* java/net/SocketImpl.java (shutdownInput, shutdownOutput): New
methods.
* java/net/URL.java (getUserInfo): New method.
(set(String,String,int,String,String,String,String,String)): New
method.
* java/net/PlainSocketImpl.java (_Jv_SO_KEEPALIVE_): Define.
(shutdownInput, shutdownOutput): Declare.
* java/net/PlainDatagramSocketImpl.java (_Jv_SO_KEEPALIVE_):
Define.
* java/net/natPlainSocketImpl.cc (setOption): Handle keepalive.
(getOption): Likewise.
(shutdownInput): New method.
(shutdownOutput): Likewise.
* java/net/natPlainDatagramSocketImpl.cc (setOption): Handle
keepalive.
(getOption): Likewise.
* java/net/SocketOptions.java (SO_KEEPALIVE): New constant.
* java/net/Socket.java (setKeepAlive): New method.
(getKeepAlive): Likewise.
(shutdownInput, shutdownOutput): New methods.
From-SVN: r56685
2002-08-30 20:16:00 +02:00
|
|
|
// Now construct the CodeSource (if loaded from a jar file)
|
|
|
|
CodeSource source = null;
|
|
|
|
if (url.getProtocol().equals("jar"))
|
|
|
|
{
|
|
|
|
Certificate[] certificates =
|
|
|
|
((JarURLConnection) connection).getCertificates();
|
|
|
|
String u = url.toExternalForm ();
|
|
|
|
u = u.substring (4); //skip "jar:"
|
|
|
|
int i = u.indexOf ('!');
|
|
|
|
if (i >= 0)
|
|
|
|
u = u.substring (0, i);
|
2002-09-16 23:40:40 +02:00
|
|
|
url = new URL(u);
|
JarURLConnection.java (getCertificates): New method from Classpath.
* java/net/JarURLConnection.java (getCertificates): New method
from Classpath.
* java/net/URLClassLoader.java (URLClassLoader): Extends
SecureClassLoader.
(definePackage): New method from Classpath.
(getPermissions): Likewise.
(newInstance): Likewise.
(findClass): Construct CodeSource for new class (from Classpath).
* java/net/SocketImpl.java (shutdownInput, shutdownOutput): New
methods.
* java/net/URL.java (getUserInfo): New method.
(set(String,String,int,String,String,String,String,String)): New
method.
* java/net/PlainSocketImpl.java (_Jv_SO_KEEPALIVE_): Define.
(shutdownInput, shutdownOutput): Declare.
* java/net/PlainDatagramSocketImpl.java (_Jv_SO_KEEPALIVE_):
Define.
* java/net/natPlainSocketImpl.cc (setOption): Handle keepalive.
(getOption): Likewise.
(shutdownInput): New method.
(shutdownOutput): Likewise.
* java/net/natPlainDatagramSocketImpl.cc (setOption): Handle
keepalive.
(getOption): Likewise.
* java/net/SocketOptions.java (SO_KEEPALIVE): New constant.
* java/net/Socket.java (setKeepAlive): New method.
(getKeepAlive): Likewise.
(shutdownInput, shutdownOutput): New methods.
From-SVN: r56685
2002-08-30 20:16:00 +02:00
|
|
|
|
|
|
|
source = new CodeSource(url, certificates);
|
|
|
|
}
|
|
|
|
else if (url.getProtocol().equals("file"))
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
String u = url.toExternalForm();
|
|
|
|
// Skip "file:" and then get canonical directory name.
|
|
|
|
File f = new File(u.substring(5));
|
|
|
|
f = f.getCanonicalFile();
|
|
|
|
url = new URL("file", "", f.getParent());
|
|
|
|
source = new CodeSource (url, null);
|
|
|
|
}
|
|
|
|
catch (IOException ignore)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return defineClass (name, data, 0, len, source);
|
1999-08-18 16:16:42 +02:00
|
|
|
}
|
|
|
|
catch (java.io.IOException x)
|
|
|
|
{
|
|
|
|
throw new ClassNotFoundException(name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
JarURLConnection.java (getCertificates): New method from Classpath.
* java/net/JarURLConnection.java (getCertificates): New method
from Classpath.
* java/net/URLClassLoader.java (URLClassLoader): Extends
SecureClassLoader.
(definePackage): New method from Classpath.
(getPermissions): Likewise.
(newInstance): Likewise.
(findClass): Construct CodeSource for new class (from Classpath).
* java/net/SocketImpl.java (shutdownInput, shutdownOutput): New
methods.
* java/net/URL.java (getUserInfo): New method.
(set(String,String,int,String,String,String,String,String)): New
method.
* java/net/PlainSocketImpl.java (_Jv_SO_KEEPALIVE_): Define.
(shutdownInput, shutdownOutput): Declare.
* java/net/PlainDatagramSocketImpl.java (_Jv_SO_KEEPALIVE_):
Define.
* java/net/natPlainSocketImpl.cc (setOption): Handle keepalive.
(getOption): Likewise.
(shutdownInput): New method.
(shutdownOutput): Likewise.
* java/net/natPlainDatagramSocketImpl.cc (setOption): Handle
keepalive.
(getOption): Likewise.
* java/net/SocketOptions.java (SO_KEEPALIVE): New constant.
* java/net/Socket.java (setKeepAlive): New method.
(getKeepAlive): Likewise.
(shutdownInput, shutdownOutput): New methods.
From-SVN: r56685
2002-08-30 20:16:00 +02:00
|
|
|
/**
|
|
|
|
* Defines a Package based on the given name and the supplied manifest
|
|
|
|
* information. The manifest indicates the tile, version and
|
|
|
|
* vendor information of the specification and implementation and wheter the
|
|
|
|
* package is sealed. If the Manifest indicates that the package is sealed
|
|
|
|
* then the Package will be sealed with respect to the supplied URL.
|
|
|
|
*
|
|
|
|
* @exception IllegalArgumentException If this package name already exists
|
|
|
|
* in this class loader
|
|
|
|
* @param name The name of the package
|
|
|
|
* @param manifest The manifest describing the specification,
|
|
|
|
* implementation and sealing details of the package
|
|
|
|
* @param url the code source url to seal the package
|
|
|
|
* @return the defined Package
|
|
|
|
*/
|
|
|
|
protected Package definePackage(String name, Manifest manifest, URL url)
|
|
|
|
throws IllegalArgumentException
|
|
|
|
{
|
|
|
|
Attributes attr = manifest.getMainAttributes();
|
|
|
|
String specTitle =
|
|
|
|
attr.getValue(Attributes.Name.SPECIFICATION_TITLE);
|
|
|
|
String specVersion =
|
|
|
|
attr.getValue(Attributes.Name.SPECIFICATION_VERSION);
|
|
|
|
String specVendor =
|
|
|
|
attr.getValue(Attributes.Name.SPECIFICATION_VENDOR);
|
|
|
|
String implTitle =
|
|
|
|
attr.getValue(Attributes.Name.IMPLEMENTATION_TITLE);
|
|
|
|
String implVersion =
|
|
|
|
attr.getValue(Attributes.Name.IMPLEMENTATION_VERSION);
|
|
|
|
String implVendor =
|
|
|
|
attr.getValue(Attributes.Name.IMPLEMENTATION_VENDOR);
|
|
|
|
|
|
|
|
// Look if the Manifest indicates that this package is sealed
|
|
|
|
// XXX - most likely not completely correct!
|
|
|
|
// Shouldn't we also check the sealed attribute of the complete jar?
|
|
|
|
// http://java.sun.com/products/jdk/1.3/docs/guide/extensions/spec.html#bundled
|
|
|
|
// But how do we get that jar manifest here?
|
|
|
|
String sealed = attr.getValue(Attributes.Name.SEALED);
|
|
|
|
if ("false".equals(sealed))
|
|
|
|
{
|
|
|
|
// Make sure that the URL is null so the package is not
|
|
|
|
// sealed.
|
|
|
|
url = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return definePackage(name, specTitle, specVersion, specVendor,
|
|
|
|
implTitle, implVersion, implVendor, url);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the permissions needed to access a particular code source.
|
|
|
|
* These permissions includes those returned by
|
|
|
|
* <CODE>SecureClassLoader.getPermissions</CODE> and the actual permissions
|
|
|
|
* to access the objects referenced by the URL of the code source.
|
|
|
|
* The extra permissions added depend on the protocol and file portion of
|
|
|
|
* the URL in the code source. If the URL has the "file" protocol ends with
|
|
|
|
* a / character then it must be a directory and a file Permission to read
|
|
|
|
* everthing in that directory and all subdirectories is added. If the URL
|
|
|
|
* had the "file" protocol and doesn't end with a / character then it must
|
|
|
|
* be a normal file and a file permission to read that file is added. If the
|
|
|
|
* URL has any other protocol then a socket permission to connect and accept
|
|
|
|
* connections from the host portion of the URL is added.
|
|
|
|
* @param source The codesource that needs the permissions to be accessed
|
|
|
|
* @return the collection of permissions needed to access the code resource
|
|
|
|
* @see SecureClassLoader.getPermissions()
|
|
|
|
*/
|
|
|
|
protected PermissionCollection getPermissions(CodeSource source)
|
|
|
|
{
|
|
|
|
// XXX - This implementation does exactly as the Javadoc describes.
|
|
|
|
// But maybe we should/could use URLConnection.getPermissions()?
|
|
|
|
|
|
|
|
// First get the permissions that would normally be granted
|
|
|
|
PermissionCollection permissions = super.getPermissions(source);
|
|
|
|
|
|
|
|
// Now add the any extra permissions depending on the URL location
|
|
|
|
URL url = source.getLocation();
|
|
|
|
String protocol = url.getProtocol();
|
|
|
|
if (protocol.equals("file"))
|
|
|
|
{
|
|
|
|
String file = url.getFile();
|
|
|
|
// If the file end in / it must be an directory
|
|
|
|
if (file.endsWith("/"))
|
|
|
|
{
|
|
|
|
// Grant permission to read everything in that directory and
|
|
|
|
// all subdirectories
|
|
|
|
permissions.add(new FilePermission(file + "-", "read"));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// It is a 'normal' file
|
|
|
|
// Grant permission to access that file
|
|
|
|
permissions.add(new FilePermission(file, "read"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Grant permission to connect to and accept connections from host
|
|
|
|
String host = url.getHost();
|
|
|
|
permissions.add(new SocketPermission(host, "connect,accept"));
|
|
|
|
}
|
|
|
|
|
|
|
|
return permissions;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a new instance of a URLClassLoader that gets classes from the
|
|
|
|
* supplied URLs. This class loader will have as parent the standard
|
|
|
|
* system class loader.
|
|
|
|
* @param urls the initial URLs used to resolve classes and resources
|
|
|
|
*/
|
2002-09-25 Michael Koch <konqueror@gmx.de>
* java/net/DatagramPacket
(DatagramPacket): Exception documentation added.
(setData): Likewise.
(setSocketAddress): Likewise.
* java/net/DatagramSocketImpl.java
(peek): Documentation addded.
(peekData): Documentation addded.
(send): Documentation addded.
(receive): Documentation addded.
(connect): New method.
(disconnect): New method.
(joinGroup): New abstract method.
(leaveGroup): New abstract method.
* java/net/InetSocketAddress.java
(InetSocketAddress): Documentation added.
(equals): final keyword added.
(getAddress): final keyword added.
(getHostName): final keyword added.
(getPort): final keyword added.
(hashCode): final keyword added.
(isUnresolved): final keyword added.
* java/net/MulticastSocket.java
(MulticastSocket): Documentation added.
(MulticastSocket): New method.
(joinGroup): Documentation added.
(joinGroup): New method.
(leaveGroup): Documentation added.
(leaveGroup): New method.
(send): Documentation added.
* java/net/NetworkInterface.java
(getByName): Documentation added.
(getByInetAddress): Documentation added.
(getNetworkInterfaces): Documentation added.
* java/net/PlainDatagramSocketImpl.java
(connect): New method.
(disconnect): New method.
* java/net/SocketImpl.java
(create): Documentation added.
(shutdownInput): Convert public to protected, as it always was.
(shutdownOutput): Convert public to protected, as it always was.
* java/net/SocketOptions.java
(whole file): Reintented.
* java/net/URLClassLoader.java
(URLClassLoader): SecurityManager check added, documentation added.
(findResources): Documentation added.
(findClass): Documentation added.
(newInstance): More correct method arguments.
* java/net/URLConnection.java
(connect): Documentation added.
(getContent): Documentation added.
(getPermission): Documentation added.
(getInputStream): Documentation added.
(getOutputStream): Documentation added.
(setDoInput): Throw correct exception, documentation added.
(setDoOutput): Throw correct exception, documentation added.
(setAllowUserInteraction): Throw correct exception, documentation added.
(setUseCaches): Throw correct exception, documentation added.
(setIfModifiedSince): Throw correct exception, documentation added.
(setRequestProperty): Throw exception, documentation added.
(addRequestProperty): Throw exception, documentation added.
(getRequestProperty): Throw exception, documentation added.
(getRequestProperties): Documentation added.
(setContentHandlerFactory): Documentation added.
(guessContentTypeFromName): protected to public.
(setFileNameMap): Documentation added.
* java/net/URLDecoder.java
(URLDecoder): New method.
(decode): Documentation added.
(whole file): Reindented.
* java/net/URLEncoder.java
(encode): Documentation added.
* java/net/natPlainDatagramSocketImpl.cc
(connect): New method.
(disconnect): New method.
* javax/naming/RefAddr:
(addrType): addrType was never final.
(equals): Fix typo in method name.
* javax/naming/BinaryRefAddr:
(equals): Fix typo in method name.
From-SVN: r57487
2002-09-25 07:05:07 +02:00
|
|
|
public static URLClassLoader newInstance(URL[] urls) throws
|
JarURLConnection.java (getCertificates): New method from Classpath.
* java/net/JarURLConnection.java (getCertificates): New method
from Classpath.
* java/net/URLClassLoader.java (URLClassLoader): Extends
SecureClassLoader.
(definePackage): New method from Classpath.
(getPermissions): Likewise.
(newInstance): Likewise.
(findClass): Construct CodeSource for new class (from Classpath).
* java/net/SocketImpl.java (shutdownInput, shutdownOutput): New
methods.
* java/net/URL.java (getUserInfo): New method.
(set(String,String,int,String,String,String,String,String)): New
method.
* java/net/PlainSocketImpl.java (_Jv_SO_KEEPALIVE_): Define.
(shutdownInput, shutdownOutput): Declare.
* java/net/PlainDatagramSocketImpl.java (_Jv_SO_KEEPALIVE_):
Define.
* java/net/natPlainSocketImpl.cc (setOption): Handle keepalive.
(getOption): Likewise.
(shutdownInput): New method.
(shutdownOutput): Likewise.
* java/net/natPlainDatagramSocketImpl.cc (setOption): Handle
keepalive.
(getOption): Likewise.
* java/net/SocketOptions.java (SO_KEEPALIVE): New constant.
* java/net/Socket.java (setKeepAlive): New method.
(getKeepAlive): Likewise.
(shutdownInput, shutdownOutput): New methods.
From-SVN: r56685
2002-08-30 20:16:00 +02:00
|
|
|
SecurityException
|
|
|
|
{
|
|
|
|
return new URLClassLoader(urls);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a new instance of a URLClassLoader that gets classes from the
|
|
|
|
* supplied URLs and with the supplied loader as parent class loader.
|
|
|
|
* @param urls the initial URLs used to resolve classes and resources
|
|
|
|
* @param parent the parent class loader
|
|
|
|
*/
|
2002-09-25 Michael Koch <konqueror@gmx.de>
* java/net/DatagramPacket
(DatagramPacket): Exception documentation added.
(setData): Likewise.
(setSocketAddress): Likewise.
* java/net/DatagramSocketImpl.java
(peek): Documentation addded.
(peekData): Documentation addded.
(send): Documentation addded.
(receive): Documentation addded.
(connect): New method.
(disconnect): New method.
(joinGroup): New abstract method.
(leaveGroup): New abstract method.
* java/net/InetSocketAddress.java
(InetSocketAddress): Documentation added.
(equals): final keyword added.
(getAddress): final keyword added.
(getHostName): final keyword added.
(getPort): final keyword added.
(hashCode): final keyword added.
(isUnresolved): final keyword added.
* java/net/MulticastSocket.java
(MulticastSocket): Documentation added.
(MulticastSocket): New method.
(joinGroup): Documentation added.
(joinGroup): New method.
(leaveGroup): Documentation added.
(leaveGroup): New method.
(send): Documentation added.
* java/net/NetworkInterface.java
(getByName): Documentation added.
(getByInetAddress): Documentation added.
(getNetworkInterfaces): Documentation added.
* java/net/PlainDatagramSocketImpl.java
(connect): New method.
(disconnect): New method.
* java/net/SocketImpl.java
(create): Documentation added.
(shutdownInput): Convert public to protected, as it always was.
(shutdownOutput): Convert public to protected, as it always was.
* java/net/SocketOptions.java
(whole file): Reintented.
* java/net/URLClassLoader.java
(URLClassLoader): SecurityManager check added, documentation added.
(findResources): Documentation added.
(findClass): Documentation added.
(newInstance): More correct method arguments.
* java/net/URLConnection.java
(connect): Documentation added.
(getContent): Documentation added.
(getPermission): Documentation added.
(getInputStream): Documentation added.
(getOutputStream): Documentation added.
(setDoInput): Throw correct exception, documentation added.
(setDoOutput): Throw correct exception, documentation added.
(setAllowUserInteraction): Throw correct exception, documentation added.
(setUseCaches): Throw correct exception, documentation added.
(setIfModifiedSince): Throw correct exception, documentation added.
(setRequestProperty): Throw exception, documentation added.
(addRequestProperty): Throw exception, documentation added.
(getRequestProperty): Throw exception, documentation added.
(getRequestProperties): Documentation added.
(setContentHandlerFactory): Documentation added.
(guessContentTypeFromName): protected to public.
(setFileNameMap): Documentation added.
* java/net/URLDecoder.java
(URLDecoder): New method.
(decode): Documentation added.
(whole file): Reindented.
* java/net/URLEncoder.java
(encode): Documentation added.
* java/net/natPlainDatagramSocketImpl.cc
(connect): New method.
(disconnect): New method.
* javax/naming/RefAddr:
(addrType): addrType was never final.
(equals): Fix typo in method name.
* javax/naming/BinaryRefAddr:
(equals): Fix typo in method name.
From-SVN: r57487
2002-09-25 07:05:07 +02:00
|
|
|
public static URLClassLoader newInstance(URL[] urls,
|
JarURLConnection.java (getCertificates): New method from Classpath.
* java/net/JarURLConnection.java (getCertificates): New method
from Classpath.
* java/net/URLClassLoader.java (URLClassLoader): Extends
SecureClassLoader.
(definePackage): New method from Classpath.
(getPermissions): Likewise.
(newInstance): Likewise.
(findClass): Construct CodeSource for new class (from Classpath).
* java/net/SocketImpl.java (shutdownInput, shutdownOutput): New
methods.
* java/net/URL.java (getUserInfo): New method.
(set(String,String,int,String,String,String,String,String)): New
method.
* java/net/PlainSocketImpl.java (_Jv_SO_KEEPALIVE_): Define.
(shutdownInput, shutdownOutput): Declare.
* java/net/PlainDatagramSocketImpl.java (_Jv_SO_KEEPALIVE_):
Define.
* java/net/natPlainSocketImpl.cc (setOption): Handle keepalive.
(getOption): Likewise.
(shutdownInput): New method.
(shutdownOutput): Likewise.
* java/net/natPlainDatagramSocketImpl.cc (setOption): Handle
keepalive.
(getOption): Likewise.
* java/net/SocketOptions.java (SO_KEEPALIVE): New constant.
* java/net/Socket.java (setKeepAlive): New method.
(getKeepAlive): Likewise.
(shutdownInput, shutdownOutput): New methods.
From-SVN: r56685
2002-08-30 20:16:00 +02:00
|
|
|
ClassLoader parent)
|
|
|
|
throws SecurityException
|
|
|
|
{
|
|
|
|
return new URLClassLoader(urls, parent);
|
|
|
|
}
|
|
|
|
}
|