@Test public void testGetUpdatedConfigsForJaasUtilWithPassword(){ String jaasConfig = "org.apache.kafka.common.security.scram.ScramLoginModule required " + "username=\"user\"" + " password=\"password\";"; Map<String, Object> originalMap = ImmutableMap.of("test-key", "test-value", SaslConfigs.SASL_JAAS_CONFIG, new Password(jaasConfig)); SaslBasicAuthCredentialProvider provider = new SaslBasicAuthCredentialProvider(); Map<String, Object> updatedMap = provider.getConfigsForJaasUtil(originalMap); Assert.assertNotNull(updatedMap); Assert.assertEquals(originalMap.keySet(), updatedMap.keySet()); Assert.assertTrue(updatedMap.get(SaslConfigs.SASL_JAAS_CONFIG) instanceof Password); Assert.assertEquals(new Password(jaasConfig), updatedMap.get(SaslConfigs.SASL_JAAS_CONFIG) ); }
Map<String, Object> getConfigsForJaasUtil(Map<String, ?> configs) { Map<String, Object> updatedConfigs = new HashMap<>(configs); if (updatedConfigs.containsKey(SaslConfigs.SASL_JAAS_CONFIG)) { Object saslJaasConfig = updatedConfigs.get(SaslConfigs.SASL_JAAS_CONFIG); if (saslJaasConfig instanceof String) { updatedConfigs.put(SaslConfigs.SASL_JAAS_CONFIG, new Password((String) saslJaasConfig)); } } return updatedConfigs; }
SaslBasicAuthCredentialProvider implements BasicAuthCredentialProvider { Map<String, Object> getConfigsForJaasUtil(Map<String, ?> configs) { Map<String, Object> updatedConfigs = new HashMap<>(configs); if (updatedConfigs.containsKey(SaslConfigs.SASL_JAAS_CONFIG)) { Object saslJaasConfig = updatedConfigs.get(SaslConfigs.SASL_JAAS_CONFIG); if (saslJaasConfig instanceof String) { updatedConfigs.put(SaslConfigs.SASL_JAAS_CONFIG, new Password((String) saslJaasConfig)); } } return updatedConfigs; } }
SaslBasicAuthCredentialProvider implements BasicAuthCredentialProvider { Map<String, Object> getConfigsForJaasUtil(Map<String, ?> configs) { Map<String, Object> updatedConfigs = new HashMap<>(configs); if (updatedConfigs.containsKey(SaslConfigs.SASL_JAAS_CONFIG)) { Object saslJaasConfig = updatedConfigs.get(SaslConfigs.SASL_JAAS_CONFIG); if (saslJaasConfig instanceof String) { updatedConfigs.put(SaslConfigs.SASL_JAAS_CONFIG, new Password((String) saslJaasConfig)); } } return updatedConfigs; }  }
SaslBasicAuthCredentialProvider implements BasicAuthCredentialProvider { Map<String, Object> getConfigsForJaasUtil(Map<String, ?> configs) { Map<String, Object> updatedConfigs = new HashMap<>(configs); if (updatedConfigs.containsKey(SaslConfigs.SASL_JAAS_CONFIG)) { Object saslJaasConfig = updatedConfigs.get(SaslConfigs.SASL_JAAS_CONFIG); if (saslJaasConfig instanceof String) { updatedConfigs.put(SaslConfigs.SASL_JAAS_CONFIG, new Password((String) saslJaasConfig)); } } return updatedConfigs; }  @Override String alias(); @Override void configure(Map<String, ?> configs); @Override String getUserInfo(URL url); }
SaslBasicAuthCredentialProvider implements BasicAuthCredentialProvider { Map<String, Object> getConfigsForJaasUtil(Map<String, ?> configs) { Map<String, Object> updatedConfigs = new HashMap<>(configs); if (updatedConfigs.containsKey(SaslConfigs.SASL_JAAS_CONFIG)) { Object saslJaasConfig = updatedConfigs.get(SaslConfigs.SASL_JAAS_CONFIG); if (saslJaasConfig instanceof String) { updatedConfigs.put(SaslConfigs.SASL_JAAS_CONFIG, new Password((String) saslJaasConfig)); } } return updatedConfigs; }  @Override String alias(); @Override void configure(Map<String, ?> configs); @Override String getUserInfo(URL url);  }