All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.bouncycastle.jsse.util.SNIUtil Maven / Gradle / Ivy

Go to download

The Bouncy Castle Java APIs for the TLS, including a JSSE provider. The APIs are designed primarily to be used in conjunction with the BC FIPS provider. The APIs may also be used with other providers although if being used in a FIPS context it is the responsibility of the user to ensure that any other providers used are FIPS certified and used appropriately.

There is a newer version: 2.0.19
Show newest version
package org.bouncycastle.jsse.util;

import java.net.URL;
import java.util.logging.Level;
import java.util.logging.Logger;

import org.bouncycastle.jsse.BCSNIHostName;
import org.bouncycastle.util.IPAddress;

public class SNIUtil
{
    private static final Logger LOG = Logger.getLogger(SNIUtil.class.getName());

    public static BCSNIHostName getBCSNIHostName(URL url)
    {
        if (null != url)
        {
            String host = url.getHost();
            if (null != host && host.indexOf('.') > 0 && !IPAddress.isValid(host))
            {
                try
                {
                    return new BCSNIHostName(host);
                }
                catch (Exception e)
                {
                    LOG.log(Level.FINER, "Failed to parse BCSNIHostName from URL: " + url, e);
                }
            }
        }
        return null;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy