servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r662362 [1/2] - in /servicemix/smx4/nmr/trunk: ./ assembly/ assembly/src/main/descriptors/ assembly/src/main/filtered-resources/ document/ document/src/ document/src/main/ document/src/main/java/ document/src/main/java/org/ document/src/mai...
Date Mon, 02 Jun 2008 08:45:16 GMT
Author: gnodet
Date: Mon Jun  2 01:45:14 2008
New Revision: 662362

URL: http://svn.apache.org/viewvc?rev=662362&view=rev
Log:
SMX4NMR-29 and SMX4NMR-30: Security framework and split the document repository in its own bundle

Added:
    servicemix/smx4/nmr/trunk/document/   (with props)
    servicemix/smx4/nmr/trunk/document/pom.xml
    servicemix/smx4/nmr/trunk/document/src/
    servicemix/smx4/nmr/trunk/document/src/main/
    servicemix/smx4/nmr/trunk/document/src/main/java/
    servicemix/smx4/nmr/trunk/document/src/main/java/org/
    servicemix/smx4/nmr/trunk/document/src/main/java/org/apache/
    servicemix/smx4/nmr/trunk/document/src/main/java/org/apache/servicemix/
    servicemix/smx4/nmr/trunk/document/src/main/java/org/apache/servicemix/document/
    servicemix/smx4/nmr/trunk/document/src/main/java/org/apache/servicemix/document/DocumentRepository.java
      - copied, changed from r655606, servicemix/smx4/nmr/trunk/jbi/runtime/src/main/java/org/apache/servicemix/jbi/runtime/DocumentRepository.java
    servicemix/smx4/nmr/trunk/document/src/main/java/org/apache/servicemix/document/Resource.java
      - copied, changed from r655606, servicemix/smx4/nmr/trunk/jbi/runtime/src/main/java/org/apache/servicemix/jbi/runtime/Resource.java
    servicemix/smx4/nmr/trunk/document/src/main/java/org/apache/servicemix/document/factory/
    servicemix/smx4/nmr/trunk/document/src/main/java/org/apache/servicemix/document/factory/DocumentFactory.java
    servicemix/smx4/nmr/trunk/document/src/main/java/org/apache/servicemix/document/impl/
    servicemix/smx4/nmr/trunk/document/src/main/java/org/apache/servicemix/document/impl/DocumentRepositoryImpl.java
      - copied, changed from r655606, servicemix/smx4/nmr/trunk/jbi/runtime/src/main/java/org/apache/servicemix/jbi/runtime/impl/DocumentRepositoryImpl.java
    servicemix/smx4/nmr/trunk/document/src/main/resources/
    servicemix/smx4/nmr/trunk/document/src/main/resources/META-INF/
    servicemix/smx4/nmr/trunk/document/src/main/resources/META-INF/spring/
    servicemix/smx4/nmr/trunk/document/src/main/resources/META-INF/spring/servicemix-document.xml
    servicemix/smx4/nmr/trunk/document/src/test/
    servicemix/smx4/nmr/trunk/document/src/test/java/
    servicemix/smx4/nmr/trunk/document/src/test/java/org/
    servicemix/smx4/nmr/trunk/document/src/test/java/org/apache/
    servicemix/smx4/nmr/trunk/document/src/test/java/org/apache/servicemix/
    servicemix/smx4/nmr/trunk/document/src/test/java/org/apache/servicemix/document/
    servicemix/smx4/nmr/trunk/document/src/test/java/org/apache/servicemix/document/impl/
    servicemix/smx4/nmr/trunk/document/src/test/java/org/apache/servicemix/document/impl/DocumentFactoryTest.java
    servicemix/smx4/nmr/trunk/document/src/test/java/org/apache/servicemix/document/impl/DocumentRepositoryImplTest.java
      - copied, changed from r655606, servicemix/smx4/nmr/trunk/jbi/runtime/src/test/java/org/apache/servicemix/jbi/runtime/impl/DocumentRepositoryImplTest.java
    servicemix/smx4/nmr/trunk/document/src/test/resources/
    servicemix/smx4/nmr/trunk/document/src/test/resources/test.xml
    servicemix/smx4/nmr/trunk/nmr/api/src/main/java/org/apache/servicemix/nmr/api/security/
    servicemix/smx4/nmr/trunk/nmr/api/src/main/java/org/apache/servicemix/nmr/api/security/AuthenticationService.java
    servicemix/smx4/nmr/trunk/nmr/api/src/main/java/org/apache/servicemix/nmr/api/security/AuthorizationEntry.java
    servicemix/smx4/nmr/trunk/nmr/api/src/main/java/org/apache/servicemix/nmr/api/security/AuthorizationService.java
    servicemix/smx4/nmr/trunk/nmr/api/src/main/java/org/apache/servicemix/nmr/api/security/CertificateCallback.java
    servicemix/smx4/nmr/trunk/nmr/api/src/main/java/org/apache/servicemix/nmr/api/security/GroupPrincipal.java
    servicemix/smx4/nmr/trunk/nmr/api/src/main/java/org/apache/servicemix/nmr/api/security/UserPrincipal.java
    servicemix/smx4/nmr/trunk/nmr/api/src/test/java/org/apache/servicemix/nmr/api/security/
    servicemix/smx4/nmr/trunk/nmr/api/src/test/java/org/apache/servicemix/nmr/api/security/GroupPrincipalTest.java
    servicemix/smx4/nmr/trunk/nmr/api/src/test/java/org/apache/servicemix/nmr/api/security/UserPrincipalTest.java
    servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/security/
    servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/security/DefaultAuthorizationEntry.java
    servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/security/DefaultAuthorizationService.java
    servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/security/JaasAuthenticationService.java
    servicemix/smx4/nmr/trunk/nmr/core/src/test/java/org/apache/servicemix/nmr/core/security/
    servicemix/smx4/nmr/trunk/nmr/core/src/test/java/org/apache/servicemix/nmr/core/security/DefaultAuthorizationEntryTest.java
    servicemix/smx4/nmr/trunk/nmr/core/src/test/java/org/apache/servicemix/nmr/core/security/DefaultAuthorizationServiceTest.java
Removed:
    servicemix/smx4/nmr/trunk/jbi/runtime/src/main/java/org/apache/servicemix/jbi/runtime/DocumentRepository.java
    servicemix/smx4/nmr/trunk/jbi/runtime/src/main/java/org/apache/servicemix/jbi/runtime/Resource.java
    servicemix/smx4/nmr/trunk/jbi/runtime/src/main/java/org/apache/servicemix/jbi/runtime/impl/DocumentRepositoryImpl.java
    servicemix/smx4/nmr/trunk/jbi/runtime/src/test/java/org/apache/servicemix/jbi/runtime/impl/DocumentRepositoryImplTest.java
Modified:
    servicemix/smx4/nmr/trunk/assembly/pom.xml
    servicemix/smx4/nmr/trunk/assembly/src/main/descriptors/unix-bin.xml
    servicemix/smx4/nmr/trunk/assembly/src/main/filtered-resources/features.xml
    servicemix/smx4/nmr/trunk/jbi/itests/pom.xml
    servicemix/smx4/nmr/trunk/jbi/itests/src/test/java/org/apache/servicemix/jbi/IntegrationTest.java
    servicemix/smx4/nmr/trunk/jbi/osgi/src/main/resources/META-INF/spring/servicemix-jbi.xml
    servicemix/smx4/nmr/trunk/jbi/runtime/pom.xml
    servicemix/smx4/nmr/trunk/jbi/runtime/src/main/java/org/apache/servicemix/jbi/runtime/impl/ComponentContextImpl.java
    servicemix/smx4/nmr/trunk/jbi/runtime/src/main/java/org/apache/servicemix/jbi/runtime/impl/ComponentRegistryImpl.java
    servicemix/smx4/nmr/trunk/jbi/runtime/src/main/java/org/apache/servicemix/jbi/runtime/impl/NormalizedMessageImpl.java
    servicemix/smx4/nmr/trunk/nmr/api/pom.xml
    servicemix/smx4/nmr/trunk/nmr/api/src/main/java/org/apache/servicemix/nmr/api/Exchange.java
    servicemix/smx4/nmr/trunk/nmr/api/src/main/java/org/apache/servicemix/nmr/api/Message.java
    servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/FlowRegistryImpl.java
    servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/MessageImpl.java
    servicemix/smx4/nmr/trunk/nmr/osgi/src/main/resources/META-INF/spring/servicemix-nmr.xml
    servicemix/smx4/nmr/trunk/pom.xml

Modified: servicemix/smx4/nmr/trunk/assembly/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/assembly/pom.xml?rev=662362&r1=662361&r2=662362&view=diff
==============================================================================
--- servicemix/smx4/nmr/trunk/assembly/pom.xml (original)
+++ servicemix/smx4/nmr/trunk/assembly/pom.xml Mon Jun  2 01:45:14 2008
@@ -35,6 +35,11 @@
 
     <dependencies>
         <dependency>
