Package org.jboss.remoting.security

Examples of org.jboss.remoting.security.SSLSocketBuilderMBean


            if (server != null)
            {
               boolean isCorrectType = server.isInstanceOf(serverSocketFactoryObjName, SSLServerSocketFactoryServiceMBean.class.getName());
               if (isCorrectType)
               {
                  SSLSocketBuilderMBean sslSocketBuilder = (SSLSocketBuilderMBean)server.
                  getAttribute(serverSocketFactoryObjName, "SSLSocketBuilder");
                  if (sslSocketBuilder != null)
                  {
                     SSLSocketBuilder clonedSSLSocketBuilder = (SSLSocketBuilder) sslSocketBuilder.clone();
                     boolean shouldUseDefault = sslSocketBuilder.getUseSSLServerSocketFactory();
                     clonedSSLSocketBuilder.setUseSSLSocketFactory(shouldUseDefault);
                     boolean useClientMode = sslSocketBuilder.isServerSocketUseClientMode();
                     clonedSSLSocketBuilder.setSocketUseClientMode(useClientMode);
                     SSLSocketFactoryService sslSocketFactoryService = new SSLSocketFactoryService();
                     sslSocketFactoryService.setSSLSocketBuilder(clonedSSLSocketBuilder);
                     sslSocketFactoryService.start();
                     clientConfig.put(Remoting.CUSTOM_SOCKET_FACTORY, sslSocketFactoryService);
View Full Code Here


            if (server != null)
            {
               boolean isCorrectType = server.isInstanceOf(serverSocketFactoryObjName, SSLServerSocketFactoryServiceMBean.class.getName());
               if (isCorrectType)
               {
                  SSLSocketBuilderMBean sslSocketBuilder = (SSLSocketBuilderMBean)server.
                  getAttribute(serverSocketFactoryObjName, "SSLSocketBuilder");
                  if (sslSocketBuilder != null)
                  {
                     SSLSocketBuilder clonedSSLSocketBuilder = (SSLSocketBuilder) sslSocketBuilder.clone();
                     boolean shouldUseDefault = sslSocketBuilder.getUseSSLServerSocketFactory();
                     clonedSSLSocketBuilder.setUseSSLSocketFactory(shouldUseDefault);
                     boolean useClientMode = sslSocketBuilder.isServerSocketUseClientMode();
                     clonedSSLSocketBuilder.setSocketUseClientMode(useClientMode);
                     SSLSocketFactoryService sslSocketFactoryService = new SSLSocketFactoryService();
                     sslSocketFactoryService.setSSLSocketBuilder(clonedSSLSocketBuilder);
                     sslSocketFactoryService.start();
                     clientConfig.put(Remoting.CUSTOM_SOCKET_FACTORY, sslSocketFactoryService);
View Full Code Here

            if (server != null)
            {
               boolean isCorrectType = server.isInstanceOf(serverSocketFactoryObjName, SSLServerSocketFactoryServiceMBean.class.getName());
               if (isCorrectType)
               {
                  SSLSocketBuilderMBean sslSocketBuilder = (SSLSocketBuilderMBean)server.
                  getAttribute(serverSocketFactoryObjName, "SSLSocketBuilder");
                  if (sslSocketBuilder != null)
                  {
                     SSLSocketBuilder clonedSSLSocketBuilder = (SSLSocketBuilder) sslSocketBuilder.clone();
                     boolean shouldUseDefault = sslSocketBuilder.getUseSSLServerSocketFactory();
                     clonedSSLSocketBuilder.setUseSSLSocketFactory(shouldUseDefault);
                     boolean useClientMode = sslSocketBuilder.isServerSocketUseClientMode();
                     clonedSSLSocketBuilder.setSocketUseClientMode(useClientMode);
                     SSLSocketFactoryService sslSocketFactoryService = new SSLSocketFactoryService();
                     sslSocketFactoryService.setSSLSocketBuilder(clonedSSLSocketBuilder);
                     sslSocketFactoryService.start();
                     clientConfig.put(Remoting.CUSTOM_SOCKET_FACTORY, sslSocketFactoryService);
View Full Code Here

      if (hostnameVerifier == null)
      {
         if (getSocketFactory() instanceof CustomSSLSocketFactory)
         {
            CustomSSLSocketFactory sf = (CustomSSLSocketFactory) getSocketFactory();
            SSLSocketBuilderMBean builder = sf.getSSLSocketBuilder();
            if (( builder.isSocketUseClientMode() && !builder.isServerAuthMode())
             || (!builder.isSocketUseClientMode() &&  builder.isClientAuthModeNone()))
               hostnameVerifier = new AnyhostVerifier();
         }
      }

      if (hostnameVerifier != null)
View Full Code Here

            if (server != null)
            {
               boolean isCorrectType = server.isInstanceOf(serverSocketFactoryObjName, SSLServerSocketFactoryServiceMBean.class.getName());
               if (isCorrectType)
               {
                  SSLSocketBuilderMBean sslSocketBuilder = (SSLSocketBuilderMBean)server.
                  getAttribute(serverSocketFactoryObjName, "SSLSocketBuilder");
                  if (sslSocketBuilder != null)
                  {
                     SSLSocketBuilder clonedSSLSocketBuilder = (SSLSocketBuilder) sslSocketBuilder.clone();
                     boolean shouldUseDefault = sslSocketBuilder.getUseSSLServerSocketFactory();
                     clonedSSLSocketBuilder.setUseSSLSocketFactory(shouldUseDefault);
                     boolean useClientMode = sslSocketBuilder.isServerSocketUseClientMode();
                     clonedSSLSocketBuilder.setSocketUseClientMode(useClientMode);
                     SSLSocketFactoryService sslSocketFactoryService = new SSLSocketFactoryService();
                     sslSocketFactoryService.setSSLSocketBuilder(clonedSSLSocketBuilder);
                     sslSocketFactoryService.start();
                     clientConfig.put(Remoting.CUSTOM_SOCKET_FACTORY, sslSocketFactoryService);
View Full Code Here

            if (server != null)
            {
               boolean isCorrectType = server.isInstanceOf(serverSocketFactoryObjName, SSLServerSocketFactoryServiceMBean.class.getName());
               if (isCorrectType)
               {
                  SSLSocketBuilderMBean sslSocketBuilder = (SSLSocketBuilderMBean)server.
                  getAttribute(serverSocketFactoryObjName, "SSLSocketBuilder");
                  if (sslSocketBuilder != null)
                  {
                     SSLSocketBuilder clonedSSLSocketBuilder = (SSLSocketBuilder) sslSocketBuilder.clone();
                     boolean shouldUseDefault = sslSocketBuilder.getUseSSLServerSocketFactory();
                     clonedSSLSocketBuilder.setUseSSLSocketFactory(shouldUseDefault);
                     boolean useClientMode = sslSocketBuilder.isServerSocketUseClientMode();
                     clonedSSLSocketBuilder.setSocketUseClientMode(useClientMode);
                     SSLSocketFactoryService sslSocketFactoryService = new SSLSocketFactoryService();
                     sslSocketFactoryService.setSSLSocketBuilder(clonedSSLSocketBuilder);
                     sslSocketFactoryService.start();
                     clientConfig.put(Remoting.CUSTOM_SOCKET_FACTORY, sslSocketFactoryService);
View Full Code Here

            if (server != null)
            {
               boolean isCorrectType = server.isInstanceOf(serverSocketFactoryObjName, SSLServerSocketFactoryServiceMBean.class.getName());
               if (isCorrectType)
               {
                  SSLSocketBuilderMBean sslSocketBuilder = (SSLSocketBuilderMBean)server.
                  getAttribute(serverSocketFactoryObjName, "SSLSocketBuilder");
                  if (sslSocketBuilder != null)
                  {
                     SSLSocketBuilder clonedSSLSocketBuilder = (SSLSocketBuilder) sslSocketBuilder.clone();
                     boolean shouldUseDefault = sslSocketBuilder.getUseSSLServerSocketFactory();
                     clonedSSLSocketBuilder.setUseSSLSocketFactory(shouldUseDefault);
                     boolean useClientMode = sslSocketBuilder.isServerSocketUseClientMode();
                     clonedSSLSocketBuilder.setSocketUseClientMode(useClientMode);
                     SSLSocketFactoryService sslSocketFactoryService = new SSLSocketFactoryService();
                     sslSocketFactoryService.setSSLSocketBuilder(clonedSSLSocketBuilder);
                     sslSocketFactoryService.start();
                     clientConfig.put(Remoting.CUSTOM_SOCKET_FACTORY, sslSocketFactoryService);
View Full Code Here

      try
      {
         if (serverSocketFactory  instanceof CustomSSLServerSocketFactory)
         {
            CustomSSLServerSocketFactory customServerSocketFactory = (CustomSSLServerSocketFactory) serverSocketFactory;
            SSLSocketBuilderMBean builder = customServerSocketFactory.getSSLSocketBuilder();
            boolean shouldUseDefault = builder.getUseSSLServerSocketFactory();
            builder.setUseSSLSocketFactory(shouldUseDefault);
            boolean useClientMode = builder.isServerSocketUseClientMode();
            builder.setSocketUseClientMode(useClientMode);
            return builder.createSSLSocketFactory();
         }

         SSLSocketBuilder builder = new SSLSocketBuilder(configuration);
         return builder.createSSLSocketFactory();
      }
      catch(Exception e)
      {
         log.error("Error creating SSL Socket Factory for server invoker.", e);
//         throw new IOException("Error creating SSL Socket Factory.  Root cause: " + e.getMessage());
View Full Code Here

         // in config map.
         ServerInvoker serverInvoker = connector.getServerInvoker();
         ServerSocketFactory ssf = serverInvoker.getServerSocketFactory();
         assertTrue(ssf instanceof CustomSSLServerSocketFactory);
         CustomSSLServerSocketFactory csssf = (CustomSSLServerSocketFactory) ssf;
         SSLSocketBuilderMBean builder = csssf.getSSLSocketBuilder();
         assertFalse(builder.isServerSocketUseClientMode());
         assertEquals("JKS", builder.getKeyStoreType());
         File file1 = new File(keyStoreFilePath);
         File file2 = new File(builder.getKeyStore().getFile());
         assertEquals(file1, file2);


         /////////////////////////////////////
         /////    Do client side test.    ////
         /////////////////////////////////////
         HashMap cconfig = new HashMap();

         // Make Client use remote invoker.
         cconfig.put(InvokerLocator.FORCE_REMOTE, "true");

         // Put SSL parameters in config map.
         cconfig.put(SSLSocketBuilder.REMOTING_SOCKET_USE_CLIENT_MODE, "true");
         cconfig.put(SSLSocketBuilder.REMOTING_TRUST_STORE_TYPE, "JKS");
         trustStoreFilePath = getTruststoreFilePath();
         cconfig.put(SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH, trustStoreFilePath);
         cconfig.put(SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD, "unit-tests-client");

         Client client = new Client(locator, cconfig);
         client.connect();

         // Verify SocketFactory was configured according to SSL parameters
         // in config map.
         ClientInvoker clientInvoker = client.getInvoker();
         SocketFactory sf = clientInvoker.getSocketFactory();
         assertTrue(sf instanceof CustomSSLSocketFactory);
         CustomSSLSocketFactory cssf = (CustomSSLSocketFactory) sf;
         builder = cssf.getSSLSocketBuilder();
         assertTrue(builder.isSocketUseClientMode());
         assertEquals("JKS", builder.getKeyStoreType());
         file1 = new File(trustStoreFilePath);
         file2 = new File(builder.getTrustStore().getFile());
         assertEquals(file1, file2);

         //////////////////////////////////////////////
         /////     Do server side callback test.   ////
         //////////////////////////////////////////////
         Thread.sleep(500);
         freeport = PortUtil.findFreePort(getHostName());
         InvokerLocator callbackLocator = new InvokerLocator(getTransport() + "://" + getHostName() + ":" + freeport);
         HashMap config = new HashMap();
         addExtraCallbackConfig(config);
         Connector callbackConnector = new Connector(callbackLocator.getLocatorURI(), config);
         ServerSocketFactory ssf3 = getDefaultCallbackServerSocketFactory();
         callbackConnector.setServerSocketFactory(ssf3);
         callbackConnector.create();
         callbackConnector.addInvocationHandler("sample", new SampleInvocationHandler());
         callbackConnector.start();

         CallbackHandler callbackHandler = new CallbackHandler();
         String callbackHandleObject = "myCallbackHandleObject";
         client.addListener(callbackHandler, callbackLocator, callbackHandleObject);

         // Verify that callback succeeded.
         assertEquals(1, callbackHandler.getCallbacks().size());

         // Verify SocketFactory was configured according to SSL parameters in config map.
         Field field = ServerInvoker.class.getDeclaredField("handlers");
         field.setAccessible(true);
         Map handlers = (Map) field.get(serverInvoker);
         Object obj = handlers.values().iterator().next();
         SampleInvocationHandler sampleInvocationHandler = (SampleInvocationHandler) obj;
         obj = sampleInvocationHandler.getCallbackHandler();
         ServerInvokerCallbackHandler serverInvokerCallbackHandler = (ServerInvokerCallbackHandler) obj;
         field = ServerInvokerCallbackHandler.class.getDeclaredField("callBackClient");
         field.setAccessible(true);
         Client callbackClient = (Client) field.get(serverInvokerCallbackHandler);
         ClientInvoker callbackClientInvoker = callbackClient.getInvoker();
         sf = callbackClientInvoker.getSocketFactory();
         assertTrue(sf instanceof CustomSSLSocketFactory);
         cssf = (CustomSSLSocketFactory) sf;
         builder = cssf.getSSLSocketBuilder();
         assertFalse(builder.isSocketUseClientMode());
         assertEquals("JKS", builder.getKeyStoreType());
         file1 = new File(keyStoreFilePath);
         file2 = new File(builder.getKeyStore().getFile());
         assertEquals(file1, file2);

         client.disconnect();
         callbackConnector.stop();
         connector.stop();
View Full Code Here

      if (hostnameVerifier == null)
      {
         if (getSocketFactory() instanceof CustomSSLSocketFactory)
         {
            CustomSSLSocketFactory sf = (CustomSSLSocketFactory) getSocketFactory();
            SSLSocketBuilderMBean builder = sf.getSSLSocketBuilder();
            if (( builder.isSocketUseClientMode() && !builder.isServerAuthMode())
             || (!builder.isSocketUseClientMode() &&  builder.isClientAuthModeNone()))
               hostnameVerifier = new AnyhostVerifier();
         }
      }

      if (hostnameVerifier != null)
View Full Code Here

TOP

Related Classes of org.jboss.remoting.security.SSLSocketBuilderMBean

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.