[jboss-user] [Remoting] - Re: No connection possible after an illegitimate attempt

Clarich do-not-reply at jboss.com
Wed Dec 6 06:14:03 EST 2006


I don't know if this matches the previous mentioned issue or if this is an issue for its own, but I have the problem that when running two Clients using Transporters to connect to a target POJO on the server side and using SSL to do this, always the second client is handled as beeing the first client. 

I mean when the first Client is trusted by the Server, the second client is also, althogh it should not. The other way round, if the first Client is not trusted the second is not ,too, althogh it should be trusted.

here is some sample code describing my problem:

---Client code---

  | package client;
  | 
  | import java.net.MalformedURLException;
  | 
  | import org.jboss.remoting.InvokerLocator;
  | import org.jboss.remoting.security.SSLSocketBuilder;
  | import org.jboss.remoting.transporter.TransporterClient;
  | 
  | import server.HandlerInterface;
  | 
  | public class Client {
  | 	/**
  | 	 * the Object containing all information about the Server location
  | 	 */
  | 	protected InvokerLocator locator;
  | 
  | 	/**
  | 	 * Constructor - initializes the locator and sets properties
  | 	 */
  | 	public Client(String user) {
  | 		if (user == "user1") {
  | 			System.setProperty(SSLSocketBuilder.STANDARD_KEY_STORE_FILE_PATH,
  | 					"./certificates/client/user1.keystore");
  | 			System.setProperty(SSLSocketBuilder.STANDARD_KEY_STORE_PASSWORD,
  | 					"client");
  | 			System.setProperty(SSLSocketBuilder.STANDARD_TRUST_STORE_FILE_PATH,
  | 					"./certificates/client/user1.truststore");
  | 			System.setProperty(SSLSocketBuilder.STANDARD_TRUST_STORE_PASSWORD,
  | 					"client");
  | 			System.setProperty(InvokerLocator.FORCE_REMOTE, "true");
  | 		}
  | 		if (user == "user2") {
  | 			System.setProperty(SSLSocketBuilder.STANDARD_KEY_STORE_FILE_PATH,
  | 					"./certificates/client/user2.keystore");
  | 			System.setProperty(SSLSocketBuilder.STANDARD_KEY_STORE_PASSWORD,
  | 					"client");
  | 			System.setProperty(SSLSocketBuilder.STANDARD_TRUST_STORE_FILE_PATH,
  | 					"./certificates/client/user2.truststore");
  | 			System.setProperty(SSLSocketBuilder.STANDARD_TRUST_STORE_PASSWORD,
  | 					"client");
  | 			System.setProperty(InvokerLocator.FORCE_REMOTE, "true");
  | 		}
  | 		
  | 		try {
  | 			locator = new InvokerLocator("sslsocket://127.0.0.1:7070");
  | 		} catch (MalformedURLException e) {
  | 			e.printStackTrace();
  | 		}
  | 	}
  | 
  | 	/**
  | 	 * reqests the Server for an handle
  | 	 */
  | 	public void requestHandle() {
  | 		HandlerInterface handler = null;
  | 		try {
  | 			handler = (HandlerInterface) TransporterClient
  | 					.createTransporterClient(locator, HandlerInterface.class);
  | 			System.out.println("server returned: " + handler.doHandle());
  | 
  | 		} catch (Exception e) {
  | 			e.printStackTrace();
  | 		} finally {
  | 			if (handler != null) {
  | 				TransporterClient.destroyTransporterClient(handler);
  | 			}
  | 		}
  | 	}
  | 
  | 	public static void main(String[] args) {
  | 		System.out.println("starting client for claudia");
  | 		Client client = new Client("user1");// is trusted
  | 
  | 		// should print a String
  | 		client.requestHandle();
  | 
  | 		System.out.println("starting client for michael");
  | 		Client client2 = new Client("user2");// is not trusted
  | 
  | 		// should not print a String but throw an exception
  | 		client2.requestHandle();
  | 	}
  | }
  | 

---Server Code---

  | package server;
  | 
  | import java.io.IOException;
  | import java.util.HashMap;
  | import java.util.Map;
  | 
  | import org.jboss.remoting.security.SSLSocketBuilder;
  | import org.jboss.remoting.transporter.TransporterServer;
  | 
  | public class Server {
  | 
  | 	private static TransporterServer server;
  | 
  | 	/**
  | 	 * runs and starts the Server
  | 	 * 
  | 	 * @param args
  | 	 */
  | 	public static void main(String[] args) {
  | 		String locatorURL = "sslsocket://127.0.0.1:7070";
  | 
  | 		HandlerInterface handler = new Handler();
  | 		try {
  | 			Map config = getConfiguration();
  | 			server = TransporterServer.createTransporterServer(locatorURL,
  | 					handler, HandlerInterface.class.getName(), config, false);
  | 			server.start();
  | 		} catch (Exception e) {
  | 			e.printStackTrace();
  | 		}
  | 
  | 	}
  | 
  | 	/**
  | 	 * creates a ServerSocketFactory that is configured by using an
  | 	 * SSLSocketBuilder
  | 	 * 
  | 	 * @return configuration Map
  | 	 * @throws IOException
  | 	 *             if the Factory could not be created
  | 	 */
  | 	private static HashMap getConfiguration() {
  | 		HashMap<String, String> sslConfig = new HashMap<String, String>();
  | 
  | 		sslConfig.put(SSLSocketBuilder.REMOTING_KEY_STORE_FILE_PATH,
  | 				"./certificates/server/Server.keystore");
  | 		sslConfig.put(SSLSocketBuilder.REMOTING_KEY_STORE_PASSWORD, "pass");
  | 		sslConfig.put(SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH,
  | 				"./certificates/server/Server.truststore");
  | 		sslConfig.put(SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD,
  | 				"pass");
  | 		sslConfig.put(SSLSocketBuilder.REMOTING_CLIENT_AUTH_MODE,
  | 				SSLSocketBuilder.CLIENT_AUTH_MODE_NEED);
  | 		sslConfig.put("numAcceptThreads", "2");
  | 		return sslConfig;
  | 	}
  | }
  | 

---HandlerInterface (POJO) returning a String to the Client if trusted---

  | package server;
  | 
  | public interface HandlerInterface {
  | 
  | 	public abstract String doHandle();
  | 
  | }
  | 

The keystore of user1 is stored in the servers truststore, but the keystore of user2 is not

I switched around the two client in the Client.main method and got the result I described above.

Could anybody tell me why this happens? Might this be another Bug?

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3991599#3991599

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3991599



More information about the jboss-user mailing list