You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@river.apache.org by pe...@apache.org on 2010/11/05 12:05:42 UTC

svn commit: r1031510 [1/3] - in /incubator/river/jtsk/skunk/river-modules: ./ etc/ jsk-module-platform/ jsk-module-platform/src/ jsk-module-platform/src/main/ jsk-module-platform/src/main/java/ jsk-module-platform/src/main/java/net/ jsk-module-platform...

Author: peter_firmstone
Date: Fri Nov  5 11:05:39 2010
New Revision: 1031510

URL: http://svn.apache.org/viewvc?rev=1031510&view=rev
Log:
Michal Kleczek's river-modules

>From river-dev:


1. The main idea is to have annotations as objects that could be verified using 
standard River proxy verification facilities. To be honest the idea of having 
Module interface that enables plugging different classloading mechanisms is 
something completely optional.
2. For the client the basic scenario is:
a) The client gets a serialized object
b) When it is deserialized annotations (Modules) are read and "installed"
c) Installing a Module means:
c1) checking if it was already installed
c2) if not - prepare it using VerifyingProxyPreparer (I've choosen not to 
place any InvocationConstraints on Modules - I don't think it is necessary)
d) after a Module is installed it is used to load classes
3. There are several places in River that depend on annotations being Strings 
provided by RMIClassLoader. The most important places are
a) Discovery
b) Reggie implementation
c) ProxyTrustVerifier
Since I did not want to modify this code I had to implement RMIClassLoaderSpi 
so that it would provide serialized Modules as Strings. I've choosen to simply 
serialize them to byte arrays and Base64 encode them.
4. There are two important Module implementations available:
a) DefaultRmiModule
b) ProxyTrustModule
DefaultRmiModule can be trusted by the client without contacting any service - 
it uses RequireDlPermissionClassProvider to load classes.
ProxyTrustModule on the other hand uses a simple PreferredClassProvider to 
load classes. It is a smart proxy that implements getProxyTrustIterator() so 
that it can be verified by ProxyTrustVerifier.

On the server before we can annotate our objects with modules we have to 
register a Module that will be used as annotation.
If the server does not register any Module - DefaultRmiModule is going to be 
used as annotation.
The server can register a ProxyTrustModule as annotation - to do that it first 
must export an object that can be contacted to obtain a Module verifier.
In other words - a service must either:
a) export two ProxyTrusts (one for Modules and another one for the service 
itself)
b) its ProxyTrust must provide a verifier that is able to verify both a Module 
and a service proxy

To make it possible to use my code with existing services without modifying 
them I've decided to implement a special ModuleExporter which will override 
the service ServerProxyTrust implementation so that getProxyVerifier will 
return a Verifier capable of verifying both a Module and the service proxy.
This verifier works as follows:
1. Check if an object being verified is a Module.
2. If so - delegate to a module verifier
3. If not it means we're verifying a service proxy so delegate to a default 
verifier.
The problem is though that when this verifier is deserialized the module that 
is capable of loading the service proxy verifier is not yet installed (the 
client got this verifier to verify a Module before it can load any classes). 
That's why I called it LazyCompositeVerifier - the default verifier is not 
deserialized until it is actually needed.

The only problem left is that every time a client gets a service proxy it will 
issue a remote call twice to get a verifier: first to get a verifier for a Module 
and then to get a verifier for a service proxy. But it is going to be the same 
verifier!!! So I've decided to implement a CachingProxyTrust that
1) can be trusted by the client without the need to issue any remote call (so 
we need a CachingProxyTrustVerifier configured on the client)
2) Will cache a verifier it obtains from its delegate

The problem with CachingProxyTrust is that it has to be used by:
a) a Module
b) a service proxy
That's why we need OverrideProxy - it is returned from ModuleExporter to the 
service so that the service is unaware of the CachingProxyTrust but still can 
use it to obtain its verifier. To trust OverrideProxy the client has to have 
OverrideProxyVerifier configured locally.



Added:
    incubator/river/jtsk/skunk/river-modules/etc/
    incubator/river/jtsk/skunk/river-modules/etc/header.txt   (with props)
    incubator/river/jtsk/skunk/river-modules/jsk-module-platform/
    incubator/river/jtsk/skunk/river-modules/jsk-module-platform/pom.xml   (with props)
    incubator/river/jtsk/skunk/river-modules/jsk-module-platform/src/
    incubator/river/jtsk/skunk/river-modules/jsk-module-platform/src/main/
    incubator/river/jtsk/skunk/river-modules/jsk-module-platform/src/main/java/
    incubator/river/jtsk/skunk/river-modules/jsk-module-platform/src/main/java/net/
    incubator/river/jtsk/skunk/river-modules/jsk-module-platform/src/main/java/net/jini/
    incubator/river/jtsk/skunk/river-modules/jsk-module-platform/src/main/java/net/jini/io/
    incubator/river/jtsk/skunk/river-modules/jsk-module-platform/src/main/java/net/jini/io/MarshalInputStream.java   (with props)
    incubator/river/jtsk/skunk/river-modules/jsk-module-platform/src/main/java/net/jini/io/MarshalOutputStream.java   (with props)
    incubator/river/jtsk/skunk/river-modules/jsk-module-platform/src/main/java/net/jini/io/MarshalledInstance.java   (with props)
    incubator/river/jtsk/skunk/river-modules/jsk-module-platform/src/main/java/net/jini/loader/
    incubator/river/jtsk/skunk/river-modules/jsk-module-platform/src/main/java/net/jini/loader/ClassLoading.java   (with props)
    incubator/river/jtsk/skunk/river-modules/nb-configuration.xml   (with props)
    incubator/river/jtsk/skunk/river-modules/pom.xml   (with props)
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/pom.xml   (with props)
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/jeri/
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/jeri/io/
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/jeri/io/DefaultAnnotationReader.java   (with props)
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/jeri/io/DefaultAnnotationWriter.java   (with props)
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/jeri/io/ExtensibleMarshalInputStream.java   (with props)
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/jeri/io/ExtensibleMarshalOutputStream.java   (with props)
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/jeri/io/MaxDepthAnnotationReader.java   (with props)
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/jeri/io/ModuleAnnotatedInputStream.java   (with props)
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/jeri/io/ModuleAnnotatedOutputStream.java   (with props)
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/jeri/io/ModuleILFactory.java   (with props)
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/jeri/io/ModuleInvocationHandler.java   (with props)
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/jeri/io/ModuleInvocationHandlerTrustVerifier.java   (with props)
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/jeri/io/NullAnnotationReader.java   (with props)
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/jeri/io/StreamDataMarker.java   (with props)
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/loader/
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/loader/AbstractRmiModule.java   (with props)
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/loader/DefaultModuleVerifier.java   (with props)
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/loader/DefaultRmiModule.java   (with props)
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/loader/DelegatedModuleTrustVerifier.java   (with props)
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/loader/Module.java   (with props)
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/loader/ModuleBasicJeriTrustVerifier.java   (with props)
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/loader/ModuleClassLoader.java   (with props)
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/loader/ModuleClassProvider.java   (with props)
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/loader/ModuleExporter.java   (with props)
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/loader/ModuleResolver.java   (with props)
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/loader/ModuleTrustILFactory.java   (with props)
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/loader/PreferredRmiModule.java   (with props)
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/loader/ProxyTrustModule.java   (with props)
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/loader/RMIClassLoaderSpiImpl.java   (with props)
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/loader/SignedRmiModule.java   (with props)
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/loader/SignedRmiModuleVerifier.java   (with props)
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/loader/SuppressModuleTrustDelegationPermission.java   (with props)
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/resolve/
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/resolve/AnnotationProvider.java   (with props)
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/resolve/AnnotationReader.java   (with props)
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/resolve/AnnotationResolver.java   (with props)
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/resolve/AnnotationWriter.java   (with props)
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/url/
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/url/rmi/
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/url/rmi/CachedResource.java   (with props)
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/url/rmi/Handler.java   (with props)
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/url/rmi/MdCheckResource.java   (with props)
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/url/rmi/MdInputStream.java   (with props)
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/url/rmi/Resource.java   (with props)
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/url/rmi/ResourceServer.java   (with props)
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/url/rmi/RmiResource.java   (with props)
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/url/rmi/UrlResource.java   (with props)
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/util/
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/util/lang/
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/util/lang/Ensure.java   (with props)
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/util/security/
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/util/security/local/
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/util/security/local/Actions.java   (with props)
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/util/security/proxy/
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/util/security/proxy/AbstractDelegateProxyTrust.java   (with props)
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/util/security/proxy/AbstractDelegateProxyTrustVerifier.java   (with props)
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/util/security/proxy/AbstractDynamicProxyVerifier.java   (with props)
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/util/security/proxy/ArrayProxyTrustIterator.java   (with props)
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/util/security/proxy/CachingProxyTrust.java   (with props)
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/util/security/proxy/CachingProxyTrustCollection.java   (with props)
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/util/security/proxy/CachingProxyTrustVerifier.java   (with props)
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/util/security/proxy/ContextWrapperVerifier.java   (with props)
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/util/security/proxy/LazyCompositeVerifier.java   (with props)
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/util/security/proxy/OverrideProxy.java   (with props)
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/util/security/proxy/OverrideProxyVerifier.java   (with props)
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/util/security/proxy/ProxyTrustOverrideVerifier.java   (with props)
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/resources/
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/resources/META-INF/
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/resources/META-INF/services/
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/resources/META-INF/services/java.rmi.server.RMIClassLoaderSpi
    incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/resources/META-INF/services/net.jini.security.TrustVerifier

