@Test public void testNameCoverageSubdomainWithWildcardOfSameDomain() throws Exception { final String name = "xmpp.example.org"; final String pattern = "*.xmpp.example.org"; final boolean result = DNSUtil.isNameCoveredByPattern( name, pattern ); Assert.assertTrue( result ); }
public static boolean isNameCoveredByPattern( String name, String pattern ) { if ( name == null || name.isEmpty() || pattern == null || pattern.isEmpty() ) { throw new IllegalArgumentException( "Arguments cannot be null or empty." ); } final String needle = name.toLowerCase(); final String hayStack = pattern.toLowerCase(); if ( needle.equals( hayStack )) { return true; } if ( hayStack.startsWith( "*." ) ) { return needle.endsWith( hayStack.substring( 2 ) ); } return false; }
DNSUtil { public static boolean isNameCoveredByPattern( String name, String pattern ) { if ( name == null || name.isEmpty() || pattern == null || pattern.isEmpty() ) { throw new IllegalArgumentException( "Arguments cannot be null or empty." ); } final String needle = name.toLowerCase(); final String hayStack = pattern.toLowerCase(); if ( needle.equals( hayStack )) { return true; } if ( hayStack.startsWith( "*." ) ) { return needle.endsWith( hayStack.substring( 2 ) ); } return false; } }
DNSUtil { public static boolean isNameCoveredByPattern( String name, String pattern ) { if ( name == null || name.isEmpty() || pattern == null || pattern.isEmpty() ) { throw new IllegalArgumentException( "Arguments cannot be null or empty." ); } final String needle = name.toLowerCase(); final String hayStack = pattern.toLowerCase(); if ( needle.equals( hayStack )) { return true; } if ( hayStack.startsWith( "*." ) ) { return needle.endsWith( hayStack.substring( 2 ) ); } return false; }  }
DNSUtil { public static boolean isNameCoveredByPattern( String name, String pattern ) { if ( name == null || name.isEmpty() || pattern == null || pattern.isEmpty() ) { throw new IllegalArgumentException( "Arguments cannot be null or empty." ); } final String needle = name.toLowerCase(); final String hayStack = pattern.toLowerCase(); if ( needle.equals( hayStack )) { return true; } if ( hayStack.startsWith( "*." ) ) { return needle.endsWith( hayStack.substring( 2 ) ); } return false; }  static List<HostAddress> resolveXMPPDomain(String domain, int defaultPort); static Map<String, HostAddress> getDnsOverride(); static void setDnsOverride(Map<String, HostAddress> dnsOverride); static List<WeightedHostAddress> srvLookup(String service, String proto, String name); static boolean isNameCoveredByPattern( String name, String pattern ); static List<WeightedHostAddress> prioritize(WeightedHostAddress[] records); }
DNSUtil { public static boolean isNameCoveredByPattern( String name, String pattern ) { if ( name == null || name.isEmpty() || pattern == null || pattern.isEmpty() ) { throw new IllegalArgumentException( "Arguments cannot be null or empty." ); } final String needle = name.toLowerCase(); final String hayStack = pattern.toLowerCase(); if ( needle.equals( hayStack )) { return true; } if ( hayStack.startsWith( "*." ) ) { return needle.endsWith( hayStack.substring( 2 ) ); } return false; }  static List<HostAddress> resolveXMPPDomain(String domain, int defaultPort); static Map<String, HostAddress> getDnsOverride(); static void setDnsOverride(Map<String, HostAddress> dnsOverride); static List<WeightedHostAddress> srvLookup(String service, String proto, String name); static boolean isNameCoveredByPattern( String name, String pattern ); static List<WeightedHostAddress> prioritize(WeightedHostAddress[] records);  }