Esempio n. 1
0
 private HttpClient getHttpClient(final UsernamePasswordToken usernamePasswordToken) {
   // risky, but we must blindly assume it is
   final DefaultHttpClient client = (DefaultHttpClient) hc4Provider.createHttpClient();
   if (usernamePasswordToken != null) {
     final List<String> authorisationPreference = new ArrayList<String>(2);
     authorisationPreference.add(AuthPolicy.DIGEST);
     authorisationPreference.add(AuthPolicy.BASIC);
     final Credentials credentials =
         new UsernamePasswordCredentials(
             usernamePasswordToken.getUsername(),
             String.valueOf(usernamePasswordToken.getPassword()));
     client.getCredentialsProvider().setCredentials(AuthScope.ANY, credentials);
     client.getParams().setParameter(AuthPNames.TARGET_AUTH_PREF, authorisationPreference);
   }
   return client;
 }
 public RepositoryMetadata readRemoteRepositoryMetadata(final String url)
     throws MetadataHandlerException, IOException {
   final Hc4RawTransport hc4RawTransport =
       new Hc4RawTransport(hc4Provider.createHttpClient(), url);
   return repositoryMetadataHandler.readRepositoryMetadata(hc4RawTransport);
 }