Added: incubator/river/jtsk/skunk/river-modules/etc/header.txt
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/river-modules/etc/header.txt?rev=1031510&view=auto
==============================================================================
--- incubator/river/jtsk/skunk/river-modules/etc/header.txt (added)
+++ incubator/river/jtsk/skunk/river-modules/etc/header.txt Fri Nov  5 11:05:39 2010
@@ -0,0 +1,15 @@
+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.

Propchange: incubator/river/jtsk/skunk/river-modules/etc/header.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/river/jtsk/skunk/river-modules/jsk-module-platform/pom.xml
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/river-modules/jsk-module-platform/pom.xml?rev=1031510&view=auto
==============================================================================
--- incubator/river/jtsk/skunk/river-modules/jsk-module-platform/pom.xml (added)
+++ incubator/river/jtsk/skunk/river-modules/jsk-module-platform/pom.xml Fri Nov  5 11:05:39 2010
@@ -0,0 +1,43 @@
+<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.apache.river.modules</groupId>
+    <artifactId>river-modules</artifactId>
+    <version>1.0.0-SNAPSHOT</version>
+  </parent>
+  <groupId>org.apache.river.modules</groupId>
+  <artifactId>jsk-module-platform</artifactId>
+  <packaging>jar</packaging>
+  <version>1.0.0-SNAPSHOT</version>
+  <name>jsk-module-platform</name>
+  <url>http://maven.apache.org</url>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <version>2.0.2</version>
+        <configuration>
+          <source>1.6</source>
+          <target>1.6</target>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+  <dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.1</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.river.modules</groupId>
+      <artifactId>secure-marshall-stream</artifactId>
+      <version>1.0.0-SNAPSHOT</version>
+      <scope>provided</scope>
+    </dependency>
+  </dependencies>
+</project>
+

Propchange: incubator/river/jtsk/skunk/river-modules/jsk-module-platform/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/river/jtsk/skunk/river-modules/jsk-module-platform/src/main/java/net/jini/io/MarshalInputStream.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/river-modules/jsk-module-platform/src/main/java/net/jini/io/MarshalInputStream.java?rev=1031510&view=auto
==============================================================================
--- incubator/river/jtsk/skunk/river-modules/jsk-module-platform/src/main/java/net/jini/io/MarshalInputStream.java (added)
+++ incubator/river/jtsk/skunk/river-modules/jsk-module-platform/src/main/java/net/jini/io/MarshalInputStream.java Fri Nov  5 11:05:39 2010
@@ -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 net.jini.io;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Collection;
+import org.apache.river.modules.jeri.io.ModuleAnnotatedInputStream;
+import org.apache.river.modules.loader.Module;
+import org.apache.river.modules.resolve.AnnotationReader;
+
+/**
+ * @author mkleczek
+ */
+public class MarshalInputStream extends ModuleAnnotatedInputStream {
+
+    public MarshalInputStream(InputStream is, ClassLoader defaultLoader, boolean verifyCodebaseIntegrity, ClassLoader verifierLoader, Collection<?> ctx, AnnotationReader<Module> annotationReader) throws IOException {
+        super(is, defaultLoader, verifyCodebaseIntegrity, verifierLoader, ctx, annotationReader);
+    }
+    public MarshalInputStream(InputStream is, ClassLoader defaultLoader, boolean verifyCodebaseIntegrity, ClassLoader verifierLoader, Collection<?> ctx) throws IOException {
+        super(is, defaultLoader, verifyCodebaseIntegrity, verifierLoader, ctx);
+    }
+
+    public void useCodebaseAnnotations() {
+        
+    }
+
+}

Propchange: incubator/river/jtsk/skunk/river-modules/jsk-module-platform/src/main/java/net/jini/io/MarshalInputStream.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/river/jtsk/skunk/river-modules/jsk-module-platform/src/main/java/net/jini/io/MarshalOutputStream.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/river-modules/jsk-module-platform/src/main/java/net/jini/io/MarshalOutputStream.java?rev=1031510&view=auto
==============================================================================
--- incubator/river/jtsk/skunk/river-modules/jsk-module-platform/src/main/java/net/jini/io/MarshalOutputStream.java (added)
+++ incubator/river/jtsk/skunk/river-modules/jsk-module-platform/src/main/java/net/jini/io/MarshalOutputStream.java Fri Nov  5 11:05:39 2010
@@ -0,0 +1,41 @@
+/**
+ * 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 net.jini.io;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Collection;
+import org.apache.river.modules.jeri.io.ModuleAnnotatedOutputStream;
+import org.apache.river.modules.loader.Module;
+import org.apache.river.modules.resolve.AnnotationWriter;
+
+/**
+ * @author mkleczek
+ */
+public class MarshalOutputStream extends ModuleAnnotatedOutputStream {
+
+    public MarshalOutputStream(OutputStream os, Collection<?> ctx, AnnotationWriter<Module> annotationWriter) throws IOException {
+        super(os, ctx, annotationWriter);
+    }
+
+    public MarshalOutputStream(OutputStream os, Collection<?> ctx) throws IOException {
+        super(os, ctx);
+    }
+
+}

