Java 类sun.misc.JavaNetAccess 实例源码

项目:jdk8u-jdk    文件:SSLSocketImpl.java   
private synchronized void useImplicitHost(boolean noSniUpdate) {

        // Note: If the local name service is not trustworthy, reverse
        // host name resolution should not be performed for endpoint
        // identification.  Use the application original specified
        // hostname or IP address instead.

        // Get the original hostname via jdk.internal.misc.SharedSecrets
        InetAddress inetAddress = getInetAddress();
        if (inetAddress == null) {      // not connected
            return;
        }

        JavaNetAccess jna = SharedSecrets.getJavaNetAccess();
        String originalHostname = jna.getOriginalHostName(inetAddress);
        if ((originalHostname != null) &&
                (originalHostname.length() != 0)) {

            host = originalHostname;
            if (!noSniUpdate && serverNames.isEmpty() && !noSniExtension) {
                serverNames =
                        Utilities.addToSNIServerNameList(serverNames, host);

                if (!roleIsServer &&
                        (handshaker != null) && !handshaker.started()) {
                    handshaker.setSNIServerNames(serverNames);
                }
            }

            return;
        }

        // No explicitly specified hostname, no server name indication.
        if (!trustNameService) {
            // The local name service is not trustworthy, use IP address.
            host = inetAddress.getHostAddress();
        } else {
            // Use the underlying reverse host name resolution service.
            host = getInetAddress().getHostName();
        }
    }
项目:jdk8u_jdk    文件:SSLSocketImpl.java   
private synchronized void useImplicitHost(boolean noSniUpdate) {

        // Note: If the local name service is not trustworthy, reverse
        // host name resolution should not be performed for endpoint
        // identification.  Use the application original specified
        // hostname or IP address instead.

        // Get the original hostname via jdk.internal.misc.SharedSecrets
        InetAddress inetAddress = getInetAddress();
        if (inetAddress == null) {      // not connected
            return;
        }

        JavaNetAccess jna = SharedSecrets.getJavaNetAccess();
        String originalHostname = jna.getOriginalHostName(inetAddress);
        if ((originalHostname != null) &&
                (originalHostname.length() != 0)) {

            host = originalHostname;
            if (!noSniUpdate && serverNames.isEmpty() && !noSniExtension) {
                serverNames =
                        Utilities.addToSNIServerNameList(serverNames, host);

                if (!roleIsServer &&
                        (handshaker != null) && !handshaker.started()) {
                    handshaker.setSNIServerNames(serverNames);
                }
            }

            return;
        }

        // No explicitly specified hostname, no server name indication.
        if (!trustNameService) {
            // The local name service is not trustworthy, use IP address.
            host = inetAddress.getHostAddress();
        } else {
            // Use the underlying reverse host name resolution service.
            host = getInetAddress().getHostName();
        }
    }
项目:lookaside_java-1.8.0-openjdk    文件:SSLSocketImpl.java   
private synchronized void useImplicitHost(boolean noSniUpdate) {

        // Note: If the local name service is not trustworthy, reverse
        // host name resolution should not be performed for endpoint
        // identification.  Use the application original specified
        // hostname or IP address instead.

        // Get the original hostname via jdk.internal.misc.SharedSecrets
        InetAddress inetAddress = getInetAddress();
        if (inetAddress == null) {      // not connected
            return;
        }

        JavaNetAccess jna = SharedSecrets.getJavaNetAccess();
        String originalHostname = jna.getOriginalHostName(inetAddress);
        if ((originalHostname != null) &&
                (originalHostname.length() != 0)) {

            host = originalHostname;
            if (!noSniUpdate && serverNames.isEmpty() && !noSniExtension) {
                serverNames =
                        Utilities.addToSNIServerNameList(serverNames, host);

                if (!roleIsServer &&
                        (handshaker != null) && !handshaker.started()) {
                    handshaker.setSNIServerNames(serverNames);
                }
            }

            return;
        }

        // No explicitly specified hostname, no server name indication.
        if (!trustNameService) {
            // The local name service is not trustworthy, use IP address.
            host = inetAddress.getHostAddress();
        } else {
            // Use the underlying reverse host name resolution service.
            host = getInetAddress().getHostName();
        }
    }