+            <groupId>org.apache.servicemix.document</groupId>
+            <artifactId>org.apache.servicemix.document</artifactId>
+            <version>${pom.version}</version>
+        </dependency>
+        <dependency>
             <groupId>org.apache.servicemix.nmr</groupId>
             <artifactId>org.apache.servicemix.nmr.api</artifactId>
             <version>${pom.version}</version>

Modified: servicemix/smx4/nmr/trunk/assembly/src/main/descriptors/unix-bin.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/assembly/src/main/descriptors/unix-bin.xml?rev=662362&r1=662361&r2=662362&view=diff
==============================================================================
--- servicemix/smx4/nmr/trunk/assembly/src/main/descriptors/unix-bin.xml (original)
+++ servicemix/smx4/nmr/trunk/assembly/src/main/descriptors/unix-bin.xml Mon Jun  2 01:45:14 2008
@@ -116,6 +116,7 @@
                 <include>org.apache.servicemix.nmr:org.apache.servicemix.nmr.osgi</include>
                 <include>org.apache.servicemix.nmr:org.apache.servicemix.nmr.commands</include>
                 <include>org.apache.servicemix.nmr:org.apache.servicemix.nmr.management</include>
+                <include>org.apache.servicemix.document:org.apache.servicemix.document</include>
                 <include>org.apache.servicemix.jbi:org.apache.servicemix.jbi.api</include>
                 <include>org.apache.servicemix.jbi:org.apache.servicemix.jbi.runtime</include>
                 <include>org.apache.servicemix.jbi:org.apache.servicemix.jbi.osgi</include>

Modified: servicemix/smx4/nmr/trunk/assembly/src/main/filtered-resources/features.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/assembly/src/main/filtered-resources/features.xml?rev=662362&r1=662361&r2=662362&view=diff
==============================================================================
--- servicemix/smx4/nmr/trunk/assembly/src/main/filtered-resources/features.xml (original)
+++ servicemix/smx4/nmr/trunk/assembly/src/main/filtered-resources/features.xml Mon Jun  2 01:45:14 2008
@@ -18,26 +18,27 @@
 -->
 <features>
     <feature name="nmr">
-	    <bundle>mvn:org.apache.servicemix.nmr/org.apache.servicemix.nmr.api/${pom.version}</bundle>
-	    <bundle>mvn:org.apache.servicemix.nmr/org.apache.servicemix.nmr.core/${pom.version}</bundle>
-	    <bundle>mvn:org.apache.servicemix.nmr/org.apache.servicemix.nmr.osgi/${pom.version}</bundle>
-	    <bundle>mvn:org.apache.servicemix.nmr/org.apache.servicemix.nmr.spring/${pom.version}</bundle>
-	    <bundle>mvn:org.apache.servicemix.nmr/org.apache.servicemix.nmr.commands/${pom.version}</bundle>
-	    <bundle>mvn:org.apache.servicemix.nmr/org.apache.servicemix.nmr.management/${pom.version}</bundle>
-	</feature>
-	<feature name="jbi">
-		<feature>nmr</feature>
+        <bundle>mvn:org.apache.servicemix.nmr/org.apache.servicemix.nmr.api/${pom.version}</bundle>
+        <bundle>mvn:org.apache.servicemix.nmr/org.apache.servicemix.nmr.core/${pom.version}</bundle>
+        <bundle>mvn:org.apache.servicemix.nmr/org.apache.servicemix.nmr.osgi/${pom.version}</bundle>
+        <bundle>mvn:org.apache.servicemix.nmr/org.apache.servicemix.nmr.spring/${pom.version}</bundle>
+        <bundle>mvn:org.apache.servicemix.nmr/org.apache.servicemix.nmr.commands/${pom.version}</bundle>
+        <bundle>mvn:org.apache.servicemix.nmr/org.apache.servicemix.nmr.management/${pom.version}</bundle>
+    </feature>
+    <feature name="jbi">
+        <feature>nmr</feature>
         <bundle>mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.stax-api-1.0/${servicemix.specs.version}</bundle>
         <bundle>mvn:org.apache.geronimo.specs/geronimo-activation_1.1_spec/${geronimo.activation.version}</bundle>
-		<bundle>mvn:org.apache.geronimo.specs/geronimo-javamail_1.4_spec/${geronimo.javamail.version}</bundle>
-		<bundle>mvn:org.apache.geronimo.specs/geronimo-jta_1.1_spec/${geronimo.jta.version}</bundle>
+        <bundle>mvn:org.apache.geronimo.specs/geronimo-javamail_1.4_spec/${geronimo.javamail.version}</bundle>
+        <bundle>mvn:org.apache.geronimo.specs/geronimo-jta_1.1_spec/${geronimo.jta.version}</bundle>
         <bundle>mvn:org.apache.xbean/xbean-classloader/${xbean.version}</bundle>
-	    <bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.woodstox-3.2.3/${pom.version}</bundle>
-	    <bundle>mvn:org.apache.servicemix.jbi/org.apache.servicemix.jbi.api/${pom.version}</bundle>
-	    <bundle>mvn:org.apache.servicemix.jbi/org.apache.servicemix.jbi.runtime/${pom.version}</bundle>
-	    <bundle>mvn:org.apache.servicemix.jbi/org.apache.servicemix.jbi.osgi/${pom.version}</bundle>
-	    <bundle>mvn:org.apache.servicemix.jbi/org.apache.servicemix.jbi.deployer/${pom.version}</bundle>
-	    <bundle>mvn:org.apache.servicemix.jbi/org.apache.servicemix.jbi.commands/${pom.version}</bundle>
-	    <bundle>mvn:org.apache.servicemix.jbi/org.apache.servicemix.jbi.management/${pom.version}</bundle>
-	</feature>
+        <bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.woodstox-3.2.3/${pom.version}</bundle>
+        <bundle>mvn:org.apache.servicemix.document/org.apache.servicemix.document/${pom.version}</bundle>
+        <bundle>mvn:org.apache.servicemix.jbi/org.apache.servicemix.jbi.api/${pom.version}</bundle>
+        <bundle>mvn:org.apache.servicemix.jbi/org.apache.servicemix.jbi.runtime/${pom.version}</bundle>
+        <bundle>mvn:org.apache.servicemix.jbi/org.apache.servicemix.jbi.osgi/${pom.version}</bundle>
+        <bundle>mvn:org.apache.servicemix.jbi/org.apache.servicemix.jbi.deployer/${pom.version}</bundle>
+        <bundle>mvn:org.apache.servicemix.jbi/org.apache.servicemix.jbi.commands/${pom.version}</bundle>
+        <bundle>mvn:org.apache.servicemix.jbi/org.apache.servicemix.jbi.management/${pom.version}</bundle>
+    </feature>
 </features>
\ No newline at end of file

Propchange: servicemix/smx4/nmr/trunk/document/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Jun  2 01:45:14 2008
@@ -0,0 +1,9 @@
+target
+*.iml
+*.ipr
+*.iws
+.classpath
+.project
+.settings
+
+

