Search in sources :

Example 1 with InvalidDnsNameException

use of org.minidns.dnsname.InvalidDnsNameException in project Smack by igniterealtime.

the class InternetAddress method from.

public static InternetAddress from(String address) {
    final InternetAddress internetAddress;
    if (InetAddressUtil.isIpV4Address(address)) {
        internetAddress = new InternetAddress.Ipv4(address);
    } else if (InetAddressUtil.isIpV6Address(address)) {
        internetAddress = new InternetAddress.Ipv6(address);
    } else if (address.contains(".")) {
        InternetAddress domainNameInternetAddress;
        try {
            DnsName dnsName = DnsName.from(address);
            domainNameInternetAddress = new InternetAddress.DomainName(address, dnsName);
        } catch (InvalidDnsNameException e) {
            domainNameInternetAddress = new InternetAddress.InvalidDomainName(address, e);
        }
        internetAddress = domainNameInternetAddress;
    } else {
        DnsLabel dnsLabel = DnsLabel.from(address);
        internetAddress = new InternetAddress.DomainNameLabel(address, dnsLabel);
    }
    return internetAddress;
}
Also used : DnsName(org.minidns.dnsname.DnsName) DnsLabel(org.minidns.dnslabel.DnsLabel) InvalidDnsNameException(org.minidns.dnsname.InvalidDnsNameException)

Aggregations

DnsLabel (org.minidns.dnslabel.DnsLabel)1 DnsName (org.minidns.dnsname.DnsName)1 InvalidDnsNameException (org.minidns.dnsname.InvalidDnsNameException)1