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:
Michael Koch 2003-02-13 07:33:40 +00:00 committed by Michael Koch
parent 4e3243ef0e
commit 05008212fb
8 changed files with 115 additions and 64 deletions

View file

@ -276,62 +276,62 @@ public final class SocketPermission extends Permission
// Get ours
if (hostport.indexOf(":") == -1)
{
ourfirstport = 0;
ourlastport = 65535;
ourfirstport = 0;
ourlastport = 65535;
}
else
{
// FIXME: Needs bulletproofing.
// This will dump if hostport if all sorts of bad data was passed to
// the constructor
String range = hostport.substring(hostport.indexOf(":") + 1);
if (range.startsWith("-"))
ourfirstport = 0;
else if (range.indexOf("-") == -1)
ourfirstport = Integer.parseInt(range);
else
ourfirstport =
Integer.parseInt(range.substring(0, range.indexOf("-")));
// FIXME: Needs bulletproofing.
// This will dump if hostport if all sorts of bad data was passed to
// the constructor
String range = hostport.substring(hostport.indexOf(":") + 1);
if (range.startsWith("-"))
ourfirstport = 0;
else if (range.indexOf("-") == -1)
ourfirstport = Integer.parseInt(range);
else
ourfirstport =
Integer.parseInt(range.substring(0, range.indexOf("-")));
if (range.endsWith("-"))
ourlastport = 65535;
else if (range.indexOf("-") == -1)
ourlastport = Integer.parseInt(range);
else
ourlastport =
Integer.parseInt(range.
substring(range.indexOf("-") + 1,
range.length()));
if (range.endsWith("-"))
ourlastport = 65535;
else if (range.indexOf("-") == -1)
ourlastport = Integer.parseInt(range);
else
ourlastport =
Integer.parseInt(range.
substring(range.indexOf("-") + 1,
range.length()));
}
// Get theirs
if (p.hostport.indexOf(":") == -1)
{
theirfirstport = 0;
ourlastport = 65535;
theirfirstport = 0;
ourlastport = 65535;
}
else
{
// This will dump if hostport if all sorts of bad data was passed to
// the constructor
String range = p.hostport.substring(hostport.indexOf(":") + 1);
if (range.startsWith("-"))
theirfirstport = 0;
else if (range.indexOf("-") == -1)
theirfirstport = Integer.parseInt(range);
else
theirfirstport =
Integer.parseInt(range.substring(0, range.indexOf("-")));
// This will dump if hostport if all sorts of bad data was passed to
// the constructor
String range = p.hostport.substring(hostport.indexOf(":") + 1);
if (range.startsWith("-"))
theirfirstport = 0;
else if (range.indexOf("-") == -1)
theirfirstport = Integer.parseInt(range);
else
theirfirstport =
Integer.parseInt(range.substring(0, range.indexOf("-")));
if (range.endsWith("-"))
theirlastport = 65535;
else if (range.indexOf("-") == -1)
theirlastport = Integer.parseInt(range);
else
theirlastport =
Integer.parseInt(range.
substring(range.indexOf("-") + 1,
range.length()));
if (range.endsWith("-"))
theirlastport = 65535;
else if (range.indexOf("-") == -1)
theirlastport = Integer.parseInt(range);
else
theirlastport =
Integer.parseInt(range.
substring(range.indexOf("-") + 1,
range.length()));
}
// Now check them
@ -361,17 +361,17 @@ public final class SocketPermission extends Permission
String ourcanonical = null, theircanonical = null;
try
{
ourcanonical = InetAddress.getByName(ourhost).getHostName();
theircanonical = InetAddress.getByName(theirhost).getHostName();
ourcanonical = InetAddress.getByName(ourhost).getHostName();
theircanonical = InetAddress.getByName(theirhost).getHostName();
}
catch (UnknownHostException e)
{
// Who didn't resolve? Just assume current address is canonical enough
// Is this ok to do?
if (ourcanonical == null)
ourcanonical = ourhost;
if (theircanonical == null)
theircanonical = theirhost;
// Who didn't resolve? Just assume current address is canonical enough
// Is this ok to do?
if (ourcanonical == null)
ourcanonical = ourhost;
if (theircanonical == null)
theircanonical = theirhost;
}
if (ourcanonical.equals(theircanonical))
@ -380,9 +380,9 @@ public final class SocketPermission extends Permission
// Well, last chance. Try for a wildcard
if (ourhost.indexOf("*.") != -1)
{
String wild_domain = ourhost.substring(ourhost.indexOf("*" + 1));
if (theircanonical.endsWith(wild_domain))
return (true);
String wild_domain = ourhost.substring(ourhost.indexOf("*" + 1));
if (theircanonical.endsWith(wild_domain))
return (true);
}
// Didn't make it