Added: servicemix/smx4/nmr/trunk/document/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/document/pom.xml?rev=662362&view=auto
==============================================================================
--- servicemix/smx4/nmr/trunk/document/pom.xml (added)
+++ servicemix/smx4/nmr/trunk/document/pom.xml Mon Jun  2 01:45:14 2008
@@ -0,0 +1,84 @@
+<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">
+
+    <!--
+
+        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.
+    -->
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.servicemix.nmr</groupId>
+        <artifactId>nmr-parent</artifactId>
+        <version>1.0-m2-SNAPSHOT</version>
+    </parent>
+
+    <groupId>org.apache.servicemix.document</groupId>
+    <artifactId>org.apache.servicemix.document</artifactId>
+    <packaging>bundle</packaging>
+    <name>Apache ServiceMix Document</name>
+
+    <dependencies>
+        <dependency>
+            <groupId>commons-logging</groupId>
+            <artifactId>commons-logging</artifactId>
+            <version>${commons.logging.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-beans</artifactId>
+            <version>${spring.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.osgi</groupId>
+            <artifactId>spring-osgi-core</artifactId>
+            <version>${spring.osgi.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.osgi.core</artifactId>
+            <version>${felix.osgi.version}</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>log4j</groupId>
+            <artifactId>log4j</artifactId>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <configuration>
+                    <instructions>
+                        <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
+                        <Export-Package>${pom.artifactId},${pom.artifactId}.factory</Export-Package>
+                        <Private-Package>${pom.artifactId}.impl</Private-Package>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>
\ No newline at end of file

Copied: servicemix/smx4/nmr/trunk/document/src/main/java/org/apache/servicemix/document/DocumentRepository.java (from r655606, servicemix/smx4/nmr/trunk/jbi/runtime/src/main/java/org/apache/servicemix/jbi/runtime/DocumentRepository.java)
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/document/src/main/java/org/apache/servicemix/document/DocumentRepository.java?p2=servicemix/smx4/nmr/trunk/document/src/main/java/org/apache/servicemix/document/DocumentRepository.java&p1=servicemix/smx4/nmr/trunk/jbi/runtime/src/main/java/org/apache/servicemix/jbi/runtime/DocumentRepository.java&r1=655606&r2=662362&rev=662362&view=diff
==============================================================================
--- servicemix/smx4/nmr/trunk/jbi/runtime/src/main/java/org/apache/servicemix/jbi/runtime/DocumentRepository.java (original)
+++ servicemix/smx4/nmr/trunk/document/src/main/java/org/apache/servicemix/document/DocumentRepository.java Mon Jun  2 01:45:14 2008
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.servicemix.jbi.runtime;
+package org.apache.servicemix.document;
 
 import java.io.IOException;
 import java.io.InputStream;

Copied: servicemix/smx4/nmr/trunk/document/src/main/java/org/apache/servicemix/document/Resource.java (from r655606, servicemix/smx4/nmr/trunk/jbi/runtime/src/main/java/org/apache/servicemix/jbi/runtime/Resource.java)
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/document/src/main/java/org/apache/servicemix/document/Resource.java?p2=servicemix/smx4/nmr/trunk/document/src/main/java/org/apache/servicemix/document/Resource.java&p1=servicemix/smx4/nmr/trunk/jbi/runtime/src/main/java/org/apache/servicemix/jbi/runtime/Resource.java&r1=655606&r2=662362&rev=662362&view=diff
==============================================================================
--- servicemix/smx4/nmr/trunk/jbi/runtime/src/main/java/org/apache/servicemix/jbi/runtime/Resource.java (original)
+++ servicemix/smx4/nmr/trunk/document/src/main/java/org/apache/servicemix/document/Resource.java Mon Jun  2 01:45:14 2008
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.servicemix.jbi.runtime;
+package org.apache.servicemix.document;
 
 import java.io.IOException;
 import java.io.InputStream;

Added: servicemix/smx4/nmr/trunk/document/src/main/java/org/apache/servicemix/document/factory/DocumentFactory.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/document/src/main/java/org/apache/servicemix/document/factory/DocumentFactory.java?rev=662362&view=auto
==============================================================================
--- servicemix/smx4/nmr/trunk/document/src/main/java/org/apache/servicemix/document/factory/DocumentFactory.java (added)
+++ servicemix/smx4/nmr/trunk/document/src/main/java/org/apache/servicemix/document/factory/DocumentFactory.java Mon Jun  2 01:45:14 2008
@@ -0,0 +1,132 @@
+/*
+ * 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.servicemix.document.factory;
+
+import org.springframework.beans.factory.FactoryBean;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.beans.factory.BeanFactoryAware;
+import org.springframework.beans.factory.BeanFactory;
+import org.springframework.beans.factory.BeanDefinitionStoreException;
+import org.springframework.beans.factory.BeanNameAware;
+import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
+import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
+import org.springframework.beans.factory.config.BeanDefinitionVisitor;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.BeansException;
+import org.springframework.osgi.context.BundleContextAware;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.apache.servicemix.document.DocumentRepository;
+
+/**
+ * A spring document factory allowing documents to be registered in the DocumentRegistry
+ * and also post processes the document-name:xxx url to transform it into a
+ * document: url handled by the repository.
+ */
+public class DocumentFactory implements FactoryBean, BundleContextAware, InitializingBean, BeanFactoryPostProcessor, BeanNameAware, BeanFactoryAware {
+
+    private BundleContext bundleContext;
+    private String document;
+    private String documentId;
+    private BeanFactory beanFactory;
+    private String beanName;
+    private DocumentRepository repository;
+
+    public Object getObject() throws Exception {
+        return documentId;
+    }
+
+    public Class getObjectType() {
+        return String.class;
+    }
+
+    public boolean isSingleton() {
+        return true;
+    }
+
+    public void setDocument(String document) {
+        this.document = document;
+    }
+
+    public void setBundleContext(BundleContext bundleContext) {
+        this.bundleContext = bundleContext;
+    }
+
+    public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
+        this.beanFactory = beanFactory;
+    }
+
+    public void setBeanName(String beanName) {
+        this.beanName = beanName;
+    }
+
+    public void setRepository(DocumentRepository repository) {
+        this.repository = repository;
+    }
+
+    public void afterPropertiesSet() throws Exception {
+        if (document == null) {
+            throw new IllegalStateException("document must be set");
+        }
+        if (repository != null) {
+            this.documentId = repository.register(document.getBytes());
+        } else if (bundleContext != null) {
+            ServiceReference ref = bundleContext.getServiceReference(DocumentRepository.class.getName());
+            if (ref == null) {
+                throw new IllegalStateException("Can not get a reference to the DocumentRepository");
+            }
+            try {
+                DocumentRepository rep = (DocumentRepository) bundleContext.getService(ref);
+                this.documentId = rep.register(document.getBytes());
+            } finally {
+                if (ref != null) {
+                    bundleContext.ungetService(ref);
+                }
+            }
+        } else {
+            throw new IllegalStateException("repoitory or bundleContext must be set");
+        }
+    }
+
+    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactoryToProcess) throws BeansException {
+        BeanDefinitionVisitor visitor = new BundleExtUrlBeanDefinitionVisitor();
+        String[] beanNames = beanFactoryToProcess.getBeanDefinitionNames();
+        for (int i = 0; i < beanNames.length; i++) {
+            // Check that we're not parsing our own bean definition,
+            // to avoid failing on unresolvable placeholders in properties file locations.
+            if (!(beanNames[i].equals(this.beanName) && beanFactoryToProcess.equals(this.beanFactory))) {
+                BeanDefinition bd = beanFactoryToProcess.getBeanDefinition(beanNames[i]);
+                try {
+                    visitor.visitBeanDefinition(bd);
+                } catch (BeanDefinitionStoreException ex) {
+                    throw new BeanDefinitionStoreException(bd.getResourceDescription(), beanNames[i], ex.getMessage());
+                }
+            }
+        }
+    }
+
+    private class BundleExtUrlBeanDefinitionVisitor extends BeanDefinitionVisitor {
+
+        protected String resolveStringValue(String string) {
+            if (string.equals("document-name:" + beanName)) {
+                string = documentId;
+            }
+            return string;
+        }
+    }
+
+}

Copied: servicemix/smx4/nmr/trunk/document/src/main/java/org/apache/servicemix/document/impl/DocumentRepositoryImpl.java (from r655606, servicemix/smx4/nmr/trunk/jbi/runtime/src/main/java/org/apache/servicemix/jbi/runtime/impl/DocumentRepositoryImpl.java)
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/document/src/main/java/org/apache/servicemix/document/impl/DocumentRepositoryImpl.java?p2=servicemix/smx4/nmr/trunk/document/src/main/java/org/apache/servicemix/document/impl/DocumentRepositoryImpl.java&p1=servicemix/smx4/nmr/trunk/jbi/runtime/src/main/java/org/apache/servicemix/jbi/runtime/impl/DocumentRepositoryImpl.java&r1=655606&r2=662362&rev=662362&view=diff
==============================================================================
--- servicemix/smx4/nmr/trunk/jbi/runtime/src/main/java/org/apache/servicemix/jbi/runtime/impl/DocumentRepositoryImpl.java (original)
+++ servicemix/smx4/nmr/trunk/document/src/main/java/org/apache/servicemix/document/impl/DocumentRepositoryImpl.java Mon Jun  2 01:45:14 2008
@@ -14,27 +14,26 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.servicemix.jbi.runtime.impl;
+package org.apache.servicemix.document.impl;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.OutputStream;
 import java.net.URL;
 import java.net.URLConnection;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
-import org.apache.servicemix.jbi.runtime.DocumentRepository;
-import org.apache.servicemix.jbi.runtime.Resource;
+import org.apache.servicemix.document.Resource;
+import org.apache.servicemix.document.DocumentRepository;
 import org.osgi.service.url.AbstractURLStreamHandlerService;
 
 /**
  * Simple document repository
  */
-public class DocumentRepositoryImpl extends AbstractURLStreamHandlerService implements DocumentRepository  {
+public class DocumentRepositoryImpl extends AbstractURLStreamHandlerService implements DocumentRepository {
 
     public static final String PROTOCOL = "document";
     public static final String PROTOCOL_COLUMN = PROTOCOL + ":";

Added: servicemix/smx4/nmr/trunk/document/src/main/resources/META-INF/spring/servicemix-document.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/document/src/main/resources/META-INF/spring/servicemix-document.xml?rev=662362&view=auto
==============================================================================
--- servicemix/smx4/nmr/trunk/document/src/main/resources/META-INF/spring/servicemix-document.xml (added)
+++ servicemix/smx4/nmr/trunk/document/src/main/resources/META-INF/spring/servicemix-document.xml Mon Jun  2 01:45:14 2008
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:osgi="http://www.springframework.org/schema/osgi"
+       xmlns:util="http://www.springframework.org/schema/util"
+       xsi:schemaLocation="
+  http://www.springframework.org/schema/beans
+  http://www.springframework.org/schema/beans/spring-beans.xsd
+  http://www.springframework.org/schema/util
+  http://www.springframework.org/schema/util/spring-util.xsd
+  http://www.springframework.org/schema/osgi
+  http://www.springframework.org/schema/osgi/spring-osgi.xsd">
+
+    <!-- URL handler for in memory documents -->
+    <bean id="documentRepository" class="org.apache.servicemix.document.impl.DocumentRepositoryImpl">
+    </bean>
+
+    <!-- Expose the Document Registry / URL Handler -->
+    <osgi:service ref="documentRepository" >
+        <osgi:interfaces>
+            <value>org.apache.servicemix.document.DocumentRepository</value>
+            <value>org.osgi.service.url.URLStreamHandlerService</value>
+        </osgi:interfaces>
+        <osgi:service-properties>
+            <entry key="url.handler.protocol" value="document" />
+        </osgi:service-properties>
+    </osgi:service>
+
+</beans>

Added: servicemix/smx4/nmr/trunk/document/src/test/java/org/apache/servicemix/document/impl/DocumentFactoryTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/document/src/test/java/org/apache/servicemix/document/impl/DocumentFactoryTest.java?rev=662362&view=auto
==============================================================================
--- servicemix/smx4/nmr/trunk/document/src/test/java/org/apache/servicemix/document/impl/DocumentFactoryTest.java (added)
+++ servicemix/smx4/nmr/trunk/document/src/test/java/org/apache/servicemix/document/impl/DocumentFactoryTest.java Mon Jun  2 01:45:14 2008
@@ -0,0 +1,33 @@
+/*
+ * 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.servicemix.document.impl;
+
+import java.net.URI;
+
+import junit.framework.TestCase;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class DocumentFactoryTest extends TestCase {
+
+    public void testDoc() {
+        ApplicationContext ctx = new ClassPathXmlApplicationContext("test.xml");
+        URI uri = (URI) ctx.getBean("uri");
+        assertEquals("document", uri.getScheme());
+    }
+}
+

Copied: servicemix/smx4/nmr/trunk/document/src/test/java/org/apache/servicemix/document/impl/DocumentRepositoryImplTest.java (from r655606, servicemix/smx4/nmr/trunk/jbi/runtime/src/test/java/org/apache/servicemix/jbi/runtime/impl/DocumentRepositoryImplTest.java)
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/document/src/test/java/org/apache/servicemix/document/impl/DocumentRepositoryImplTest.java?p2=servicemix/smx4/nmr/trunk/document/src/test/java/org/apache/servicemix/document/impl/DocumentRepositoryImplTest.java&p1=servicemix/smx4/nmr/trunk/jbi/runtime/src/test/java/org/apache/servicemix/jbi/runtime/impl/DocumentRepositoryImplTest.java&r1=655606&r2=662362&rev=662362&view=diff
==============================================================================
--- servicemix/smx4/nmr/trunk/jbi/runtime/src/test/java/org/apache/servicemix/jbi/runtime/impl/DocumentRepositoryImplTest.java (original)
+++ servicemix/smx4/nmr/trunk/document/src/test/java/org/apache/servicemix/document/impl/DocumentRepositoryImplTest.java Mon Jun  2 01:45:14 2008
@@ -14,20 +14,20 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.servicemix.jbi.runtime.impl;
+package org.apache.servicemix.document.impl;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.OutputStream;
 import java.net.URL;
 import java.net.URLConnection;
 import java.net.URLStreamHandler;
 import java.net.URLStreamHandlerFactory;
 
 import junit.framework.TestCase;
-import org.apache.servicemix.jbi.util.FileUtil;
 import org.osgi.service.url.URLStreamHandlerSetter;
 
 public class DocumentRepositoryImplTest extends TestCase {
@@ -56,7 +56,7 @@
 
         InputStream is = new URL(url).openStream();
         ByteArrayOutputStream os = new ByteArrayOutputStream();
-        FileUtil.copyInputStream(is, os);
+        copyInputStream(is, os);
         byte[] d = os.toByteArray();
         assertEquals(4, d.length);
         for (int i = 0; i < 4; i++) {
@@ -90,5 +90,22 @@
             super.setURL(u, protocol, host, port, authority, userInfo, path, query, ref);
         }
     }
+
+    /**
+     * Copy in stream to an out stream
+     * 
+     * @param in
+     * @param out
+     * @throws IOException
+     */
+    public static void copyInputStream(InputStream in, OutputStream out) throws IOException {
+        byte[] buffer = new byte[8192];
+        int len = in.read(buffer);
+        while (len >= 0) {
+            out.write(buffer, 0, len);
+            len = in.read(buffer);
+        }
+    }
+
 }
 

Added: servicemix/smx4/nmr/trunk/document/src/test/resources/test.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/document/src/test/resources/test.xml?rev=662362&view=auto
==============================================================================
--- servicemix/smx4/nmr/trunk/document/src/test/resources/test.xml (added)
+++ servicemix/smx4/nmr/trunk/document/src/test/resources/test.xml Mon Jun  2 01:45:14 2008
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:osgi="http://www.springframework.org/schema/osgi"
+       xmlns:util="http://www.springframework.org/schema/util"
+       xsi:schemaLocation="
+  http://www.springframework.org/schema/beans
+  http://www.springframework.org/schema/beans/spring-beans.xsd
+  http://www.springframework.org/schema/util
+  http://www.springframework.org/schema/util/spring-util.xsd
+  http://www.springframework.org/schema/osgi
+  http://www.springframework.org/schema/osgi/spring-osgi.xsd">
+
+    <bean id="documentRepository" class="org.apache.servicemix.document.impl.DocumentRepositoryImpl">
+    </bean>
+
+    <bean id="doc" class="org.apache.servicemix.document.factory.DocumentFactory">
+        <property name="repository" ref="documentRepository" />
+        <property name="document">
+            <value>
+                Hey guy !
+            </value>
+        </property>
+    </bean>
+
+    <bean id="uri" class="java.net.URI" factory-method="create">
+        <constructor-arg value="document-name:doc" />
+    </bean>
+
+</beans>

Modified: servicemix/smx4/nmr/trunk/jbi/itests/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/jbi/itests/pom.xml?rev=662362&r1=662361&r2=662362&view=diff
==============================================================================
--- servicemix/smx4/nmr/trunk/jbi/itests/pom.xml (original)
+++ servicemix/smx4/nmr/trunk/jbi/itests/pom.xml Mon Jun  2 01:45:14 2008
@@ -98,6 +98,12 @@
             <scope>test</scope>
         </dependency>
         <dependency>
+            <groupId>org.apache.servicemix.document</groupId>
+            <artifactId>org.apache.servicemix.document</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
             <groupId>org.apache.servicemix.jbi</groupId>
             <artifactId>org.apache.servicemix.jbi.api</artifactId>
             <version>${project.version}</version>

Modified: servicemix/smx4/nmr/trunk/jbi/itests/src/test/java/org/apache/servicemix/jbi/IntegrationTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/jbi/itests/src/test/java/org/apache/servicemix/jbi/IntegrationTest.java?rev=662362&r1=662361&r2=662362&view=diff
==============================================================================
--- servicemix/smx4/nmr/trunk/jbi/itests/src/test/java/org/apache/servicemix/jbi/IntegrationTest.java (original)
+++ servicemix/smx4/nmr/trunk/jbi/itests/src/test/java/org/apache/servicemix/jbi/IntegrationTest.java Mon Jun  2 01:45:14 2008
@@ -65,6 +65,7 @@
             getBundle("org.apache.servicemix.nmr", "org.apache.servicemix.nmr.core"),
             getBundle("org.apache.servicemix.nmr", "org.apache.servicemix.nmr.spring"),
             getBundle("org.apache.servicemix.nmr", "org.apache.servicemix.nmr.osgi"),
+            getBundle("org.apache.servicemix.document", "org.apache.servicemix.document"),
             getBundle("org.apache.servicemix.jbi", "org.apache.servicemix.jbi.api"),
             getBundle("org.apache.servicemix.jbi", "org.apache.servicemix.jbi.runtime"),
             getBundle("org.apache.servicemix.jbi", "org.apache.servicemix.jbi.deployer"),

Modified: servicemix/smx4/nmr/trunk/jbi/osgi/src/main/resources/META-INF/spring/servicemix-jbi.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/jbi/osgi/src/main/resources/META-INF/spring/servicemix-jbi.xml?rev=662362&r1=662361&r2=662362&view=diff
==============================================================================
--- servicemix/smx4/nmr/trunk/jbi/osgi/src/main/resources/META-INF/spring/servicemix-jbi.xml (original)
+++ servicemix/smx4/nmr/trunk/jbi/osgi/src/main/resources/META-INF/spring/servicemix-jbi.xml Mon Jun  2 01:45:14 2008
@@ -37,10 +37,6 @@
         <property name="environment" ref="environment" />
     </bean>
 
-    <!-- URL handler for in memory documents -->
-    <bean id="documentRepository" class="org.apache.servicemix.jbi.runtime.impl.DocumentRepositoryImpl">
-    </bean>
-
     <!-- Management context -->
     <bean id="managementContext" class="org.apache.servicemix.jbi.runtime.impl.ManagementContext">
         <property name="jmxDomainName" value="org.apache.servicemix" />
@@ -69,6 +65,10 @@
     <osgi:reference id="nmr"
                     interface="org.apache.servicemix.nmr.api.NMR" />
 
+    <!-- Reference to the DocumentRepository -->
+    <osgi:reference id="documentRepository"
+                    interface="org.apache.servicemix.document.DocumentRepository" />
+
     <!-- Reference to the Transaction Manager -->
     <osgi:list id="transactionManagers"
                interface="javax.transaction.TransactionManager"
@@ -91,15 +91,4 @@
         </osgi:interfaces>
     </osgi:service>
 
-    <!-- Expose the Document Registry / URL Handler -->
-    <osgi:service ref="documentRepository" >
-        <osgi:interfaces>
-            <value>org.apache.servicemix.jbi.runtime.DocumentRepository</value>
-            <value>org.osgi.service.url.URLStreamHandlerService</value>
-        </osgi:interfaces>
-        <osgi:service-properties>
-            <entry key="url.handler.protocol" value="document" />       
-        </osgi:service-properties>
-    </osgi:service>
-
 </beans>

Modified: servicemix/smx4/nmr/trunk/jbi/runtime/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/jbi/runtime/pom.xml?rev=662362&r1=662361&r2=662362&view=diff
==============================================================================
--- servicemix/smx4/nmr/trunk/jbi/runtime/pom.xml (original)
+++ servicemix/smx4/nmr/trunk/jbi/runtime/pom.xml Mon Jun  2 01:45:14 2008
@@ -43,6 +43,11 @@
             <version>${project.version}</version>
         </dependency>
         <dependency>
+            <groupId>org.apache.servicemix.document</groupId>
+            <artifactId>org.apache.servicemix.document</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
             <groupId>commons-logging</groupId>
             <artifactId>commons-logging</artifactId>
             <version>${commons.logging.version}</version>

Modified: servicemix/smx4/nmr/trunk/jbi/runtime/src/main/java/org/apache/servicemix/jbi/runtime/impl/ComponentContextImpl.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/jbi/runtime/src/main/java/org/apache/servicemix/jbi/runtime/impl/ComponentContextImpl.java?rev=662362&r1=662361&r2=662362&view=diff
==============================================================================
--- servicemix/smx4/nmr/trunk/jbi/runtime/src/main/java/org/apache/servicemix/jbi/runtime/impl/ComponentContextImpl.java (original)
+++ servicemix/smx4/nmr/trunk/jbi/runtime/src/main/java/org/apache/servicemix/jbi/runtime/impl/ComponentContextImpl.java Mon Jun  2 01:45:14 2008
@@ -30,7 +30,6 @@
 import java.util.logging.Logger;
 
 import javax.jbi.JBIException;
-import javax.jbi.component.Component;
 import javax.jbi.component.ComponentContext;
 import javax.jbi.management.MBeanNames;
 import javax.jbi.messaging.DeliveryChannel;
@@ -50,8 +49,8 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.servicemix.document.DocumentRepository;
 import org.apache.servicemix.jbi.runtime.ComponentRegistry;
-import org.apache.servicemix.jbi.runtime.DocumentRepository;
 import org.apache.servicemix.jbi.runtime.Environment;
 import org.apache.servicemix.jbi.runtime.ComponentWrapper;
 import org.apache.servicemix.jbi.runtime.impl.utils.DOMUtil;

Modified: servicemix/smx4/nmr/trunk/jbi/runtime/src/main/java/org/apache/servicemix/jbi/runtime/impl/ComponentRegistryImpl.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/jbi/runtime/src/main/java/org/apache/servicemix/jbi/runtime/impl/ComponentRegistryImpl.java?rev=662362&r1=662361&r2=662362&view=diff
==============================================================================
--- servicemix/smx4/nmr/trunk/jbi/runtime/src/main/java/org/apache/servicemix/jbi/runtime/impl/ComponentRegistryImpl.java (original)
+++ servicemix/smx4/nmr/trunk/jbi/runtime/src/main/java/org/apache/servicemix/jbi/runtime/impl/ComponentRegistryImpl.java Mon Jun  2 01:45:14 2008
@@ -16,18 +16,15 @@
  */
 package org.apache.servicemix.jbi.runtime.impl;
 
-import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
 import javax.jbi.JBIException;
-import javax.jbi.component.Component;
-import javax.jbi.component.ComponentContext;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.servicemix.document.DocumentRepository;
 import org.apache.servicemix.jbi.runtime.ComponentRegistry;
-import org.apache.servicemix.jbi.runtime.DocumentRepository;
 import org.apache.servicemix.jbi.runtime.Environment;
 import org.apache.servicemix.jbi.runtime.ComponentWrapper;
 import org.apache.servicemix.nmr.api.NMR;

Modified: servicemix/smx4/nmr/trunk/jbi/runtime/src/main/java/org/apache/servicemix/jbi/runtime/impl/NormalizedMessageImpl.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/jbi/runtime/src/main/java/org/apache/servicemix/jbi/runtime/impl/NormalizedMessageImpl.java?rev=662362&r1=662361&r2=662362&view=diff
==============================================================================
--- servicemix/smx4/nmr/trunk/jbi/runtime/src/main/java/org/apache/servicemix/jbi/runtime/impl/NormalizedMessageImpl.java (original)
+++ servicemix/smx4/nmr/trunk/jbi/runtime/src/main/java/org/apache/servicemix/jbi/runtime/impl/NormalizedMessageImpl.java Mon Jun  2 01:45:14 2008
@@ -80,7 +80,7 @@
     }
 
     public void setSecuritySubject(Subject subject) {
-        message.setHeader(Subject.class, subject);
+        message.setSecuritySubject(subject);
     }
 
     public Set getPropertyNames() {
@@ -92,6 +92,6 @@
     }
 
     public Subject getSecuritySubject() {
-        return message.getHeader(Subject.class);
+        return message.getSecuritySubject();
     }
 }