Propchange: incubator/river/jtsk/skunk/river-modules/jsk-module-platform/src/main/java/net/jini/io/MarshalOutputStream.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/river/jtsk/skunk/river-modules/jsk-module-platform/src/main/java/net/jini/io/MarshalledInstance.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/river-modules/jsk-module-platform/src/main/java/net/jini/io/MarshalledInstance.java?rev=1031510&view=auto
==============================================================================
--- incubator/river/jtsk/skunk/river-modules/jsk-module-platform/src/main/java/net/jini/io/MarshalledInstance.java (added)
+++ incubator/river/jtsk/skunk/river-modules/jsk-module-platform/src/main/java/net/jini/io/MarshalledInstance.java Fri Nov  5 11:05:39 2010
@@ -0,0 +1,558 @@
+/**
+ * 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 net.jini.io;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InvalidObjectException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.ObjectStreamClass;
+import java.io.ObjectStreamException;
+import java.io.Serializable;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import net.jini.io.context.IntegrityEnforcement;
+import org.apache.river.modules.jeri.io.DefaultAnnotationReader;
+import org.apache.river.modules.jeri.io.DefaultAnnotationWriter;
+import org.apache.river.modules.jeri.io.NullAnnotationReader;
+import org.apache.river.modules.loader.Module;
+
+/*
+ * Implementation note: This class uses the helper class
+ * MarshalledObject that is in this package. To avoid confusion
+ * with java.rmi.MarshalledObject the fully qualified class names
+ * are used for both classes.
+ */
+
+/**
+ * A <code>MarshalledInstance</code> contains an object in serialized
+ * form. The contained object can be deserialized on demand when
+ * explicitly requested. This allows an object to be sent from one VM
+ * to another in a way that allows the receiver to control when and if
+ * the object is deserialized.
+ * <p>
+ * The contained object is specified at construction time and can
+ * either be provided in unserialized or serialized form. If provided
+ * in unserialized form it will be serialized during construction
+ * with the serialization semantics defined by
+ * <code>MarshalOutputStream</code>. In particular, classes are annotated
+ * with a codebase URL from which the class can be loaded (if available).
+ * <p>
+ * If the <code>MarshalledInstance</code> needs to deserialize the
+ * contained object then the contained object will be deserialized with the
+ * deserialization semantics defined by <code>MarshalInputStream</code>.
+ * In particular, the codebase annotations associated with the contained
+ * object may be used to load classes referenced by the contained object.
+ * <p>
+ * <code>MarshalledInstance</code> provides functionality similar to
+ * <code>java.rmi.MarshalledObject</code>, but additionally provides
+ * for the verification of codebase integrity. Unlike
+ * <code>java.rmi.MarshalledObject</code>, it does not perform remote
+ * object-to-stub replacement.
+ *
+ * @author Sun Microsystems, Inc.
+ * @since 2.0
+ */
+public class MarshalledInstance implements Serializable {
+
+    /**
+     * @serial Bytes of serialized representation.  If <code>objBytes</code> is
+     * <code>null</code> then the object marshalled was a <code>null</code>
+     * reference.
+     */
+    private byte[] objBytes = null;
+
+    /**
+     * @serial Bytes of location annotations, which are ignored by
+     * <code>equals</code>.  If <code>locBytes</code> is null, there were no
+     * non-<code>null</code> annotations during marshalling.
+     */
+    private byte[] locBytes = null;
+
+    /**
+     * @serial Stored hash code of contained object.
+     *
+     * @see #hashCode
+     */
+    private int hash;
+
+    static final long serialVersionUID = -5187033771082433496L;
+
+    /**
+     * Creates a new <code>MarshalledInstance</code> that contains the
+     * marshalled representation of the current state of the supplied
+     * object. The object is serialized with the semantics defined by
+     * <code>MarshalOutputStream</code>. The output stream used to marshal the
+     * object implements {@link ObjectStreamContext} and returns an empty
+     * collection from its {@link ObjectStreamContext#getObjectStreamContext
+     * getObjectStreamContext} method.
+     *
+     * @param obj The Object to be contained in the new
+     *          <code>MarshalledInstance</code>
+     * @throws IOException if the object cannot be serialized
+     */
+    public MarshalledInstance(Object obj) throws IOException {
+	this(obj, Collections.EMPTY_SET);
+    }
+
+    /**
+     * Creates a new <code>MarshalledInstance</code> that contains the
+     * marshalled representation of the current state of the supplied
+     * object. The object is serialized with the semantics defined by
+     * <code>MarshalOutputStream</code>. The output stream used to marshal the
+     * object implements {@link ObjectStreamContext} and returns the given
+     * collection from its {@link ObjectStreamContext#getObjectStreamContext
+     * getObjectStreamContext} method.
+     *
+     * @param obj The Object to be contained in the new
+     *          <code>MarshalledInstance</code>
+     * @param context the collection of context information objects
+     * @throws IOException if the object cannot be serialized
+     * @throws NullPointerException if <code>context</code> is <code>null</code>
+     */
+    public MarshalledInstance(Object obj, Collection context)
+	throws IOException
+    {
+	if (context == null)
+	    throw new NullPointerException();
+
+	if (obj == null) {
+	    hash = 13;		// null hash for java.rmi.MarshalledObject
+	    return;
+	}
+	ByteArrayOutputStream bout = new ByteArrayOutputStream();
+	ByteArrayOutputStream lout = new ByteArrayOutputStream();
+        MarshalOutputStream annotationOutputStream = new MarshalOutputStream(lout, context);
+        MarshalledInstanceAnnotationWriter<Module> annotationWriter = new MarshalledInstanceAnnotationWriter<Module>(annotationOutputStream);
+	MarshalOutputStream out =
+			new MarshalOutputStream(bout, context, annotationWriter);
+	out.writeObject(obj);
+	out.flush();
+        annotationOutputStream.flush();
+	objBytes = bout.toByteArray();
+	// locBytes is null if no annotations
+	locBytes = (annotationWriter.hadAnnotations ? lout.toByteArray() : null);
+
+	// Calculate hash from the marshalled representation of object
+	// so the hashcode will be comparable when sent between VMs.
+	//
+	// Note: This calculation must match the calculation in
+	//	 java.rmi.MarshalledObject since we use this hash
+	//	 in the converted MarshalledObject. The reverse is
+	//	 also true in that we use the MarshalledObject's
+	//	 hash for our hash. (see the MarshalledInstance(
+	//	 MarshalledObject) constructor)
+	//
+	int h = 0;
+	for (int i = 0; i < objBytes.length; i++) {
+	    h = 31 * h + objBytes[i];
+	}
+	hash = h;
+    }
+
+    /**
+     * Creates a new <code>MarshalledInstance</code> from an
+     * existing <code>MarshalledObject</code>. An object equivalent
+     * to the object contained in the passed <code>MarshalledObject</code>
+     * will be contained in the new <code>MarshalledInstance</code>.
+     * <p>
+     * The object contained in the passed <code>MarshalledObject</code>
+     * will not be unmarshalled as part of this call.
+     *
+     * @param mo The <code>MarshalledObject</code> that contains
+     *        the object the new <code>MarshalledInstance</code> should
+     *        contain
+     * @throws NullPointerException if <code>mo</code> is <code>null</code>
+     */
+    public MarshalledInstance(java.rmi.MarshalledObject mo) {
+
+	if (mo == null)
+	    throw new NullPointerException();
+
+	// To extract the java.rmi.MarshalledObject's fields we
+	// convert the mo into a net.jini.io.MarshalledObject.
+	// (See resolveClass() in FromMOInputStream) The private
+	// version of MarshalledObject allows access to the needed
+	// fields.
+	//
+	net.jini.io.MarshalledObject privateMO = null;
+	try {
+	    ByteArrayOutputStream baos = new ByteArrayOutputStream();
+	    ObjectOutputStream oos = new ObjectOutputStream(baos);
+	    oos.writeObject(mo);
+	    oos.flush();
+	    byte[] bytes = baos.toByteArray();
+	    ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+	    ObjectInputStream ois = new FromMOInputStream(bais);
+	    privateMO =
+		(net.jini.io.MarshalledObject)ois.readObject();
+	} catch (IOException ioe) {
+	    throw new AssertionError(ioe);
+	} catch (ClassNotFoundException cnfe) {
+	    throw new AssertionError(cnfe);
+	}
+	objBytes = privateMO.objBytes;
+	locBytes = privateMO.locBytes;
+	hash = privateMO.hash;
+    }
+
+    /**
+     * Creates a new <code>MarshalledObject</code> that will
+     * contain an object equivalent to the object contained
+     * in this <code>MarshalledInstance</code> object.
+     * <p>
+     * The object contained in this <code>MarshalledInstance</code>
+     * object will not be unmarshalled as part of this call.
+     * @return A new <code>MarshalledObject</code> which
+     *        contains an object equivalent to the object
+     *        contained in this <code>MarshalledInstance</code>
+     */
+    public java.rmi.MarshalledObject convertToMarshalledObject() {
+
+	// To create a java.rmi.MarshalledObject with previously
+	// serialized data we first create a private
+	// net.jini.io.MarshalledObject with the
+	// data and then convert it to the final object by changing
+	// the class during readObject(). (See resolveClass() in
+	// ToMOInputStream)
+	//
+	net.jini.io.MarshalledObject privateMO =
+		new net.jini.io.MarshalledObject();
+
+	privateMO.objBytes = objBytes;
+	privateMO.locBytes = locBytes;
+	privateMO.hash = hash;
+
+	java.rmi.MarshalledObject mo = null;
+	try {
+	    ByteArrayOutputStream baos = new ByteArrayOutputStream();
+	    ObjectOutputStream oos = new ObjectOutputStream(baos);
+	    oos.writeObject(privateMO);
+	    oos.flush();
+	    byte[] bytes = baos.toByteArray();
+	    ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+	    ObjectInputStream ois = new ToMOInputStream(bais);
+	    mo = (java.rmi.MarshalledObject)ois.readObject();
+	} catch (IOException ioe) {
+	    throw new AssertionError(ioe);
+	} catch (ClassNotFoundException cnfe) {
+	    throw new AssertionError(cnfe);
+	}
+	return mo;
+    }
+
+    /**
+     * Returns a new copy of the contained object. Deserialization is
+     * performed with the semantics defined by <code>MarshalInputStream</code>.
+     * The input stream used to unmarshal the object implements {@link
+     * ObjectStreamContext} and returns a collection from its {@link
+     * ObjectStreamContext#getObjectStreamContext getObjectStreamContext}
+     * method which contains a single element of type {@link
+     * IntegrityEnforcement}; the {@link IntegrityEnforcement#integrityEnforced
+     * integrityEnforced} method of this element returns the specified
+     * <code>verifyCodebaseIntegrity</code> value.
+     * <p>MarshalledInstance</code> implements this method by calling
+     * <code>{@link #get(ClassLoader, boolean, ClassLoader, Collection)
+     * get}(null, verifyCodebaseIntegrity, null, null)</code>.
+     *
+     * @param verifyCodebaseIntegrity if <code>true</code> then
+     *        codebase integrity is verified, otherwise code base
+     *        integrity is not verified
+     * @return a new copy of the contained object
+     * @throws IOException if an
+     *         <code>IOException</code> occurs while deserializing the
+     *         object from its internal representation
+     * @throws ClassNotFoundException if any classes necessary
+     *         for reconstructing the contained object can not
+     *         be found or if <code>verifyCodebaseIntegrity</code>
+     *         is <code>true</code> and the integrity of the
+     *         contained object's codebase cannot be confirmed
+     */
+    public Object get(final boolean verifyCodebaseIntegrity)
+	throws IOException, ClassNotFoundException
+    {
+	return get(null, verifyCodebaseIntegrity, null, null);
+    }
+
+    /**
+     * Returns a new copy of the contained object. Deserialization is
+     * performed with the semantics defined by <code>MarshalInputStream</code>.
+     * If <code>context</code> is not <code>null</code>
+     * the input stream used to unmarshal the object implements {@link
+     * ObjectStreamContext} and returns the given collection from its {@link
+     * ObjectStreamContext#getObjectStreamContext getObjectStreamContext}
+     * method.
+     * <p>If <code>context</code> is <code>null</code>
+     * the input stream used to unmarshal the object implements {@link
+     * ObjectStreamContext} and returns a collection from its {@link
+     * ObjectStreamContext#getObjectStreamContext getObjectStreamContext}
+     * method which contains a single element of type {@link
+     * IntegrityEnforcement}; the {@link IntegrityEnforcement#integrityEnforced
+     * integrityEnforced} method of this element returns the specified
+     * <code>verifyCodebaseIntegrity</code> value.
+     *
+     * @param defaultLoader the class loader value (possibly
+     *	      <code>null</code>) to pass as the <code>defaultLoader</code>
+     *        argument to <code>RMIClassLoader</code> methods
+     * @param verifyCodebaseIntegrity if <code>true</code> then
+     *        codebase integrity is verified, otherwise code base
+     *        integrity is not verified
+     * @param verifierLoader the class loader value (possibly
+     *        <code>null</code>) to pass to {@link
+     *        net.jini.security.Security#verifyCodebaseIntegrity
+     *        Security.verifyCodebaseIntegrity}, if
+     *        <code>verifyCodebaseIntegrity</code> is <code>true</code>
+     * @param context the collection of context information objects or
+     *        <code>null</code>
+     * @return a new copy of the contained object
+     * @throws IOException if an
+     *         <code>IOException</code> occurs while deserializing the
+     *         object from its internal representation
+     * @throws ClassNotFoundException if any classes necessary
+     *         for reconstructing the contained object can not
+     *         be found or if <code>verifyCodebaseIntegrity</code>
+     *         is <code>true</code> and the integrity of the
+     *         contained object's codebase cannot be confirmed
+     */
+    public Object get(ClassLoader defaultLoader,
+		      final boolean verifyCodebaseIntegrity,
+		      ClassLoader verifierLoader,
+		      Collection context)
+	throws IOException, ClassNotFoundException
+    {
+	if (objBytes == null)   // must have been a null object
+	    return null;
+
+	if (context == null) {
+	    context = Collections.singleton(
+			new IntegrityEnforcement() {
+			    public boolean integrityEnforced() {
+				return verifyCodebaseIntegrity;
+			    }
+			} );
+	}
+	ByteArrayInputStream bin = new ByteArrayInputStream(objBytes);
+	// locBytes is null if no annotations
+	ByteArrayInputStream lin =
+	    (locBytes == null ? null : new ByteArrayInputStream(locBytes));
+	MarshalledInstanceInputStream in =
+	    new MarshalledInstanceInputStream(bin, lin,
+					      defaultLoader,
+					      verifyCodebaseIntegrity,
+					      verifierLoader,
+					      context);
+//	in.useCodebaseAnnotations();
+	Object obj = in.readObject();
+	in.close();
+	return obj;
+    }
+
+    /**
+     * Compares this <code>MarshalledInstance</code> to another
+     * object. Returns true if and only if the argument refers to an instance
+     * of <code>MarshalledInstance</code> that contains exactly the same
+     * serialized form for its contained object as this object does and
+     * has the same class codebase annotations.
+     *
+     * @param obj the object to compare with this
+     *            <code>MarshalledInstance</code>
+     * @return <code>true</code> if the argument contains an object
+     *         with an equivalent serialized form and codebase;
+     *	       otherwise returns <code>false</code>
+     */
+    public boolean fullyEquals(Object obj) {
+	if (equals(obj)) {
+	    MarshalledInstance other = (MarshalledInstance)obj;
+	    return Arrays.equals(locBytes, other.locBytes);
+	}
+	return false;
+    }
+
+    /**
+     * Compares this <code>MarshalledInstance</code> to another
+     * object. Returns true if and only if the argument refers to an instance
+     * of <code>MarshalledInstance</code> that contains exactly the same
+     * serialized form for its contained object as this object does. The
+     * comparison ignores any class codebase annotations, so that
+     * two objects can be equivalent if they have the same serialized
+     * representation, except for the codebase of each class in the
+     * serialized representation.
+     * @param obj the object to compare with this
+     *            <code>MarshalledInstance</code>
+     * @return <code>true</code> if the argument contains an object
+     *         with an equivalent serialized form; otherwise returns
+     *         <code>false</code>
+     */
+    public boolean equals(Object obj) {
+	if (obj == this)
+	    return true;
+
+	if (obj instanceof MarshalledInstance) {
+	    MarshalledInstance other = (MarshalledInstance)obj;
+	    if (hash != other.hash)
+		return false;
+	    return Arrays.equals(objBytes, other.objBytes);
+	}
+	return false;
+    }
+
+    /**
+     * Returns the hash code for this <code>MarshalledInstance</code>.
+     * The hash code is calculated only from the serialized form
+     * of the contained object.
+     * @return The hash code for this object
+     */
+    public int hashCode() {
+	return hash;
+    }
+
+    /**
+     * Verify the case of null contained object.
+     */
+    private void readObject(ObjectInputStream in)
+	throws IOException, ClassNotFoundException
+    {
+	in.defaultReadObject();
+
+	// If contained object is null, then hash and locBytes must be
+	// proper
+	//
+	if ((objBytes == null) && ((hash != 13) || (locBytes != null)))
+	    throw new InvalidObjectException("Bad hash or annotation");
+    }
+
+    /**
+     * Protect against missing superclass.
+     */
+    private void readObjectNoData() throws ObjectStreamException {
+	throw new InvalidObjectException("Bad class hierarchy");
+    }
+
+    private static class MarshalledInstanceAnnotationWriter<T> extends DefaultAnnotationWriter<T> {
+
+        private boolean hadAnnotations;
+
+        public MarshalledInstanceAnnotationWriter(ObjectOutputStream os) {
+            super(os);
+        }
+
+        @Override
+        public void writeAnnotation(T annotation) throws IOException {
+            hadAnnotations |= (annotation != null);
+            super.writeAnnotation(annotation);
+        }
+
+    }
+    /**
+     * The counterpart to <code>MarshalledInstanceOutputStream</code>.
+     *
+     * @see MarshalledInstanceOutputStream
+     */
+    private static class MarshalledInstanceInputStream
+        extends MarshalInputStream
+    {
+	/**
+	 * The stream from which annotations will be read.  If this is
+	 * <code>null</code>, then all annotations were <code>null</code>.
+	 */
+	private ObjectInputStream locIn;
+
+	/**
+	 * Creates a new <code>MarshalledObjectInputStream</code> that
+	 * reads its objects from <code>objIn</code> and annotations
+	 * from <code>locIn</code>.  If <code>locIn</code> is
+	 * <code>null</code>, then all annotations will be
+	 * <code>null</code>.
+	 */
+	MarshalledInstanceInputStream(InputStream objIn,
+				      InputStream locIn,
+				      ClassLoader defaultLoader,
+				      boolean verifyCodebaseIntegrity,
+				      ClassLoader verifierLoader,
+				      Collection context)
+	    throws IOException
+	{
+            super(objIn,
+                    defaultLoader,
+                    verifyCodebaseIntegrity,
+                    verifierLoader,
+                    context,
+                    locIn == null ?
+                        NullAnnotationReader.<Module>getInstance() :
+                        new DefaultAnnotationReader<Module>(Module.class, new MarshalInputStream(locIn, defaultLoader, verifyCodebaseIntegrity, verifierLoader, context)));
+	}
+
+    }
+
+    /**
+     * Input stream to convert <code>java.rmi.MarshalledObject</code>
+     * into <code>net.jini.io.MarshalledObject</code>.
+     */
+    private static class FromMOInputStream extends ObjectInputStream {
+
+	public FromMOInputStream(InputStream in) throws IOException {
+	    super(in);
+	}
+
+	/**
+	 * Overrides <code>ObjectInputStream.resolveClass</code> to change
+	 * an occurence of class <code>java.rmi.MarshalledObject</code> to
+	 * class <code>net.jini.io.MarshalledObject</code>.
+	 */
+	protected Class resolveClass(ObjectStreamClass desc)
+	    throws IOException, ClassNotFoundException
+	{
+	    if (desc.getName().equals("java.rmi.MarshalledObject")) {
+		return net.jini.io.MarshalledObject.class;
+	    }
+	    return super.resolveClass(desc);
+	}
+    }
+
+    /**
+     * Input stream to convert
+     * <code>net.jini.io.MarshalledObject</code> into
+     * <code>java.rmi.MarshalledObject</code>.
+     */
+    private static class ToMOInputStream extends ObjectInputStream {
+
+	public ToMOInputStream(InputStream in) throws IOException {
+	    super(in);
+	}
+
+	/**
+	 * Overrides <code>ObjectInputStream.resolveClass</code>
+	 * to change an occurence of class
+	 * <code>net.jini.io.MarshalledObject</code>
+	 * to class <code>java.rmi.MarshalledObject</code>.
+	 */
+	protected Class resolveClass(ObjectStreamClass desc)
+	    throws IOException, ClassNotFoundException
+	{
+	    if (desc.getName().equals("net.jini.io.MarshalledObject")) {
+		return java.rmi.MarshalledObject.class;
+	    }
+	    return super.resolveClass(desc);
+	}
+    }
+}

