Author: jawi
Date: Wed Jul 12 12:56:41 2017
New Revision: 1801735

URL: http://svn.apache.org/viewvc?rev=1801735&view=rev
Log:
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.


Modified:
    ace/trunk/org.apache.ace.gogo/bnd.bnd
    ace/trunk/org.apache.ace.gogo/src/org/apache/ace/gogo/Activator.java
    ace/trunk/org.apache.ace.gogo/src/org/apache/ace/gogo/repo/RepoCommands.java

Modified: ace/trunk/org.apache.ace.gogo/bnd.bnd
URL: 
http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.gogo/bnd.bnd?rev=1801735&r1=1801734&r2=1801735&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.gogo/bnd.bnd (original)
+++ ace/trunk/org.apache.ace.gogo/bnd.bnd Wed Jul 12 12:56:41 2017
@@ -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 @@ Private-Package: \
        org.osgi.impl.bundle.obr.*;-split-package:=merge-last,\
        org.xmlpull.v1;-split-package:=first,\
        org.kxml2.io;-split-package:=first
-       
+

Modified: ace/trunk/org.apache.ace.gogo/src/org/apache/ace/gogo/Activator.java
URL: 
http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.gogo/src/org/apache/ace/gogo/Activator.java?rev=1801735&r1=1801734&r2=1801735&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.gogo/src/org/apache/ace/gogo/Activator.java 
(original)
+++ ace/trunk/org.apache.ace.gogo/src/org/apache/ace/gogo/Activator.java Wed 
Jul 12 12:56:41 2017
@@ -20,6 +20,7 @@ package org.apache.ace.gogo;
 
 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 class Activator extends Dependenc
     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 @@ public class Activator extends Dependenc
 
         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);

Modified: 
ace/trunk/org.apache.ace.gogo/src/org/apache/ace/gogo/repo/RepoCommands.java
URL: 
http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.gogo/src/org/apache/ace/gogo/repo/RepoCommands.java?rev=1801735&r1=1801734&r2=1801735&view=diff
==============================================================================
--- 
ace/trunk/org.apache.ace.gogo/src/org/apache/ace/gogo/repo/RepoCommands.java 
(original)
+++ 
ace/trunk/org.apache.ace.gogo/src/org/apache/ace/gogo/repo/RepoCommands.java 
Wed Jul 12 12:56:41 2017
@@ -31,6 +31,10 @@ import static org.apache.ace.gogo.repo.R
 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 class RepoCommands {
     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")


Reply via email to