Author: ivol37 at gmail.com
Date: Mon Dec  6 10:15:24 2010
New Revision: 478

Log:
[AMDATU-201] Added filebased implementation of service consumer storage

Added:
   
trunk/amdatu-authentication/oauth-api/src/main/java/org/amdatu/authentication/oauth/api/ConsumerAlreadyExistsException.java
      - copied, changed from r476, 
/trunk/amdatu-authentication/oauth-server/src/main/java/org/amdatu/authentication/oauth/server/ConsumerAlreadyExistsException.java
   
trunk/amdatu-authentication/oauth-api/src/main/java/org/amdatu/authentication/oauth/api/ConsumerNotFoundException.java
      - copied, changed from r476, 
/trunk/amdatu-authentication/oauth-server/src/main/java/org/amdatu/authentication/oauth/server/ConsumerNotFoundException.java
   
trunk/amdatu-authentication/oauth-api/src/main/java/org/amdatu/authentication/oauth/api/ConsumerRegistryStorageException.java
   
trunk/amdatu-authentication/oauth-api/src/main/java/org/amdatu/authentication/oauth/api/OAuthServiceConsumerRegistry.java
      - copied, changed from r476, 
/trunk/amdatu-authentication/oauth-server/src/main/java/org/amdatu/authentication/oauth/server/OAuthServiceConsumerRegistry.java
   trunk/amdatu-authentication/oauth-consumerregistry-fs/
   trunk/amdatu-authentication/oauth-consumerregistry-fs/pom.xml
   trunk/amdatu-authentication/oauth-consumerregistry-fs/src/
   trunk/amdatu-authentication/oauth-consumerregistry-fs/src/main/
   trunk/amdatu-authentication/oauth-consumerregistry-fs/src/main/java/
   trunk/amdatu-authentication/oauth-consumerregistry-fs/src/main/java/org/
   
trunk/amdatu-authentication/oauth-consumerregistry-fs/src/main/java/org/amdatu/
   
trunk/amdatu-authentication/oauth-consumerregistry-fs/src/main/java/org/amdatu/authentication/
   
trunk/amdatu-authentication/oauth-consumerregistry-fs/src/main/java/org/amdatu/authentication/oauth/
   
trunk/amdatu-authentication/oauth-consumerregistry-fs/src/main/java/org/amdatu/authentication/oauth/consumerregistry/
   
trunk/amdatu-authentication/oauth-consumerregistry-fs/src/main/java/org/amdatu/authentication/oauth/consumerregistry/fs/
   
trunk/amdatu-authentication/oauth-consumerregistry-fs/src/main/java/org/amdatu/authentication/oauth/consumerregistry/fs/internal/
   
trunk/amdatu-authentication/oauth-consumerregistry-fs/src/main/java/org/amdatu/authentication/oauth/consumerregistry/fs/internal/ConsumerKeyList.java
   
trunk/amdatu-authentication/oauth-consumerregistry-fs/src/main/java/org/amdatu/authentication/oauth/consumerregistry/fs/internal/FSConsumerStore.java
   
trunk/amdatu-authentication/oauth-consumerregistry-fs/src/main/java/org/amdatu/authentication/oauth/consumerregistry/fs/osgi/
   
trunk/amdatu-authentication/oauth-consumerregistry-fs/src/main/java/org/amdatu/authentication/oauth/consumerregistry/fs/osgi/Activator.java
   
trunk/amdatu-authentication/oauth-consumerregistry-fs/src/main/java/org/amdatu/authentication/oauth/consumerregistry/fs/service/
   
trunk/amdatu-authentication/oauth-consumerregistry-fs/src/main/java/org/amdatu/authentication/oauth/consumerregistry/fs/service/FSConsumerRegistryImpl.java
   
trunk/amdatu-core/config-filebased/src/main/resources/conf/org.amdatu.authentication.oauth.consumerregistry.fs.cfg
   
trunk/amdatu-libraries/utilities/src/main/java/org/amdatu/libraries/utilities/FSUtil.java
      - copied, changed from r476, 
/trunk/amdatu-core/tenantstore-fs/src/main/java/org/amdatu/core/tenantstore/fs/internal/FSUtil.java
Removed:
   
trunk/amdatu-authentication/oauth-server/src/main/java/org/amdatu/authentication/oauth/server/ConsumerAlreadyExistsException.java
   
trunk/amdatu-authentication/oauth-server/src/main/java/org/amdatu/authentication/oauth/server/ConsumerNotFoundException.java
   
trunk/amdatu-authentication/oauth-server/src/main/java/org/amdatu/authentication/oauth/server/OAuthServiceConsumerRegistry.java
   
trunk/amdatu-authentication/oauth-server/src/main/java/org/amdatu/authentication/oauth/server/service/OAuthServiceConsumerRegistryImpl.java
   
trunk/amdatu-core/tenantstore-fs/src/main/java/org/amdatu/core/tenantstore/fs/internal/FSUtil.java
Modified:
   
trunk/amdatu-authentication/oauth-api/src/main/java/org/amdatu/authentication/oauth/api/OAuthServiceConsumer.java
   
trunk/amdatu-authentication/oauth-server/src/main/java/org/amdatu/authentication/oauth/server/osgi/Activator.java
   
trunk/amdatu-authentication/oauth-server/src/main/java/org/amdatu/authentication/oauth/server/service/OAuthServiceConsumerBean.java
   
trunk/amdatu-authentication/oauth-server/src/main/java/org/amdatu/authentication/oauth/server/service/OAuthServiceConsumerRegistryREST.java
   trunk/amdatu-authentication/pom.xml
   trunk/amdatu-core/tenantstore-fs/pom.xml
   
trunk/amdatu-core/tenantstore-fs/src/main/java/org/amdatu/core/tenantstore/fs/internal/FSTenantIdList.java
   
trunk/amdatu-core/tenantstore-fs/src/main/java/org/amdatu/core/tenantstore/fs/internal/FSTenantStore.java
   trunk/amdatu-release/pom.xml
   trunk/integration-tests/pom.xml
   
trunk/integration-tests/src/test/java/org/amdatu/test/integration/base/ConfigProvider.java
   
trunk/integration-tests/src/test/java/org/amdatu/test/integration/base/IntegrationTestBase.java
   
trunk/integration-tests/src/test/java/org/amdatu/test/integration/base/OAuthTestBase.java
   
trunk/integration-tests/src/test/java/org/amdatu/test/integration/mock/OAuthTestConsumer.java
   
trunk/integration-tests/src/test/java/org/amdatu/test/integration/tests/HttpServiceTest.java
   
trunk/integration-tests/src/test/java/org/amdatu/test/integration/tests/OAuthServiceConsumerRegistryTest.java
   trunk/src/main/resources/conf/felix-config.properties

Copied: 
trunk/amdatu-authentication/oauth-api/src/main/java/org/amdatu/authentication/oauth/api/ConsumerAlreadyExistsException.java
 (from r476, 
/trunk/amdatu-authentication/oauth-server/src/main/java/org/amdatu/authentication/oauth/server/ConsumerAlreadyExistsException.java)
==============================================================================
--- 
/trunk/amdatu-authentication/oauth-server/src/main/java/org/amdatu/authentication/oauth/server/ConsumerAlreadyExistsException.java
  (original)
+++ 
trunk/amdatu-authentication/oauth-api/src/main/java/org/amdatu/authentication/oauth/api/ConsumerAlreadyExistsException.java
 Mon Dec  6 10:15:24 2010
@@ -14,7 +14,7 @@
     You should have received a copy of the GNU General Public License
     along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