Modified: servicemix/smx4/nmr/trunk/nmr/api/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/nmr/api/pom.xml?rev=662362&r1=662361&r2=662362&view=diff
==============================================================================
--- servicemix/smx4/nmr/trunk/nmr/api/pom.xml (original)
+++ servicemix/smx4/nmr/trunk/nmr/api/pom.xml Mon Jun  2 01:45:14 2008
@@ -56,7 +56,7 @@
                         <Bundle-Name>${pom.name}</Bundle-Name>
                         <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
                         <Export-Package>
-                            ${pom.artifactId},${pom.artifactId}.service,${pom.artifactId}.event,${pom.artifactId}.internal
+                            ${pom.artifactId},${pom.artifactId}.service,${pom.artifactId}.event,${pom.artifactId}.internal,${pom.artifactId}.security
                         </Export-Package>
                     </instructions>
                 </configuration>

Modified: servicemix/smx4/nmr/trunk/nmr/api/src/main/java/org/apache/servicemix/nmr/api/Exchange.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/nmr/api/src/main/java/org/apache/servicemix/nmr/api/Exchange.java?rev=662362&r1=662361&r2=662362&view=diff
==============================================================================
--- servicemix/smx4/nmr/trunk/nmr/api/src/main/java/org/apache/servicemix/nmr/api/Exchange.java (original)
+++ servicemix/smx4/nmr/trunk/nmr/api/src/main/java/org/apache/servicemix/nmr/api/Exchange.java Mon Jun  2 01:45:14 2008
@@ -27,8 +27,6 @@
  * representing a link to a logical endpoint.
  * Exchanges are created using the {@link Channel}.
  *
