2003-02-13 Michael Koch <konqueror@gmx.de>
* java/net/NetPermission.java (NetPermission): Make doucmentation match the method declaration. * java/net/NetworkInterface.java (equals): Reformated for GNU coding style. * java/net/ServerSocket.java: Merged with classpath. * java/net/Socket.java: Partly merged with classpath (Added some @since). * java/net/SocketImpl.java (localPort): Merged with classpath (initialize with -1). * java/net/SocketPermission.java: Merged with classpath (reindented). * java/net/URLDecoder.java: Merged with classpath (reindented). From-SVN: r62824
This commit is contained in:
parent
4e3243ef0e
commit
05008212fb
8 changed files with 115 additions and 64 deletions
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
||||||
|
2003-02-13 Michael Koch <konqueror@gmx.de>
|
||||||
|
|
||||||
|
* java/net/NetPermission.java
|
||||||
|
(NetPermission): Make doucmentation match the method declaration.
|
||||||
|
* java/net/NetworkInterface.java
|
||||||
|
(equals): Reformated for GNU coding style.
|
||||||
|
* java/net/ServerSocket.java: Merged with classpath.
|
||||||
|
* java/net/Socket.java: Partly merged with classpath (Added some @since).
|
||||||
|
* java/net/SocketImpl.java
|
||||||
|
(localPort): Merged with classpath (initialize with -1).
|
||||||
|
* java/net/SocketPermission.java: Merged with classpath (reindented).
|
||||||
|
* java/net/URLDecoder.java: Merged with classpath (reindented).
|
||||||
|
|
||||||
2003-02-08 Laurynas Biveinis <laurynas.biveinis@mif.vu.lt>
|
2003-02-08 Laurynas Biveinis <laurynas.biveinis@mif.vu.lt>
|
||||||
|
|
||||||
* MAINTAINERS: Update my email.
|
* MAINTAINERS: Update my email.
|
||||||
|
|
|
@ -64,7 +64,7 @@ public final class NetPermission extends BasicPermission
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes a new instance of <code>NetPermission</code> with the
|
* Initializes a new instance of <code>NetPermission</code> with the
|
||||||
* specified name and value. Note that the value field is irrelevant and is
|
* specified name and perms. Note that the perms field is irrelevant and is
|
||||||
* ignored. This constructor should never need to be used.
|
* ignored. This constructor should never need to be used.
|
||||||
*
|
*
|
||||||
* @param name The name of this permission
|
* @param name The name of this permission
|
||||||
|
|
|
@ -200,8 +200,9 @@ public final class NetworkInterface
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
NetworkInterface tmp = (NetworkInterface) obj;
|
NetworkInterface tmp = (NetworkInterface) obj;
|
||||||
return name.equals (tmp.name) &&
|
|
||||||
inetAddresses.equals (tmp.inetAddresses);
|
return (name.equals (tmp.name)
|
||||||
|
&& inetAddresses.equals (tmp.inetAddresses));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -356,7 +356,7 @@ public class ServerSocket
|
||||||
}
|
}
|
||||||
catch (SocketException e)
|
catch (SocketException e)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -95,6 +95,7 @@ public class Socket
|
||||||
* might want this behavior.
|
* might want this behavior.
|
||||||
*
|
*
|
||||||
* @specnote This constructor is public since JDK 1.4
|
* @specnote This constructor is public since JDK 1.4
|
||||||
|
* @since 1.1
|
||||||
*/
|
*/
|
||||||
public Socket ()
|
public Socket ()
|
||||||
{
|
{
|
||||||
|
@ -122,6 +123,8 @@ public class Socket
|
||||||
* <code>Socket</code>
|
* <code>Socket</code>
|
||||||
*
|
*
|
||||||
* @exception SocketException If an error occurs
|
* @exception SocketException If an error occurs
|
||||||
|
*
|
||||||
|
* @since 1.1
|
||||||
*/
|
*/
|
||||||
protected Socket (SocketImpl impl) throws SocketException
|
protected Socket (SocketImpl impl) throws SocketException
|
||||||
{
|
{
|
||||||
|
@ -180,6 +183,8 @@ public class Socket
|
||||||
* exists and does not allow a connection to the specified host/port or
|
* exists and does not allow a connection to the specified host/port or
|
||||||
* binding to the specified local host/port.
|
* binding to the specified local host/port.
|
||||||
* @exception IOException If a connection error occurs.
|
* @exception IOException If a connection error occurs.
|
||||||
|
*
|
||||||
|
* @since 1.1
|
||||||
*/
|
*/
|
||||||
public Socket (String host, int port,
|
public Socket (String host, int port,
|
||||||
InetAddress localAddr, int localPort) throws IOException
|
InetAddress localAddr, int localPort) throws IOException
|
||||||
|
@ -200,6 +205,8 @@ public class Socket
|
||||||
* @exception IOException If an error occurs
|
* @exception IOException If an error occurs
|
||||||
* @exception SecurityException If a security manager exists and its
|
* @exception SecurityException If a security manager exists and its
|
||||||
* checkConnect method doesn't allow the operation
|
* checkConnect method doesn't allow the operation
|
||||||
|
*
|
||||||
|
* @since 1.1
|
||||||
*/
|
*/
|
||||||
public Socket (InetAddress address, int port,
|
public Socket (InetAddress address, int port,
|
||||||
InetAddress localAddr, int localPort) throws IOException
|
InetAddress localAddr, int localPort) throws IOException
|
||||||
|
@ -396,6 +403,8 @@ public class Socket
|
||||||
* is not connected, then <code>null</code> is returned.
|
* is not connected, then <code>null</code> is returned.
|
||||||
*
|
*
|
||||||
* @return The local address
|
* @return The local address
|
||||||
|
*
|
||||||
|
* @since 1.1
|
||||||
*/
|
*/
|
||||||
public InetAddress getLocalAddress ()
|
public InetAddress getLocalAddress ()
|
||||||
{
|
{
|
||||||
|
@ -521,6 +530,8 @@ public class Socket
|
||||||
* @param on true to enable, false to disable
|
* @param on true to enable, false to disable
|
||||||
*
|
*
|
||||||
* @exception SocketException If an error occurs or Socket is not connected
|
* @exception SocketException If an error occurs or Socket is not connected
|
||||||
|
*
|
||||||
|
* @since 1.1
|
||||||
*/
|
*/
|
||||||
public void setTcpNoDelay (boolean on) throws SocketException
|
public void setTcpNoDelay (boolean on) throws SocketException
|
||||||
{
|
{
|
||||||
|
@ -539,6 +550,8 @@ public class Socket
|
||||||
* @return Whether or not TCP_NODELAY is set
|
* @return Whether or not TCP_NODELAY is set
|
||||||
*
|
*
|
||||||
* @exception SocketException If an error occurs or Socket not connected
|
* @exception SocketException If an error occurs or Socket not connected
|
||||||
|
*
|
||||||
|
* @since 1.1
|
||||||
*/
|
*/
|
||||||
public boolean getTcpNoDelay() throws SocketException
|
public boolean getTcpNoDelay() throws SocketException
|
||||||
{
|
{
|
||||||
|
@ -567,6 +580,8 @@ public class Socket
|
||||||
*
|
*
|
||||||
* @exception SocketException If an error occurs or Socket not connected
|
* @exception SocketException If an error occurs or Socket not connected
|
||||||
* @exception IllegalArgumentException If linger is negative
|
* @exception IllegalArgumentException If linger is negative
|
||||||
|
*
|
||||||
|
* @since 1.1
|
||||||
*/
|
*/
|
||||||
public void setSoLinger(boolean on, int linger) throws SocketException
|
public void setSoLinger(boolean on, int linger) throws SocketException
|
||||||
{
|
{
|
||||||
|
@ -602,6 +617,8 @@ public class Socket
|
||||||
* if SO_LINGER not set
|
* if SO_LINGER not set
|
||||||
*
|
*
|
||||||
* @exception SocketException If an error occurs or Socket is not connected
|
* @exception SocketException If an error occurs or Socket is not connected
|
||||||
|
*
|
||||||
|
* @since 1.1
|
||||||
*/
|
*/
|
||||||
public int getSoLinger() throws SocketException
|
public int getSoLinger() throws SocketException
|
||||||
{
|
{
|
||||||
|
@ -681,6 +698,8 @@ public class Socket
|
||||||
* 0 if not set
|
* 0 if not set
|
||||||
*
|
*
|
||||||
* @exception SocketException If an error occurs or Socket not connected
|
* @exception SocketException If an error occurs or Socket not connected
|
||||||
|
*
|
||||||
|
* @since 1.1
|
||||||
*/
|
*/
|
||||||
public synchronized void setSoTimeout (int timeout) throws SocketException
|
public synchronized void setSoTimeout (int timeout) throws SocketException
|
||||||
{
|
{
|
||||||
|
@ -707,6 +726,8 @@ public class Socket
|
||||||
* if not set
|
* if not set
|
||||||
*
|
*
|
||||||
* @exception SocketException If an error occurs or Socket not connected
|
* @exception SocketException If an error occurs or Socket not connected
|
||||||
|
*
|
||||||
|
* @since 1.1
|
||||||
*/
|
*/
|
||||||
public synchronized int getSoTimeout () throws SocketException
|
public synchronized int getSoTimeout () throws SocketException
|
||||||
{
|
{
|
||||||
|
@ -822,7 +843,7 @@ public class Socket
|
||||||
*
|
*
|
||||||
* @exception SocketException If an error occurs or Socket is not connected
|
* @exception SocketException If an error occurs or Socket is not connected
|
||||||
*
|
*
|
||||||
* @since Java 1.3
|
* @since 1.3
|
||||||
*/
|
*/
|
||||||
public void setKeepAlive (boolean on) throws SocketException
|
public void setKeepAlive (boolean on) throws SocketException
|
||||||
{
|
{
|
||||||
|
@ -840,7 +861,7 @@ public class Socket
|
||||||
*
|
*
|
||||||
* @exception SocketException If an error occurs or Socket is not connected
|
* @exception SocketException If an error occurs or Socket is not connected
|
||||||
*
|
*
|
||||||
* @since Java 1.3
|
* @since 1.3
|
||||||
*/
|
*/
|
||||||
public boolean getKeepAlive () throws SocketException
|
public boolean getKeepAlive () throws SocketException
|
||||||
{
|
{
|
||||||
|
@ -918,6 +939,8 @@ public class Socket
|
||||||
* Closes the input side of the socket stream.
|
* Closes the input side of the socket stream.
|
||||||
*
|
*
|
||||||
* @exception IOException If an error occurs.
|
* @exception IOException If an error occurs.
|
||||||
|
*
|
||||||
|
* @since 1.3
|
||||||
*/
|
*/
|
||||||
public void shutdownInput() throws IOException
|
public void shutdownInput() throws IOException
|
||||||
{
|
{
|
||||||
|
@ -931,6 +954,8 @@ public class Socket
|
||||||
* Closes the output side of the socket stream.
|
* Closes the output side of the socket stream.
|
||||||
*
|
*
|
||||||
* @exception IOException If an error occurs.
|
* @exception IOException If an error occurs.
|
||||||
|
*
|
||||||
|
* @since 1.3
|
||||||
*/
|
*/
|
||||||
public void shutdownOutput() throws IOException
|
public void shutdownOutput() throws IOException
|
||||||
{
|
{
|
||||||
|
@ -944,6 +969,8 @@ public class Socket
|
||||||
* Returns the socket channel associated with this socket.
|
* Returns the socket channel associated with this socket.
|
||||||
*
|
*
|
||||||
* It returns null if no associated socket exists.
|
* It returns null if no associated socket exists.
|
||||||
|
*
|
||||||
|
* @since 1.4
|
||||||
*/
|
*/
|
||||||
public SocketChannel getChannel()
|
public SocketChannel getChannel()
|
||||||
{
|
{
|
||||||
|
@ -1032,6 +1059,8 @@ public class Socket
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the socket is connected
|
* Checks if the socket is connected
|
||||||
|
*
|
||||||
|
* @since 1.4
|
||||||
*/
|
*/
|
||||||
public boolean isConnected ()
|
public boolean isConnected ()
|
||||||
{
|
{
|
||||||
|
@ -1040,6 +1069,8 @@ public class Socket
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the socket is already bound.
|
* Checks if the socket is already bound.
|
||||||
|
*
|
||||||
|
* @since 1.4
|
||||||
*/
|
*/
|
||||||
public boolean isBound ()
|
public boolean isBound ()
|
||||||
{
|
{
|
||||||
|
@ -1048,6 +1079,8 @@ public class Socket
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the socket is closed.
|
* Checks if the socket is closed.
|
||||||
|
*
|
||||||
|
* @since 1.4
|
||||||
*/
|
*/
|
||||||
public boolean isClosed ()
|
public boolean isClosed ()
|
||||||
{
|
{
|
||||||
|
@ -1056,6 +1089,8 @@ public class Socket
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the socket's input stream is shutdown
|
* Checks if the socket's input stream is shutdown
|
||||||
|
*
|
||||||
|
* @since 1.4
|
||||||
*/
|
*/
|
||||||
public boolean isInputShutdown ()
|
public boolean isInputShutdown ()
|
||||||
{
|
{
|
||||||
|
@ -1064,6 +1099,8 @@ public class Socket
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the socket's output stream is shutdown
|
* Checks if the socket's output stream is shutdown
|
||||||
|
*
|
||||||
|
* @since 1.4
|
||||||
*/
|
*/
|
||||||
public boolean isOutputShutdown ()
|
public boolean isOutputShutdown ()
|
||||||
{
|
{
|
||||||
|
|
|
@ -74,7 +74,7 @@ public abstract class SocketImpl implements SocketOptions
|
||||||
/**
|
/**
|
||||||
* The port number the socket is bound to locally
|
* The port number the socket is bound to locally
|
||||||
*/
|
*/
|
||||||
protected int localport;
|
protected int localport = -1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The port number of the remote end of the socket connection
|
* The port number of the remote end of the socket connection
|
||||||
|
|
|
@ -276,62 +276,62 @@ public final class SocketPermission extends Permission
|
||||||
// Get ours
|
// Get ours
|
||||||
if (hostport.indexOf(":") == -1)
|
if (hostport.indexOf(":") == -1)
|
||||||
{
|
{
|
||||||
ourfirstport = 0;
|
ourfirstport = 0;
|
||||||
ourlastport = 65535;
|
ourlastport = 65535;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// FIXME: Needs bulletproofing.
|
// FIXME: Needs bulletproofing.
|
||||||
// This will dump if hostport if all sorts of bad data was passed to
|
// This will dump if hostport if all sorts of bad data was passed to
|
||||||
// the constructor
|
// the constructor
|
||||||
String range = hostport.substring(hostport.indexOf(":") + 1);
|
String range = hostport.substring(hostport.indexOf(":") + 1);
|
||||||
if (range.startsWith("-"))
|
if (range.startsWith("-"))
|
||||||
ourfirstport = 0;
|
ourfirstport = 0;
|
||||||
else if (range.indexOf("-") == -1)
|
else if (range.indexOf("-") == -1)
|
||||||
ourfirstport = Integer.parseInt(range);
|
ourfirstport = Integer.parseInt(range);
|
||||||
else
|
else
|
||||||
ourfirstport =
|
ourfirstport =
|
||||||
Integer.parseInt(range.substring(0, range.indexOf("-")));
|
Integer.parseInt(range.substring(0, range.indexOf("-")));
|
||||||
|
|
||||||
if (range.endsWith("-"))
|
if (range.endsWith("-"))
|
||||||
ourlastport = 65535;
|
ourlastport = 65535;
|
||||||
else if (range.indexOf("-") == -1)
|
else if (range.indexOf("-") == -1)
|
||||||
ourlastport = Integer.parseInt(range);
|
ourlastport = Integer.parseInt(range);
|
||||||
else
|
else
|
||||||
ourlastport =
|
ourlastport =
|
||||||
Integer.parseInt(range.
|
Integer.parseInt(range.
|
||||||
substring(range.indexOf("-") + 1,
|
substring(range.indexOf("-") + 1,
|
||||||
range.length()));
|
range.length()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get theirs
|
// Get theirs
|
||||||
if (p.hostport.indexOf(":") == -1)
|
if (p.hostport.indexOf(":") == -1)
|
||||||
{
|
{
|
||||||
theirfirstport = 0;
|
theirfirstport = 0;
|
||||||
ourlastport = 65535;
|
ourlastport = 65535;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// This will dump if hostport if all sorts of bad data was passed to
|
// This will dump if hostport if all sorts of bad data was passed to
|
||||||
// the constructor
|
// the constructor
|
||||||
String range = p.hostport.substring(hostport.indexOf(":") + 1);
|
String range = p.hostport.substring(hostport.indexOf(":") + 1);
|
||||||
if (range.startsWith("-"))
|
if (range.startsWith("-"))
|
||||||
theirfirstport = 0;
|
theirfirstport = 0;
|
||||||
else if (range.indexOf("-") == -1)
|
else if (range.indexOf("-") == -1)
|
||||||
theirfirstport = Integer.parseInt(range);
|
theirfirstport = Integer.parseInt(range);
|
||||||
else
|
else
|
||||||
theirfirstport =
|
theirfirstport =
|
||||||
Integer.parseInt(range.substring(0, range.indexOf("-")));
|
Integer.parseInt(range.substring(0, range.indexOf("-")));
|
||||||
|
|
||||||
if (range.endsWith("-"))
|
if (range.endsWith("-"))
|
||||||
theirlastport = 65535;
|
theirlastport = 65535;
|
||||||
else if (range.indexOf("-") == -1)
|
else if (range.indexOf("-") == -1)
|
||||||
theirlastport = Integer.parseInt(range);
|
theirlastport = Integer.parseInt(range);
|
||||||
else
|
else
|
||||||
theirlastport =
|
theirlastport =
|
||||||
Integer.parseInt(range.
|
Integer.parseInt(range.
|
||||||
substring(range.indexOf("-") + 1,
|
substring(range.indexOf("-") + 1,
|
||||||
range.length()));
|
range.length()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now check them
|
// Now check them
|
||||||
|
@ -361,17 +361,17 @@ public final class SocketPermission extends Permission
|
||||||
String ourcanonical = null, theircanonical = null;
|
String ourcanonical = null, theircanonical = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ourcanonical = InetAddress.getByName(ourhost).getHostName();
|
ourcanonical = InetAddress.getByName(ourhost).getHostName();
|
||||||
theircanonical = InetAddress.getByName(theirhost).getHostName();
|
theircanonical = InetAddress.getByName(theirhost).getHostName();
|
||||||
}
|
}
|
||||||
catch (UnknownHostException e)
|
catch (UnknownHostException e)
|
||||||
{
|
{
|
||||||
// Who didn't resolve? Just assume current address is canonical enough
|
// Who didn't resolve? Just assume current address is canonical enough
|
||||||
// Is this ok to do?
|
// Is this ok to do?
|
||||||
if (ourcanonical == null)
|
if (ourcanonical == null)
|
||||||
ourcanonical = ourhost;
|
ourcanonical = ourhost;
|
||||||
if (theircanonical == null)
|
if (theircanonical == null)
|
||||||
theircanonical = theirhost;
|
theircanonical = theirhost;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ourcanonical.equals(theircanonical))
|
if (ourcanonical.equals(theircanonical))
|
||||||
|
@ -380,9 +380,9 @@ public final class SocketPermission extends Permission
|
||||||
// Well, last chance. Try for a wildcard
|
// Well, last chance. Try for a wildcard
|
||||||
if (ourhost.indexOf("*.") != -1)
|
if (ourhost.indexOf("*.") != -1)
|
||||||
{
|
{
|
||||||
String wild_domain = ourhost.substring(ourhost.indexOf("*" + 1));
|
String wild_domain = ourhost.substring(ourhost.indexOf("*" + 1));
|
||||||
if (theircanonical.endsWith(wild_domain))
|
if (theircanonical.endsWith(wild_domain))
|
||||||
return (true);
|
return (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Didn't make it
|
// Didn't make it
|
||||||
|
|
|
@ -82,12 +82,12 @@ public class URLDecoder
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return decode(s, "UTF-8");
|
return decode(s, "UTF-8");
|
||||||
}
|
}
|
||||||
catch (UnsupportedEncodingException uee)
|
catch (UnsupportedEncodingException uee)
|
||||||
{
|
{
|
||||||
// Should never happen since UTF-8 encoding should always be supported
|
// Should never happen since UTF-8 encoding should always be supported
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue