ace-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1329199 [3/5] - in /ace/trunk: ./ ace-authenticationprocessor-basicauth/src/main/java/org/apache/ace/authenticationprocessor/basicauth/ ace-client-automation/src/main/java/org/apache/ace/client/automation/ ace-client-repository-api/src/mai...
Date Mon, 23 Apr 2012 12:15:06 GMT
Modified: ace/trunk/ace-deployment-provider-repositorybased/src/main/java/org/apache/ace/deployment/provider/repositorybased/RepositoryBasedProvider.java
URL: http://svn.apache.org/viewvc/ace/trunk/ace-deployment-provider-repositorybased/src/main/java/org/apache/ace/deployment/provider/repositorybased/RepositoryBasedProvider.java?rev=1329199&r1=1329198&r2=1329199&view=diff
==============================================================================
--- ace/trunk/ace-deployment-provider-repositorybased/src/main/java/org/apache/ace/deployment/provider/repositorybased/RepositoryBasedProvider.java (original)
+++ ace/trunk/ace-deployment-provider-repositorybased/src/main/java/org/apache/ace/deployment/provider/repositorybased/RepositoryBasedProvider.java Mon Apr 23 12:15:01 2012
@@ -39,6 +39,7 @@ import org.apache.ace.deployment.provide
 import org.apache.ace.deployment.provider.DeploymentProvider;
 import org.apache.ace.deployment.provider.impl.ArtifactDataImpl;
 import org.apache.ace.deployment.provider.repositorybased.BaseRepositoryHandler.XmlDeploymentArtifact;
+import org.apache.ace.connectionfactory.ConnectionFactory;
 import org.apache.ace.range.RangeIterator;
 import org.apache.ace.repository.Repository;
 import org.apache.ace.repository.ext.BackupRepository;
@@ -46,6 +47,7 @@ import org.apache.ace.repository.ext.Cac
 import org.apache.ace.repository.ext.impl.CachedRepositoryImpl;
 import org.apache.ace.repository.ext.impl.FilebasedBackupRepository;
 import org.apache.ace.repository.ext.impl.RemoteRepository;
+import org.apache.felix.dm.DependencyManager;
 import org.osgi.framework.Version;
 import org.osgi.service.cm.ConfigurationException;
 import org.osgi.service.cm.ManagedService;
@@ -59,6 +61,7 @@ public class RepositoryBasedProvider imp
     private static final String URL = "url";
     private static final String NAME = "name";
     private static final String CUSTOMER = "customer";
+    
     private volatile LogService m_log;
 
     /** This variable is volatile since it can be changed by the Updated() method. */
@@ -69,13 +72,14 @@ public class RepositoryBasedProvider imp
      * custom repository in the integration test.
      */
     private volatile Repository m_directRepository;
-    private final SAXParserFactory m_saxParserFactory;
-    
+    private volatile DependencyManager m_manager;
     
-    private Map<String,List<String>> m_cachedVersionLists = new LRUMap<String, List<String>>();
+    private final SAXParserFactory m_saxParserFactory;
+    private final Map<String,List<String>> m_cachedVersionLists;
 
     public RepositoryBasedProvider() {
         m_saxParserFactory = SAXParserFactory.newInstance();
+        m_cachedVersionLists = new LRUMap<String, List<String>>();
     }
 
     public List<ArtifactData> getBundleData(String targetId, String version) throws IllegalArgumentException, IOException {
@@ -380,27 +384,34 @@ public class RepositoryBasedProvider imp
             String name = getNotNull(settings, NAME, "RepositoryName not configured.");
             String customer = getNotNull(settings, CUSTOMER, "RepositoryCustomer not configured.");
 
-            //create the remote repository and set it.
+            // create the remote repository and set it.
             try {
-                BackupRepository backup = null;
-                try {
-                    backup = new FilebasedBackupRepository(File.createTempFile("currentrepository", null), File.createTempFile("backuprepository", null));
-                }
-                catch (Exception e) {
-                    m_log.log(LogService.LOG_WARNING, "Unable to create temporary files for FilebasedBackupRepository");
-                }
+                BackupRepository backup = new FilebasedBackupRepository(File.createTempFile("currentrepository", null), File.createTempFile("backuprepository", null));
 
                 // We always create the remote repository. If we can create a backup repository, we will wrap a CachedRepository
                 // around it.
                 m_directRepository = new RemoteRepository(new URL(url), customer, name);
+
+                m_manager.add(m_manager.createComponent()
+                    .setImplementation(m_directRepository)
+                    .add(m_manager.createServiceDependency()
+                        .setService(ConnectionFactory.class)
+                        .setRequired(true)));
+
                 m_cachedRepository = null;
                 if (backup != null) {
-                    m_cachedRepository = new CachedRepositoryImpl(null, m_directRepository, backup, CachedRepositoryImpl.UNCOMMITTED_VERSION);
+                    m_cachedRepository = new CachedRepositoryImpl(m_directRepository, backup, CachedRepositoryImpl.UNCOMMITTED_VERSION);
                 }
             }
+            catch (IllegalArgumentException e) {
+                throw new ConfigurationException("Authentication", e.getMessage());
+            }
             catch (MalformedURLException mue) {
                 throw new ConfigurationException(URL, mue.getMessage());
             }
+            catch (IOException e) {
+                m_log.log(LogService.LOG_WARNING, "Unable to create temporary files for FilebasedBackupRepository");
+            }
         }
     }
 

Modified: ace/trunk/ace-deployment-servlet/pom.xml
URL: http://svn.apache.org/viewvc/ace/trunk/ace-deployment-servlet/pom.xml?rev=1329199&r1=1329198&r2=1329199&view=diff
==============================================================================
--- ace/trunk/ace-deployment-servlet/pom.xml (original)
+++ ace/trunk/ace-deployment-servlet/pom.xml Mon Apr 23 12:15:01 2012
@@ -46,6 +46,7 @@
             org.apache.ace.deployment.processor;version=${project.version}
         </export.package>
         <import.package>
+            org.apache.ace.authentication.api;resolution:=optional;version=${project.version},
             org.apache.ace.deployment.processor;version=${project.version},
             org.apache.ace.deployment.provider;version=${project.version},
             org.apache.ace.deployment.streamgenerator;version=${project.version},
@@ -62,6 +63,10 @@
     <dependencies>
         <dependency>
             <groupId>org.apache.ace</groupId>
+            <artifactId>org.apache.ace.authentication.api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.ace</groupId>
             <artifactId>org.apache.ace.deployment.api</artifactId>
         </dependency>
         <dependency>

Modified: ace/trunk/ace-deployment-servlet/src/main/java/org/apache/ace/deployment/servlet/DeploymentServlet.java
URL: http://svn.apache.org/viewvc/ace/trunk/ace-deployment-servlet/src/main/java/org/apache/ace/deployment/servlet/DeploymentServlet.java?rev=1329199&r1=1329198&r2=1329199&view=diff
==============================================================================
--- ace/trunk/ace-deployment-servlet/src/main/java/org/apache/ace/deployment/servlet/DeploymentServlet.java (original)
+++ ace/trunk/ace-deployment-servlet/src/main/java/org/apache/ace/deployment/servlet/DeploymentServlet.java Mon Apr 23 12:15:01 2012
@@ -18,25 +18,33 @@
  */
 package org.apache.ace.deployment.servlet;
 
+import static javax.servlet.http.HttpServletResponse.SC_UNAUTHORIZED;
+
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.util.Dictionary;
 import java.util.List;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
 
+import javax.servlet.ServletException;
 import javax.servlet.ServletOutputStream;
 import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.apache.ace.authentication.api.AuthenticationService;
 import org.apache.ace.deployment.processor.DeploymentProcessor;
 import org.apache.ace.deployment.provider.DeploymentProvider;
 import org.apache.ace.deployment.streamgenerator.StreamGenerator;
+import org.apache.felix.dm.Component;
+import org.apache.felix.dm.DependencyManager;
 import org.osgi.framework.ServiceReference;
 import org.osgi.service.cm.ConfigurationException;
 import org.osgi.service.cm.ManagedService;
 import org.osgi.service.log.LogService;
