2
* JBoss, Home of Professional Open Source
3
* Copyright 2005, JBoss Inc., and individual contributors as indicated
4
* by the @authors tag. See the copyright.txt in the distribution for a
5
* full listing of individual contributors.
7
* This is free software; you can redistribute it and/or modify it
8
* under the terms of the GNU Lesser General Public License as
9
* published by the Free Software Foundation; either version 2.1 of
10
* the License, or (at your option) any later version.
12
* This software is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
* Lesser General Public License for more details.
17
* You should have received a copy of the GNU Lesser General Public
18
* License along with this software; if not, write to the Free
19
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
23
package org.jboss.test.remoting.marshall.encrypt;
25
import javax.management.MBeanServer;
26
import org.jboss.jrunit.extensions.ServerTestCase;
27
import org.jboss.remoting.InvocationRequest;
28
import org.jboss.remoting.InvokerLocator;
29
import org.jboss.remoting.ServerInvocationHandler;
30
import org.jboss.remoting.ServerInvoker;
31
import org.jboss.remoting.callback.InvokerCallbackHandler;
32
import org.jboss.remoting.marshal.MarshalFactory;
33
import org.jboss.remoting.marshal.encryption.EncryptingMarshaller;
34
import org.jboss.remoting.marshal.encryption.EncryptingUnMarshaller;
35
import org.jboss.remoting.serialization.SerializationStreamFactory;
36
import org.jboss.remoting.transport.Connector;
40
* A EncryptingMarshallerTestServer.
42
* @author Anil.Saldhana@jboss.org
43
* @version $Revision: 1402 $
46
public class EncryptingMarshallerTestServer extends ServerTestCase
48
private static final Object lock = new Object();
52
String javauri = "socket://localhost:5300/?datatype=encrypt"
53
+ "&"+ InvokerLocator.SERIALIZATIONTYPE + "=" +
54
SerializationStreamFactory.JAVA_ENCRYPT;
55
String jbosslocatorURI = "socket://localhost:5400/?datatype=encrypt"
56
+ "&"+ InvokerLocator.SERIALIZATIONTYPE + "=" +
57
SerializationStreamFactory.JBOSS_ENCRYPT;
58
EncryptionServerThread jbossThread =
59
new EncryptionServerThread(jbosslocatorURI,2);
60
EncryptionServerThread javaThread =
61
new EncryptionServerThread(javauri,2);
63
//Start the two threads - one for JBoss Invocation and one for Java invocation
70
public static void main(String[] args)
74
new EncryptingMarshallerTestServer().setUp();
82
public class EncryptionServerThread extends Thread
84
private String locatorURI = null;
85
private int counter = 0;
86
public EncryptionServerThread(String url, int counter)
88
this.counter = counter;
89
this.locatorURI = url;
97
MarshalFactory.addMarshaller("encrypt",
98
new EncryptingMarshaller(),
99
new EncryptingUnMarshaller());
100
InvokerLocator locator = new InvokerLocator(locatorURI);
101
System.out.println("Starting remoting server with locator uri of: " + locatorURI);
102
Connector connector = new Connector();
103
connector.setInvokerLocator(locator.getLocatorURI());
105
JavaInvocationHandler invocationHandler = new JavaInvocationHandler(counter);
106
connector.addInvocationHandler("sample", invocationHandler);
126
* Noop Invocation Handler
127
* @author <a href="anil.saldhana@jboss.com">Anil Saldhana</a>
128
* @version $Revision: 1402 $
130
public abstract class AdapterInvocationHandler implements ServerInvocationHandler
132
public void addListener(InvokerCallbackHandler callbackHandler)
136
public abstract Object invoke(InvocationRequest invocation) throws Throwable;
138
public void removeListener(InvokerCallbackHandler callbackHandler)
142
public void setInvoker(ServerInvoker invoker)
146
public void setMBeanServer(MBeanServer server)
153
* Simple invocation handler implementation.
154
* This is the code that will be called with the invocation payload from the client.
156
public class JavaInvocationHandler extends AdapterInvocationHandler
158
private int counter = 0;
159
public JavaInvocationHandler(int counter)
161
this.counter = counter;
165
* called to handle a specific invocation
171
public Object invoke(InvocationRequest invocation) throws Throwable
180
Object obj = invocation.getParameter();