kumaab commented on code in PR #584:
URL: https://github.com/apache/ranger/pull/584#discussion_r2226067280
##########
agents-common/src/main/java/org/apache/ranger/plugin/service/RangerDefaultRequestProcessor.java:
##########
@@ -98,6 +103,18 @@ public void preProcess(RangerAccessRequest request) {
reqImpl.setClusterType(pluginContext.getClusterType());
}
+ RangerPluginConfig config =
policyEngine.getPluginContext().getConfig();
+ LOG.debug("RangerPluginConfig = " +
config.getPropertyPrefix());
Review Comment:
Avoid string concat, use {} instead, see other usages as well.
##########
ugsync-util/src/main/java/org/apache/ranger/ugsyncutil/transform/RegEx.java:
##########
@@ -17,34 +17,27 @@
* under the License.
*/
-package org.apache.ranger.usergroupsync;
-
-import org.apache.ranger.unixusersync.config.UserGroupSyncConfig;
+package org.apache.ranger.ugsyncutil.transform;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class RegEx extends AbstractMapper {
- private final UserGroupSyncConfig config =
UserGroupSyncConfig.getInstance();
- private LinkedHashMap<String, String> replacementPattern;
+ private LinkedHashMap<String, String> replacementPattern;
public LinkedHashMap<String, String> getReplacementPattern() {
return replacementPattern;
}
@Override
- public void init(String baseProperty) {
- logger.info("Initializing for {}", baseProperty);
-
+ public void init(String baseProperty, List<String> regexPatterns, String
regexSeparator) {
+ AbstractMapper.logger.info("Initializing for " + baseProperty);
try {
- List<String> regexPatterns =
config.getAllRegexPatterns(baseProperty);
- String regexSeparator = config.getRegexSeparator();
-
populateReplacementPatterns(baseProperty, regexPatterns,
regexSeparator);
} catch (Throwable t) {
- logger.error("Failed to initialize {}", baseProperty,
t.fillInStackTrace());
+ AbstractMapper.logger.error("Failed to initialize " +
baseProperty, t.fillInStackTrace());
Review Comment:
Avoid string concat, use {} instead, see other usages as well.
##########
agents-common/src/main/java/org/apache/ranger/plugin/service/RangerBasePlugin.java:
##########
@@ -1274,6 +1275,76 @@ private RangerAdminClient getAdminClient() throws
Exception {
return admin;
}
+ private void
configurePluginContextFromServicePoliciesForUserGroupName(ServicePolicies
servicePolicies) {
+ if (servicePolicies != null) {
+ Map<String, String> serviceConfigMap =
servicePolicies.getServiceConfig();
+ if (MapUtils.isNotEmpty(serviceConfigMap)) {
+ LOG.debug("==> RangerBasePlugin(" + serviceConfigMap.keySet()
+ ")");
+
pluginContext.setUserNameCaseConversion(serviceConfigMap.get(RangerCommonConstants.PLUGINS_CONF_USERNAME_CASE_CONVERSION_PARAM));
+
pluginContext.setGroupNameCaseConversion(serviceConfigMap.get(RangerCommonConstants.PLUGINS_CONF_GROUPNAME_CASE_CONVERSION_PARAM));
+ String mappingUserNameHandler =
serviceConfigMap.get(RangerCommonConstants.PLUGINS_CONF_MAPPING_USERNAME_HANDLER);
+ try {
+ if (mappingUserNameHandler != null) {
+ Class<Mapper> regExClass = (Class<Mapper>)
Class.forName(mappingUserNameHandler);
+ Mapper userNameRegExInst =
regExClass.newInstance();
+ if (userNameRegExInst != null) {
+ String baseProperty =
RangerCommonConstants.PLUGINS_CONF_MAPPING_USERNAME;
+ userNameRegExInst.init(baseProperty,
getAllRegexPatterns(baseProperty, serviceConfigMap),
+
serviceConfigMap.get(RangerCommonConstants.PLUGINS_CONF_MAPPING_SEPARATOR));
+
pluginContext.setUserNameTransformInst(userNameRegExInst);
+ } else {
+ LOG.error("RegEx handler instance for username is
null!");
+ }
+ }
+ } catch (ClassNotFoundException cne) {
+ LOG.error("Failed to load " + mappingUserNameHandler + "
", cne);
+ } catch (Throwable te) {
+ LOG.error("Failed to instantiate " +
mappingUserNameHandler + " ", te);
+ }
+ String mappingGroupNameHandler =
serviceConfigMap.get(RangerCommonConstants.PLUGINS_CONF_MAPPING_GROUPNAME_HANDLER);
+ try {
+ if (mappingGroupNameHandler != null) {
+ Class<Mapper> regExClass = (Class<Mapper>)
Class.forName(mappingGroupNameHandler);
+ Mapper groupNameRegExInst =
regExClass.newInstance();
+ if (groupNameRegExInst != null) {
+ String baseProperty =
RangerCommonConstants.PLUGINS_CONF_MAPPING_GROUPNAME;
+ groupNameRegExInst.init(baseProperty,
getAllRegexPatterns(baseProperty, serviceConfigMap),
+
serviceConfigMap.get(RangerCommonConstants.PLUGINS_CONF_MAPPING_SEPARATOR));
+
pluginContext.setGroupNameTransformInst(groupNameRegExInst);
+ } else {
+ LOG.error("RegEx handler instance for groupname is
null!");
+ }
+ }
+ } catch (ClassNotFoundException cne) {
+ LOG.error("Failed to load " + mappingGroupNameHandler + "
", cne);
+ } catch (Throwable te) {
+ LOG.error("Failed to instantiate " +
mappingGroupNameHandler + " ", te);
+ }
+ }
+ }
+ }
+
+ private List<String> getAllRegexPatterns(String baseProperty, Map<String,
String> serviceConfig) throws Throwable {
+ List<String> regexPatterns = new ArrayList<String>();
+ String baseRegex = serviceConfig.get(baseProperty);
+ LOG.debug("==> getAllRegexPatterns(" + baseProperty + ")");
Review Comment:
Avoid string concat, use {} instead, see other usages as well.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]