21
21
import com .google .common .collect .ImmutableMap ;
22
22
import java .util .Map ;
23
23
24
- public class AuthorizationPropertiesMeta {
24
+ public class AuthorizationPropertiesMeta extends BasePropertiesMetadata
25
+ implements WildcardPropertiesMeta {
26
+ private static volatile AuthorizationPropertiesMeta instance = null ;
27
+
28
+ public static synchronized AuthorizationPropertiesMeta getInstance () {
29
+ if (instance == null ) {
30
+ synchronized (AuthorizationPropertiesMeta .class ) {
31
+ if (instance == null ) {
32
+ instance = new AuthorizationPropertiesMeta ();
33
+ }
34
+ }
35
+ }
36
+ return instance ;
37
+ }
38
+
25
39
/** Ranger admin web URIs */
26
- public static final String RANGER_ADMIN_URL = "authorization.ranger.admin.url" ;
40
+ private static final String RANGER_ADMIN_URL_KEY = "ranger.admin.url" ;
41
+
42
+ public static final String getRangerAdminUrlKey () {
43
+ return RANGER_ADMIN_URL_KEY ;
44
+ }
45
+
46
+ public static final String RANGER_ADMIN_URL =
47
+ AuthorizationPropertiesMeta .getInstance ().generateFirstNodePropertyKey (RANGER_ADMIN_URL_KEY );
27
48
/** Ranger authentication type kerberos or simple */
28
- public static final String RANGER_AUTH_TYPE = "authorization.ranger.auth.type" ;
49
+ private static final String RANGER_AUTH_TYPE_KEY = "ranger.auth.type" ;
50
+
51
+ public static final String getRangerAuthTypeKey () {
52
+ return RANGER_AUTH_TYPE_KEY ;
53
+ }
54
+
55
+ public static final String RANGER_AUTH_TYPE =
56
+ AuthorizationPropertiesMeta .getInstance ().generateFirstNodePropertyKey (RANGER_AUTH_TYPE_KEY );
29
57
/**
30
58
* Ranger admin web login username(auth_type=simple), or kerberos principal(auth_type=kerberos)
31
59
*/
32
- public static final String RANGER_USERNAME = "authorization.ranger.username" ;
60
+ private static final String RANGER_USERNAME_KEY = "ranger.username" ;
61
+
62
+ public static final String getRangerUsernameKey () {
63
+ return RANGER_USERNAME_KEY ;
64
+ }
65
+
66
+ public static final String RANGER_USERNAME =
67
+ AuthorizationPropertiesMeta .getInstance ().generateFirstNodePropertyKey (RANGER_USERNAME_KEY );
33
68
/**
34
69
* Ranger admin web login user password(auth_type=simple), or path of the keytab
35
70
* file(auth_type=kerberos)
36
71
*/
37
- public static final String RANGER_PASSWORD = "authorization.ranger.password" ;
72
+ private static final String RANGER_PASSWORD_KEY = "ranger.password" ;
73
+
74
+ public static final String getRangerPasswordKey () {
75
+ return RANGER_PASSWORD_KEY ;
76
+ }
77
+
78
+ public static final String RANGER_PASSWORD =
79
+ AuthorizationPropertiesMeta .getInstance ().generateFirstNodePropertyKey (RANGER_PASSWORD_KEY );
80
+
38
81
/** Ranger service name */
39
- public static final String RANGER_SERVICE_NAME = "authorization.ranger.service.name" ;
82
+ private static final String RANGER_SERVICE_NAME_KEY = "ranger.service.name" ;
83
+
84
+ public static final String getRangerServiceNameKey () {
85
+ return RANGER_SERVICE_NAME_KEY ;
86
+ }
87
+
88
+ public static final String RANGER_SERVICE_NAME =
89
+ AuthorizationPropertiesMeta .getInstance ()
90
+ .generateFirstNodePropertyKey (RANGER_SERVICE_NAME_KEY );
91
+
92
+ /** Chain authorization plugin provider */
93
+ private static final String CHAIN_CATALOG_PROVIDER_KEY = "catalog-provider" ;
94
+
95
+ public static final String getChainCatalogProviderKey () {
96
+ return CHAIN_CATALOG_PROVIDER_KEY ;
97
+ }
98
+
99
+ public static final String CHAIN_CATALOG_PROVIDER =
100
+ AuthorizationPropertiesMeta .getInstance ()
101
+ .getPropertyValue (Constants .WILDCARD , CHAIN_CATALOG_PROVIDER_KEY );
102
+
103
+ /** Chain authorization plugin provider */
104
+ private static final String CHAIN_PROVIDER_KEY = "provider" ;
40
105
41
- public static final Map <String , PropertyEntry <?>> RANGER_AUTHORIZATION_PROPERTY_ENTRIES =
106
+ public static final String getChainProviderKey () {
107
+ return CHAIN_PROVIDER_KEY ;
108
+ }
109
+
110
+ public static final String CHAIN_PROVIDER =
111
+ AuthorizationPropertiesMeta .getInstance ()
112
+ .getPropertyValue (Constants .WILDCARD , CHAIN_PROVIDER_KEY );
113
+ /** Chain authorization Ranger admin web URIs */
114
+ public static final String CHAIN_RANGER_ADMIN_URL =
115
+ AuthorizationPropertiesMeta .getInstance ()
116
+ .getPropertyValue (Constants .WILDCARD , RANGER_ADMIN_URL_KEY );
117
+ /** Chain authorization Ranger authentication type kerberos or simple */
118
+ public static final String CHAIN_RANGER_AUTH_TYPES =
119
+ AuthorizationPropertiesMeta .getInstance ()
120
+ .getPropertyValue (Constants .WILDCARD , RANGER_AUTH_TYPE_KEY );
121
+ /** Chain authorization Ranger username */
122
+ public static final String CHAIN_RANGER_USERNAME =
123
+ AuthorizationPropertiesMeta .getInstance ()
124
+ .getPropertyValue (Constants .WILDCARD , RANGER_USERNAME_KEY );
125
+ /**
126
+ * Chain authorization Ranger admin web login user password(auth_type=simple), or path of the
127
+ * keytab file(auth_type=kerberos)
128
+ */
129
+ public static final String CHAIN_RANGER_PASSWORD =
130
+ AuthorizationPropertiesMeta .getInstance ()
131
+ .getPropertyValue (Constants .WILDCARD , RANGER_PASSWORD_KEY );
132
+ /** Chain authorization Ranger service name */
133
+ public static final String CHAIN_RANGER_SERVICE_NAME =
134
+ AuthorizationPropertiesMeta .getInstance ()
135
+ .getPropertyValue (Constants .WILDCARD , RANGER_SERVICE_NAME_KEY );
136
+
137
+ public static String chainKeyToPluginKey (String chainKey , String plugin ) {
138
+ return chainKey .replace (
139
+ String .format (
140
+ "%s.%s" , AuthorizationPropertiesMeta .getInstance ().wildcardNodePropertyKey (), plugin ),
141
+ AuthorizationPropertiesMeta .getInstance ().firstNodeName ());
142
+ }
143
+
144
+ public static final Map <String , PropertyEntry <?>> AUTHORIZATION_PROPERTY_ENTRIES =
42
145
ImmutableMap .<String , PropertyEntry <?>>builder ()
146
+ .put (
147
+ AuthorizationPropertiesMeta .getInstance ().wildcardNodePropertyKey (),
148
+ PropertyEntry .wildcardPropertyEntry (
149
+ AuthorizationPropertiesMeta .getInstance ().wildcardNodePropertyKey (),
150
+ "The Chain authorization plugins" ))
151
+ .put (
152
+ CHAIN_CATALOG_PROVIDER ,
153
+ PropertyEntry .wildcardPropertyEntry (
154
+ CHAIN_PROVIDER , "The Chain sub entity catalog provider" ))
155
+ .put (
156
+ CHAIN_PROVIDER ,
157
+ PropertyEntry .wildcardPropertyEntry (
158
+ CHAIN_PROVIDER , "The Chain sub entity authorization plugin provider" ))
159
+ .put (
160
+ CHAIN_RANGER_SERVICE_NAME ,
161
+ PropertyEntry .wildcardPropertyEntry (
162
+ CHAIN_RANGER_SERVICE_NAME ,
163
+ "The Chain sub entity authorization Ranger service name" ))
164
+ .put (
165
+ CHAIN_RANGER_ADMIN_URL ,
166
+ PropertyEntry .wildcardPropertyEntry (
167
+ CHAIN_RANGER_ADMIN_URL ,
168
+ "The Chain sub entity authorization Ranger admin web URIs" ))
169
+ .put (
170
+ CHAIN_RANGER_AUTH_TYPES ,
171
+ PropertyEntry .wildcardPropertyEntry (
172
+ CHAIN_RANGER_AUTH_TYPES ,
173
+ "The Chain sub entity authorization Ranger admin web auth type (kerberos/simple)" ))
174
+ .put (
175
+ CHAIN_RANGER_USERNAME ,
176
+ PropertyEntry .wildcardPropertyEntry (
177
+ CHAIN_RANGER_USERNAME ,
178
+ "The Chain sub entity authorization Ranger admin web login username" ))
179
+ .put (
180
+ CHAIN_RANGER_PASSWORD ,
181
+ PropertyEntry .wildcardPropertyEntry (
182
+ CHAIN_RANGER_PASSWORD ,
183
+ "The Chain sub entity authorization Ranger admin web login password" ))
43
184
.put (
44
185
RANGER_SERVICE_NAME ,
45
186
PropertyEntry .stringOptionalPropertyEntry (
@@ -65,4 +206,24 @@ public class AuthorizationPropertiesMeta {
65
206
PropertyEntry .stringOptionalPropertyEntry (
66
207
RANGER_PASSWORD , "The Ranger admin web login password" , true , null , false ))
67
208
.build ();
209
+
210
+ @ Override
211
+ protected Map <String , PropertyEntry <?>> specificPropertyEntries () {
212
+ return AUTHORIZATION_PROPERTY_ENTRIES ;
213
+ }
214
+
215
+ @ Override
216
+ public String firstNodeName () {
217
+ return "authorization" ;
218
+ }
219
+
220
+ @ Override
221
+ public String secondNodeName () {
222
+ return "chain" ;
223
+ }
224
+
225
+ @ Override
226
+ public String wildcardNodeName () {
227
+ return "plugins" ;
228
+ }
68
229
}
0 commit comments