throws Exception
{
String remoteUrl = "http://localhost:" + server.getConnectors()[0].getLocalPort() + "/auth-test/";
String repoId = "testSiteWithAuth";
RepositoryRegistry repoRegistry = this.lookup(RepositoryRegistry.class);
TemplateProvider templateProvider =
this.lookup(TemplateProvider.class, DefaultRepositoryTemplateProvider.PROVIDER_ID);
Maven2ProxyRepositoryTemplate template =
(Maven2ProxyRepositoryTemplate) templateProvider.getTemplateById("default_proxy_release");
template.getCoreConfiguration().getConfiguration(true).setId(repoId);
template.getCoreConfiguration().getConfiguration(true).setName(repoId + "-name");
template.getCoreConfiguration().getConfiguration(true).setIndexable(false); // disable index
template.getCoreConfiguration().getConfiguration(true).setSearchable(false); // disable index
M2Repository m2Repo = (M2Repository) template.create();
repoRegistry.addRepository(m2Repo);
m2Repo.setRemoteUrl(remoteUrl);
m2Repo.setRemoteAuthenticationSettings(new UsernamePasswordRemoteAuthenticationSettings("admin", "admin"));
m2Repo.commitChanges();