ranger-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mad...@apache.org
Subject [1/3] git commit: ARGUS-5: added support for %app-type% token in file and directory names, to enable configuration of separate log directories for HBase Master and Regional servers, HiveServer2 and HiveCLI. Audit framework initialization call deferred to
Date Thu, 25 Sep 2014 08:27:21 GMT
Repository: incubator-argus
Updated Branches:
  refs/heads/master 674c615dd -> 7a01fbbe2


ARGUS-5: added support for %app-type% token in file and directory names,
to enable configuration of separate log directories for HBase Master and
Regional servers, HiveServer2 and HiveCLI. Audit framework
initialization call deferred to a point where the application-type
information is available.

Project: http://git-wip-us.apache.org/repos/asf/incubator-argus/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-argus/commit/fcf01f98
Tree: http://git-wip-us.apache.org/repos/asf/incubator-argus/tree/fcf01f98
Diff: http://git-wip-us.apache.org/repos/asf/incubator-argus/diff/fcf01f98

Branch: refs/heads/master
Commit: fcf01f981bf810d868f15b65b5d7b802851e3cf4
Parents: 4058fd2
Author: mneethiraj <mneethiraj@hortonworks.com>
Authored: Wed Sep 24 22:57:23 2014 -0700
Committer: mneethiraj <mneethiraj@hortonworks.com>
Committed: Wed Sep 24 22:57:23 2014 -0700

----------------------------------------------------------------------
 .../audit/provider/AuditProviderFactory.java    |  58 ++++++-
 .../audit/provider/LocalFileLogBuffer.java      |   2 +-
 .../com/xasecure/audit/provider/MiscUtil.java   | 152 +++++++++++++------
 .../audit/provider/hdfs/HdfsLogDestination.java |   2 +-
 .../com/xasecure/audit/test/TestEvents.java     |   3 +-
 .../hadoop/config/XaSecureConfiguration.java    |  30 ++--
 .../pdp/knox/filter/XASecurePDPKnoxFilter.java  |   4 +
 .../hbase/XaSecureAuthorizationCoprocessor.java |  12 +-
 .../namenode/XaSecureFSPermissionChecker.java   |   4 +-
 .../hive/authorizer/XaSecureHiveAuthorizer.java |  18 +++
 .../authorizer/XaSecureStormAuthorizer.java     |   7 +-
 11 files changed, 221 insertions(+), 71 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/fcf01f98/agents-audit/src/main/java/com/xasecure/audit/provider/AuditProviderFactory.java