Propchange: incubator/river/jtsk/skunk/river-modules/jsk-module-platform/src/main/java/net/jini/io/MarshalledInstance.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/river/jtsk/skunk/river-modules/jsk-module-platform/src/main/java/net/jini/loader/ClassLoading.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/river-modules/jsk-module-platform/src/main/java/net/jini/loader/ClassLoading.java?rev=1031510&view=auto
==============================================================================
--- incubator/river/jtsk/skunk/river-modules/jsk-module-platform/src/main/java/net/jini/loader/ClassLoading.java (added)
+++ incubator/river/jtsk/skunk/river-modules/jsk-module-platform/src/main/java/net/jini/loader/ClassLoading.java Fri Nov  5 11:05:39 2010
@@ -0,0 +1,52 @@
+/**
+ * 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 net.jini.loader;
+
+import java.net.MalformedURLException;
+import org.apache.river.modules.loader.ModuleClassProvider;
+
+/**
+ * @author mkleczek
+ */
+public final class ClassLoading {
+
+    private ClassLoading() {
+        throw new AssertionError();
+    }
+
+    public static Class loadClass(String codebase,
+				  String name,
+				  ClassLoader defaultLoader,
+				  boolean verifyCodebaseIntegrity,
+				  ClassLoader verifierLoader)
+	throws MalformedURLException, ClassNotFoundException {
+        return ModuleClassProvider.getInstance().loadClass(codebase, name, defaultLoader, verifyCodebaseIntegrity, verifierLoader);
+    }
+
+    public static Class loadProxyClass(String codebase,
+				       String[] interfaceNames,
+				       ClassLoader defaultLoader,
+				       boolean verifyCodebaseIntegrity,
+				       ClassLoader verifierLoader)
+	throws MalformedURLException, ClassNotFoundException
+    {
+        return ModuleClassProvider.getInstance().loadProxyClass(codebase, interfaceNames, defaultLoader, verifyCodebaseIntegrity, verifierLoader);
+    }
+
+}