- * TODO: transactions
- *
  * @version $Revision: $
  * @since 4.0
  */

Modified: servicemix/smx4/nmr/trunk/nmr/api/src/main/java/org/apache/servicemix/nmr/api/Message.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/nmr/api/src/main/java/org/apache/servicemix/nmr/api/Message.java?rev=662362&r1=662361&r2=662362&view=diff
==============================================================================
--- servicemix/smx4/nmr/trunk/nmr/api/src/main/java/org/apache/servicemix/nmr/api/Message.java (original)
+++ servicemix/smx4/nmr/trunk/nmr/api/src/main/java/org/apache/servicemix/nmr/api/Message.java Mon Jun  2 01:45:14 2008
@@ -19,6 +19,8 @@
 import java.io.Serializable;
 import java.util.Map;
 
+import javax.security.auth.Subject;
+
 /**
  * The Message represents the content of a request, a response or a fault.
  * Messages are part of {@link Exchange}s are created using
@@ -200,6 +202,20 @@
     void setContentEncoding(String encoding);
 
     /**
+     * Get the security subject for this message
+     *
+     * @return the security subject
+     */
+    Subject getSecuritySubject();
+
+    /**
+     * Set the security subject for this message
+     *
+     * @param securitySubject the security subject
+     */
+    void setSecuritySubject(Subject securitySubject);
+
+    /**
      * Copies the contents of the other message into this message
      * 
      * @param msg the message to copy from

Added: servicemix/smx4/nmr/trunk/nmr/api/src/main/java/org/apache/servicemix/nmr/api/security/AuthenticationService.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/nmr/api/src/main/java/org/apache/servicemix/nmr/api/security/AuthenticationService.java?rev=662362&view=auto
==============================================================================
--- servicemix/smx4/nmr/trunk/nmr/api/src/main/java/org/apache/servicemix/nmr/api/security/AuthenticationService.java (added)
+++ servicemix/smx4/nmr/trunk/nmr/api/src/main/java/org/apache/servicemix/nmr/api/security/AuthenticationService.java Mon Jun  2 01:45:14 2008
@@ -0,0 +1,44 @@
+/*
+ * 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.servicemix.nmr.api.security;
+
+import java.security.GeneralSecurityException;
+
+import javax.security.auth.Subject;
+
+/**
+ * Interface for the authentication service.
+ *
+ */
+public interface AuthenticationService {
+
+    /**
+     * Authenticate a user given its name and credentials.
+     * Upon sucessfull completion, the subject should be populated
+     * with the user known principals, including, but not limited to
+     * a UserPrincipal and the GroupPrincipal that this user belongs
+     * to.
+     *
+     * @param subject the subject to populate
+     * @param domain the security domain to use
+     * @param user the user name
+     * @param credentials the user credntials
+     * @throws GeneralSecurityException if the user can not be authenticated
+     */
+    void authenticate(Subject subject, String domain, String user, Object credentials) throws GeneralSecurityException;
+
+}

