sun.misc.JavaNetAccess Java Examples

The following examples show how to use sun.misc.JavaNetAccess. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SSLSocketImpl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private static String getOriginalHostname(InetAddress inetAddress) {
    /*
     * Get the original hostname via sun.misc.SharedSecrets.
     */
    JavaNetAccess jna = SharedSecrets.getJavaNetAccess();
    String originalHostname = jna.getOriginalHostName(inetAddress);

    /*
     * If no application specified hostname, use the IP address.
     */
    if (originalHostname == null || originalHostname.length() == 0) {
        originalHostname = inetAddress.getHostAddress();
    }

    return originalHostname;
}
 
Example #2
Source File: SSLSocketImpl.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private static String getOriginalHostname(InetAddress inetAddress) {
    /*
     * Get the original hostname via sun.misc.SharedSecrets.
     */
    JavaNetAccess jna = SharedSecrets.getJavaNetAccess();
    String originalHostname = jna.getOriginalHostName(inetAddress);

    /*
     * If no application specified hostname, use the IP address.
     */
    if (originalHostname == null || originalHostname.length() == 0) {
        originalHostname = inetAddress.getHostAddress();
    }

    return originalHostname;
}
 
Example #3
Source File: HostNameAccessor.java    From openjsse with GNU General Public License v2.0 4 votes vote down vote up
public static String getOriginalHostName(InetAddress inetAddress) {
    JavaNetAccess jna = SharedSecrets.getJavaNetAccess();
    return jna.getOriginalHostName(inetAddress);
}
 
Example #4
Source File: SSLSocketImpl.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
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();
        }
    }
 
Example #5
Source File: SSLSocketImpl.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
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();
        }
    }
 
Example #6
Source File: SSLSocketImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
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();
        }
    }
 
Example #7
Source File: SSLSocketImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
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();
        }
    }
 
Example #8
Source File: SSLSocketImpl.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
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();
        }
    }
 
Example #9
Source File: SSLSocketImpl.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
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();
        }
    }