ArtifactResolutionProfileImpl extends ArtifactResolutionProfileBase { protected HostConfiguration getHostConfiguration(URI uri, SAMLMessageContext context) throws MessageEncodingException { try { HostConfiguration hc = httpClient.getHostConfiguration(); if (hc != null) { hc = new HostConfiguration(hc); } else { hc = new HostConfiguration(); } if (uri.getScheme().equalsIgnoreCase("http")) { log.debug("Using HTTP configuration"); hc.setHost(uri); } else { log.debug("Using HTTPS configuration"); CriteriaSet criteriaSet = new CriteriaSet(); criteriaSet.add(new EntityIDCriteria(context.getPeerEntityId())); criteriaSet.add(new MetadataCriteria(IDPSSODescriptor.DEFAULT_ELEMENT_NAME, SAMLConstants.SAML20P_NS)); criteriaSet.add(new UsageCriteria(UsageType.UNSPECIFIED)); X509TrustManager trustManager = new X509TrustManager(criteriaSet, context.getLocalSSLTrustEngine()); X509KeyManager manager = new X509KeyManager(context.getLocalSSLCredential()); HostnameVerifier hostnameVerifier = context.getLocalSSLHostnameVerifier(); ProtocolSocketFactory socketFactory = getSSLSocketFactory(context, manager, trustManager, hostnameVerifier); Protocol protocol = new Protocol("https", socketFactory, 443); hc.setHost(uri.getHost(), uri.getPort(), protocol); } return hc; } catch (URIException e) { throw new MessageEncodingException("Error parsing remote location URI", e); } } ArtifactResolutionProfileImpl(HttpClient httpClient);   }
@Test public void testHostConfigurationNoDefaults() throws Exception { HttpClient client = new HttpClient(); ArtifactResolutionProfileImpl artifactResolutionProfile = new ArtifactResolutionProfileImpl(client); URI uri = new URI("http", "test", "/artifact", null); HostConfiguration hostConfiguration = artifactResolutionProfile.getHostConfiguration(uri, null); assertNotNull(hostConfiguration); assertEquals("test", hostConfiguration.getHost()); }
@Test public void testHostConfigurationWithDefaults() throws Exception { HttpClient client = new HttpClient(); HostConfiguration defaultConfiguration = new HostConfiguration(); defaultConfiguration.setProxy("testProxy", 8000); defaultConfiguration.getParams().setParameter("testParam", "testValue"); client.setHostConfiguration(defaultConfiguration); ArtifactResolutionProfileImpl artifactResolutionProfile = new ArtifactResolutionProfileImpl(client); URI uri = new URI("http", "test", "/artifact", null); HostConfiguration hostConfiguration = artifactResolutionProfile.getHostConfiguration(uri, null); assertNotNull(hostConfiguration); assertEquals("test", hostConfiguration.getHost()); assertEquals("testProxy", hostConfiguration.getProxyHost()); assertEquals(8000, hostConfiguration.getProxyPort()); assertEquals("testValue", hostConfiguration.getParams().getParameter("testParam")); defaultConfiguration.setProxyHost(null); assertEquals("testProxy", hostConfiguration.getProxyHost()); assertEquals(8000, hostConfiguration.getProxyPort()); }