@Test public void shouldCheckContent() throws U2fBadInputException { ClientData clientData = new ClientData(CLIENT_DATA_REGISTRATION_BASE64); clientData.checkContent("navigator.id.finishEnrollment", SERVER_CHALLENGE_REGISTER_BASE64, Optional.<Set<String>>of(ImmutableSet.of(APP_ID_ENROLL))); }
public void checkContent(String type, String challenge, Optional<Set<String>> facets) throws U2fBadInputException { if (!type.equals(this.type)) { throw new U2fBadInputException("Bad clientData: wrong type " + this.type); } if (!challenge.equals(this.challenge)) { throw new U2fBadInputException("Bad clientData: wrong challenge"); } if (facets.isPresent()) { Set<String> allowedFacets = canonicalizeOrigins(facets.get()); String canonicalOrigin; try { canonicalOrigin = canonicalizeOrigin(origin); } catch (RuntimeException e) { throw new U2fBadInputException("Bad clientData: Malformed origin", e); } verifyOrigin(canonicalOrigin, allowedFacets); } }
ClientData { public void checkContent(String type, String challenge, Optional<Set<String>> facets) throws U2fBadInputException { if (!type.equals(this.type)) { throw new U2fBadInputException("Bad clientData: wrong type " + this.type); } if (!challenge.equals(this.challenge)) { throw new U2fBadInputException("Bad clientData: wrong challenge"); } if (facets.isPresent()) { Set<String> allowedFacets = canonicalizeOrigins(facets.get()); String canonicalOrigin; try { canonicalOrigin = canonicalizeOrigin(origin); } catch (RuntimeException e) { throw new U2fBadInputException("Bad clientData: Malformed origin", e); } verifyOrigin(canonicalOrigin, allowedFacets); } } }
ClientData { public void checkContent(String type, String challenge, Optional<Set<String>> facets) throws U2fBadInputException { if (!type.equals(this.type)) { throw new U2fBadInputException("Bad clientData: wrong type " + this.type); } if (!challenge.equals(this.challenge)) { throw new U2fBadInputException("Bad clientData: wrong challenge"); } if (facets.isPresent()) { Set<String> allowedFacets = canonicalizeOrigins(facets.get()); String canonicalOrigin; try { canonicalOrigin = canonicalizeOrigin(origin); } catch (RuntimeException e) { throw new U2fBadInputException("Bad clientData: Malformed origin", e); } verifyOrigin(canonicalOrigin, allowedFacets); } } ClientData(String clientData); }
ClientData { public void checkContent(String type, String challenge, Optional<Set<String>> facets) throws U2fBadInputException { if (!type.equals(this.type)) { throw new U2fBadInputException("Bad clientData: wrong type " + this.type); } if (!challenge.equals(this.challenge)) { throw new U2fBadInputException("Bad clientData: wrong challenge"); } if (facets.isPresent()) { Set<String> allowedFacets = canonicalizeOrigins(facets.get()); String canonicalOrigin; try { canonicalOrigin = canonicalizeOrigin(origin); } catch (RuntimeException e) { throw new U2fBadInputException("Bad clientData: Malformed origin", e); } verifyOrigin(canonicalOrigin, allowedFacets); } } ClientData(String clientData); String asJson(); @Override String toString(); String getChallenge(); void checkContent(String type, String challenge, Optional<Set<String>> facets); static Set<String> canonicalizeOrigins(Set<String> origins); static String canonicalizeOrigin(String url); }
ClientData { public void checkContent(String type, String challenge, Optional<Set<String>> facets) throws U2fBadInputException { if (!type.equals(this.type)) { throw new U2fBadInputException("Bad clientData: wrong type " + this.type); } if (!challenge.equals(this.challenge)) { throw new U2fBadInputException("Bad clientData: wrong challenge"); } if (facets.isPresent()) { Set<String> allowedFacets = canonicalizeOrigins(facets.get()); String canonicalOrigin; try { canonicalOrigin = canonicalizeOrigin(origin); } catch (RuntimeException e) { throw new U2fBadInputException("Bad clientData: Malformed origin", e); } verifyOrigin(canonicalOrigin, allowedFacets); } } ClientData(String clientData); String asJson(); @Override String toString(); String getChallenge(); void checkContent(String type, String challenge, Optional<Set<String>> facets); static Set<String> canonicalizeOrigins(Set<String> origins); static String canonicalizeOrigin(String url);  }