rameeshm commented on code in PR #584:
URL: https://github.com/apache/ranger/pull/584#discussion_r2131549405


##########
agents-common/src/main/java/org/apache/ranger/plugin/policyengine/RangerPolicyEngineImpl.java:
##########
@@ -83,6 +84,53 @@ public RangerPolicyEngineImpl(ServicePolicies 
servicePolicies, RangerPluginConte
         policyEngine     = new PolicyEngine(servicePolicies, pluginContext, 
roles, isUseReadWriteLock);
         serviceConfig    = new 
ServiceConfig(servicePolicies.getServiceConfig());
         requestProcessor = new RangerDefaultRequestProcessor(policyEngine);
+
+        Map<String, String> serviceConfigMap = 
servicePolicies.getServiceConfig();

Review Comment:
   can the whole pluginContext setting be done upfront in basePlugin before 
RangerPolicyEngineImpl is created? 



##########
agents-common/src/main/java/org/apache/ranger/plugin/policyengine/RangerPolicyEngineImpl.java:
##########
@@ -83,6 +84,53 @@ public RangerPolicyEngineImpl(ServicePolicies 
servicePolicies, RangerPluginConte
         policyEngine     = new PolicyEngine(servicePolicies, pluginContext, 
roles, isUseReadWriteLock);
         serviceConfig    = new 
ServiceConfig(servicePolicies.getServiceConfig());
         requestProcessor = new RangerDefaultRequestProcessor(policyEngine);
+
+        Map<String, String> serviceConfigMap = 
servicePolicies.getServiceConfig();
+        if (MapUtils.isNotEmpty(serviceConfigMap)) {
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("==> RangerBasePlugin(" + serviceConfigMap.keySet() 
+ ")");
+            }
+            
pluginContext.setUserNameCaseConversion(serviceConfigMap.get(RangerCommonConstants.PLUGINS_USERNAME_CASE_CONVERSION_PARAM));
+            
pluginContext.setGroupNameCaseConversion(serviceConfigMap.get(RangerCommonConstants.PLUGINS_GROUPNAME_CASE_CONVERSION_PARAM));
+            String mappingUserNameHandler = 
serviceConfigMap.get(RangerCommonConstants.PLUGINS_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_MAPPING_USERNAME;
+                        userNameRegExInst.init(baseProperty, 
getAllRegexPatterns(baseProperty, serviceConfigMap),
+                                
serviceConfigMap.get(RangerCommonConstants.PLUGINS_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_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_MAPPING_GROUPNAME;
+                        groupNameRegExInst.init(baseProperty, 
getAllRegexPatterns(baseProperty, serviceConfigMap),
+                                
serviceConfigMap.get(RangerCommonConstants.PLUGINS_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);

Review Comment:
   Print the whole stack trace, do this for all the occurance
   LOG.error("Failed to load " + mappingGroupNameHandler + " " , cne);



-- 
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: dev-unsubscr...@ranger.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to