AcmeUtils { public static boolean isValidBase64Url(@Nullable String base64) { return base64 != null && BASE64URL_PATTERN.matcher(base64).matches(); } 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 testBase64UrlValidate() { assertThat(isValidBase64Url(null), is(false)); assertThat(isValidBase64Url(""), is(true)); assertThat(isValidBase64Url(" "), is(false)); assertThat(isValidBase64Url("Zg"), is(true)); assertThat(isValidBase64Url("Zg="), is(false)); assertThat(isValidBase64Url("Zg=="), is(false)); assertThat(isValidBase64Url("Zm9v"), is(true)); assertThat(isValidBase64Url(" Zm9v "), is(false)); assertThat(isValidBase64Url("<some>.illegal#Text"), is(false)); }