/** * Unicode域名转puny code * * @param unicode Unicode域名 * @return puny code * @since 4.1.22 */ public static String idnToASCII(String unicode) { return IDN.toASCII(unicode); }
/** * Unicode域名转puny code * * @param unicode Unicode域名 * @return puny code * @since 4.1.22 */ public static String idnToASCII(String unicode) { return IDN.toASCII(unicode); }
private static boolean keepsTrailingDot() { final String input = "a."; // must be a valid name return input.equals(IDN.toASCII(input)); } private static final boolean IDN_TOASCII_PRESERVES_TRAILING_DOTS = keepsTrailingDot();
/** * Equivalent to {@code toASCII(input, 0)}. * * @param input the Unicode name * @return the ACE name * @throws IllegalArgumentException if {@code input} does not conform to <a href="http://www.ietf.org/rfc/rfc3490.txt">RFC 3490</a> */ public static String toASCII(String input) { return toASCII(input, 0); }
/** * IDNA ASCII conversion and case normalization */ static String normalizeHostname(String hostname) { if (needsNormalization(hostname)) { hostname = IDN.toASCII(hostname, IDN.ALLOW_UNASSIGNED); } return hostname.toLowerCase(Locale.US); }
private static boolean keepsTrailingDot() { final String input = "a."; // must be a valid name return input.equals(IDN.toASCII(input)); } private static final boolean IDN_TOASCII_PRESERVES_TRAILING_DOTS = keepsTrailingDot();
/** * IDNA ASCII conversion and case normalization */ static String normalizeHostname(String hostname) { if (needsNormalization(hostname)) { hostname = IDN.toASCII(hostname, IDN.ALLOW_UNASSIGNED); } return hostname.toLowerCase(Locale.US); }
public static URL getIDNizedURL(URL inUrl) throws IllegalArgumentException { try { return new URL(inUrl.getProtocol(), IDN.toASCII(inUrl.getHost()), inUrl.getPort(), inUrl.getFile()); } catch(MalformedURLException ex) { throw new IllegalArgumentException(ex); } } }
private static String getSanitizedDomainName(String domainName) throws AcmeException { if (domainName == null) { throw acme.domainNameIsNull(); } domainName = IDN.toASCII(domainName.trim()); return domainName.toLowerCase(Locale.ROOT); }
/** * IDNA ASCII conversion and case normalization */ static String normalizeHostname(String hostname) { if (needsNormalization(hostname)) { hostname = IDN.toASCII(hostname, IDN.ALLOW_UNASSIGNED); } return hostname.toLowerCase(Locale.US); }
DnsEndpointGroupBuilder(String hostname) { this.hostname = Ascii.toLowerCase(IDN.toASCII(requireNonNull(hostname, "hostname"), IDN.ALLOW_UNASSIGNED)); }
String result = IDN.toASCII(host).toLowerCase(Locale.US); if (result.isEmpty()) return null;
final String ascii = IDN.toASCII(input); if (DomainValidator.IDNBUGHOLDER.IDN_TOASCII_PRESERVES_TRAILING_DOTS) { return ascii;
/** * Normalise ENS name as per the * <a href="http://docs.ens.domains/en/latest/implementers.html#normalising-and-validating-names">specification</a>. * * @param ensName our user input ENS name * @return normalised ens name * @throws EnsResolutionException if the name cannot be normalised */ public static String normalise(String ensName) { try { return IDN.toASCII(ensName, IDN.USE_STD3_ASCII_RULES) .toLowerCase(); } catch (IllegalArgumentException e) { throw new EnsResolutionException("Invalid ENS name provided: " + ensName); } } }
private static String hostname(String inetHost) { String hostname = IDN.toASCII(inetHost); // Check for http://bugs.java.com/bugdatabase/view_bug.do?bug_id=6894622 if (StringUtil.endsWith(inetHost, '.') && !StringUtil.endsWith(hostname, '.')) { hostname += "."; } return hostname; }
/** * IDNA ASCII conversion, case normalization and validation. */ static String normalizeDefaultHostname(String defaultHostname) { requireNonNull(defaultHostname, "defaultHostname"); if (needsNormalization(defaultHostname)) { defaultHostname = IDN.toASCII(defaultHostname, IDN.ALLOW_UNASSIGNED); } if (!HOSTNAME_PATTERN.matcher(defaultHostname).matches()) { throw new IllegalArgumentException("defaultHostname: " + defaultHostname); } return Ascii.toLowerCase(defaultHostname); }
/** * IDNA ASCII conversion, case normalization and validation. */ static String normalizeHostnamePattern(String hostnamePattern) { requireNonNull(hostnamePattern, "hostnamePattern"); if (needsNormalization(hostnamePattern)) { hostnamePattern = IDN.toASCII(hostnamePattern, IDN.ALLOW_UNASSIGNED); } if (!"*".equals(hostnamePattern) && !HOSTNAME_PATTERN.matcher(hostnamePattern.startsWith("*.") ? hostnamePattern.substring(2) : hostnamePattern).matches()) { throw new IllegalArgumentException("hostnamePattern: " + hostnamePattern); } return Ascii.toLowerCase(hostnamePattern); }
private static String hostname(String inetHost) { String hostname = IDN.toASCII(inetHost); // Check for http://bugs.java.com/bugdatabase/view_bug.do?bug_id=6894622 if (StringUtil.endsWith(inetHost, '.') && !StringUtil.endsWith(hostname, '.')) { hostname += "."; } return hostname; }
String result = IDN.toASCII(host).toLowerCase(Locale.US); if (result.isEmpty()) return null;
/** * Creates a new record. * * @param name the domain name * @param type the type of the record * @param dnsClass the class of the record, usually one of the following: * <ul> * <li>{@link #CLASS_IN}</li> * <li>{@link #CLASS_CSNET}</li> * <li>{@link #CLASS_CHAOS}</li> * <li>{@link #CLASS_HESIOD}</li> * <li>{@link #CLASS_NONE}</li> * <li>{@link #CLASS_ANY}</li> * </ul> * @param timeToLive the TTL value of the record */ protected AbstractDnsRecord(String name, DnsRecordType type, int dnsClass, long timeToLive) { if (timeToLive < 0) { throw new IllegalArgumentException("timeToLive: " + timeToLive + " (expected: >= 0)"); } // Convert to ASCII which will also check that the length is not too big. // See: // - https://github.com/netty/netty/issues/4937 // - https://github.com/netty/netty/issues/4935 this.name = appendTrailingDot(IDN.toASCII(checkNotNull(name, "name"))); this.type = checkNotNull(type, "type"); this.dnsClass = (short) dnsClass; this.timeToLive = timeToLive; }