-package org.amdatu.authentication.oauth.server;
+package org.amdatu.authentication.oauth.api;
 
 /**
  * Exception class thrown by consumer management services to indicate that a 
customer already exists

Copied: 
trunk/amdatu-authentication/oauth-api/src/main/java/org/amdatu/authentication/oauth/api/ConsumerNotFoundException.java
 (from r476, 
/trunk/amdatu-authentication/oauth-server/src/main/java/org/amdatu/authentication/oauth/server/ConsumerNotFoundException.java)
==============================================================================
--- 
/trunk/amdatu-authentication/oauth-server/src/main/java/org/amdatu/authentication/oauth/server/ConsumerNotFoundException.java
       (original)
+++ 
trunk/amdatu-authentication/oauth-api/src/main/java/org/amdatu/authentication/oauth/api/ConsumerNotFoundException.java
      Mon Dec  6 10:15:24 2010
@@ -14,7 +14,7 @@
     You should have received a copy of the GNU General Public License
     along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
-package org.amdatu.authentication.oauth.server;
+package org.amdatu.authentication.oauth.api;
 
 /**
  * Exception class thrown by consumer management services to indicate that a 
customer was not found

Added: 
trunk/amdatu-authentication/oauth-api/src/main/java/org/amdatu/authentication/oauth/api/ConsumerRegistryStorageException.java
==============================================================================
--- (empty file)
+++ 
trunk/amdatu-authentication/oauth-api/src/main/java/org/amdatu/authentication/oauth/api/ConsumerRegistryStorageException.java
       Mon Dec  6 10:15:24 2010
@@ -0,0 +1,45 @@
+/*
+    Copyright (C) 2010 Amdatu.org
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.amdatu.authentication.oauth.api;
+
+/**
+ * Exception class thrown by consumer registry storages to indicate a storage 
related problem.
+ * 
+ * @author ivol
+ */
+public class ConsumerRegistryStorageException extends Exception {
+    // The serial version UID of this exception class
+    private static final long serialVersionUID = -1593266292334420845L;
+
+    /**
+     * Constructs a new consumer registry storage exception.
+     * 
+     * @param msg An error message providing more information about the cause 
of the error.
+     */
+    public ConsumerRegistryStorageException(String msg) {
+        super(msg);
+    }
+    
+    /**
+     * Constructs a new consumer registry storage exception.
+     * 
+     * @param e The root cause of the exception.
+     */
+    public ConsumerRegistryStorageException(Exception e) {
+        super(e);
+    }
+}

Modified: 
trunk/amdatu-authentication/oauth-api/src/main/java/org/amdatu/authentication/oauth/api/OAuthServiceConsumer.java
==============================================================================
--- 
trunk/amdatu-authentication/oauth-api/src/main/java/org/amdatu/authentication/oauth/api/OAuthServiceConsumer.java
   (original)
+++ 
trunk/amdatu-authentication/oauth-api/src/main/java/org/amdatu/authentication/oauth/api/OAuthServiceConsumer.java
   Mon Dec  6 10:15:24 2010
@@ -16,6 +16,8 @@
  */
 package org.amdatu.authentication.oauth.api;
 
+import java.util.Map;
+
 /**
  * This interface represents an oAuth service consumer. An oAuth service 
consumer is a service that invokes
  * a service provider on behalf of another client. The service consumer 
communicates with the service provider
@@ -66,4 +68,11 @@
      * @return The URL to which a user will be redirected after a request 
token has been authorized.
      */
     String getCallbackUrl();
+    
+    /**
+     * Map of arbitrary additional properties stored in the service consumer. 
This could for example be used
+     * to associated a service consumer with subscribed tenants.
+     * @return Map of extended properties
+     */
+    Map<String, String> getProperties();
 }

Copied: 
trunk/amdatu-authentication/oauth-api/src/main/java/org/amdatu/authentication/oauth/api/OAuthServiceConsumerRegistry.java
 (from r476, 
/trunk/amdatu-authentication/oauth-server/src/main/java/org/amdatu/authentication/oauth/server/OAuthServiceConsumerRegistry.java)
==============================================================================
--- 
/trunk/amdatu-authentication/oauth-server/src/main/java/org/amdatu/authentication/oauth/server/OAuthServiceConsumerRegistry.java
    (original)
+++ 
trunk/amdatu-authentication/oauth-api/src/main/java/org/amdatu/authentication/oauth/api/OAuthServiceConsumerRegistry.java
   Mon Dec  6 10:15:24 2010
@@ -14,9 +14,7 @@
     You should have received a copy of the GNU General Public License
     along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
-package org.amdatu.authentication.oauth.server;
-
-import org.amdatu.authentication.oauth.api.OAuthServiceConsumer;
+package org.amdatu.authentication.oauth.api;
 
 /**
  * The oAuth server uses a service consumer registry to identify from which 
consumers
@@ -32,13 +30,14 @@
 public interface OAuthServiceConsumerRegistry {
     /**
      * Returns the oAuth service consumer matching the specified consumer key. 
If no such consumer could be found
-     * a ConsumerNotFoundException is thrown.
+     * null is returned.
+     * 
      * @param consumerKey Key of the consumer to find
      * @return The consumer if found
-     * @throws ConsumerNotFoundException If no consumer could be found 
matching the specified consumer key
+     * @throws ConsumerRegistryStorageException If an internal error occurred 
in the consumer registry storage
      */
-    OAuthServiceConsumer getConsumer(String consumerKey) throws 
ConsumerNotFoundException;
-    
+    OAuthServiceConsumer getConsumer(String consumerKey) throws 
ConsumerRegistryStorageException;
+
     /**
      * Adds an oAuth service consumer to the registry of the oAuth server. A 
ConsumerAlreadyExistsException will be thrown
      * if the consumer already exists. Note that each service consumer is 
uniquely identified by the consumer key
@@ -46,8 +45,9 @@
      * 
      * @param consumer The OAuth service consumer to add
      * @throws ConsumerAlreadyExistsException If a consumer with the same 
consumer key already exists
+     * @throws ConsumerRegistryStorageException If an internal error occurred 
in the consumer registry storage
      */
-    void addConsumer(OAuthServiceConsumer consumer) throws 
ConsumerAlreadyExistsException;
+    void addConsumer(OAuthServiceConsumer consumer) throws 
ConsumerAlreadyExistsException, ConsumerRegistryStorageException;
 
     /**
      * Removes an ooAuth service consumer from the registry of the oAuth 
server. The consumer that will be
@@ -55,15 +55,18 @@
      * 
      * @param consumer The oAith service consumer to remove
      * @throws ConsumerNotFoundException if no consumer exists matching the 
consumer key of the specified consumer
+     * @throws ConsumerRegistryStorageException If an internal error occurred 
in the consumer registry storage
      */
-    void removeConsumer(OAuthServiceConsumer consumer) throws 
ConsumerNotFoundException;
+    void removeConsumer(OAuthServiceConsumer consumer) throws 
ConsumerNotFoundException, ConsumerRegistryStorageException;
 
     /**
      * Updates the properties of the specified oAuth service consumer. The 
consumer that will be updated is the one
      * that matches the consumer key of the specified consumer. So the 
consumer key itself can never be updated. If
      * you want to do so you will need to remove and add the consumer.
+     * 
      * @param consumer The oAith service consumer to update
      * @throws ConsumerNotFoundException if no consumer exists matching the 
consumer key of the specified consumer
+     * @throws ConsumerRegistryStorageException If an internal error occurred 
in the consumer registry storage
      */
-    void updateConsumer(OAuthServiceConsumer consumer) throws 
ConsumerNotFoundException;
+    void updateConsumer(OAuthServiceConsumer consumer) throws 
ConsumerNotFoundException, ConsumerRegistryStorageException;
 }