Propchange: incubator/river/jtsk/skunk/river-modules/jsk-module-platform/src/main/java/net/jini/loader/ClassLoading.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/river/jtsk/skunk/river-modules/nb-configuration.xml
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/river-modules/nb-configuration.xml?rev=1031510&view=auto
==============================================================================
--- incubator/river/jtsk/skunk/river-modules/nb-configuration.xml (added)
+++ incubator/river/jtsk/skunk/river-modules/nb-configuration.xml Fri Nov  5 11:05:39 2010
@@ -0,0 +1,38 @@
+<?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.
+
+-->
+
+<project-shared-configuration>
+    <!--
+This file contains additional configuration written by modules in the NetBeans IDE.
+The configuration is intended to be shared among all the users of project and
+therefore it is assumed to be part of version control checkout.
+Without this configuration present, some functionality in the IDE may be limited or fail altogether.
+-->
+    <properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">
+        <!--
+Properties that influence various parts of the IDE, especially code formatting and the like. 
+You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up.
+That way multiple projects can share the same settings (useful for formatting rules for example).
+Any value defined here will override the pom.xml file value but is only applicable to the current project.
+-->
+        <netbeans.checkstyle.format>true</netbeans.checkstyle.format>
+    </properties>
+</project-shared-configuration>

Propchange: incubator/river/jtsk/skunk/river-modules/nb-configuration.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/river/jtsk/skunk/river-modules/pom.xml
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/river-modules/pom.xml?rev=1031510&view=auto
==============================================================================
--- incubator/river/jtsk/skunk/river-modules/pom.xml (added)
+++ incubator/river/jtsk/skunk/river-modules/pom.xml Fri Nov  5 11:05:39 2010
@@ -0,0 +1,58 @@
+<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>
+    <groupId>org.apache.river.modules</groupId>
+    <artifactId>river-modules</artifactId>
+    <version>1.0.0-SNAPSHOT</version>
+    <packaging>pom</packaging>
+    <name>river-modules</name>
+    <modules>
+        <module>secure-marshall-stream</module>
+        <module>jsk-module-platform</module>
+    </modules>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>2.0.2</version>
+                <configuration>
+                    <source>1.6</source>
+                    <target>1.6</target>
+                </configuration>
+            </plugin>
+            <plugin>
+                <inherited>false</inherited>
+                <groupId>com.mycila.maven-license-plugin</groupId>
+                <artifactId>maven-license-plugin</artifactId>
+                <configuration>
+                    <strictCheck>true</strictCheck>
+                    <header>${basedir}/etc/header.txt</header>
+                    <failIfMissing>true</failIfMissing>
+                    <aggregate>true</aggregate>
+                    <excludes>
+                        <exclude>LICENSE.txt</exclude>
+                        <exclude>**/src/test/resources/**</exclude>
+                        <exclude>**/src/test/data/**</exclude>
+                    </excludes>
+                </configuration>
+                <executions>
+                    <execution>
+                        <id>add-headers</id>
+                        <phase>process-sources</phase>
+                        <goals>
+                            <goal>format</goal>
+                        </goals>
+                    </execution>
+                    <execution>
+                        <id>check-headers</id>
+                        <phase>verify</phase>
+                        <goals>
+                            <goal>check</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+</project>

Propchange: incubator/river/jtsk/skunk/river-modules/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/pom.xml
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/pom.xml?rev=1031510&view=auto
==============================================================================
--- incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/pom.xml (added)
+++ incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/pom.xml Fri Nov  5 11:05:39 2010
@@ -0,0 +1,117 @@
+<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.apache.river.modules</groupId>
+      <artifactId>river-modules</artifactId>
+      <version>1.0.0-SNAPSHOT</version>
+    </parent>
+    <groupId>org.apache.river.modules</groupId>
+    <artifactId>secure-marshall-stream</artifactId>
+    <packaging>jar</packaging>
+    <version>1.0.0-SNAPSHOT</version>
+    <name>secure-marshall-stream</name>
+    <url>http://maven.apache.org</url>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>com.pyx4me</groupId>
+                <artifactId>proguard-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <phase>package</phase>
+                        <goals><goal>proguard</goal></goals>
+                    </execution>
+                </executions>
+                <configuration>
+                    <assembly>
+                        <inclusions>
+                            <inclusion>
+                                <groupId>com.google.guava</groupId><artifactId>guava</artifactId><library>false</library>
+                            </inclusion>
+                            <inclusion>
+                                <groupId>commons-codec</groupId><artifactId>commons-codec</artifactId><library>false</library>
+                            </inclusion>
+                        </inclusions>
+                    </assembly>
+                    <obfuscate>true</obfuscate>
+                    <options>
+                        <option>-keep public class org.apache.river.modules.** {public protected *;}</option>
+                        <option>-keep public interface org.apache.river.modules.** </option>
+                        <option>-keepclassmembers class org.apache.river.modules.loader.ProxyTrustModule {
+                            *;
+                        }</option>
+                        <option>-keepclassmembers class * implements java.io.Serializable {
+                            static final long serialVersionUID;
+                            private static final java.io.ObjectStreamField[] serialPersistentFields;
+                            private void writeObject(java.io.ObjectOutputStream);
+                            private void readObject(java.io.ObjectInputStream);
+                            java.lang.Object writeReplace();
+                            java.lang.Object readResolve();
+                            protected net.jini.security.proxytrust.ProxyTrustIterator getProxyTrustIterator();
+                        }</option>
+                        <option>-keepattributes Exceptions,InnerClasses,Signature,Deprecated,
+                        SourceFile,LineNumberTable,*Annotation*,EnclosingMethod</option>
+                        <option>-keepclassmembers class com.google.common.** {
+                            private void finalizeReferent();
+                            protected void finalizeReferent();
+                            public void finalizeReferent();
+                            void finalizeReferent();
+                            }</option>
+                        <option>-keep class com.google.common.base.internal.Finalizer</option>
+                        <option>-keep interface com.google.common.base.FinalizableReference</option>
+                        <option>-keepclassmembers class com.google.common.** {
+                            private *** startFinalizer(java.lang.Class,java.lang.Object);
+                            protected *** startFinalizer(java.lang.Class,java.lang.Object);
+                            public *** startFinalizer(java.lang.Class,java.lang.Object);
+                            *** startFinalizer(java.lang.Class,java.lang.Object);
+                            }</option>
+                    </options>
+                    <libs>
+                        <lib>${java.home}/lib/rt.jar</lib>
+                    </libs>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+    <dependencies>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>3.8.1</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>net.jini</groupId>
+            <artifactId>jsk-platform</artifactId>
+            <version>2.1</version>
+        </dependency>
+        <dependency>
+            <groupId>commons-codec</groupId>
+            <artifactId>commons-codec</artifactId>
+            <version>1.4</version>
+        </dependency>
+        <dependency>
+            <groupId>commons-io</groupId>
+            <artifactId>commons-io</artifactId>
+            <version>1.4</version>
+        </dependency>
+        <dependency>
+            <groupId>com.google.guava</groupId>
+            <artifactId>guava</artifactId>
+            <version>r06</version>
+        </dependency>
+        <dependency>
+            <groupId>com.google.code.findbugs</groupId>
+            <artifactId>jsr305</artifactId>
+            <version>1.3.9</version>
+        </dependency>
+    </dependencies>
+</project>
+
+
+
+
+
+
+

Propchange: incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/jeri/io/DefaultAnnotationReader.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/jeri/io/DefaultAnnotationReader.java?rev=1031510&view=auto
==============================================================================
--- incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/jeri/io/DefaultAnnotationReader.java (added)
+++ incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/jeri/io/DefaultAnnotationReader.java Fri Nov  5 11:05:39 2010
@@ -0,0 +1,46 @@
+/**
+ * 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.river.modules.jeri.io;
+
+import org.apache.river.modules.resolve.AnnotationReader;
+import java.io.IOException;
+import java.io.InvalidObjectException;
+import java.io.ObjectInputStream;
+
+public final class DefaultAnnotationReader<T> implements AnnotationReader<T> {
+
+    private final Class<T> annotationType;
+    private final ObjectInputStream inputStream;
+
+    public DefaultAnnotationReader(Class<T> annotationType, final ObjectInputStream is) {
+        this.annotationType = annotationType;
+        this.inputStream = is;
+    }
+
+    @Override
+    public T readAnnotation() throws IOException, ClassNotFoundException {
+        try {
+            return annotationType.cast(inputStream.readObject());
+        } catch (ClassCastException e) {
+            InvalidObjectException ioe = new InvalidObjectException("annotation not of expected type: " + annotationType.getName());
+            ioe.initCause(e);
+            throw ioe;
+        }
+    }
+}

Propchange: incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/jeri/io/DefaultAnnotationReader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/jeri/io/DefaultAnnotationWriter.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/jeri/io/DefaultAnnotationWriter.java?rev=1031510&view=auto
==============================================================================
--- incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/jeri/io/DefaultAnnotationWriter.java (added)
+++ incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/jeri/io/DefaultAnnotationWriter.java Fri Nov  5 11:05:39 2010
@@ -0,0 +1,37 @@
+/**
+ * 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.river.modules.jeri.io;
+
+import org.apache.river.modules.resolve.AnnotationWriter;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+
+public class DefaultAnnotationWriter<T> implements AnnotationWriter<T> {
+
+    private final ObjectOutputStream os;
+
+    public DefaultAnnotationWriter(final ObjectOutputStream os) {
+        this.os = os;
+    }
+
+    @Override
+    public void writeAnnotation(T annotation) throws IOException {
+        os.writeObject(annotation);
+    }
+}

Propchange: incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/jeri/io/DefaultAnnotationWriter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/jeri/io/ExtensibleMarshalInputStream.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/jeri/io/ExtensibleMarshalInputStream.java?rev=1031510&view=auto
==============================================================================
--- incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/jeri/io/ExtensibleMarshalInputStream.java (added)
+++ incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/jeri/io/ExtensibleMarshalInputStream.java Fri Nov  5 11:05:39 2010
@@ -0,0 +1,85 @@
+/**
+ * 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.river.modules.jeri.io;
+
+import org.apache.river.modules.resolve.AnnotationReader;
+import org.apache.river.modules.resolve.AnnotationResolver;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectStreamClass;
+import java.util.Collection;
+import java.util.concurrent.atomic.AtomicBoolean;
+import net.jini.io.ObjectStreamContext;
+
+/**
+ * @author mkleczek
+ */
+public class ExtensibleMarshalInputStream<T> extends ObjectInputStream implements ObjectStreamContext {
+
+    private final Collection<?> ctx;
+    private final AtomicBoolean suppressClose;
+    private final AnnotationReader<T> annotationReader;
+    private final AnnotationResolver<T> resolver;
+
+    public ExtensibleMarshalInputStream(final InputStream is, Collection<?> ctx, final Class<T> annotationType, AnnotationResolver<T> resolver, boolean suppressFirstClose) throws IOException {
+        super(is);
+        this.ctx = ctx;
+        this.annotationReader = new MaxDepthAnnotationReader<T>(new DefaultAnnotationReader(annotationType, this));
+        this.resolver = resolver;
+        this.suppressClose = new AtomicBoolean(suppressFirstClose);
+    }
+
+    public ExtensibleMarshalInputStream(final InputStream is, Collection<?> ctx, AnnotationReader<T> annotationReader, AnnotationResolver<T> resolver, boolean suppressFirstClose) throws IOException {
+        super(is);
+        this.ctx = ctx;
+        this.annotationReader = annotationReader;
+        this.resolver = resolver;
+        this.suppressClose = new AtomicBoolean(suppressFirstClose);
+    }
+
+    @Override
+    public Collection getObjectStreamContext() {
+        return ctx;
+    }
+
+    @Override
+    protected final Class resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException {
+        final String name = desc.getName();
+        return resolver.readAndResolve(annotationReader.readAnnotation(), name);
+    }
+
+    @Override
+    protected final Class<?> resolveProxyClass(String[] interfaceNames) throws IOException, ClassNotFoundException {
+        for (int i = 0; i < interfaceNames.length; i++) {
+            if (interfaceNames[i] == null) {
+                throw new NullPointerException();
+            }
+        }
+        return resolver.readAndResolveProxy(annotationReader.readAnnotation(), interfaceNames);
+
+    }
+
+    @Override
+    public final void close() throws IOException {
+        if (!suppressClose.getAndSet(false)) {
+            super.close();
+        }
+    }
+}