Added: servicemix/smx4/nmr/trunk/nmr/api/src/main/java/org/apache/servicemix/nmr/api/security/AuthorizationEntry.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/nmr/api/src/main/java/org/apache/servicemix/nmr/api/security/AuthorizationEntry.java?rev=662362&view=auto
==============================================================================
--- servicemix/smx4/nmr/trunk/nmr/api/src/main/java/org/apache/servicemix/nmr/api/security/AuthorizationEntry.java (added)
+++ servicemix/smx4/nmr/trunk/nmr/api/src/main/java/org/apache/servicemix/nmr/api/security/AuthorizationEntry.java Mon Jun  2 01:45:14 2008
@@ -0,0 +1,57 @@
+/*
+ * 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.servicemix.nmr.api.security;
+
+import java.util.Set;
+
+import javax.xml.namespace.QName;
+
+/**
+ *
+ */
+public interface AuthorizationEntry {
+
+    enum Type {
+
+        /**
+         * Add the roles to the ACLs list
+         */
+        Add,
+
+        /**
+         * Set the ACLs to the given roles
+         */
+        Set,
+
+
+        /**
+         * Remove the given roles from the ACLs list
+         */
+        Remove
+    }
+
+    Type getType();
+
+    int getRank();
+
+    String getEndpoint();
+
+    QName getOperation();
+
+    Set<GroupPrincipal> getAcls();
+
+}

Added: servicemix/smx4/nmr/trunk/nmr/api/src/main/java/org/apache/servicemix/nmr/api/security/AuthorizationService.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/nmr/api/src/main/java/org/apache/servicemix/nmr/api/security/AuthorizationService.java?rev=662362&view=auto
==============================================================================
--- servicemix/smx4/nmr/trunk/nmr/api/src/main/java/org/apache/servicemix/nmr/api/security/AuthorizationService.java (added)
+++ servicemix/smx4/nmr/trunk/nmr/api/src/main/java/org/apache/servicemix/nmr/api/security/AuthorizationService.java Mon Jun  2 01:45:14 2008
@@ -0,0 +1,44 @@
+/*
+ * 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.servicemix.nmr.api.security;
+
+import java.security.Principal;
+import java.util.Set;
+
+import javax.xml.namespace.QName;
+
+/**
+ * The AuthorizationService interface allows the NMR to retrieve the
+ * Access Control List for a given combination of endpoint / operation.
+ *
+ * This is used to secure access to a given endpoint. 
+ *  
+ */
+public interface AuthorizationService {
+
+    /**
+     * Retrieve the Access Control List for a given endpoint and operation.
+     * The endpoint is identified by its ID (usually a combination of
+     * service QName and endpoint in the JBI case).
+     * 
+     * @param endpoint the endpoint identifier
+     * @param operation the operation invoked or null
+     * @return a set of GroupPrincipal allowed to invoke the endpoint / operation
+     */
+    Set<GroupPrincipal> getAcls(String endpoint, QName operation);
+
+}

Added: servicemix/smx4/nmr/trunk/nmr/api/src/main/java/org/apache/servicemix/nmr/api/security/CertificateCallback.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/nmr/api/src/main/java/org/apache/servicemix/nmr/api/security/CertificateCallback.java?rev=662362&view=auto
==============================================================================
--- servicemix/smx4/nmr/trunk/nmr/api/src/main/java/org/apache/servicemix/nmr/api/security/CertificateCallback.java (added)
+++ servicemix/smx4/nmr/trunk/nmr/api/src/main/java/org/apache/servicemix/nmr/api/security/CertificateCallback.java Mon Jun  2 01:45:14 2008
@@ -0,0 +1,40 @@
+/*
+ * 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.servicemix.nmr.api.security;
+
+import java.security.cert.X509Certificate;
+
+import javax.security.auth.callback.Callback;
+
+/**
+ * A callback to retrieve an X509Certificate.
+ * This class is mainly used from the related login module.
+ *
+ * @see CertificatesLoginModule
+ */
+public class CertificateCallback implements Callback {
+
+    private X509Certificate certificate;
+
+    public X509Certificate getCertificate() {
+        return certificate;
+    }
+
+    public void setCertificate(X509Certificate certificate) {
+        this.certificate = certificate;
+    }
+}

Added: servicemix/smx4/nmr/trunk/nmr/api/src/main/java/org/apache/servicemix/nmr/api/security/GroupPrincipal.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/nmr/api/src/main/java/org/apache/servicemix/nmr/api/security/GroupPrincipal.java?rev=662362&view=auto
==============================================================================
--- servicemix/smx4/nmr/trunk/nmr/api/src/main/java/org/apache/servicemix/nmr/api/security/GroupPrincipal.java (added)
+++ servicemix/smx4/nmr/trunk/nmr/api/src/main/java/org/apache/servicemix/nmr/api/security/GroupPrincipal.java Mon Jun  2 01:45:14 2008
@@ -0,0 +1,68 @@
+/*
+ * 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.servicemix.nmr.api.security;
+
+import java.security.Principal;
+
+
+/**
+ * This principal represents a group against which authorizations are
+ * usually checked.
+ */
+public class GroupPrincipal implements Principal {
+
+    public static final GroupPrincipal ANY = new GroupPrincipal("*");
+
+    private final String name;
+    private transient int hash;
+
+    public GroupPrincipal(String name) {
+        if (name == null) {
+            throw new IllegalArgumentException("name cannot be null");
+        }
+        this.name = name;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
+        final GroupPrincipal that = (GroupPrincipal) o;
+        if (!name.equals(that.name)) {
+            return false;
+        }
+        return true;
+    }
+
+    public int hashCode() {
+        if (hash == 0) {
+            hash = name.hashCode();
+        }
+        return hash;
+    }
+
+    public String toString() {
+        return name;
+    }
+}

Added: servicemix/smx4/nmr/trunk/nmr/api/src/main/java/org/apache/servicemix/nmr/api/security/UserPrincipal.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/nmr/api/src/main/java/org/apache/servicemix/nmr/api/security/UserPrincipal.java?rev=662362&view=auto
==============================================================================
--- servicemix/smx4/nmr/trunk/nmr/api/src/main/java/org/apache/servicemix/nmr/api/security/UserPrincipal.java (added)
+++ servicemix/smx4/nmr/trunk/nmr/api/src/main/java/org/apache/servicemix/nmr/api/security/UserPrincipal.java Mon Jun  2 01:45:14 2008
@@ -0,0 +1,68 @@
+/*
+ * 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.servicemix.nmr.api.security;
+
+import java.security.Principal;
+
+
+/**
+ * Represents the user authenticated by the AuthenticationService
+ */
+public class UserPrincipal implements Principal {
+
+    private final String name;
+    private transient int hash;
+
+    public UserPrincipal(String name) {
+        if (name == null) {
+            throw new IllegalArgumentException("name cannot be null");
+        }
+        this.name = name;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
+
+        final UserPrincipal that = (UserPrincipal) o;
+
+        if (!name.equals(that.name)) {
+            return false;
+        }
+
+        return true;
+    }
+
+    public int hashCode() {
+        if (hash == 0) {
+            hash = name.hashCode();
+        }
+        return hash;
+    }
+
+    public String toString() {
+        return name;
+    }
+}