Added: trunk/amdatu-authentication/oauth-consumerregistry-fs/pom.xml
==============================================================================
--- (empty file)
+++ trunk/amdatu-authentication/oauth-consumerregistry-fs/pom.xml       Mon Dec 
 6 10:15:24 2010
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.amdatu</groupId>
+    <artifactId>org.amdatu.authentication</artifactId>
+    <version>0.1.0-SNAPSHOT</version>
+  </parent>
+  <groupId>org.amdatu.authentication.oauth</groupId>
+  <artifactId>consumerregistry-fs</artifactId>
+  <packaging>bundle</packaging>
+  <name>Amdatu Authentication - oAuth File-based consumer registry store</name>
+  <description>This bundle implements a persistent storage for oAuth service 
consumers</description>
+  
+  <dependencies>
+    <dependency>
+      <groupId>org.amdatu.authentication.oauth</groupId>
+      <artifactId>api</artifactId>
+      <version>${platform.version}</version>   
+      <scope>provided</scope>
+      <type>bundle</type>
+    </dependency> 
+    <dependency>
+      <groupId>org.amdatu.libraries</groupId>
+      <artifactId>utilities</artifactId>
+      <version>${platform.version}</version>
+      <scope>compile</scope>
+    </dependency>
+  </dependencies>
+  
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+        <configuration>
+          <instructions>
+            
<Bundle-Activator>org.amdatu.authentication.oauth.consumerregistry.fs.osgi.Activator</Bundle-Activator>
+            
<Bundle-SymbolicName>org.amdatu.authentication.oauth.consumerregistry.fs</Bundle-SymbolicName>
+            
<Export-Package>org.amdatu.authentication.oauth.consumerregistry.fs</Export-Package>
+            <Embed-Dependency>*;scope=compile</Embed-Dependency>
+          </instructions>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build> 
+</project>

Added: 
trunk/amdatu-authentication/oauth-consumerregistry-fs/src/main/java/org/amdatu/authentication/oauth/consumerregistry/fs/internal/ConsumerKeyList.java
==============================================================================
--- (empty file)
+++ 
trunk/amdatu-authentication/oauth-consumerregistry-fs/src/main/java/org/amdatu/authentication/oauth/consumerregistry/fs/internal/ConsumerKeyList.java
       Mon Dec  6 10:15:24 2010
@@ -0,0 +1,124 @@
+/*
+    Copyright (C) 2010 Amdatu.org
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.amdatu.authentication.oauth.consumerregistry.fs.internal;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.amdatu.authentication.oauth.api.ConsumerAlreadyExistsException;
+import org.amdatu.authentication.oauth.api.ConsumerNotFoundException;
+import org.amdatu.authentication.oauth.api.ConsumerRegistryStorageException;
+import org.amdatu.libraries.utilities.FSUtil;
+
+/**
+ * Implementation of a persistent list of consumer keys on disk.
+ */
+public class ConsumerKeyList {
+    private final File m_file;
+    private List<String> m_consumerKeyList;
+
+    public ConsumerKeyList(final File file) throws 
ConsumerRegistryStorageException {
+        m_file = file;
+        m_consumerKeyList = new LinkedList<String>();
+        try {
+            readConsumerKeyList();
+        }
+        catch (IOException e) {
+            throw new ConsumerRegistryStorageException(e);
+        }
+    }
+
+    public List<String> getAll() throws ConsumerRegistryStorageException {
+        return new LinkedList<String>(m_consumerKeyList);
+    }
+
+    public void addConsumerKey(final String consumerKey) throws 
ConsumerRegistryStorageException, ConsumerAlreadyExistsException {
+        try {
+            if (!m_consumerKeyList.contains(consumerKey)) {
+                m_consumerKeyList.add(consumerKey);
+                writeConsumerKeyList();
+            } else {
+                throw new ConsumerAlreadyExistsException("Consumer with key '" 
+ consumerKey + "' already exists");
+            }
+        }
+        catch (IOException e) {
+            throw new ConsumerRegistryStorageException(e);
+        }
+    }
+
+    public void removeConsumerKey(final String consumerKey) throws 
ConsumerRegistryStorageException, ConsumerNotFoundException {
+        try {
+            if (m_consumerKeyList.contains(consumerKey)) {
+                m_consumerKeyList.remove(consumerKey);
+                writeConsumerKeyList();
+            } else {
+                throw new ConsumerNotFoundException("Consumer with key '" + 
consumerKey + "' doesn't exist");
+            }
+        }
+        catch (IOException e) {
+            throw new ConsumerRegistryStorageException(e);
+        }
+    }
+
+    private void readConsumerKeyList() throws IOException {
+        if (!m_file.exists()) {
+            m_consumerKeyList.clear();
+            return;
+        }
+        FileInputStream fis = null;
+        ObjectInputStream ois = null;
+        try {
+            fis = new FileInputStream(m_file);
+            ois = new ObjectInputStream(fis);
+            final int numberOfConsumerKeys = ois.readInt();
+            for (int i = 0; i < numberOfConsumerKeys; i++) {
+                final String id = FSUtil.readString(ois);
+                m_consumerKeyList.add(id);
+            }
+        }
+        finally {
+            FSUtil.closeInputStreamsSafely(ois, fis);
+        }
+    }
+
+    private void writeConsumerKeyList() throws IOException {
+        if (m_consumerKeyList.size() == 0 && m_file.exists()) {
+            m_file.delete();
+            return;
+        }
+        FileOutputStream fos = null;
+        ObjectOutputStream oos = null;
+        try {
+            fos = new FileOutputStream(m_file);
+            oos = new ObjectOutputStream(fos);
+            oos.writeInt(m_consumerKeyList.size());
+            for (final String consumerkey : m_consumerKeyList) {
+                FSUtil.writeString(oos, consumerkey);
+            }
+            oos.flush();
+        }
+        finally {
+            FSUtil.closeOutputStreamsSafely(oos, fos);
+        }
+    }
+}

Added: 
trunk/amdatu-authentication/oauth-consumerregistry-fs/src/main/java/org/amdatu/authentication/oauth/consumerregistry/fs/internal/FSConsumerStore.java
==============================================================================
--- (empty file)
+++ 
trunk/amdatu-authentication/oauth-consumerregistry-fs/src/main/java/org/amdatu/authentication/oauth/consumerregistry/fs/internal/FSConsumerStore.java
       Mon Dec  6 10:15:24 2010
