Top Fields Constructors Methods
org.hibernate.validator.internal.util

public final Class DomainNameUtil

extends Object
Class Inheritance
Static Imports
java.util.regex.Pattern.CASE_INSENSITIVE

Authors
Marko Bekhta, Guillaume Smet

Field Summary

Modifier and TypeField and Description
private static final String
private static final String
private static final String
private static final Pattern
DOMAIN_PATTERN

Regular expression for the domain part of an URL

A host string must be a domain string, an IPv4 address string, or "[", followed by an IPv6 address string, followed by "]".

private static final Pattern
EMAIL_DOMAIN_PATTERN

Regular expression for the domain part of an email address (everything after '@')

private static final String
private static final String
private static final int
MAX_DOMAIN_PART_LENGTH

This is the maximum length of a domain name.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static boolean

Returns:

true if the provided string is a valid domain, false otherwise
isValidDomainAddress
(String
the domain to check for validity
domain
)

Checks validity of a domain name.

private static boolean
public static boolean

Returns:

true if the provided string is a valid domain, false otherwise
isValidEmailDomainAddress
(String
domain to check for validity
domain
)

Checks the validity of the domain name used in an email.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DOMAINback to summary
private static final String DOMAIN
DOMAIN_CHARS_WITHOUT_DASHback to summary
private static final String DOMAIN_CHARS_WITHOUT_DASH
DOMAIN_LABELback to summary
private static final String DOMAIN_LABEL
DOMAIN_PATTERNback to summary
private static final Pattern DOMAIN_PATTERN

Regular expression for the domain part of an URL

A host string must be a domain string, an IPv4 address string, or "[", followed by an IPv6 address string, followed by "]".

EMAIL_DOMAIN_PATTERNback to summary
private static final Pattern EMAIL_DOMAIN_PATTERN

Regular expression for the domain part of an email address (everything after '@')

IP_DOMAINback to summary
private static final String IP_DOMAIN
IP_V6_DOMAINback to summary
private static final String IP_V6_DOMAIN
MAX_DOMAIN_PART_LENGTHback to summary
private static final int MAX_DOMAIN_PART_LENGTH

This is the maximum length of a domain name. But be aware that each label (parts separated by a dot) of the domain name must be at most 63 characters long. This is verified by IDN#toASCII(String).

Constructor Detail

DomainNameUtilback to summary
private DomainNameUtil()

Method Detail

isValidDomainAddressback to summary
public static boolean isValidDomainAddress(String domain)

Checks validity of a domain name.

Parameters
domain:String

the domain to check for validity

Returns:boolean

true if the provided string is a valid domain, false otherwise

isValidDomainAddressback to summary
private static boolean isValidDomainAddress(String domain, Pattern pattern)
isValidEmailDomainAddressback to summary
public static boolean isValidEmailDomainAddress(String domain)

Checks the validity of the domain name used in an email. To be valid it should be either a valid host name, or an IP address wrapped in [].

Parameters
domain:String

domain to check for validity

Returns:boolean

true if the provided string is a valid domain, false otherwise