- Timestamp:
- Apr 27, 2004, 8:39:34 PM (22 years ago)
- Location:
- branches/GNU/src/gcc
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
libjava/java/net/SocketPermission.java (modified) (11 diffs, 1 prop)
Legend:
- Unmodified
- Added
- Removed
-
branches/GNU/src/gcc
- Property svn:ignore
-
old new 26 26 configure.vr 27 27 configure.vrs 28 28 29 Makefile 29 dir.info30 30 lost+found 31 31 update.out
-
- Property svn:ignore
-
branches/GNU/src/gcc/libjava/java/net/SocketPermission.java
-
Property cvs2svn:cvs-rev
changed from
1.1to1.1.1.2
r1390 r1391 1 1 /* SocketPermission.java -- Class modeling permissions for socket operations 2 Copyright (C) 1998, 2000, 2001 Free Software Foundation, Inc.2 Copyright (C) 1998, 2000, 2001 Free Software Foundation, Inc. 3 3 4 4 This file is part of GNU Classpath. … … 38 38 package java.net; 39 39 40 40 41 import java.security.Permission; 41 42 import java.security.PermissionCollection; … … 88 89 * Can connect to or accept connections from www.urbanophile.com on port 80 89 90 * SocketPermission("localhost:1024-", "listen,accept,connect"); 90 * Can connect to, accept from, an listen on any local port number 1024 and up. 91 * Can connect to, accept from, an listen on any local port number 1024 92 * and up. 91 93 * SocketPermission("*.edu", "connect"); 92 94 * Can connect to any host in the edu domain … … 100 102 */ 101 103 public final class SocketPermission extends Permission 102 implements java.io.Serializable104 implements Serializable 103 105 { 106 104 107 105 108 // FIXME: Needs serialization work, including readObject/writeObject methods. … … 119 122 * 120 123 * @param hostport The hostname/port number combination 121 * @param perms The actions string124 * @param s The actions string 122 125 */ 123 126 public SocketPermission(String hostport, String actions) … … 164 167 { 165 168 int hash = 100; 166 167 // FIXME: Get a real hash function 168 for (int i = 0; i < hostport.length(); i++) 169 hash = hash + (int) hostport.charAt(i) * 7; 170 171 return (hash); 169 if (hostport != null) 170 hash += hostport.hashCode(); 171 if (actions != null) 172 hash += actions.hashCode(); 173 return hash; 172 174 } 173 175 … … 242 244 * <li>The argument's hostname or IP address is equal to this object's. 243 245 * <li>The argument's canonical hostname is equal to this object's. 244 * <li>The argument's canonical name matches this domains hostname with wildcards 246 * <li>The argument's canonical name matches this domains hostname with 247 * wildcards 245 248 * </ul> 246 249 * … … 274 277 if (hostport.indexOf(":") == -1) 275 278 { 276 ourfirstport = 0;277 ourlastport = 65535;278 } 279 else 280 { 281 // FIXME: Needs bulletproofing.282 // This will dump if hostport if all sorts of bad data was passed to283 // the constructor284 String range = hostport.substring(hostport.indexOf(":") + 1);285 if (range.startsWith("-"))286 ourfirstport = 0;287 else if (range.indexOf("-") == -1)288 ourfirstport = Integer.parseInt(range);289 else290 ourfirstport =291 Integer.parseInt(range.substring(0, range.indexOf("-")));292 293 if (range.endsWith("-"))294 ourlastport = 65535;295 else if (range.indexOf("-") == -1)296 ourlastport = Integer.parseInt(range);297 else298 ourlastport =299 Integer.parseInt(range.300 substring(range.indexOf("-") + 1,301 range.length()));279 ourfirstport = 0; 280 ourlastport = 65535; 281 } 282 else 283 { 284 // FIXME: Needs bulletproofing. 285 // This will dump if hostport if all sorts of bad data was passed to 286 // the constructor 287 String range = hostport.substring(hostport.indexOf(":") + 1); 288 if (range.startsWith("-")) 289 ourfirstport = 0; 290 else if (range.indexOf("-") == -1) 291 ourfirstport = Integer.parseInt(range); 292 else 293 ourfirstport = 294 Integer.parseInt(range.substring(0, range.indexOf("-"))); 295 296 if (range.endsWith("-")) 297 ourlastport = 65535; 298 else if (range.indexOf("-") == -1) 299 ourlastport = Integer.parseInt(range); 300 else 301 ourlastport = 302 Integer.parseInt(range. 303 substring(range.indexOf("-") + 1, 304 range.length())); 302 305 } 303 306 … … 305 308 if (p.hostport.indexOf(":") == -1) 306 309 { 307 theirfirstport = 0;308 ourlastport = 65535;309 } 310 else 311 { 312 // This will dump if hostport if all sorts of bad data was passed to313 // the constructor314 String range = p.hostport.substring(hostport.indexOf(":") + 1);315 if (range.startsWith("-"))316 theirfirstport = 0;317 else if (range.indexOf("-") == -1)318 theirfirstport = Integer.parseInt(range);319 else320 theirfirstport =321 Integer.parseInt(range.substring(0, range.indexOf("-")));322 323 if (range.endsWith("-"))324 theirlastport = 65535;325 else if (range.indexOf("-") == -1)326 theirlastport = Integer.parseInt(range);327 else328 theirlastport =329 Integer.parseInt(range.330 substring(range.indexOf("-") + 1,331 range.length()));310 theirfirstport = 0; 311 ourlastport = 65535; 312 } 313 else 314 { 315 // This will dump if hostport if all sorts of bad data was passed to 316 // the constructor 317 String range = p.hostport.substring(hostport.indexOf(":") + 1); 318 if (range.startsWith("-")) 319 theirfirstport = 0; 320 else if (range.indexOf("-") == -1) 321 theirfirstport = Integer.parseInt(range); 322 else 323 theirfirstport = 324 Integer.parseInt(range.substring(0, range.indexOf("-"))); 325 326 if (range.endsWith("-")) 327 theirlastport = 65535; 328 else if (range.indexOf("-") == -1) 329 theirlastport = Integer.parseInt(range); 330 else 331 theirlastport = 332 Integer.parseInt(range. 333 substring(range.indexOf("-") + 1, 334 range.length())); 332 335 } 333 336 … … 359 362 try 360 363 { 361 ourcanonical = InetAddress.getByName(ourhost).getHostName();362 theircanonical = InetAddress.getByName(theirhost).getHostName();364 ourcanonical = InetAddress.getByName(ourhost).getHostName(); 365 theircanonical = InetAddress.getByName(theirhost).getHostName(); 363 366 } 364 367 catch (UnknownHostException e) 365 368 { 366 // Who didn't resolve? Just assume current address is canonical enough367 // Is this ok to do?368 if (ourcanonical == null)369 ourcanonical = ourhost;370 if (theircanonical == null)371 theircanonical = theirhost;369 // Who didn't resolve? Just assume current address is canonical enough 370 // Is this ok to do? 371 if (ourcanonical == null) 372 ourcanonical = ourhost; 373 if (theircanonical == null) 374 theircanonical = theirhost; 372 375 } 373 376 … … 378 381 if (ourhost.indexOf("*.") != -1) 379 382 { 380 String wild_domain = ourhost.substring(ourhost.indexOf("*" + 1));381 if (theircanonical.endsWith(wild_domain))382 return (true);383 String wild_domain = ourhost.substring(ourhost.indexOf("*" + 1)); 384 if (theircanonical.endsWith(wild_domain)) 385 return (true); 383 386 } 384 387 -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.