Propchange: incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/jeri/io/ExtensibleMarshalInputStream.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/jeri/io/ExtensibleMarshalOutputStream.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/jeri/io/ExtensibleMarshalOutputStream.java?rev=1031510&view=auto
==============================================================================
--- incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/jeri/io/ExtensibleMarshalOutputStream.java (added)
+++ incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/jeri/io/ExtensibleMarshalOutputStream.java Fri Nov  5 11:05:39 2010
@@ -0,0 +1,69 @@
+/**
+ * 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.river.modules.jeri.io;
+
+import org.apache.river.modules.resolve.AnnotationWriter;
+import org.apache.river.modules.util.lang.Ensure;
+import org.apache.river.modules.resolve.AnnotationProvider;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.io.OutputStream;
+import java.util.Collection;
+import net.jini.io.ObjectStreamContext;
+
+/**
+ * @author mkleczek
+ */
+public class ExtensibleMarshalOutputStream<T> extends ObjectOutputStream implements ObjectStreamContext {
+
+    private final Collection<?> ctx;
+
+    private final AnnotationWriter<T> annotationWriter;
+    private final AnnotationProvider<T> annotationProvider;
+
+    public ExtensibleMarshalOutputStream(final OutputStream os, final Collection<?> ctx, final AnnotationProvider<T> annotationProvider) throws IOException {
+        super(os);
+        this.ctx = Ensure.notNull(ctx, "ctx is null");
+        this.annotationWriter = new DefaultAnnotationWriter<T>(this);
+        this.annotationProvider = annotationProvider;
+    }
+
+    public ExtensibleMarshalOutputStream(final OutputStream os, final Collection<?> ctx, final AnnotationWriter<T> annotationWriter, final AnnotationProvider<T> annotationProvider) throws IOException {
+        super(os);
+        this.ctx = Ensure.notNull(ctx, "ctx is null");
+        this.annotationWriter = Ensure.notNull(annotationWriter, "annotationWriter is null");
+        this.annotationProvider = Ensure.notNull(annotationProvider, "annotationProvider is null");
+    }
+
+    @Override
+    public final Collection getObjectStreamContext() {
+        return ctx;
+    }
+
+    @Override
+    protected final void annotateClass(Class cl) throws IOException {
+        annotationWriter.writeAnnotation(annotationProvider.getExtendedAnnotation(cl));
+    }
+
+    @Override
+    protected final void annotateProxyClass(Class<?> cl) throws IOException {
+        annotationWriter.writeAnnotation(annotationProvider.getExtendedAnnotation(cl));
+    }
+
+}