+import org.osgi.service.useradmin.User;
 
 /**
  * The DeploymentServlet class provides in a list of versions available for a target and a stream
@@ -44,15 +52,26 @@ import org.osgi.service.log.LogService;
  */
 public class DeploymentServlet extends HttpServlet implements ManagedService {
     private static final long serialVersionUID = 1L;
+
+    /** A boolean denoting whether or not authentication is enabled. */
+    private static final String KEY_USE_AUTHENTICATION = "authentication.enabled";
+
     public static final String CURRENT = "current";
     public static final String PROCESSOR = "processor";
     public static final String VERSIONS = "versions";
     public static final String DP_MIMETYPE = "application/vnd.osgi.dp";
     public static final String TEXT_MIMETYPE = "text/plain";
-    private volatile LogService m_log;                  /* injected by dependency manager */
-    private volatile StreamGenerator m_streamGenerator; /* injected by dependency manager */
-    private volatile DeploymentProvider m_provider;     /* injected by dependency manager */
-    private final ConcurrentHashMap<String, DeploymentProcessor> m_processors = new ConcurrentHashMap<String, DeploymentProcessor>();
+    
+    private final ConcurrentMap<String, DeploymentProcessor> m_processors = new ConcurrentHashMap<String, DeploymentProcessor>();
+    
+    // injected by Dependency Manager
+    private volatile DependencyManager m_dm; 
+    private volatile LogService m_log;
+    private volatile StreamGenerator m_streamGenerator;
+    private volatile DeploymentProvider m_provider;
+    private volatile AuthenticationService m_authService;
+
+    private volatile boolean m_useAuth = false;
 
     /**
      * Responds to GET requests sent to this endpoint, the response depends on the requested path:
@@ -88,6 +107,50 @@ public class DeploymentServlet extends H
     }
 
     /**
+     * Called by Dependency Manager upon initialization of this component.
+     * 
+     * @param comp the component to initialize, cannot be <code>null</code>.
+     */
+    protected void init(Component comp) {
+        comp.add(m_dm.createServiceDependency()
+            .setService(AuthenticationService.class)
+            .setRequired(m_useAuth)
+            .setInstanceBound(true)
+            );
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+        if (!authenticate(req)) {
+            // Authentication failed; don't proceed with the original request...
+            resp.sendError(SC_UNAUTHORIZED);
+        } else {
+            // Authentication successful, proceed with original request...
+            super.service(req, resp);
+        }
+    }
+
+    /**
+     * Authenticates, if needed the user with the information from the given request.
+     * 
+     * @param request the request to obtain the credentials from, cannot be <code>null</code>.
+     * @return <code>true</code> if the authentication was successful, <code>false</code> otherwise.
+     */
+    private boolean authenticate(HttpServletRequest request) {
+        if (m_useAuth) {
+            User user = m_authService.authenticate(request);
+            if (user == null) {
+                m_log.log(LogService.LOG_INFO, "Authentication failure!");
+            }
+            return (user != null);
+        }
+        return true;
+    }
+
+    /**
      * Serve the case where requested path is like:
      * http://host/endpoint/targetid/versions/ returns a list of versions available for the specified target
      *
@@ -210,7 +273,19 @@ public class DeploymentServlet extends H
     }
 
     public void updated(Dictionary settings) throws ConfigurationException {
-        // Nothing needs to be done - handled by DependencyManager
+        if (settings != null) {
+            String useAuthString = (String) settings.get(KEY_USE_AUTHENTICATION);
+            if (useAuthString == null
+                || !("true".equalsIgnoreCase(useAuthString) || "false".equalsIgnoreCase(useAuthString))) {
+                throw new ConfigurationException(KEY_USE_AUTHENTICATION, "Missing or invalid value!");
+            }
+            boolean useAuth = Boolean.parseBoolean(useAuthString);
+
+            m_useAuth = useAuth;
+        }
+        else {
+            m_useAuth = false;
+        }
     }
 
     public void addProcessor(ServiceReference ref, DeploymentProcessor processor) {

Modified: ace/trunk/ace-deployment-streamgenerator/pom.xml
URL: http://svn.apache.org/viewvc/ace/trunk/ace-deployment-streamgenerator/pom.xml?rev=1329199&r1=1329198&r2=1329199&view=diff
==============================================================================
--- ace/trunk/ace-deployment-streamgenerator/pom.xml (original)
+++ ace/trunk/ace-deployment-streamgenerator/pom.xml Mon Apr 23 12:15:01 2012
@@ -64,6 +64,10 @@
             <artifactId>org.apache.ace.deployment.provider.api</artifactId>
         </dependency>
         <dependency>
+            <groupId>org.apache.ace</groupId>
+            <artifactId>org.apache.ace.connectionfactory</artifactId>
+        </dependency>
+        <dependency>
             <groupId>org.osgi</groupId>
             <artifactId>org.osgi.core</artifactId>
         </dependency>

Modified: ace/trunk/ace-deployment-streamgenerator/src/main/java/org/apache/ace/deployment/streamgenerator/impl/Activator.java
URL: http://svn.apache.org/viewvc/ace/trunk/ace-deployment-streamgenerator/src/main/java/org/apache/ace/deployment/streamgenerator/impl/Activator.java?rev=1329199&r1=1329198&r2=1329199&view=diff
==============================================================================
--- ace/trunk/ace-deployment-streamgenerator/src/main/java/org/apache/ace/deployment/streamgenerator/impl/Activator.java (original)
+++ ace/trunk/ace-deployment-streamgenerator/src/main/java/org/apache/ace/deployment/streamgenerator/impl/Activator.java Mon Apr 23 12:15:01 2012
@@ -18,6 +18,7 @@
  */
 package org.apache.ace.deployment.streamgenerator.impl;
 
+import org.apache.ace.connectionfactory.ConnectionFactory;
 import org.apache.ace.deployment.provider.DeploymentProvider;
 import org.apache.ace.deployment.streamgenerator.StreamGenerator;
 import org.apache.felix.dm.DependencyActivatorBase;
@@ -33,7 +34,11 @@ public class Activator extends Dependenc
             .add(createServiceDependency()
                 .setService(DeploymentProvider.class)
                 .setRequired(true)
-                )
+            )
+            .add(createServiceDependency()
+                .setService(ConnectionFactory.class)
+                .setRequired(true)
+            )
             );
     }
 

Modified: ace/trunk/ace-deployment-streamgenerator/src/main/java/org/apache/ace/deployment/streamgenerator/impl/StreamGeneratorImpl.java
URL: http://svn.apache.org/viewvc/ace/trunk/ace-deployment-streamgenerator/src/main/java/org/apache/ace/deployment/streamgenerator/impl/StreamGeneratorImpl.java?rev=1329199&r1=1329198&r2=1329199&view=diff
==============================================================================
--- ace/trunk/ace-deployment-streamgenerator/src/main/java/org/apache/ace/deployment/streamgenerator/impl/StreamGeneratorImpl.java (original)
+++ ace/trunk/ace-deployment-streamgenerator/src/main/java/org/apache/ace/deployment/streamgenerator/impl/StreamGeneratorImpl.java Mon Apr 23 12:15:01 2012
@@ -22,6 +22,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.lang.ref.SoftReference;
+import java.net.URLConnection;
 import java.util.Iterator;
 import java.util.List;
 import java.util.jar.Attributes;
@@ -29,6 +30,7 @@ import java.util.jar.JarOutputStream;
 import java.util.jar.Manifest;
 import java.util.zip.ZipEntry;
 
+import org.apache.ace.connectionfactory.ConnectionFactory;
 import org.apache.ace.deployment.provider.ArtifactData;
 import org.apache.ace.deployment.provider.DeploymentProvider;
 import org.apache.ace.deployment.streamgenerator.StreamGenerator;
@@ -39,6 +41,7 @@ import org.apache.ace.deployment.streamg
  */
 public class StreamGeneratorImpl implements StreamGenerator {
     private volatile DeploymentProvider m_provider;
+    private volatile ConnectionFactory m_connectionFactory;
 
     /**
      * Returns an input stream with the requested deployment package.
@@ -49,7 +52,6 @@ public class StreamGeneratorImpl impleme
      * @throws java.io.IOException when the stream could not be generated
      */
     public InputStream getDeploymentPackage(String id, String version) throws IOException {
-        //return execute(new Worker(id, version));
         List<ArtifactData> data = m_provider.getBundleData(id, version);
         Manifest manifest = new Manifest();
         Attributes main = manifest.getMainAttributes();
@@ -65,7 +67,7 @@ public class StreamGeneratorImpl impleme
             manifest.getEntries().put(bd.getFilename(), bd.getManifestAttributes(false));
         }
 
-        return DeploymentPackageStream.createStreamForThread(manifest, data.iterator(), false);
+        return DeploymentPackageStream.createStreamForThread(m_connectionFactory, manifest, data.iterator(), false);
     }
 
     /**
@@ -92,40 +94,35 @@ public class StreamGeneratorImpl impleme
             manifest.getEntries().put(bd.getFilename(), bd.getManifestAttributes(true));
         }
 
-        return DeploymentPackageStream.createStreamForThread(manifest, data.iterator(), true);
+        return DeploymentPackageStream.createStreamForThread(m_connectionFactory, manifest, data.iterator(), true);
     }
 
     private static final class DeploymentPackageStream extends InputStream {
         private byte[] m_readBuffer;
-
         private byte[] m_buffer;
-
-        private final OutputBuffer m_outputBuffer = new OutputBuffer(this);
-
         private JarOutputStream m_output;
-
         private Iterator<ArtifactData> m_iter;
-
         private InputStream m_current = null;
-
         private int m_pos = 0;
-
         private int m_max = 0;
-
         private boolean m_fixPack;
+        
+        private final OutputBuffer m_outputBuffer = new OutputBuffer(this);
+        private final ConnectionFactory m_connectionFactory;
 
-        private DeploymentPackageStream() {
-            this(64 * 1024);
+        private DeploymentPackageStream(ConnectionFactory connectionFactory) {
+            this(connectionFactory, 64 * 1024);
         }
 
-        private DeploymentPackageStream(int bufferSize) {
+        private DeploymentPackageStream(ConnectionFactory connectionFactory, int bufferSize) {
+            m_connectionFactory = connectionFactory;
             m_buffer = new byte[bufferSize];
             m_readBuffer = new byte[bufferSize];
         }
 
         private static final ThreadLocal<SoftReference<DeploymentPackageStream>> m_cache = new ThreadLocal<SoftReference<DeploymentPackageStream>>();
 
-        static DeploymentPackageStream createStreamForThread(Manifest man, Iterator<ArtifactData> iter, boolean fixpack) throws IOException {
+        static DeploymentPackageStream createStreamForThread(ConnectionFactory connectionFactory, Manifest man, Iterator<ArtifactData> iter, boolean fixpack) throws IOException {
             SoftReference<DeploymentPackageStream> ref = m_cache.get();
             DeploymentPackageStream dps = null;
             if (ref != null) {
@@ -133,12 +130,12 @@ public class StreamGeneratorImpl impleme
             }
 
             if (dps == null) {
-                dps = new DeploymentPackageStream();
+                dps = new DeploymentPackageStream(connectionFactory);
                 m_cache.set(new SoftReference<DeploymentPackageStream>(dps));
             }
 
             if (dps.isInUse()) {
-                dps = new DeploymentPackageStream();
+                dps = new DeploymentPackageStream(connectionFactory);
             }
 
             dps.init(man, iter, fixpack);
@@ -167,7 +164,7 @@ public class StreamGeneratorImpl impleme
                 m_output.close();
             }
             else if (!m_fixPack || current.hasChanged()) {
-                m_current = current.getUrl().openStream();
+                m_current = openStream(current);
                 m_output.putNextEntry(new ZipEntry(current.getFilename()));
             }
             else {
@@ -175,6 +172,11 @@ public class StreamGeneratorImpl impleme
             }
         }
 
+        private InputStream openStream(ArtifactData data) throws IOException {
+            URLConnection conn = m_connectionFactory.createConnection(data.getUrl());
+            return conn.getInputStream();
+        }
+
         @Override
         public int read() throws IOException {
             while (m_pos == m_max) {

Modified: ace/trunk/ace-deployment-streamgenerator/src/test/java/org/apache/ace/deployment/streamgenerator/impl/StreamTest.java
URL: http://svn.apache.org/viewvc/ace/trunk/ace-deployment-streamgenerator/src/test/java/org/apache/ace/deployment/streamgenerator/impl/StreamTest.java?rev=1329199&r1=1329198&r2=1329199&view=diff
==============================================================================
--- ace/trunk/ace-deployment-streamgenerator/src/test/java/org/apache/ace/deployment/streamgenerator/impl/StreamTest.java (original)
+++ ace/trunk/ace-deployment-streamgenerator/src/test/java/org/apache/ace/deployment/streamgenerator/impl/StreamTest.java Mon Apr 23 12:15:01 2012
@@ -20,13 +20,14 @@ package org.apache.ace.deployment.stream
 
 import static org.apache.ace.test.utils.TestUtils.BROKEN;
 import static org.apache.ace.test.utils.TestUtils.UNIT;
+import static org.ops4j.pax.swissbox.tinybundles.core.TinyBundles.newBundle;
 
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
-import java.net.URI;
 import java.net.URL;
+import java.net.URLConnection;
 import java.util.HashSet;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
@@ -36,14 +37,15 @@ import java.util.jar.JarEntry;
 import java.util.jar.JarInputStream;
 import java.util.jar.Manifest;
 
+import org.apache.ace.connectionfactory.ConnectionFactory;
 import org.apache.ace.deployment.provider.DeploymentProvider;
 import org.apache.ace.test.constants.TestConstants;
 import org.apache.ace.test.utils.TestUtils;
 import org.apache.ace.test.utils.deployment.TestProvider;
 import org.osgi.service.log.LogService;
+import org.osgi.service.useradmin.User;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
-import static org.ops4j.pax.swissbox.tinybundles.core.TinyBundles.*;
 
 /**
  * Unit tests for the deployment admin stream.
@@ -52,7 +54,6 @@ public class StreamTest {
     private static final int COPY_BUFFER_SIZE = 4096;
 
     private StreamGeneratorImpl m_generator;
-
     private TestProvider m_provider;
 
     @BeforeTest(alwaysRun = true)
@@ -78,6 +79,7 @@ public class StreamTest {
         m_provider.addData("A3.jar", "A3", url, "1.0.0", true);
         TestUtils.configureObject(m_generator, DeploymentProvider.class, m_provider);
         TestUtils.configureObject(m_generator, LogService.class);
+        TestUtils.configureObject(m_generator, ConnectionFactory.class, new MockConnectionFactory());
     }
 
     public static void main(String[] args) {
@@ -254,9 +256,7 @@ public class StreamTest {
 
             byte[] buffer = new byte[COPY_BUFFER_SIZE];
             int bytes = jis.read(buffer);
-            long size = 0;
             while (bytes != -1) {
-                size += bytes;
                 bytes = jis.read(buffer);
             }
 
@@ -311,4 +311,17 @@ public class StreamTest {
 
         assert m_failure == null : "Test failed: " + m_failure.getLocalizedMessage();
     }
+
+    /**
+     * Mock implementation of {@link ConnectionFactory}.
+     */
+    static final class MockConnectionFactory implements ConnectionFactory {
+        public URLConnection createConnection(URL url) throws IOException {
+            return url.openConnection();
+        }
+        
+        public URLConnection createConnection(URL url, User user) throws IOException {
+            return createConnection(url);
+        }
+    }
 }

