< prev index next >

src/java.base/share/classes/java/net/SocketPermission.java

Print this page




 447         // is this a domain wildcard specification
 448         if (host.lastIndexOf('*') > 0) {
 449             throw new
 450                IllegalArgumentException("invalid host wildcard specification");
 451         } else if (host.startsWith("*")) {
 452             wildcard = true;
 453             if (host.equals("*")) {
 454                 cname = "";
 455             } else if (host.startsWith("*.")) {
 456                 cname = host.substring(1).toLowerCase();
 457             } else {
 458               throw new
 459                IllegalArgumentException("invalid host wildcard specification");
 460             }
 461             return;
 462         } else {
 463             if (host.length() > 0) {
 464                 // see if we are being initialized with an IP address.
 465                 char ch = host.charAt(0);
 466                 if (ch == ':' || Character.digit(ch, 16) != -1) {
 467                     byte ip[] = IPAddressUtil.textToNumericFormatV4(host);
 468                     if (ip == null) {
 469                         ip = IPAddressUtil.textToNumericFormatV6(host);
 470                     }
 471                     if (ip != null) {
 472                         try {
 473                             addresses =
 474                                 new InetAddress[]
 475                                 {InetAddress.getByAddress(ip) };
 476                             init_with_ip = true;
 477                         } catch (UnknownHostException uhe) {
 478                             // this shouldn't happen
 479                             invalid = true;
 480                         }
 481                     }
 482                 }
 483             }
 484         }
 485     }
 486 
 487     /**




 447         // is this a domain wildcard specification
 448         if (host.lastIndexOf('*') > 0) {
 449             throw new
 450                IllegalArgumentException("invalid host wildcard specification");
 451         } else if (host.startsWith("*")) {
 452             wildcard = true;
 453             if (host.equals("*")) {
 454                 cname = "";
 455             } else if (host.startsWith("*.")) {
 456                 cname = host.substring(1).toLowerCase();
 457             } else {
 458               throw new
 459                IllegalArgumentException("invalid host wildcard specification");
 460             }
 461             return;
 462         } else {
 463             if (host.length() > 0) {
 464                 // see if we are being initialized with an IP address.
 465                 char ch = host.charAt(0);
 466                 if (ch == ':' || Character.digit(ch, 16) != -1) {
 467                     byte[] ip = IPAddressUtil.textToNumericFormatV4(host);
 468                     if (ip == null) {
 469                         ip = IPAddressUtil.textToNumericFormatV6(host);
 470                     }
 471                     if (ip != null) {
 472                         try {
 473                             addresses =
 474                                 new InetAddress[]
 475                                 {InetAddress.getByAddress(ip) };
 476                             init_with_ip = true;
 477                         } catch (UnknownHostException uhe) {
 478                             // this shouldn't happen
 479                             invalid = true;
 480                         }
 481                     }
 482                 }
 483             }
 484         }
 485     }
 486 
 487     /**


< prev index next >