@Test public void testFilteringOfSslProperties() throws Exception { Map<String,String> configuration = new HashMap<> (); configuration.put( RABBITMQ_SERVER_IP, "localhost" ); configuration.put( RABBITMQ_SERVER_USERNAME, "guest" ); configuration.put( RABBITMQ_SERVER_PASSWORD, "guest" ); configuration.put( RABBITMQ_SSL_KEY_STORE_PASSPHRASE, "1" ); configuration.put( RABBITMQ_SSL_KEY_STORE_TYPE, "2" ); configuration.put( RABBITMQ_SSL_KEY_STORE_PATH, "3" ); configuration.put( RABBITMQ_SSL_KEY_MNGR_FACTORY, "4" ); configuration.put( RABBITMQ_SSL_TRUST_MNGR_FACTORY, "5" ); configuration.put( RABBITMQ_SSL_TRUST_STORE_PASSPHRASE, "6" ); configuration.put( RABBITMQ_SSL_TRUST_STORE_PATH, "7" ); configuration.put( RABBITMQ_SSL_TRUST_STORE_TYPE, "8" ); configuration.put( RABBITMQ_SSL_PROTOCOL, "9" ); configuration.put( RABBITMQ_USE_SSL, "true" ); final int beforeCpt = configuration.size(); RabbitMqClient client = new RabbitMqClient( null, configuration, RecipientKind.DM ); Map<String,String> retrievedConfiguration = client.getConfiguration(); Assert.assertEquals( beforeCpt + 4, retrievedConfiguration.size()); Assert.assertEquals( "", retrievedConfiguration.get( UserDataHelpers.ENCODE_FILE_CONTENT_PREFIX + RABBITMQ_SSL_KEY_STORE_PATH )); Assert.assertEquals( "", retrievedConfiguration.get( UserDataHelpers.ENCODE_FILE_CONTENT_PREFIX + RABBITMQ_SSL_TRUST_STORE_PATH )); configuration.put( RABBITMQ_SSL_AS_USER_DATA, "true" ); client = new RabbitMqClient( null, configuration, RecipientKind.DM ); retrievedConfiguration = client.getConfiguration(); Assert.assertEquals( beforeCpt + 4, retrievedConfiguration.size()); Assert.assertEquals( "", retrievedConfiguration.get( UserDataHelpers.ENCODE_FILE_CONTENT_PREFIX + RABBITMQ_SSL_KEY_STORE_PATH )); Assert.assertEquals( "", retrievedConfiguration.get( UserDataHelpers.ENCODE_FILE_CONTENT_PREFIX + RABBITMQ_SSL_TRUST_STORE_PATH )); configuration.put( RABBITMQ_SSL_AS_USER_DATA, "false" ); client = new RabbitMqClient( null, configuration, RecipientKind.DM ); retrievedConfiguration = client.getConfiguration(); Assert.assertEquals( 7, retrievedConfiguration.size()); Assert.assertEquals( "localhost", retrievedConfiguration.get( RABBITMQ_SERVER_IP )); Assert.assertEquals( "guest", retrievedConfiguration.get( RABBITMQ_SERVER_USERNAME )); Assert.assertEquals( "guest", retrievedConfiguration.get( RABBITMQ_SERVER_PASSWORD )); Assert.assertEquals( "9", retrievedConfiguration.get( RABBITMQ_SSL_PROTOCOL )); Assert.assertEquals( FACTORY_RABBITMQ, retrievedConfiguration.get( MessagingConstants.MESSAGING_TYPE_PROPERTY )); Assert.assertEquals( "false", retrievedConfiguration.get( RABBITMQ_SSL_AS_USER_DATA )); Assert.assertEquals( "true", retrievedConfiguration.get( RABBITMQ_USE_SSL )); configuration.put( RABBITMQ_SSL_AS_USER_DATA, "oops" ); client = new RabbitMqClient( null, configuration, RecipientKind.DM ); retrievedConfiguration = client.getConfiguration(); Assert.assertEquals( beforeCpt + 4, retrievedConfiguration.size()); Assert.assertEquals( "true", retrievedConfiguration.get( RABBITMQ_SSL_AS_USER_DATA )); Assert.assertEquals( "", retrievedConfiguration.get( UserDataHelpers.ENCODE_FILE_CONTENT_PREFIX + RABBITMQ_SSL_KEY_STORE_PATH )); Assert.assertEquals( "", retrievedConfiguration.get( UserDataHelpers.ENCODE_FILE_CONTENT_PREFIX + RABBITMQ_SSL_TRUST_STORE_PATH )); configuration.put( RABBITMQ_USE_SSL, "false" ); client = new RabbitMqClient( null, configuration, RecipientKind.DM ); retrievedConfiguration = client.getConfiguration(); Assert.assertEquals( 4, retrievedConfiguration.size()); Assert.assertEquals( "localhost", retrievedConfiguration.get( RABBITMQ_SERVER_IP )); Assert.assertEquals( "guest", retrievedConfiguration.get( RABBITMQ_SERVER_USERNAME )); Assert.assertEquals( "guest", retrievedConfiguration.get( RABBITMQ_SERVER_PASSWORD )); Assert.assertEquals( FACTORY_RABBITMQ, retrievedConfiguration.get( MessagingConstants.MESSAGING_TYPE_PROPERTY )); configuration.remove( RABBITMQ_USE_SSL ); client = new RabbitMqClient( null, configuration, RecipientKind.DM ); retrievedConfiguration = client.getConfiguration(); Assert.assertEquals( 4, retrievedConfiguration.size()); Assert.assertEquals( "localhost", retrievedConfiguration.get( RABBITMQ_SERVER_IP )); Assert.assertEquals( "guest", retrievedConfiguration.get( RABBITMQ_SERVER_USERNAME )); Assert.assertEquals( "guest", retrievedConfiguration.get( RABBITMQ_SERVER_PASSWORD )); Assert.assertEquals( FACTORY_RABBITMQ, retrievedConfiguration.get( MessagingConstants.MESSAGING_TYPE_PROPERTY )); }
@Override public final Map<String,String> getConfiguration() { Map<String,String> result = new HashMap<>( this.configuration ); String useSsl = this.configuration.get( RABBITMQ_USE_SSL ); List<String> allSslProperties = new ArrayList<>( Arrays.asList( RABBITMQ_SSL_KEY_STORE_PASSPHRASE, RABBITMQ_SSL_KEY_STORE_PATH, RABBITMQ_SSL_KEY_STORE_TYPE, RABBITMQ_SSL_KEY_MNGR_FACTORY, RABBITMQ_SSL_TRUST_MNGR_FACTORY, RABBITMQ_SSL_TRUST_STORE_PASSPHRASE, RABBITMQ_SSL_TRUST_STORE_PATH, RABBITMQ_SSL_TRUST_STORE_TYPE, RABBITMQ_SSL_AS_USER_DATA, RABBITMQ_SSL_PROTOCOL, RABBITMQ_USE_SSL )); if( useSsl == null || "false".equalsIgnoreCase( useSsl )) { result.keySet().removeAll( allSslProperties ); } else if( "false".equalsIgnoreCase( this.configuration.get( RABBITMQ_SSL_AS_USER_DATA ))) { allSslProperties.remove( RABBITMQ_SSL_AS_USER_DATA ); allSslProperties.remove( RABBITMQ_SSL_PROTOCOL ); allSslProperties.remove( RABBITMQ_USE_SSL ); result.keySet().removeAll( allSslProperties ); } else { result.put( RABBITMQ_SSL_AS_USER_DATA, "true" ); result.put( UserDataHelpers.ENCODE_FILE_CONTENT_PREFIX + RABBITMQ_SSL_KEY_STORE_PATH, "" ); result.put( UserDataHelpers.ENCODE_FILE_CONTENT_PREFIX + RABBITMQ_SSL_TRUST_STORE_PATH, "" ); } return result; }
RabbitMqClient implements IMessagingClient { @Override public final Map<String,String> getConfiguration() { Map<String,String> result = new HashMap<>( this.configuration ); String useSsl = this.configuration.get( RABBITMQ_USE_SSL ); List<String> allSslProperties = new ArrayList<>( Arrays.asList( RABBITMQ_SSL_KEY_STORE_PASSPHRASE, RABBITMQ_SSL_KEY_STORE_PATH, RABBITMQ_SSL_KEY_STORE_TYPE, RABBITMQ_SSL_KEY_MNGR_FACTORY, RABBITMQ_SSL_TRUST_MNGR_FACTORY, RABBITMQ_SSL_TRUST_STORE_PASSPHRASE, RABBITMQ_SSL_TRUST_STORE_PATH, RABBITMQ_SSL_TRUST_STORE_TYPE, RABBITMQ_SSL_AS_USER_DATA, RABBITMQ_SSL_PROTOCOL, RABBITMQ_USE_SSL )); if( useSsl == null || "false".equalsIgnoreCase( useSsl )) { result.keySet().removeAll( allSslProperties ); } else if( "false".equalsIgnoreCase( this.configuration.get( RABBITMQ_SSL_AS_USER_DATA ))) { allSslProperties.remove( RABBITMQ_SSL_AS_USER_DATA ); allSslProperties.remove( RABBITMQ_SSL_PROTOCOL ); allSslProperties.remove( RABBITMQ_USE_SSL ); result.keySet().removeAll( allSslProperties ); } else { result.put( RABBITMQ_SSL_AS_USER_DATA, "true" ); result.put( UserDataHelpers.ENCODE_FILE_CONTENT_PREFIX + RABBITMQ_SSL_KEY_STORE_PATH, "" ); result.put( UserDataHelpers.ENCODE_FILE_CONTENT_PREFIX + RABBITMQ_SSL_TRUST_STORE_PATH, "" ); } return result; } }
RabbitMqClient implements IMessagingClient { @Override public final Map<String,String> getConfiguration() { Map<String,String> result = new HashMap<>( this.configuration ); String useSsl = this.configuration.get( RABBITMQ_USE_SSL ); List<String> allSslProperties = new ArrayList<>( Arrays.asList( RABBITMQ_SSL_KEY_STORE_PASSPHRASE, RABBITMQ_SSL_KEY_STORE_PATH, RABBITMQ_SSL_KEY_STORE_TYPE, RABBITMQ_SSL_KEY_MNGR_FACTORY, RABBITMQ_SSL_TRUST_MNGR_FACTORY, RABBITMQ_SSL_TRUST_STORE_PASSPHRASE, RABBITMQ_SSL_TRUST_STORE_PATH, RABBITMQ_SSL_TRUST_STORE_TYPE, RABBITMQ_SSL_AS_USER_DATA, RABBITMQ_SSL_PROTOCOL, RABBITMQ_USE_SSL )); if( useSsl == null || "false".equalsIgnoreCase( useSsl )) { result.keySet().removeAll( allSslProperties ); } else if( "false".equalsIgnoreCase( this.configuration.get( RABBITMQ_SSL_AS_USER_DATA ))) { allSslProperties.remove( RABBITMQ_SSL_AS_USER_DATA ); allSslProperties.remove( RABBITMQ_SSL_PROTOCOL ); allSslProperties.remove( RABBITMQ_USE_SSL ); result.keySet().removeAll( allSslProperties ); } else { result.put( RABBITMQ_SSL_AS_USER_DATA, "true" ); result.put( UserDataHelpers.ENCODE_FILE_CONTENT_PREFIX + RABBITMQ_SSL_KEY_STORE_PATH, "" ); result.put( UserDataHelpers.ENCODE_FILE_CONTENT_PREFIX + RABBITMQ_SSL_TRUST_STORE_PATH, "" ); } return result; } protected  RabbitMqClient( ReconfigurableClient<?> reconfigurable, Map<String,String> messagingProperties ); protected  RabbitMqClient( ReconfigurableClient<?> reconfigurable, Map<String,String> messagingProperties, RecipientKind ownerKind ); }
RabbitMqClient implements IMessagingClient { @Override public final Map<String,String> getConfiguration() { Map<String,String> result = new HashMap<>( this.configuration ); String useSsl = this.configuration.get( RABBITMQ_USE_SSL ); List<String> allSslProperties = new ArrayList<>( Arrays.asList( RABBITMQ_SSL_KEY_STORE_PASSPHRASE, RABBITMQ_SSL_KEY_STORE_PATH, RABBITMQ_SSL_KEY_STORE_TYPE, RABBITMQ_SSL_KEY_MNGR_FACTORY, RABBITMQ_SSL_TRUST_MNGR_FACTORY, RABBITMQ_SSL_TRUST_STORE_PASSPHRASE, RABBITMQ_SSL_TRUST_STORE_PATH, RABBITMQ_SSL_TRUST_STORE_TYPE, RABBITMQ_SSL_AS_USER_DATA, RABBITMQ_SSL_PROTOCOL, RABBITMQ_USE_SSL )); if( useSsl == null || "false".equalsIgnoreCase( useSsl )) { result.keySet().removeAll( allSslProperties ); } else if( "false".equalsIgnoreCase( this.configuration.get( RABBITMQ_SSL_AS_USER_DATA ))) { allSslProperties.remove( RABBITMQ_SSL_AS_USER_DATA ); allSslProperties.remove( RABBITMQ_SSL_PROTOCOL ); allSslProperties.remove( RABBITMQ_USE_SSL ); result.keySet().removeAll( allSslProperties ); } else { result.put( RABBITMQ_SSL_AS_USER_DATA, "true" ); result.put( UserDataHelpers.ENCODE_FILE_CONTENT_PREFIX + RABBITMQ_SSL_KEY_STORE_PATH, "" ); result.put( UserDataHelpers.ENCODE_FILE_CONTENT_PREFIX + RABBITMQ_SSL_TRUST_STORE_PATH, "" ); } return result; } protected  RabbitMqClient( ReconfigurableClient<?> reconfigurable, Map<String,String> messagingProperties ); protected  RabbitMqClient( ReconfigurableClient<?> reconfigurable, Map<String,String> messagingProperties, RecipientKind ownerKind ); final ReconfigurableClient<?> getReconfigurableClient(); @Override final void setMessageQueue( RoboconfMessageQueue messageQueue ); @Override final synchronized boolean isConnected(); @Override final String getMessagingType(); @Override final Map<String,String> getConfiguration(); @Override void setOwnerProperties( RecipientKind ownerKind, String domain, String applicationName, String scopedInstancePath ); @Override void openConnection(); @Override void closeConnection(); @Override void deleteMessagingServerArtifacts( Application application ); @Override void publish( MessagingContext ctx, Message msg ); @Override void subscribe( MessagingContext ctx ); @Override void unsubscribe( MessagingContext ctx ); }
RabbitMqClient implements IMessagingClient { @Override public final Map<String,String> getConfiguration() { Map<String,String> result = new HashMap<>( this.configuration ); String useSsl = this.configuration.get( RABBITMQ_USE_SSL ); List<String> allSslProperties = new ArrayList<>( Arrays.asList( RABBITMQ_SSL_KEY_STORE_PASSPHRASE, RABBITMQ_SSL_KEY_STORE_PATH, RABBITMQ_SSL_KEY_STORE_TYPE, RABBITMQ_SSL_KEY_MNGR_FACTORY, RABBITMQ_SSL_TRUST_MNGR_FACTORY, RABBITMQ_SSL_TRUST_STORE_PASSPHRASE, RABBITMQ_SSL_TRUST_STORE_PATH, RABBITMQ_SSL_TRUST_STORE_TYPE, RABBITMQ_SSL_AS_USER_DATA, RABBITMQ_SSL_PROTOCOL, RABBITMQ_USE_SSL )); if( useSsl == null || "false".equalsIgnoreCase( useSsl )) { result.keySet().removeAll( allSslProperties ); } else if( "false".equalsIgnoreCase( this.configuration.get( RABBITMQ_SSL_AS_USER_DATA ))) { allSslProperties.remove( RABBITMQ_SSL_AS_USER_DATA ); allSslProperties.remove( RABBITMQ_SSL_PROTOCOL ); allSslProperties.remove( RABBITMQ_USE_SSL ); result.keySet().removeAll( allSslProperties ); } else { result.put( RABBITMQ_SSL_AS_USER_DATA, "true" ); result.put( UserDataHelpers.ENCODE_FILE_CONTENT_PREFIX + RABBITMQ_SSL_KEY_STORE_PATH, "" ); result.put( UserDataHelpers.ENCODE_FILE_CONTENT_PREFIX + RABBITMQ_SSL_TRUST_STORE_PATH, "" ); } return result; } protected  RabbitMqClient( ReconfigurableClient<?> reconfigurable, Map<String,String> messagingProperties ); protected  RabbitMqClient( ReconfigurableClient<?> reconfigurable, Map<String,String> messagingProperties, RecipientKind ownerKind ); final ReconfigurableClient<?> getReconfigurableClient(); @Override final void setMessageQueue( RoboconfMessageQueue messageQueue ); @Override final synchronized boolean isConnected(); @Override final String getMessagingType(); @Override final Map<String,String> getConfiguration(); @Override void setOwnerProperties( RecipientKind ownerKind, String domain, String applicationName, String scopedInstancePath ); @Override void openConnection(); @Override void closeConnection(); @Override void deleteMessagingServerArtifacts( Application application ); @Override void publish( MessagingContext ctx, Message msg ); @Override void subscribe( MessagingContext ctx ); @Override void unsubscribe( MessagingContext ctx );  }