Modified: ace/trunk/ace-deployment-task-base/pom.xml
URL: http://svn.apache.org/viewvc/ace/trunk/ace-deployment-task-base/pom.xml?rev=1329199&r1=1329198&r2=1329199&view=diff
==============================================================================
--- ace/trunk/ace-deployment-task-base/pom.xml (original)
+++ ace/trunk/ace-deployment-task-base/pom.xml Mon Apr 23 12:15:01 2012
@@ -77,6 +77,10 @@
             <artifactId>org.apache.ace.identification.api</artifactId>
         </dependency>
         <dependency>
+            <groupId>org.apache.ace</groupId>
+            <artifactId>org.apache.ace.connectionfactory</artifactId>
+        </dependency>
+        <dependency>
             <groupId>org.osgi</groupId>
             <artifactId>org.osgi.core</artifactId>
         </dependency>

Modified: ace/trunk/ace-deployment-task-base/src/main/java/org/apache/ace/deployment/service/impl/Activator.java
URL: http://svn.apache.org/viewvc/ace/trunk/ace-deployment-task-base/src/main/java/org/apache/ace/deployment/service/impl/Activator.java?rev=1329199&r1=1329198&r2=1329199&view=diff
==============================================================================
--- ace/trunk/ace-deployment-task-base/src/main/java/org/apache/ace/deployment/service/impl/Activator.java (original)
+++ ace/trunk/ace-deployment-task-base/src/main/java/org/apache/ace/deployment/service/impl/Activator.java Mon Apr 23 12:15:01 2012
@@ -23,6 +23,7 @@ import java.util.Map;
 import java.util.Properties;
 import java.util.concurrent.ConcurrentHashMap;
 
+import org.apache.ace.connectionfactory.ConnectionFactory;
 import org.apache.ace.deployment.Deployment;
 import org.apache.ace.deployment.service.DeploymentService;
 import org.apache.ace.discovery.Discovery;
@@ -144,6 +145,7 @@ public class Activator extends Dependenc
             .setInterface(DeploymentService.class.getName(), deploymentProperties)
             .setImplementation(deploymentService)
             .add(createServiceDependency().setService(Deployment.class).setRequired(true))
+            .add(createServiceDependency().setService(ConnectionFactory.class).setRequired(true))
             .add(createServiceDependency().setService(Identification.class, identificationFilter).setRequired(true))
             .add(createServiceDependency().setService(Discovery.class, discoveryFilter).setRequired(true))
             .add(createServiceDependency().setService(EventAdmin.class).setRequired(false))

Modified: ace/trunk/ace-deployment-task-base/src/main/java/org/apache/ace/deployment/service/impl/DeploymentServiceImpl.java
URL: http://svn.apache.org/viewvc/ace/trunk/ace-deployment-task-base/src/main/java/org/apache/ace/deployment/service/impl/DeploymentServiceImpl.java?rev=1329199&r1=1329198&r2=1329199&view=diff
==============================================================================
--- ace/trunk/ace-deployment-task-base/src/main/java/org/apache/ace/deployment/service/impl/DeploymentServiceImpl.java (original)
+++ ace/trunk/ace-deployment-task-base/src/main/java/org/apache/ace/deployment/service/impl/DeploymentServiceImpl.java Mon Apr 23 12:15:01 2012
@@ -27,6 +27,7 @@ import java.io.InputStreamReader;
 import java.net.MalformedURLException;
 import java.net.URISyntaxException;
 import java.net.URL;
+import java.net.URLConnection;
 import java.util.ArrayList;
 import java.util.Dictionary;
 import java.util.Iterator;
@@ -35,6 +36,7 @@ import java.util.Properties;
 import java.util.SortedSet;
 import java.util.TreeSet;
 
+import org.apache.ace.connectionfactory.ConnectionFactory;
 import org.apache.ace.deployment.Deployment;
 import org.apache.ace.deployment.service.DeploymentService;
 import org.apache.ace.discovery.Discovery;
@@ -57,6 +59,7 @@ public class DeploymentServiceImpl imple
     protected volatile Discovery m_discovery;
     protected volatile LogService m_log;
     protected volatile EventAdmin m_eventAdmin;
+    protected volatile ConnectionFactory m_connectionFactory;
 
     /**
      * @see org.apache.ace.deployment.service.DeploymentService#getHighestLocalVersion()
@@ -108,7 +111,7 @@ public class DeploymentServiceImpl imple
                 inputStream = new FileInputStream(file);
             }
             else {
-                inputStream = dataURL.openStream();
+                inputStream = getContents(dataURL);
             }
 
             // Post event for auditlog
@@ -234,7 +237,7 @@ public class DeploymentServiceImpl imple
     private SortedSet<Version> getVersionsFromServer(URL url) {
         BufferedReader bufReader = null;
         try {
-            bufReader = new BufferedReader(new InputStreamReader(url.openStream()));
+            bufReader = new BufferedReader(new InputStreamReader(getContents(url)));
             SortedSet<Version> versions = new TreeSet<Version>();
             
             String versionString;
@@ -253,6 +256,7 @@ public class DeploymentServiceImpl imple
             return versions;
         }
         catch (IOException ioe) {
+            m_log.log(LogService.LOG_DEBUG, "I/O error accessing server!", ioe);
             return null;
         }
         finally {
@@ -284,4 +288,13 @@ public class DeploymentServiceImpl imple
         return file;
     }
 
+    /**
+     * @param url the remote URL to connect to, cannot be <code>null</code>.
+     * @return an {@link InputStream} to the remote URL, never <code>null</code>.
+     * @throws IOException in case of I/O problems opening the remote connection.
+     */
+    private InputStream getContents(URL url) throws IOException {
+        URLConnection conn = m_connectionFactory.createConnection(url);
+        return conn.getInputStream();
+    }
 }
\ No newline at end of file

