@Test public void testWkdAdvancedURL() { URL url = WebKeyDirectoryUtil.toWebKeyDirectoryURL("https: assertNotNull(url); assertEquals("openpgpkey.openkeychain.org", url.getHost()); assertEquals("https", url.getProtocol()); assertEquals("/.well-known/openpgpkey/openkeychain.org/hu/4hg7tescnttreaouu4z1izeuuyibwww1", url.getPath()); assertEquals("l=test-wkd", url.getQuery()); }
@Nullable public static URL toWebKeyDirectoryURL(String name, Boolean wkdMethodAdvanced) { if (name == null) { return null; } if (name.startsWith("https: try { return new URL(name); } catch (MalformedURLException e) { return null; } } Matcher matcher = EMAIL_PATTERN.matcher(name); if (!matcher.matches()) { return null; } String localPart = matcher.group(1); String encodedPart = ZBase32.encode(toSHA1(localPart.toLowerCase().getBytes())); String domain = matcher.group(2); try { if(wkdMethodAdvanced) { return new URL("https: }else{ return new URL("https: } } catch (MalformedURLException e) { return null; } catch (UnsupportedEncodingException e) { return null; } }
WebKeyDirectoryUtil { @Nullable public static URL toWebKeyDirectoryURL(String name, Boolean wkdMethodAdvanced) { if (name == null) { return null; } if (name.startsWith("https: try { return new URL(name); } catch (MalformedURLException e) { return null; } } Matcher matcher = EMAIL_PATTERN.matcher(name); if (!matcher.matches()) { return null; } String localPart = matcher.group(1); String encodedPart = ZBase32.encode(toSHA1(localPart.toLowerCase().getBytes())); String domain = matcher.group(2); try { if(wkdMethodAdvanced) { return new URL("https: }else{ return new URL("https: } } catch (MalformedURLException e) { return null; } catch (UnsupportedEncodingException e) { return null; } } }
WebKeyDirectoryUtil { @Nullable public static URL toWebKeyDirectoryURL(String name, Boolean wkdMethodAdvanced) { if (name == null) { return null; } if (name.startsWith("https: try { return new URL(name); } catch (MalformedURLException e) { return null; } } Matcher matcher = EMAIL_PATTERN.matcher(name); if (!matcher.matches()) { return null; } String localPart = matcher.group(1); String encodedPart = ZBase32.encode(toSHA1(localPart.toLowerCase().getBytes())); String domain = matcher.group(2); try { if(wkdMethodAdvanced) { return new URL("https: }else{ return new URL("https: } } catch (MalformedURLException e) { return null; } catch (UnsupportedEncodingException e) { return null; } } private  WebKeyDirectoryUtil(); }
WebKeyDirectoryUtil { @Nullable public static URL toWebKeyDirectoryURL(String name, Boolean wkdMethodAdvanced) { if (name == null) { return null; } if (name.startsWith("https: try { return new URL(name); } catch (MalformedURLException e) { return null; } } Matcher matcher = EMAIL_PATTERN.matcher(name); if (!matcher.matches()) { return null; } String localPart = matcher.group(1); String encodedPart = ZBase32.encode(toSHA1(localPart.toLowerCase().getBytes())); String domain = matcher.group(2); try { if(wkdMethodAdvanced) { return new URL("https: }else{ return new URL("https: } } catch (MalformedURLException e) { return null; } catch (UnsupportedEncodingException e) { return null; } } private  WebKeyDirectoryUtil(); @Nullable static URL toWebKeyDirectoryURL(String name, Boolean wkdMethodAdvanced); }
WebKeyDirectoryUtil { @Nullable public static URL toWebKeyDirectoryURL(String name, Boolean wkdMethodAdvanced) { if (name == null) { return null; } if (name.startsWith("https: try { return new URL(name); } catch (MalformedURLException e) { return null; } } Matcher matcher = EMAIL_PATTERN.matcher(name); if (!matcher.matches()) { return null; } String localPart = matcher.group(1); String encodedPart = ZBase32.encode(toSHA1(localPart.toLowerCase().getBytes())); String domain = matcher.group(2); try { if(wkdMethodAdvanced) { return new URL("https: }else{ return new URL("https: } } catch (MalformedURLException e) { return null; } catch (UnsupportedEncodingException e) { return null; } } private  WebKeyDirectoryUtil(); @Nullable static URL toWebKeyDirectoryURL(String name, Boolean wkdMethodAdvanced);  }