Propchange: incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/jeri/io/ExtensibleMarshalOutputStream.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/jeri/io/MaxDepthAnnotationReader.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/jeri/io/MaxDepthAnnotationReader.java?rev=1031510&view=auto
==============================================================================
--- incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/jeri/io/MaxDepthAnnotationReader.java (added)
+++ incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/jeri/io/MaxDepthAnnotationReader.java Fri Nov  5 11:05:39 2010
@@ -0,0 +1,55 @@
+/**
+ * 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.river.modules.jeri.io;
+
+import org.apache.river.modules.resolve.AnnotationReader;
+import java.io.IOException;
+import java.io.InvalidObjectException;
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * @author mkleczek
+ */
+public final class MaxDepthAnnotationReader<T> implements AnnotationReader<T> {
+
+    private static final int maxModuleAnnotationDepth = Integer.MAX_VALUE - 1;
+    private final AtomicInteger moduleAnnotationDepth = new AtomicInteger(0);
+    private final AnnotationReader<T> delegate;
+
+    public MaxDepthAnnotationReader(AnnotationReader<T> delegate) {
+        this.delegate = delegate;
+    }
+
+    @Override
+    public T readAnnotation() throws IOException, ClassNotFoundException {
+        try {
+            if (moduleAnnotationDepth.incrementAndGet() > maxModuleAnnotationDepth) {
+                throw new InvalidObjectException("Someone tries a DoS!!!");
+            }
+            return delegate.readAnnotation();
+        } catch (StackOverflowError e) {
+            InvalidObjectException ioe =
+                    new InvalidObjectException("Someone tries a DoS!!!");
+            ioe.initCause(e);
+            throw ioe;
+        } finally {
+            moduleAnnotationDepth.decrementAndGet();
+        }
+    }
+}

