ProtocolOriginRestrictionFilter extends BaseOriginRestrictionFilter { protected ProtocolOriginRestrictionFilter(Set<String> matchingProtocols, OriginMatchResults originMatchResults) { super(originMatchResults); this.matchingProtocols = matchingProtocols; } protected  ProtocolOriginRestrictionFilter(Set<String> matchingProtocols, OriginMatchResults originMatchResults); @Override boolean matches(URL url);  }
@Test public void testProtocolOriginRestrictionFilter() throws Exception { ProtocolOriginRestrictionFilter httpOnly = new ProtocolOriginRestrictionFilter(Collections.singleton("http"), OriginMatchResults.ALLOW); assertTrue(httpOnly.matches(new URL("http: assertEquals(OriginMatchResults.ALLOW, httpOnly.isAllowed(new URL("http: assertFalse(httpOnly.matches(new URL("https: assertEquals(OriginMatchResults.NO_MATCH, httpOnly.isAllowed(new URL("https: Set<String> protocolSet = new HashSet<>(Arrays.asList("http", "https")); ProtocolOriginRestrictionFilter httpAndHttpsDeny = new ProtocolOriginRestrictionFilter(protocolSet, OriginMatchResults.DENY); assertTrue(httpAndHttpsDeny.matches(new URL("http: assertEquals(OriginMatchResults.DENY, httpAndHttpsDeny.isAllowed(new URL("http: assertTrue(httpAndHttpsDeny.matches(new URL("https: assertEquals(OriginMatchResults.DENY, httpAndHttpsDeny.isAllowed(new URL("https: }