----------------------------------------------------------------------
diff --git a/agents-audit/src/main/java/com/xasecure/audit/provider/AuditProviderFactory.java
b/agents-audit/src/main/java/com/xasecure/audit/provider/AuditProviderFactory.java
index bb31e7c..814026d 100644
--- a/agents-audit/src/main/java/com/xasecure/audit/provider/AuditProviderFactory.java
+++ b/agents-audit/src/main/java/com/xasecure/audit/provider/AuditProviderFactory.java
@@ -40,6 +40,8 @@ import com.xasecure.authorization.hadoop.utils.XaSecureCredentialProvider;
 
 public class AuditProviderFactory {
 
+	public enum ApplicationType { Unknown, Hdfs, HiveCLI, HiveServer2, HBaseMaster, HBaseRegionalServer,
Knox, Storm };
+
 	private static final Log LOG = LogFactory.getLog(AuditProviderFactory.class);
 
 	private static final String AUDIT_IS_ENABLED_PROP               = "xasecure.audit.is.enabled"
;
@@ -71,6 +73,7 @@ public class AuditProviderFactory {
 	private static AuditProviderFactory sFactory;
 
 	private AuditProvider mProvider = null;
+	private boolean       mInitDone = false;
 
 	private AuditProviderFactory() {
 		LOG.info("AuditProviderFactory: creating..");
@@ -98,8 +101,21 @@ public class AuditProviderFactory {
 		return mProvider;
 	}
 
-	public void init(Properties props) {
+	public boolean isInitDone() {
+		return mInitDone;
+	}
+
+	public synchronized void init(Properties props, ApplicationType appType) {
 		LOG.info("AuditProviderFactory: initializing..");
+		
+		if(mInitDone) {
+			LOG.warn("AuditProviderFactory.init(): already initialized!", new Exception());
+
+			return;
+		}
+		mInitDone = true;
+		
+		setApplicationType(appType);
 
 		boolean isEnabled             = getBooleanProperty(props, AUDIT_IS_ENABLED_PROP, false);
 		boolean isAuditToDbEnabled    = getBooleanProperty(props, AUDIT_DB_IS_ENABLED_PROP, false);
@@ -228,6 +244,46 @@ public class AuditProviderFactory {
 
 	    Runtime.getRuntime().addShutdownHook(jvmShutdownHook);
 	}
+
+	private static void setApplicationType(ApplicationType appType) {
+		String strAppType = null;
+
+		switch(appType) {
+			case Hdfs:
+				strAppType = "hdfs";
+			break;
+	
+			case HiveCLI:
+				strAppType = "hiveCli";
+			break;
+	
+			case HiveServer2:
+				strAppType = "hiveServer2";
+			break;
+	
+			case HBaseMaster:
+				strAppType = "hbaseMaster";
+			break;
+
+			case HBaseRegionalServer:
+				strAppType = "hbaseRegional";
+			break;
+
+			case Knox:
+				strAppType = "knox";
+			break;
+
+			case Storm:
+				strAppType = "storm";
+			break;
+
+			case Unknown:
+				strAppType = "unknown";
+			break;
+		}
+
+		MiscUtil.setApplicationType(strAppType);
+	}
 	
 	private Map<String, String> getPropertiesWithPrefix(Properties props, String prefix)
{
 		Map<String, String> prefixedProperties = new HashMap<String, String>();

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/fcf01f98/agents-audit/src/main/java/com/xasecure/audit/provider/LocalFileLogBuffer.java
----------------------------------------------------------------------
diff --git a/agents-audit/src/main/java/com/xasecure/audit/provider/LocalFileLogBuffer.java
b/agents-audit/src/main/java/com/xasecure/audit/provider/LocalFileLogBuffer.java
index 767cbc4..fc53ba6 100644
--- a/agents-audit/src/main/java/com/xasecure/audit/provider/LocalFileLogBuffer.java
+++ b/agents-audit/src/main/java/com/xasecure/audit/provider/LocalFileLogBuffer.java
@@ -408,7 +408,7 @@ class DestinationDispatcherThread<T> extends Thread {
 					try {
 						mCompletedLogfiles.wait(pollIntervalInMs);
 					} catch(InterruptedException excp) {
-						LogLog.warn("LocalFileLogBuffer.run(): failed to wait for log file", excp);
+						LogLog.warn("DestinationDispatcherThread.run(): failed to wait for log file", excp);
 					}
 				}
 				

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/fcf01f98/agents-audit/src/main/java/com/xasecure/audit/provider/MiscUtil.java
----------------------------------------------------------------------
diff --git a/agents-audit/src/main/java/com/xasecure/audit/provider/MiscUtil.java b/agents-audit/src/main/java/com/xasecure/audit/provider/MiscUtil.java
index d382ead..9ad3db9 100644
--- a/agents-audit/src/main/java/com/xasecure/audit/provider/MiscUtil.java
+++ b/agents-audit/src/main/java/com/xasecure/audit/provider/MiscUtil.java
@@ -12,17 +12,22 @@ import com.google.gson.Gson;
 import com.google.gson.GsonBuilder;
 
 public class MiscUtil {
-	public static final String TOKEN_HOSTNAME     = "%hostname%";
-	public static final String TOKEN_JVM_INSTANCE = "%jvm-instance%";
-	public static final String TOKEN_TIME_START   = "%time:";
-	public static final String TOKEN_TIME_END     = "%";
-	public static final String ESCAPE_STR         = "\\";
+	public static final String TOKEN_START        = "%";
+	public static final String TOKEN_END          = "%";
+	public static final String TOKEN_HOSTNAME     = "hostname";
+	public static final String TOKEN_APP_TYPE     = "app-type";
+	public static final String TOKEN_JVM_INSTANCE = "jvm-instance";
+	public static final String TOKEN_TIME         = "time:";
+	public static final String TOKEN_PROPERTY     = "property:";
+	public static final String TOKEN_ENV          = "env:";
+	public static final String ESCAPE_STR           = "\\";
 
 	static VMID sJvmID = new VMID();
 
 	public static String LINE_SEPARATOR = System.getProperty("line.separator");
 
-	private static Gson sGsonBuilder = null;
+	private static Gson   sGsonBuilder = null;
+	private static String sApplicationType = null;
 
 	static {
 		try {
@@ -37,71 +42,122 @@ public class MiscUtil {
 			return str;
 		}
 
-		str = replaceHostname(str);
-		str = replaceJvmInstance(str);
-		str = replaceTime(str, time);
+		if(time <= 0) {
+			time = System.currentTimeMillis();
+		}
 
-		return str;
-	}
+        for(int startPos = 0; startPos < str.length(); ) {
+            int tagStartPos = str.indexOf(TOKEN_START, startPos);
+            
+            if(tagStartPos == -1) {
+            	break;
+            }
 
-	public static String replaceHostname(String str) {
-		if(!str.contains(TOKEN_HOSTNAME)) {
-			return str;
-		}
+            int tagEndPos = str.indexOf(TOKEN_END, tagStartPos + TOKEN_START.length());
+
+            if(tagEndPos == -1) {
+            	break;
+            }
 
-		String hostName = null;
+            String tag   = str.substring(tagStartPos, tagEndPos+TOKEN_END.length());
+            String token = tag.substring(TOKEN_START.length(), tag.lastIndexOf(TOKEN_END));
+            String val   = "";
+
+            if(token != null) {
+	            if(token.equals(TOKEN_HOSTNAME)) {
+	            	val = getHostname();
+	            } else if(token.equals(TOKEN_APP_TYPE)) {
+	            	val = getApplicationType();
+	            } else if(token.equals(TOKEN_JVM_INSTANCE)) {
+	            	val = getJvmInstanceId();
+	            } else if(token.startsWith(TOKEN_PROPERTY)) {
+	            	String propertyName = token.substring(TOKEN_PROPERTY.length());
+	
+	                val = getSystemProperty(propertyName);
+	            } else if(token.startsWith(TOKEN_ENV)) {
+	            	String envName = token.substring(TOKEN_ENV.length());
+	
+	                val = getEnv(envName);
+	            } else if(token.startsWith(TOKEN_TIME)) {
+	                String dtFormat = token.substring(TOKEN_TIME.length());
+	                
+	                val = getFormattedTime(time, dtFormat);
+	            }
+            }
+
+            if(val == null) {
+            	val = "";
+            }
+
+            str = str.substring(0, tagStartPos) + val + str.substring(tagEndPos + TOKEN_END.length());
+            startPos = tagStartPos + val.length();
+        }
+
+        return str;
+	}
+
+	public static String getHostname() {
+		String ret = null;
 
 		try {
-			hostName = InetAddress.getLocalHost().getHostName();
+			ret = InetAddress.getLocalHost().getHostName();
 		} catch (UnknownHostException excp) {
-			LogLog.warn("replaceHostname()", excp);
+			LogLog.warn("getHostname()", excp);
 		}
 
-		if(hostName == null) {
-			hostName = "Unknown";
-		}
+		return ret;
+	}
 
-		return str.replace(TOKEN_HOSTNAME, hostName);
+	public static void setApplicationType(String applicationType) {
+		sApplicationType = applicationType;
+	}
+
+	public static String getApplicationType() {
+		return sApplicationType;
 	}
-	
-	public static String replaceJvmInstance(String str) {
-		if(!str.contains(TOKEN_JVM_INSTANCE)) {
-			return str;
-		}
 
-		String jvmInstance = Integer.toString(Math.abs(sJvmID.hashCode()));
+	public static String getJvmInstanceId() {
+		String ret = Integer.toString(Math.abs(sJvmID.toString().hashCode()));
 
-		return str.replace(TOKEN_JVM_INSTANCE, jvmInstance);
+		return ret;
 	}
 
-	public static String replaceTime(String str, long time) {
-		if(time <= 0) {
-			time = System.currentTimeMillis();
+	public static String getSystemProperty(String propertyName) {
+		String ret = null;
+
+		try {
+			ret = propertyName != null ? System.getProperty(propertyName) : null;
+		} catch (Exception excp) {
+			LogLog.warn("getSystemProperty(" + propertyName + ") failed", excp);
 		}
 
-        while(str.contains(TOKEN_TIME_START)) {
-            int tagStartPos = str.indexOf(TOKEN_TIME_START);
-            int tagEndPos   = str.indexOf(TOKEN_TIME_END, tagStartPos + TOKEN_TIME_START.length());
+		return ret;
+	}
 
-            if(tagEndPos <= tagStartPos) {
-            	break;
-            }
+	public static String getEnv(String envName) {
+		String ret = null;
 
-            String tag      = str.substring(tagStartPos, tagEndPos+1);
-            String dtFormat = tag.substring(TOKEN_TIME_START.length(), tag.lastIndexOf(TOKEN_TIME_END));
+		try {
+			ret = envName != null ? System.getenv(envName) : null;
+		} catch (Exception excp) {
+			LogLog.warn("getenv(" + envName + ") failed", excp);
+		}
 
-            String replaceStr = "";
+		return ret;
+	}
 
-            if(dtFormat != null) {
-                SimpleDateFormat sdf = new SimpleDateFormat(dtFormat);
+	public static String getFormattedTime(long time, String format) {
+		String ret = null;
 
-                replaceStr = sdf.format(time);
-            }
+		try {
+            SimpleDateFormat sdf = new SimpleDateFormat(format);
 
-            str = str.replace(tag, replaceStr);
-        }
+            ret = sdf.format(time);
+		} catch (Exception excp) {
+			LogLog.warn("SimpleDateFormat.format() failed: " + format, excp);
+		}
 
-        return str;
+		return ret;
 	}
 
 	public static void createParents(File file) {

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/fcf01f98/agents-audit/src/main/java/com/xasecure/audit/provider/hdfs/HdfsLogDestination.java
----------------------------------------------------------------------
diff --git a/agents-audit/src/main/java/com/xasecure/audit/provider/hdfs/HdfsLogDestination.java
b/agents-audit/src/main/java/com/xasecure/audit/provider/hdfs/HdfsLogDestination.java
index 3c3a0a4..8872541 100644
--- a/agents-audit/src/main/java/com/xasecure/audit/provider/hdfs/HdfsLogDestination.java
+++ b/agents-audit/src/main/java/com/xasecure/audit/provider/hdfs/HdfsLogDestination.java
@@ -199,7 +199,7 @@ public class HdfsLogDestination<T> implements LogDestination<T>
{
 						ostream = fileSystem.append(pathLogfile);
 					} catch(IOException excp) {
 						// append may not be supported by the filesystem. rename existing file and create a
new one
-						String fileSuffix    = MiscUtil.replaceTokens("-" + MiscUtil.TOKEN_TIME_START + "yyyyMMdd-HHmm.ss"
+ MiscUtil.TOKEN_TIME_END, startTime);
+						String fileSuffix    = MiscUtil.replaceTokens("-" + MiscUtil.TOKEN_START + MiscUtil.TOKEN_TIME
+ "yyyyMMdd-HHmm.ss" + MiscUtil.TOKEN_END, startTime);
 						String movedFilename = appendToFilename(mHdfsFilename, fileSuffix);
 						Path   movedFilePath = new Path(movedFilename);
 

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/fcf01f98/agents-audit/src/main/java/com/xasecure/audit/test/TestEvents.java
----------------------------------------------------------------------
diff --git a/agents-audit/src/main/java/com/xasecure/audit/test/TestEvents.java b/agents-audit/src/main/java/com/xasecure/audit/test/TestEvents.java
index 8968093..92497f7 100644
--- a/agents-audit/src/main/java/com/xasecure/audit/test/TestEvents.java
+++ b/agents-audit/src/main/java/com/xasecure/audit/test/TestEvents.java
@@ -35,6 +35,7 @@ import com.xasecure.audit.model.KnoxAuditEvent;
 import com.xasecure.audit.model.StormAuditEvent;
 import com.xasecure.audit.provider.AuditProvider;
 import com.xasecure.audit.provider.AuditProviderFactory;
+import com.xasecure.audit.provider.AuditProviderFactory.ApplicationType;
 
 public class TestEvents {
 
@@ -76,7 +77,7 @@ public class TestEvents {
 	        	auditProperties.setProperty("xasecure.audit.db.batch.size", "100");
         	}
         	
-        	AuditProviderFactory.getInstance().init(auditProperties);
+        	AuditProviderFactory.getInstance().init(auditProperties, ApplicationType.Hdfs);
 
         	AuditProvider provider = AuditProviderFactory.getAuditProvider();
 

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/fcf01f98/agents-common/src/main/java/com/xasecure/authorization/hadoop/config/XaSecureConfiguration.java
----------------------------------------------------------------------
diff --git a/agents-common/src/main/java/com/xasecure/authorization/hadoop/config/XaSecureConfiguration.java
b/agents-common/src/main/java/com/xasecure/authorization/hadoop/config/XaSecureConfiguration.java
index e61da1b..e026b00 100644
--- a/agents-common/src/main/java/com/xasecure/authorization/hadoop/config/XaSecureConfiguration.java
+++ b/agents-common/src/main/java/com/xasecure/authorization/hadoop/config/XaSecureConfiguration.java
@@ -83,35 +83,37 @@ public class XaSecureConfiguration extends Configuration {
 				XaSecureConfiguration temp = config;
 				if (temp == null) {
 					config = new XaSecureConfiguration();
-					
-					onConfigInstantiation(config);
 				}
 			}
 		}
 		return config;
 	}
-	
-	private static void onConfigInstantiation(XaSecureConfiguration config) {
-		initAudit(config);
-	}
 
-	private static void initAudit(XaSecureConfiguration config) {
+	public void initAudit(AuditProviderFactory.ApplicationType appType) {
 		AuditProviderFactory auditFactory = AuditProviderFactory.getInstance();
-		
+
 		if(auditFactory == null) {
 			LOG.error("Unable to find the AuditProviderFactory. (null) found") ;
 			return;
 		}
-		
-		Properties props = config.getProps();
-		
+
+		Properties props = getProps();
+
 		if(props == null) {
 			return;
 		}
-		
-		auditFactory.init(props);
+
+		if(! auditFactory.isInitDone()) {
+			auditFactory.init(props, appType);
+		}
 	}
-	
+
+	public boolean isAuditInitDone() {
+		AuditProviderFactory auditFactory = AuditProviderFactory.getInstance();
+
+		return auditFactory != null && auditFactory.isInitDone();
+	}
+
 	
 	@SuppressWarnings("deprecation")
 	public  URL getXAAuditXMLFileLocation() {

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/fcf01f98/agents-impl/src/main/java/com/xasecure/pdp/knox/filter/XASecurePDPKnoxFilter.java
----------------------------------------------------------------------
diff --git a/agents-impl/src/main/java/com/xasecure/pdp/knox/filter/XASecurePDPKnoxFilter.java
b/agents-impl/src/main/java/com/xasecure/pdp/knox/filter/XASecurePDPKnoxFilter.java
index 92c0a4a..dfa68b5 100644
--- a/agents-impl/src/main/java/com/xasecure/pdp/knox/filter/XASecurePDPKnoxFilter.java
+++ b/agents-impl/src/main/java/com/xasecure/pdp/knox/filter/XASecurePDPKnoxFilter.java
@@ -61,6 +61,10 @@ public class XASecurePDPKnoxFilter implements Filter {
 
 	AuditProvider auditProvider = AuditProviderFactory.getAuditProvider();
 	private final String REPOSITORY_NAME = XaSecureConfiguration.getInstance().get(XaSecureHadoopConstants.AUDITLOG_REPOSITORY_NAME_PROP);
+	
+	static {
+		XaSecureConfiguration.getInstance().initAudit(AuditProviderFactory.ApplicationType.Knox);
+	}
 
 	@Override
 	public void init(FilterConfig filterConfig) throws ServletException {

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/fcf01f98/hbase-agent/src/main/java/com/xasecure/authorization/hbase/XaSecureAuthorizationCoprocessor.java
----------------------------------------------------------------------
diff --git a/hbase-agent/src/main/java/com/xasecure/authorization/hbase/XaSecureAuthorizationCoprocessor.java
b/hbase-agent/src/main/java/com/xasecure/authorization/hbase/XaSecureAuthorizationCoprocessor.java
index db70d2a..774a3cf 100644
--- a/hbase-agent/src/main/java/com/xasecure/authorization/hbase/XaSecureAuthorizationCoprocessor.java
+++ b/hbase-agent/src/main/java/com/xasecure/authorization/hbase/XaSecureAuthorizationCoprocessor.java
@@ -732,15 +732,23 @@ public class XaSecureAuthorizationCoprocessor extends XaSecureAuthorizationCopro
 	private static final String REGIONAL_COPROCESSOR_TYPE = "regional";
 	private static final String REGIONAL_SERVER_COPROCESSOR_TYPE = "regionalServer";
 	@Override
-	public void start(CoprocessorEnvironment env) throws IOException {
+	public void start(CoprocessorEnvironment env) throws IOException {
+		AuditProviderFactory.ApplicationType appType = AuditProviderFactory.ApplicationType.Unknown;
+
 		if (env instanceof MasterCoprocessorEnvironment) {
 			coprocessorType = MASTER_COPROCESSOR_TYPE;
+			appType = AuditProviderFactory.ApplicationType.HBaseMaster;
 		} else if (env instanceof RegionServerCoprocessorEnvironment) {
 			coprocessorType = REGIONAL_SERVER_COPROCESSOR_TYPE;
+			appType = AuditProviderFactory.ApplicationType.HBaseRegionalServer;
 		} else if (env instanceof RegionCoprocessorEnvironment) {
 			regionEnv = (RegionCoprocessorEnvironment) env;
 			coprocessorType = REGIONAL_COPROCESSOR_TYPE;
-		}
+			appType = AuditProviderFactory.ApplicationType.HBaseRegionalServer;
+		}
+
+		XaSecureConfiguration.getInstance().initAudit(appType);
+
 		if (superUserList == null) {
 			superUserList = new ArrayList<String>();
 			Configuration conf = env.getConfiguration();

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/fcf01f98/hdfs-agent/src/main/java/org/apache/hadoop/hdfs/server/namenode/XaSecureFSPermissionChecker.java
----------------------------------------------------------------------
diff --git a/hdfs-agent/src/main/java/org/apache/hadoop/hdfs/server/namenode/XaSecureFSPermissionChecker.java
b/hdfs-agent/src/main/java/org/apache/hadoop/hdfs/server/namenode/XaSecureFSPermissionChecker.java
index 28c8226..a5d55c4 100644
--- a/hdfs-agent/src/main/java/org/apache/hadoop/hdfs/server/namenode/XaSecureFSPermissionChecker.java
+++ b/hdfs-agent/src/main/java/org/apache/hadoop/hdfs/server/namenode/XaSecureFSPermissionChecker.java
@@ -104,8 +104,8 @@ public class XaSecureFSPermissionChecker {
 				excludeUsers.add(excludeUser) ;
  			}
 		}
-		
-		
+
+		XaSecureConfiguration.getInstance().initAudit(AuditProviderFactory.ApplicationType.Hdfs);
	
 	}
 
 	public static boolean check(UserGroupInformation ugi, INode inode, FsAction access) throws
XaSecureAccessControlException {

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/fcf01f98/hive-agent/src/main/java/com/xasecure/authorization/hive/authorizer/XaSecureHiveAuthorizer.java
----------------------------------------------------------------------
diff --git a/hive-agent/src/main/java/com/xasecure/authorization/hive/authorizer/XaSecureHiveAuthorizer.java
b/hive-agent/src/main/java/com/xasecure/authorization/hive/authorizer/XaSecureHiveAuthorizer.java
index a7c4611..9acad11 100644
--- a/hive-agent/src/main/java/com/xasecure/authorization/hive/authorizer/XaSecureHiveAuthorizer.java
+++ b/hive-agent/src/main/java/com/xasecure/authorization/hive/authorizer/XaSecureHiveAuthorizer.java
@@ -78,6 +78,24 @@ public class XaSecureHiveAuthorizer extends XaSecureHiveAuthorizerBase
{
 		LOG.debug("XaSecureHiveAuthorizer.XaSecureHiveAuthorizer()");
 
 		mHiveAccessVerifier = XaHiveAccessVerifierFactory.getInstance() ;
+		
+		if(!XaSecureConfiguration.getInstance().isAuditInitDone()) {
+			if(sessionContext != null) {
+				AuditProviderFactory.ApplicationType appType = AuditProviderFactory.ApplicationType.Unknown;
+
+				switch(sessionContext.getClientType()) {
+					case HIVECLI:
+						appType = AuditProviderFactory.ApplicationType.HiveCLI;
+					break;
+
+					case HIVESERVER2:
+						appType = AuditProviderFactory.ApplicationType.HiveServer2;
+					break;
+				}
+
+				XaSecureConfiguration.getInstance().initAudit(appType);
+			}
+		}
 	}
 
 

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/fcf01f98/storm-agent/src/main/java/com/xasecure/authorization/storm/authorizer/XaSecureStormAuthorizer.java
----------------------------------------------------------------------
diff --git a/storm-agent/src/main/java/com/xasecure/authorization/storm/authorizer/XaSecureStormAuthorizer.java
b/storm-agent/src/main/java/com/xasecure/authorization/storm/authorizer/XaSecureStormAuthorizer.java
index 778f319..b07769c 100644
--- a/storm-agent/src/main/java/com/xasecure/authorization/storm/authorizer/XaSecureStormAuthorizer.java
+++ b/storm-agent/src/main/java/com/xasecure/authorization/storm/authorizer/XaSecureStormAuthorizer.java
@@ -48,7 +48,12 @@ public class XaSecureStormAuthorizer implements IAuthorizer {
 	private static final String repositoryName     = XaSecureConfiguration.getInstance().get(XaSecureHadoopConstants.AUDITLOG_REPOSITORY_NAME_PROP);
 	
 	private XaStormAccessVerifier xaStormVerifier = XaStormAccessVerifierFactory.getInstance()
;
-	
+
+	static {
+		XaSecureConfiguration.getInstance().initAudit(AuditProviderFactory.ApplicationType.Storm);
+	}
+
+
 	/**
      * permit() method is invoked for each incoming Thrift request.
      * @param context request context includes info about 


Mime
View raw message