Added: servicemix/smx4/nmr/trunk/nmr/api/src/test/java/org/apache/servicemix/nmr/api/security/GroupPrincipalTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/nmr/api/src/test/java/org/apache/servicemix/nmr/api/security/GroupPrincipalTest.java?rev=662362&view=auto
==============================================================================
--- servicemix/smx4/nmr/trunk/nmr/api/src/test/java/org/apache/servicemix/nmr/api/security/GroupPrincipalTest.java (added)
+++ servicemix/smx4/nmr/trunk/nmr/api/src/test/java/org/apache/servicemix/nmr/api/security/GroupPrincipalTest.java Mon Jun  2 01:45:14 2008
@@ -0,0 +1,58 @@
+/*
+ * 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.servicemix.nmr.api.security;
+
+import junit.framework.TestCase;
+
+/**
+ *
+ */
+public class GroupPrincipalTest extends TestCase {
+
+    public void testArguments() {
+        GroupPrincipal principal = new GroupPrincipal("FOO");
+
+        assertEquals("FOO", principal.getName());
+
+        try {
+            new GroupPrincipal(null);
+            fail("Should have thrown IllegalArgumentException");
+        } catch (IllegalArgumentException ingore) {
+            // Expected
+        }
+    }
+
+    public void testHash() {
+        GroupPrincipal p1 = new GroupPrincipal("FOO");
+        GroupPrincipal p2 = new GroupPrincipal("FOO");
+
+        assertEquals(p1.hashCode(), p1.hashCode());
+        assertEquals(p1.hashCode(), p2.hashCode());
+    }
+
+    public void testEquals() {
+        GroupPrincipal p1 = new GroupPrincipal("FOO");
+        GroupPrincipal p2 = new GroupPrincipal("FOO");
+        GroupPrincipal p3 = new GroupPrincipal("BAR");
+
+        assertTrue(p1.equals(p1));
+        assertTrue(p1.equals(p2));
+        assertFalse(p1.equals((Object) null)); // NOPMD just testing
+        assertFalse(p1.equals(new Object())); // NOPMD just testing
+        assertFalse(p1.equals(p3));
+    }
+}

Added: servicemix/smx4/nmr/trunk/nmr/api/src/test/java/org/apache/servicemix/nmr/api/security/UserPrincipalTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/nmr/api/src/test/java/org/apache/servicemix/nmr/api/security/UserPrincipalTest.java?rev=662362&view=auto
==============================================================================
--- servicemix/smx4/nmr/trunk/nmr/api/src/test/java/org/apache/servicemix/nmr/api/security/UserPrincipalTest.java (added)
+++ servicemix/smx4/nmr/trunk/nmr/api/src/test/java/org/apache/servicemix/nmr/api/security/UserPrincipalTest.java Mon Jun  2 01:45:14 2008
@@ -0,0 +1,59 @@
+/*
+ * 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.servicemix.nmr.api.security;
+
+import junit.framework.TestCase;
+
+/**
+ *
+ */
+public class UserPrincipalTest extends TestCase {
+
+    public void testArguments() {
+        UserPrincipal principal = new UserPrincipal("FOO");
+
+        assertEquals("FOO", principal.getName());
+
+        try {
+            new UserPrincipal(null);
+            fail("Should have thrown IllegalArgumentException");
+        } catch (IllegalArgumentException ingore) {
+            // Expected
+        }
+    }
+
+    public void testHash() {
+        UserPrincipal p1 = new UserPrincipal("FOO");
+        UserPrincipal p2 = new UserPrincipal("FOO");
+
+        assertEquals(p1.hashCode(), p1.hashCode());
+        assertEquals(p1.hashCode(), p2.hashCode());
+    }
+
+    @SuppressWarnings("PMD.PositionLiteralsFirstInComparisons")
+    public void testEquals() {
+        UserPrincipal p1 = new UserPrincipal("FOO");
+        UserPrincipal p2 = new UserPrincipal("FOO");
+        UserPrincipal p3 = new UserPrincipal("BAR");
+
+        assertTrue(p1.equals(p1));
+        assertTrue(p1.equals(p2));
+        assertFalse(p1.equals((Object) null)); // NOPMD just testing
+        assertFalse(p1.equals(new Object())); // NOPMD just testing
+        assertFalse(p1.equals(p3));
+    }
+}

Modified: servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/FlowRegistryImpl.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/FlowRegistryImpl.java?rev=662362&r1=662361&r2=662362&view=diff
==============================================================================
--- servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/FlowRegistryImpl.java (original)
+++ servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/FlowRegistryImpl.java Mon Jun  2 01:45:14 2008
@@ -16,8 +16,15 @@
  */
 package org.apache.servicemix.nmr.core;
 
+import java.util.Set;
+import java.security.Principal;
+
+import javax.security.auth.Subject;
+
 import org.apache.servicemix.nmr.api.Role;
 import org.apache.servicemix.nmr.api.ServiceMixException;
+import org.apache.servicemix.nmr.api.security.AuthorizationService;
+import org.apache.servicemix.nmr.api.security.GroupPrincipal;
 import org.apache.servicemix.nmr.api.internal.Flow;
 import org.apache.servicemix.nmr.api.internal.FlowRegistry;
 import org.apache.servicemix.nmr.api.internal.InternalEndpoint;
