TR03112Utils { public static boolean checkSameOriginPolicy(URL url1, URL url2) { LOG.debug("Checking SOP for {} and {}.", url1, url2); String endpointProtocol = url1.getProtocol(); String subjectProtocol = url2.getProtocol(); if (! endpointProtocol.equalsIgnoreCase(subjectProtocol)) { LOG.error("SOP violated; the protocols do not match."); return false; } String endpointHost = url1.getHost(); String subjectHost = url2.getHost(); if (! endpointHost.equalsIgnoreCase(subjectHost)) { LOG.error("SOP violated; the hosts do not match."); return false; } int endpointPort = url1.getPort(); if (endpointPort == -1) { endpointPort = url1.getDefaultPort(); } int subjectPort = url2.getPort(); if (subjectPort == -1) { subjectPort = url2.getDefaultPort(); } if (! (endpointPort == subjectPort)) { LOG.error("SOP violated; the ports do not match"); return false; } return true; }  static boolean checkSameOriginPolicy(URL url1, URL url2); static boolean isInCommCertificates(TlsServerCertificate serverCertificate, List<byte[]> commCertificates,
	    @Nullable String serverDesc); static boolean isRedirectStatusCode(int statusCode); static boolean DEVELOPER_MODE; }
@Test public void testSameOriginPolicy() throws MalformedURLException { URL url1 = new URL("http: URL url2 = new URL("http: boolean result = TR03112Utils.checkSameOriginPolicy(url1, url2); Assert.assertTrue(result); url2 = new URL("http: result = TR03112Utils.checkSameOriginPolicy(url1, url2); Assert.assertTrue(result); url2 = new URL("http: result = TR03112Utils.checkSameOriginPolicy(url1, url2); Assert.assertFalse(result); url2 = new URL("http: result = TR03112Utils.checkSameOriginPolicy(url1, url2); Assert.assertFalse(result); url2 = new URL("https: result = TR03112Utils.checkSameOriginPolicy(url1, url2); Assert.assertFalse(result); }