ranger-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From omal...@apache.org
Subject [03/44] ARGUS-1. Initial code commit (Selvamohan Neethiraj via omalley)
Date Thu, 14 Aug 2014 20:50:14 GMT
http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/7defc061/security-admin/src/main/webapp/templates/users/GroupForm_tmpl.html
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/templates/users/GroupForm_tmpl.html b/security-admin/src/main/webapp/templates/users/GroupForm_tmpl.html
new file mode 100644
index 0000000..f09033f
--- /dev/null
+++ b/security-admin/src/main/webapp/templates/users/GroupForm_tmpl.html
@@ -0,0 +1,4 @@
+<form class="form-horizontal" >
+		<div class="" data-fields="name"></div>
+		<div class="" data-fields="description"></div>
+</form>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/7defc061/security-admin/src/main/webapp/templates/users/UserCreate_tmpl.html
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/templates/users/UserCreate_tmpl.html b/security-admin/src/main/webapp/templates/users/UserCreate_tmpl.html
new file mode 100644
index 0000000..38bb794
--- /dev/null
+++ b/security-admin/src/main/webapp/templates/users/UserCreate_tmpl.html
@@ -0,0 +1,22 @@
+<h4 class="wrap-header bold"> User Detail </h4>
+<div class="wrap non-collapsible ">
+	<ul class="nav nav-tabs tabs clearfix">
+
+		<li class="" data-tab="edit-password">
+			<a data-toggle="tab" href="#edit-password"> <i class="blue icon-key bigger-125"></i> Change Password </a>
+		</li>
+		<li class="active" data-tab="edit-basic">
+			<a data-toggle="tab" href="#edit-basic"> <i class="green icon-edit bigger-125"></i> Basic Info </a>
+		</li>
+	</ul>
+	<div data-id="r_form"></div>
+	<div class="form-actions form-policy" class="row-fluid">
+		<button type="button" data-id="save" class="btn btn-primary">
+			Save
+		</button>
+		<button type="button" data-id="cancel" class="btn btn-inverse">
+			Cancel
+		</button>
+	</div>
+</div>
+

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/7defc061/security-admin/src/main/webapp/templates/users/UserForm_tmpl.html
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/templates/users/UserForm_tmpl.html b/security-admin/src/main/webapp/templates/users/UserForm_tmpl.html
new file mode 100644
index 0000000..d622006
--- /dev/null
+++ b/security-admin/src/main/webapp/templates/users/UserForm_tmpl.html
@@ -0,0 +1,17 @@
+<form class="form-horizontal" >
+		<div class="" data-fields="name"></div>
+		<div class="" data-fields="password"></div>
+		<div class="" data-fields="passwordConfirm"></div>
+		<div class="" data-fields="firstName"></div>
+		<div class="" data-fields="lastName"></div>
+		<div class="" data-fields="emailAddress"></div>
+		<div class="" data-fields="userRoleList"></div>
+		<div class="" data-customfields="groupIdList">
+			<div class="control-group field-groupIdList">
+				<label class="control-label" for="c13_group">Group *</label>
+			    <div class="controls controls-row">
+			    	<img src="images/loading.gif" style=" margin-left: 4%; margin-top: 1%;" />                        
+			    </div>
+			</div>
+		</div>
+</form>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/7defc061/security-admin/src/main/webapp/templates/users/UserInfo_tmpl.html
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/templates/users/UserInfo_tmpl.html b/security-admin/src/main/webapp/templates/users/UserInfo_tmpl.html
new file mode 100644
index 0000000..e7aa049
--- /dev/null
+++ b/security-admin/src/main/webapp/templates/users/UserInfo_tmpl.html
@@ -0,0 +1,83 @@
+<div class="well well-small " style="margin-top: 36px;">
+	<div class="fancy title" style="margin-bottom: 16px;">
+		{{#if  userModel}}	
+				<span>User Information</span>
+		{{/if}}	
+		{{#if  groupModel}}
+				<span>Group Information</span>
+		{{/if}}
+	</div>
+	
+	{{#if  userModel}}	
+		<h4 style="font-size: 14.25px;">{{tt 'lbl.userName'}} : <span class="r-path">{{name}}</span></h4>
+	{{/if}}	
+	{{#if  groupModel}}
+		<h4 style="font-size: 14.25px;">{{tt 'lbl.groupName'}} : <span class="r-path">{{name}}</span></h4>
+	{{/if}}	
+		<label class="labelInverse">{{tt 'lbl.userInfo'}} :</label>
+		<table class="table table-bordered">
+			<tbody>
+				<tr>
+					<td>{{tt 'lbl.createdBy'}}</td>
+					<td> {{owner}} </td>
+				</tr>
+				<tr>
+					<td>{{tt 'lbl.createdOn'}}</td>
+					<td>{{dateFormat createDate format="MM/DD/YYYY HH:mm:ss A"}}</td>
+				</tr>
+				<tr>
+					<td>{{tt 'lbl.updatedBy'}}</td>
+					<td> {{updatedBy}} </td>
+				</tr>
+				<tr>
+					<td>{{tt 'lbl.updatedOn'}}</td>
+					<td>{{dateFormat updateDate format="MM/DD/YYYY HH:mm:ss A"}} </td>
+				</tr>
+			</tbody>
+		</table>
+	 {{#if  groupList.length}}	
+		<label class="labelInverse">{{tt 'lbl.group'}} :</label>
+		<table class="table table-bordered" >
+			<thead>
+				<tr>
+					<th >{{tt 'lbl.groupName'}}</th>
+				</tr>
+			</thead>
+			<tbody>
+				<tr>
+					<td>
+				{{#each groupList.models}}
+						<span class="label label-info">{{./this.attributes.name}}</span>					
+				{{/each}}
+					<a href="javascript:void(0);" data-id="showMore" class="" style="display:none;">
+							<code style=""> + More..</code>
+					</a>
+					<a href="javascript:void(0);" data-id="showLess" class="" style="display:none;">
+							<code style=""> - Less..</code>
+					</a>
+					</td>
+				</tr>
+			</tbody>
+		</table>
+	{{/if}}	 
+	{{#if  userList.length}}	
+		<label class="labelInverse">{{tt 'lbl.users'}} :</label>
+		<table class="table table-bordered">
+			<thead>
+				<tr>
+					<th >{{tt 'lbl.userName'}}</th>
+				</tr>
+			</thead>
+			<tbody>
+				<tr>
+					<td>
+				{{#each userList.models}}
+						<span class="label label-info">{{./this.attributes.name}}</span>
+				{{/each}}
+					</td>
+				</tr>
+			</tbody>
+		</table>
+	{{/if}}	 
+	</div>
+</div>

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/7defc061/security-admin/src/main/webapp/templates/users/UserTableLayout_tmpl.html
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/templates/users/UserTableLayout_tmpl.html b/security-admin/src/main/webapp/templates/users/UserTableLayout_tmpl.html
new file mode 100644
index 0000000..c40bc34
--- /dev/null
+++ b/security-admin/src/main/webapp/templates/users/UserTableLayout_tmpl.html
@@ -0,0 +1,40 @@
+<!-- <ul class="nav nav-tabs">
+  <li class="active" data-js="users">
+    <a data-toggle="tab" href="#users">Users</a>
+  </li>
+  <li data="groups" data-js="groups">
+  	<a data-toggle="tab" href="#groups">Groups</a>
+  </li>
+</ul> -->
+  <ul class="nav nav-tabs tabs clearfix">
+    <li data="groups" data-js="groups"> 
+      <a data-toggle="tab" href="#groups">Groups</a> 
+    </li>
+    <li class="active" data-js="users">
+      <a data-toggle="tab" href="#users">Users</a> 
+    </li>
+  </ul>
+
+
+
+
+<h3 class="wrap-header bold"> {{tt 'lbl.userListing'}} </h3>
+
+<div class="wrap non-collapsible m-height ">
+
+	<div class="span9">
+		<div class="span9">
+			<div class="visual_search"></div>
+		</div>
+		<div class="clearfix">
+			<a href="#!/user/create" class="btn btn-primary btn-right" type="button" data-id="addNewUser"> {{tt 'lbl.addNewUser'}} </a>
+			<a href="#!/group/create" class="btn btn-primary btn-right" type="button" data-id="addNewGroup" style="display:none;"> {{tt 'lbl.addNewGroup'}} </a>
+		</div>
+		<div data-id="r_tableList" class="clickable">
+		</div>
+	</div>
+
+	<div class="span3">
+		<div id="userDetail"></div>
+	</div>
+</div>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/7defc061/security-admin/src/test/java/com/xasecure/rest/TestPublicAPIs.java
----------------------------------------------------------------------
diff --git a/security-admin/src/test/java/com/xasecure/rest/TestPublicAPIs.java b/security-admin/src/test/java/com/xasecure/rest/TestPublicAPIs.java
new file mode 100644
index 0000000..ce6f67e
--- /dev/null
+++ b/security-admin/src/test/java/com/xasecure/rest/TestPublicAPIs.java
@@ -0,0 +1,560 @@
+package com.xasecure.rest;
+
+import static org.junit.Assert.*;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+import org.junit.Before;
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.mock.web.MockHttpServletRequest;
+import org.springframework.test.annotation.Rollback;
+
+import com.xasecure.common.AppConstants;
+import com.xasecure.common.GUIDUtil;
+import com.xasecure.db.XADaoManager;
+import com.xasecure.entity.XXAsset;
+import com.xasecure.entity.XXResource;
+import com.xasecure.rest.PublicAPIs;
+import com.xasecure.util.BaseTest;
+import com.xasecure.view.VXLong;
+import com.xasecure.view.VXPermObj;
+import com.xasecure.view.VXPolicy;
+import com.xasecure.view.VXRepository;
+import com.xasecure.view.VXResponse;
+
+/**
+ * @author tushar
+ * 
+ */
+
+/**
+ * JUnit testSuite for {@link com.xasecure.rest.PublicAPIs}
+ * 
+ */
+
+public class TestPublicAPIs extends BaseTest {
+	static Logger logger = Logger.getLogger(TestPublicAPIs.class);
+
+	@Autowired
+	PublicAPIs publicAPIs;
+
+	@Autowired
+	XADaoManager daoManager;
+
+	VXRepository vXRepoHDFS;
+	VXRepository vXRepoHBase;
+	VXRepository vXRepoHive;
+
+	VXPolicy vXPolicyHDFS;
+	VXPolicy vXPolicyHBase;
+	VXPolicy vXPolicyHive;
+
+	@Override
+	public void init() {
+		super.startSession();
+		super.startRequest();
+	}
+
+	/**
+	 * @throws java.lang.Exception
+	 */
+	@Before
+	public void setUp() throws Exception {
+		super.authenticate();
+	}
+
+	/**
+	 * Test method for
+	 * {@link com.xasecure.rest.PublicAPIs#createRepository(com.xasecure.view.VXRepository)}
+	 * .
+	 */
+	public void testCreateRepository() {
+		vXRepoHDFS = new VXRepository();
+		vXRepoHBase = new VXRepository();
+		vXRepoHive = new VXRepository();
+
+		// Create HDFS Repository
+		String configHdfs = "{"
+				+ "  \"username\": \"policymgr\","
+				+ "  \"password\": \"policymgr\","
+				+ "  \"fs.default.name\": \"hdfs://sandbox.hortonworks.com:8020\","
+				+ "  \"hadoop.security.authorization\": \"true\","
+				+ "  \"hadoop.security.authentication\": \"simple\","
+				+ "  \"hadoop.security.auth_to_local\": \"\","
+				+ "  \"dfs.datanode.kerberos.principal\": \"\","
+				+ "  \"dfs.namenode.kerberos.principal\": \"\","
+				+ "  \"dfs.secondary.namenode.kerberos.principal\": \"\","
+				+ "  \"commonNameForCertificate\": \"\"}";
+
+		vXRepoHDFS.setName("HDFS Repo_" + GUIDUtil.genGUI());
+		vXRepoHDFS.setDescription("HDFS Repository, using JUnit");
+		vXRepoHDFS.setActive(true);
+		vXRepoHDFS.setRepositoryType("hdfs");
+		vXRepoHDFS.setConfig(configHdfs);
+		vXRepoHDFS = publicAPIs.createRepository(vXRepoHDFS);
+
+		assertNotNull("Error while creating Repository for HDFS", vXRepoHDFS);
+		logger.info("Create : Repo for HDFS created Successfully");
+
+		// Create Hive Repository
+		String configHive = "{"
+				+ "  \"username\": \"policymgr_hive\" ,"
+				+ "  \"password\": \"policymgr_hive\","
+				+ "  \"jdbc.driverClassName\": \"org.apache.hive.jdbc.HiveDriver\","
+				+ "  \"jdbc.url\": \"jdbc:hive2://127.0.0.1:10000/default\","
+				+ "  \"commonNameForCertificate\": \"\"}";
+
+		vXRepoHive.setName("hivedev_" + GUIDUtil.genGUI());
+		vXRepoHive.setDescription("Hive Dev");
+		vXRepoHive.setActive(true);
+		vXRepoHive.setRepositoryType("Hive");
+		vXRepoHive.setConfig(configHive);
+		vXRepoHive = publicAPIs.createRepository(vXRepoHive);
+
+		assertNotNull("Error while creating Repository for Hive", vXRepoHive);
+		logger.info("Create : Repo for Hive created Successfully");
+
+		// Create HBase Repository
+		String configHbase = "{"
+				+ "  \"username\": \"policymgr_hbase\","
+				+ "  \"password\": \"policymgr_hbase\","
+				+ "  \"fs.default.name\": \"hdfs://sandbox.hortonworks.com:8020\","
+				+ "  \"hadoop.security.authorization\": \"true\","
+				+ "  \"hadoop.security.authentication\": \"simple\","
+				+ "  \"hadoop.security.auth_to_local\": \"\","
+				+ "  \"dfs.datanode.kerberos.principal\": \"\","
+				+ "  \"dfs.namenode.kerberos.principal\": \"\","
+				+ "  \"dfs.secondary.namenode.kerberos.principal\": \"\","
+				+ "  \"hbase.master.kerberos.principal\": \"\","
+				+ "  \"hbase.rpc.engine\": \"org.apache.hadoop.hbase.ipc.SecureRpcEngine\","
+				+ "  \"hbase.rpc.protection\": \"PRIVACY\","
+				+ "  \"hbase.security.authentication\": \"simple\","
+				+ "  \"hbase.zookeeper.property.clientPort\": \"2181\","
+				+ "  \"hbase.zookeeper.quorum\": \"sandbox.hortonworks.com\","
+				+ "  \"zookeeper.znode.parent\": \"/hbase-unsecure\","
+				+ "  \"commonNameForCertificate\": \"\"}";
+
+		vXRepoHBase.setName("hbasedev_" + GUIDUtil.genGUI());
+		vXRepoHBase.setDescription("HBase Dev");
+		vXRepoHBase.setActive(true);
+		vXRepoHBase.setRepositoryType("HBase");
+		vXRepoHBase.setConfig(configHbase);
+		vXRepoHBase = publicAPIs.createRepository(vXRepoHBase);
+
+		assertNotNull("Error while creating Repo for HBase", vXRepoHBase);
+		logger.info("Create : Repo for HBase created Successfully");
+	}
+
+	/**
+	 * Test method for
+	 * {@link com.xasecure.rest.PublicAPIs#updateRepository(com.xasecure.view.VXRepository)}
+	 * .
+	 */
+	public void testUpdateRepository() {
+
+		// Update HDFS Repo
+		vXRepoHDFS.setName("HDFS Repo Updated_" + GUIDUtil.genGUI());
+		vXRepoHDFS = publicAPIs.updateRepository(vXRepoHDFS);
+
+		assertNotNull("Error While updating Repo", vXRepoHDFS);
+		logger.info("Update : Repo for HDFS updated Successfully");
+
+		// Update HBase Repo
+		vXRepoHBase.setName("HBase Repo Updated_" + GUIDUtil.genGUI());
+		vXRepoHBase = publicAPIs.updateRepository(vXRepoHBase);
+
+		assertNotNull("Error While updating Repo", vXRepoHBase);
+		logger.info("Update : Repo for HBase updated Successfully");
+
+		// Update HIVE Repo
+		vXRepoHive.setName("Hive Repo Updated_" + GUIDUtil.genGUI());
+		vXRepoHive = publicAPIs.updateRepository(vXRepoHive);
+
+		assertNotNull("Error While updating Repo", vXRepoHive);
+		logger.info("Update : Repo for Hive updated Successfully");
+	}
+
+	/**
+	 * Test method for
+	 * {@link com.xasecure.rest.PublicAPIs#getRepository(java.lang.Long)}.
+	 */
+	public void testGetRepository() {
+		VXRepository vXRepositoryHDFS = publicAPIs.getRepository(vXRepoHDFS
+				.getId());
+		assertNotNull(
+				"No Repository found for this Id : " + vXRepoHDFS.getId(),
+				vXRepositoryHDFS);
+		logger.info("Get : Repo found for this id : " + vXRepoHDFS.getId());
+
+		VXRepository vXRepositoryHBase = publicAPIs.getRepository(vXRepoHBase
+				.getId());
+		assertNotNull(
+				"No Repository found for this Id : " + vXRepoHBase.getId(),
+				vXRepositoryHBase);
+		logger.info("Get : Repo found for this id : " + vXRepoHBase.getId());
+
+		VXRepository vXRepositoryHive = publicAPIs.getRepository(vXRepoHive
+				.getId());
+		assertNotNull(
+				"No Repository found for this Id : " + vXRepoHive.getId(),
+				vXRepositoryHive);
+		logger.info("Get : Repo found for this id : " + vXRepoHive.getId());
+	}
+
+	/**
+	 * Test method for
+	 * {@link com.xasecure.rest.PublicAPIs#deleteRepository(java.lang.Long, javax.servlet.http.HttpServletRequest)}
+	 * .
+	 */
+	public void testDeleteRepository() {
+
+		XXAsset xxAsset = daoManager.getXXAsset().findByAssetName(
+				vXRepoHDFS.getName());
+		MockHttpServletRequest request = super.startRequest();
+		request.addParameter("force", "true");
+		publicAPIs.deleteRepository(xxAsset.getId(), request);
+
+		VXRepository deletedRepo = publicAPIs.getRepository(xxAsset.getId());
+
+		if (deletedRepo != null && deletedRepo.isActive() == false) {
+			logger.info("Repository has been deleted"
+					+ " successfully, and DB change has been rolled back");
+		} else {
+			fail("Delete Repository test failed");
+		}
+
+		super.endRequest();
+	}
+
+	/**
+	 * Test method for
+	 * {@link com.xasecure.rest.PublicAPIs#testConfig(com.xasecure.view.VXRepository)}
+	 * .
+	 */
+	public void testTestConfig() {
+		VXResponse vXResponseHDFS = publicAPIs.testConfig(vXRepoHDFS);
+		assertNotNull(
+				"Error while testing testConfig : for HDFS, testConfig function",
+				vXResponseHDFS);
+
+		if (vXResponseHDFS.getStatusCode() == VXResponse.STATUS_SUCCESS) {
+			logger.info("testConfig : for HDFS, testConfig function has been tested and working as expected");
+		} else if (vXResponseHDFS.getStatusCode() == VXResponse.STATUS_ERROR) {
+			logger.info("testConfig : for HDFS, testConfig function send error response");
+		}
+
+		// NOTE : testConfig will not work on local server but to test
+		// PublicREST API we need write it over here
+	}
+
+	/**
+	 * Test method for
+	 * {@link com.xasecure.rest.PublicAPIs#searchRepositories(javax.servlet.http.HttpServletRequest)}
+	 * .
+	 */
+	public void testSearchRepositories() {
+
+	}
+
+	/**
+	 * Test method for
+	 * {@link com.xasecure.rest.PublicAPIs#countRepositories(javax.servlet.http.HttpServletRequest)}
+	 * .
+	 */
+	public void testCountRepositories() {
+		VXLong vXLong = publicAPIs.countRepositories(super.startRequest());
+
+		assertNotNull("Count : Error while counting Repos", vXLong);
+		logger.info("Count : Total no of Repos are : " + vXLong.getValue());
+
+		super.endRequest();
+	}
+
+	/**
+	 * Test method for
+	 * {@link com.xasecure.rest.PublicAPIs#createPolicy(com.xasecure.view.VXPolicy)}
+	 * .
+	 */
+	public void testCreatePolicy() {
+		vXPolicyHDFS = new VXPolicy();
+		vXPolicyHBase = new VXPolicy();
+		vXPolicyHive = new VXPolicy();
+
+		// Create Policy for HDFS
+		createHDFSPolicy();
+		// Create Policy for HBase
+		createHBasePolicy();
+		// Create Policy for Hive
+		createHivePolicy();
+
+	}
+
+	private void createHivePolicy() {
+		vXPolicyHive.setPolicyName("HomePolicy_" + GUIDUtil.genGUI());
+		vXPolicyHive.setDatabases("vXPolicyHive_" + GUIDUtil.genGUI());
+		vXPolicyHive.setTables("finance,hr," + GUIDUtil.genGUI());
+		vXPolicyHive.setColumns("amt, emp_id, " + GUIDUtil.genGUI());
+		vXPolicyHive.setDescription("home policy for Hive");
+		// vXPolicyHive.setRepositoryName(vXRepoHive.getName());
+		vXPolicyHive.setRepositoryType("Hive");
+		vXPolicyHive.setEnabled(true);
+		vXPolicyHive.setRecursive(true);
+		vXPolicyHive.setAuditEnabled(true);
+		vXPolicyHive.setRepositoryId(vXRepoHive.getId());
+		vXPolicyHive.setResourceType("Column");
+		vXPolicyHive.setColumnType("Exclusion");
+
+		VXPermObj vXPermObj = new VXPermObj();
+		List<String> userList = new ArrayList<String>();
+		userList.add("policymgr");
+		vXPermObj.setUserList(userList);
+
+		List<String> permList = new ArrayList<String>();
+		permList.add("read");
+		permList.add("write");
+		permList.add("admin");
+		vXPermObj.setPermList(permList);
+
+		VXPermObj vXPermObj2 = new VXPermObj();
+		List<String> userList2 = new ArrayList<String>();
+		List<String> permList2 = new ArrayList<String>();
+
+		userList2.add("policymgr_hbase");
+		userList2.add("policymgr_hive");
+
+		permList2.add("admin");
+		permList2.add("write");
+		vXPermObj2.setUserList(userList2);
+		vXPermObj2.setPermList(permList2);
+
+		List<VXPermObj> permObjList = new ArrayList<VXPermObj>();
+		permObjList.add(vXPermObj);
+		permObjList.add(vXPermObj2);
+
+		vXPolicyHive.setPermMapList(permObjList);
+
+		vXPolicyHive = publicAPIs.createPolicy(vXPolicyHive);
+		assertNotNull("Create Policy : Error while creating Policy for Hive",
+				vXPolicyHive);
+		logger.info("Create Policy : Policy created successfully for Hive");
+	}
+
+	private void createHBasePolicy() {
+		vXPolicyHBase.setPolicyName("HomePolicy_" + GUIDUtil.genGUI());
+		vXPolicyHBase.setTables("finance,hr," + GUIDUtil.genGUI());
+		vXPolicyHBase.setColumnFamilies("invoices,emps," + GUIDUtil.genGUI());
+		vXPolicyHBase.setColumns("amt, emp_id, " + GUIDUtil.genGUI());
+		vXPolicyHBase.setDescription("home policy for HBase");
+		// vXPolicyHBase.setRepositoryName("hadoopdev");
+		vXPolicyHBase.setRepositoryType("HBase");
+		vXPolicyHBase.setEnabled(true);
+		vXPolicyHBase.setRecursive(true);
+		vXPolicyHBase.setAuditEnabled(true);
+		vXPolicyHBase.setRepositoryId(vXRepoHBase.getId());
+		vXPolicyHBase.setResourceType("Column");
+
+		VXPermObj vXPermObj = new VXPermObj();
+		List<String> userList = new ArrayList<String>();
+		userList.add("policymgr");
+		vXPermObj.setUserList(userList);
+
+		List<String> permList = new ArrayList<String>();
+		permList.add("read");
+		permList.add("write");
+		permList.add("admin");
+		vXPermObj.setPermList(permList);
+
+		VXPermObj vXPermObj2 = new VXPermObj();
+		List<String> userList2 = new ArrayList<String>();
+		List<String> permList2 = new ArrayList<String>();
+
+		userList2.add("policymgr_hbase");
+		userList2.add("policymgr_hive");
+
+		permList2.add("admin");
+		permList2.add("write");
+		vXPermObj2.setUserList(userList2);
+		vXPermObj2.setPermList(permList2);
+
+		List<VXPermObj> permObjList = new ArrayList<VXPermObj>();
+		permObjList.add(vXPermObj);
+		permObjList.add(vXPermObj2);
+
+		vXPolicyHBase.setPermMapList(permObjList);
+
+		vXPolicyHBase = publicAPIs.createPolicy(vXPolicyHBase);
+		assertNotNull("Create Policy : Error while creating Policy for HBase",
+				vXPolicyHBase);
+		logger.info("Create Policy : Policy created successfully for HBase");
+	}
+
+	private void createHDFSPolicy() {
+		vXPolicyHDFS.setPolicyName("HomePolicy_" + GUIDUtil.genGUI());
+		vXPolicyHDFS.setResourceName("/home,/apps,/" + GUIDUtil.genGUI());
+		vXPolicyHDFS.setDescription("home policy for HDFS");
+		// vXPolicyHDFS.setRepositoryName("hadoopdev");
+		vXPolicyHDFS.setRepositoryType("hdfs");
+		vXPolicyHDFS.setEnabled(true);
+		vXPolicyHDFS.setRecursive(true);
+		vXPolicyHDFS.setAuditEnabled(true);
+		vXPolicyHDFS.setRepositoryId(vXRepoHDFS.getId());
+
+		VXPermObj vXPermObj = new VXPermObj();
+		List<String> userList = new ArrayList<String>();
+		userList.add("policymgr");
+		userList.add("policymgr_hive");
+		vXPermObj.setUserList(userList);
+
+		List<String> permList = new ArrayList<String>();
+		permList.add("read");
+		permList.add("write");
+		permList.add("admin");
+		vXPermObj.setPermList(permList);
+
+		VXPermObj vXPermObj2 = new VXPermObj();
+		List<String> userList2 = new ArrayList<String>();
+		List<String> permList2 = new ArrayList<String>();
+
+		userList2.add("policymgr_hbase");
+
+		permList2.add("admin");
+		permList2.add("write");
+		vXPermObj2.setUserList(userList2);
+		vXPermObj2.setPermList(permList2);
+
+		List<VXPermObj> permObjList = new ArrayList<VXPermObj>();
+		permObjList.add(vXPermObj);
+		permObjList.add(vXPermObj2);
+
+		vXPolicyHDFS.setPermMapList(permObjList);
+
+		vXPolicyHDFS = publicAPIs.createPolicy(vXPolicyHDFS);
+		assertNotNull("Create Policy : Error while creating Policy for HDFS",
+				vXPolicyHDFS);
+		logger.info("Create Policy : Policy created successfully for HDFS");
+	}
+
+	/**
+	 * Test method for
+	 * {@link com.xasecure.rest.PublicAPIs#updatePolicy(com.xasecure.view.VXPolicy)}
+	 * .
+	 */
+	public void testUpdatePolicy() {
+
+		// Update HDFS Policy
+		vXPolicyHDFS.setPolicyName("HDFS Policy Updated_" + GUIDUtil.genGUI());
+		vXPolicyHDFS.setRecursive(false);
+		vXPolicyHDFS.setPermMapList(vXPolicyHive.getPermMapList());
+		vXPolicyHDFS = publicAPIs.updatePolicy(vXPolicyHDFS);
+
+		assertNotNull("Error While updating Policy", vXPolicyHDFS);
+		logger.info("Update : Policy for HDFS updated Successfully");
+
+		// Update HBase Policy
+		vXPolicyHBase
+				.setPolicyName("HBase Policy Updated_" + GUIDUtil.genGUI());
+		vXPolicyHBase.setEnabled(false);
+		vXPolicyHBase = publicAPIs.updatePolicy(vXPolicyHBase);
+
+		assertNotNull("Error While updating Policy", vXPolicyHBase);
+		logger.info("Update : Policy for HBase updated Successfully");
+
+		// Update HIVE Policy
+		vXPolicyHive.setPolicyName("Hive Policy Updated_" + GUIDUtil.genGUI());
+		vXPolicyHive.setAuditEnabled(false);
+		vXPolicyHive.setPermMapList(null);
+		vXPolicyHive = publicAPIs.updatePolicy(vXPolicyHive);
+
+		assertNotNull("Error While updating Policy", vXPolicyHive);
+		logger.info("Update : Policy for Hive updated Successfully");
+	}
+
+	/**
+	 * Test method for
+	 * {@link com.xasecure.rest.PublicAPIs#getPolicy(java.lang.Long)}.
+	 */
+	public void testGetPolicy() {
+
+		VXPolicy vXPolHDFS = publicAPIs.getPolicy(vXPolicyHDFS.getId());
+		assertNotNull("No Policy found for this Id : " + vXPolicyHDFS.getId(),
+				vXPolHDFS);
+		logger.info("Get : Policy found for this id : " + vXPolicyHDFS.getId());
+
+		VXPolicy vXPolHBase = publicAPIs.getPolicy(vXPolicyHBase.getId());
+		assertNotNull("No Policy found for this Id : " + vXPolicyHBase.getId(),
+				vXPolHBase);
+		logger.info("Get : Policy found for this id : " + vXPolicyHBase.getId());
+
+		VXPolicy vXPolHive = publicAPIs.getPolicy(vXPolicyHive.getId());
+		assertNotNull("No Policy found for this Id : " + vXPolicyHive.getId(),
+				vXPolHive);
+		logger.info("Get : Policy found for this id : " + vXPolicyHive.getId());
+	}
+
+	/**
+	 * Test method for
+	 * {@link com.xasecure.rest.PublicAPIs#deletePolicy(java.lang.Long, javax.servlet.http.HttpServletRequest)}
+	 * .
+	 */
+	public void testDeletePolicy() {
+
+		XXResource xxResource = daoManager.getXXResource()
+				.findByAssetType(AppConstants.ASSET_HBASE).get(0);
+
+		if (xxResource == null) {
+			fail("No Resource found with name : HDFS Repo Updated");
+		}
+
+		MockHttpServletRequest request = super.startRequest();
+		request.addParameter("force", "true");
+		publicAPIs.deletePolicy(xxResource.getId(), request);
+
+		super.endRequest();
+	}
+
+	/**
+	 * Test method for
+	 * {@link com.xasecure.rest.PublicAPIs#searchPolicies(javax.servlet.http.HttpServletRequest)}
+	 * .
+	 */
+	public void testSearchPolicies() {
+
+	}
+
+	/**
+	 * Test method for
+	 * {@link com.xasecure.rest.PublicAPIs#countPolicies(javax.servlet.http.HttpServletRequest)}
+	 * .
+	 */
+	public void testCountPolicies() {
+		VXLong vXLong = publicAPIs.countPolicies(super.startRequest());
+
+		assertNotNull("Count : Error while counting Policies", vXLong);
+		logger.info("Count : Total no of Policies are : " + vXLong.getValue());
+
+		super.endRequest();
+	}
+
+	@Test
+	@Rollback(false)
+	public void test() throws Exception {
+
+		testCreateRepository();
+		testUpdateRepository();
+		testGetRepository();
+		testTestConfig();
+		testSearchRepositories();
+		testCountRepositories();
+		testCreatePolicy();
+		testUpdatePolicy();
+		testGetPolicy();
+		testSearchPolicies();
+		testCountPolicies();
+		testDeleteRepository();
+		testDeletePolicy();
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/7defc061/security-admin/src/test/java/com/xasecure/util/BaseTest.java
----------------------------------------------------------------------
diff --git a/security-admin/src/test/java/com/xasecure/util/BaseTest.java b/security-admin/src/test/java/com/xasecure/util/BaseTest.java
new file mode 100644
index 0000000..f20e4b5
--- /dev/null
+++ b/security-admin/src/test/java/com/xasecure/util/BaseTest.java
@@ -0,0 +1,96 @@
+/**
+ *
+ */
+package com.xasecure.util;
+
+import org.junit.runner.RunWith;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.mock.web.MockHttpServletRequest;
+import org.springframework.mock.web.MockHttpSession;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.TestExecutionListeners;
+import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
+import org.springframework.test.context.support.DirtiesContextTestExecutionListener;
+import org.springframework.test.context.transaction.TransactionConfiguration;
+import org.springframework.test.context.transaction.TransactionalTestExecutionListener;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
+import com.xasecure.util.CLIUtil;
+
+/**
+ * @author tushar
+ * 
+ */
+@TransactionConfiguration
+@Transactional
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(locations = { "classpath:applicationContext.xml",
+		"classpath:asynctask-applicationContext.xml" })
+@TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,
+		DirtiesContextTestExecutionListener.class,
+		TransactionalTestExecutionListener.class })
+abstract public class BaseTest {
+
+	/**
+	 * MockHttpSession, SubStitute of HttpSession
+	 */
+	protected MockHttpSession session;
+	/**
+	 * MockHttpServletRequest, SubStitute of HttpServletRequest
+	 */
+	protected MockHttpServletRequest request;
+
+	public BaseTest() {
+		init();
+	}
+
+	public void authenticate() throws Exception {
+		CLIUtil cliUtil = (CLIUtil) CLIUtil.getBean(CLIUtil.class);
+		cliUtil.authenticate();
+	}
+
+	/*
+	 * Start New MockHttpSession
+	 */
+	protected void startSession() {
+		session = new MockHttpSession();
+	}
+
+	/*
+	 * Destroy MockHttpSession, if exists
+	 */
+	protected void endSession() {
+		if (session != null) {
+			session.clearAttributes();
+		}
+		session = null;
+	}
+
+	/*
+	 * Create New MockHttpServletRequest
+	 */
+	protected MockHttpServletRequest startRequest() {
+		request = new MockHttpServletRequest();
+		request.setSession(session);
+		RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(
+				request));
+		return request;
+	}
+
+	/*
+	 * terminate existing MockHttpServletRequest
+	 */
+	protected void endRequest() {
+		((ServletRequestAttributes) RequestContextHolder.getRequestAttributes())
+				.requestCompleted();
+		RequestContextHolder.resetRequestAttributes();
+		request = null;
+	}
+
+	public void init() {
+
+	}
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/7defc061/security-admin/unixauth-config/keystore.jks
----------------------------------------------------------------------
diff --git a/security-admin/unixauth-config/keystore.jks b/security-admin/unixauth-config/keystore.jks
new file mode 100644
index 0000000..adee30f
Binary files /dev/null and b/security-admin/unixauth-config/keystore.jks differ

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/7defc061/security-admin/unixauth-config/server.crt
----------------------------------------------------------------------
diff --git a/security-admin/unixauth-config/server.crt b/security-admin/unixauth-config/server.crt
new file mode 100644
index 0000000..9680f72
--- /dev/null
+++ b/security-admin/unixauth-config/server.crt
@@ -0,0 +1,19 @@
+-----BEGIN CERTIFICATE-----
+MIIDlzCCAn+gAwIBAgIEWsSk3zANBgkqhkiG9w0BAQsFADB8MQswCQYDVQQGEwJVUzERMA8GA1UE
+CBMIdmlyZ2luaWExFjAUBgNVBAcTDVBvdG9tYWMgRmFsbHMxETAPBgNVBAoTCHhhc2VjdXJlMRkw
+FwYDVQQLExBjZXJ0aWZpY2F0ZSBkZXB0MRQwEgYDVQQDEwthdXRoc2VydmljZTAeFw0xMzEyMDQx
+NTQyMDdaFw0xNDExMjkxNTQyMDdaMHwxCzAJBgNVBAYTAlVTMREwDwYDVQQIEwh2aXJnaW5pYTEW
+MBQGA1UEBxMNUG90b21hYyBGYWxsczERMA8GA1UEChMIeGFzZWN1cmUxGTAXBgNVBAsTEGNlcnRp
+ZmljYXRlIGRlcHQxFDASBgNVBAMTC2F1dGhzZXJ2aWNlMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A
+MIIBCgKCAQEAp49e8gb8W0YzhtFn71zhK2jhxKJj0bprS+Xojf6jf67219B9DCShB8FQ2/xtUq1k
+qM6hbS3PFoAJ5YCjF7lOOQ6kywK8Uzy15bH3bqDmu+V3WlBUj2qFIWQtAoEHItnDinpBkTVIMzz/
+0e8oSh+ijomH728vBzxrHkYPb6uYaJJJxBsIpbFIBDFhlZZAHxNT+N1kynTea2+KyiVmkK8IK5YI
+kSWrW1sx2xWQa/bh3Kdb2FQT54iocv2J1akzhTogfERy+yEluCe8WIA0PTcbwm08M0IVpjFAS6R6
+3Qjobqtab8BurS4+Mtaiien6kOxdL9qRsnqU1aK0PR5Z8gCJewIDAQABoyEwHzAdBgNVHQ4EFgQU
+QnSmA+pPaTOBxiZpOACcgQyTsiIwDQYJKoZIhvcNAQELBQADggEBADSFFrb6DdPvhLW3b89fSBGm
+YSwC4BMnvptgkbPz/I0277kJV2FaCdE6FNmn/eSfverz7/SaYp949NSnzvwaPsX7HVeFwNN8denL
+iPHq776HpR+4eRaQsyBI5f9J2vEBQqQJjRwWS78nUN2d2G85bRPImyFIJD7M9UT6aJumGlSdi49b
+EF96itjtZWPdvY96bK8YNDiUbbguZt1Wz3cSCivF6kfKMG2uVQqyaMn1HKFFO7a9NoxiW3AbBCJw
+21wI5WATSre89f3NZGzPf1SyJRhJ9DMQG2AlVXJ4AYUqGI2HmBlPHHTrgYHvSO/TW8060IwZXFX2
+ZWCNp2BwRMsKgQA=
+-----END CERTIFICATE-----

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/7defc061/security-admin/unixauth-config/unixauth.properties
----------------------------------------------------------------------
diff --git a/security-admin/unixauth-config/unixauth.properties b/security-admin/unixauth-config/unixauth.properties
new file mode 100644
index 0000000..15e7ba7
--- /dev/null
+++ b/security-admin/unixauth-config/unixauth.properties
@@ -0,0 +1,9 @@
+remoteLoginEnabled=true
+authServiceHostName=bigdata.xasecure.net
+authServicePort=5151
+keyStore=keystore.jks
+keyStorePassword=password
+trustStore=cacerts
+trustStorePassword=changeit
+sslEnabled=true
+debug=true
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/7defc061/src/main/assembly/admin-web.xml
----------------------------------------------------------------------
diff --git a/src/main/assembly/admin-web.xml b/src/main/assembly/admin-web.xml
new file mode 100644
index 0000000..ec742c2
--- /dev/null
+++ b/src/main/assembly/admin-web.xml
@@ -0,0 +1,139 @@
+<assembly>
+  <id>bin</id> 
+  <formats>
+     <format>tar</format>
+     <format>zip</format>
+  </formats>
+  <baseDirectory>security-admin-${project.version}</baseDirectory>
+  <includeBaseDirectory>true</includeBaseDirectory>
+  <moduleSets>
+
+    <moduleSet>
+     <binaries>
+        <includeDependencies>false</includeDependencies>
+        <unpack>false</unpack>
+        <outputDirectory>/war</outputDirectory>
+     </binaries>
+     <includes>
+		<include>com.hortonworks.hadoop.security:security-admin-web</include>
+     </includes>
+    </moduleSet>
+
+    <moduleSet>
+     <binaries>
+        <includeDependencies>false</includeDependencies>
+        <outputDirectory>/ews/lib</outputDirectory>
+        <unpack>false</unpack>
+        <directoryMode>755</directoryMode>
+        <fileMode>644</fileMode>
+        <dependencySets>
+            <dependencySet>
+                <outputDirectory>/ews/lib</outputDirectory>
+                <includes>
+                    <include>org.apache.tomcat.embed:tomcat-embed*</include>
+                </includes>
+                <unpack>false</unpack>
+            </dependencySet>
+        </dependencySets>
+     </binaries>
+     <includes>
+	    <include>com.hortonworks.hadoop.security:embededwebserver</include>
+     </includes>
+    </moduleSet>
+
+
+    <moduleSet>
+     <binaries>
+        <includeDependencies>false</includeDependencies>
+        <outputDirectory>/cred/lib</outputDirectory>
+        <unpack>false</unpack>
+        <directoryMode>755</directoryMode>
+        <fileMode>644</fileMode>
+        <dependencySets>
+            <dependencySet>
+                <outputDirectory>/cred/lib</outputDirectory>
+                <unpack>false</unpack>
+   				<includes>
+                    <include>commons-cli:commons-cli</include>
+                    <include>commons-collections:commons-collections</include>
+                    <include>commons-configuration:commons-configuration</include>
+                    <include>commons-lang:commons-lang</include>
+                    <include>commons-logging:commons-logging</include>
+                    <include>com.google.guava:guava</include>
+                    <include>org.hamcrest:hamcrest-all</include>
+                    <include>junit:junit</include>
+                    <include>org.slf4j:slf4j-api</include>
+                    <include>org.apache.hadoop:hadoop-common</include>
+                    <include>org.apache.hadoop:hadoop-auth</include>
+				</includes>
+            </dependencySet>
+        </dependencySets>
+     </binaries>
+     <includes>
+	    <include>com.hortonworks.hadoop.security:credentialbuilder</include>
+     </includes>
+    </moduleSet>
+
+  </moduleSets> 	
+
+  <fileSets>
+	<fileSet>
+		<outputDirectory>/ews</outputDirectory>
+		<directory>embededwebserver/scripts</directory>
+		<fileMode>544</fileMode>
+	</fileSet>
+	<fileSet>
+		<outputDirectory>/ews</outputDirectory>
+		<directory>embededwebserver/conf</directory>
+		<fileMode>700</fileMode>
+	</fileSet>
+	<fileSet>
+		<outputDirectory>/ews/lib</outputDirectory>
+		<directory>embededwebserver/lib</directory>
+	</fileSet>
+	<fileSet>
+		<outputDirectory>/unixauth-config</outputDirectory>
+		<directory>security-admin/unixauth-config</directory>
+		<fileMode>544</fileMode>
+	</fileSet>
+	<fileSet>
+		<outputDirectory>/db</outputDirectory>
+		<directory>security-admin/db</directory>
+		<fileMode>544</fileMode>
+	</fileSet>
+	<fileSet>
+		<outputDirectory>/</outputDirectory>
+		<directory>security-admin/scripts</directory>
+		<includes>
+			<include>install.properties</include>
+		</includes>
+		<fileMode>700</fileMode>
+	</fileSet>
+	<fileSet>
+		<outputDirectory>/</outputDirectory>
+		<directory>security-admin/scripts</directory>
+		<includes>
+			<include>install.sh</include>
+			<include>setup_authentication.sh</include>
+		</includes>
+		<fileMode>544</fileMode>
+	</fileSet>
+	<fileSet>
+		<outputDirectory>/</outputDirectory>
+		<directory>security-admin</directory>
+		<includes>
+			<include>3rd_party_licenses.txt</include>
+			<include>3rd_party_licenses_text.txt</include>
+		</includes>
+		<fileMode>444</fileMode>
+	</fileSet>
+	<fileSet>
+		<outputDirectory>/</outputDirectory>
+		<directory>${project.build.directory}</directory>
+		<includes>
+			<include>version</include>
+		</includes>
+		<fileMode>444</fileMode>
+	</fileSet>
+  </fileSets>
+</assembly>

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/7defc061/src/main/assembly/hbase-agent.xml
----------------------------------------------------------------------
diff --git a/src/main/assembly/hbase-agent.xml b/src/main/assembly/hbase-agent.xml
new file mode 100644
index 0000000..f9d51a7
--- /dev/null
+++ b/src/main/assembly/hbase-agent.xml
@@ -0,0 +1,86 @@
+<assembly>
+  <id>hbase</id> 
+  <formats>
+     <format>tar</format>
+  </formats>
+  <baseDirectory>security-agents-${project.version}-hbase</baseDirectory>
+  <includeBaseDirectory>true</includeBaseDirectory>
+  <moduleSets>
+    <moduleSet>
+     <binaries>
+        <includeDependencies>false</includeDependencies>
+        <unpack>false</unpack>
+	<directoryMode>755</directoryMode>
+	<fileMode>644</fileMode>
+        <dependencySets>
+            <dependencySet>
+                <outputDirectory>/lib</outputDirectory>
+                <includes>
+                    <include>com.google.code.gson:gson*</include>
+                    <include>org.eclipse.persistence:eclipselink</include>
+                </includes>
+                <unpack>false</unpack>
+            </dependencySet>
+        </dependencySets>
+        <outputDirectory>/dist</outputDirectory>
+     </binaries>
+     <includes>
+	<include>security_agents.agents-audit:agents-audit</include>
+	<include>security_agents.agents-cred:agents-cred</include>
+	<include>security_agents.agents-impl:agents-impl</include>
+	<include>security_agents.agents-common:agents-common</include>
+	<include>security_agents.hbase-agent:hbase-agent</include>
+     </includes>
+    </moduleSet>
+    <moduleSet>
+     <binaries>
+        <includeDependencies>false</includeDependencies>
+        <outputDirectory>/installer/lib</outputDirectory>
+        <unpack>false</unpack>
+     </binaries>
+     <includes>
+	<include>security_agents.agents-installer:agents-installer</include>
+     </includes>
+    </moduleSet>
+  </moduleSets> 	
+  <fileSets>
+	<fileSet>
+		<outputDirectory>/conf</outputDirectory>
+		<directory>hbase-agent/conf</directory>
+		<excludes>
+			<exclude>*.cfg</exclude>
+		</excludes>
+	</fileSet>
+	<fileSet>
+		<outputDirectory>/installer/conf</outputDirectory>
+		<directory>hbase-agent/conf</directory>
+		<includes>
+			<include>*.cfg</include>
+		</includes>
+	</fileSet>
+	<fileSet>
+		<outputDirectory>/</outputDirectory>
+		<directory>hbase-agent/scripts</directory>
+		<excludes>
+			<exclude>*.sh</exclude>
+		</excludes>
+		<fileMode>700</fileMode>
+	</fileSet>
+	<fileSet>
+		<outputDirectory>/</outputDirectory>
+		<directory>hbase-agent/scripts</directory>
+		<includes>
+			<include>*.sh</include>
+		</includes>
+		<fileMode>544</fileMode>
+	</fileSet>
+	<fileSet>
+		<outputDirectory>/</outputDirectory>
+		<directory>${project.build.directory}</directory>
+		<includes>
+			<include>version</include>
+		</includes>
+		<fileMode>444</fileMode>
+	</fileSet>
+  </fileSets>
+</assembly>

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/7defc061/src/main/assembly/hdfs-agent.xml
----------------------------------------------------------------------
diff --git a/src/main/assembly/hdfs-agent.xml b/src/main/assembly/hdfs-agent.xml
new file mode 100644
index 0000000..e13287a
--- /dev/null
+++ b/src/main/assembly/hdfs-agent.xml
@@ -0,0 +1,94 @@
+<assembly>
+  <id>hdfs</id> 
+  <formats>
+     <format>tar</format>
+  </formats>
+  <baseDirectory>security-agents-${project.version}-hdfs</baseDirectory>
+  <includeBaseDirectory>true</includeBaseDirectory>
+  <moduleSets>
+    <moduleSet>
+     <binaries>
+        <includeDependencies>false</includeDependencies>
+        <unpack>false</unpack>
+	    <directoryMode>755</directoryMode>
+	    <fileMode>644</fileMode>
+  		<dependencySets>
+   			<dependencySet>
+     			<outputDirectory>/lib</outputDirectory>
+				<includes>
+					<include>com.google.code.gson:gson*</include>
+					<include>org.eclipse.persistence:javax.persistence</include>
+					<include>org.eclipse.persistence:eclipselink</include>
+				</includes>
+				<unpack>false</unpack>
+  			</dependencySet>
+  		</dependencySets>
+        <outputDirectory>/dist</outputDirectory>
+     </binaries>
+     <includes>
+	<include>security_agents.agents-audit:agents-audit</include>
+	<include>security_agents.agents-cred:agents-cred</include>
+	<include>security_agents.agents-impl:agents-impl</include>
+	<include>security_agents.agents-common:agents-common</include>
+	<include>security_agents.hdfs-agent:hdfs-agent</include>
+     </includes>
+    </moduleSet>
+    <moduleSet>
+     <binaries>
+        <includeDependencies>false</includeDependencies>
+        <outputDirectory>/installer/lib</outputDirectory>
+        <unpack>false</unpack>
+     </binaries>
+     <includes>
+	<include>security_agents.agents-installer:agents-installer</include>
+     </includes>
+    </moduleSet>
+  </moduleSets> 	
+  <fileSets>
+	<fileSet>
+		<outputDirectory>/conf</outputDirectory>
+		<directory>hdfs-agent/conf</directory>
+		<excludes>
+			<exclude>*.cfg</exclude>
+		</excludes>
+	</fileSet>
+	<fileSet>
+		<outputDirectory>/installer/conf</outputDirectory>
+		<directory>hdfs-agent/conf</directory>
+		<includes>
+			<include>*.cfg</include>
+		</includes>
+	</fileSet>
+	<fileSet>
+		<outputDirectory>/</outputDirectory>
+		<directory>hdfs-agent/scripts</directory>
+		<excludes>
+			<exclude>*.sh</exclude>
+		</excludes>
+		<fileMode>700</fileMode>
+	</fileSet>
+	<fileSet>
+		<outputDirectory>/</outputDirectory>
+		<directory>hdfs-agent/scripts</directory>
+		<includes>
+			<include>*.sh</include>
+		</includes>
+		<fileMode>544</fileMode>
+	</fileSet>
+	<fileSet>
+		<outputDirectory>/</outputDirectory>
+		<directory>${project.build.outputDirectory}</directory>
+		<includes>
+			<include>version</include>
+		</includes>
+	</fileSet>
+        <fileSet>
+                <outputDirectory>/</outputDirectory>
+                <directory>${project.build.directory}</directory>
+                <includes>
+                        <include>version</include>
+                </includes>
+				<fileMode>444</fileMode>
+        </fileSet>
+  </fileSets>
+</assembly>

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/7defc061/src/main/assembly/hive-agent.xml
----------------------------------------------------------------------
diff --git a/src/main/assembly/hive-agent.xml b/src/main/assembly/hive-agent.xml
new file mode 100644
index 0000000..51c6edf
--- /dev/null
+++ b/src/main/assembly/hive-agent.xml
@@ -0,0 +1,87 @@
+<assembly>
+  <id>hive</id> 
+  <formats>
+     <format>tar</format>
+  </formats>
+  <baseDirectory>security-agents-${project.version}-hive</baseDirectory>
+  <includeBaseDirectory>true</includeBaseDirectory>
+  <moduleSets>
+    <moduleSet>
+     <binaries>
+        <includeDependencies>false</includeDependencies>
+        <unpack>false</unpack>
+	    <directoryMode>755</directoryMode>
+	    <fileMode>644</fileMode>
+        <dependencySets>
+            <dependencySet>
+                <outputDirectory>/lib</outputDirectory>
+                <includes>
+                    <include>com.google.code.gson:gson*</include>
+					<include>org.eclipse.persistence:eclipselink</include>
+                    <include>org.eclipse.persistence:javax.persistence</include>
+                </includes>
+                <unpack>false</unpack>
+            </dependencySet>
+        </dependencySets>
+        <outputDirectory>/dist</outputDirectory>
+     </binaries>
+     <includes>
+	<include>security_agents.agents-audit:agents-audit</include>
+	<include>security_agents.agents-cred:agents-cred</include>
+	<include>security_agents.agents-impl:agents-impl</include>
+	<include>security_agents.agents-common:agents-common</include>
+	<include>security_agents.hive-agent:hive-agent</include>
+     </includes>
+    </moduleSet>
+    <moduleSet>
+     <binaries>
+        <includeDependencies>false</includeDependencies>
+        <outputDirectory>/installer/lib</outputDirectory>
+        <unpack>false</unpack>
+     </binaries>
+     <includes>
+	<include>security_agents.agents-installer:agents-installer</include>
+     </includes>
+    </moduleSet>
+  </moduleSets> 	
+  <fileSets>
+	<fileSet>
+		<outputDirectory>/conf</outputDirectory>
+		<directory>hive-agent/conf</directory>
+		<excludes>
+			<exclude>*.cfg</exclude>
+		</excludes>
+	</fileSet>
+	<fileSet>
+		<outputDirectory>/installer/conf</outputDirectory>
+		<directory>hive-agent/conf</directory>
+		<includes>
+			<include>*.cfg</include>
+		</includes>
+	</fileSet>
+	<fileSet>
+		<outputDirectory>/</outputDirectory>
+		<directory>hive-agent/scripts</directory>
+		<excludes>
+			<exclude>*.sh</exclude>
+		</excludes>
+		<fileMode>700</fileMode>
+	</fileSet>
+	<fileSet>
+		<outputDirectory>/</outputDirectory>
+		<directory>hive-agent/scripts</directory>
+		<includes>
+			<include>*.sh</include>
+		</includes>
+		<fileMode>544</fileMode>
+	</fileSet>
+        <fileSet>
+                <outputDirectory>/</outputDirectory>
+                <directory>${project.build.directory}</directory>
+                <includes>
+                        <include>version</include>
+                </includes>
+				<fileMode>444</fileMode>
+        </fileSet>
+  </fileSets>
+</assembly>

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/7defc061/src/main/assembly/knox-agent.xml
----------------------------------------------------------------------
diff --git a/src/main/assembly/knox-agent.xml b/src/main/assembly/knox-agent.xml
new file mode 100644
index 0000000..55ab876
--- /dev/null
+++ b/src/main/assembly/knox-agent.xml
@@ -0,0 +1,87 @@
+<assembly>
+  <id>knox</id> 
+  <formats>
+     <format>tar</format>
+  </formats>
+  <baseDirectory>security-agents-${project.version}-knox</baseDirectory>
+  <includeBaseDirectory>true</includeBaseDirectory>
+  <moduleSets>
+    <moduleSet>
+     <binaries>
+        <includeDependencies>false</includeDependencies>
+        <unpack>false</unpack>
+	    <directoryMode>755</directoryMode>
+	    <fileMode>644</fileMode>
+        <dependencySets>
+            <dependencySet>
+                <outputDirectory>/lib</outputDirectory>
+                <includes>
+                    <include>com.google.code.gson:gson*</include>
+					<include>org.eclipse.persistence:eclipselink</include>
+                    <include>org.eclipse.persistence:javax.persistence</include>
+                </includes>
+                <unpack>false</unpack>
+            </dependencySet>
+        </dependencySets>
+        <outputDirectory>/dist</outputDirectory>
+     </binaries>
+     <includes>
+	<include>security_agents.agents-audit:agents-audit</include>
+	<include>security_agents.agents-cred:agents-cred</include>
+	<include>security_agents.agents-impl:agents-impl</include>
+	<include>security_agents.agents-common:agents-common</include>
+	<include>security_agents.knox-agent:knox-agent</include>
+     </includes>
+    </moduleSet>
+    <moduleSet>
+     <binaries>
+        <includeDependencies>false</includeDependencies>
+        <outputDirectory>/installer/lib</outputDirectory>
+        <unpack>false</unpack>
+     </binaries>
+     <includes>
+	<include>security_agents.agents-installer:agents-installer</include>
+     </includes>
+    </moduleSet>
+  </moduleSets> 	
+  <fileSets>
+	<fileSet>
+		<outputDirectory>/conf</outputDirectory>
+		<directory>knox-agent/conf</directory>
+		<excludes>
+			<exclude>*.cfg</exclude>
+		</excludes>
+	</fileSet>
+	<fileSet>
+		<outputDirectory>/installer/conf</outputDirectory>
+		<directory>knox-agent/conf</directory>
+		<includes>
+			<include>*.cfg</include>
+		</includes>
+	</fileSet>
+	<fileSet>
+		<outputDirectory>/</outputDirectory>
+		<directory>knox-agent/scripts</directory>
+		<excludes>
+			<exclude>*.sh</exclude>
+		</excludes>
+		<fileMode>700</fileMode>
+	</fileSet>
+	<fileSet>
+		<outputDirectory>/</outputDirectory>
+		<directory>knox-agent/scripts</directory>
+		<includes>
+			<include>*.sh</include>
+		</includes>
+		<fileMode>544</fileMode>
+	</fileSet>
+        <fileSet>
+                <outputDirectory>/</outputDirectory>
+                <directory>${project.build.directory}</directory>
+                <includes>
+                        <include>version</include>
+                </includes>
+				<fileMode>444</fileMode>
+        </fileSet>
+  </fileSets>
+</assembly>

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/7defc061/src/main/assembly/usersync.xml
----------------------------------------------------------------------
diff --git a/src/main/assembly/usersync.xml b/src/main/assembly/usersync.xml
new file mode 100644
index 0000000..5f4cdf1
--- /dev/null
+++ b/src/main/assembly/usersync.xml
@@ -0,0 +1,104 @@
+<assembly>
+  <id>usync</id> 
+  <formats>
+     <format>tar</format>
+  </formats>
+  <baseDirectory>security-usergroup-sync-${project.version}</baseDirectory>
+  <includeBaseDirectory>true</includeBaseDirectory>
+  <moduleSets>
+    <moduleSet>
+     <binaries>
+        <includeDependencies>false</includeDependencies>
+        <unpack>false</unpack>
+	    <directoryMode>755</directoryMode>
+	    <fileMode>644</fileMode>
+  		<dependencySets>
+   			<dependencySet>
+     			<outputDirectory>/lib</outputDirectory>
+				<includes>
+					<include>com.google.code.gson:gson*</include>
+					<include>com.sun.jersey:jersey-bundle*</include>
+					<include>log4j:log4j*</include>
+					<include>commons-cli:commons-cli*</include>
+					<include>commons-collections:commons-collections*</include>
+					<include>commons-configuration:commons-configuration*</include>
+					<include>commons-lang:commons-lang*</include>
+					<include>commons-logging:commons-logging*</include>
+					<include>com.google.guava:guava*</include>
+					<include>org.apache.hadoop:hadoop-auth*</include>
+					<include>org.slf4j:slf4j-api*</include>
+					<include>com.hortonworks:hadoop-common-plus*</include>
+					<include>com.hortonworks:local-jks-builder*</include>					
+				</includes>
+				<unpack>false</unpack>
+  			</dependencySet>
+  		</dependencySets>
+        <outputDirectory>/dist</outputDirectory>
+     </binaries>
+     <includes>
+	<include>com.hortonworks.hadoop.security:unixauthservice</include>
+	<include>com.hortonworks.hadoop.security:unixusersync</include>
+     </includes>
+    </moduleSet>
+    <moduleSet>
+     <binaries>
+        <includeDependencies>false</includeDependencies>
+        <outputDirectory>/installer/lib</outputDirectory>
+        <unpack>false</unpack>
+     </binaries>
+     <includes>
+	<include>security_agents.agents-installer:agents-installer</include>
+     </includes>
+    </moduleSet>
+  </moduleSets> 	
+  <fileSets>
+	<fileSet>
+	    	<directoryMode>755</directoryMode>
+	    	<fileMode>644</fileMode>
+		<outputDirectory>/conf</outputDirectory>
+		<directory>unixauthservice/conf</directory>
+		<excludes>
+			<exclude>jaas.conf</exclude>
+		</excludes>
+	</fileSet>
+	<fileSet>
+	    	<directoryMode>755</directoryMode>
+		<fileMode>544</fileMode>
+		<outputDirectory>/</outputDirectory>
+		<directory>unixauthservice/scripts</directory>
+		<excludes>
+			<exclude>*.properties</exclude>
+		</excludes>
+	</fileSet>
+	<fileSet>
+	    	<directoryMode>755</directoryMode>
+		<fileMode>700</fileMode>
+		<outputDirectory>/</outputDirectory>
+		<directory>unixauthservice/scripts</directory>
+		<includes>
+			<include>*.properties</include>
+		</includes>
+	</fileSet>
+	<fileSet>
+	    	<directoryMode>755</directoryMode>
+	    	<fileMode>644</fileMode>
+		<outputDirectory>/cert</outputDirectory>
+		<directory>unixauthservice/cert</directory>
+	</fileSet>
+	<fileSet>
+	    	<directoryMode>755</directoryMode>
+	    	<fileMode>500</fileMode>
+		<outputDirectory>/native</outputDirectory>
+		<directory>unixauthnative/native</directory>
+	</fileSet>
+        <fileSet>
+	    	<directoryMode>755</directoryMode>
+                <outputDirectory>/</outputDirectory>
+                <directory>${project.build.directory}</directory>
+                <includes>
+                        <include>version</include>
+                </includes>
+		<fileMode>444</fileMode>
+        </fileSet>
+  </fileSets>
+</assembly>

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/7defc061/ugsync/pom.xml
----------------------------------------------------------------------
diff --git a/ugsync/pom.xml b/ugsync/pom.xml
new file mode 100644
index 0000000..3dc2aa9
--- /dev/null
+++ b/ugsync/pom.xml
@@ -0,0 +1,99 @@
+<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>
+
+    <parent>
+      <groupId>com.hortonworks.hadoop.security</groupId>
+      <artifactId>argus</artifactId>
+      <version>3.5.000</version>
+	  <relativePath>..</relativePath>
+    </parent>
+
+    <artifactId>unixusersync</artifactId>
+
+    <packaging>jar</packaging>
+
+    <name>unixusersync</name>
+    <description>HDP Advanced Security - User, Group sync from sources such as Unix and LDAP</description>
+    <url>http:/hortonworks.com/</url>
+
+
+	<repositories>
+    <repository>
+        <id>usersync.local</id>
+        <name>usersync</name>
+        <url>file:${project.basedir}/ugsync/repo</url>
+    </repository>
+	</repositories>
+
+    <dependencies>
+      <dependency>
+        <groupId>log4j</groupId>
+        <artifactId>log4j</artifactId>
+        <version>${log4j.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>com.google.code.gson</groupId>
+        <artifactId>gson</artifactId>
+        <version>${gson.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>com.sun.jersey</groupId>
+        <artifactId>jersey-bundle</artifactId>
+        <version>${jersey-bundle.version}</version>
+      </dependency>
+      <dependency>
+      	<groupId>commons-cli</groupId>
+      	<artifactId>commons-cli</artifactId>
+      	<version>${commons.cli.version}</version>
+      </dependency>
+      <dependency>
+      	<groupId>commons-collections</groupId>
+      	<artifactId>commons-collections</artifactId>
+      	<version>${commons.collections.version}</version>
+      </dependency>
+      <dependency>
+      	<groupId>commons-configuration</groupId>
+      	<artifactId>commons-configuration</artifactId>
+      	<version>${commons.configuration.version}</version>
+      </dependency>
+      <dependency>
+      	<groupId>commons-lang</groupId>
+      	<artifactId>commons-lang</artifactId>
+      	<version>${commons.lang.version}</version>
+      </dependency>
+      <dependency>
+      	<groupId>commons-logging</groupId>
+      	<artifactId>commons-logging</artifactId>
+      	<version>${commons.logging.version}</version>
+      </dependency>
+      <dependency>
+      	<groupId>com.google.guava</groupId>
+      	<artifactId>guava</artifactId>
+      	<version>${guava.version}</version>
+      </dependency>
+      <dependency>
+      	<groupId>org.apache.hadoop</groupId>
+      	<artifactId>hadoop-auth</artifactId>
+      	<version>${hadoop-auth.version}</version>
+      </dependency>
+      <dependency>
+      	<groupId>org.slf4j</groupId>
+      	<artifactId>slf4j-api</artifactId>
+      	<version>${slf4j-api.version}</version>
+      </dependency>   
+       <dependency>
+    	<groupId>com.hortonworks</groupId>
+    	<artifactId>hadoop-common-plus</artifactId>
+    	<version>3.0.0-SNAPSHOT</version>   	 	
+	  </dependency>
+	  <dependency>
+    	<groupId>com.hortonworks</groupId>
+    	<artifactId>local-jks-builder</artifactId>
+    	<version>0.2</version>  	
+	  </dependency>  
+    </dependencies>
+
+</project>
+

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/7defc061/ugsync/src/main/java/com/xasecure/ldapusersync/process/LdapUserGroupBuilder.java
----------------------------------------------------------------------
diff --git a/ugsync/src/main/java/com/xasecure/ldapusersync/process/LdapUserGroupBuilder.java b/ugsync/src/main/java/com/xasecure/ldapusersync/process/LdapUserGroupBuilder.java
new file mode 100644
index 0000000..34bf538
--- /dev/null
+++ b/ugsync/src/main/java/com/xasecure/ldapusersync/process/LdapUserGroupBuilder.java
@@ -0,0 +1,201 @@
+package com.xasecure.ldapusersync.process;
+
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+import javax.naming.Context;
+import javax.naming.InvalidNameException;
+import javax.naming.NamingEnumeration;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.DirContext;
+import javax.naming.directory.InitialDirContext;
+import javax.naming.directory.SearchControls;
+import javax.naming.directory.SearchResult;
+
+import org.apache.log4j.Logger;
+
+import com.xasecure.unixusersync.config.UserGroupSyncConfig;
+import com.xasecure.usergroupsync.UserGroupSink;
+import com.xasecure.usergroupsync.UserGroupSource;
+
+public class LdapUserGroupBuilder implements UserGroupSource {
+	
+	private static final Logger LOG = Logger.getLogger(LdapUserGroupBuilder.class);
+	
+	private UserGroupSyncConfig config = UserGroupSyncConfig.getInstance();
+	
+	private String userSearchBase;
+	private String extendedSearchFilter;
+	private String userNameAttribute;
+	
+	private DirContext dirContext;
+	private SearchControls searchControls;
+	
+	public static void main(String[] args) throws Throwable {
+		LdapUserGroupBuilder  ugBuilder = new LdapUserGroupBuilder();
+		ugBuilder.init();
+	}
+	
+	public LdapUserGroupBuilder() {
+		LOG.info("LdapUserGroupBuilder created") ;
+	}
+
+	@Override
+	public void init() {
+		// do nothing
+	}
+	
+	private void createDirContext() throws Throwable {
+		LOG.info("LdapUserGroupBuilder initialization started");
+		String ldapUrl = config.getLdapUrl();
+		String ldapBindDn = config.getLdapBindDn();
+		String ldapBindPassword = config.getLdapBindPassword();
+		String ldapAuthenticationMechanism = config.getLdapAuthenticationMechanism();
+		
+		Properties env = new Properties();
+		env.put(Context.INITIAL_CONTEXT_FACTORY, 
+		    "com.sun.jndi.ldap.LdapCtxFactory");
+		env.put(Context.PROVIDER_URL, ldapUrl);
+		
+		env.put(Context.SECURITY_PRINCIPAL, ldapBindDn);
+		env.put(Context.SECURITY_CREDENTIALS, ldapBindPassword);
+		env.put(Context.SECURITY_AUTHENTICATION, ldapAuthenticationMechanism);
+		env.put(Context.REFERRAL, "follow") ;
+
+		dirContext = new InitialDirContext(env);
+		
+		userSearchBase = config.getUserSearchBase();
+		int  userSearchScope = config.getUserSearchScope();
+		String userObjectClass = config.getUserObjectClass();
+		String userSearchFilter = config.getUserSearchFilter();
+		extendedSearchFilter = "(objectclass=" + userObjectClass + ")";
+		if (userSearchFilter != null && !userSearchFilter.trim().isEmpty()) {
+			String customFilter = userSearchFilter.trim();
+			if (!customFilter.startsWith("(")) {
+				customFilter = "(" + customFilter + ")";
+			}
+			extendedSearchFilter = "(&" + extendedSearchFilter + customFilter + ")";
+		}
+		
+		userNameAttribute = config.getUserNameAttribute();
+		
+		Set<String> userSearchAttributes = new HashSet<String>();
+		userSearchAttributes.add(userNameAttribute);
+		
+		Set<String> userGroupNameAttributeSet = config.getUserGroupNameAttributeSet();
+		for (String useGroupNameAttribute : userGroupNameAttributeSet) {
+			userSearchAttributes.add(useGroupNameAttribute);
+		}
+		
+		searchControls = new SearchControls();
+		searchControls.setSearchScope(userSearchScope);
+		searchControls.setReturningAttributes(userSearchAttributes.toArray(
+				new String[userSearchAttributes.size()]));
+		
+		if (LOG.isInfoEnabled()) {
+			LOG.info("LdapUserGroupBuilder initialization completed with --  "
+					+ "ldapUrl: " + ldapUrl 
+					+ ",  ldapBindDn: " + ldapBindDn
+					+ ",  ldapBindPassword: ***** " 
+					+ ",  ldapAuthenticationMechanism: "
+					+ ldapAuthenticationMechanism + ",  userSearchBase: "
+					+ userSearchBase + ",  userSearchScope: " + userSearchScope
+					+ ",  userObjectClass: " + userObjectClass
+					+ ",  userSearchFilter: " + userSearchFilter
+					+ ",  extendedSearchFilter: " + extendedSearchFilter
+					+ ",  userNameAttribute: " + userNameAttribute
+					+ ",  userSearchAttributes: " + userSearchAttributes	);
+		}
+		
+	}
+	
+	private void closeDirContext() throws Throwable {
+		if (dirContext != null) {
+			dirContext.close();
+		}
+	}
+	
+	@Override
+	public boolean isChanged() {
+		// we do not want to get the full ldap dit and check whether anything has changed
+		return true;
+	}
+
+	@Override
+	public void updateSink(UserGroupSink sink) throws Throwable {
+		LOG.info("LDAPUserGroupBuilder updateSink started");
+		try {
+			createDirContext();
+			int counter = 0;
+			NamingEnumeration<SearchResult> searchResultEnum = dirContext
+					.search(userSearchBase, extendedSearchFilter,
+							searchControls);
+			while (searchResultEnum.hasMore()) { 
+				// searchResults contains all the user entries
+				final SearchResult userEntry = searchResultEnum.next();
+				String userName = (String) userEntry.getAttributes()
+						.get(userNameAttribute).get();
+				Set<String> groups = new HashSet<String>();
+				Set<String> userGroupNameAttributeSet = config.getUserGroupNameAttributeSet();
+				for (String useGroupNameAttribute : userGroupNameAttributeSet) {
+					Attribute userGroupfAttribute = userEntry.getAttributes().get(useGroupNameAttribute);
+					if(userGroupfAttribute != null) {
+						NamingEnumeration<?> groupEnum = userGroupfAttribute.getAll();
+						while (groupEnum.hasMore()) {
+							groups.add(getShortGroupName((String) groupEnum.next()));
+						}
+					}
+				}
+
+				List<String> groupList = new ArrayList<String>(groups);
+				counter++;
+				if (counter <= 1000) { 
+					if (LOG.isInfoEnabled()) {
+						LOG.info("Updating user count: " + counter
+								+ ", userName: " + userName + ", groupList: "
+								+ groupList);
+					}
+				} else {
+					if (LOG.isTraceEnabled()) {
+						LOG.trace("Updating user count: " + counter
+								+ ", userName: " + userName + ", groupList: "
+								+ groupList);
+					}
+				}
+				try {
+					sink.addOrUpdateUser(userName, groupList);
+				} catch (Throwable t) {
+					LOG.error("sink.addOrUpdateUser failed with exception: " + t.getMessage()
+							+ ", for user: " + userName
+							+ ", groups: " + groupList);
+				}
+			}
+			LOG.info("LDAPUserGroupBuilder.updateSink() completed with user count: "
+					+ counter);
+		} finally {
+			closeDirContext();
+		}
+	}
+	
+	private static String getShortGroupName(String longGroupName) throws InvalidNameException {
+		if (longGroupName == null) {
+			return null;
+		}
+		StringTokenizer stc = new StringTokenizer(longGroupName, ",");
+		String firstToken = stc.nextToken();
+		StringTokenizer ste = new StringTokenizer(firstToken, "=");
+		String groupName =  ste.nextToken();
+		if (ste.hasMoreTokens()) {
+			groupName = ste.nextToken();
+		}
+		groupName = groupName.trim();
+		LOG.info("longGroupName: " + longGroupName + ", groupName: " + groupName);
+		return groupName;
+	}
+	
+}

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/7defc061/ugsync/src/main/java/com/xasecure/ldapusersync/process/PolicyMgrUserGroupBuilder.java
----------------------------------------------------------------------
diff --git a/ugsync/src/main/java/com/xasecure/ldapusersync/process/PolicyMgrUserGroupBuilder.java b/ugsync/src/main/java/com/xasecure/ldapusersync/process/PolicyMgrUserGroupBuilder.java
new file mode 100644
index 0000000..6fc55ae
--- /dev/null
+++ b/ugsync/src/main/java/com/xasecure/ldapusersync/process/PolicyMgrUserGroupBuilder.java
@@ -0,0 +1,684 @@
+package com.xasecure.ldapusersync.process;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.net.UnknownHostException;
+import java.security.KeyStore;
+import java.security.SecureRandom;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.regex.Pattern;
+
+import javax.net.ssl.HostnameVerifier;
+import javax.net.ssl.KeyManager;
+import javax.net.ssl.KeyManagerFactory;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLSession;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.TrustManagerFactory;
+import javax.ws.rs.core.MediaType;
+
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.sun.jersey.api.client.Client;
+import com.sun.jersey.api.client.ClientResponse;
+import com.sun.jersey.api.client.WebResource;
+import com.sun.jersey.api.client.config.ClientConfig;
+import com.sun.jersey.api.client.config.DefaultClientConfig;
+import com.sun.jersey.client.urlconnection.HTTPSProperties;
+import com.xasecure.unixusersync.config.UserGroupSyncConfig;
+import com.xasecure.unixusersync.model.GetXGroupListResponse;
+import com.xasecure.unixusersync.model.GetXUserGroupListResponse;
+import com.xasecure.unixusersync.model.GetXUserListResponse;
+import com.xasecure.unixusersync.model.MUserInfo;
+import com.xasecure.unixusersync.model.XGroupInfo;
+import com.xasecure.unixusersync.model.XUserGroupInfo;
+import com.xasecure.unixusersync.model.XUserInfo;
+import com.xasecure.usergroupsync.UserGroupSink;
+
+public class PolicyMgrUserGroupBuilder implements UserGroupSink {
+	
+	private static final Logger LOG = Logger.getLogger(PolicyMgrUserGroupBuilder.class) ;
+	
+	public static final String PM_USER_LIST_URI  = "/service/xusers/users/" ;				// GET
+	private static final String PM_ADD_USER_URI  = "/service/xusers/users/" ;				// POST
+	
+	public static final String PM_GROUP_LIST_URI = "/service/xusers/groups/" ;				// GET
+	private static final String PM_ADD_GROUP_URI = "/service/xusers/groups/" ;				// POST
+	
+	public static final String PM_USER_GROUP_MAP_LIST_URI = "/service/xusers/groupusers/" ;		// GET
+	private static final String PM_ADD_USER_GROUP_LINK_URI = "/service/xusers/groupusers/" ;	// POST
+	
+	private static final String PM_DEL_USER_GROUP_LINK_URI = "/service/xusers/group/${groupName}/user/${userName}" ; // DELETE
+	
+	private static final String PM_ADD_LOGIN_USER_URI = "/service/users/default" ;			// POST
+	
+	private static String LOCAL_HOSTNAME = "unknown" ;
+	private String recordsToPullPerCall = "1000" ;
+	private boolean isMockRun = false ;
+	private String policyMgrBaseUrl ;
+	
+	private UserGroupSyncConfig  config = UserGroupSyncConfig.getInstance() ;
+
+	private List<XGroupInfo> 			xgroupList = new ArrayList<XGroupInfo>() ;
+	private List<XUserInfo> 			xuserList = new ArrayList<XUserInfo>() ;
+	private List<XUserGroupInfo> 		xusergroupList = new ArrayList<XUserGroupInfo>() ;
+	private HashMap<String,XUserInfo>  	userId2XUserInfoMap = new HashMap<String,XUserInfo>() ;
+	private HashMap<String,XUserInfo>  	userName2XUserInfoMap = new HashMap<String,XUserInfo>() ;
+	private HashMap<String,XGroupInfo>  groupName2XGroupInfoMap = new HashMap<String,XGroupInfo>() ;
+	
+	private String keyStoreFile =  null ;
+	private String keyStoreFilepwd = null; 
+	private String trustStoreFile = null ;
+	private String trustStoreFilepwd = null ;
+	private String keyStoreType = null ;
+	private String trustStoreType = null ;
+	private HostnameVerifier hv =  null ;
+
+	private SSLContext sslContext = null ;
+
+	
+	static {
+		try {
+			LOCAL_HOSTNAME = java.net.InetAddress.getLocalHost().getHostName();
+		} catch (UnknownHostException e) {
+			LOCAL_HOSTNAME = "unknown" ;
+		} 
+	}
+	
+	
+	public static void main(String[] args) throws Throwable {
+		PolicyMgrUserGroupBuilder  ugbuilder = new PolicyMgrUserGroupBuilder() ;
+		ugbuilder.init() ;
+//		ugbuilder.print();
+//		ugbuilder.addMUser("testuser") ;
+//		ugbuilder.addXUserInfo("testuser") ;
+//		ugbuilder.addXGroupInfo("testgroup") ;
+// 		XUserInfo u = ugbuilder.addXUserInfo("testuser") ;
+//		XGroupInfo g = ugbuilder.addXGroupInfo("testgroup") ;
+//		 ugbuilder.addXUserGroupInfo(u, g) ;
+		
+	}
+
+	
+	public void init() throws Throwable {
+		recordsToPullPerCall = config.getMaxRecordsPerAPICall() ;
+		policyMgrBaseUrl = config.getPolicyManagerBaseURL() ;
+		isMockRun = config.isMockRunEnabled() ;
+		
+		if (isMockRun) {
+			LOG.setLevel(Level.DEBUG) ;
+		}
+		
+		keyStoreFile =  config.getSSLKeyStorePath() ;
+		keyStoreFilepwd = config.getSSLKeyStorePathPassword() ; 
+		trustStoreFile = config.getSSLTrustStorePath() ;
+		trustStoreFilepwd = config.getSSLTrustStorePathPassword() ;
+		keyStoreType = KeyStore.getDefaultType() ;
+		trustStoreType = KeyStore.getDefaultType() ;
+		
+		buildUserGroupInfo() ;
+	}
+	
+	private void buildUserGroupInfo() throws Throwable {
+		buildGroupList(); 
+		buildUserList();
+		buildUserGroupLinkList() ;
+		rebuildUserGroupMap() ;
+		if (LOG.isDebugEnabled()) {
+			this.print(); 
+		}
+	}
+	
+	private String getURL(String uri) {
+		String ret = null ;
+		ret = policyMgrBaseUrl + (uri.startsWith("/") ? uri : ("/" + uri)) ;
+		return ret;
+	}
+	
+	
+	
+	private void rebuildUserGroupMap() {
+		
+		for(XUserInfo user : xuserList) {
+			addUserToList(user);
+		}
+		
+		for(XGroupInfo group : xgroupList) {
+			addGroupToList(group);
+		}
+		
+		for(XUserGroupInfo ug : xusergroupList) {
+			addUserGroupToList(ug);
+		}
+	}
+	
+	
+	private void addUserToList(XUserInfo aUserInfo) {
+		if (! xuserList.contains(aUserInfo)) {
+			xuserList.add(aUserInfo) ;
+		}
+		
+		String userId = aUserInfo.getId() ;
+		
+		if (userId != null) {
+			userId2XUserInfoMap.put(userId, aUserInfo) ;
+		}
+		
+		String userName = aUserInfo.getName();
+		
+		if (userName != null) {
+			userName2XUserInfoMap.put(userName, aUserInfo) ;
+		}
+	}
+	
+
+	private void addGroupToList(XGroupInfo aGroupInfo) {
+		
+		if (! xgroupList.contains(aGroupInfo) ) {
+			xgroupList.add(aGroupInfo) ;
+		}
+
+		if (aGroupInfo.getName() != null) {
+			groupName2XGroupInfoMap.put(aGroupInfo.getName(), aGroupInfo) ;
+		}
+
+	}
+	
+	
+	private void addUserGroupToList(XUserGroupInfo ugInfo) {
+		String userId = ugInfo.getUserId() ;
+		
+		if (userId != null) {
+			XUserInfo user = userId2XUserInfoMap.get(userId) ;
+			
+			if (user != null) {
+				List<String> groups = user.getGroups() ;
+				if (! groups.contains(ugInfo.getGroupName())) {
+					groups.add(ugInfo.getGroupName()) ;
+				}
+			}
+		}
+	}
+
+	private void delUserGroupFromList(XUserInfo userInfo, XGroupInfo groupInfo) {
+		List<String> groups = userInfo.getGroups() ;
+		if (groups.contains(groupInfo.getName())) {
+			groups.remove(groupInfo.getName()) ;
+		}
+	}
+	
+	private void print() {
+		LOG.debug("Number of users read [" + xuserList.size() + "]");
+		for(XUserInfo user : xuserList) {
+			LOG.debug("USER: " + user.getName()) ;
+			for(String group : user.getGroups()) {
+				LOG.debug("\tGROUP: " + group) ;
+			}
+		}
+	}
+
+	@Override
+	public void addOrUpdateUser(String userName, List<String> groups) {
+		XUserInfo user = userName2XUserInfoMap.get(userName) ;
+		
+		if (groups == null) {
+			groups = new ArrayList<String>() ;
+		}
+		
+		if (user == null) {    // Does not exists
+			LOG.debug("INFO: addPMAccount(" + userName + ")" ) ;
+			if (! isMockRun) {
+				addMUser(userName) ;
+			}
+			
+			LOG.debug("INFO: addPMXAUser(" + userName + ")" ) ;
+			if (! isMockRun) {
+				user = addXUserInfo(userName) ;
+			}
+			
+ 			for(String g : groups) {
+ 				LOG.debug("INFO: addPMXAGroupToUser(" + userName + "," + g + ")" ) ;
+ 			}
+ 			if (! isMockRun ) { 
+ 				addXUserGroupInfo(user, groups) ;
+ 			}
+		}
+		else {					// Validate group memberships
+			List<String> oldGroups = user.getGroups() ;
+			
+			List<String> addGroups = new ArrayList<String>() ;
+			List<String> delGroups = new ArrayList<String>() ;
+			
+			for(String group : groups) {
+				if (! oldGroups.contains(group)) {
+					addGroups.add(group) ;
+				}
+			}
+			
+			for(String group : oldGroups) {
+				if (! groups.contains(group) ) {
+					delGroups.add(group) ;
+				}
+			}
+			
+ 			for(String g : addGroups) {
+ 				LOG.debug("INFO: addPMXAGroupToUser(" + userName + "," + g + ")" ) ;
+ 			}
+ 			if (! isMockRun) {
+ 				addXUserGroupInfo(user, addGroups) ;
+ 			}
+ 			
+ 			for(String g : delGroups) {
+ 				LOG.debug("INFO: delPMXAGroupFromUser(" + userName + "," + g + ")" ) ;
+ 			}
+ 			
+ 			if (! isMockRun ) {
+ 				delXUserGroupInfo(user, delGroups) ;
+ 			}
+			
+		}
+	}
+	
+	
+	private void buildGroupList() {
+		
+	    Client c = getClient() ;
+	    
+	    int totalCount = 100 ;
+	    int retrievedCount = 0 ;
+	    
+	    while (retrievedCount < totalCount) {
+	    	
+		    WebResource r = c.resource(getURL(PM_GROUP_LIST_URI))
+		    					.queryParam("pageSize", recordsToPullPerCall)
+		    					.queryParam("startIndex", String.valueOf(retrievedCount)) ;
+		    
+		    String response = r.accept(MediaType.APPLICATION_JSON_TYPE).get(String.class);
+		    
+		    LOG.debug("RESPONSE: [" + response + "]") ;
+		    		    
+		    Gson gson = new GsonBuilder().create() ;
+	
+		    GetXGroupListResponse groupList = gson.fromJson(response, GetXGroupListResponse.class) ;
+		    
+		    totalCount = groupList.getTotalCount() ;
+		    
+		    if (groupList.getXgroupInfoList() != null) {
+		    	xgroupList.addAll(groupList.getXgroupInfoList()) ;
+		    	retrievedCount = xgroupList.size() ;
+
+		    	for(XGroupInfo g : groupList.getXgroupInfoList()) {
+		    		LOG.debug("GROUP:  Id:" + g.getId() + ", Name: " + g.getName() + ", Description: " + g.getDescription()) ;
+			    }
+		    }
+	    }
+
+	}
+
+	
+	private void buildUserList() {
+		
+	    Client c = getClient() ;	
+	    
+	    int totalCount = 100 ;
+	    int retrievedCount = 0 ;
+	    
+	    while (retrievedCount < totalCount) {
+		    
+		    WebResource r = c.resource(getURL(PM_USER_LIST_URI))
+		    					.queryParam("pageSize", recordsToPullPerCall)
+		    					.queryParam("startIndex", String.valueOf(retrievedCount)) ;
+		    
+		    String response = r.accept(MediaType.APPLICATION_JSON_TYPE).get(String.class);
+		    
+		    Gson gson = new GsonBuilder().create() ;
+	
+		    LOG.debug("RESPONSE: [" + response + "]") ;
+	
+		    GetXUserListResponse userList = gson.fromJson(response, GetXUserListResponse.class) ;
+		    
+		    totalCount = userList.getTotalCount() ;
+		    
+		    if (userList.getXuserInfoList() != null) {
+		    	xuserList.addAll(userList.getXuserInfoList()) ;
+		    	retrievedCount = xuserList.size() ;
+
+		    	for(XUserInfo u : userList.getXuserInfoList()) {
+			    	LOG.debug("USER: Id:" + u.getId() + ", Name: " + u.getName() + ", Description: " + u.getDescription()) ;
+			    }
+		    }
+	    }
+	    
+	}
+	
+	
+	private void buildUserGroupLinkList() {
+
+		Client c = getClient() ;
+	    
+	    int totalCount = 100 ;
+	    int retrievedCount = 0 ;
+	    
+	    while (retrievedCount < totalCount) {
+		    
+		    WebResource r = c.resource(getURL(PM_USER_GROUP_MAP_LIST_URI))
+		    					.queryParam("pageSize", recordsToPullPerCall)
+		    					.queryParam("startIndex", String.valueOf(retrievedCount)) ;
+		    
+		    String response = r.accept(MediaType.APPLICATION_JSON_TYPE).get(String.class);
+		    
+		    LOG.debug("RESPONSE: [" + response + "]") ;
+		    
+		    Gson gson = new GsonBuilder().create() ;
+	
+		    GetXUserGroupListResponse usergroupList = gson.fromJson(response, GetXUserGroupListResponse.class) ;
+		    
+		    totalCount = usergroupList.getTotalCount() ;
+		    
+		    if (usergroupList.getXusergroupInfoList() != null) {
+		    	xusergroupList.addAll(usergroupList.getXusergroupInfoList()) ;
+		    	retrievedCount = xusergroupList.size() ;
+
+		    	for(XUserGroupInfo ug : usergroupList.getXusergroupInfoList()) {
+			    	LOG.debug("USER_GROUP: UserId:" + ug.getUserId() + ", Name: " + ug.getGroupName()) ;
+			    }
+		    }
+	    }
+
+	}
+	
+	
+	
+	private XUserInfo addXUserInfo(String aUserName) {
+		XUserInfo ret = null ;
+		
+		XUserInfo addUser = new XUserInfo() ;
+		addUser.setName(aUserName);
+		addUser.setDescription(aUserName + " - add from Unix box") ;
+		
+	    Client c = getClient() ;
+	    
+	    WebResource r = c.resource(getURL(PM_ADD_USER_URI)) ;
+	    
+	    Gson gson = new GsonBuilder().create() ;
+
+	    String jsonString = gson.toJson(addUser) ;
+	    
+	    String response = r.accept(MediaType.APPLICATION_JSON_TYPE).type(MediaType.APPLICATION_JSON_TYPE).post(String.class, jsonString) ;
+	    
+	    LOG.debug("RESPONSE: [" + response + "]") ;
+
+	    ret = gson.fromJson(response, XUserInfo.class) ;
+
+	    if (ret != null) {
+	    	addUserToList(ret);
+	    }
+		
+		return ret ;
+	}
+	
+	private XGroupInfo addXGroupInfo(String aGroupName) {
+		
+		XGroupInfo ret = null ;
+		
+		XGroupInfo addGroup = new XGroupInfo() ;
+		addGroup.setName(aGroupName);
+		addGroup.setDescription(aGroupName + " - add from Unix box") ;
+		addGroup.setGroupType("1") ;
+		
+	    Client c = getClient() ;
+	    
+	    WebResource r = c.resource(getURL(PM_ADD_GROUP_URI)) ;
+	    
+	    Gson gson = new GsonBuilder().create() ;
+
+	    String jsonString = gson.toJson(addGroup) ;
+	    
+	    String response = r.accept(MediaType.APPLICATION_JSON_TYPE).type(MediaType.APPLICATION_JSON_TYPE).post(String.class, jsonString) ;
+	    
+	    LOG.debug("RESPONSE: [" + response + "]") ;
+
+	    ret = gson.fromJson(response, XGroupInfo.class) ;
+	    
+	    if (ret != null) {
+	    	addGroupToList(ret);
+	    }
+		
+		return ret ;
+	}
+	
+	
+	
+	private void addXUserGroupInfo(XUserInfo aUserInfo, List<String> aGroupList) {
+		for(String groupName : aGroupList) {
+			XGroupInfo group = groupName2XGroupInfoMap.get(groupName) ;
+			if (group == null) {
+				group = addXGroupInfo(groupName) ;
+			}
+			addXUserGroupInfo(aUserInfo, group) ;
+		}
+	}
+
+	private XUserGroupInfo addXUserGroupInfo(XUserInfo aUserInfo, XGroupInfo aGroupInfo) {
+		
+		XUserGroupInfo ret = null ;
+		
+		XUserGroupInfo ugInfo = new XUserGroupInfo() ;
+		
+		ugInfo.setUserId(aUserInfo.getId());
+		ugInfo.setGroupName(aGroupInfo.getName()) ;
+		// ugInfo.setParentGroupId("1");
+		
+	    Client c = getClient() ;
+	    
+	    WebResource r = c.resource(getURL(PM_ADD_USER_GROUP_LINK_URI)) ;
+	    
+	    Gson gson = new GsonBuilder().create() ;
+
+	    String jsonString = gson.toJson(ugInfo) ;
+	    
+	    String response = r.accept(MediaType.APPLICATION_JSON_TYPE).type(MediaType.APPLICATION_JSON_TYPE).post(String.class, jsonString) ;
+	    
+	    LOG.debug("RESPONSE: [" + response + "]") ;
+
+	    ret = gson.fromJson(response, XUserGroupInfo.class) ;
+	    
+	    if (ret != null) {
+	    	addUserGroupToList(ret);
+	    }
+		
+		return ret ;
+		
+	}
+	
+	private void delXUserGroupInfo(XUserInfo aUserInfo, List<String> aGroupList) {
+		for(String groupName : aGroupList) {
+			XGroupInfo group = groupName2XGroupInfoMap.get(groupName) ;
+			if (group != null) {
+				delXUserGroupInfo(aUserInfo, group) ;
+			}
+		}
+	}
+
+	private void delXUserGroupInfo(XUserInfo aUserInfo, XGroupInfo aGroupInfo) {
+		
+		Client c = getClient() ;
+	    
+	    String uri = PM_DEL_USER_GROUP_LINK_URI.replaceAll(Pattern.quote("${groupName}"), aGroupInfo.getName()).replaceAll(Pattern.quote("${userName}"), aUserInfo.getName()) ;
+	    
+	    WebResource r = c.resource(getURL(uri)) ;
+	    
+	    ClientResponse response = r.delete(ClientResponse.class) ;
+	    
+	    LOG.debug("RESPONSE: [" + response.toString() + "]") ;
+
+	    
+	    if (response.getStatus() == 200) {
+	    	delUserGroupFromList(aUserInfo, aGroupInfo) ;
+	    }
+		
+	}
+	
+	
+	private MUserInfo addMUser(String aUserName) {
+		
+		MUserInfo ret = null ;
+		
+		MUserInfo userInfo = new MUserInfo() ;
+
+		userInfo.setLoginId(aUserName);
+		userInfo.setFirstName(aUserName);
+		userInfo.setLastName(aUserName);
+		userInfo.setEmailAddress(aUserName + "@" + LOCAL_HOSTNAME);
+		
+	    Client c = getClient() ;
+	    
+	    WebResource r = c.resource(getURL(PM_ADD_LOGIN_USER_URI)) ;
+	    
+	    Gson gson = new GsonBuilder().create() ;
+
+	    String jsonString = gson.toJson(userInfo) ;
+	    
+	    String response = r.accept(MediaType.APPLICATION_JSON_TYPE).type(MediaType.APPLICATION_JSON_TYPE).post(String.class, jsonString) ;
+	    
+	    LOG.debug("RESPONSE[" + response + "]") ;
+	    
+	    ret = gson.fromJson(response, MUserInfo.class) ;
+	    
+	    LOG.debug("MUser Creation successful " + ret);
+		
+		return ret ;
+
+	}
+
+	
+	private synchronized Client getClient() {
+		
+		Client ret = null; 
+		
+		if (policyMgrBaseUrl.startsWith("https://")) {
+			
+			ClientConfig config = new DefaultClientConfig();
+			
+			if (sslContext == null) {
+				
+				try {
+
+				KeyManager[] kmList = null;
+				TrustManager[] tmList = null;
+	
+				if (keyStoreFile != null && keyStoreFilepwd != null) {
+	
+					KeyStore keyStore = KeyStore.getInstance(keyStoreType);
+					InputStream in = null ;
+					try {
+						in = getFileInputStream(keyStoreFile) ;
+						if (in == null) {
+							LOG.error("Unable to obtain keystore from file [" + keyStoreFile + "]");
+							return ret ;
+						}
+						keyStore.load(in, keyStoreFilepwd.toCharArray());
+						KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
+						keyManagerFactory.init(keyStore, keyStoreFilepwd.toCharArray());
+						kmList = keyManagerFactory.getKeyManagers();
+					}
+					finally {
+						if (in != null) {
+							in.close(); 
+						}
+					}
+					 
+				}
+	
+				if (trustStoreFile != null && trustStoreFilepwd != null) {
+	
+					KeyStore trustStore = KeyStore.getInstance(trustStoreType);
+					InputStream in = null ;
+					try {
+						in = getFileInputStream(trustStoreFile) ;
+						if (in == null) {
+							LOG.error("Unable to obtain keystore from file [" + trustStoreFile + "]");
+							return ret ;
+						}
+						trustStore.load(in, trustStoreFilepwd.toCharArray());
+						TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
+						trustManagerFactory.init(trustStore);
+						tmList = trustManagerFactory.getTrustManagers();
+					}
+					finally {
+						if (in != null) {
+							in.close() ;
+						}
+					}
+				}
+
+				sslContext = SSLContext.getInstance("SSL");
+	
+				sslContext.init(kmList, tmList, new SecureRandom());
+
+				hv = new HostnameVerifier() {
+					public boolean verify(String urlHostName, SSLSession session) {
+						return session.getPeerHost().equals(urlHostName);
+					}
+				};
+				}
+				catch(Throwable t) {
+					throw new RuntimeException("Unable to create SSLConext for communication to policy manager", t);
+				}
+
+			}
+
+			config.getProperties().put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES, new HTTPSProperties(hv, sslContext));
+
+			ret = Client.create(config);
+
+			
+		}
+		else {
+			ClientConfig cc = new DefaultClientConfig();
+		    cc.getProperties().put(ClientConfig.PROPERTY_FOLLOW_REDIRECTS, true);
+		    ret = Client.create(cc);	
+		}
+		
+		return ret ;
+	}
+	
+	private InputStream getFileInputStream(String path) throws FileNotFoundException {
+
+		InputStream ret = null;
+
+		File f = new File(path);
+
+		if (f.exists()) {
+			ret = new FileInputStream(f);
+		} else {
+			ret = getClass().getResourceAsStream(path);
+			
+			if (ret == null) {
+				if (! path.startsWith("/")) {
+					ret = getClass().getResourceAsStream("/" + path);
+				}
+			}
+			
+			if (ret == null) {
+				ret = ClassLoader.getSystemClassLoader().getResourceAsStream(path) ;
+				if (ret == null) {
+					if (! path.startsWith("/")) {
+						ret = ClassLoader.getSystemResourceAsStream("/" + path);
+					}
+				}
+			}
+		}
+
+		return ret;
+	}
+
+	
+}


Mime
View raw message