Java Code Examples for sun.net.util.IPAddressUtil#checkHostString()

The following examples show how to use sun.net.util.IPAddressUtil#checkHostString() . 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: URLStreamHandler.java    From dragonwell8_jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Sets the fields of the {@code URL} argument to the indicated values.
 * Only classes derived from URLStreamHandler are able
 * to use this method to set the values of the URL fields.
 *
 * @param   u         the URL to modify.
 * @param   protocol  the protocol name.
 * @param   host      the remote host value for the URL.
 * @param   port      the port on the remote machine.
 * @param   authority the authority part for the URL.
 * @param   userInfo the userInfo part of the URL.
 * @param   path      the path component of the URL.
 * @param   query     the query part for the URL.
 * @param   ref       the reference.
 * @exception       SecurityException       if the protocol handler of the URL is
 *                                  different from this one
 * @see     java.net.URL#set(java.lang.String, java.lang.String, int, java.lang.String, java.lang.String)
 * @since 1.3
 */
protected void setURL(URL u, String protocol, String host, int port,
                         String authority, String userInfo, String path,
                         String query, String ref) {
    if (this != u.handler) {
        throw new SecurityException("handler for url different from " +
                                    "this handler");
    } else if (host != null && u.isBuiltinStreamHandler(this)) {
        String s = IPAddressUtil.checkHostString(host);
        if (s != null) throw new IllegalArgumentException(s);
    }
    // ensure that no one can reset the protocol on a given URL.
    u.set(u.getProtocol(), host, port, authority, userInfo, path, query, ref);
}
 
Example 2
Source File: URLStreamHandler.java    From TencentKona-8 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Sets the fields of the {@code URL} argument to the indicated values.
 * Only classes derived from URLStreamHandler are able
 * to use this method to set the values of the URL fields.
 *
 * @param   u         the URL to modify.
 * @param   protocol  the protocol name.
 * @param   host      the remote host value for the URL.
 * @param   port      the port on the remote machine.
 * @param   authority the authority part for the URL.
 * @param   userInfo the userInfo part of the URL.
 * @param   path      the path component of the URL.
 * @param   query     the query part for the URL.
 * @param   ref       the reference.
 * @exception       SecurityException       if the protocol handler of the URL is
 *                                  different from this one
 * @see     java.net.URL#set(java.lang.String, java.lang.String, int, java.lang.String, java.lang.String)
 * @since 1.3
 */
protected void setURL(URL u, String protocol, String host, int port,
                         String authority, String userInfo, String path,
                         String query, String ref) {
    if (this != u.handler) {
        throw new SecurityException("handler for url different from " +
                                    "this handler");
    } else if (host != null && u.isBuiltinStreamHandler(this)) {
        String s = IPAddressUtil.checkHostString(host);
        if (s != null) throw new IllegalArgumentException(s);
    }
    // ensure that no one can reset the protocol on a given URL.
    u.set(u.getProtocol(), host, port, authority, userInfo, path, query, ref);
}
 
Example 3
Source File: URLStreamHandler.java    From openjdk-jdk8u with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Sets the fields of the {@code URL} argument to the indicated values.
 * Only classes derived from URLStreamHandler are able
 * to use this method to set the values of the URL fields.
 *
 * @param   u         the URL to modify.
 * @param   protocol  the protocol name.
 * @param   host      the remote host value for the URL.
 * @param   port      the port on the remote machine.
 * @param   authority the authority part for the URL.
 * @param   userInfo the userInfo part of the URL.
 * @param   path      the path component of the URL.
 * @param   query     the query part for the URL.
 * @param   ref       the reference.
 * @exception       SecurityException       if the protocol handler of the URL is
 *                                  different from this one
 * @see     java.net.URL#set(java.lang.String, java.lang.String, int, java.lang.String, java.lang.String)
 * @since 1.3
 */
protected void setURL(URL u, String protocol, String host, int port,
                         String authority, String userInfo, String path,
                         String query, String ref) {
    if (this != u.handler) {
        throw new SecurityException("handler for url different from " +
                                    "this handler");
    } else if (host != null && u.isBuiltinStreamHandler(this)) {
        String s = IPAddressUtil.checkHostString(host);
        if (s != null) throw new IllegalArgumentException(s);
    }
    // ensure that no one can reset the protocol on a given URL.
    u.set(u.getProtocol(), host, port, authority, userInfo, path, query, ref);
}
 
Example 4
Source File: URLStreamHandler.java    From Bytecoder with Apache License 2.0 3 votes vote down vote up
/**
 * Sets the fields of the {@code URL} argument to the indicated values.
 * Only classes derived from URLStreamHandler are able
 * to use this method to set the values of the URL fields.
 *
 * @param   u         the URL to modify.
 * @param   protocol  the protocol name.
 * @param   host      the remote host value for the URL.
 * @param   port      the port on the remote machine.
 * @param   authority the authority part for the URL.
 * @param   userInfo the userInfo part of the URL.
 * @param   path      the path component of the URL.
 * @param   query     the query part for the URL.
 * @param   ref       the reference.
 * @throws          SecurityException       if the protocol handler of the URL is
 *                                  different from this one
 * @since 1.3
 */
protected void setURL(URL u, String protocol, String host, int port,
                         String authority, String userInfo, String path,
                         String query, String ref) {
    if (this != u.handler) {
        throw new SecurityException("handler for url different from " +
                                    "this handler");
    } else if (host != null && u.isBuiltinStreamHandler(this)) {
        String s = IPAddressUtil.checkHostString(host);
        if (s != null) throw new IllegalArgumentException(s);
    }
    // ensure that no one can reset the protocol on a given URL.
    u.set(u.getProtocol(), host, port, authority, userInfo, path, query, ref);
}
 
Example 5
Source File: URLStreamHandler.java    From jdk8u_jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Sets the fields of the {@code URL} argument to the indicated values.
 * Only classes derived from URLStreamHandler are able
 * to use this method to set the values of the URL fields.
 *
 * @param   u         the URL to modify.
 * @param   protocol  the protocol name.
 * @param   host      the remote host value for the URL.
 * @param   port      the port on the remote machine.
 * @param   authority the authority part for the URL.
 * @param   userInfo the userInfo part of the URL.
 * @param   path      the path component of the URL.
 * @param   query     the query part for the URL.
 * @param   ref       the reference.
 * @exception       SecurityException       if the protocol handler of the URL is
 *                                  different from this one
 * @see     java.net.URL#set(java.lang.String, java.lang.String, int, java.lang.String, java.lang.String)
 * @since 1.3
 */
protected void setURL(URL u, String protocol, String host, int port,
                         String authority, String userInfo, String path,
                         String query, String ref) {
    if (this != u.handler) {
        throw new SecurityException("handler for url different from " +
                                    "this handler");
    } else if (host != null && u.isBuiltinStreamHandler(this)) {
        String s = IPAddressUtil.checkHostString(host);
        if (s != null) throw new IllegalArgumentException(s);
    }
    // ensure that no one can reset the protocol on a given URL.
    u.set(u.getProtocol(), host, port, authority, userInfo, path, query, ref);
}