@@ -0,0 +1,148 @@
+/*
+    Copyright (C) 2010 Amdatu.org
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.amdatu.authentication.oauth.consumerregistry.fs.internal;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.UnsupportedEncodingException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.amdatu.authentication.oauth.api.ConsumerRegistryStorageException;
+import org.amdatu.authentication.oauth.api.OAuthServiceConsumer;
+import org.amdatu.libraries.utilities.FSUtil;
+
+public class FSConsumerStore {
+    private final File m_file;
+    private final Map<String, OAuthServiceConsumer> m_consumers;
+
+    public FSConsumerStore(File file) throws ConsumerRegistryStorageException {
+        m_file = file;
+        m_consumers = new HashMap<String, OAuthServiceConsumer>();
+        try {
+            readConsumers();
+        }
+        catch (IOException e) {
+            throw new ConsumerRegistryStorageException(e);
+        }
+    }
+
+    public OAuthServiceConsumer getConsumer(final String consumerKey) {
+        return m_consumers.get(consumerKey);
+    }
+
+    public OAuthServiceConsumer addConsumer(final OAuthServiceConsumer 
consumer) {
+        return m_consumers.put(consumer.getConsumerKey(), consumer);
+    }
+
+    public OAuthServiceConsumer removeConsumer(final String consumerId) {
+        return m_consumers.remove(consumerId);
+    }
+
+    public void save() throws ConsumerRegistryStorageException {
+        try {
+            writeConsumers();
+        }
+        catch (IOException e) {
+            throw new ConsumerRegistryStorageException(e);
+        }
+    }
+
+    private void readConsumers() throws IOException {
+        if (!m_file.exists()) {
+            return;
+        }
+        m_consumers.clear();
+        FileInputStream fis = null;
+        ObjectInputStream ois = null;
+        try {
+            fis = new FileInputStream(m_file);
+            ois = new ObjectInputStream(fis);
+            final int numberOfConsumers = ois.readInt();
+            for (int i = 0; i < numberOfConsumers; i++) {
+                final OAuthServiceConsumer consumer = readConsumer(ois);
+                m_consumers.put(consumer.getConsumerKey(), consumer);
+            }
+        }
+        finally {
+            FSUtil.closeInputStreamsSafely(ois, fis);
+        }
+    }
+
+    private OAuthServiceConsumer readConsumer(ObjectInputStream ois) throws 
IOException, UnsupportedEncodingException {
+        final String name = FSUtil.readString(ois);
+        final String key = FSUtil.readString(ois);
+        final String secret = FSUtil.readString(ois);
+        final String callbackUrl = FSUtil.readString(ois);
+        final Map<String, String> properties = FSUtil.readProperties(ois);
+        return new OAuthServiceConsumer() {
+            public String getName() {
+                return name;
+            }
+
+            public String getConsumerKey() {
+                return key;
+            }
+
+            public String getConsumerSecret() {
+                return secret;
+            }
+
+            public String getCallbackUrl() {
+                return callbackUrl;
+            }
+
+            public Map<String, String> getProperties() {
+                return properties;
+            }
+        };
+    }
+
+    private void writeConsumers() throws IOException {
+        if ((m_consumers == null || m_consumers.size() == 0) && 
m_file.exists()) {
+            m_file.delete();
+            return;
+        }
+        FileOutputStream fos = null;
+        ObjectOutputStream oos = null;
+        try {
+            fos = new FileOutputStream(m_file);
+            oos = new ObjectOutputStream(fos);
+            oos.writeInt(m_consumers.size());
+            for (OAuthServiceConsumer consumer : m_consumers.values()) {
+                writeConsumer(oos, consumer);
+            }
+            oos.flush();
+        }
+        finally {
+            FSUtil.closeOutputStreamsSafely(oos, fos);
+        }
+    }
+
+    private void writeConsumer(ObjectOutputStream oos, OAuthServiceConsumer 
consumer)
+        throws UnsupportedEncodingException, IOException {
+        FSUtil.writeString(oos, consumer.getName());
+        FSUtil.writeString(oos, consumer.getConsumerKey());
+        FSUtil.writeString(oos, consumer.getConsumerSecret());
+        FSUtil.writeString(oos, consumer.getCallbackUrl());
+        FSUtil.writeProperties(oos, consumer.getProperties());
+    }
+}

Added: 
trunk/amdatu-authentication/oauth-consumerregistry-fs/src/main/java/org/amdatu/authentication/oauth/consumerregistry/fs/osgi/Activator.java
==============================================================================
--- (empty file)
+++ 
trunk/amdatu-authentication/oauth-consumerregistry-fs/src/main/java/org/amdatu/authentication/oauth/consumerregistry/fs/osgi/Activator.java
 Mon Dec  6 10:15:24 2010
@@ -0,0 +1,45 @@
+/*
+    Copyright (C) 2010 Amdatu.org
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.amdatu.authentication.oauth.consumerregistry.fs.osgi;
+
+import org.amdatu.authentication.oauth.api.OAuthServiceConsumerRegistry;
+import 
org.amdatu.authentication.oauth.consumerregistry.fs.service.FSConsumerRegistryImpl;
+import org.apache.felix.dm.DependencyActivatorBase;
+import org.apache.felix.dm.DependencyManager;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.log.LogService;
+
+/**
+ * This class represents the OSGi activator for the tenant service fs storage 
provider.
+ */
+public final class Activator extends DependencyActivatorBase {
+
+    @Override
+    public void init(BundleContext context, DependencyManager manager) throws 
Exception {
+
+        manager.add(
+                createComponent()
+                    .setImplementation(FSConsumerRegistryImpl.class)
+                    
.setInterface(OAuthServiceConsumerRegistry.class.getName(), null)
+                    
.add(createConfigurationDependency().setPid(FSConsumerRegistryImpl.CONFIGURATION_PID))
+                    
.add(createServiceDependency().setService(LogService.class).setRequired(true)));
+    }
+
+    @Override
+    public void destroy(BundleContext context, DependencyManager manager) 
throws Exception {
+    }
+}

Added: 
trunk/amdatu-authentication/oauth-consumerregistry-fs/src/main/java/org/amdatu/authentication/oauth/consumerregistry/fs/service/FSConsumerRegistryImpl.java
==============================================================================
--- (empty file)
+++ 
trunk/amdatu-authentication/oauth-consumerregistry-fs/src/main/java/org/amdatu/authentication/oauth/consumerregistry/fs/service/FSConsumerRegistryImpl.java
 Mon Dec  6 10:15:24 2010
