@@ -12,9 +12,6 @@ public class SchemaRegistryConfigLoader {
12
12
13
13
public static final String SCHEMA_REGISTRY_URL_KEY = "SCHEMA_REGISTRY_URL" ;
14
14
public static final String SCHEMA_DIRECTORY_KEY = "SCHEMA_DIRECTORY" ;
15
- public static final String SCHEMA_REGISTRY_SASL_JAAS_USERNAME_KEY = "SCHEMA_REGISTRY_SASL_JAAS_USERNAME" ;
16
- public static final String SCHEMA_REGISTRY_SASL_JAAS_PASSWORD_KEY = "SCHEMA_REGISTRY_SASL_JAAS_PASSWORD" ;
17
- public static final String SCHEMA_REGISTRY_SASL_CONFIG_KEY = "SCHEMA_REGISTRY_SASL_CONFIG" ;
18
15
19
16
private SchemaRegistryConfigLoader () {}
20
17
@@ -26,17 +23,11 @@ public static SchemaRegistryConfig load() {
26
23
27
24
private static void setConfig (SchemaRegistryConfig .Builder builder ) {
28
25
Map <String , Object > config = new HashMap <>();
29
- AtomicReference <String > username = new AtomicReference <>();
30
- AtomicReference <String > password = new AtomicReference <>();
31
26
32
27
Map <String , String > environment = System .getenv ();
33
28
34
29
environment .forEach ((key , value ) -> {
35
- if (key .equals (SCHEMA_REGISTRY_SASL_JAAS_USERNAME_KEY )) {
36
- username .set (value );
37
- } else if (key .equals (SCHEMA_REGISTRY_SASL_JAAS_PASSWORD_KEY )) {
38
- password .set (value );
39
- } else if (key .equals (SCHEMA_REGISTRY_URL_KEY )) {
30
+ if (key .equals (SCHEMA_REGISTRY_URL_KEY )) {
40
31
config .put (SCHEMA_REGISTRY_URL_KEY , value );
41
32
} else if (key .equals (SCHEMA_DIRECTORY_KEY )) {
42
33
config .put (SCHEMA_DIRECTORY_KEY , value );
@@ -47,7 +38,6 @@ private static void setConfig(SchemaRegistryConfig.Builder builder) {
47
38
});
48
39
49
40
handleDefaultConfig (config );
50
- handleAuthentication (username , password , config );
51
41
52
42
log .info ("Schema Registry Config: {}" , config );
53
43
@@ -62,29 +52,8 @@ private static void handleDefaultConfig(Map<String, Object> config) {
62
52
config .put (SCHEMA_REGISTRY_URL_KEY , DEFAULT_URL );
63
53
}
64
54
if (!config .containsKey (SCHEMA_DIRECTORY_KEY )) {
65
- log .info ("{} not set. Defaulting to current working directory: {}" , SCHEMA_DIRECTORY_KEY , CURRENT_WORKING_DIR );
55
+ log .info ("{} not set. Defaulting to current working directory: {}" , SCHEMA_DIRECTORY_KEY , CURRENT_WORKING_DIR );
66
56
config .put (SCHEMA_DIRECTORY_KEY , CURRENT_WORKING_DIR );
67
57
}
68
58
}
69
-
70
- private static void handleAuthentication (AtomicReference <String > username , AtomicReference <String > password , Map <String , Object > config ) {
71
- if (username .get () != null && password .get () != null ) {
72
- String loginModule = "org.apache.kafka.common.security.plain.PlainLoginModule" ;
73
- String value = String .format ("%s required username=\" %s\" password=\" %s\" ;" ,
74
- loginModule , escape (username .get ()), escape (password .get ()));
75
- config .put (SCHEMA_REGISTRY_SASL_CONFIG_KEY , value );
76
- } else {
77
- if (config .get (SCHEMA_REGISTRY_SASL_CONFIG_KEY ) == null ) {
78
- log .info ("{} or {} not set. No authentication configured for the Schema Registry" ,
79
- SCHEMA_REGISTRY_SASL_JAAS_USERNAME_KEY , SCHEMA_REGISTRY_SASL_JAAS_PASSWORD_KEY );
80
- }
81
- }
82
- }
83
-
84
- private static String escape (String value ) {
85
- if (value != null ) {
86
- return value .replace ("\" " , "\\ \" " );
87
- }
88
- return null ;
89
- }
90
59
}
0 commit comments