965 return in;
966 }
967
968
969 //
970 // Same as java.net.URL.hostsEqual
971 //
972 private static boolean hostsEqual(URL u1, URL u2) {
973 final String h1 = u1.getHost();
974 final String h2 = u2.getHost();
975
976 if (h1 == null) {
977 return h2 == null;
978 } else if (h2 == null) {
979 return false;
980 } else if (h1.equalsIgnoreCase(h2)) {
981 return true;
982 }
983 // Have to resolve addresses before comparing, otherwise
984 // names like tachyon and tachyon.eng would compare different
985 final boolean result[] = {false};
986
987 java.security.AccessController.doPrivileged(
988 new java.security.PrivilegedAction<>() {
989 public Void run() {
990 try {
991 InetAddress a1 = InetAddress.getByName(h1);
992 InetAddress a2 = InetAddress.getByName(h2);
993 result[0] = a1.equals(a2);
994 } catch(UnknownHostException | SecurityException e) {
995 }
996 return null;
997 }
998 });
999
1000 return result[0];
1001 }
1002
1003 // overridden in HTTPS subclass
1004
1005 public void connect() throws IOException {
|
965 return in;
966 }
967
968
969 //
970 // Same as java.net.URL.hostsEqual
971 //
972 private static boolean hostsEqual(URL u1, URL u2) {
973 final String h1 = u1.getHost();
974 final String h2 = u2.getHost();
975
976 if (h1 == null) {
977 return h2 == null;
978 } else if (h2 == null) {
979 return false;
980 } else if (h1.equalsIgnoreCase(h2)) {
981 return true;
982 }
983 // Have to resolve addresses before comparing, otherwise
984 // names like tachyon and tachyon.eng would compare different
985 final boolean[] result = {false};
986
987 java.security.AccessController.doPrivileged(
988 new java.security.PrivilegedAction<>() {
989 public Void run() {
990 try {
991 InetAddress a1 = InetAddress.getByName(h1);
992 InetAddress a2 = InetAddress.getByName(h2);
993 result[0] = a1.equals(a2);
994 } catch(UnknownHostException | SecurityException e) {
995 }
996 return null;
997 }
998 });
999
1000 return result[0];
1001 }
1002
1003 // overridden in HTTPS subclass
1004
1005 public void connect() throws IOException {
|