Propchange: incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/jeri/io/MaxDepthAnnotationReader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/jeri/io/ModuleAnnotatedInputStream.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/jeri/io/ModuleAnnotatedInputStream.java?rev=1031510&view=auto
==============================================================================
--- incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/jeri/io/ModuleAnnotatedInputStream.java (added)
+++ incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/jeri/io/ModuleAnnotatedInputStream.java Fri Nov  5 11:05:39 2010
@@ -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.river.modules.jeri.io;
+
+import org.apache.river.modules.loader.Module;
+import org.apache.river.modules.loader.ModuleResolver;
+import org.apache.river.modules.resolve.AnnotationReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Collection;
+
+/**
+ * @author mkleczek
+ */
+public class ModuleAnnotatedInputStream extends ExtensibleMarshalInputStream<Module> {
+
+    public ModuleAnnotatedInputStream(InputStream is, ClassLoader defaultLoader, boolean verifyCodebaseIntegrity, ClassLoader verifierLoader, Collection<?> ctx, AnnotationReader<Module> annotationReader) throws IOException {
+        super(is, ctx, annotationReader, new ModuleResolver(defaultLoader, verifyCodebaseIntegrity, verifierLoader), false);
+    }
+    public ModuleAnnotatedInputStream(InputStream is, ClassLoader defaultLoader, boolean verifyCodebaseIntegrity, ClassLoader verifierLoader, Collection<?> ctx) throws IOException {
+        super(is, ctx, Module.class, new ModuleResolver(defaultLoader, verifyCodebaseIntegrity, verifierLoader), false);
+    }
+
+}

Propchange: incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/jeri/io/ModuleAnnotatedInputStream.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/jeri/io/ModuleAnnotatedOutputStream.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/jeri/io/ModuleAnnotatedOutputStream.java?rev=1031510&view=auto
==============================================================================
--- incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/jeri/io/ModuleAnnotatedOutputStream.java (added)
+++ incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/jeri/io/ModuleAnnotatedOutputStream.java Fri Nov  5 11:05:39 2010
@@ -0,0 +1,49 @@
+/**
+ * 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.
+ */
+
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package org.apache.river.modules.jeri.io;
+
+import org.apache.river.modules.loader.Module;
+import org.apache.river.modules.loader.ModuleClassProvider;
+import org.apache.river.modules.resolve.AnnotationWriter;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Collection;
+
+/**
+ *
+ * @author mkleczek
+ */
+public class ModuleAnnotatedOutputStream extends ExtensibleMarshalOutputStream<Module> {
+
+    public ModuleAnnotatedOutputStream(OutputStream os, Collection<?> ctx, AnnotationWriter<Module> annotationWriter) throws IOException {
+        super(os, ctx, annotationWriter, ModuleClassProvider.getInstance());
+    }
+
+    public ModuleAnnotatedOutputStream(OutputStream os, Collection<?> ctx) throws IOException {
+        super(os, ctx, ModuleClassProvider.getInstance());
+    }
+
+    
+
+}

Propchange: incubator/river/jtsk/skunk/river-modules/secure-marshall-stream/src/main/java/org/apache/river/modules/jeri/io/ModuleAnnotatedOutputStream.java
------------------------------------------------------------------------------
    svn:eol-style = native