ranger-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From omal...@apache.org
Subject [43/44] ARGUS-1. Initial code commit (Selvamohan Neethiraj via omalley)
Date Thu, 14 Aug 2014 20:50:54 GMT
http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/7defc061/agents-audit/src/main/java/com/xasecure/audit/model/HiveAuditEvent.java
----------------------------------------------------------------------
diff --git a/agents-audit/src/main/java/com/xasecure/audit/model/HiveAuditEvent.java b/agents-audit/src/main/java/com/xasecure/audit/model/HiveAuditEvent.java
new file mode 100644
index 0000000..f064481
--- /dev/null
+++ b/agents-audit/src/main/java/com/xasecure/audit/model/HiveAuditEvent.java
@@ -0,0 +1,99 @@
+package com.xasecure.audit.model;
+
+import java.util.Date;
+
+import com.xasecure.audit.provider.AuditProvider;
+
+public class HiveAuditEvent extends AuditEventBase {
+	protected String resourcePath;
+	protected String resourceType;
+	protected String requestData;
+
+	public HiveAuditEvent() {
+	}
+
+	public HiveAuditEvent(String agentId,
+						  String user,
+						  Date   eventTime,
+						  long   policyId,
+						  String accessType,
+						  short  accessResult,
+						  String resultReason,
+						  String aclEnforcer,
+						  int repositoryType,
+						  String repositoryName,
+						  String sessionId,
+						  String clientType,
+						  String clientIP,
+						  String resourcePath,
+						  String resourceType,
+						  String requestData,
+						  String action) {
+		super(agentId, user, eventTime, policyId, accessType, accessResult, resultReason, aclEnforcer, repositoryType, repositoryName, sessionId, clientType, clientIP, action);
+		
+		this.resourcePath = resourcePath;
+		this.resourceType = resourceType;
+		this.requestData  = requestData;
+	}
+
+	/**
+	 * @return the resourcePath
+	 */
+	public String getResourcePath() {
+		return resourcePath;
+	}
+
+	/**
+	 * @param resourcePath the resourcePath to set
+	 */
+	public void setResourcePath(String resourcePath) {
+		this.resourcePath = resourcePath;
+	}
+
+	/**
+	 * @return the resourceType
+	 */
+	public String getResourceType() {
+		return resourceType;
+	}
+
+	/**
+	 * @param resourceType the resourceType to set
+	 */
+	public void setResourceType(String resourceType) {
+		this.resourceType = resourceType;
+	}
+
+	/**
+	 * @return the requestData
+	 */
+	public String getRequestData() {
+		return trim(requestData,MAX_REQUEST_DATA_FIELD_SIZE);
+	}
+
+	/**
+	 * @param requestData the requestData to set
+	 */
+	public void setRequestData(String requestData) {
+		this.requestData = requestData;
+	}
+
+	@Override
+	public void logEvent(AuditProvider provider) {
+		provider.log(this);
+	}
+
+	@Override
+	protected StringBuilder toString(StringBuilder sb) {
+		sb.append("HiveAuditEvent{");
+		
+		super.toString(sb)
+		     .append("resourcePath=").append(resourcePath).append(FIELD_SEPARATOR)
+		     .append("resourceType=").append(resourceType).append(FIELD_SEPARATOR)
+		     .append("requestData=").append(requestData).append(FIELD_SEPARATOR);
+		
+		sb.append("}");
+		
+		return sb;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/7defc061/agents-audit/src/main/java/com/xasecure/audit/model/KnoxAuditEvent.java
----------------------------------------------------------------------
diff --git a/agents-audit/src/main/java/com/xasecure/audit/model/KnoxAuditEvent.java b/agents-audit/src/main/java/com/xasecure/audit/model/KnoxAuditEvent.java
new file mode 100644
index 0000000..56be88c
--- /dev/null
+++ b/agents-audit/src/main/java/com/xasecure/audit/model/KnoxAuditEvent.java
@@ -0,0 +1,91 @@
+package com.xasecure.audit.model;
+
+import java.util.Date;
+
+import com.xasecure.audit.provider.AuditProvider;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+public class KnoxAuditEvent extends AuditEventBase {
+	protected String resourcePath;
+	protected String resourceType;
+	protected String requestData;
+
+	public KnoxAuditEvent() {
+	}
+
+	/**
+	 * @return the resourcePath
+	 */
+	public String getResourcePath() {
+		return resourcePath;
+	}
+
+	/**
+	 * @param resourcePath the resourcePath to set
+	 */
+	public void setResourcePath(String resourcePath) {
+		this.resourcePath = resourcePath;
+	}
+
+	/**
+	 * @return the resourceType
+	 */
+	public String getResourceType() {
+		return resourceType;
+	}
+
+	/**
+	 * @param resourceType the resourceType to set
+	 */
+	public void setResourceType(String resourceType) {
+		this.resourceType = resourceType;
+	}
+	
+	/**
+	 * @return the requestData
+	 */
+	public String getRequestData() {
+		return trim(requestData, MAX_REQUEST_DATA_FIELD_SIZE);
+	}
+
+	/**
+	 * @param requestData
+	 *            the requestData to set
+	 */
+	public void setRequestData(String requestData) {
+		this.requestData = requestData;
+	}
+
+	@Override
+	public void logEvent(AuditProvider provider) {
+		provider.log(this);
+	}
+
+	@Override
+	protected StringBuilder toString(StringBuilder sb) {
+		sb.append("KnoxAuditEvent{");
+
+		super.toString(sb).append("requestData=")
+				.append(requestData).append(FIELD_SEPARATOR);
+
+		sb.append("}");
+
+		return sb;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/7defc061/agents-audit/src/main/java/com/xasecure/audit/provider/AsyncAuditProvider.java
----------------------------------------------------------------------
diff --git a/agents-audit/src/main/java/com/xasecure/audit/provider/AsyncAuditProvider.java b/agents-audit/src/main/java/com/xasecure/audit/provider/AsyncAuditProvider.java
new file mode 100644
index 0000000..08f2982
--- /dev/null
+++ b/agents-audit/src/main/java/com/xasecure/audit/provider/AsyncAuditProvider.java
@@ -0,0 +1,322 @@
+package com.xasecure.audit.provider;
+
+import java.util.Date;
+import java.util.LinkedList;
+import java.util.Queue;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.xasecure.audit.model.AuditEventBase;
+import com.xasecure.audit.model.HBaseAuditEvent;
+import com.xasecure.audit.model.HdfsAuditEvent;
+import com.xasecure.audit.model.HiveAuditEvent;
+
+public class AsyncAuditProvider extends MultiDestAuditProvider implements
+		Runnable {
+
+	private static final Log LOG = LogFactory.getLog(AsyncAuditProvider.class);
+
+	private static int sThreadCount = 0;
+
+	private Queue<AuditEventBase> mQueue = new LinkedList<AuditEventBase>();
+	private Thread mThread = null;
+	private boolean mStopThread = false;
+	private int mMaxQueueSize = -1;
+	private int mResumeQueueSize = 0;
+	private int mMaxFlushInterval = -1;
+	private long mFirstDropTime = 0;
+	private int mDropCount = 0;
+
+	// Summary of logs handled
+	private long lifeTimeLogCount = 0; // Total count, including drop count
+	private long lifeTimeDropCount = 0;
+	private long intervalLogCount = 0;
+	private long intervalDropCount = 0;
+	private long lastIntervalLogTime = System.currentTimeMillis();
+	private int intervalLogDurationMS = 60000;
+
+	public AsyncAuditProvider() {
+		LOG.info("AsyncAuditProvider: creating..");
+	}
+
+	public AsyncAuditProvider(AuditProvider provider) {
+		LOG.info("AsyncAuditProvider: creating..");
+
+		addAuditProvider(provider);
+	}
+
+	public int getIntervalLogDurationMS() {
+		return intervalLogDurationMS;
+	}
+
+	public void setIntervalLogDurationMS(int intervalLogDurationMS) {
+		this.intervalLogDurationMS = intervalLogDurationMS;
+	}
+
+	public void setMaxQueueSize(int maxQueueSize) {
+		mMaxQueueSize = maxQueueSize > 0 ? maxQueueSize : Integer.MAX_VALUE;
+	}
+
+	public void setMaxFlushInterval(int maxFlushInterval) {
+		mMaxFlushInterval = maxFlushInterval;
+	}
+
+	public void setResumeQueueSize(int resumeQueueSize) {
+		mResumeQueueSize = resumeQueueSize > 0 ? resumeQueueSize : 0;
+	}
+
+	@Override
+	public void log(HBaseAuditEvent event) {
+		LOG.debug("AsyncAuditProvider.log(HBaseAuditEvent)");
+
+		queueEvent(event);
+	}
+
+	@Override
+	public void log(HdfsAuditEvent event) {
+		LOG.debug("AsyncAuditProvider.log(HdfsAuditEvent)");
+
+		queueEvent(event);
+	}
+
+	@Override
+	public void log(HiveAuditEvent event) {
+		LOG.debug("AsyncAuditProvider.log(HiveAuditEvent)");
+
+		queueEvent(event);
+	}
+
+	@Override
+	public void start() {
+		mThread = new Thread(this, "AsyncAuditProvider" + (++sThreadCount));
+
+		mThread.setDaemon(true);
+		mThread.start();
+
+		super.start();
+	}
+
+	@Override
+	public void stop() {
+		mStopThread = true;
+
+		synchronized (mQueue) {
+			mQueue.notify();
+		}
+
+		try {
+			mThread.join();
+		} catch (InterruptedException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+
+		super.stop();
+	}
+
+	@Override
+	public void waitToComplete() {
+		waitToComplete(0);
+
+		super.waitToComplete();
+	}
+
+	@Override
+	public void run() {
+		LOG.info("==> AsyncAuditProvider.run()");
+
+		try {
+			while (!mStopThread) {
+				AuditEventBase event = dequeueEvent();
+
+				if (event != null) {
+					logEvent(event);
+				} else {
+					flush();
+				}
+			}
+
+			flush();
+		} catch (Exception excp) {
+			LOG.error("AsyncAuditProvider.run()", excp);
+		}
+
+		LOG.info("<== AsyncAuditProvider.run()");
+	}
+
+	private void queueEvent(AuditEventBase event) {
+		synchronized (mQueue) {
+
+			// Running this within synchronized block to avoid multiple
+			// logs from different threads
+			// Running this upfront so the log interval is fixed
+
+			// Log summary if required
+			logSummaryIfRequired();
+
+			// Increase counts
+			lifeTimeLogCount++;
+			intervalLogCount++;
+
+			int maxQueueSize = mMaxQueueSize;
+
+			// if we are currently dropping, don't resume until the queue size
+			// goes to mResumeQueueSize
+			if (mDropCount > 0) {
+				maxQueueSize = (mResumeQueueSize < maxQueueSize ? mResumeQueueSize
+						: (int) (maxQueueSize / 100.0 * 80)) + 1;
+			}
+
+			if (mQueue.size() < maxQueueSize) {
+				mQueue.add(event);
+				mQueue.notify();
+
+				if (mDropCount > 0) {
+					String pauseDuration = getTimeDiffStr(System.currentTimeMillis(),
+							mFirstDropTime);
+
+					LOG.warn("AsyncAuditProvider: resumes after dropping "
+							+ mDropCount + " audit logs in past "
+							+ pauseDuration);
+
+					mDropCount = 0;
+					mFirstDropTime = 0;
+				}
+			} else {
+				if (mDropCount == 0) {
+					mFirstDropTime = System.currentTimeMillis();
+	
+					LOG.warn("AsyncAuditProvider: queue size is at max ("
+							+ mMaxQueueSize
+							+ "); further audit logs will be dropped until queue clears up");
+				}
+
+				mDropCount++;
+				lifeTimeDropCount++;
+				intervalDropCount++;
+			}
+
+		}
+	}
+
+	private AuditEventBase dequeueEvent() {
+		synchronized (mQueue) {
+			while (mQueue.isEmpty()) {
+				if (mStopThread) {
+					return null;
+				}
+				try {
+					// Log summary if required
+					logSummaryIfRequired();
+
+					if (mMaxFlushInterval > 0 && isFlushPending()) {
+						long timeTillNextFlush = getTimeTillNextFlush();
+
+						if (timeTillNextFlush <= 0) {
+							return null; // force flush
+						}
+
+						mQueue.wait(timeTillNextFlush);
+					} else {
+						// Let's wake up for summary logging
+						long waitTime = intervalLogDurationMS
+								- (System.currentTimeMillis() - lastIntervalLogTime);
+						waitTime = waitTime <= 0 ? intervalLogDurationMS
+								: waitTime;
+						mQueue.wait(waitTime);
+					}
+				} catch (InterruptedException excp) {
+					LOG.error("AsyncAuditProvider.dequeueEvent()", excp);
+
+					return null;
+				}
+			}
+
+			AuditEventBase ret = mQueue.remove();
+
+			return ret;
+		}
+	}
+
+	private void logSummaryIfRequired() {
+		if (System.currentTimeMillis() - lastIntervalLogTime > intervalLogDurationMS) {
+			// Log interval and life time summary
+
+			if (intervalLogCount > 0) {
+				LOG.info("AsyncAuditProvider: Interval="
+						+ formatTimeForLog(intervalLogDurationMS) + ", logs="
+						+ intervalLogCount + ", dropped=" + intervalDropCount);
+				LOG.info("AsyncAuditProvider: Process Lifetime, logs="
+						+ lifeTimeLogCount + ", dropped=" + lifeTimeDropCount);
+			}
+			lastIntervalLogTime = System.currentTimeMillis();
+			intervalLogCount = 0;
+			intervalDropCount = 0;
+		}
+	}
+
+	private boolean isEmpty() {
+		synchronized (mQueue) {
+			return mQueue.isEmpty();
+		}
+	}
+
+	private void waitToComplete(long maxWaitSeconds) {
+		LOG.debug("==> AsyncAuditProvider.waitToComplete()");
+
+		for (long waitTime = 0; !isEmpty()
+				&& (maxWaitSeconds <= 0 || maxWaitSeconds > waitTime); waitTime++) {
+			try {
+				Thread.sleep(1000);
+			} catch (Exception excp) {
+				// ignore
+			}
+		}
+
+		LOG.debug("<== AsyncAuditProvider.waitToComplete()");
+	}
+
+	private String getTimeDiffStr(long time1, long time2) {
+		long timeInMs = Math.abs(time1 - time2);
+		return formatTimeForLog(timeInMs);
+	}
+
+	private String formatTimeForLog(long timeInMs) {
+		long hours = timeInMs / (60 * 60 * 1000);
+		long minutes = (timeInMs / (60 * 1000)) % 60;
+		long seconds = (timeInMs % (60 * 1000)) / 1000;
+		long mSeconds = (timeInMs % (1000));
+
+		if (hours > 0)
+			return String.format("%02d:%02d:%02d.%03d hours", hours, minutes,
+					seconds, mSeconds);
+		else if (minutes > 0)
+			return String.format("%02d:%02d.%03d minutes", minutes, seconds,
+					mSeconds);
+		else if (seconds > 0)
+			return String.format("%02d.%03d seconds", seconds, mSeconds);
+		else
+			return String.format("%03d milli-seconds", mSeconds);
+	}
+
+	private long getTimeTillNextFlush() {
+		long timeTillNextFlush = mMaxFlushInterval;
+
+		if (mMaxFlushInterval > 0) {
+			long lastFlushTime = getLastFlushTime();
+
+			if (lastFlushTime != 0) {
+				long timeSinceLastFlush = System.currentTimeMillis()
+						- lastFlushTime;
+
+				if (timeSinceLastFlush >= mMaxFlushInterval)
+					timeTillNextFlush = 0;
+				else
+					timeTillNextFlush = mMaxFlushInterval - timeSinceLastFlush;
+			}
+		}
+
+		return timeTillNextFlush;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/7defc061/agents-audit/src/main/java/com/xasecure/audit/provider/AuditProvider.java
----------------------------------------------------------------------
diff --git a/agents-audit/src/main/java/com/xasecure/audit/provider/AuditProvider.java b/agents-audit/src/main/java/com/xasecure/audit/provider/AuditProvider.java
new file mode 100644
index 0000000..8b04497
--- /dev/null
+++ b/agents-audit/src/main/java/com/xasecure/audit/provider/AuditProvider.java
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.xasecure.audit.provider;
+
+import com.xasecure.audit.model.HBaseAuditEvent;
+import com.xasecure.audit.model.HdfsAuditEvent;
+import com.xasecure.audit.model.HiveAuditEvent;
+import com.xasecure.audit.model.KnoxAuditEvent;
+
+public interface AuditProvider {
+    public void log(HBaseAuditEvent event);
+    public void log(HdfsAuditEvent event);
+    public void log(HiveAuditEvent event);
+    public void log(KnoxAuditEvent event);
+    
+    public void start();
+    public void stop();
+    public void waitToComplete();
+
+	public boolean isFlushPending();
+	public long    getLastFlushTime();
+    public void    flush();
+}

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/7defc061/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
new file mode 100644
index 0000000..7bed0f7
--- /dev/null
+++ b/agents-audit/src/main/java/com/xasecure/audit/provider/AuditProviderFactory.java
@@ -0,0 +1,289 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.xasecure.audit.provider;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.xasecure.authorization.hadoop.utils.XaSecureCredentialProvider;
+
+
+/*
+ * TODO:
+ * 1) Flag to enable/disable audit logging
+ * 2) Failed path to be recorded
+ * 3) Repo name, repo type from configuration
+ */
+
+public class AuditProviderFactory {
+
+	private static final Log LOG = LogFactory.getLog(AuditProviderFactory.class);
+
+	private static final String AUDIT_JPA_CONFIG_PROP_PREFIX        = "xasecure.audit.jpa.";
+	private static final String AUDIT_IS_ENABLED_PROP               = "xasecure.audit.is.enabled" ;
+	private static final String AUDIT_LOG4J_IS_ENABLED_PROP         = "xasecure.audit.log4j.is.enabled" ;
+	private static final String AUDIT_LOG4J_IS_ASYNC_PROP           = "xasecure.audit.log4j.is.async" ;
+	private static final String AUDIT_LOG4J_MAX_QUEUE_SIZE_PROP     = "xasecure.audit.log4j.async.max.queue.size" ;
+	private static final String AUDIT_LOG4J_MAX_FLUSH_INTERVAL_PROP = "xasecure.audit.log4j.async.max.flush.interval.ms";
+	private static final String AUDIT_DB_IS_ENABLED_PROP            = "xasecure.audit.db.is.enabled" ;
+	private static final String AUDIT_DB_IS_ASYNC_PROP              = "xasecure.audit.db.is.async" ;
+	private static final String AUDIT_DB_MAX_QUEUE_SIZE_PROP        = "xasecure.audit.db.async.max.queue.size" ;
+	private static final String AUDIT_DB_MAX_FLUSH_INTERVAL_PROP    = "xasecure.audit.db.async.max.flush.interval.ms";
+	private static final String AUDIT_DB_RESUME_QUEUE_SIZE__PROP    = "xasecure.audit.db.async.resume.queue.size" ;
+	private static final String AUDIT_DB_BATCH_SIZE_PROP            = "xasecure.audit.db.batch.size" ;
+	private static final String AUDIT_DB_CREDENTIAL_PROVIDER_FILE   = "xasecure.audit.credential.provider.file";
+	private static final String AUDIT_DB_CREDENTIAL_PROVIDER_ALIAS	= "auditDBCred";
+	private static final String AUDIT_JPA_JDBC_PASSWORD  			= "javax.persistence.jdbc.password";
+
+	private static AuditProviderFactory sFactory;
+
+	private AuditProvider mProvider = null;
+
+	private AuditProviderFactory() {
+		LOG.info("AuditProviderFactory: creating..");
+
+		mProvider = getDefaultProvider();
+	}
+
+	public static AuditProviderFactory getInstance() {
+		if(sFactory == null) {
+			synchronized(AuditProviderFactory.class) {
+				if(sFactory == null) {
+					sFactory = new AuditProviderFactory();
+				}
+			}
+		}
+
+		return sFactory;
+	}
+
+	public static AuditProvider getAuditProvider() {
+		return AuditProviderFactory.getInstance().getProvider();
+	}
+	
+	public AuditProvider getProvider() {
+		return mProvider;
+	}
+
+	public void init(Properties props) {
+		LOG.info("AuditProviderFactory: initializing..");
+		
+		boolean isEnabled             = getBooleanProperty(props, AUDIT_IS_ENABLED_PROP, false);
+		boolean isAuditToLog4jEnabled = getBooleanProperty(props, AUDIT_LOG4J_IS_ENABLED_PROP, false);
+		boolean isAuditToLog4jAsync   = getBooleanProperty(props, AUDIT_LOG4J_IS_ASYNC_PROP, false);
+		boolean isAuditToDbEnabled    = getBooleanProperty(props, AUDIT_DB_IS_ENABLED_PROP, false);
+		boolean isAuditToDbAsync      = getBooleanProperty(props, AUDIT_DB_IS_ASYNC_PROP, false);
+		
+		List<AuditProvider> providers = new ArrayList<AuditProvider>();
+
+
+		if(!isEnabled || (!isAuditToDbEnabled && !isAuditToLog4jEnabled)) {
+			LOG.info("AuditProviderFactory: Audit not enabled..");
+			
+			mProvider = getDefaultProvider();
+
+			return;
+		}
+		
+		if(isAuditToDbEnabled) {
+			
+						
+			Map<String, String> jpaInitProperties = getJpaProperties(props);
+	
+			LOG.info("AuditProviderFactory: found " + jpaInitProperties.size() + " Audit JPA properties");
+	
+			int dbBatchSize = getIntProperty(props, AUDIT_DB_BATCH_SIZE_PROP, 1000);
+			
+			if(! isAuditToDbAsync) {
+				dbBatchSize = 1; // Batching not supported in sync mode; need to address multiple threads making audit calls
+			}
+
+			DbAuditProvider dbProvider = new DbAuditProvider(jpaInitProperties, dbBatchSize);
+			
+			if(isAuditToDbAsync) {
+				AsyncAuditProvider asyncProvider = new AsyncAuditProvider();
+
+				int maxQueueSize     = getIntProperty(props, AUDIT_DB_MAX_QUEUE_SIZE_PROP, -1);
+				int maxFlushInterval = getIntProperty(props, AUDIT_DB_MAX_FLUSH_INTERVAL_PROP, -1);
+				int resumeQueueSize  = getIntProperty(props, AUDIT_DB_RESUME_QUEUE_SIZE__PROP, 0);
+
+
+				asyncProvider.setMaxQueueSize(maxQueueSize);
+				asyncProvider.setMaxFlushInterval(maxFlushInterval);
+				asyncProvider.setResumeQueueSize(resumeQueueSize);
+				
+				asyncProvider.addAuditProvider(dbProvider);
+				
+				providers.add(asyncProvider);
+			} else {
+				providers.add(dbProvider);
+			}
+		}
+
+		if(isAuditToLog4jEnabled) {
+			Log4jAuditProvider log4jProvider = new Log4jAuditProvider();
+			
+			if(isAuditToLog4jAsync) {
+				AsyncAuditProvider asyncProvider = new AsyncAuditProvider();
+
+				int maxQueueSize     = getIntProperty(props, AUDIT_LOG4J_MAX_QUEUE_SIZE_PROP, -1);
+				int maxFlushInterval = getIntProperty(props, AUDIT_LOG4J_MAX_FLUSH_INTERVAL_PROP, -1);
+
+				asyncProvider.setMaxQueueSize(maxQueueSize);
+				asyncProvider.setMaxFlushInterval(maxFlushInterval);
+				
+				asyncProvider.addAuditProvider(log4jProvider);
+				
+				providers.add(asyncProvider);
+			} else {
+				providers.add(log4jProvider);
+			}
+		}
+
+		if(providers.size() == 0) {
+			mProvider = getDefaultProvider();
+		} else if(providers.size() == 1) {
+			mProvider = providers.get(0);
+		} else {
+			MultiDestAuditProvider multiDestProvider = new MultiDestAuditProvider();
+			
+			multiDestProvider.addAuditProviders(providers);
+			
+			mProvider = multiDestProvider;
+		}
+		
+		mProvider.start();
+
+		JVMShutdownHook jvmShutdownHook = new JVMShutdownHook(mProvider);
+
+	    Runtime.getRuntime().addShutdownHook(jvmShutdownHook);
+	}
+	
+	private Map<String, String> getJpaProperties(Properties props) {
+		Map<String, String> jpaInitProperties = new HashMap<String, String>();
+		
+		for(String key : props.stringPropertyNames()) {
+			if(key == null) {
+				continue;
+			}
+			
+			String val = props.getProperty(key);
+			
+			if(key.startsWith(AuditProviderFactory.AUDIT_JPA_CONFIG_PROP_PREFIX)) {
+				key = key.substring(AuditProviderFactory.AUDIT_JPA_CONFIG_PROP_PREFIX.length());
+
+				if(key == null) {
+					continue;
+				}
+				
+				jpaInitProperties.put(key, val);
+			}
+		}
+
+		String jdbcPassword = getCredentialString(getStringProperty(props,AUDIT_DB_CREDENTIAL_PROVIDER_FILE), AUDIT_DB_CREDENTIAL_PROVIDER_ALIAS);
+
+		if(jdbcPassword != null && !jdbcPassword.isEmpty()) {
+			jpaInitProperties.put(AUDIT_JPA_JDBC_PASSWORD, jdbcPassword);
+		}
+
+            
+		return jpaInitProperties;
+	}
+	
+	private boolean getBooleanProperty(Properties props, String propName, boolean defValue) {
+		boolean ret = defValue;
+
+		if(props != null && propName != null) {
+			String val = props.getProperty(propName);
+			
+			if(val != null) {
+				ret = Boolean.valueOf(val);
+			}
+		}
+		
+		return ret;
+	}
+	
+	private int getIntProperty(Properties props, String propName, int defValue) {
+		int ret = defValue;
+
+		if(props != null && propName != null) {
+			String val = props.getProperty(propName);
+			
+			if(val != null) {
+				ret = Integer.parseInt(val);
+			}
+		}
+		
+		return ret;
+	}
+	
+	
+	private String getStringProperty(Properties props, String propName) {
+	
+		String ret = null;
+		if(props != null && propName != null) {
+			String val = props.getProperty(propName);
+			if ( val != null){
+				ret = val;
+			}
+			
+		}
+		
+		return ret;
+	}
+	
+	private AuditProvider getDefaultProvider() {
+		return new DummyAuditProvider();
+	}
+
+	private static class JVMShutdownHook extends Thread {
+		AuditProvider mProvider;
+
+		public JVMShutdownHook(AuditProvider provider) {
+			mProvider = provider;
+		}
+
+		public void run() {
+			mProvider.waitToComplete();
+			mProvider.stop();
+	    }
+	  }
+
+	
+	private String getCredentialString(String url,String alias) {
+		String ret = null;
+
+		if(url != null && alias != null) {
+			char[] cred = XaSecureCredentialProvider.getInstance().getCredentialString(url,alias);
+
+			if ( cred != null ) {
+				ret = new String(cred);	
+			}
+		}
+		
+		return ret;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/7defc061/agents-audit/src/main/java/com/xasecure/audit/provider/DbAuditProvider.java
----------------------------------------------------------------------
diff --git a/agents-audit/src/main/java/com/xasecure/audit/provider/DbAuditProvider.java b/agents-audit/src/main/java/com/xasecure/audit/provider/DbAuditProvider.java
new file mode 100644
index 0000000..106394b
--- /dev/null
+++ b/agents-audit/src/main/java/com/xasecure/audit/provider/DbAuditProvider.java
@@ -0,0 +1,302 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.xasecure.audit.provider;
+
+import java.util.ArrayList;
+import java.util.Map;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.EntityTransaction;
+import javax.persistence.Persistence;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.xasecure.audit.dao.DaoManager;
+import com.xasecure.audit.dao.XAHBaseAuditEventDao;
+import com.xasecure.audit.dao.XAHdfsAuditEventDao;
+import com.xasecure.audit.dao.XAHiveAuditEventDao;
+import com.xasecure.audit.dao.XAKnoxAuditEventDao;
+import com.xasecure.audit.entity.XXHBaseAuditEvent;
+import com.xasecure.audit.entity.XXHdfsAuditEvent;
+import com.xasecure.audit.entity.XXHiveAuditEvent;
+import com.xasecure.audit.entity.XXKnoxAuditEvent;
+import com.xasecure.audit.model.AuditEventBase;
+import com.xasecure.audit.model.HBaseAuditEvent;
+import com.xasecure.audit.model.HdfsAuditEvent;
+import com.xasecure.audit.model.HiveAuditEvent;
+import com.xasecure.audit.model.KnoxAuditEvent;
+
+
+/*
+ * NOTE:
+ * - Instances of this class are not thread-safe.
+ */
+public class DbAuditProvider implements AuditProvider {
+
+	private static final Log LOG = LogFactory.getLog(DbAuditProvider.class);
+
+	private EntityManagerFactory entityManagerFactory;
+	private DaoManager          daoManager;
+	private XAHBaseAuditEventDao hbaseDao;
+	private XAHdfsAuditEventDao hdfsDao;
+	private XAHiveAuditEventDao hiveDao;
+	private XAKnoxAuditEventDao knoxDao;
+	
+	private int                 mCommitBatchSize  = 1;
+	private long                mLastCommitTime   = 0;
+	private ArrayList<AuditEventBase> mUncommitted = new ArrayList<AuditEventBase>();
+	private Map<String, String> mDbProperties;
+
+	public DbAuditProvider(Map<String, String> properties, int dbBatchSize) {
+		LOG.info("DbAuditProvider: creating..");
+		
+		mDbProperties    = properties;
+		mCommitBatchSize = dbBatchSize < 1 ? 1 : dbBatchSize;
+	}
+
+	@Override
+	public void log(HBaseAuditEvent event) {
+		LOG.debug("DbAuditProvider.log(HBaseAuditEvent)");
+
+		if(preCreate(event)) {
+			hbaseDao.create(new XXHBaseAuditEvent(event));
+			postCreate(event);
+		}
+	}
+
+	@Override
+	public void log(HdfsAuditEvent event) {
+		LOG.debug("DbAuditProvider.log(HdfsAuditEvent)");
+
+		if(preCreate(event)) {
+			hdfsDao.create(new XXHdfsAuditEvent(event));
+			postCreate(event);
+		}
+	}
+
+	@Override
+	public void log(HiveAuditEvent event) {
+		LOG.debug("DbAuditProvider.log(HiveAuditEvent)");
+		
+		if(preCreate(event)) {
+			hiveDao.create(new XXHiveAuditEvent(event));
+			postCreate(event);
+		}
+	}
+	
+	@Override
+	public void log(KnoxAuditEvent event) {
+		LOG.debug("DbAuditProvider.log(KnoxAuditEvent)");
+		
+		if(preCreate(event)) {
+			knoxDao.create(new XXKnoxAuditEvent(event));
+			postCreate(event);
+		}
+	}
+
+	@Override
+	public void start() {
+		LOG.info("DbAuditProvider.start()");
+
+		init();
+	}
+
+	@Override
+	public void stop() {
+		LOG.info("DbAuditProvider.stop()");
+
+		cleanUp();
+	}
+	
+	@Override
+    public void waitToComplete() {
+		LOG.info("DbAuditProvider.waitToComplete()");
+	}
+
+	@Override
+	public boolean isFlushPending() {
+		return mUncommitted.size() > 0;
+	}
+	
+	@Override
+	public long getLastFlushTime() {
+		return mLastCommitTime;
+	}
+
+	@Override
+	public void flush() {
+		if(mUncommitted.size() > 0) {
+			commitTransaction();
+		}
+	}
+
+	private boolean init() {
+		LOG.info("DbAuditProvider: init()");
+
+		try {
+			entityManagerFactory = Persistence.createEntityManagerFactory("xa_server", mDbProperties);
+		} catch(Exception excp) {
+			LOG.error("DbAuditProvider: DB initalization failed", excp);
+
+			entityManagerFactory = null;
+
+			return false;
+		}
+
+   	    daoManager = new DaoManager();
+   	    daoManager.setEntityManagerFactory(entityManagerFactory);
+
+		hbaseDao = daoManager.getXAHBaseAuditEvent();
+		hdfsDao = daoManager.getXAHdfsAuditEvent();
+		hiveDao = daoManager.getXAHiveAuditEvent();
+		knoxDao = daoManager.getXAKnoxAuditEvent();
+
+		return true;
+	}
+	
+	private void cleanUp() {
+		LOG.info("DbAuditProvider: cleanUp()");
+
+		try {
+			clearEntityManager();
+
+			if(entityManagerFactory != null && entityManagerFactory.isOpen()) {
+				entityManagerFactory.close();
+			}
+		} finally {
+			entityManagerFactory = null;
+			daoManager    = null;
+			hbaseDao      = null;
+			hdfsDao       = null;
+			hiveDao       = null;
+		}
+	}
+	
+	private boolean isDbConnected() {
+		EntityManager em = getEntityManager();
+		
+		return em != null && em.isOpen();
+	}
+	
+	private EntityManager getEntityManager() {
+		return daoManager != null ? daoManager.getEntityManager() : null;
+	}
+	
+	private void clearEntityManager() {
+		EntityManager em = getEntityManager();
+		
+		if(em == null) {
+			LOG.info("clearEntityManager(): em is null");
+		} else {
+			em.clear();
+		}
+	}
+	
+	private EntityTransaction getTransaction() {
+		EntityManager em = getEntityManager();
+
+		if(em == null)
+			LOG.info("getTransaction(): em is null");
+
+		return em != null ? em.getTransaction() : null;
+	}
+	
+	private boolean isInTransaction() {
+		EntityTransaction trx = getTransaction();
+
+		return trx != null && trx.isActive();
+	}
+
+	private boolean beginTransaction() {
+		EntityTransaction trx = getTransaction();
+		
+		if(trx != null && !trx.isActive()) {
+			trx.begin();
+		}
+
+		if(trx == null) {
+			LOG.error("beginTransaction(): trx is null");
+		}
+		
+		return trx != null;
+	}
+
+	private void commitTransaction() {
+		EntityTransaction trx = getTransaction();
+
+		try {
+			if(trx != null && trx.isActive()) {
+				trx.commit();
+			} else {
+				if(trx == null) {
+					LOG.error("commitTransaction(): trx is null. Clearing " + mUncommitted.size() + " uncommitted logs");
+				}
+				else {
+					LOG.error("commitTransaction(): trx is not active. Clearing " + mUncommitted.size() + " uncommitted logs");
+				}
+
+				cleanUp(); // so that next insert will try to init()
+			}
+		} catch(Exception excp) {
+			LOG.error("commitTransaction(): error while committing " + mUncommitted.size() + " log(s)", excp);
+			for(AuditEventBase event : mUncommitted) {
+				LOG.error("failed to log event { " + event.toString() + " }");
+			}
+
+			cleanUp(); // so that next insert will try to init()
+		} finally {
+			mLastCommitTime = System.currentTimeMillis();
+			mUncommitted.clear();
+
+			clearEntityManager();
+		}
+	}
+	
+	private boolean preCreate(AuditEventBase event) {
+		boolean ret = true;
+
+		if(!isDbConnected()) {
+			LOG.error("DbAuditProvider: not connected to DB. Retrying..");
+
+			ret = init();
+		}
+
+		if(ret) {
+			if(! isInTransaction()) {
+				ret = beginTransaction();
+			}
+		}
+		
+		if(!ret) {
+			LOG.error("failed to log event { " + event.toString() + " }");
+		}
+		
+		return ret;
+	}
+	
+	private void postCreate(AuditEventBase event) {
+		mUncommitted.add(event);
+
+		if((mCommitBatchSize == 1) || ((mUncommitted.size() % mCommitBatchSize) == 0)) {
+			flush();
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/7defc061/agents-audit/src/main/java/com/xasecure/audit/provider/DummyAuditProvider.java
----------------------------------------------------------------------
diff --git a/agents-audit/src/main/java/com/xasecure/audit/provider/DummyAuditProvider.java b/agents-audit/src/main/java/com/xasecure/audit/provider/DummyAuditProvider.java
new file mode 100644
index 0000000..6ea8fc7
--- /dev/null
+++ b/agents-audit/src/main/java/com/xasecure/audit/provider/DummyAuditProvider.java
@@ -0,0 +1,77 @@
+package com.xasecure.audit.provider;
+
+import com.xasecure.audit.model.HBaseAuditEvent;
+import com.xasecure.audit.model.HdfsAuditEvent;
+import com.xasecure.audit.model.HiveAuditEvent;
+import com.xasecure.audit.model.KnoxAuditEvent;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+public class DummyAuditProvider implements AuditProvider {
+
+	@Override
+	public void log(HBaseAuditEvent event) {
+		// intentionally left empty
+	}
+
+	@Override
+	public void log(HdfsAuditEvent event) {
+		// intentionally left empty
+	}
+
+	@Override
+	public void log(HiveAuditEvent event) {
+		// intentionally left empty
+	}
+
+	@Override
+	public void log(KnoxAuditEvent event) {
+		// intentionally left empty
+	}
+	
+	@Override
+	public void start() {
+		// intentionally left empty
+	}
+
+	@Override
+	public void stop() {
+		// intentionally left empty
+	}
+
+	@Override
+	public void waitToComplete() {
+		// intentionally left empty
+	}
+
+	@Override
+	public boolean isFlushPending() {
+		return false;
+	}
+	
+	@Override
+	public long getLastFlushTime() {
+		return 0;
+	}
+
+	@Override
+	public void flush() {
+		// intentionally left empty
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/7defc061/agents-audit/src/main/java/com/xasecure/audit/provider/Log4jAuditProvider.java
----------------------------------------------------------------------
diff --git a/agents-audit/src/main/java/com/xasecure/audit/provider/Log4jAuditProvider.java b/agents-audit/src/main/java/com/xasecure/audit/provider/Log4jAuditProvider.java
new file mode 100644
index 0000000..8350073
--- /dev/null
+++ b/agents-audit/src/main/java/com/xasecure/audit/provider/Log4jAuditProvider.java
@@ -0,0 +1,101 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.xasecure.audit.provider;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.xasecure.audit.model.HBaseAuditEvent;
+import com.xasecure.audit.model.HdfsAuditEvent;
+import com.xasecure.audit.model.HiveAuditEvent;
+import com.xasecure.audit.model.KnoxAuditEvent;
+
+
+public class Log4jAuditProvider implements AuditProvider {
+
+	private static final Log LOG      = LogFactory.getLog(Log4jAuditProvider.class);
+	private static final Log AUDITLOG = LogFactory.getLog("xaaudit." + Log4jAuditProvider.class);
+
+
+	public Log4jAuditProvider() {
+		LOG.info("Log4jAuditProvider: creating..");
+	}
+
+	@Override
+	public void log(HBaseAuditEvent event) {
+		if(! AUDITLOG.isInfoEnabled())
+			return;
+
+		AUDITLOG.info(event.toString());
+	}
+
+	@Override
+	public void log(HdfsAuditEvent event) {
+		if(! AUDITLOG.isInfoEnabled())
+			return;
+
+		AUDITLOG.info(event.toString());
+	}
+
+	@Override
+	public void log(HiveAuditEvent event) {
+		if(! AUDITLOG.isInfoEnabled())
+			return;
+
+		AUDITLOG.info(event.toString());
+	}
+
+	@Override
+	public void log(KnoxAuditEvent event) {
+		if(! AUDITLOG.isInfoEnabled())
+			return;
+
+		AUDITLOG.info(event.toString());
+	}
+	
+	@Override
+	public void start() {
+		// intentionally left empty
+	}
+
+	@Override
+	public void stop() {
+		// intentionally left empty
+	}
+
+	@Override
+    public void waitToComplete() {
+		// intentionally left empty
+	}
+
+	@Override
+	public boolean isFlushPending() {
+		return false;
+	}
+	
+	@Override
+	public long getLastFlushTime() {
+		return 0;
+	}
+
+	@Override
+	public void flush() {
+		// intentionally left empty
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/7defc061/agents-audit/src/main/java/com/xasecure/audit/provider/MultiDestAuditProvider.java
----------------------------------------------------------------------
diff --git a/agents-audit/src/main/java/com/xasecure/audit/provider/MultiDestAuditProvider.java b/agents-audit/src/main/java/com/xasecure/audit/provider/MultiDestAuditProvider.java
new file mode 100644
index 0000000..6646e04
--- /dev/null
+++ b/agents-audit/src/main/java/com/xasecure/audit/provider/MultiDestAuditProvider.java
@@ -0,0 +1,163 @@
+package com.xasecure.audit.provider;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.xasecure.audit.model.AuditEventBase;
+import com.xasecure.audit.model.HBaseAuditEvent;
+import com.xasecure.audit.model.HdfsAuditEvent;
+import com.xasecure.audit.model.HiveAuditEvent;
+import com.xasecure.audit.model.KnoxAuditEvent;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+public class MultiDestAuditProvider implements AuditProvider {
+
+	private static final Log LOG = LogFactory.getLog(MultiDestAuditProvider.class);
+
+	protected List<AuditProvider> mProviders = new ArrayList<AuditProvider>();
+
+
+	public MultiDestAuditProvider() {
+		LOG.info("MultiDestAuditProvider: creating..");
+	}
+
+	public MultiDestAuditProvider(AuditProvider provider) {
+		LOG.info("MultiDestAuditProvider: creating..");
+
+		addAuditProvider(provider);
+	}
+	
+	public void addAuditProvider(AuditProvider provider) {
+		if(provider != null) {
+			LOG.info("MultiDestAuditProvider.addAuditProvider(providerType=" + provider.getClass().getCanonicalName() + ")");
+
+			mProviders.add(provider);
+		}
+	}
+
+	public void addAuditProviders(List<AuditProvider> providers) {
+		if(providers != null) {
+			for(AuditProvider provider : providers) {
+				addAuditProvider(provider);
+			}
+		}
+	}
+
+	@Override
+	public void log(HBaseAuditEvent event) {
+		LOG.debug("MultiDestAuditProvider.log(HBaseAuditEvent)");
+
+		logEvent(event);
+	}
+
+	@Override
+	public void log(HdfsAuditEvent event) {
+		LOG.debug("MultiDestAuditProvider.log(HdfsAuditEvent)");
+
+		logEvent(event);
+	}
+
+	@Override
+	public void log(HiveAuditEvent event) {
+		LOG.debug("MultiDestAuditProvider.log(HiveAuditEvent)");
+
+		logEvent(event);
+	}
+	
+	@Override
+	public void log(KnoxAuditEvent event) {
+		LOG.debug("MultiDestAuditProvider.log(KnoxAuditEvent)");
+
+		logEvent(event);
+	}
+
+	@Override
+	public void start() {
+		for(AuditProvider provider : mProviders) {
+			provider.start();
+		}
+	}
+
+	@Override
+	public void stop() {
+		for(AuditProvider provider : mProviders) {
+			provider.stop();
+		}
+	}
+
+	@Override
+    public void waitToComplete() {
+		for(AuditProvider provider : mProviders) {
+			provider.waitToComplete();
+		}
+	}
+	
+	@Override
+	public boolean isFlushPending() {
+		for(AuditProvider provider : mProviders) {
+			if(provider.isFlushPending()) {
+				return true;
+			}
+		}
+		
+		return false;
+	}
+	
+	@Override
+	public long getLastFlushTime() {
+		long lastFlushTime = 0;
+		for(AuditProvider provider : mProviders) {
+			long flushTime = provider.getLastFlushTime();
+			
+			if(flushTime != 0) {
+				if(lastFlushTime == 0 || lastFlushTime > flushTime) {
+					lastFlushTime = flushTime;
+				}
+			}
+		}
+		
+		return lastFlushTime;
+	}
+	
+	@Override
+	public void flush() {
+		try {
+			for(AuditProvider provider : mProviders) {
+				provider.flush();
+			}
+		} catch(Throwable excp) {
+			LOG.error("AsyncAuditProvider.flush(): failed to flush events", excp);
+		}
+	}
+	
+	protected void logEvent(AuditEventBase event) {
+		try {
+            for(AuditProvider provider : mProviders) {
+                event.logEvent(provider);
+            }
+		} catch(Throwable excp) {
+			LOG.error("failed to log event { " + event.toString() + " }", excp);
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/7defc061/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
new file mode 100644
index 0000000..f31aa66
--- /dev/null
+++ b/agents-audit/src/main/java/com/xasecure/audit/test/TestEvents.java
@@ -0,0 +1,98 @@
+package com.xasecure.audit.test;
+import org.apache.commons.logging.Log;
+import org.apache.log4j.xml.DOMConfigurator;
+import org.apache.commons.logging.LogFactory;
+
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.util.Properties;
+
+import com.xasecure.audit.model.EnumRepositoryType;
+import com.xasecure.audit.model.HBaseAuditEvent;
+import com.xasecure.audit.model.HdfsAuditEvent;
+import com.xasecure.audit.model.HiveAuditEvent;
+import com.xasecure.audit.provider.AuditProvider;
+import com.xasecure.audit.provider.AuditProviderFactory;
+
+public class TestEvents {
+
+	private static final Log LOG = LogFactory.getLog(TestEvents.class);
+
+    public static void main(String[] args) {
+    	DOMConfigurator.configure("log4j.xml");
+
+        LOG.info("==> TestEvents.main()");
+        
+        try {
+        	Properties auditProperties = new Properties();
+        	
+        	String AUDIT_PROPERTIES_FILE = "xasecure-audit.properties";
+        	
+        	File propFile = new File(AUDIT_PROPERTIES_FILE);
+        	
+        	if(propFile.exists()) {
+            	LOG.info("Loading Audit properties file" + AUDIT_PROPERTIES_FILE);
+
+            	auditProperties.load(new FileInputStream(propFile));
+        	} else {
+            	LOG.info("Audit properties file missing: " + AUDIT_PROPERTIES_FILE);
+
+            	auditProperties.setProperty("xasecure.audit.jpa.javax.persistence.jdbc.url", "jdbc:mysql://localhost:3306/xa_db");
+	        	auditProperties.setProperty("xasecure.audit.jpa.javax.persistence.jdbc.user", "xaaudit");
+	        	auditProperties.setProperty("xasecure.audit.jpa.javax.persistence.jdbc.password", "xaaudit");
+	        	auditProperties.setProperty("xasecure.audit.jpa.javax.persistence.jdbc.driver", "com.mysql.jdbc.Driver");
+	
+	        	auditProperties.setProperty("xasecure.audit.is.enabled", "true");
+	        	auditProperties.setProperty("xasecure.audit.log4j.is.enabled", "false");
+	        	auditProperties.setProperty("xasecure.audit.log4j.is.async", "false");
+	        	auditProperties.setProperty("xasecure.audit.log4j.async.max.queue.size", "100000");
+	        	auditProperties.setProperty("xasecure.audit.log4j.async.max.flush.interval.ms", "30000");
+	        	auditProperties.setProperty("xasecure.audit.db.is.enabled", "true");
+	        	auditProperties.setProperty("xasecure.audit.db.is.async", "true");
+	        	auditProperties.setProperty("xasecure.audit.db.async.max.queue.size", "100000");
+	        	auditProperties.setProperty("xasecure.audit.db.async.max.flush.interval.ms", "30000");
+	        	auditProperties.setProperty("xasecure.audit.db.batch.size", "100");
+        	}
+        	
+        	AuditProviderFactory.getInstance().init(auditProperties);
+
+        	AuditProvider provider = AuditProviderFactory.getAuditProvider();
+        	
+        	LOG.info("provider=" + provider.toString());
+        	
+        	String strEventCount = args.length > 0 ? args[0] : auditProperties.getProperty("xasecure.audit.test.event.count");
+        	
+        	int eventCount = (strEventCount == null) ? 1024 : Integer.parseInt(strEventCount);        		
+        	
+        	int count = 0;
+        	for(int i = 0; i < eventCount / 3; i++) {
+	            HBaseAuditEvent hbaseEvent = new HBaseAuditEvent();
+	            hbaseEvent.setRepositoryType(EnumRepositoryType.HBASE);
+
+	            HdfsAuditEvent hdfsEvent = new HdfsAuditEvent();
+	            hdfsEvent.setRepositoryType(EnumRepositoryType.HDFS);
+
+	            HiveAuditEvent hiveEvent = new HiveAuditEvent();
+	            hiveEvent.setRepositoryType(EnumRepositoryType.HIVE);
+
+	            LOG.info("==> TestEvents.main(" + (++count) + "): adding HBaseAuditEvent");
+	            provider.log(hbaseEvent);
+
+	            LOG.info("==> TestEvents.main(" + (++count) + "): adding HdfsAuditEvent");
+	            provider.log(hdfsEvent);
+	
+	            LOG.info("==> TestEvents.main(" + (++count) + "): adding HiveAuditEvent");
+	            provider.log(hiveEvent);
+	            
+	            if(i != 0 && ((i % 100) == 0))
+	            	Thread.sleep(100);
+        	}
+        } catch(Exception excp) {
+            LOG.info(excp.getLocalizedMessage());
+        	excp.printStackTrace();
+        }
+
+        LOG.info("<== TestEvents.main()");
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/7defc061/agents-audit/src/main/resources/META-INF/persistence.xml
----------------------------------------------------------------------
diff --git a/agents-audit/src/main/resources/META-INF/persistence.xml b/agents-audit/src/main/resources/META-INF/persistence.xml
new file mode 100644
index 0000000..80d3fc4
--- /dev/null
+++ b/agents-audit/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
+	<persistence-unit name="xa_server">
+		<class>com.xasecure.audit.entity.XXBaseAuditEvent</class>
+		<class>com.xasecure.audit.entity.XXHBaseAuditEvent</class>
+		<class>com.xasecure.audit.entity.XXHdfsAuditEvent</class>
+		<class>com.xasecure.audit.entity.XXHiveAuditEvent</class>
+		<class>com.xasecure.audit.entity.XXKnoxAuditEvent</class>
+	</persistence-unit>
+</persistence>

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/7defc061/agents-common/pom.xml
----------------------------------------------------------------------
diff --git a/agents-common/pom.xml b/agents-common/pom.xml
new file mode 100644
index 0000000..93b84d4
--- /dev/null
+++ b/agents-common/pom.xml
@@ -0,0 +1,39 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>security_agents.agents-common</groupId>
+  <artifactId>agents-common</artifactId>
+  <name>Common library for Agents</name>
+  <description>Agent Common</description>
+  <packaging>jar</packaging>
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+  <parent>
+     <groupId>com.hortonworks.hadoop.security</groupId>
+     <artifactId>argus</artifactId>
+     <version>3.5.000</version>
+     <relativePath>..</relativePath>
+  </parent>
+  <dependencies>
+    <dependency>
+        <groupId>commons-logging</groupId>
+        <artifactId>commons-logging</artifactId>
+        <version>${commons.logging.version}</version>
+    </dependency>
+    <dependency>
+        <groupId>org.apache.hadoop</groupId>
+        <artifactId>hadoop-common</artifactId>
+        <version>${hadoop-common.version}</version>
+    </dependency>
+    <dependency>
+        <groupId>log4j</groupId>
+        <artifactId>log4j</artifactId>
+        <version>${log4j.version}</version>
+    </dependency>
+    <dependency>
+  	<groupId>security_agents.agents-audit</groupId>
+  	<artifactId>agents-audit</artifactId>
+  	<version>${project.version}</version>
+    </dependency>
+  </dependencies>
+</project>

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/7defc061/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
new file mode 100644
index 0000000..f56f730
--- /dev/null
+++ b/agents-common/src/main/java/com/xasecure/authorization/hadoop/config/XaSecureConfiguration.java
@@ -0,0 +1,139 @@
+/**************************************************************************
+ *                                                                        *
+ * The information in this document is proprietary to XASecure Inc.,      *
+ * It may not be used, reproduced or disclosed without the written        *
+ * approval from the XASecure Inc.,                                       *
+ *                                                                        *
+ * PRIVILEGED AND CONFIDENTIAL XASECURE PROPRIETARY INFORMATION           *
+ *                                                                        *
+ * Copyright (c) 2013 XASecure, Inc.  All rights reserved.                *
+ *                                                                        *
+ *************************************************************************/
+
+ /**
+  *
+  *	@version: 1.0.004
+  *
+  */
+
+package com.xasecure.authorization.hadoop.config;
+
+import java.io.File;
+import java.net.URL;
+import java.util.Properties;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.log4j.Logger;
+
+import com.xasecure.audit.provider.AuditProviderFactory;
+import com.xasecure.authorization.hadoop.constants.XaSecureHadoopConstants;
+
+public class XaSecureConfiguration extends Configuration {
+	
+	private static final Logger LOG = Logger.getLogger(XaSecureConfiguration.class) ;
+	
+	private static XaSecureConfiguration config = null;
+	
+	private XaSecureConfiguration() {
+		super(false) ;
+		
+		//
+		// WorkAround for having all Hadoop Configuration in the CLASSPATH first, even if it is invoked by Hive Engine.
+		// 
+		//   So, we look for "hive-site.xml", if it is available, take the xasecure-audit.xml file from the same location.
+		//   If we do not see "hive-site.xml", we look for "hbase-site.xml", if found, take the xasecure-audit.xml file from the same location.
+		//   If we do not see "hbase-site.xml", we look for "hdfs-site.xml", if found, take the xasecure-audit.xml file from the same location.
+		//   If we do not see, we let the CLASSPATH based search to find xasecure-audit.xml file.
+		
+		
+		URL auditFileLocation = getXAAuditXMLFileLocation() ;
+		
+		if (auditFileLocation != null) {
+			addResource(auditFileLocation) ;
+		}
+		else {
+			addResource(XaSecureHadoopConstants.XASECURE_AUDIT_FILE) ;
+		}
+		addResource(XaSecureHadoopConstants.XASECURE_HDFS_SECURITY_FILE);
+		addResource(XaSecureHadoopConstants.XASECURE_KNOX_SECURITY_FILE);
+		addResource(XaSecureHadoopConstants.XASECURE_HBASE_SECURITY_FILE) ;
+		addResource(XaSecureHadoopConstants.XASECURE_HIVE_SECURITY_FILE) ;
+		addResource(XaSecureHadoopConstants.XASECURE_KEYMGR_FILE) ;
+	}
+
+	public static XaSecureConfiguration getInstance() {
+		if (config == null) {
+			synchronized (XaSecureConfiguration.class) {
+				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) {
+		AuditProviderFactory auditFactory = AuditProviderFactory.getInstance();
+		
+		if(auditFactory == null) {
+			LOG.error("Unable to find the AuditProviderFactory. (null) found") ;
+			return;
+		}
+		
+		Properties props = config.getProps();
+		
+		if(props == null) {
+			return;
+		}
+		
+		auditFactory.init(props);
+	}
+	
+	
+	@SuppressWarnings("deprecation")
+	public  URL getXAAuditXMLFileLocation() {
+		URL ret = null ;
+
+		try {
+			for(String  cfgFile : 	new String[] {  "hive-site.xml",  "hbase-site.xml",  "hdfs-site.xml" } ) {
+				String loc = getFileLocation(cfgFile) ;
+				if (loc != null) {
+					File parentFile = new File(loc).getParentFile() ;
+					ret = new File(parentFile, XaSecureHadoopConstants.XASECURE_AUDIT_FILE).toURL() ;
+					break ;
+				}
+			}
+		}
+		catch(Throwable t) {
+			LOG.error("Unable to locate audit file location." , t) ;
+			ret = null ;
+		}
+		
+		return ret ;
+	}
+	
+	private String getFileLocation(String fileName) {
+		
+		String ret = null ;
+		
+		URL lurl = XaSecureConfiguration.class.getClassLoader().getResource(fileName) ;
+		
+		if (lurl == null ) {
+			lurl = XaSecureConfiguration.class.getClassLoader().getResource("/" + fileName) ;
+		}
+		
+		if (lurl != null) {
+			ret = lurl.getFile() ;
+		}
+		
+		return ret ;
+	}
+	
+}

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/7defc061/agents-common/src/main/java/com/xasecure/authorization/hadoop/constants/XaSecureHadoopConstants.java
----------------------------------------------------------------------
diff --git a/agents-common/src/main/java/com/xasecure/authorization/hadoop/constants/XaSecureHadoopConstants.java b/agents-common/src/main/java/com/xasecure/authorization/hadoop/constants/XaSecureHadoopConstants.java
new file mode 100644
index 0000000..7788ce2
--- /dev/null
+++ b/agents-common/src/main/java/com/xasecure/authorization/hadoop/constants/XaSecureHadoopConstants.java
@@ -0,0 +1,80 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.xasecure.authorization.hadoop.constants;
+
+public class XaSecureHadoopConstants {
+	
+	public static final String XASECURE_AUDIT_FILE          = "xasecure-audit.xml" ; 
+	public static final String XASECURE_HDFS_SECURITY_FILE  = "xasecure-hdfs-security.xml" ; 
+	public static final String XASECURE_KNOX_SECURITY_FILE  = "xasecure-knox-security.xml" ; 
+	public static final String XASECURE_HBASE_SECURITY_FILE = "xasecure-hbase-security.xml" ; 
+	public static final String XASECURE_HIVE_SECURITY_FILE  = "xasecure-hive-security.xml" ; 
+	public static final String XASECURE_POLICYMGR_SSL_FILE  = "xasecure-policymgr-ssl.xml"  ;
+	public static final String XASECURE_KEYMGR_FILE = "xasecure-keymanager.xml" ;
+	
+	public static final String XASECURE_ADD_HDFS_PERMISSION_PROP = "xasecure.add-hadoop-authorization" ;
+	public static final boolean XASECURE_ADD_HDFS_PERMISSION_DEFAULT = false ;
+	public static final String READ_ACCCESS_TYPE = "read";
+	public static final String WRITE_ACCCESS_TYPE = "write";
+	public static final String EXECUTE_ACCCESS_TYPE = "execute";
+
+	public static final String HDFS_ROOT_FOLDER_PATH_ALT = "";
+	public static final String HDFS_ROOT_FOLDER_PATH = "/";
+	
+	public static final String HDFS_ACCESS_VERIFIER_CLASS_NAME_PROP 	= "hdfs.authorization.verifier.classname" ;
+	public static final String HDFS_ACCESS_VERIFIER_CLASS_NAME_DEFAULT_VALUE = "com.xasecure.pdp.hdfs.XASecureAuthorizer" ;	
+
+	public static final String HIVE_ACCESS_VERIFIER_CLASS_NAME_PROP 	= "hive.authorization.verifier.classname" ;
+	public static final String HIVE_ACCESS_VERIFIER_CLASS_NAME_DEFAULT_VALUE = "com.xasecure.pdp.hive.XASecureAuthorizer" ;
+	
+	public static final String KNOX_ACCESS_VERIFIER_CLASS_NAME_PROP 	= "knox.authorization.verifier.classname" ;
+	public static final String KNOX_ACCESS_VERIFIER_CLASS_NAME_DEFAULT_VALUE = "com.xasecure.pdp.knox.XASecureAuthorizer" ;
+
+	public static final String HBASE_ACCESS_VERIFIER_CLASS_NAME_PROP 	= "hbase.authorization.verifier.classname" ;
+	public static final String HBASE_ACCESS_VERIFIER_CLASS_NAME_DEFAULT_VALUE = "com.xasecure.pdp.hbase.XASecureAuthorizer" ;	
+
+	//
+	// Loging constants 
+	//
+	public static final String AUDITLOG_FIELD_DELIMITER_PROP 			= "xasecure.auditlog.fieldDelimiterString";
+	public static final String AUDITLOG_XASECURE_MODULE_ACL_NAME_PROP  	= "xasecure.auditlog.xasecureAcl.name" ;
+	public static final String AUDITLOG_HADOOP_MODULE_ACL_NAME_PROP    	= "xasecure.auditlog.hadoopAcl.name" ;
+	
+	public static final String DEFAULT_LOG_FIELD_DELIMITOR  			= "|" ;
+	public static final String DEFAULT_XASECURE_MODULE_ACL_NAME  		= "xasecure-acl" ;
+	public static final String DEFAULT_HADOOP_MODULE_ACL_NAME    		= "hadoop-acl" ;
+	
+
+	public static final String AUDITLOG_FIELDINFO_VISIBLE_PROP 			= "xasecure.auditlog.fieldInfoVisible" ;
+	public static final boolean DEFAULT_AUDITLOG_FIELDINFO_VISIBLE    	= false ;
+
+	public static final String AUDITLOG_ACCESS_GRANTED_TEXT_PROP 		= "xasecure.auditlog.accessgranted.text" ;
+	public static final String AUDITLOG_ACCESS_DENIED_TEXT_PROP 		= "xasecure.auditlog.accessdenied.text" ;
+
+	public static final String DEFAULT_ACCESS_GRANTED_TEXT 				= "granted" ;
+	public static final String DEFAULT_ACCESS_DENIED_TEXT 				= "denied" ;
+	
+	public static final String AUDITLOG_EMPTY_STRING 					= "" ;
+	
+	public static final String AUDITLOG_HDFS_EXCLUDE_LIST_PROP 			= "xasecure.auditlog.hdfs.excludeusers" ;
+	public static final String AUDITLOG_REPOSITORY_NAME_PROP 			= "xasecure.audit.repository.name" ;
+	public static final String AUDITLOG_IS_ENABLED_PROP 			    = "xasecure.audit.is.enabled" ;
+	
+	public static final String KEYMGR_URL_PROP = "hdfs.keymanager.url" ;
+}

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/7defc061/agents-common/src/main/java/com/xasecure/authorization/utils/StringUtil.java
----------------------------------------------------------------------
diff --git a/agents-common/src/main/java/com/xasecure/authorization/utils/StringUtil.java b/agents-common/src/main/java/com/xasecure/authorization/utils/StringUtil.java
new file mode 100644
index 0000000..d13193b
--- /dev/null
+++ b/agents-common/src/main/java/com/xasecure/authorization/utils/StringUtil.java
@@ -0,0 +1,231 @@
+package com.xasecure.authorization.utils;
+
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.List;
+import java.util.TimeZone;
+
+public class StringUtil {
+
+	public static boolean equals(String str1, String str2) {
+		boolean ret = false;
+
+		if(str1 == null) {
+			ret = str2 == null;
+		} else if(str2 == null) {
+			ret = false;
+		} else {
+			ret = str1.equals(str2);
+		}
+
+		return ret;
+	}
+
+	public static boolean equalsIgnoreCase(String str1, String str2) {
+		boolean ret = false;
+
+		if(str1 == null) {
+			ret = str2 == null;
+		} else if(str2 == null) {
+			ret = false;
+		} else {
+			ret = str1.equalsIgnoreCase(str2);
+		}
+
+		return ret;
+	}
+
+	public static boolean equals(Collection<String> set1, Collection<String> set2) {
+		boolean ret = false;
+
+		if(set1 == null) {
+			ret = set2 == null;
+		} else if(set2 == null) {
+			ret = false;
+		} else if(set1.size() == set2.size()) {
+			ret = set1.containsAll(set2);
+		}
+
+		return ret;
+	}
+
+	public static boolean equalsIgnoreCase(Collection<String> set1, Collection<String> set2) {
+		boolean ret = false;
+
+		if(set1 == null) {
+			ret = set2 == null;
+		} else if(set2 == null) {
+			ret = false;
+		} else if(set1.size() == set2.size()) {
+			int numFound = 0;
+
+			for(String str1 : set1) {
+				boolean str1Found = false;
+
+				for(String str2 : set2) {
+					if(equalsIgnoreCase(str1, str2)) {
+						str1Found = true;
+
+						break;
+					}
+				}
+				
+				if(str1Found) {
+					numFound++;
+				} else {
+					break;
+				}
+			}
+
+			ret = numFound == set1.size();
+		}
+
+		return ret;
+	}
+
+	public static boolean matches(String pattern, String str) {
+		boolean ret = false;
+
+		if(pattern == null || str == null || pattern.isEmpty() || str.isEmpty()) {
+			ret = true;
+		} else {
+			ret = str.matches(pattern);
+		}
+
+		return ret;
+	}
+
+	/*
+	public static boolean matches(Collection<String> patternSet, Collection<String> strSet) {
+		boolean ret = false;
+
+		if(patternSet == null || strSet == null || patternSet.isEmpty() || strSet.isEmpty()) {
+			ret = true;
+		} else {
+			boolean foundUnmatched = false;
+
+			for(String str : strSet) {
+				boolean isMatched = false;
+				for(String pattern : patternSet) {
+					isMatched = str.matches(pattern);
+					
+					if(isMatched) {
+						break;
+					}
+				}
+				
+				foundUnmatched = ! isMatched;
+				
+				if(foundUnmatched) {
+					break;
+				}
+			}
+			
+			ret = !foundUnmatched;
+		}
+
+		return ret;
+	}
+	*/
+
+	public static boolean contains(String[] strArr, String str) {
+		boolean ret = false;
+
+		if(strArr != null && strArr.length > 0 && str != null) {
+			for(String s : strArr) {
+				ret = equals(s, str);
+
+				if(ret) {
+					break;
+				}
+			}
+		}
+
+		return ret;
+	}
+
+	public static boolean containsIgnoreCase(String[] strArr, String str) {
+		boolean ret = false;
+
+		if(strArr != null && strArr.length > 0 && str != null) {
+			for(String s : strArr) {
+				ret = equalsIgnoreCase(s, str);
+				
+				if(ret) {
+					break;
+				}
+			}
+		}
+
+		return ret;
+	}
+
+	public static String toString(Iterable<String> iterable) {
+		String ret = "";
+
+		if(iterable != null) {
+			int count = 0;
+			for(String str : iterable) {
+				if(count == 0)
+					ret = str;
+				else
+					ret += (", " + str);
+				count++;
+			}
+		}
+		
+		return ret;
+	}
+
+	public static String toString(String[] arr) {
+		String ret = "";
+
+		if(arr != null && arr.length > 0) {
+			ret = arr[0];
+			for(int i = 1; i < arr.length; i++) {
+				ret += (", " + arr[i]);
+			}
+		}
+		
+		return ret;
+	}
+
+	public static String toString(List<String> arr) {
+		String ret = "";
+
+		if(arr != null && arr.size() > 0) {
+			ret = arr.get(0);
+			for(int i = 1; i < arr.size(); i++) {
+				ret += (", " + arr.get(i));
+			}
+		}
+		
+		return ret;
+	}
+
+	public static boolean isEmpty(String str) {
+		return str == null || str.trim().isEmpty();
+	}
+
+	public static <T> boolean isEmpty(Collection<T> set) {
+		return set == null || set.isEmpty();
+	}
+	
+	public static String toLower(String str) {
+		return str == null ? null : str.toLowerCase();
+	}
+
+	public static Date getUTCDate() {
+	    Calendar local  = Calendar.getInstance();
+	    int      offset = local.getTimeZone().getOffset(local.getTimeInMillis());
+
+	    GregorianCalendar utc = new GregorianCalendar(TimeZone.getTimeZone("GMT+0"));
+
+	    utc.setTimeInMillis(local.getTimeInMillis());
+	    utc.add(Calendar.MILLISECOND, -offset);
+
+	    return utc.getTime();
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/7defc061/agents-cred/pom.xml
----------------------------------------------------------------------
diff --git a/agents-cred/pom.xml b/agents-cred/pom.xml
new file mode 100644
index 0000000..8243262
--- /dev/null
+++ b/agents-cred/pom.xml
@@ -0,0 +1,34 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>security_agents.agents-cred</groupId>
+  <artifactId>agents-cred</artifactId>
+  <name>Credential Support</name>
+  <description>Agent Common</description>
+  <packaging>jar</packaging>
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+  <parent>
+     <groupId>com.hortonworks.hadoop.security</groupId>
+     <artifactId>argus</artifactId>
+     <version>3.5.000</version>
+     <relativePath>..</relativePath>
+  </parent>
+  <dependencies>
+    <dependency>
+        <groupId>commons-logging</groupId>
+        <artifactId>commons-logging</artifactId>
+        <version>${commons.logging.version}</version>
+    </dependency>
+    <dependency>
+        <groupId>org.apache.hadoop</groupId>
+        <artifactId>hadoop-common</artifactId>
+        <version>${hadoop-common.version}</version>
+    </dependency>
+    <dependency>
+        <groupId>log4j</groupId>
+        <artifactId>log4j</artifactId>
+        <version>${log4j.version}</version>
+    </dependency>
+  </dependencies>
+</project>

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/7defc061/agents-cred/src/main/java/com/xasecure/authorization/hadoop/utils/XaSecureCredentialProvider.java
----------------------------------------------------------------------
diff --git a/agents-cred/src/main/java/com/xasecure/authorization/hadoop/utils/XaSecureCredentialProvider.java b/agents-cred/src/main/java/com/xasecure/authorization/hadoop/utils/XaSecureCredentialProvider.java
new file mode 100644
index 0000000..4e7855b
--- /dev/null
+++ b/agents-cred/src/main/java/com/xasecure/authorization/hadoop/utils/XaSecureCredentialProvider.java
@@ -0,0 +1,74 @@
+package com.xasecure.authorization.hadoop.utils;
+
+import java.lang.String;
+import java.util.List;
+import java.io.IOException;
+
+import org.apache.hadoop.security.alias.CredentialProvider;
+import org.apache.hadoop.security.alias.CredentialProviderFactory;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+
+public class XaSecureCredentialProvider {
+
+  private static Log LOG = LogFactory.getLog(XaSecureCredentialProvider.class);
+  private static Configuration conf = null;
+
+  private static List<CredentialProvider> providers = null;
+  private static XaSecureCredentialProvider  me = null;
+
+  
+  public static XaSecureCredentialProvider getInstance()  {
+	  if ( me == null) {
+		  synchronized(XaSecureCredentialProvider.class) {
+			  XaSecureCredentialProvider temp = me;
+			  if ( temp == null){
+				  me = new XaSecureCredentialProvider();
+				  me.init();
+			  }
+		  }
+	  }
+	return me;
+  }
+  
+  
+  private void init() {
+	  conf  = new Configuration();
+  }
+  
+  public char[] getCredentialString(String url, String alias)  {
+  
+   char[] pass = null;
+ 
+   conf.set(CredentialProviderFactory.CREDENTIAL_PROVIDER_PATH, url);
+   providers =  getCredentialProviders(); 
+   
+   CredentialProvider.CredentialEntry credEntry = null;
+   
+   for(  CredentialProvider provider: providers) {
+	   try {
+         credEntry = provider.getCredentialEntry(alias);
+         if (credEntry != null) {
+            pass = credEntry.getCredential();
+         } else {
+        	return pass;
+         }
+        } catch(IOException ie) {
+        	LOG.error("Unable to get the Credential Provider from the Configuration", ie);	 
+       }
+    }
+   return pass;
+  }
+  
+  public  List<CredentialProvider>  getCredentialProviders(){
+   try {
+       providers = CredentialProviderFactory.getProviders(conf);   
+      } catch( IOException ie) {
+    	  LOG.error("Unable to get the Credential Provider from the Configuration", ie);
+      }     
+   return providers;
+  }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/7defc061/agents-impl/pom.xml
----------------------------------------------------------------------
diff --git a/agents-impl/pom.xml b/agents-impl/pom.xml
new file mode 100644
index 0000000..1751b83
--- /dev/null
+++ b/agents-impl/pom.xml
@@ -0,0 +1,96 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>security_agents.agents-impl</groupId>
+  <artifactId>agents-impl</artifactId>
+  <name>Agent Implementation Libary</name>
+  <description>Security Agents Implementation</description>
+  <packaging>jar</packaging>
+  <parent>
+     <groupId>com.hortonworks.hadoop.security</groupId>
+     <artifactId>argus</artifactId>
+     <version>3.5.000</version>
+     <relativePath>..</relativePath>
+  </parent>
+  <dependencies>
+
+  <dependency>
+    <groupId>org.glassfish.jersey.core</groupId>
+    <artifactId>jersey-client</artifactId>
+    <version>2.6</version>
+  </dependency>
+
+    <dependency>
+	<groupId>commons-logging</groupId>
+	<artifactId>commons-logging</artifactId>
+	<version>${commons.logging.version}</version>
+    </dependency>
+    <dependency>
+        <groupId>org.apache.hadoop</groupId>
+        <artifactId>hadoop-hdfs</artifactId>
+        <version>${hadoop.version}</version>
+    </dependency>
+    <dependency>
+        <groupId>org.apache.hbase</groupId>
+        <artifactId>hbase-server</artifactId>
+        <version>${hbase.version}</version>
+    </dependency>
+    <dependency>
+	  <groupId>org.apache.hive</groupId>
+	  <artifactId>hive-common</artifactId>
+	  <version>${hive.version}</version>
+      <scope>system</scope>
+      <systemPath>${local.lib.dir}/hive-0.14.0-SNAPSHOT/hive-common-0.14.0-SNAPSHOT.jar</systemPath>
+    </dependency>
+    <dependency>
+	  <groupId>org.apache.hive</groupId>
+	  <artifactId>hive-service</artifactId>
+	  <version>${hive.version}</version>
+        <scope>system</scope>
+      <systemPath>${local.lib.dir}/hive-0.14.0-SNAPSHOT/hive-service-0.14.0-SNAPSHOT.jar</systemPath>
+    </dependency>
+    <dependency>
+	  <groupId>org.apache.hive</groupId>
+	  <artifactId>hive-exec</artifactId>
+	  <version>${hive.version}</version>
+        <scope>system</scope>
+      <systemPath>${local.lib.dir}/hive-0.14.0-SNAPSHOT/hive-exec-0.14.0-SNAPSHOT.jar</systemPath>
+    </dependency>
+    <dependency>
+	  <groupId>org.apache.hive</groupId>
+	  <artifactId>hive-metastore</artifactId>
+	  <version>${hive.version}</version>
+        <scope>system</scope>
+      <systemPath>${local.lib.dir}/hive-0.14.0-SNAPSHOT/hive-metastore-0.14.0-SNAPSHOT.jar</systemPath>
+    </dependency>
+    <dependency>
+      <groupId>security_agents.agents-audit</groupId>
+      <artifactId>agents-audit</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>security_agents.agents-common</groupId>
+      <artifactId>agents-common</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>security_agents.hdfs-agent</groupId>
+      <artifactId>hdfs-agent</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>security_agents.hive-agent</groupId>
+      <artifactId>hive-agent</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>security_agents.hbase-agent</groupId>
+      <artifactId>hbase-agent</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>security_agents.knox-agent</groupId>
+      <artifactId>knox-agent</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+  </dependencies>
+</project>


Mime
View raw message