@@ -32,6 +39,16 @@
  */
 public class FlowRegistryImpl extends ServiceRegistryImpl<Flow> implements FlowRegistry {
 
+    private AuthorizationService authorizationService;
+
+    public AuthorizationService getAuthorizationService() {
+        return authorizationService;
+    }
+
+    public void setAuthorizationService(AuthorizationService authorizationService) {
+        this.authorizationService = authorizationService;
+    }
+
     public boolean canDispatch(InternalExchange exchange, InternalEndpoint endpoint) {
         for (Flow flow : getServices()) {
             if (flow.canDispatch(exchange, endpoint)) {
@@ -47,33 +64,46 @@
                 InternalReference target = (InternalReference) exchange.getTarget();
                 assert target != null;
                 boolean match = false;
+                boolean securityMatch = false;
                 for (InternalEndpoint endpoint : target.choose()) {
                     match = true;
+                    if (authorizationService != null) {
+                        Set<GroupPrincipal> acls = authorizationService.getAcls(endpoint.getId(), exchange.getOperation());
+                        if (!acls.contains(GroupPrincipal.ANY)) {
+                            Subject subject = exchange.getIn().getSecuritySubject();
+                            if (subject == null) {
+                                continue;
+                            }
+                            acls.retainAll(subject.getPrincipals());
+                            if (acls.size() == 0) {
+                                continue;
+                            }
+                        }
+                    }
+                    securityMatch = true;
                     if (internalDispatch(exchange, endpoint, true)) {
                         return;
                     }
                 }
                 if (!match) {
                     throw new ServiceMixException("Could not dispatch exchange. No matching endpoints.");
+                } else if (!securityMatch) {
+                    throw new ServiceMixException("User not authenticated or not authorized to access any matching endpoint.");
                 } else {
                     throw new ServiceMixException("Could not dispatch exchange. No flow can handle it.");
                 }
             } else {
-                if (!internalDispatch(exchange, exchange.getDestination())) {
+                if (!internalDispatch(exchange, exchange.getDestination(), false)) {
                     throw new ServiceMixException("Could not dispatch exchange. No flow can handle it.");
                 }
             }
         } else {
-            if (!internalDispatch(exchange, exchange.getSource())) {
+            if (!internalDispatch(exchange, exchange.getSource(), false)) {
                 throw new ServiceMixException("Could not dispatch exchange. No flow can handle it.");
             }
         }
     }
 
-    protected boolean internalDispatch(InternalExchange exchange, InternalEndpoint endpoint) {
-        return internalDispatch(exchange, endpoint, false);
-    }
-
     protected boolean internalDispatch(InternalExchange exchange, InternalEndpoint endpoint, boolean setDestination) {
         for (Flow flow : getServices()) {
             if (flow.canDispatch(exchange, endpoint)) {

Modified: servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/MessageImpl.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/MessageImpl.java?rev=662362&r1=662361&r2=662362&view=diff
==============================================================================
--- servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/MessageImpl.java (original)
+++ servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/MessageImpl.java Mon Jun  2 01:45:14 2008
@@ -20,6 +20,8 @@
 import java.util.HashMap;
 import java.util.Map;
 
+import javax.security.auth.Subject;
+
 import org.apache.servicemix.nmr.api.Message;
 
 /**
@@ -38,6 +40,7 @@
     private Object body;
     private String contentType;
     private String contentEncoding;
+    private Subject securitySubject;
     private Map<String, Object> headers;
     private Map<String, Object> attachments;
     private transient Converter converter;
@@ -120,6 +123,24 @@
     }
 
     /**
+     * Get the security subject for this message
+     *
+     * @return the security subject
+     */
+    public Subject getSecuritySubject() {
+        return securitySubject;
+    }
+
+    /**
+     * Set the security subject for this message
+     *
+     * @param securitySubject the security subject
+     */
+    public void setSecuritySubject(Subject securitySubject) {
+        this.securitySubject = securitySubject;
+    }
+
+    /**
      * Get a header on this message.
      *
      * @param name the name of the header

Added: servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/security/DefaultAuthorizationEntry.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/security/DefaultAuthorizationEntry.java?rev=662362&view=auto
==============================================================================
--- servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/security/DefaultAuthorizationEntry.java (added)
+++ servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/security/DefaultAuthorizationEntry.java Mon Jun  2 01:45:14 2008
@@ -0,0 +1,171 @@
+/*
+ * 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.servicemix.nmr.core.security;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+import javax.xml.XMLConstants;
+import javax.xml.namespace.QName;
+
+import org.apache.servicemix.nmr.api.security.GroupPrincipal;
+import org.apache.servicemix.nmr.api.security.AuthorizationEntry;
+
+/**
+ * A simple authorization entry
+ *
+ * @author gnodet
+ */
+public class DefaultAuthorizationEntry implements AuthorizationEntry {
+
+    private Set<GroupPrincipal> acls;
+    private String endpoint;
+    private QName operation;
+    private Type type = Type.Add;
+    private int rank;
+
+    public DefaultAuthorizationEntry() {
+    }
+
+    public DefaultAuthorizationEntry(String endpoint, QName operation, String roles) {
+        this.endpoint = endpoint;
+        this.operation = operation;
+        this.acls = buildRoles(roles);
+    }
+
+    public DefaultAuthorizationEntry(String endpoint, QName operation, String roles, Type type) {
+        this.endpoint = endpoint;
+        this.operation = operation;
+        this.acls = buildRoles(roles);
+        this.type = type;
+    }
+
+    public DefaultAuthorizationEntry(String endpoint, QName operation, String roles, Type type, int rank) {
+        this.endpoint = endpoint;
+        this.operation = operation;
+        this.acls = buildRoles(roles);
+        this.type = type;
+        this.rank = rank;
+    }
+
+    /**
+     * @return the type
+     */
+    public Type getType() {
+        return type;
+    }
+
+    /**
+     * @param type the type to set
+     */
+    public void setType(Type type) {
+        this.type = type;
+    }
+
+    /**
+     * @return the rank
+     */
+    public int getRank() {
+        return rank;
+    }
+
+    /**
+     * @param rank the rank to set
+     */
+    public void setRank(int rank) {
+        this.rank = rank;
+    }
+
+    /**
+     * @return the endpoint
+     */
+    public String getEndpoint() {
+        return endpoint;
+    }
+
+    /**
+     * @param endpoint the endpoint to set
+     */
+    public void setEndpoint(String endpoint) {
+        this.endpoint = endpoint;
+    }
+
+    /**
+     * @return the service
+     */
+    /**
+     * @return the operation
+     */
+    public QName getOperation() {
+        return operation;
+    }
+
+    /**
+     * @param operation the operation to set
+     */
+    public void setOperation(QName operation) {
+        this.operation = operation;
+    }
+
+    /**
+     * @return the acls
+     */
+    public Set<GroupPrincipal> getAcls() {
+        return acls;
+    }
+
+    /**
+     * @param acls the acls to set
+     */
+    public void setAcls(Set<GroupPrincipal> acls) {
+        this.acls = acls;
+    }
+
+    public void setRoles(String roles) {
+        this.acls = buildRoles(roles);
+    }
+
+    public String getRoles() {
+        StringBuffer sb = new StringBuffer();
+        if (this.acls != null) {
+            for (Iterator<GroupPrincipal> iter = this.acls.iterator(); iter.hasNext();) {
+                GroupPrincipal p = iter.next();
+                sb.append(p);
+                if (iter.hasNext()) {
+                    sb.append(",");
+                }
+            }
+        }
+        return sb.toString();
+    }
+
+    public String toString() {
+        return "AuthorizationEntry[endpoint=" + endpoint + ", roles=" + getRoles() + ",type=" + type + "]";
+    }
+
+    private Set<GroupPrincipal> buildRoles(String roles) {
+        Set<GroupPrincipal> s = new HashSet<GroupPrincipal>();
+        StringTokenizer iter = new StringTokenizer(roles, ",");
+        while (iter.hasMoreTokens()) {
+            String name = iter.nextToken().trim();
+            s.add(new GroupPrincipal(name));
+        }
+        return s;
+    }
+}

Added: servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/security/DefaultAuthorizationService.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/security/DefaultAuthorizationService.java?rev=662362&view=auto
==============================================================================
--- servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/security/DefaultAuthorizationService.java (added)
+++ servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/security/DefaultAuthorizationService.java Mon Jun  2 01:45:14 2008
@@ -0,0 +1,100 @@
+/*
+ * 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.servicemix.nmr.core.security;
+
+import java.util.Set;
+import java.util.HashSet;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Map;
+import java.util.regex.Pattern;
+
+import javax.xml.namespace.QName;
+
+import org.apache.servicemix.nmr.api.security.AuthorizationService;
+import org.apache.servicemix.nmr.api.security.GroupPrincipal;
+import org.apache.servicemix.nmr.api.security.AuthorizationEntry;
+
+/**
+ * A default implementation of the authorization service.
+ */
+public class DefaultAuthorizationService implements AuthorizationService {
+
+    private List<AuthorizationEntry> authorizationEntries;
+    private Comparator<AuthorizationEntry> comparator;
+
+    public DefaultAuthorizationService() {
+        authorizationEntries = new ArrayList<AuthorizationEntry>();
+        comparator = new Comparator<AuthorizationEntry>() {
+            public int compare(AuthorizationEntry o1, AuthorizationEntry o2) {
+                if (o1.getRank() < o2.getRank()) {
+                    return -1;
+                } else if (o1.getRank() > o2.getRank()) {
+                    return 1;
+                } else {
+                    return 0;
+                }
+            }
+        };
+    }
+
+    public void register(AuthorizationEntry entry, Map<String,?> props) {
+        authorizationEntries.add(entry);
+        Collections.sort(authorizationEntries, comparator);
+    }
+
+    public void unregister(AuthorizationEntry entry, Map<String,?> props) {
+        authorizationEntries.remove(entry);
+        Collections.sort(authorizationEntries, comparator);
+    }
+
+    public Set<GroupPrincipal> getAcls(String endpoint, QName operation) {
+        Set<GroupPrincipal> acls = new HashSet<GroupPrincipal>();
+        for (AuthorizationEntry entry : authorizationEntries) {
+            if (match(entry, endpoint, operation)) {
+                if (AuthorizationEntry.Type.Add == entry.getType()) {
+                    acls.addAll(entry.getAcls());
+                } else if (AuthorizationEntry.Type.Set == entry.getType()) {
+                    acls.clear();
+                    acls.addAll(entry.getAcls());
+                } else if (AuthorizationEntry.Type.Remove == entry.getType()) {
+                    acls.removeAll(entry.getAcls());
+                }
+            }
+        }
+        return acls;
+    }
+
+    protected boolean match(AuthorizationEntry entry, String endpoint, QName operation) {
+        return match(entry.getEndpoint(), endpoint)
+            && (entry.getOperation() == null || operation == null || match(entry.getOperation(), operation));
+    }
+
+    private boolean match(QName acl, QName target) {
+        return match(acl.getNamespaceURI(), target.getNamespaceURI())
+            && match(acl.getLocalPart(), target.getLocalPart());
+    }
+
+    private boolean match(String acl, String target) {
+        return acl == null
+            || acl.equals("*")
+            || Pattern.matches(acl, target);
+    }
+
+}

Added: servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/security/JaasAuthenticationService.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/security/JaasAuthenticationService.java?rev=662362&view=auto
==============================================================================
--- servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/security/JaasAuthenticationService.java (added)
+++ servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/security/JaasAuthenticationService.java Mon Jun  2 01:45:14 2008
@@ -0,0 +1,68 @@
+/*
+ * 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.servicemix.nmr.core.security;
+
+import java.io.IOException;
+import java.security.GeneralSecurityException;
+import java.security.cert.X509Certificate;
+
+import javax.security.auth.Subject;
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.NameCallback;
+import javax.security.auth.callback.PasswordCallback;
+import javax.security.auth.callback.UnsupportedCallbackException;
+import javax.security.auth.login.LoginContext;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.servicemix.nmr.api.security.AuthenticationService;
+import org.apache.servicemix.nmr.api.security.CertificateCallback;
+
+/**
+ * An implementation of the AuthenticationService based on JAAS.
+ */
+public class JaasAuthenticationService implements AuthenticationService {
+
+    private static final Log LOG = LogFactory.getLog(JaasAuthenticationService.class);
+
+    public void authenticate(Subject subject,
+                             String domain,
+                             final String user,
+                             final Object credentials) throws GeneralSecurityException {
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Authenticating '" + user + "' with '" + credentials + "'");
+        }
+        LoginContext loginContext = new LoginContext(domain, subject, new CallbackHandler() {
+            public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
+                for (int i = 0; i < callbacks.length; i++) {
+                    if (callbacks[i] instanceof NameCallback) {
+                        ((NameCallback) callbacks[i]).setName(user);
+                    } else if (callbacks[i] instanceof PasswordCallback && credentials instanceof String) {
+                        ((PasswordCallback) callbacks[i]).setPassword(((String) credentials).toCharArray());
+                    } else if (callbacks[i] instanceof CertificateCallback && credentials instanceof X509Certificate) {
+                        ((CertificateCallback) callbacks[i]).setCertificate((X509Certificate) credentials);
+                    } else {
+                        throw new UnsupportedCallbackException(callbacks[i]);
+                    }
+                }
+            }
+        });
+        loginContext.login();
+    }
+
+}



Mime
View raw message