geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r578566 [1/4] - in /geronimo/sandbox/gshell/trunk/gshell-whisper: ./ src/ src/main/java/org/apache/geronimo/gshell/remote/ src/main/java/org/apache/geronimo/gshell/whisper/ src/main/java/org/apache/geronimo/gshell/whisper/crypto/ src/main/j...
Date Sun, 23 Sep 2007 12:02:52 GMT
Author: jdillon
Date: Sun Sep 23 05:02:46 2007
New Revision: 578566

URL: http://svn.apache.org/viewvc?rev=578566&view=rev
Log:
Moving most of the messaging framework to a new module and doing a wee bit of refactoring to make it a little bit more generic, still needs love but it should work after a few more kicks

Added:
    geronimo/sandbox/gshell/trunk/gshell-whisper/
      - copied from r578559, geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/
    geronimo/sandbox/gshell/trunk/gshell-whisper/pom.xml
      - copied, changed from r578564, geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/pom.xml
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/
      - copied from r578564, geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/crypto/
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/crypto/CryptoContext.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/crypto/CryptoContextAware.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/crypto/CryptoContextInjectingFilter.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/crypto/package-info.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/marshal/
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/marshal/MarshalAware.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/marshal/Marshaller.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/marshal/package-info.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/CryptoAwareMessage.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/Message.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/MessageException.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/MessageHandler.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/MessageID.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/MessageSupport.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/MessageType.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/MessageVisitor.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/package-info.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/spi/
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/spi/DefaultMessageFactory.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/spi/DefaultMessageHeader.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/spi/DefaultMessageMarshaller.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/spi/DefaultMessageProvider.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/spi/LongMessageID.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/spi/MessageDecoder.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/spi/MessageEncoder.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/spi/MessageFactory.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/spi/MessageHeader.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/spi/MessageIDFactory.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/spi/MessageMarshaller.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/spi/MessageProvider.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/spi/UUIDMessageID.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/spi/UuidMessageID.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/spi/package-info.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/request/
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/request/Request.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/request/RequestEncoder.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/request/RequestException.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/request/RequestManager.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/request/RequestResponseFilter.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/request/RequestTimeoutException.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/request/Requestor.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/request/Response.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/request/package-info.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/session/
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/session/SessionAttributeBinder.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/session/ThreadPoolModel.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/session/package-info.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/ssl/
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/ssl/BogusSSLContextFactory.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/ssl/SSLContextFactory.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/ssl/package-info.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/stream/
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/stream/SessionInputStream.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/stream/SessionOutputStream.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/stream/SessionStreamFilter.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/stream/StreamFeeder.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/stream/StreamMessage.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/stream/package-info.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/ConnectException.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/Transport.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/TransportException.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/TransportExceptionMonitor.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/TransportFactory.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/TransportFactoryLocator.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/TransportServer.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/base/
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/base/BaseCommon.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/base/BaseTransport.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/base/BaseTransportFactory.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/base/BaseTransportServer.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/base/package-info.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/package-info.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/ssl/
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/ssl/SslTransport.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/ssl/SslTransportFactory.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/ssl/SslTransportServer.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/ssl/package-info.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/tcp/
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/tcp/TcpTransport.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/tcp/TcpTransportFactory.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/tcp/TcpTransportServer.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/tcp/package-info.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/vm/
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/vm/VmTransport.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/vm/VmTransportFactory.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/vm/VmTransportServer.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/transport/vm/package-info.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/resources/org/apache/geronimo/gshell/whisper/
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/resources/org/apache/geronimo/gshell/whisper/ssl/
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/resources/org/apache/geronimo/gshell/whisper/ssl/bogus.cert   (with props)
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/test/java/org/apache/geronimo/gshell/whisper/
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/test/resources/org/apache/geronimo/gshell/whisper/
Removed:
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/remote/
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/resources/org/apache/geronimo/gshell/remote/
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/test/java/org/apache/geronimo/gshell/remote/
    geronimo/sandbox/gshell/trunk/gshell-whisper/src/test/resources/org/apache/geronimo/gshell/remote/

Copied: geronimo/sandbox/gshell/trunk/gshell-whisper/pom.xml (from r578564, geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/pom.xml)
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/pom.xml?p2=geronimo/sandbox/gshell/trunk/gshell-whisper/pom.xml&p1=geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/pom.xml&r1=578564&r2=578566&rev=578566&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/pom.xml (original)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/pom.xml Sun Sep 23 05:02:46 2007
@@ -25,18 +25,69 @@
     <modelVersion>4.0.0</modelVersion>
 
     <parent>
-        <groupId>org.apache.geronimo.gshell.remote</groupId>
-        <artifactId>gshell-remote</artifactId>
+        <groupId>org.apache.geronimo.gshell</groupId>
+        <artifactId>gshell</artifactId>
         <version>1.0-alpha-1-SNAPSHOT</version>
     </parent>
 
-    <artifactId>gshell-remote-common</artifactId>
-    <name>GShell Remote :: Common</name>
+    <artifactId>gshell-whisper</artifactId>
+    <name>GShell Whisper</name>
     
     <description>