Modified: ace/trunk/ace-deployment-task-base/src/test/java/org/apache/ace/deployment/service/impl/DeploymentServiceImplTest.java
URL: http://svn.apache.org/viewvc/ace/trunk/ace-deployment-task-base/src/test/java/org/apache/ace/deployment/service/impl/DeploymentServiceImplTest.java?rev=1329199&r1=1329198&r2=1329199&view=diff
==============================================================================
--- ace/trunk/ace-deployment-task-base/src/test/java/org/apache/ace/deployment/service/impl/DeploymentServiceImplTest.java (original)
+++ ace/trunk/ace-deployment-task-base/src/test/java/org/apache/ace/deployment/service/impl/DeploymentServiceImplTest.java Mon Apr 23 12:15:01 2012
@@ -31,6 +31,7 @@ import java.net.URLConnection;
 import java.net.URLStreamHandler;
 import java.util.SortedSet;
 
+import org.apache.ace.connectionfactory.ConnectionFactory;
 import org.apache.ace.deployment.Deployment;
 import org.apache.ace.discovery.Discovery;
 import org.apache.ace.identification.Identification;
@@ -38,6 +39,7 @@ import org.apache.ace.test.utils.TestUti
 import org.osgi.framework.Version;
 import org.osgi.service.event.EventAdmin;
 import org.osgi.service.log.LogService;
+import org.osgi.service.useradmin.User;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
@@ -62,6 +64,7 @@ public class DeploymentServiceImplTest {
         
         TestUtils.configureObject(m_service, LogService.class);
         TestUtils.configureObject(m_service, EventAdmin.class);
+        TestUtils.configureObject(m_service, ConnectionFactory.class, new MockConnectionFactory());
         TestUtils.configureObject(m_service, Identification.class, new Identification() {
             public String getID() {
                 return "test";
@@ -171,7 +174,20 @@ public class DeploymentServiceImplTest {
 
         return new URL[] {controlEndpoint, dataEndpoint};
     }
-    
+
+    /**
+     * Mock implementation of {@link ConnectionFactory}.
+     */
+    static final class MockConnectionFactory implements ConnectionFactory {
+        public URLConnection createConnection(URL url) throws IOException {
+            return url.openConnection();
+        }
+        
+        public URLConnection createConnection(URL url, User user) throws IOException {
+            return createConnection(url);
+        }
+    }
+
     /**
      * Mock implementation of <code>DeploymentService</code> that expects Version objects.
      * The Version objects that are 'installed' can be mocked with the new <code>setList(Version[] objects)</code>

Modified: ace/trunk/ace-deployment-verifier-ui/pom.xml
URL: http://svn.apache.org/viewvc/ace/trunk/ace-deployment-verifier-ui/pom.xml?rev=1329199&r1=1329198&r2=1329199&view=diff
==============================================================================
--- ace/trunk/ace-deployment-verifier-ui/pom.xml (original)
+++ ace/trunk/ace-deployment-verifier-ui/pom.xml Mon Apr 23 12:15:01 2012
@@ -59,6 +59,14 @@
             <artifactId>org.apache.ace.deployment.verifier</artifactId>
         </dependency>
         <dependency>
+            <groupId>org.apache.ace</groupId>
+            <artifactId>org.apache.ace.connectionfactory</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.ace</groupId>
+            <artifactId>org.apache.ace.client.repository.api</artifactId>
+        </dependency>
+        <dependency>
             <groupId>org.osgi</groupId>
             <artifactId>org.osgi.core</artifactId>
             <version>4.3.0</version>

Modified: ace/trunk/ace-deployment-verifier-ui/src/main/java/org/apache/ace/deployment/verifier/ui/ACEVerifierExtension.java
URL: http://svn.apache.org/viewvc/ace/trunk/ace-deployment-verifier-ui/src/main/java/org/apache/ace/deployment/verifier/ui/ACEVerifierExtension.java?rev=1329199&r1=1329198&r2=1329199&view=diff
==============================================================================
--- ace/trunk/ace-deployment-verifier-ui/src/main/java/org/apache/ace/deployment/verifier/ui/ACEVerifierExtension.java (original)
+++ ace/trunk/ace-deployment-verifier-ui/src/main/java/org/apache/ace/deployment/verifier/ui/ACEVerifierExtension.java Mon Apr 23 12:15:01 2012
@@ -24,6 +24,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.PrintStream;
 import java.net.URL;
+import java.net.URLConnection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
@@ -40,6 +41,7 @@ import org.apache.ace.client.repository.
 import org.apache.ace.deployment.verifier.VerifierService;
 import org.apache.ace.deployment.verifier.VerifierService.VerifyEnvironment;
 import org.apache.ace.deployment.verifier.VerifierService.VerifyReporter;
+import org.apache.ace.connectionfactory.ConnectionFactory;
 import org.apache.ace.webui.NamedObject;
 import org.apache.ace.webui.UIExtensionFactory;
 import org.osgi.framework.Constants;
@@ -138,8 +140,10 @@ public class ACEVerifierExtension implem
         }
     }
 
+    // Injected by Dependency Manager
     private volatile VerifierService m_verifier;
     private volatile DeploymentVersionRepository m_repo;
+    private volatile ConnectionFactory m_connectionFactory;
 
     /**
      * {@inheritDoc}
@@ -370,7 +374,7 @@ public class ACEVerifierExtension implem
         JarInputStream jis = null;
 
         try {
-            is = new URL(bundle.getUrl()).openStream();
+            is = getBundleContents(bundle.getUrl());
             jis = new JarInputStream(is, false /* verify */);
 
             Map<String, String> manifest = getManifestEntries(jis.getManifest());
@@ -395,4 +399,14 @@ public class ACEVerifierExtension implem
             closeQuietly(jis);
         }
     }
+
+    /**
+     * @param url the remote URL to connect to, cannot be <code>null</code>.
+     * @return an {@link InputStream} to the remote URL, never <code>null</code>.
+     * @throws IOException in case of I/O problems opening the remote connection.
+     */
+    private InputStream getBundleContents(String url) throws IOException {
+        URLConnection conn = m_connectionFactory.createConnection(new URL(url));
+        return conn.getInputStream();
+    }
 }

Modified: ace/trunk/ace-deployment-verifier-ui/src/main/java/org/apache/ace/deployment/verifier/ui/Activator.java
URL: http://svn.apache.org/viewvc/ace/trunk/ace-deployment-verifier-ui/src/main/java/org/apache/ace/deployment/verifier/ui/Activator.java?rev=1329199&r1=1329198&r2=1329199&view=diff
==============================================================================
--- ace/trunk/ace-deployment-verifier-ui/src/main/java/org/apache/ace/deployment/verifier/ui/Activator.java (original)
+++ ace/trunk/ace-deployment-verifier-ui/src/main/java/org/apache/ace/deployment/verifier/ui/Activator.java Mon Apr 23 12:15:01 2012
@@ -21,6 +21,7 @@ package org.apache.ace.deployment.verifi
 import java.util.Properties;
 
 import org.apache.ace.client.repository.repository.DeploymentVersionRepository;
+import org.apache.ace.connectionfactory.ConnectionFactory;
 import org.apache.ace.deployment.verifier.VerifierService;
 import org.apache.ace.webui.UIExtensionFactory;
 import org.apache.felix.dm.DependencyActivatorBase;
@@ -42,6 +43,9 @@ public class Activator extends Dependenc
                 		.setService(VerifierService.class)
                 		.setRequired(true))
                 .add(createServiceDependency()
+                        .setService(ConnectionFactory.class)
+                        .setRequired(true))
+                .add(createServiceDependency()
                         .setService(DeploymentVersionRepository.class)
                         .setRequired(true)
                         ));

Modified: ace/trunk/ace-gateway-log/pom.xml
URL: http://svn.apache.org/viewvc/ace/trunk/ace-gateway-log/pom.xml?rev=1329199&r1=1329198&r2=1329199&view=diff
==============================================================================
--- ace/trunk/ace-gateway-log/pom.xml (original)
+++ ace/trunk/ace-gateway-log/pom.xml Mon Apr 23 12:15:01 2012
@@ -59,6 +59,10 @@
             <groupId>org.apache.ace</groupId>
             <artifactId>org.apache.ace.discovery.api</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.apache.ace</groupId>
+            <artifactId>org.apache.ace.connectionfactory</artifactId>
+        </dependency>
          <dependency>
             <groupId>org.apache.ace</groupId>
             <artifactId>org.apache.ace.scheduler.api</artifactId>

Modified: ace/trunk/ace-gateway-log/src/main/java/org/apache/ace/target/log/LogSyncConfigurator.java
URL: http://svn.apache.org/viewvc/ace/trunk/ace-gateway-log/src/main/java/org/apache/ace/target/log/LogSyncConfigurator.java?rev=1329199&r1=1329198&r2=1329199&view=diff
==============================================================================
--- ace/trunk/ace-gateway-log/src/main/java/org/apache/ace/target/log/LogSyncConfigurator.java (original)
+++ ace/trunk/ace-gateway-log/src/main/java/org/apache/ace/target/log/LogSyncConfigurator.java Mon Apr 23 12:15:01 2012
@@ -5,6 +5,7 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.Properties;
 
+import org.apache.ace.connectionfactory.ConnectionFactory;
 import org.apache.ace.discovery.Discovery;
 import org.apache.ace.identification.Identification;
 import org.apache.ace.scheduler.constants.SchedulerConstants;
@@ -77,6 +78,7 @@ public class LogSyncConfigurator impleme
             Component sync = m_manager.createComponent()
                 .setInterface(Runnable.class.getName(), properties)
                 .setImplementation(new LogSyncTask(name))
+                .add(m_manager.createServiceDependency().setService(ConnectionFactory.class).setRequired(true))
                 .add(m_manager.createServiceDependency().setService(LogStore.class, filterString).setRequired(true))
                 .add(m_manager.createServiceDependency().setService(Discovery.class, filterForDiscovery).setRequired(true))
                 .add(m_manager.createServiceDependency().setService(Identification.class, filterForIdentification).setRequired(true))

