ACE-624 support OBRs with basic authentication
* Pass in the connection factory from ACE to the OBR repository, allowing it to
annotate URL connections with the right credentials;
* Fix was created by bramp in a private repository; ported it to the upstream
SVN repository.
git-svn-id: https://svn.apache.org/repos/asf/ace/trunk@1801735 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/org.apache.ace.gogo/bnd.bnd b/org.apache.ace.gogo/bnd.bnd
index 1b8c90f..620141b 100644
--- a/org.apache.ace.gogo/bnd.bnd
+++ b/org.apache.ace.gogo/bnd.bnd
@@ -8,15 +8,17 @@
org.osgi.impl.bundle.repoindex.lib;packages="org.osgi.service.indexer,org.osgi.service.indexer.impl",\
org.apache.felix.dependencymanager,\
org.apache.felix.gogo.runtime,\
+ org.apache.ace.bnd.registry;version=latest,\
org.apache.ace.bnd.repository;version=latest,\
org.apache.ace.log.server.store.api;version=latest,\
org.apache.ace.feedback.common;version=latest
Bundle-Name: Apache ACE Gogo commands
-Bundle-Description: Provides Gogo commands for working with ACE
+Bundle-Description: Provides Gogo commands for working with ACE
Bundle-Version: 1.0.2
Bundle-Activator: org.apache.ace.gogo.Activator
Private-Package: \
+ org.apache.ace.bnd.registry,\
org.apache.ace.bnd.repository,\
org.apache.ace.gogo,\
org.apache.ace.gogo.execute,\
@@ -85,4 +87,4 @@
org.osgi.impl.bundle.obr.*;-split-package:=merge-last,\
org.xmlpull.v1;-split-package:=first,\
org.kxml2.io;-split-package:=first
-
+
diff --git a/org.apache.ace.gogo/src/org/apache/ace/gogo/Activator.java b/org.apache.ace.gogo/src/org/apache/ace/gogo/Activator.java
index 5a53662..310b2fb 100644
--- a/org.apache.ace.gogo/src/org/apache/ace/gogo/Activator.java
+++ b/org.apache.ace.gogo/src/org/apache/ace/gogo/Activator.java
@@ -20,6 +20,7 @@
import java.util.Properties;
+import org.apache.ace.connectionfactory.ConnectionFactory;
import org.apache.ace.gogo.collection.CollectionCommands;
import org.apache.ace.gogo.execute.ExecuteCommands;
import org.apache.ace.gogo.execute.ScriptExecutor;
@@ -45,7 +46,8 @@
public void init(BundleContext context, DependencyManager manager) throws Exception {
manager.add(createComponent()
.setInterface(Object.class.getName(), createProps(RepoCommands.SCOPE, RepoCommands.FUNCTIONS))
- .setImplementation(RepoCommands.class));
+ .setImplementation(RepoCommands.class)
+ .add(createServiceDependency().setService(ConnectionFactory.class).setRequired(true)));
manager.add(createComponent()
.setInterface(Object.class.getName(), createProps(MathCommands.SCOPE, MathCommands.FUNCTIONS))
@@ -75,9 +77,8 @@
manager.add(createComponent()
.setInterface(Object.class.getName(), createProps(CollectionCommands.SCOPE, CollectionCommands.FUNCTIONS))
- .setImplementation(CollectionCommands.class)
- );
-
+ .setImplementation(CollectionCommands.class));
+
String script = System.getProperty("ace.gogo.script");
if (script != null) {
long delay = Long.getLong("ace.gogo.script.delay", 300L);
diff --git a/org.apache.ace.gogo/src/org/apache/ace/gogo/repo/RepoCommands.java b/org.apache.ace.gogo/src/org/apache/ace/gogo/repo/RepoCommands.java
index 1da4c49..c10254f 100644
--- a/org.apache.ace.gogo/src/org/apache/ace/gogo/repo/RepoCommands.java
+++ b/org.apache.ace.gogo/src/org/apache/ace/gogo/repo/RepoCommands.java
@@ -31,6 +31,10 @@
import java.net.URL;
import java.util.List;
+import org.apache.ace.bnd.registry.RegistryImpl;
+import org.apache.ace.bnd.repository.AceObrRepository;
+import org.apache.ace.bnd.repository.AceUrlConnector;
+import org.apache.ace.connectionfactory.ConnectionFactory;
import org.apache.felix.service.command.Descriptor;
import org.osgi.resource.Requirement;
import org.osgi.resource.Resource;
@@ -42,9 +46,17 @@
public final static String SCOPE = "repo";
public final static String[] FUNCTIONS = new String[] { "repo", "index", "ls", "cp", "rm", "cd", "d" };
+ private volatile ConnectionFactory m_connectionFactory;
+
@Descriptor("Defines a repository")
- public static CommandRepo repo(@Descriptor("the type e { R5, OBR }") String type, @Descriptor("url of the repository index") String location) throws Exception {
- return new CommandRepo(createRepository(type, location));
+ public CommandRepo repo(@Descriptor("the type e { R5, OBR }") String type, @Descriptor("url of the repository index") String location) throws Exception {
+ AceObrRepository repo = createRepository(type, location);
+
+ // ACE-624 allow support for different auth mechanisms...
+ RegistryImpl registry = new RegistryImpl(m_connectionFactory, new AceUrlConnector(m_connectionFactory));
+ repo.setRegistry(registry);
+
+ return new CommandRepo(repo);
}
@Descriptor("Indexes a directory")