@@ -0,0 +1,157 @@
+/*
+    Copyright (C) 2010 Amdatu.org
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.amdatu.authentication.oauth.consumerregistry.fs.service;
+
+import java.io.File;
+import java.util.Dictionary;
+
+import org.amdatu.authentication.oauth.api.ConsumerAlreadyExistsException;
+import org.amdatu.authentication.oauth.api.ConsumerNotFoundException;
+import org.amdatu.authentication.oauth.api.ConsumerRegistryStorageException;
+import org.amdatu.authentication.oauth.api.OAuthServiceConsumer;
+import org.amdatu.authentication.oauth.api.OAuthServiceConsumerRegistry;
+import 
org.amdatu.authentication.oauth.consumerregistry.fs.internal.ConsumerKeyList;
+import 
org.amdatu.authentication.oauth.consumerregistry.fs.internal.FSConsumerStore;
+import org.osgi.service.cm.ConfigurationException;
+import org.osgi.service.cm.ManagedService;
+import org.osgi.service.log.LogService;
+
+public class FSConsumerRegistryImpl implements OAuthServiceConsumerRegistry, 
ManagedService {
+    // Configuration ids
+    public static final String CONFIGURATION_PID = 
"org.amdatu.authentication.oauth.consumerregistry.fs";
+    public final static String DATA_DIRECTORY = "datadir";
+
+    // File naming constants
+    private static final String ENTITYLIST_FILENAME = "consumerKeyList.ser";
+    private static final String STORAGEFILE_PREFIX = "consumerkey_";
+    private static final String STORAGEFILE_POSTFIX = ".ser";
+
+    // Injected service dependencies
+    private volatile LogService m_logService;
+
+    // Storage directory
+    private String m_dataDirectoryName;
+    private File m_dataDirectory;
+
+    // Collaborator
+    private ConsumerKeyList m_consumerKeyList = null;
+
+    /**
+     * Invoked since this is a managed service.
+     * @param dictionary Dictionary holding the configuration properties
+     * @throws ConfigurationException In case some Config Admin exception 
occurred
+     */
+    @SuppressWarnings("unchecked")
+    public synchronized void updated(Dictionary dictionary) throws 
ConfigurationException {
+        if (dictionary != null) {
+            m_dataDirectoryName = (String) dictionary.get(DATA_DIRECTORY);
+            if (m_dataDirectoryName == null || "".equals(m_dataDirectoryName)) 
{
+                throw new ConfigurationException(DATA_DIRECTORY, "Missing 
mandatory data directory configuration");
+            }           
+        }
+    }
+    
+    public void init() {
+        File dataDirectory = new File(m_dataDirectoryName);
+        try {
+            setDataDirectory(dataDirectory);
+        }
+        catch (ConsumerRegistryStorageException e) {
+            m_logService.log(LogService.LOG_ERROR, "Could not prepare data 
directory '" + m_dataDirectoryName + "' for storage");
+        }
+    }
+
+    public synchronized void stop() {
+        m_consumerKeyList = null;
+    }
+
+    public synchronized File getDataDirectory() {
+        return m_dataDirectory;
+    }
+
+    public synchronized void setDataDirectory(File dataDirectory) throws 
ConsumerRegistryStorageException {
+        if (!dataDirectory.isAbsolute()) {
+            File userDirectory = new File(System.getProperty("user.dir"));
+            dataDirectory = new File(userDirectory, dataDirectory.getPath());
+        }
+        if (!((dataDirectory.exists() && dataDirectory.canRead() && 
dataDirectory.canWrite()) || dataDirectory.mkdirs())) {
+            throw new ConsumerRegistryStorageException("Unable to access data 
directory: "
+                + dataDirectory.getAbsolutePath());
+        }
+        m_dataDirectory = dataDirectory;
+        m_consumerKeyList = new ConsumerKeyList(new File(m_dataDirectory, 
ENTITYLIST_FILENAME));
+        m_logService.log(LogService.LOG_DEBUG, "Datadirectory set to: " + 
m_dataDirectory.getAbsolutePath());
+    }
+
+    public synchronized OAuthServiceConsumer getConsumer(String consumerKey) 
throws ConsumerRegistryStorageException {
+        FSConsumerStore consumerStorageFile = getStorageFile(consumerKey);
+        return consumerStorageFile.getConsumer(consumerKey);
+    }
+
+    public synchronized void addConsumer(OAuthServiceConsumer consumer) throws 
ConsumerAlreadyExistsException, ConsumerRegistryStorageException {
+        FSConsumerStore consumerStorageFile = 
getStorageFile(consumer.getConsumerKey());
+        if (consumerStorageFile.getConsumer(consumer.getConsumerKey()) != 
null) {
+            throw new ConsumerAlreadyExistsException("Consumer with key '" + 
consumer.getConsumerKey() + "' already exists");
+        }
+        if (consumerStorageFile.addConsumer(consumer) != null) {
+            // This shouldn't happen
+            throw new ConsumerRegistryStorageException("Internal storage error 
while adding consumer '" + consumer.getConsumerKey() + "'");
+        }
+        m_consumerKeyList.addConsumerKey(consumer.getConsumerKey());
+        consumerStorageFile.save();
+        m_logService.log(LogService.LOG_DEBUG, "Added consumer with key '" + 
consumer.getConsumerKey() + "' to the oAuth service consumer registry");
+    }
+
+    public synchronized void updateConsumer(OAuthServiceConsumer consumer) 
throws ConsumerNotFoundException, ConsumerRegistryStorageException {
+        FSConsumerStore consumerStorageFile = 
getStorageFile(consumer.getConsumerKey());
+        if (consumerStorageFile.getConsumer(consumer.getConsumerKey()) == 
null) {
+            throw new ConsumerNotFoundException("Consumer with key '" + 
consumer.getConsumerKey() + "' doesn't exist");
+        }
+        OAuthServiceConsumer storedEntity = 
consumerStorageFile.addConsumer(consumer);
+        if (storedEntity == null) {
+            // This shouldn't happen
+            throw new ConsumerRegistryStorageException("Internal storage error 
while updating consumer '" + consumer.getConsumerKey() + "'");
+        }
+        consumerStorageFile.save();
+        m_logService.log(LogService.LOG_DEBUG, "Updated consumer with key '" + 
consumer.getConsumerKey() + "' in the oAuth service consumer registry");
+    }
+
+    public synchronized void removeConsumer(OAuthServiceConsumer consumer) 
throws ConsumerNotFoundException, ConsumerRegistryStorageException {
+        FSConsumerStore consumerStorageFile = 
getStorageFile(consumer.getConsumerKey());
+        if (consumerStorageFile.getConsumer(consumer.getConsumerKey()) == 
null) {
+            throw new ConsumerNotFoundException("Consumer with key '" + 
consumer.getConsumerKey() + "' doesn't exist");
+        }
+        OAuthServiceConsumer storedEntity = 
consumerStorageFile.removeConsumer(consumer.getConsumerKey());
+        if (storedEntity == null) {
+            // This shouldn't happen
+            throw new ConsumerRegistryStorageException("Internal storage error 
while deleting consumer '" + consumer.getConsumerKey() + "'");
+        }
+        m_consumerKeyList.removeConsumerKey(consumer.getConsumerKey());
+        consumerStorageFile.save();
+        m_logService.log(LogService.LOG_DEBUG, "Removed consumer with key '" + 
consumer.getConsumerKey() + "' from the oAuth service consumer registry");
+    }
+
+    private FSConsumerStore getStorageFile(final String entityId) throws 
ConsumerRegistryStorageException {
+        final int hash = Math.abs(entityId.hashCode());
+        final String subdirName = "" + (hash % 50);
+        final File subdirFile = new File(m_dataDirectory, subdirName);
+        if (!subdirFile.exists()) {
+            subdirFile.mkdir();
+        }
+        return new FSConsumerStore(new File(subdirFile, STORAGEFILE_PREFIX + 
hash + STORAGEFILE_POSTFIX));
+    }
+}

Modified: 
trunk/amdatu-authentication/oauth-server/src/main/java/org/amdatu/authentication/oauth/server/osgi/Activator.java
==============================================================================
--- 
trunk/amdatu-authentication/oauth-server/src/main/java/org/amdatu/authentication/oauth/server/osgi/Activator.java
   (original)
+++ 
trunk/amdatu-authentication/oauth-server/src/main/java/org/amdatu/authentication/oauth/server/osgi/Activator.java
   Mon Dec  6 10:15:24 2010
@@ -22,18 +22,17 @@
 import javax.servlet.Servlet;
 
 import org.amdatu.authentication.oauth.api.OAuthServiceConsumer;
+import org.amdatu.authentication.oauth.api.OAuthServiceConsumerRegistry;
 import org.amdatu.authentication.oauth.api.OAuthServiceProvider;
 import org.amdatu.authentication.oauth.server.OAuthAccessTokenServlet;
 import org.amdatu.authentication.oauth.server.OAuthAuthorizeTokenServlet;
 import org.amdatu.authentication.oauth.server.OAuthRequestTokenServlet;
-import org.amdatu.authentication.oauth.server.OAuthServiceConsumerRegistry;
-import org.amdatu.authentication.oauth.server.OAuthTokenProvider;
 import org.amdatu.authentication.oauth.server.OAuthServerConfig;
+import org.amdatu.authentication.oauth.server.OAuthTokenProvider;
 import 
org.amdatu.authentication.oauth.server.service.OAuthAccessTokenServletImpl;
 import 
org.amdatu.authentication.oauth.server.service.OAuthAuthorizeTokenServletImpl;
 import 
org.amdatu.authentication.oauth.server.service.OAuthRequestTokenServletImpl;
 import 
org.amdatu.authentication.oauth.server.service.OAuthResourceProviderImpl;
-import 
org.amdatu.authentication.oauth.server.service.OAuthServiceConsumerRegistryImpl;
 import 
org.amdatu.authentication.oauth.server.service.OAuthServiceConsumerRegistryREST;
 import org.amdatu.authentication.oauth.server.service.OAuthServiceProviderImpl;
 import org.amdatu.authentication.oauth.server.service.OAuthTokenProviderImpl;
@@ -76,13 +75,6 @@
             .setImplementation(OAuthServiceProviderImpl.class)
             
.add(createConfigurationDependency().setPid(OAuthServerConfig.PID)));
 
-        // Create and register the oAuth service consumer registry service
-        manager.add(
-            createComponent()
-            .setInterface(OAuthServiceConsumerRegistry.class.getName(), null)
-            .setImplementation(OAuthServiceConsumerRegistryImpl.class)
-            
.add(createServiceDependency().setService(LogService.class).setRequired(true)));
-
         // Create and register the oAuth service consumer registry REST service
         manager.add(
             createComponent()

Modified: 
trunk/amdatu-authentication/oauth-server/src/main/java/org/amdatu/authentication/oauth/server/service/OAuthServiceConsumerBean.java
==============================================================================
--- 
trunk/amdatu-authentication/oauth-server/src/main/java/org/amdatu/authentication/oauth/server/service/OAuthServiceConsumerBean.java
 (original)
+++ 
trunk/amdatu-authentication/oauth-server/src/main/java/org/amdatu/authentication/oauth/server/service/OAuthServiceConsumerBean.java
 Mon Dec  6 10:15:24 2010
@@ -18,6 +18,7 @@
 
 import java.lang.reflect.InvocationTargetException;
 import java.net.URI;
+import java.util.Map;
 
 import javax.ws.rs.core.UriInfo;
 import javax.xml.bind.annotation.XmlAccessType;
@@ -44,6 +45,8 @@
     private String m_name;
 
     private String m_callbackUrl;
+    
+    private Map<String, String> m_properties;
 
     private AtomSyndicationLink m_link;
 
@@ -78,6 +81,14 @@
     public void setCallbackUrl(String callbackUrl) {
         m_callbackUrl = callbackUrl;
     }
+    
+    public Map<String, String> getProperties() {
+        return m_properties;
+    }
+    
+    public void setProperties(Map<String, String> properties) {
+        m_properties = properties;
+    }
 
     public AtomSyndicationLink getLink() {
         return m_link;
@@ -99,4 +110,6 @@
         bean.addLink(thisLink, "alternate");
         return bean;
     }
+
+
 }

Modified: 
trunk/amdatu-authentication/oauth-server/src/main/java/org/amdatu/authentication/oauth/server/service/OAuthServiceConsumerRegistryREST.java
==============================================================================
--- 
trunk/amdatu-authentication/oauth-server/src/main/java/org/amdatu/authentication/oauth/server/service/OAuthServiceConsumerRegistryREST.java
 (original)
+++ 
trunk/amdatu-authentication/oauth-server/src/main/java/org/amdatu/authentication/oauth/server/service/OAuthServiceConsumerRegistryREST.java
 Mon Dec  6 10:15:24 2010
@@ -32,10 +32,11 @@
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriInfo;
 
+import org.amdatu.authentication.oauth.api.ConsumerAlreadyExistsException;
+import org.amdatu.authentication.oauth.api.ConsumerNotFoundException;
+import org.amdatu.authentication.oauth.api.ConsumerRegistryStorageException;
 import org.amdatu.authentication.oauth.api.OAuthServiceConsumer;
-import org.amdatu.authentication.oauth.server.ConsumerAlreadyExistsException;
-import org.amdatu.authentication.oauth.server.ConsumerNotFoundException;
-import org.amdatu.authentication.oauth.server.OAuthServiceConsumerRegistry;
+import org.amdatu.authentication.oauth.api.OAuthServiceConsumerRegistry;
 import org.amdatu.web.httpcontext.ResourceProvider;
 import org.osgi.service.log.LogService;
 
@@ -55,7 +56,7 @@
     public void start() {
         m_logService.log(LogService.LOG_DEBUG, "OAuth Service Consumer 
registry REST service started.");
     }
-    
+
     @GET
     /**
      * Use this method to verify if the REST service is online.
@@ -76,10 +77,12 @@
     @Produces( { MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
     public OAuthServiceConsumer getConsumer(@PathParam("consumerKey") final 
String consumerKey, @Context UriInfo uriInfo) {
         try {
-            return 
OAuthServiceConsumerBean.copy(m_registry.getConsumer(consumerKey), uriInfo);
-        }
-        catch (ConsumerNotFoundException e) {
-            throw new WebApplicationException(Response.Status.NOT_FOUND);
+            OAuthServiceConsumer consumer = 
m_registry.getConsumer(consumerKey);
+            if (consumer != null) {
+                return OAuthServiceConsumerBean.copy(consumer, uriInfo);
+            } else {
+                return null;
+            }
         }
         catch (IllegalAccessException e) {
             throw new WebApplicationException(e, 
Response.Status.INTERNAL_SERVER_ERROR);
@@ -87,6 +90,9 @@
         catch (InvocationTargetException e) {
             throw new WebApplicationException(e, 
Response.Status.INTERNAL_SERVER_ERROR);
         }
+        catch (ConsumerRegistryStorageException e) {
+            throw new WebApplicationException(e, 
Response.Status.INTERNAL_SERVER_ERROR);
+        }
     }
 
     /**
@@ -105,6 +111,9 @@
         catch (ConsumerAlreadyExistsException e) {
             throw new WebApplicationException(Response.Status.NOT_MODIFIED);
         }
+        catch (ConsumerRegistryStorageException e) {
+            throw new WebApplicationException(e, 
Response.Status.INTERNAL_SERVER_ERROR);
+        }
     }
 
     /**
@@ -125,6 +134,9 @@
         catch (ConsumerNotFoundException e) {
             throw new WebApplicationException(Response.Status.NOT_FOUND);
         }
+        catch (ConsumerRegistryStorageException e) {
+            throw new WebApplicationException(e, 
Response.Status.INTERNAL_SERVER_ERROR);
+        }
     }
 
     /**
@@ -143,6 +155,9 @@
         catch (ConsumerNotFoundException e) {
             throw new WebApplicationException(Response.Status.NOT_FOUND);
         }
+        catch (ConsumerRegistryStorageException e) {
+            throw new WebApplicationException(e, 
Response.Status.INTERNAL_SERVER_ERROR);
+        }
     }
 
     public URL getResource(String name) {

Modified: trunk/amdatu-authentication/pom.xml
==============================================================================
--- trunk/amdatu-authentication/pom.xml (original)
+++ trunk/amdatu-authentication/pom.xml Mon Dec  6 10:15:24 2010
@@ -25,6 +25,7 @@
     <module>oauth-api</module>
     <module>oauth-client</module>
     <module>oauth-server</module>
+    <module>oauth-consumerregistry-fs</module>
   </modules>
 
 </project>
\ No newline at end of file

Added: 
trunk/amdatu-core/config-filebased/src/main/resources/conf/org.amdatu.authentication.oauth.consumerregistry.fs.cfg
==============================================================================
--- (empty file)
+++ 
trunk/amdatu-core/config-filebased/src/main/resources/conf/org.amdatu.authentication.oauth.consumerregistry.fs.cfg
  Mon Dec  6 10:15:24 2010
@@ -0,0 +1,2 @@
+# Consumer store FS datadirectory
+datadir=work/consumerregistrystore
\ No newline at end of file

Modified: trunk/amdatu-core/tenantstore-fs/pom.xml
==============================================================================
--- trunk/amdatu-core/tenantstore-fs/pom.xml    (original)
+++ trunk/amdatu-core/tenantstore-fs/pom.xml    Mon Dec  6 10:15:24 2010
@@ -21,6 +21,12 @@
       <scope>provided</scope>
       <type>bundle</type>
     </dependency>
+    <dependency>
+      <groupId>org.amdatu.libraries</groupId>
+      <artifactId>utilities</artifactId>
+      <version>${platform.version}</version>
+      <scope>compile</scope>
+    </dependency>    
   </dependencies>
 
   <build>
@@ -32,6 +38,7 @@
           <instructions>
             
<Bundle-Activator>org.amdatu.core.tenantstore.fs.osgi.FSTenantStorageProviderActivator</Bundle-Activator>
             
<Bundle-SymbolicName>org.amdatu.core.tenantstore-fs</Bundle-SymbolicName>
+            <Embed-Dependency>*;scope=compile</Embed-Dependency>
           </instructions>
         </configuration>
       </plugin>

Modified: 
trunk/amdatu-core/tenantstore-fs/src/main/java/org/amdatu/core/tenantstore/fs/internal/FSTenantIdList.java
==============================================================================
--- 
trunk/amdatu-core/tenantstore-fs/src/main/java/org/amdatu/core/tenantstore/fs/internal/FSTenantIdList.java
  (original)
+++ 
trunk/amdatu-core/tenantstore-fs/src/main/java/org/amdatu/core/tenantstore/fs/internal/FSTenantIdList.java
  Mon Dec  6 10:15:24 2010
@@ -26,6 +26,7 @@
 import java.util.List;
 
 import org.amdatu.core.tenant.TenantStorageException;
+import org.amdatu.libraries.utilities.FSUtil;
 
 /**
  * Implementation of a persistent list of tenant identifiers on disk.

Modified: 
trunk/amdatu-core/tenantstore-fs/src/main/java/org/amdatu/core/tenantstore/fs/internal/FSTenantStore.java
==============================================================================
--- 
trunk/amdatu-core/tenantstore-fs/src/main/java/org/amdatu/core/tenantstore/fs/internal/FSTenantStore.java
   (original)
+++ 
trunk/amdatu-core/tenantstore-fs/src/main/java/org/amdatu/core/tenantstore/fs/internal/FSTenantStore.java
   Mon Dec  6 10:15:24 2010
@@ -28,6 +28,7 @@
 
 import org.amdatu.core.tenant.TenantEntity;
 import org.amdatu.core.tenant.TenantStorageException;
+import org.amdatu.libraries.utilities.FSUtil;
 
 /**
  * Implementation of a persistent tenant store (containing 0 or more tenants) 
on disk.

Copied: 
trunk/amdatu-libraries/utilities/src/main/java/org/amdatu/libraries/utilities/FSUtil.java
 (from r476, 
/trunk/amdatu-core/tenantstore-fs/src/main/java/org/amdatu/core/tenantstore/fs/internal/FSUtil.java)
==============================================================================
--- 
/trunk/amdatu-core/tenantstore-fs/src/main/java/org/amdatu/core/tenantstore/fs/internal/FSUtil.java
 (original)
+++ 
trunk/amdatu-libraries/utilities/src/main/java/org/amdatu/libraries/utilities/FSUtil.java
   Mon Dec  6 10:15:24 2010
@@ -14,7 +14,7 @@
     You should have received a copy of the GNU General Public License
     along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
-package org.amdatu.core.tenantstore.fs.internal;
+package org.amdatu.libraries.utilities;
 
 import java.io.FileInputStream;
 import java.io.FileOutputStream;

Modified: trunk/amdatu-release/pom.xml
==============================================================================
--- trunk/amdatu-release/pom.xml        (original)
+++ trunk/amdatu-release/pom.xml        Mon Dec  6 10:15:24 2010
@@ -33,6 +33,13 @@
       <scope>compile</scope>
       <type>bundle</type>
     </dependency>    
+    <dependency>
+      <groupId>org.amdatu.authentication.oauth</groupId>
+      <artifactId>consumerregistry-fs</artifactId>    
+      <version>${platform.version}</version>
+      <scope>compile</scope>
+      <type>bundle</type>
+    </dependency>    
     
     <!-- Authorization bundles -->
     <dependency>

Modified: trunk/integration-tests/pom.xml
==============================================================================
--- trunk/integration-tests/pom.xml     (original)
+++ trunk/integration-tests/pom.xml     Mon Dec  6 10:15:24 2010
@@ -196,7 +196,14 @@
       <scope>test</scope>
       <type>bundle</type>
     </dependency>    
-
+    <dependency>
+      <groupId>org.amdatu.authentication.oauth</groupId>
+      <artifactId>consumerregistry-fs</artifactId>    
+      <version>${platform.version}</version>
+      <scope>test</scope>
+      <type>bundle</type>
+    </dependency>    
+    
     <dependency>
       <groupId>org.apache.felix</groupId>
       <artifactId>org.apache.felix.configadmin</artifactId>

Modified: 
trunk/integration-tests/src/test/java/org/amdatu/test/integration/base/ConfigProvider.java
==============================================================================
--- 
trunk/integration-tests/src/test/java/org/amdatu/test/integration/base/ConfigProvider.java
  (original)
+++ 
trunk/integration-tests/src/test/java/org/amdatu/test/integration/base/ConfigProvider.java
  Mon Dec  6 10:15:24 2010
@@ -75,6 +75,13 @@
         config.update(properties);
     }
 
+    public void addFSConsumerStoreConfig(ConfigurationAdmin configAdmin) 
throws IOException {
+        Configuration config = 
configAdmin.getConfiguration("org.amdatu.authentication.oauth.consumerregistry.fs",
 null);
+        Properties properties = new Properties();
+        properties.put("datadir", "work/consumerregistrystore");
+        config.update(properties);
+    }
+    
     public void addShindigConfig(ConfigurationAdmin configAdmin) throws 
IOException {
         Configuration config = 
configAdmin.getConfiguration(ShindigService.SHINDIG_CONFIG_PID, null);
         Properties properties = new Properties();
@@ -134,7 +141,7 @@
         config.update(properties);
     }
 
-    public void addHttpServiceConfig(ConfigurationAdmin configAdmin) throws 
IOException {
+    public void addFelixHttpServiceConfig(ConfigurationAdmin configAdmin) 
throws IOException {
         // NB: Due to issue https://issues.apache.org/jira/browse/FELIX-2714 
updating the felix http service
         // configuration may cause throwing a connection refused, a service 
that still listens to the default 
         // port 8080 or returning a 404. Therefore, until this issue has been 
fixed, we will not try to change 

Modified: 
trunk/integration-tests/src/test/java/org/amdatu/test/integration/base/IntegrationTestBase.java
==============================================================================
--- 
trunk/integration-tests/src/test/java/org/amdatu/test/integration/base/IntegrationTestBase.java
     (original)
+++ 
trunk/integration-tests/src/test/java/org/amdatu/test/integration/base/IntegrationTestBase.java
     Mon Dec  6 10:15:24 2010
@@ -343,6 +343,10 @@
     protected static MavenArtifactProvisionOption amdatuOAuthServer() {
         return 
mavenBundle().groupId("org.amdatu.authentication.oauth").artifactId("server").versionAsInProject();
     }
+    
+    protected static MavenArtifactProvisionOption 
amdatuOAuthConsumerRegistry() {
+        return 
mavenBundle().groupId("org.amdatu.authentication.oauth").artifactId("consumerregistry-fs").versionAsInProject();
+    }    
 
     protected static MavenArtifactProvisionOption fileBasedConfiguration() {
         return 
mavenBundle().groupId("org.amdatu.core.config").artifactId("filebased").versionAsInProject();

Modified: 
trunk/integration-tests/src/test/java/org/amdatu/test/integration/base/OAuthTestBase.java
==============================================================================
--- 
trunk/integration-tests/src/test/java/org/amdatu/test/integration/base/OAuthTestBase.java
   (original)
+++ 
trunk/integration-tests/src/test/java/org/amdatu/test/integration/base/OAuthTestBase.java
   Mon Dec  6 10:15:24 2010
@@ -31,6 +31,7 @@
 import net.oauth.OAuthProblemException;
 
 import org.amdatu.authentication.oauth.api.OAuthServiceConsumer;
+import org.amdatu.authentication.oauth.api.OAuthServiceConsumerRegistry;
 import org.amdatu.authentication.oauth.api.OAuthServiceProvider;
 import org.amdatu.authentication.oauth.server.OAuthRequestTokenServlet;
 import org.amdatu.authentication.oauth.server.OAuthTokenProvider;
@@ -43,6 +44,7 @@
 import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.junit.Configuration;
 import org.osgi.service.cm.ConfigurationAdmin;
+import org.osgi.service.http.HttpService;
 import org.osgi.service.log.LogService;
 
 public class OAuthTestBase extends IntegrationTestBase {
@@ -62,9 +64,10 @@
         
         // Add cassandra and templates configs
         ConfigProvider configProvider = new ConfigProvider();
-        configProvider.addHttpServiceConfig(m_configAdmin);
+        configProvider.addFelixHttpServiceConfig(m_configAdmin);
         configProvider.addOAuthConfig(m_configAdmin);
         configProvider.addLogConfig(m_configAdmin);
+        configProvider.addFSConsumerStoreConfig(m_configAdmin);
     }
 
     protected Component[] getDependencies(DependencyManager manager) {
@@ -85,6 +88,8 @@
             
.add(manager.createServiceDependency().setService(OAuthTokenProvider.class).setRequired(true))
             
.add(manager.createServiceDependency().setService(OAuthServiceProvider.class).setRequired(true))
             
.add(manager.createServiceDependency().setService(ConfigurationAdmin.class).setRequired(true))
+            
.add(manager.createServiceDependency().setService(OAuthServiceConsumerRegistry.class).setRequired(true))
+            
.add(manager.createServiceDependency().setService(HttpService.class).setRequired(true))
             
.add(manager.createServiceDependency().setService(LogService.class).setRequired(true));
 
         return new Component[] { servletComponent, testComponent };
@@ -104,9 +109,11 @@
             json(),
             amdatuHttpContext(),
             amdatuJaxRs(),
+            amdatuWink(),
             amdatuOAuthAPI(),
             amdatuOAuthClient(),
             amdatuOAuthServer(),
+            amdatuOAuthConsumerRegistry(),
             amdatuJspSupport());
     }
     

Modified: 
trunk/integration-tests/src/test/java/org/amdatu/test/integration/mock/OAuthTestConsumer.java
==============================================================================
--- 
trunk/integration-tests/src/test/java/org/amdatu/test/integration/mock/OAuthTestConsumer.java
       (original)
+++ 
trunk/integration-tests/src/test/java/org/amdatu/test/integration/mock/OAuthTestConsumer.java
       Mon Dec  6 10:15:24 2010
@@ -16,6 +16,9 @@
  */
 package org.amdatu.test.integration.mock;
 
+import java.util.HashMap;
+import java.util.Map;
+
 import org.amdatu.authentication.oauth.api.OAuthServiceConsumer;
 import org.json.JSONException;
 import org.json.JSONObject;
@@ -33,6 +36,7 @@
     private String m_consumerKey = DEFAULT_CONSUMER_KEY;
     private String m_consumerSecret = DEFAULT_CONSUMER_SECRET;
     private String m_callbackUrl = DEFAULT_CALLBACK_URL;
+    private Map<String, String> m_properties = new HashMap<String, String>();
     
     public void setName(String name) {
         m_name = name;
@@ -65,6 +69,14 @@
         return m_consumerSecret;
     }
     
+    public Map<String, String> getProperties() {
+        return m_properties;
+    }
+    
+    public void setProperties(Map<String, String> properties) {
+        m_properties = properties;
+    }
+    
     public JSONObject toJson() throws JSONException {
         JSONObject consumer = new JSONObject();
         consumer.put("name", getName());

Modified: 
trunk/integration-tests/src/test/java/org/amdatu/test/integration/tests/HttpServiceTest.java
==============================================================================
--- 
trunk/integration-tests/src/test/java/org/amdatu/test/integration/tests/HttpServiceTest.java
        (original)
+++ 
trunk/integration-tests/src/test/java/org/amdatu/test/integration/tests/HttpServiceTest.java
        Mon Dec  6 10:15:24 2010
@@ -141,7 +141,7 @@
        
        // Add cassandra and templates configs
        ConfigProvider configProvider = new ConfigProvider();
-       configProvider.addHttpServiceConfig(m_configAdmin);
+       configProvider.addFelixHttpServiceConfig(m_configAdmin);
        m_logService.log(LogService.LOG_DEBUG, "HttpService config set to " + 
ConfigProvider.HOSTNAME + ":" + ConfigProvider.PORTNR);
     }
 

Modified: 
trunk/integration-tests/src/test/java/org/amdatu/test/integration/tests/OAuthServiceConsumerRegistryTest.java
==============================================================================
--- 
trunk/integration-tests/src/test/java/org/amdatu/test/integration/tests/OAuthServiceConsumerRegistryTest.java
       (original)
+++ 
trunk/integration-tests/src/test/java/org/amdatu/test/integration/tests/OAuthServiceConsumerRegistryTest.java
       Mon Dec  6 10:15:24 2010
@@ -16,13 +16,10 @@
  */
 package org.amdatu.test.integration.tests;
 
-import static org.ops4j.pax.exam.CoreOptions.provision;
-
 import java.io.IOException;
 
-import org.amdatu.authentication.oauth.server.OAuthServiceConsumerRegistry;
 import org.amdatu.test.integration.base.ConfigProvider;
-import org.amdatu.test.integration.base.IntegrationTestBase;
+import org.amdatu.test.integration.base.OAuthTestBase;
 import org.amdatu.test.integration.mock.OAuthTestConsumer;
 import org.apache.commons.httpclient.HttpClient;
 import org.apache.commons.httpclient.HttpException;
@@ -31,74 +28,20 @@
 import org.apache.commons.httpclient.methods.PutMethod;
 import org.apache.commons.httpclient.methods.RequestEntity;
 import org.apache.commons.httpclient.methods.StringRequestEntity;
-import org.apache.felix.dm.Component;
-import org.apache.felix.dm.DependencyManager;
 import org.apache.http.HttpStatus;
 import org.json.JSONException;
 import org.junit.Assert;
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.junit.Configuration;
 import org.ops4j.pax.exam.junit.JUnit4TestRunner;
-import org.osgi.service.cm.ConfigurationAdmin;
 import org.osgi.service.log.LogService;
 
 @RunWith(JUnit4TestRunner.class)
-public class OAuthServiceConsumerRegistryTest extends IntegrationTestBase {
+public class OAuthServiceConsumerRegistryTest extends OAuthTestBase {
     private final static String CONSUMERS_REST_RESOURCE = 
"/rest/services/oauth/consumers/oauth/consumers";
 
-    private volatile LogService m_logService;
-    private volatile ConfigurationAdmin m_configAdmin;
-    
     private String m_baseUrl;
-
-    @Configuration
-    public Option[] configure() {
-        return super.configure();
-    }
-    
-    protected void initConfiguration() throws IOException {
-        m_configAdmin = getService(ConfigurationAdmin.class);
-        
-        // Add cassandra and templates configs
-        ConfigProvider configProvider = new ConfigProvider();
-        configProvider.addHttpServiceConfig(m_configAdmin);
-        configProvider.addOAuthConfig(m_configAdmin);
-        configProvider.addLogConfig(m_configAdmin);
-    }
-
-    protected Component[] getDependencies(DependencyManager manager) {
-        Component testComponent = manager.createComponent()
-            .setImplementation(this)
-            
.add(manager.createServiceDependency().setService(ConfigurationAdmin.class).setRequired(true))
-            
.add(manager.createServiceDependency().setService(OAuthServiceConsumerRegistry.class).setRequired(true))
-            
.add(manager.createServiceDependency().setService(LogService.class).setRequired(true));
-
-        return new Component[] { testComponent };
-    }
-
-    protected Option provisionBundles() {
-        return provision(
-            felixHttpServiceJetty(),
-            felixHttpServiceWhiteboard(),
-            slingMime(),
-            slingCommons(),
-            json(),
-            commonsCodec(),
-            commonsLogging(),
-            commonsHttpClient(),
-            paxSwissbox(),
-            ops4jBaseLang(),
-            amdatuWink(),
-            amdatuHttpContext(),
-            amdatuJaxRs(),
-            amdatuOAuthAPI(),
-            amdatuOAuthClient(),
-            amdatuOAuthServer(),
-            amdatuJspSupport());
-    }
-
+   
     @Test
     // Test the REST service that provides CRUD operations on the consumer 
registry of the oAuth server
     public void testRestService() throws Exception {

Modified: trunk/src/main/resources/conf/felix-config.properties
==============================================================================
--- trunk/src/main/resources/conf/felix-config.properties       (original)
+++ trunk/src/main/resources/conf/felix-config.properties       Mon Dec  6 
10:15:24 2010
@@ -119,7 +119,8 @@
           
reference:file:amdatu-application/org.amdatu.authorization.login.gadget-${platform.version}.jar
 \
           
reference:file:amdatu-application/org.amdatu.authentication.oauth.api-${platform.version}.jar
 \
           
reference:file:amdatu-application/org.amdatu.authentication.oauth.client-${platform.version}.jar
 \
-          
reference:file:amdatu-application/org.amdatu.authentication.oauth.server-${platform.version}.jar
+          
reference:file:amdatu-application/org.amdatu.authentication.oauth.server-${platform.version}.jar
 \
+          
reference:file:amdatu-application/org.amdatu.authentication.oauth.consumerregistry-fs-${platform.version}.jar
 
felix.auto.start.20=reference:file:amdatu-examples/org.amdatu.example.friends.gadget-${platform.version}.jar
 \
           
reference:file:amdatu-examples/org.amdatu.example.course.gadget-${platform.version}.jar
 \
           
reference:file:amdatu-examples/org.amdatu.example.course.service-${platform.version}.jar

Reply via email to