Modified: ace/trunk/ace-gateway-log/src/main/java/org/apache/ace/target/log/task/LogSyncTask.java
URL: http://svn.apache.org/viewvc/ace/trunk/ace-gateway-log/src/main/java/org/apache/ace/target/log/task/LogSyncTask.java?rev=1329199&r1=1329198&r2=1329199&view=diff
==============================================================================
--- ace/trunk/ace-gateway-log/src/main/java/org/apache/ace/target/log/task/LogSyncTask.java (original)
+++ ace/trunk/ace-gateway-log/src/main/java/org/apache/ace/target/log/task/LogSyncTask.java Mon Apr 23 12:15:01 2012
@@ -24,10 +24,13 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.OutputStreamWriter;
+import java.net.HttpURLConnection;
 import java.net.URL;
+import java.net.URLConnection;
 import java.util.Iterator;
 import java.util.List;
 
+import org.apache.ace.connectionfactory.ConnectionFactory;
 import org.apache.ace.discovery.Discovery;
 import org.apache.ace.identification.Identification;
 import org.apache.ace.log.LogDescriptor;
@@ -49,6 +52,7 @@ public class LogSyncTask implements Runn
     private volatile Identification m_identification;
     private volatile LogService m_log;
     private volatile LogStore m_LogStore;
+    private volatile ConnectionFactory m_connectionFactory;
 
     private final String m_endpoint;
 
@@ -76,26 +80,30 @@ public class LogSyncTask implements Runn
     	}
 
     	String targetId = m_identification.getID();
-        Connection sendConnection = null;
+        URLConnection sendConnection = null;
         try {
-            sendConnection = new Connection(new URL(host, m_endpoint + "/" + COMMAND_SEND));
+            sendConnection = m_connectionFactory.createConnection(new URL(host, m_endpoint + "/" + COMMAND_SEND));
+            sendConnection.setDoOutput(true);
+
             long[] logIDs = m_LogStore.getLogIDs();
             for (int i = 0; i < logIDs.length; i++) {
-                Connection queryConnection = new Connection(new URL(host,
-                        m_endpoint + "/" + COMMAND_QUERY + "?"
-                            + PARAMETER_TARGETID + "=" + targetId + "&"
-                            + PARAMETER_LOGID + "=" + logIDs[i]));
+                URL url = new URL(host, m_endpoint + "/" + COMMAND_QUERY + "?" + PARAMETER_TARGETID + "=" + targetId + "&" + PARAMETER_LOGID + "=" + logIDs[i]);
+                
+                URLConnection queryConnection = m_connectionFactory.createConnection(url);
                 // TODO: make sure no actual call is made using sendConnection
                 // when there's nothing to sync
                 synchronizeLog(logIDs[i], queryConnection.getInputStream(), sendConnection);
             }
+            
+            // Make sure to send the actual POST request...
+            sendConnection.getContent();
         }
         catch (IOException e) {
             m_log.log(LogService.LOG_ERROR, "Unable to (fully) synchronize log with remote (endpoint=" + m_endpoint + ")", e);
         }
         finally {
-            if (sendConnection != null) {
-                sendConnection.close();
+            if (sendConnection instanceof HttpURLConnection) {
+                ((HttpURLConnection) sendConnection).disconnect();
             }
         }
     }
@@ -116,18 +124,20 @@ public class LogSyncTask implements Runn
      *             If synchronization could not be completed due to an I/O
      *             failure.
      */
-    protected void synchronizeLog(long logID, InputStream queryInput, Connection sendConnection) throws IOException {
+    protected void synchronizeLog(long logID, InputStream queryInput, URLConnection sendConnection) throws IOException {
         long highestLocal = m_LogStore.getHighestID(logID);
         if (highestLocal == 0) {
             // No events, no need to synchronize
             return;
         }
+        
         SortedRangeSet localRange = new SortedRangeSet("1-" + highestLocal);
         SortedRangeSet remoteRange = getDescriptor(queryInput).getRangeSet();
         SortedRangeSet delta = remoteRange.diffDest(localRange);
         RangeIterator rangeIterator = delta.iterator();
-        BufferedWriter writer = null;
-        writer = new BufferedWriter(new OutputStreamWriter(sendConnection.getOutputStream()));
+
+        BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(sendConnection.getOutputStream()));
+        
         if (rangeIterator.hasNext()) {
             long lowest = rangeIterator.next();
             long highest = delta.getHigh();
@@ -148,6 +158,7 @@ public class LogSyncTask implements Runn
                 }
             }
         }
+
         writer.flush();
     }
 

Modified: ace/trunk/ace-gateway-log/src/test/java/org/apache/ace/target/log/task/LogSyncTaskTest.java
URL: http://svn.apache.org/viewvc/ace/trunk/ace-gateway-log/src/test/java/org/apache/ace/target/log/task/LogSyncTaskTest.java?rev=1329199&r1=1329198&r2=1329199&view=diff
==============================================================================
--- ace/trunk/ace-gateway-log/src/test/java/org/apache/ace/target/log/task/LogSyncTaskTest.java (original)
+++ ace/trunk/ace-gateway-log/src/test/java/org/apache/ace/target/log/task/LogSyncTaskTest.java Mon Apr 23 12:15:01 2012
@@ -23,6 +23,7 @@ import static org.apache.ace.test.utils.
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.net.HttpURLConnection;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Dictionary;
@@ -35,8 +36,6 @@ import org.apache.ace.log.LogDescriptor;
 import org.apache.ace.log.LogEvent;
 import org.apache.ace.range.SortedRangeSet;
 import org.apache.ace.target.log.store.LogStore;
-import org.apache.ace.target.log.task.Connection;
-import org.apache.ace.target.log.task.LogSyncTask;
 import org.apache.ace.test.utils.TestUtils;
 import org.osgi.service.log.LogService;
 import org.testng.annotations.BeforeMethod;