-        Common support for the GShell remote shell client and server.
+        Messaging framework muck and fluff.
     </description>
+    
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.geronimo.gshell.support</groupId>
+            <artifactId>gshell-common</artifactId>
+            <version>${version}</version>
+        </dependency>
+        
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.codehaus.plexus</groupId>
+            <artifactId>plexus-component-api</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.codehaus.plexus</groupId>
+            <artifactId>plexus-component-annotations</artifactId>
+        </dependency>
 
+        <dependency>
+            <groupId>org.codehaus.plexus</groupId>
+            <artifactId>plexus-utils</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.mina</groupId>
+            <artifactId>mina-core</artifactId>
+        </dependency>
+        
+        <dependency>
+            <groupId>org.apache.mina</groupId>
+            <artifactId>mina-filter-ssl</artifactId>
+            <version>1.1.2</version>
+        </dependency>
+        
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-simple</artifactId>
+            <scope>test</scope>
+        </dependency>
+        
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+    
     <build>
         <plugins>
             <plugin>

Added: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/crypto/CryptoContext.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/crypto/CryptoContext.java?rev=578566&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/crypto/CryptoContext.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/crypto/CryptoContext.java Sun Sep 23 05:02:46 2007
@@ -0,0 +1,134 @@
+/*
+ * 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.geronimo.gshell.whisper.crypto;
+
+import java.security.Key;
+import java.security.KeyFactory;
+import java.security.KeyPair;
+import java.security.KeyPairGenerator;
+import java.security.PublicKey;
+import java.security.spec.X509EncodedKeySpec;
+
+import javax.crypto.Cipher;
+
+import org.codehaus.plexus.component.annotations.Component;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Provides an abstraction of the crypto bits which are required for some remote shell communications.
+ *
+ * @version $Rev$ $Date$
+ */
+@Component(role=CryptoContext.class)
+public class CryptoContext
+{
+    private Logger log = LoggerFactory.getLogger(getClass());
+    
+    //
+    // TODO: See if we should use DSA or RSA for this...
+    //
+    
+    // @Configuration
+    private String transformation = "RSA";
+
+    // @Configuration
+    private String provider;
+
+    private final KeyPair keyPair;
+
+    public CryptoContext() throws Exception {
+        KeyPairGenerator keyGen = createKeyPairGenerator();
+        keyGen.initialize(1024);
+        
+        keyPair = keyGen.genKeyPair();
+    }
+
+    public PublicKey getPublicKey() {
+        return keyPair.getPublic();
+    }
+
+    private byte[] codec(final int mode, final Key key, final byte[] bytes) throws Exception {
+        assert key != null;
+        assert bytes != null;
+
+        Cipher cipher = createCipher();
+        cipher.init(mode, key);
+
+        return cipher.doFinal(bytes);
+    }
+
+    public byte[] encrypt(final Key key, final byte[] bytes) throws Exception {
+        return codec(Cipher.ENCRYPT_MODE, key, bytes);
+    }
+
+    public byte[] encrypt(final byte[] bytes) throws Exception {
+        return encrypt(keyPair.getPublic(), bytes);
+    }
+
+    public byte[] decrypt(final Key key, final byte[] bytes) throws Exception {
+        return codec(Cipher.DECRYPT_MODE, key, bytes);
+    }
+
+    public byte[] decrypt(final byte[] bytes) throws Exception {
+        return decrypt(keyPair.getPrivate(), bytes);
+    }
+
+    public PublicKey deserializePublicKey(final byte[] bytes) throws Exception {
+        assert bytes != null;
+
+        X509EncodedKeySpec spec = new X509EncodedKeySpec(bytes);
+
+        KeyFactory keyFactory = createKeyFactory();
+
+        return keyFactory.generatePublic(spec);
+    }
+    
+    //
+    // JCE Access
+    //
+
+    private KeyPairGenerator createKeyPairGenerator() throws Exception {
+        if (provider != null) {
+            return KeyPairGenerator.getInstance(transformation, provider);
+        }
+        else {
+            return KeyPairGenerator.getInstance(transformation);
+        }
+    }
+
+    private Cipher createCipher() throws Exception {
+        if (provider != null) {
+            return Cipher.getInstance(transformation, provider);
+        }
+        else {
+            return Cipher.getInstance(transformation);
+        }
+    }
+
+    private KeyFactory createKeyFactory() throws Exception {
+        if (provider != null) {
+            return KeyFactory.getInstance(transformation, provider);
+        }
+        else {
+            return KeyFactory.getInstance(transformation);
+        }
+    }
+}
\ No newline at end of file

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/crypto/CryptoContext.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/crypto/CryptoContext.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/crypto/CryptoContext.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/crypto/CryptoContextAware.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/crypto/CryptoContextAware.java?rev=578566&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/crypto/CryptoContextAware.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/crypto/CryptoContextAware.java Sun Sep 23 05:02:46 2007
@@ -0,0 +1,30 @@
+/*
+ * 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.geronimo.gshell.whisper.crypto;
+
+/**
+ * Allows manual injection of the {@link CryptoContext}.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface CryptoContextAware
+{
+    void setCryptoContext(CryptoContext ctx);
+}
\ No newline at end of file

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/crypto/CryptoContextAware.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/crypto/CryptoContextAware.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/crypto/CryptoContextAware.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/crypto/CryptoContextInjectingFilter.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/crypto/CryptoContextInjectingFilter.java?rev=578566&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/crypto/CryptoContextInjectingFilter.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/crypto/CryptoContextInjectingFilter.java Sun Sep 23 05:02:46 2007
@@ -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.geronimo.gshell.whisper.crypto;
+
+import org.apache.mina.common.IoFilterAdapter;
+import org.apache.mina.common.IoSession;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * ????
+ *
+ * @version $Rev$ $Date$
+ */
+public class CryptoContextInjectingFilter
+    extends IoFilterAdapter
+{
+    private final Logger log = LoggerFactory.getLogger(getClass());
+
+    private CryptoContext crypto;
+
+    public CryptoContextInjectingFilter(final CryptoContext crypto) {
+        this.crypto = crypto;
+    }
+
+    private void set(final Object message) {
+        try {
+            if (message instanceof CryptoContextAware) {
+                CryptoContextAware aware = (CryptoContextAware) message;
+        
+                aware.setCryptoContext(crypto);
+            }
+        }
+        catch (Exception e) {
+            log.warn("Failed to set crypto context; ignoring", e);
+        }
+    }
+
+    public void messageReceived(final NextFilter nextFilter, final IoSession session, final Object message) throws Exception {
+        set(message);
+
+        nextFilter.messageReceived(session, message);
+    }
+
+    public void filterWrite(final NextFilter nextFilter, final IoSession session, final WriteRequest writeRequest) throws Exception {
+        Object message = writeRequest.getMessage();
+
+        set(message);
+
+        nextFilter.filterWrite(session, writeRequest);
+    }
+}
\ No newline at end of file

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/crypto/CryptoContextInjectingFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/crypto/CryptoContextInjectingFilter.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/crypto/CryptoContextInjectingFilter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/crypto/package-info.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/crypto/package-info.java?rev=578566&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/crypto/package-info.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/crypto/package-info.java Sun Sep 23 05:02:46 2007
@@ -0,0 +1,25 @@
+/*
+ * 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.
+ */
+
+/**
+ * Support for encryption and decryption and related operations.
+ *
+ * @version $Rev$ $Date$
+ */
+package org.apache.geronimo.gshell.whisper.crypto;
\ No newline at end of file

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/crypto/package-info.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/crypto/package-info.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/crypto/package-info.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/marshal/MarshalAware.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/marshal/MarshalAware.java?rev=578566&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/marshal/MarshalAware.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/marshal/MarshalAware.java Sun Sep 23 05:02:46 2007
@@ -0,0 +1,34 @@
+/*
+ * 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.geronimo.gshell.whisper.marshal;
+
+import org.apache.mina.common.ByteBuffer;
+
+/**
+ * Interface for objects to implement if they wish to customize their externalization.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface MarshalAware
+{
+    void writeExternal(final ByteBuffer out) throws Exception;
+
+    void readExternal(final ByteBuffer in) throws Exception;
+}
\ No newline at end of file

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/marshal/MarshalAware.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/marshal/MarshalAware.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/marshal/MarshalAware.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/marshal/Marshaller.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/marshal/Marshaller.java?rev=578566&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/marshal/Marshaller.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/marshal/Marshaller.java Sun Sep 23 05:02:46 2007
@@ -0,0 +1,412 @@
+/*
+ * 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.geronimo.gshell.whisper.marshal;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.nio.channels.Channels;
+import java.nio.channels.WritableByteChannel;
+import java.nio.charset.CharacterCodingException;
+import java.nio.charset.Charset;
+import java.util.UUID;
+
+import org.apache.mina.common.ByteBuffer;
+
+/**
+ * Provides support for marshalling and unmarshalling objects.
+ *
+ * @version $Rev$ $Date$
+ */
+public class Marshaller
+{
+    //
+    // TODO: Should we maybe look at using XStream to handle cases when things don't marshall normally?
+    //
+    
+    private final ByteBuffer buff;
+
+    public Marshaller(final ByteBuffer buff) {
+        assert buff != null;
+
+        this.buff = buff;
+    }
+
+    public static MarshalAware unmarshal(final ByteBuffer in) throws Exception {
+        assert in != null;
+
+        //
+        // HACK: This is broke... so just use the default for now...
+        //
+
+        /*
+        Class type = (Class) readObject(in);
+
+        MarshalAware obj = (MarshalAware) type.newInstance();
+
+        obj.readExternal(in);
+        
+        return obj;
+        */
+
+        return (MarshalAware) readObject(in);
+    }
+
+    public MarshalAware unmarshal() throws Exception {
+        return unmarshal(buff);
+    }
+
+    public static void marshal(final ByteBuffer out, final MarshalAware obj) throws Exception {
+        assert out != null;
+
+        //
+        // HACK: This is broke... so just use the default for now...
+        //
+
+        /*
+        writeObject(out, obj.getClass());
+
+        obj.writeExternal(out);
+        */
+
+        writeObject(out, obj);
+    }
+
+    public void marshal(final MarshalAware obj) throws Exception {
+        marshal(buff, obj);
+    }
+
+    //
+    // Basic Marshall to Bytes
+    //
+    
+    public static byte[] marshall(final ByteBuffer out) throws IOException {
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+        WritableByteChannel channel = Channels.newChannel(baos);
+        channel.write(out.buf());
+        channel.close();
+
+        return baos.toByteArray();
+    }
+
+    public static byte[] marshall(final Object obj) throws IOException {
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        ObjectOutputStream oos = new ObjectOutputStream(baos);
+
+        oos.writeObject(obj);
+        oos.flush();
+
+        return baos.toByteArray();
+    }
+
+    //
+    // Boolean Serialization
+    //
+
+    private static final byte TRUE = 1;
+
+    private static final byte FALSE = 0;
+
+    public static boolean readBoolean(final ByteBuffer in) {
+        assert in != null;
+
+        byte b = in.get();
+
+        if (b == TRUE) {
+            return true;
+        }
+        else if (b == FALSE) {
+            return false;
+        }
+        else {
+            throw new Error();
+        }
+    }
+
+    public boolean getBoolean() {
+        return readBoolean(buff);
+    }
+
+    public static void writeBoolean(final ByteBuffer out, final boolean bool) {
+        assert out != null;
+
+        if (bool) {
+            out.put(TRUE);
+        }
+        else {
+            out.put(FALSE);
+        }
+    }
+
+    public void put(final boolean bool) {
+        writeBoolean(buff, bool);
+    }
+
+    //
+    // Byte[] Serialization
+    //
+
+    public static byte[] readBytes(final ByteBuffer in) {
+        assert in != null;
+
+        boolean isNull = readBoolean(in);
+
+        if (isNull) {
+            return null;
+        }
+
+        int len = in.getInt();
+
+        byte[] bytes = new byte[len];
+
+        in.get(bytes);
+
+        return bytes;
+    }
+
+    public byte[] getBytes() {
+        return readBytes(buff);
+    }
+
+    public static void writeBytes(final ByteBuffer out, final byte[] bytes) {
+        assert out != null;
+
+        if (bytes == null) {
+            writeBoolean(out, true);
+        }
+        else {
+            writeBoolean(out, false);
+
+            out.putInt(bytes.length);
+
+            out.put(bytes);
+        }
+    }
+
+    public void put(final byte[] bytes) {
+        writeBytes(buff, bytes);
+    }
+
+    //
+    // ByteBuffer Serialization
+    //
+
+    public static ByteBuffer readBuffer(final ByteBuffer in) {
+        assert in != null;
+
+        byte[] bytes = readBytes(in);
+
+        if (bytes == null) {
+            return null;
+        }
+
+        return ByteBuffer.wrap(bytes);
+    }
+
+    public ByteBuffer getBuffer() {
+        return readBuffer(buff);
+    }
+
+    public static void writeBuffer(final ByteBuffer out, final ByteBuffer buffer) {
+        assert out != null;
+
+        if (buffer == null) {
+            writeBytes(out, null);
+        }
+        else {
+            writeBoolean(out, false);
+
+            out.putInt(buffer.remaining());
+
+            out.put(buffer);
+        }
+    }
+
+    public void put(final ByteBuffer b) {
+        writeBuffer(buff, b);
+    }
+
+    //
+    // Object Serialization
+    //
+
+    public static Object readObject(final ByteBuffer in) throws IOException, ClassNotFoundException {
+        assert in != null;
+
+        byte[] bytes = readBytes(in);
+
+        if (bytes == null) {
+            return null;
+        }
+
+        ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+        ObjectInputStream ois = new ObjectInputStream(bais);
+
+        return ois.readObject();
+    }
+
+    public Object getObject() throws IOException, ClassNotFoundException {
+        return readObject(buff);
+    }
+
+    public static void writeObject(final ByteBuffer out, final Object obj) throws IOException {
+        assert out != null;
+
+        byte[] bytes = null;
+
+        if (obj != null) {
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+            ObjectOutputStream oos = new ObjectOutputStream(baos);
+
+            oos.writeObject(obj);
+            oos.flush();
+
+            bytes = baos.toByteArray();
+        }
+
+        writeBytes(out, bytes);
+    }
+
+    public void put(final Object obj) throws IOException {
+        writeObject(buff, obj);
+    }
+
+    //
+    // String Serialization
+    //
+
+    private static final Charset UTF_8_CHARSET = Charset.forName("UTF-8");
+
+    public static String readString(final ByteBuffer in) throws CharacterCodingException {
+        assert in != null;
+
+        int len = in.getInt();
+
+        if (len == -1) {
+            return null;
+        }
+
+        return in.getString(len, UTF_8_CHARSET.newDecoder());
+    }
+
+    public String getString() throws CharacterCodingException {
+        return readString(buff);
+    }
+
+    public static void writeString(final ByteBuffer out, final String str) throws CharacterCodingException {
+        assert out != null;
+
+        if (str == null) {
+            out.putInt(-1);
+        }
+        else {
+            int len = str.length();
+            out.putInt(len);
+
+            out.putString(str, len, UTF_8_CHARSET.newEncoder());
+        }
+    }
+
+    public void put(final String str) throws CharacterCodingException {
+        writeString(buff, str);
+    }
+
+    //
+    // UUID Serialization
+    //
+
+    public static UUID readUuid(final ByteBuffer in) {
+        assert in != null;
+
+        boolean isNull = readBoolean(in);
+
+        if (isNull) {
+            return null;
+        }
+
+        long msb = in.getLong();
+
+        long lsb = in.getLong();
+
+        return new UUID(msb, lsb);
+    }
+
+    public UUID getUuid() {
+        return readUuid(buff);
+    }
+
+    public static void writeUuid(final ByteBuffer out, final UUID uuid) {
+        assert out != null;
+
+        if (uuid == null) {
+            writeBoolean(out, true);
+        }
+        else {
+            writeBoolean(out, false);
+
+            out.putLong(uuid.getMostSignificantBits());
+
+            out.putLong(uuid.getLeastSignificantBits());
+        }
+    }
+
+    public void put(final UUID uuid) {
+        writeUuid(buff, uuid);
+    }
+
+    //
+    // Enum Serialization (adapted from Mina 2.x)
+    //
+
+    public static ByteBuffer writeEnum(final ByteBuffer out, Enum<?> e) {
+        if (e.ordinal() > Byte.MAX_VALUE) {
+            throw new IllegalArgumentException(enumConversionErrorMessage(e, "byte"));
+        }
+
+        return out.put((byte) e.ordinal());
+    }
+
+    public void put(Enum<?> e) {
+        writeEnum(buff, e);
+    }
+
+    public static <E extends Enum<E>> E readEnum(final ByteBuffer in, final Class<E> enumClass) {
+        return toEnum(enumClass, in.get());
+    }
+
+    public <E extends Enum<E>> E getEnum(final Class<E> enumClass) {
+        return readEnum(buff, enumClass);
+    }
+
+    private static <E> E toEnum(Class<E> enumClass, int i) {
+        E[] enumConstants = enumClass.getEnumConstants();
+        if (i > enumConstants.length) {
+            throw new IndexOutOfBoundsException(String.format("%d is too large of an ordinal to convert to the enum %s", i, enumClass.getName()));
+        }
+        return enumConstants[i];
+    }
+
+    private static String enumConversionErrorMessage(Enum<?> e, String type) {
+        return String.format("%s.%s has an ordinal value too large for a %s", e.getClass().getName(), e.name(), type);
+    }
+}
\ No newline at end of file

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/marshal/Marshaller.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/marshal/Marshaller.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/marshal/Marshaller.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/marshal/package-info.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/marshal/package-info.java?rev=578566&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/marshal/package-info.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/marshal/package-info.java Sun Sep 23 05:02:46 2007
@@ -0,0 +1,25 @@
+/*
+ * 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.
+ */
+
+/**
+ * Marshalling support.
+ *
+ * @version $Rev$ $Date$
+ */
+package org.apache.geronimo.gshell.whisper.marshal;
\ No newline at end of file

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/marshal/package-info.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/marshal/package-info.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/marshal/package-info.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/CryptoAwareMessage.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/CryptoAwareMessage.java?rev=578566&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/CryptoAwareMessage.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/CryptoAwareMessage.java Sun Sep 23 05:02:46 2007
@@ -0,0 +1,88 @@
+/*
+ * 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.geronimo.gshell.whisper.message;
+
+import java.security.Key;
+
+import org.apache.geronimo.gshell.whisper.crypto.CryptoContext;
+import org.apache.geronimo.gshell.whisper.crypto.CryptoContextAware;
+import org.apache.geronimo.gshell.whisper.marshal.Marshaller;
+import org.apache.mina.common.ByteBuffer;
+
+/**
+ * ???
+ *
+ * @version $Rev$ $Date$
+ */
+public class CryptoAwareMessage
+    extends MessageSupport
+    implements CryptoContextAware
+{
+    private transient CryptoContext ctx;
+
+    protected CryptoAwareMessage(final MessageType type) {
+        super(type);
+    }
+
+    public void setCryptoContext(final CryptoContext ctx) {
+        assert ctx != null;
+        
+        this.ctx = ctx;
+    }
+
+    protected CryptoContext getCryptoContext() {
+        if (ctx == null) {
+            throw new IllegalStateException("Crypto context is not set");
+        }
+        
+        return ctx;
+    }
+
+    protected String decryptString(final ByteBuffer in) throws Exception {
+        assert in != null;
+
+        byte[] bytes = Marshaller.readBytes(in);
+        
+        if (bytes == null) {
+            return null;
+        }
+
+        bytes = getCryptoContext().decrypt(bytes);
+
+        return new String(bytes);
+    }
+
+    protected void encryptString(final ByteBuffer out, final Key key, final String str) throws Exception {
+        assert out != null;
+        assert key != null;
+
+        byte[] bytes = null;
+
+        if (str != null) {
+            bytes = getCryptoContext().encrypt(key, str.getBytes());
+        }
+
+        Marshaller.writeBytes(out, bytes);
+    }
+
+    protected void encryptString(final ByteBuffer out, final String str) throws Exception {
+        encryptString(out, getCryptoContext().getPublicKey(), str);
+    }
+}
\ No newline at end of file

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/CryptoAwareMessage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/CryptoAwareMessage.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/CryptoAwareMessage.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/Message.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/Message.java?rev=578566&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/Message.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/Message.java Sun Sep 23 05:02:46 2007
@@ -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.geronimo.gshell.whisper.message;
+
+import org.apache.geronimo.gshell.whisper.marshal.MarshalAware;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.common.WriteFuture;
+
+/**
+ * ???
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Message
+    extends MarshalAware
+{
+    MessageID getId();
+
+    MessageID getCorrelationId();
+
+    void setCorrelationId(MessageID id);
+
+    MessageType getType();
+
+    long getTimestamp();
+
+    long getSequence();
+
+    void setSession(IoSession session);
+
+    IoSession getSession();
+
+    void freeze();
+
+    boolean isFrozen();
+
+    void process(IoSession session, MessageVisitor visitor) throws Exception;
+
+    WriteFuture reply(Message msg);
+}
\ No newline at end of file

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/Message.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/Message.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/Message.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/MessageException.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/MessageException.java?rev=578566&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/MessageException.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/MessageException.java Sun Sep 23 05:02:46 2007
@@ -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.geronimo.gshell.whisper.message;
+
+/**
+ * Thrown to indicate a message operation failed.
+ *
+ * @version $Rev$ $Date$
+ */
+public class MessageException
+    extends Exception
+{
+    private static final long serialVersionUID = 1;
+
+    public MessageException(final String msg, final Throwable cause) {
+        super(msg, cause);
+    }
+
+    public MessageException(final String msg) {
+        super(msg);
+    }
+
+    public MessageException(final Throwable cause) {
+        super(cause);
+    }
+
+    public MessageException() {
+        super();
+    }
+
+    public MessageException(final MessageID id) {
+        super(String.valueOf(id));
+    }
+
+    public MessageException(final Message msg) {
+        this(msg.getId());
+    }
+}
\ No newline at end of file

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/MessageException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/MessageException.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/MessageException.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/MessageHandler.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/MessageHandler.java?rev=578566&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/MessageHandler.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/MessageHandler.java Sun Sep 23 05:02:46 2007
@@ -0,0 +1,73 @@
+/*
+ * 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.geronimo.gshell.whisper.message;
+
+import org.apache.geronimo.gshell.whisper.session.SessionAttributeBinder;
+import org.apache.mina.common.IoHandlerAdapter;
+import org.apache.mina.common.IoSession;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * ???
+ *
+ * @version $Rev$ $Date$
+ */
+public class MessageHandler
+    extends IoHandlerAdapter
+{
+    protected static final SessionAttributeBinder<MessageVisitor> VISITOR = new SessionAttributeBinder<MessageVisitor>(MessageVisitor.class);
+
+    protected final Logger log = LoggerFactory.getLogger(getClass());
+
+    protected MessageVisitor visitor;
+
+    public MessageHandler(final MessageVisitor visitor) {
+        this.visitor = visitor;
+    }
+
+    @Override
+    public void sessionCreated(final IoSession session) throws Exception {
+        VISITOR.bind(session, visitor);
+    }
+
+    @Override
+    public void sessionClosed(final IoSession session) throws Exception {
+        VISITOR.unbind(session);
+    }
+
+    @Override
+    public void messageReceived(final IoSession session, final Object obj) throws Exception {
+        if (obj instanceof Message) {
+            Message msg = (Message)obj;
+
+            // Attach the session to the message (which is needed for methods like reply())
+            msg.setSession(session);
+            msg.freeze();
+            
+            // Hand over to visitor for processing
+            MessageVisitor visitor = VISITOR.lookup(session);
+            msg.process(session, visitor);
+        }
+        else {
+            throw new MessageException("Invalid message: " + obj);
+        }
+    }
+}
\ No newline at end of file

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/MessageHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/MessageHandler.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/MessageHandler.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/MessageID.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/MessageID.java?rev=578566&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/MessageID.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/MessageID.java Sun Sep 23 05:02:46 2007
@@ -0,0 +1,35 @@
+/*
+ * 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.geronimo.gshell.whisper.message;
+
+import java.io.Serializable;
+
+import org.apache.geronimo.gshell.whisper.marshal.MarshalAware;
+
+/**
+ * ???
+ *
+ * @version $Rev$ $Date$
+ */
+public interface MessageID
+    extends MarshalAware, Serializable
+{
+    // Empty
+}
\ No newline at end of file

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/MessageID.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/MessageID.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/MessageID.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/MessageSupport.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/MessageSupport.java?rev=578566&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/MessageSupport.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/MessageSupport.java Sun Sep 23 05:02:46 2007
@@ -0,0 +1,211 @@
+/*
+ * 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.geronimo.gshell.whisper.message;
+
+import org.apache.geronimo.gshell.common.tostring.ReflectionToStringBuilder;
+import org.apache.geronimo.gshell.common.tostring.ToStringBuilder;
+import org.apache.geronimo.gshell.common.tostring.ToStringStyle;
+import org.apache.geronimo.gshell.whisper.marshal.Marshaller;
+import org.apache.mina.common.ByteBuffer;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.common.WriteFuture;
+
+/**
+ * Support for {@link Message} implementations.
+ *
+ * @version $Rev$ $Date$
+ */
+public class MessageSupport
+    implements Message
+{
+    private MessageType type;
+
+    private MessageID id;
+
+    private MessageID cid;
+
+    private Long sequence;
+
+    private long timestamp;
+    
+    private transient IoSession session;
+
+    private transient boolean frozen;
+
+    protected MessageSupport(final MessageType type) {
+        assert type != null;
+        
+        this.type = type;
+
+        this.timestamp = System.currentTimeMillis();
+    }
+
+    public int hashCode() {
+        return getId().hashCode();
+    }
+    
+    public MessageType getType() {
+        return type;
+    }
+
+    public MessageID getId() {
+        return id;
+    }
+    
+    public MessageID getCorrelationId() {
+        return cid;
+    }
+
+    public void setCorrelationId(final MessageID id) {
+        ensureWritable();
+
+        if (this.cid == null) {
+            throw new IllegalStateException("Correlation ID has already been set");
+        }
+
+        this.cid = id;
+    }
+
+    public long getTimestamp() {
+        return timestamp;
+    }
+
+    public long getSequence() {
+        return sequence;
+    }
+
+    public void setSession(final IoSession session) {
+        ensureWritable();
+        
+        this.session = session;
+    }
+
+    public IoSession getSession() {
+        if (session == null) {
+            throw new IllegalStateException("Session has not been attached");
+        }
+        
+        return session;
+    }
+
+    protected void ensureWritable() {
+        if (frozen) {
+            throw new IllegalStateException("Message is frozen");
+        }
+    }
+
+    public void freeze() {
+        frozen = true;
+    }
+
+    public boolean isFrozen() {
+        return frozen;
+    }
+
+    public void process(final IoSession session, final MessageVisitor visitor) throws Exception {
+        // Non-operation
+    }
+
+    public WriteFuture reply(final Message msg) {
+        assert msg != null;
+
+        IoSession session = getSession();
+
+        msg.setCorrelationId(getId());
+        msg.freeze();
+
+        return session.write(msg);
+    }
+
+    public void readExternal(final ByteBuffer in) throws Exception {
+        assert in != null;
+
+        id = (MessageID) Marshaller.unmarshal(in);
+
+        cid = (MessageID) Marshaller.unmarshal(in);
+
+        timestamp = in.getLong();
+
+        sequence = in.getLong();
+    }
+
+    public void writeExternal(final ByteBuffer out) throws Exception {
+        assert out != null;
+
+        Marshaller.marshal(out, getId());
+
+        Marshaller.marshal(out, getCorrelationId());
+
+        out.putLong(getTimestamp());
+
+        out.putLong(getSequence());
+    }
+
+    //
+    // ToString Muck
+    //
+
+    protected static final class MessageToStringStyle
+        extends ToStringStyle
+    {
+        private static final long serialVersionUID = 1L;
+
+        public static final String[] EXCLUDED_FIELDS = {
+            "type",
+            "session",
+            "frozen"
+        };
+
+        MessageToStringStyle() {
+            this.setUseShortClassName(true);
+            this.setUseIdentityHashCode(false);
+        }
+
+        protected void appendClassName(StringBuffer buffer, Object object) {
+            if (object instanceof Message) {
+                Message msg = (Message) object;
+
+                buffer.append(msg.getType());
+            }
+            else {
+                super.appendClassName(buffer, object);
+            }
+        }
+
+        private Object readResolve() {
+            return MESSAGE_STYLE;
+        }
+    }
+
+    private static final ToStringStyle MESSAGE_STYLE = new MessageToStringStyle();
+
+    protected ToStringBuilder createToStringBuilder() {
+        return new ToStringBuilder(this, MESSAGE_STYLE)
+                .append("id", getId())
+                .append("sequence", getSequence())
+                .append("timestamp", getTimestamp());
+    }
+
+    public String toString() {
+        return new ReflectionToStringBuilder(this, MESSAGE_STYLE)
+                .setExcludeFieldNames(MessageToStringStyle.EXCLUDED_FIELDS)
+                .toString();
+    }
+}
\ No newline at end of file

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/MessageSupport.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/MessageSupport.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/MessageSupport.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/MessageType.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/MessageType.java?rev=578566&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/MessageType.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/MessageType.java Sun Sep 23 05:02:46 2007
@@ -0,0 +1,35 @@
+/*
+ * 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.geronimo.gshell.whisper.message;
+
+import java.io.Serializable;
+
+/**
+ * ???
+ *
+ * @version $Rev$ $Date$
+ */
+public interface MessageType
+    extends Serializable
+{
+    Class<? extends Message> getType();
+
+    int size();
+}
\ No newline at end of file

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/MessageType.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/MessageType.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/MessageType.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/MessageVisitor.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/MessageVisitor.java?rev=578566&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/MessageVisitor.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/MessageVisitor.java Sun Sep 23 05:02:46 2007
@@ -0,0 +1,32 @@
+/*
+ * 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.geronimo.gshell.whisper.message;
+
+import org.apache.mina.common.IoSession;
+
+/**
+ * ???
+ *
+ * @version $Rev$ $Date$
+ */
+public interface MessageVisitor
+{
+    void visit(IoSession session, Message msg) throws Exception;
+}
\ No newline at end of file

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/MessageVisitor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/MessageVisitor.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/MessageVisitor.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/package-info.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/package-info.java?rev=578566&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/package-info.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/package-info.java Sun Sep 23 05:02:46 2007
@@ -0,0 +1,25 @@
+/*
+ * 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.
+ */
+
+/**
+ * ???
+ *
+ * @version $Rev$ $Date$
+ */
+package org.apache.geronimo.gshell.whisper.message;
\ No newline at end of file

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/package-info.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/package-info.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/package-info.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/spi/DefaultMessageFactory.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/spi/DefaultMessageFactory.java?rev=578566&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/spi/DefaultMessageFactory.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/spi/DefaultMessageFactory.java Sun Sep 23 05:02:46 2007
@@ -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.geronimo.gshell.whisper.message.spi;
+
+import org.apache.geronimo.gshell.common.tostring.ReflectionToStringBuilder;
+import org.apache.geronimo.gshell.common.tostring.ToStringStyle;
+import org.apache.geronimo.gshell.whisper.message.Message;
+import org.apache.geronimo.gshell.whisper.message.MessageType;
+
+/**
+ * ???
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultMessageFactory
+    implements MessageFactory
+{
+    public Message create(final MessageType type) throws Exception {
+        assert type != null;
+
+        Class impl = type.getType();
+
+        return (Message) impl.newInstance();
+    }
+
+    public String toString() {
+        return new ReflectionToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).toString();
+    }
+}
\ No newline at end of file

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/spi/DefaultMessageFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/spi/DefaultMessageFactory.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/spi/DefaultMessageFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/spi/DefaultMessageHeader.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/spi/DefaultMessageHeader.java?rev=578566&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/spi/DefaultMessageHeader.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/spi/DefaultMessageHeader.java Sun Sep 23 05:02:46 2007
@@ -0,0 +1,145 @@
+/*
+ * 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.geronimo.gshell.whisper.message.spi;
+
+import java.util.Arrays;
+
+import org.apache.geronimo.gshell.common.tostring.ReflectionToStringBuilder;
+import org.apache.geronimo.gshell.common.tostring.ToStringStyle;
+import org.apache.mina.common.ByteBuffer;
+import org.apache.mina.filter.codec.ProtocolCodecException;
+
+/**
+ * ???
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultMessageHeader
+    implements MessageHeader
+{
+    private final byte[] magic;
+
+    private final byte version;
+
+    /*
+    private MessageType type;
+
+    private int length;
+    */
+
+    public DefaultMessageHeader(final byte[] magic, final byte version) {
+        this.magic = magic;
+        this.version = version;
+    }
+
+    public String toString() {
+        return new ReflectionToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).toString();
+    }
+    
+    public byte[] magic() {
+        return magic;
+    }
+
+    public byte version() {
+        return version;
+    }
+
+    /*
+    public MessageType type() {
+        return type;
+    }
+
+    public int length() {
+        return length;
+    }
+    */
+
+    public int size() {
+        return magic().length + /* version */ 1; //  + /* message type */ type.size() + /* length */ 4;
+    }
+
+    protected void writeMagic(final ByteBuffer out) throws Exception {
+        assert out != null;
+
+        out.put(magic());
+    }
+
+    protected byte[] readMagic(final ByteBuffer in) throws Exception {
+        assert in != null;
+
+        byte[] bytes = new byte[magic().length];
+
+        in.get(bytes);
+
+        if (!Arrays.equals(magic(), bytes)) {
+            throw new InvalidMagicException(bytes);
+        }
+
+        return bytes;
+    }
+
+    protected void writeVersion(final ByteBuffer out) throws Exception {
+        assert out != null;
+
+        out.put(version());
+    }
+
+    protected byte readVersion(final ByteBuffer in) throws Exception {
+        assert in != null;
+
+        byte version = in.get();
+
+        if (version() != version) {
+            throw new InvalidVersionException(version);
+        }
+
+        return version;
+    }
+
+    public void writeExternal(final ByteBuffer out) throws Exception {
+        writeMagic(out);
+        writeVersion(out);
+    }
+
+    public void readExternal(final ByteBuffer in) throws Exception {
+        readMagic(in);
+        readVersion(in);
+    }
+
+    public class InvalidMagicException
+        extends ProtocolCodecException
+    {
+        public InvalidMagicException(final byte[] bytes) {
+            //
+            // TODO:
+            //
+        }
+    }
+
+    public class InvalidVersionException
+        extends ProtocolCodecException
+    {
+        public InvalidVersionException(final byte version) {
+            //
+            // TODO:
+            //
+        }
+    }
+}
\ No newline at end of file

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/spi/DefaultMessageHeader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/spi/DefaultMessageHeader.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/message/spi/DefaultMessageHeader.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message