AcmeUtils { public static void validateContact(URI contact) { if ("mailto".equalsIgnoreCase(contact.getScheme())) { String address = contact.toString().substring(7); if (MAIL_PATTERN.matcher(address).find()) { throw new IllegalArgumentException( "multiple recipients or hfields are not allowed: " + contact); } } } private  AcmeUtils(); static byte[] sha256hash(String z); static String hexEncode(byte[] data); static String base64UrlEncode(byte[] data); static byte[] base64UrlDecode(String base64); static boolean isValidBase64Url(@Nullable String base64); static String toAce(String domain); static Instant parseTimestamp(String str); @Nullable static String stripErrorPrefix(@Nullable String type); static void writeToPem(byte[] encoded, PemLabel label, Writer out); @Nullable static String getContentType(@Nullable String header); static void validateContact(URI contact);  }
@Test public void testValidateContact() { AcmeUtils.validateContact(URI.create("mailto:foo@example.com")); try { AcmeUtils.validateContact(URI.create("mailto:foo@example.com,bar@example.com")); fail("multiple recipients are accepted"); } catch (IllegalArgumentException ex) { } try { AcmeUtils.validateContact(URI.create("mailto:foo@example.com?to=bar@example.com")); fail("hfields are accepted"); } catch (IllegalArgumentException ex) { } try { AcmeUtils.validateContact(URI.create("mailto:?to=foo@example.com")); fail("hfields are accepted"); } catch (IllegalArgumentException ex) { } }