@@ -44,7 +43,7 @@ import org.testng.annotations.Test;
 
 public class LogSyncTaskTest {
 
-    private static final String GW_ID = "gwID";
+    private static final String TARGET_ID = "gwID";
     private LogSyncTask m_task;
 
     @BeforeMethod(alwaysRun = true)
@@ -53,7 +52,7 @@ public class LogSyncTaskTest {
         TestUtils.configureObject(m_task, LogService.class);
         TestUtils.configureObject(m_task, Identification.class, new Identification() {
             public String getID() {
-                return GW_ID;
+                return TARGET_ID;
             }
         });
         TestUtils.configureObject(m_task, Discovery.class);
@@ -62,7 +61,7 @@ public class LogSyncTaskTest {
 
     @Test(groups = { UNIT })
     public synchronized void getRange() throws Exception {
-        final LogDescriptor range = new LogDescriptor(GW_ID, 1, new SortedRangeSet("1-10"));
+        final LogDescriptor range = new LogDescriptor(TARGET_ID, 1, new SortedRangeSet("1-10"));
         m_task.getDescriptor(new InputStream() {
             int m_count = 0;
             byte[] m_bytes = (range.toRepresentation() + "\n").getBytes();
@@ -81,8 +80,8 @@ public class LogSyncTaskTest {
 
     @Test(groups = { UNIT })
     public synchronized void synchronizeLog() throws Exception {
-        final LogDescriptor range = new LogDescriptor(GW_ID, 1, new SortedRangeSet(new long[] {0}));
-        final LogEvent event = new LogEvent(GW_ID, 1, 1, 1, 1, new Properties());
+        final LogDescriptor range = new LogDescriptor(TARGET_ID, 1, new SortedRangeSet(new long[] {0}));
+        final LogEvent event = new LogEvent(TARGET_ID, 1, 1, 1, 1, new Properties());
         final List<LogEvent> events = new ArrayList<LogEvent>();
         events.add(event);
 
@@ -113,6 +112,7 @@ public class LogSyncTaskTest {
             public LogEvent put(int type, Dictionary props) throws IOException { return null; }
         });
         MockConnection connection = new MockConnection(new URL("http://mock"));
+        
         m_task.synchronizeLog(1, input, connection);
         String expectedString = event.toRepresentation() + "\n";
         String actualString = connection.getString();
@@ -120,7 +120,7 @@ public class LogSyncTaskTest {
         assert actualString.equals(expectedString) : "We expected " + expectedString + " but received " + actualString;
     }
 
-    private class MockConnection extends Connection {
+    private class MockConnection extends HttpURLConnection {
 
         private MockOutputStream m_output;
 
@@ -138,7 +138,20 @@ public class LogSyncTaskTest {
             return m_output;
         }
 
+        @Override
+        public void disconnect() {
+            // Nop
+        }
 
+        @Override
+        public boolean usingProxy() {
+            return false;
+        }
+
+        @Override
+        public void connect() throws IOException {
+            // Nop
+        }
     }
 
     private class MockOutputStream extends OutputStream {

Modified: ace/trunk/ace-http-redirector/src/main/java/org/apache/ace/http/redirector/Activator.java
URL: http://svn.apache.org/viewvc/ace/trunk/ace-http-redirector/src/main/java/org/apache/ace/http/redirector/Activator.java?rev=1329199&r1=1329198&r2=1329199&view=diff
==============================================================================
--- ace/trunk/ace-http-redirector/src/main/java/org/apache/ace/http/redirector/Activator.java (original)
+++ ace/trunk/ace-http-redirector/src/main/java/org/apache/ace/http/redirector/Activator.java Mon Apr 23 12:15:01 2012
@@ -13,7 +13,6 @@ import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
 import org.osgi.service.cm.ConfigurationException;
 import org.osgi.service.cm.ManagedServiceFactory;
-import org.osgi.service.log.LogService;
 
 public class Activator extends DependencyActivatorBase implements ManagedServiceFactory {
     private static final String PID = "org.apache.ace.http.redirector.factory";

Modified: ace/trunk/ace-integrationtests/pom.xml
URL: http://svn.apache.org/viewvc/ace/trunk/ace-integrationtests/pom.xml?rev=1329199&r1=1329198&r2=1329199&view=diff
==============================================================================
--- ace/trunk/ace-integrationtests/pom.xml (original)
+++ ace/trunk/ace-integrationtests/pom.xml Mon Apr 23 12:15:01 2012
@@ -107,9 +107,29 @@
 
         <dependency>
             <groupId>org.apache.ace</groupId>
+            <artifactId>org.apache.ace.connectionfactory</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.ace</groupId>
+            <artifactId>org.apache.ace.authentication</artifactId>
+        </dependency>
+        <dependency>
+        	<groupId>org.apache.ace</groupId>
+        	<artifactId>org.apache.ace.authenticationprocessor.basicauth</artifactId>
+        </dependency>
+        <dependency>
+        	<groupId>org.apache.ace</groupId>
+        	<artifactId>org.apache.ace.authenticationprocessor.clientcert</artifactId>
+        </dependency>
+        <dependency>
+        	<groupId>org.apache.ace</groupId>
+        	<artifactId>org.apache.ace.authenticationprocessor.password</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.ace</groupId>
             <artifactId>org.apache.ace.scheduler</artifactId>
         </dependency>
-      <dependency>
+        <dependency>
             <groupId>org.apache.ace</groupId>
             <artifactId>org.apache.ace.discovery.property</artifactId>
         </dependency>

Modified: ace/trunk/ace-integrationtests/src/test/java/org/apache/ace/it/Options.java
URL: http://svn.apache.org/viewvc/ace/trunk/ace-integrationtests/src/test/java/org/apache/ace/it/Options.java?rev=1329199&r1=1329198&r2=1329199&view=diff
==============================================================================
--- ace/trunk/ace-integrationtests/src/test/java/org/apache/ace/it/Options.java (original)
+++ ace/trunk/ace-integrationtests/src/test/java/org/apache/ace/it/Options.java Mon Apr 23 12:15:01 2012
@@ -18,6 +18,8 @@
  */
 package org.apache.ace.it;
 
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.container.def.options.VMOption;
 import org.ops4j.pax.exam.options.MavenArtifactProvisionOption;
 import org.ops4j.pax.exam.options.WrappedUrlProvisionOption;
 
@@ -69,6 +71,38 @@ public class Options {
             // we do this because we need access to some test classes that aren't exported
             return wrappedBundle(mavenBundle("org.apache.ace", "org.apache.ace.util")).overwriteManifest(WrappedUrlProvisionOption.OverwriteMode.FULL);
         }
+        
+        public static Option enableDebugger() {
+            return enableDebugger(true, 8787);
+        }
+        
+        public static Option enableDebugger(boolean suspend, int port) {
+            return new VMOption("-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=" + (suspend ? "y" : "n") + ",address=" + port);
+        }
+
+        public static MavenArtifactProvisionOption authenticationApi() {
+            return maven("org.apache.ace.authentication.api");
+        }
+
+        public static MavenArtifactProvisionOption authentication() {
+            return maven("org.apache.ace.authentication");
+        }
+
+        public static MavenArtifactProvisionOption authenticationProcessorBasicAuth() {
+            return maven("org.apache.ace.authenticationprocessor.basicauth");
+        }
+
+        public static MavenArtifactProvisionOption authenticationProcessorClientCert() {
+            return maven("org.apache.ace.authenticationprocessor.clientcert");
+        }
+
+        public static MavenArtifactProvisionOption authenticationProcessorPassword() {
+            return maven("org.apache.ace.authenticationprocessor.password");
+        }
+
+        public static MavenArtifactProvisionOption connectionFactory() {
+            return maven("org.apache.ace.connectionfactory");
+        }
 
         public static MavenArtifactProvisionOption rangeApi() {
             return maven("org.apache.ace.range.api");

Added: ace/trunk/ace-integrationtests/src/test/java/org/apache/ace/it/authentication/ObrAuthenticationTest.java
URL: http://svn.apache.org/viewvc/ace/trunk/ace-integrationtests/src/test/java/org/apache/ace/it/authentication/ObrAuthenticationTest.java?rev=1329199&view=auto
==============================================================================
--- ace/trunk/ace-integrationtests/src/test/java/org/apache/ace/it/authentication/ObrAuthenticationTest.java (added)
+++ ace/trunk/ace-integrationtests/src/test/java/org/apache/ace/it/authentication/ObrAuthenticationTest.java Mon Apr 23 12:15:01 2012
@@ -0,0 +1,367 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.ace.it.authentication;
+
+import static org.apache.ace.it.Options.jetty;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.CoreOptions.provision;
+import static org.ops4j.pax.exam.CoreOptions.systemProperty;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.jar.Attributes;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
+
+import org.apache.ace.client.repository.SessionFactory;
+import org.apache.ace.client.repository.helper.bundle.BundleHelper;
+import org.apache.ace.client.repository.repository.ArtifactRepository;
+import org.apache.ace.connectionfactory.ConnectionFactory;
+import org.apache.ace.it.IntegrationTestBase;
+import org.apache.ace.it.Options.Ace;
+import org.apache.ace.it.Options.Felix;
+import org.apache.ace.it.Options.Knopflerfish;
+import org.apache.ace.it.Options.Osgi;
+import org.apache.ace.obr.storage.file.constants.OBRFileStoreConstants;
+import org.apache.ace.repository.Repository;
+import org.apache.ace.repository.impl.constants.RepositoryConstants;
+import org.apache.ace.test.constants.TestConstants;
+import org.apache.ace.test.utils.FileUtils;
+import org.apache.ace.test.utils.NetUtils;
+import org.apache.felix.dm.Component;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.container.def.options.VMOption;
+import org.ops4j.pax.exam.junit.Configuration;
+import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.osgi.framework.Constants;
+import org.osgi.service.cm.ConfigurationAdmin;
+import org.osgi.service.useradmin.UserAdmin;
+
+/**
+ * Provides a test case in which the OBR has authentication enabled, and the 
+ * rest of ACE has to remain function correctly.
+ */
+@RunWith(JUnit4TestRunner.class)
+public class ObrAuthenticationTest extends IntegrationTestBase {
+    
+    private volatile String m_endpoint;
+    private volatile File m_storeLocation;
+    private volatile String m_authConfigPID;
+    
+    /* Injected by dependency manager */
+    private volatile ArtifactRepository m_artifactRepository; 
+    private volatile Repository m_userRepository;
+    private volatile UserAdmin m_userAdmin;
+    private volatile ConfigurationAdmin m_configAdmin;
+    private volatile ConnectionFactory m_connectionFactory;
+
+    /**
+     * @return the PAX Exam configuration options, never <code>null</code>.
+     */
+    @Configuration
+    public Option[] configuration() {
+        return options(
+            systemProperty("org.osgi.service.http.port").value("" + TestConstants.PORT),
+            new VMOption("-ea"),
+            provision(
+                // Misc bundles...
+                Osgi.compendium(),
+                Felix.dependencyManager(),
+                jetty(),
+                Felix.configAdmin(),
+                Felix.preferences(),
+                Felix.eventAdmin(),
+                Knopflerfish.useradmin(),
+                Knopflerfish.log(),
+                // ACE core bundles...
+                Ace.util(),
+                Ace.authentication(),
+                Ace.authenticationProcessorBasicAuth(),
+                Ace.connectionFactory(),
+                Ace.rangeApi(),
+                Ace.log(),
+                Ace.serverLogStore(),
+                Ace.httplistener(),
+                Ace.repositoryApi(),
+                Ace.repositoryImpl(),
+                Ace.repositoryServlet(),
+                Ace.configuratorServeruseradmin(),
+                Ace.obrMetadata(),
+                Ace.obrServlet(),
+                Ace.obrStorage(),
+                Ace.clientRepositoryApi(),
+                Ace.clientRepositoryImpl(),
+                Ace.clientRepositoryHelperBase(),
+                Ace.clientRepositoryHelperBundle(),
+                Ace.clientRepositoryHelperConfiguration(),
+                Ace.scheduler(),
+                Ace.resourceprocessorUseradmin(),
+                Ace.configuratorUseradminTask()
+            )
+        );
+    }
+
+    /**
+     * Sets up of the test case.
+     * 
+     * @throws java.lang.Exception not part of this test case.
+     */
+    @Before
+    public void setUp() throws Exception {
+        m_endpoint = "/obr";
+
+        String tmpDir = System.getProperty("java.io.tmpdir");
+        m_storeLocation = new File(tmpDir, "store");
+        m_storeLocation.delete();
+        m_storeLocation.mkdirs();
+    }
+
+    /**
+     * Tears down the set up of the test case.
+     * 
+     * @throws java.lang.Exception not part of this test case.
+     */
+    @After
+    public void tearDown() throws Exception {
+        FileUtils.removeDirectoryWithContent(m_storeLocation);
+    }
+
+    /**
+     * Test that we can retrieve the 'repository.xml' from the OBR.
+     */
+    @Test
+    public void testAccessObrRepositoryWithCredentialsOk() throws IOException {
+        URL url = new URL("http://localhost:" + TestConstants.PORT + m_endpoint + "/repository.xml");
+        
+        URLConnection conn = m_connectionFactory.createConnection(url);
+        assertNotNull(conn);
+
+        Object content = conn.getContent();
+        assertNotNull(content);
+    }
+
+    /**
+     * Test that we cannot retrieve the 'repository.xml' from the OBR without any credentials.
+     */
+    @Test(expected = IOException.class)
+    public void testAccessObrRepositoryWithoutCredentialsFail() throws IOException {
+        URL url = new URL("http://localhost:" + TestConstants.PORT + m_endpoint + "/repository.xml");
+        
+        // do NOT use connection factory as it will supply the credentials for us...
+        URLConnection conn = url.openConnection();
+        assertNotNull(conn);
+
+        // we expect a 401 for this URL...
+        NetUtils.waitForURL(url, 401, 15000);
+
+        // ...causing all other methods on URLConnection to fail...
+        conn.getContent(); // should fail!
+    }
+
+    /**
+     * Test that we cannot retrieve the 'repository.xml' from the OBR with incorrect credentials.
+     */
+    @Test(expected = IOException.class)
+    public void testAccessObrRepositoryWithWrongCredentialsFail() throws IOException {
+        org.osgi.service.cm.Configuration configuration = m_configAdmin.getConfiguration(m_authConfigPID);
+        assertNotNull(configuration);
+
+        // Simulate incorrect credentials by updating the config of the connection factory...
+        configuration.getProperties().put("authentication.user.name", "foo");
+        
+        configuration.update();
+
+        URL url = new URL("http://localhost:" + TestConstants.PORT + m_endpoint + "/repository.xml");
+        
+        // do NOT use connection factory as it will supply the credentials for us...
+        URLConnection conn = url.openConnection();
+        assertNotNull(conn);
+
+        // we expect a 401 for this URL...
+        NetUtils.waitForURL(url, 401, 15000);
+
+        // ...causing all other methods on URLConnection to fail...
+        conn.getContent(); // should fail!
+    }
+
+    /**
+     * Test that an import of an artifact through the API of ACE works, making sure they can access an authenticated OBR as well.
+     */
+    @Test
+    public void testImportArtifactWithCredentialsOk() throws Exception {
+        // Use a valid JAR file, without a Bundle-SymbolicName header.
+        Manifest manifest = new Manifest();
+        Attributes attributes = manifest.getMainAttributes();
+        attributes.putValue(Attributes.Name.MANIFEST_VERSION.toString(), "1");
+        attributes.putValue(Constants.BUNDLE_MANIFESTVERSION, "2");
+        attributes.putValue(BundleHelper.KEY_SYMBOLICNAME, "org.apache.ace.test");
+
+        File temp = File.createTempFile("org.apache.ace.test", ".jar");
+        temp.deleteOnExit();
+        JarOutputStream jos = new JarOutputStream(new FileOutputStream(temp), manifest);
+        jos.close();
+
+        m_artifactRepository.importArtifact(temp.toURI().toURL(), true /* upload */);
+
+        assertEquals(1, m_artifactRepository.get().size());
+        assertTrue(m_artifactRepository.getResourceProcessors().isEmpty());
+
+        // Create a JAR file which looks like a resource processor supplying bundle.
+        attributes.putValue(BundleHelper.KEY_RESOURCE_PROCESSOR_PID, "someProcessor");
+        attributes.putValue(BundleHelper.KEY_VERSION, "1.0.0.processor");
+
+        temp = File.createTempFile("org.apache.ace.test", ".jar");
+        temp.deleteOnExit();
+        jos = new JarOutputStream(new FileOutputStream(temp), manifest);
+        jos.close();
+
+        m_artifactRepository.importArtifact(temp.toURI().toURL(), true);
+
+        assertEquals(1, m_artifactRepository.get().size());
+        assertEquals(1, m_artifactRepository.getResourceProcessors().size());
+    }
+
+    /**
+     * Test that an import of an artifact through the API of ACE works, making sure they can access an authenticated OBR as well.
+     */
+    @Test(expected = IOException.class)
+    public void testImportArtifactWithoutCredentialsFail() throws Exception {
+        org.osgi.service.cm.Configuration configuration = m_configAdmin.getConfiguration(m_authConfigPID);
+        assertNotNull(configuration);
+
+        // Delete the credentials for the OBR-URL, thereby simulating wrong credentials for the OBR...
+        configuration.delete();
+
+        // Use a valid JAR file, without a Bundle-SymbolicName header.
+        Manifest manifest = new Manifest();
+        Attributes attributes = manifest.getMainAttributes();
+        attributes.putValue(Attributes.Name.MANIFEST_VERSION.toString(), "1");
+        attributes.putValue(Constants.BUNDLE_MANIFESTVERSION, "2");
+        attributes.putValue(BundleHelper.KEY_SYMBOLICNAME, "org.apache.ace.test");
+
+        File temp = File.createTempFile("org.apache.ace.test", ".jar");
+        temp.deleteOnExit();
+        JarOutputStream jos = new JarOutputStream(new FileOutputStream(temp), manifest);
+        jos.close();
+
+        m_artifactRepository.importArtifact(temp.toURI().toURL(), true /* upload */); // should fail!
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    protected void before() throws Exception {
+        final String fileLocation = m_storeLocation.getAbsolutePath();
+
+        getService(SessionFactory.class).createSession("test-session-ID");
+
+        configureFactory("org.apache.ace.server.repository.factory",
+            RepositoryConstants.REPOSITORY_NAME, "users",
+            RepositoryConstants.REPOSITORY_CUSTOMER, "apache",
+            RepositoryConstants.REPOSITORY_MASTER, "true");
+        configure("org.apache.ace.configurator.useradmin.task.UpdateUserAdminTask",
+            "repositoryName", "users",
+            "repositoryCustomer", "apache");
+        configure("org.apache.ace.scheduler",
+            "org.apache.ace.configurator.useradmin.task.UpdateUserAdminTask", "100");
+
+        configure("org.apache.ace.obr.servlet", 
+            "OBRInstance", "singleOBRServlet", 
+            "org.apache.ace.server.servlet.endpoint", m_endpoint, 
+            "authentication.enabled", "true");
+        configure("org.apache.ace.obr.storage.file", 
+            "OBRInstance", "singleOBRStore",
+            OBRFileStoreConstants.FILE_LOCATION_KEY, fileLocation);
+
+        String userName = "d";
+        String password = "f";
+
+        importSingleUser(userName, password);
+
+        URL obrURL = new URL("http://localhost:" + TestConstants.PORT + m_endpoint + "/");
+
+        m_authConfigPID = configureFactory("org.apache.ace.connectionfactory", 
+                "authentication.baseURL", obrURL.toExternalForm(), 
+                "authentication.type", "basic",
+                "authentication.user.name", userName,
+                "authentication.user.password", password);
+
+        URL testURL = new URL(obrURL, "repository.xml");
+
+        assertTrue("Failed to access OBR in time!", NetUtils.waitForURL(testURL, 401, 15000));
+        
+        m_artifactRepository.setObrBase(obrURL);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    protected Component[] getDependencies() {
+        return new Component[] {
+            createComponent()
+                .setImplementation(this)
+                .add(createServiceDependency().setService(ArtifactRepository.class).setRequired(true))
+                .add(createServiceDependency().setService(ConnectionFactory.class).setRequired(true))
+                .add(createServiceDependency().setService(ConfigurationAdmin.class).setRequired(true))
+                .add(createServiceDependency().setService(UserAdmin.class).setRequired(true))
+                .add(createServiceDependency()
+                    .setService(Repository.class, "(&(" + RepositoryConstants.REPOSITORY_NAME + "=users)(" + RepositoryConstants.REPOSITORY_CUSTOMER + "=apache))")
+                    .setRequired(true))
+        };
+    }           
+
+    /**
+     * Imports a single user into the user repository.
+     * 
+     * @param userName the name of the user to import;
+     * @param password the password of the user to import.
+     * @throws Exception in case of exceptions during the import.
+     */
+    private void importSingleUser(String userName, String password) throws Exception {
+        ByteArrayInputStream bis = new ByteArrayInputStream((
+            "<roles>" +
+                "<user name=\"" + userName + "\">" +
+                "<properties><username>" + userName + "</username></properties>" +
+                "<credentials><password type=\"String\">" + password + "</password></credentials>" +
+                "</user>" +
+            "</roles>").getBytes());
+
+        assertTrue("Committing test user data failed!", m_userRepository.commit(bis, m_userRepository.getRange().getHigh()));
+
+        int count = 0;
+        while ((m_userAdmin.getRole(userName) == null) && (count++ < 60)) {
+            Thread.sleep(100);
+        }
+        assertTrue("Failed to obtain user from userAdmin!", count != 60);
+    }
+}

Propchange: ace/trunk/ace-integrationtests/src/test/java/org/apache/ace/it/authentication/ObrAuthenticationTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: ace/trunk/ace-integrationtests/src/test/java/org/apache/ace/it/deployment/DeploymentIntegrationTest.java
URL: http://svn.apache.org/viewvc/ace/trunk/ace-integrationtests/src/test/java/org/apache/ace/it/deployment/DeploymentIntegrationTest.java?rev=1329199&r1=1329198&r2=1329199&view=diff
==============================================================================
--- ace/trunk/ace-integrationtests/src/test/java/org/apache/ace/it/deployment/DeploymentIntegrationTest.java (original)
+++ ace/trunk/ace-integrationtests/src/test/java/org/apache/ace/it/deployment/DeploymentIntegrationTest.java Mon Apr 23 12:15:01 2012
@@ -18,12 +18,34 @@
  */
 package org.apache.ace.it.deployment;
 
+import static org.apache.ace.it.Options.jetty;
+import static org.ops4j.pax.exam.CoreOptions.maven;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.CoreOptions.provision;
+import static org.ops4j.pax.exam.CoreOptions.systemProperty;
+import static org.ops4j.pax.exam.CoreOptions.wrappedBundle;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.Semaphore;
+import java.util.concurrent.TimeUnit;
+
 import org.apache.ace.deployment.provider.ArtifactData;
 import org.apache.ace.deployment.provider.impl.ArtifactDataImpl;
 import org.apache.ace.discovery.property.constants.DiscoveryConstants;
 import org.apache.ace.http.listener.constants.HttpConstants;
 import org.apache.ace.identification.property.constants.IdentificationConstants;
 import org.apache.ace.it.IntegrationTestBase;
+import org.apache.ace.it.Options.Ace;
+import org.apache.ace.it.Options.Felix;
+import org.apache.ace.it.Options.Osgi;
 import org.apache.ace.scheduler.constants.SchedulerConstants;
 import org.apache.ace.test.constants.TestConstants;
 import org.apache.ace.test.utils.deployment.BundleStreamGenerator;
@@ -38,7 +60,6 @@ import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleEvent;
 import org.osgi.framework.BundleListener;
 import org.osgi.framework.ServiceRegistration;
-import org.osgi.service.cm.Configuration;
 import org.osgi.service.cm.ConfigurationAdmin;
 import org.osgi.service.deploymentadmin.DeploymentAdmin;
 import org.osgi.service.deploymentadmin.DeploymentException;
@@ -48,17 +69,6 @@ import org.osgi.service.event.EventConst
 import org.osgi.service.event.EventHandler;
 import org.osgi.service.http.HttpService;
 
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.*;
-import java.util.concurrent.Semaphore;
-import java.util.concurrent.TimeUnit;
-
-import static org.apache.ace.it.Options.*;
-import static org.ops4j.pax.exam.CoreOptions.maven;
-import static org.ops4j.pax.exam.CoreOptions.*;
-
 @RunWith(JUnit4TestRunner.class)
 public class DeploymentIntegrationTest extends IntegrationTestBase implements BundleListener, EventHandler {
 
@@ -76,6 +86,8 @@ public class DeploymentIntegrationTest e
                 Felix.configAdmin(),
                 Felix.eventAdmin(),
                 Felix.deploymentAdmin(),
+                Ace.authenticationApi(),
+                Ace.connectionFactory(),
                 Ace.scheduler(),
                 Ace.deploymentProviderApi(),
                 Ace.deploymentProviderFilebased(),
@@ -112,7 +124,7 @@ public class DeploymentIntegrationTest e
 
     public static final String HOST = "localhost";
     public static final String GWID = "gw-id";
-    public static final long POLL_INTERVAL = 1000;
+    public static final String POLL_INTERVAL = "1000";
     private volatile ConfigurationAdmin m_config;
     private volatile DeploymentAdmin m_deployment;
     private volatile File m_tempDir;
@@ -343,14 +355,13 @@ public class DeploymentIntegrationTest e
 
     private void configureTarget() throws IOException {
         // configure discovery bundle
-        setProperty(DiscoveryConstants.DISCOVERY_PID, new Object[][] { { DiscoveryConstants.DISCOVERY_URL_KEY, "http://" + HOST + ":" + TestConstants.PORT } });
+        configure(DiscoveryConstants.DISCOVERY_PID, DiscoveryConstants.DISCOVERY_URL_KEY, "http://" + HOST + ":" + TestConstants.PORT);
         // configure identification bundle
-        setProperty(IdentificationConstants.IDENTIFICATION_PID, new Object[][] { { IdentificationConstants.IDENTIFICATION_TARGETID_KEY, GWID } });
+        configure(IdentificationConstants.IDENTIFICATION_PID, IdentificationConstants.IDENTIFICATION_TARGETID_KEY, GWID);
         // configure scheduler
-        setProperty(SchedulerConstants.SCHEDULER_PID, new Object[][] {
-            { "org.apache.ace.target.auditlog.task.AuditLogSyncTask", POLL_INTERVAL },
-            { "org.apache.ace.deployment.task.DeploymentUpdateTask", POLL_INTERVAL }
-            });
+        configure(SchedulerConstants.SCHEDULER_PID,
+             "org.apache.ace.target.auditlog.task.AuditLogSyncTask", POLL_INTERVAL,
+             "org.apache.ace.deployment.task.DeploymentUpdateTask", POLL_INTERVAL);
     }
 
     private void unconfigureTarget() throws IOException {
@@ -366,22 +377,9 @@ public class DeploymentIntegrationTest e
 
     private void configureServer() throws IOException {
         // configure data bundle
-        setProperty(org.apache.ace.deployment.servlet.Activator.PID, new Object[][] { { HttpConstants.ENDPOINT, "/deployment" } });
+        configure(org.apache.ace.deployment.servlet.Activator.PID, HttpConstants.ENDPOINT, "/deployment", "authentication.enabled", "false");
         // configure file based backend
-        setProperty(org.apache.ace.deployment.provider.filebased.Activator.PID, new Object[][] { { "BaseDirectoryName", m_tempDir.getAbsolutePath() } });
-    }
-
-    @SuppressWarnings("unchecked")
-    private void setProperty(String pid, Object[][] props) throws IOException {
-        Configuration configuration = m_config.getConfiguration(pid, null);
-        Dictionary dictionary = configuration.getProperties();
-        if (dictionary == null) {
-            dictionary = new Hashtable();
-        }
-        for (Object[] pair : props) {
-            dictionary.put(pair[0], pair[1]);
-        }
-        configuration.update(dictionary);
+        configure(org.apache.ace.deployment.provider.filebased.Activator.PID, "BaseDirectoryName", m_tempDir.getAbsolutePath());
     }
 
     private ArtifactData generateBundle(File file, String symbolicName, String version) throws Exception {

Modified: ace/trunk/ace-integrationtests/src/test/java/org/apache/ace/it/log/LogIntegrationTest.java
URL: http://svn.apache.org/viewvc/ace/trunk/ace-integrationtests/src/test/java/org/apache/ace/it/log/LogIntegrationTest.java?rev=1329199&r1=1329198&r2=1329199&view=diff
==============================================================================
--- ace/trunk/ace-integrationtests/src/test/java/org/apache/ace/it/log/LogIntegrationTest.java (original)
+++ ace/trunk/ace-integrationtests/src/test/java/org/apache/ace/it/log/LogIntegrationTest.java Mon Apr 23 12:15:01 2012
@@ -69,12 +69,14 @@ public class LogIntegrationTest extends 
                 Felix.configAdmin(),
                 jetty(),
                 Ace.util(),
+                Ace.authenticationApi(),
                 Ace.rangeApi(),
                 Ace.discoveryApi(),
                 Ace.discoveryProperty(),
                 Ace.identificationApi(),
                 Ace.identificationProperty(),
                 Ace.httplistener(),
+                Ace.connectionFactory(),
                 Ace.log(),
                 Ace.logListener(),
                 Ace.logServlet(),
@@ -97,14 +99,14 @@ public class LogIntegrationTest extends 
         configureFactory("org.apache.ace.target.log.factory",
                 "name", "auditlog");
         configureFactory("org.apache.ace.target.log.sync.factory",
-            "name", "auditlog");
+            "name", "auditlog", "authentication.enabled", "false");
 
         configure("org.apache.ace.deployment.servlet",
-                HttpConstants.ENDPOINT, DEPLOYMENT);
+                HttpConstants.ENDPOINT, DEPLOYMENT, "authentication.enabled", "false");
 
         configureFactory("org.apache.ace.server.log.servlet.factory",
                 "name", "auditlog",
-                HttpConstants.ENDPOINT, AUDITLOG);
+                HttpConstants.ENDPOINT, AUDITLOG, "authentication.enabled", "false");
         configureFactory("org.apache.ace.server.log.store.factory",
                 "name", "auditlog");
 

Modified: ace/trunk/ace-integrationtests/src/test/java/org/apache/ace/it/repository/RepositoryTest.java
URL: http://svn.apache.org/viewvc/ace/trunk/ace-integrationtests/src/test/java/org/apache/ace/it/repository/RepositoryTest.java?rev=1329199&r1=1329198&r2=1329199&view=diff
==============================================================================
--- ace/trunk/ace-integrationtests/src/test/java/org/apache/ace/it/repository/RepositoryTest.java (original)
+++ ace/trunk/ace-integrationtests/src/test/java/org/apache/ace/it/repository/RepositoryTest.java Mon Apr 23 12:15:01 2012
@@ -18,8 +18,28 @@
  */
 package org.apache.ace.it.repository;
 
+import static org.apache.ace.it.Options.jetty;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.CoreOptions.provision;
+import static org.ops4j.pax.exam.CoreOptions.systemProperty;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.util.Arrays;
+import java.util.Properties;
+import java.util.concurrent.Semaphore;
+import java.util.concurrent.TimeUnit;
+
 import org.apache.ace.http.listener.constants.HttpConstants;
 import org.apache.ace.it.IntegrationTestBase;
+import org.apache.ace.it.Options.Ace;
+import org.apache.ace.it.Options.Felix;
+import org.apache.ace.it.Options.Osgi;
 import org.apache.ace.repository.Repository;
 import org.apache.ace.repository.impl.constants.RepositoryConstants;
 import org.apache.ace.test.constants.TestConstants;
@@ -37,19 +57,6 @@ import org.osgi.service.cm.Configuration
 import org.osgi.service.cm.ConfigurationAdmin;
 import org.osgi.util.tracker.ServiceTracker;
 
-import java.io.*;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.util.Arrays;
-import java.util.Dictionary;
-import java.util.Hashtable;
-import java.util.Properties;
-import java.util.concurrent.Semaphore;
-import java.util.concurrent.TimeUnit;
-
-import static org.apache.ace.it.Options.*;
-import static org.ops4j.pax.exam.CoreOptions.*;
-
 /**
  * Integration test for our repositories, and the replication thereof.
  */
@@ -68,6 +75,7 @@ public class RepositoryTest extends Inte
                 Felix.configAdmin(),
                 Felix.preferences(),
                 Ace.util(),
+                Ace.authenticationApi(),
                 Ace.rangeApi(),
                 Ace.httplistener(),
                 Ace.repositoryApi(),
@@ -79,9 +87,9 @@ public class RepositoryTest extends Inte
 
     protected void before() throws IOException {
         configure("org.apache.ace.repository.servlet.RepositoryReplicationServlet",
-                HttpConstants.ENDPOINT, "/replication");
+                HttpConstants.ENDPOINT, "/replication", "authentication.enabled", "false");
         configure("org.apache.ace.repository.servlet.RepositoryServlet",
-                HttpConstants.ENDPOINT, "/repository");
+                HttpConstants.ENDPOINT, "/repository", "authentication.enabled", "false");
     }
 
     protected Component[] getDependencies() {



Mime
View raw message