ranger-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From omal...@apache.org
Subject [22/44] ARGUS-1. Initial code commit (Selvamohan Neethiraj via omalley)
Date Thu, 14 Aug 2014 20:50:33 GMT
http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/7defc061/security-admin/src/main/java/com/xasecure/service/XAssetService.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/com/xasecure/service/XAssetService.java b/security-admin/src/main/java/com/xasecure/service/XAssetService.java
new file mode 100644
index 0000000..7b0db7a
--- /dev/null
+++ b/security-admin/src/main/java/com/xasecure/service/XAssetService.java
@@ -0,0 +1,307 @@
+package com.xasecure.service;
+
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import com.xasecure.common.JSONUtil;
+import com.xasecure.common.MessageEnums;
+import com.xasecure.common.PropertiesUtil;
+import com.xasecure.common.SearchField;
+import com.xasecure.common.StringUtil;
+import com.xasecure.entity.*;
+
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.type.TypeReference;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Service;
+
+import com.xasecure.common.AppConstants;
+import com.xasecure.common.view.VTrxLogAttr;
+import com.xasecure.db.XADaoManager;
+import com.xasecure.util.XAEnumUtil;
+import com.xasecure.view.*;
+
+@Service
+@Scope("singleton")
+public class XAssetService extends XAssetServiceBase<XXAsset, VXAsset> {
+
+	@Autowired
+	JSONUtil jsonUtil;
+
+	@Autowired
+	XADaoManager appDaoMgr;
+	
+	@Autowired
+	StringUtil stringUtil;
+	
+	static HashMap<String, VTrxLogAttr> trxLogAttrs = new HashMap<String, VTrxLogAttr>();
+	static {
+		trxLogAttrs.put("name", new VTrxLogAttr("name", "Repository Name", false));
+		trxLogAttrs.put("description", new VTrxLogAttr("description", "Repository Description", false));
+		trxLogAttrs.put("activeStatus", new VTrxLogAttr("activeStatus", "Repository Status", true));
+		trxLogAttrs.put("config", new VTrxLogAttr("config", "Connection Configurations", false));
+	}
+
+	private String hiddenPasswordString;
+	
+	@Autowired
+	XAEnumUtil xaEnumUtil;
+	
+	public XAssetService(){
+		super();
+		hiddenPasswordString = PropertiesUtil.getProperty("xa.password.hidden", "*****");
+		searchFields.add(new SearchField("status", "obj.activeStatus",
+				SearchField.DATA_TYPE.INT_LIST, SearchField.SEARCH_TYPE.FULL));
+	}
+
+	@Override
+	protected void validateForCreate(VXAsset vObj) {
+		XXAsset xxAsset = appDaoMgr.getXXAsset()
+				.findByAssetName(vObj.getName());
+		if (xxAsset != null) {
+			String errorMessage = "Repository Name already exists";
+			throw restErrorUtil.createRESTException(errorMessage,
+					MessageEnums.INVALID_INPUT_DATA, null, null,
+					vObj.toString());
+		}
+		if(vObj.getName()==null || vObj.getName().trim().length()==0){
+			String errorMessage = "Repository Name can't be empty";
+			throw restErrorUtil.createRESTException(errorMessage,
+					MessageEnums.INVALID_INPUT_DATA, null, null,
+					vObj.toString());
+		}
+		
+		validateConfig(vObj);
+	}
+
+	@Override
+	protected void validateForUpdate(VXAsset vObj, XXAsset mObj) {
+		if (!vObj.getName().equalsIgnoreCase(mObj.getName())) {
+			validateForCreate(vObj);
+		}else{		
+		validateConfig(vObj);
+		}
+	}
+
+	@Override
+	protected XXAsset mapViewToEntityBean(VXAsset vObj, XXAsset mObj,
+			int OPERATION_CONTEXT) {
+		String oldConfig = (mObj != null) ? mObj.getConfig() : null;
+		super.mapViewToEntityBean(vObj, mObj, OPERATION_CONTEXT);
+		String config = vObj.getConfig();
+		if (config != null && !config.isEmpty()) {
+			Map<String, String> configMap = jsonUtil.jsonToMap(config);
+			Entry<String, String> passwordEntry = getPasswordEntry(configMap);
+			if (passwordEntry != null) {
+				// If "*****" then get password from db and update
+				String password = passwordEntry.getValue();
+				if (password != null) {
+					if (password.equals(hiddenPasswordString)) {
+						if (oldConfig != null && !oldConfig.isEmpty()) {
+							Map<String, String> oldConfigMap = jsonUtil
+									.jsonToMap(oldConfig);
+							Entry<String, String> oldPasswordEntry 
+									= getPasswordEntry(oldConfigMap);
+							if (oldPasswordEntry != null) {
+								configMap.put(oldPasswordEntry.getKey(),
+										oldPasswordEntry.getValue());
+							}
+						}
+					}
+					config = jsonUtil.readMapToString(configMap);
+				}
+			}
+		}
+		mObj.setConfig(config);
+		return mObj;
+	}
+
+	@Override
+	protected VXAsset mapEntityToViewBean(VXAsset vObj, XXAsset mObj) {
+		vObj = super.mapEntityToViewBean(vObj, mObj);
+		String config = vObj.getConfig();
+		if (config != null && !config.isEmpty()) {
+			Map<String, String> configMap = jsonUtil.jsonToMap(config);
+			Entry<String, String> passwordEntry = getPasswordEntry(configMap);
+			if (passwordEntry != null) {
+				configMap.put(passwordEntry.getKey(), hiddenPasswordString);
+			}
+			config = jsonUtil.readMapToString(configMap);
+		}
+		vObj.setConfig(config);
+		return vObj;
+	}
+	
+	private Entry<String, String> getPasswordEntry(Map<String, String> configMap) {
+		Entry<String, String> entry = null;
+		
+		for(Entry<String, String> e : configMap.entrySet()) {
+			if(e.getKey().toLowerCase().contains("password")){
+				entry = e;
+				break;
+			}
+		}
+		
+		return entry;
+	}
+	
+	public void validateConfig(VXAsset vObj) {
+		HashMap<String, Object> configrationMap = null;
+		if (vObj.getAssetType() == AppConstants.ASSET_HDFS) {
+			ObjectMapper objectMapper = new ObjectMapper();
+			TypeReference<HashMap<String, Object>> typeRef = new TypeReference
+					<HashMap<String, Object>>() {};
+			try {
+				configrationMap = objectMapper.readValue(vObj.getConfig(),
+						typeRef);
+			} catch (Exception e) {
+				logger.error("Error in config json", e);
+			}
+
+			if (configrationMap != null) {
+				String fs_default_name = configrationMap.get("fs.default.name")
+						.toString();
+
+				if (fs_default_name.isEmpty()) {
+					throw restErrorUtil.createRESTException(
+							"serverMsg.fsDefaultNameEmptyError",
+							MessageEnums.INVALID_INPUT_DATA, null, "fs.default.name",
+							vObj.toString());
+				}
+				/*String expression="^+(hdfs://)\\s*(.*?):[0-9]{1,5}";
+//				String expression = "^+(hdfs://)[a-z,A-Z,0-9,.]*+:[0-9]{1,5}";
+				Pattern pattern = Pattern.compile(expression,
+						Pattern.CASE_INSENSITIVE);
+				// String inputStr = "hdfs://192.168.1.16:2";
+				Matcher matcher = pattern.matcher(fs_default_name);
+				if (!matcher.matches()) {					
+					throw restErrorUtil.createRESTException(
+							"serverMsg.fsDefaultNameValidationError",
+							MessageEnums.INVALID_INPUT_DATA, null, "fs.default.name",
+							vObj.toString());
+				}*/
+			}
+		}
+	}
+
+	public List<XXTrxLog> getTransactionLog(VXAsset vResource, String action){
+		return getTransactionLog(vResource, null, action);
+	}
+
+	public List<XXTrxLog> getTransactionLog(VXAsset vObj, XXAsset mObj, String action){
+		if(vObj == null && (action == null || !action.equalsIgnoreCase("update"))){
+			return null;
+		}
+		
+		List<XXTrxLog> trxLogList = new ArrayList<XXTrxLog>();
+		Field[] fields = vObj.getClass().getDeclaredFields();
+		
+		try {
+			Field nameField = vObj.getClass().getDeclaredField("name");
+			nameField.setAccessible(true);
+			String objectName = ""+nameField.get(vObj);
+	
+			for(Field field : fields){
+				field.setAccessible(true);
+				String fieldName = field.getName();
+				if(!trxLogAttrs.containsKey(fieldName)){
+					continue;
+				}
+				
+				VTrxLogAttr vTrxLogAttr = trxLogAttrs.get(fieldName);
+				
+				XXTrxLog xTrxLog = new XXTrxLog();
+				xTrxLog.setAttributeName(vTrxLogAttr.getAttribUserFriendlyName());
+			
+				String value = null;
+				boolean isEnum = vTrxLogAttr.isEnum();
+				if(isEnum){
+					String enumName = XXAsset.getEnumName(fieldName);
+					int enumValue = field.get(vObj) == null ? 0 : Integer.parseInt(""+field.get(vObj));
+					value = xaEnumUtil.getLabel(enumName, enumValue);
+				} else {
+					value = ""+field.get(vObj);
+				}
+				
+				if(action.equalsIgnoreCase("create")){
+					if(stringUtil.isEmpty(value)){
+						continue;
+					}
+					xTrxLog.setNewValue(value);
+				} else if(action.equalsIgnoreCase("delete")){
+					xTrxLog.setPreviousValue(value);
+				} else if(action.equalsIgnoreCase("update")){
+					String oldValue = null;
+					Field[] mFields = mObj.getClass().getDeclaredFields();
+					for(Field mField : mFields){
+						mField.setAccessible(true);
+						String mFieldName = mField.getName();
+						if(fieldName.equalsIgnoreCase(mFieldName)){
+							if(isEnum){
+								String enumName = XXAsset.getEnumName(mFieldName);
+								int enumValue = mField.get(mObj) == null ? 0 : Integer.parseInt(""+mField.get(mObj));
+								oldValue = xaEnumUtil.getLabel(enumName, enumValue);
+							} else {
+								oldValue = mField.get(mObj)+"";
+							}
+							break;
+						}
+					}
+					if(fieldName.equalsIgnoreCase("config")){
+						Map<String, String> vConfig = jsonUtil.jsonToMap(value);
+						Map<String, String> xConfig = jsonUtil.jsonToMap(oldValue);
+						
+						Map<String, String> newConfig = new HashMap<String, String>();
+						Map<String, String> oldConfig = new HashMap<String, String>();
+						
+						for (Entry<String, String> entry: vConfig.entrySet()) {
+							String key = entry.getKey();
+						    if (!xConfig.containsKey(key)) {
+						    	newConfig.put(key, entry.getValue());
+						    } else if(!entry.getValue().equalsIgnoreCase(xConfig.get(key))){
+						    	if(key.equalsIgnoreCase("password") && entry
+						    			.getValue().equalsIgnoreCase(hiddenPasswordString)){
+						    		continue;
+						    	}
+						    	newConfig.put(key, entry.getValue());
+						    	oldConfig.put(key, xConfig.get(key));
+						    }
+						}
+						
+						oldValue = jsonUtil.readMapToString(oldConfig);
+						value = jsonUtil.readMapToString(newConfig);
+					}
+					if(value.equalsIgnoreCase(oldValue)){
+						continue;
+					}
+					xTrxLog.setPreviousValue(oldValue);
+					xTrxLog.setNewValue(value);
+				}
+				
+				xTrxLog.setAction(action);
+				xTrxLog.setObjectClassType(AppConstants.CLASS_TYPE_XA_ASSET);
+				xTrxLog.setObjectId(vObj.getId());
+				xTrxLog.setObjectName(objectName);
+				trxLogList.add(xTrxLog);
+				
+			}
+		} catch (IllegalArgumentException e) {
+			e.printStackTrace();
+		} catch (IllegalAccessException e) {
+			e.printStackTrace();
+		} catch (NoSuchFieldException e) {
+			e.printStackTrace();
+		} catch (SecurityException e) {
+			e.printStackTrace();
+		}
+		
+		return trxLogList;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/7defc061/security-admin/src/main/java/com/xasecure/service/XAssetServiceBase.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/com/xasecure/service/XAssetServiceBase.java b/security-admin/src/main/java/com/xasecure/service/XAssetServiceBase.java
new file mode 100644
index 0000000..52f7c6d
--- /dev/null
+++ b/security-admin/src/main/java/com/xasecure/service/XAssetServiceBase.java
@@ -0,0 +1,80 @@
+package com.xasecure.service;
+/*
+ * Copyright (c) 2014 XASecure
+ * All rights reserved.
+ *
+ * This software is the confidential and proprietary information of
+ * XASecure ("Confidential Information").  You shall not
+ * disclose such Confidential Information and shall use it only in
+ * accordance with the terms of the license agreement you entered into
+ * with XASecure
+ */
+
+/**
+ * 
+ */
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.xasecure.common.*;
+import com.xasecure.entity.*;
+import com.xasecure.view.*;
+import com.xasecure.service.*;
+
+public abstract class XAssetServiceBase<T extends XXAsset, V extends VXAsset>
+		extends AbstractBaseResourceService<T, V> {
+	public static final String NAME = "XAsset";
+
+	public XAssetServiceBase() {
+
+	}
+
+	@SuppressWarnings("unchecked")
+	@Override
+	protected XXAsset mapViewToEntityBean(VXAsset vObj, XXAsset mObj, int OPERATION_CONTEXT) {
+		mObj.setName( vObj.getName());
+		mObj.setDescription( vObj.getDescription());
+		mObj.setActiveStatus( vObj.getActiveStatus());
+		mObj.setAssetType( vObj.getAssetType());
+		mObj.setConfig( vObj.getConfig());
+		mObj.setSupportNative( vObj.isSupportNative());
+		return mObj;
+	}
+
+	@SuppressWarnings("unchecked")
+	@Override
+	protected VXAsset mapEntityToViewBean(VXAsset vObj, XXAsset mObj) {
+		vObj.setName( mObj.getName());
+		vObj.setDescription( mObj.getDescription());
+		vObj.setActiveStatus( mObj.getActiveStatus());
+		vObj.setAssetType( mObj.getAssetType());
+		vObj.setConfig( mObj.getConfig());
+		vObj.setSupportNative( mObj.isSupportNative());
+		return vObj;
+	}
+
+	/**
+	 * @param searchCriteria
+	 * @return
+	 */
+	public VXAssetList searchXAssets(SearchCriteria searchCriteria) {
+		VXAssetList returnList = new VXAssetList();
+		List<VXAsset> xAssetList = new ArrayList<VXAsset>();
+
+		@SuppressWarnings("unchecked")
+		List<XXAsset> resultList = (List<XXAsset>)searchResources(searchCriteria,
+				searchFields, sortFields, returnList);
+
+		// Iterate over the result list and create the return list
+		for (XXAsset gjXAsset : resultList) {
+			@SuppressWarnings("unchecked")
+			VXAsset vXAsset = populateViewBean((T)gjXAsset);
+			xAssetList.add(vXAsset);
+		}
+
+		returnList.setVXAssets(xAssetList);
+		return returnList;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/7defc061/security-admin/src/main/java/com/xasecure/service/XAuditMapService.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/com/xasecure/service/XAuditMapService.java b/security-admin/src/main/java/com/xasecure/service/XAuditMapService.java
new file mode 100644
index 0000000..be43105
--- /dev/null
+++ b/security-admin/src/main/java/com/xasecure/service/XAuditMapService.java
@@ -0,0 +1,124 @@
+package com.xasecure.service;
+
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import com.xasecure.common.SearchField;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Service;
+
+import com.xasecure.common.AppConstants;
+import com.xasecure.common.view.VTrxLogAttr;
+import com.xasecure.db.XADaoManager;
+import com.xasecure.entity.*;
+import com.xasecure.util.XAEnumUtil;
+import com.xasecure.view.*;
+
+@Service
+@Scope("singleton")
+public class XAuditMapService extends
+		XAuditMapServiceBase<XXAuditMap, VXAuditMap> {
+
+	@Autowired
+	XAEnumUtil xaEnumUtil;
+
+	@Autowired
+	XADaoManager xADaoManager;
+
+	static HashMap<String, VTrxLogAttr> trxLogAttrs = new HashMap<String, VTrxLogAttr>();
+	static {
+//		trxLogAttrs.put("groupId", new VTrxLogAttr("groupId", "Group Audit", false));
+//		trxLogAttrs.put("userId", new VTrxLogAttr("userId", "User Audit", false));
+		trxLogAttrs.put("auditType", new VTrxLogAttr("auditType", "Audit Type", true));
+	}
+
+	public XAuditMapService() {
+		searchFields.add(new SearchField("resourceId", "obj.resourceId",
+				SearchField.DATA_TYPE.INTEGER, SearchField.SEARCH_TYPE.FULL));
+	}
+
+	@Override
+	protected void validateForCreate(VXAuditMap vObj) {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	protected void validateForUpdate(VXAuditMap vObj, XXAuditMap mObj) {
+		// TODO Auto-generated method stub
+
+	}
+
+	public List<XXTrxLog> getTransactionLog(VXAuditMap vXAuditMap, String action){
+		return getTransactionLog(vXAuditMap, null, action);
+	}
+
+	public List<XXTrxLog> getTransactionLog(VXAuditMap vObj, VXAuditMap mObj, String action){
+		if(vObj == null && (action == null || !action.equalsIgnoreCase("update"))){
+			return null;
+		}
+		
+		List<XXTrxLog> trxLogList = new ArrayList<XXTrxLog>();
+		Field[] fields = vObj.getClass().getDeclaredFields();
+		
+		try {
+			for(Field field : fields){
+				field.setAccessible(true);
+				String fieldName = field.getName();
+				if(!trxLogAttrs.containsKey(fieldName)){
+					continue;
+				}
+				
+				VTrxLogAttr vTrxLogAttr = trxLogAttrs.get(fieldName);
+				
+				XXTrxLog xTrxLog = new XXTrxLog();
+				xTrxLog.setAttributeName(vTrxLogAttr.getAttribUserFriendlyName());
+			
+				String value = null;
+				boolean isEnum = vTrxLogAttr.isEnum();
+				if(isEnum){
+					String enumName = XXAuditMap.getEnumName(fieldName);
+					int enumValue = field.get(vObj) == null ? 0 : Integer.parseInt(""+field.get(vObj));
+					value = xaEnumUtil.getLabel(enumName, enumValue);
+				} else {
+					value = ""+field.get(vObj);
+					XXUser xUser = xADaoManager.getXXUser().getById(Long.parseLong(value));
+					value = xUser.getName();
+				}
+				
+				if(action.equalsIgnoreCase("create")){
+					xTrxLog.setNewValue(value);
+				} else if(action.equalsIgnoreCase("delete")){
+					xTrxLog.setPreviousValue(value);
+				} else if(action.equalsIgnoreCase("update")){
+					// Not Changed.
+					xTrxLog.setNewValue(value);
+					xTrxLog.setPreviousValue(value);
+				}
+				
+				xTrxLog.setAction(action);
+				xTrxLog.setObjectClassType(AppConstants.CLASS_TYPE_XA_AUDIT_MAP);
+				xTrxLog.setObjectId(vObj.getId());
+				xTrxLog.setParentObjectClassType(AppConstants.CLASS_TYPE_XA_RESOURCE);
+				xTrxLog.setParentObjectId(vObj.getResourceId());
+//				xTrxLog.setParentObjectName(vObj.get);
+//				xTrxLog.setObjectName(objectName);
+				trxLogList.add(xTrxLog);
+				
+			}
+		} catch (IllegalArgumentException e) {
+			e.printStackTrace();
+		} catch (IllegalAccessException e) {
+			e.printStackTrace();
+		} catch (SecurityException e) {
+			e.printStackTrace();
+		}
+		
+		return trxLogList;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/7defc061/security-admin/src/main/java/com/xasecure/service/XAuditMapServiceBase.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/com/xasecure/service/XAuditMapServiceBase.java b/security-admin/src/main/java/com/xasecure/service/XAuditMapServiceBase.java
new file mode 100644
index 0000000..44d9e8f
--- /dev/null
+++ b/security-admin/src/main/java/com/xasecure/service/XAuditMapServiceBase.java
@@ -0,0 +1,76 @@
+package com.xasecure.service;
+/*
+ * Copyright (c) 2014 XASecure
+ * All rights reserved.
+ *
+ * This software is the confidential and proprietary information of
+ * XASecure ("Confidential Information").  You shall not
+ * disclose such Confidential Information and shall use it only in
+ * accordance with the terms of the license agreement you entered into
+ * with XASecure
+ */
+
+/**
+ * 
+ */
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.xasecure.common.*;
+import com.xasecure.entity.*;
+import com.xasecure.view.*;
+import com.xasecure.service.*;
+
+public abstract class XAuditMapServiceBase<T extends XXAuditMap, V extends VXAuditMap>
+		extends AbstractBaseResourceService<T, V> {
+	public static final String NAME = "XAuditMap";
+
+	public XAuditMapServiceBase() {
+
+	}
+
+	@SuppressWarnings("unchecked")
+	@Override
+	protected XXAuditMap mapViewToEntityBean(VXAuditMap vObj, XXAuditMap mObj, int OPERATION_CONTEXT) {
+		mObj.setResourceId( vObj.getResourceId());
+		mObj.setGroupId( vObj.getGroupId());
+		mObj.setUserId( vObj.getUserId());
+		mObj.setAuditType( vObj.getAuditType());
+		return mObj;
+	}
+
+	@SuppressWarnings("unchecked")
+	@Override
+	protected VXAuditMap mapEntityToViewBean(VXAuditMap vObj, XXAuditMap mObj) {
+		vObj.setResourceId( mObj.getResourceId());
+		vObj.setGroupId( mObj.getGroupId());
+		vObj.setUserId( mObj.getUserId());
+		vObj.setAuditType( mObj.getAuditType());
+		return vObj;
+	}
+
+	/**
+	 * @param searchCriteria
+	 * @return
+	 */
+	public VXAuditMapList searchXAuditMaps(SearchCriteria searchCriteria) {
+		VXAuditMapList returnList = new VXAuditMapList();
+		List<VXAuditMap> xAuditMapList = new ArrayList<VXAuditMap>();
+
+		@SuppressWarnings("unchecked")
+		List<XXAuditMap> resultList = (List<XXAuditMap>)searchResources(searchCriteria,
+				searchFields, sortFields, returnList);
+
+		// Iterate over the result list and create the return list
+		for (XXAuditMap gjXAuditMap : resultList) {
+			@SuppressWarnings("unchecked")
+			VXAuditMap vXAuditMap = populateViewBean((T)gjXAuditMap);
+			xAuditMapList.add(vXAuditMap);
+		}
+
+		returnList.setVXAuditMaps(xAuditMapList);
+		return returnList;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/7defc061/security-admin/src/main/java/com/xasecure/service/XCredentialStoreService.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/com/xasecure/service/XCredentialStoreService.java b/security-admin/src/main/java/com/xasecure/service/XCredentialStoreService.java
new file mode 100644
index 0000000..6b78d03
--- /dev/null
+++ b/security-admin/src/main/java/com/xasecure/service/XCredentialStoreService.java
@@ -0,0 +1,30 @@
+package com.xasecure.service;
+
+import com.xasecure.entity.*;
+import com.xasecure.view.*;
+
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Service;
+
+import com.xasecure.biz.*;
+import com.xasecure.entity.*;
+import com.xasecure.service.*;
+import com.xasecure.view.*;
+
+@Service
+@Scope("singleton")
+public class XCredentialStoreService extends XCredentialStoreServiceBase<XXCredentialStore, VXCredentialStore> {
+
+	@Override
+	protected void validateForCreate(VXCredentialStore vObj) {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	protected void validateForUpdate(VXCredentialStore vObj, XXCredentialStore mObj) {
+		// TODO Auto-generated method stub
+
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/7defc061/security-admin/src/main/java/com/xasecure/service/XCredentialStoreServiceBase.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/com/xasecure/service/XCredentialStoreServiceBase.java b/security-admin/src/main/java/com/xasecure/service/XCredentialStoreServiceBase.java
new file mode 100644
index 0000000..9dc336f
--- /dev/null
+++ b/security-admin/src/main/java/com/xasecure/service/XCredentialStoreServiceBase.java
@@ -0,0 +1,72 @@
+package com.xasecure.service;
+/*
+ * Copyright (c) 2014 XASecure
+ * All rights reserved.
+ *
+ * This software is the confidential and proprietary information of
+ * XASecure ("Confidential Information").  You shall not
+ * disclose such Confidential Information and shall use it only in
+ * accordance with the terms of the license agreement you entered into
+ * with XASecure
+ */
+
+/**
+ * 
+ */
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.xasecure.common.*;
+import com.xasecure.entity.*;
+import com.xasecure.view.*;
+import com.xasecure.service.*;
+
+public abstract class XCredentialStoreServiceBase<T extends XXCredentialStore, V extends VXCredentialStore>
+		extends AbstractBaseResourceService<T, V> {
+	public static final String NAME = "XCredentialStore";
+
+	public XCredentialStoreServiceBase() {
+
+	}
+
+	@SuppressWarnings("unchecked")
+	@Override
+	protected XXCredentialStore mapViewToEntityBean(VXCredentialStore vObj, XXCredentialStore mObj, int OPERATION_CONTEXT) {
+		mObj.setName( vObj.getName());
+		mObj.setDescription( vObj.getDescription());
+		return mObj;
+	}
+
+	@SuppressWarnings("unchecked")
+	@Override
+	protected VXCredentialStore mapEntityToViewBean(VXCredentialStore vObj, XXCredentialStore mObj) {
+		vObj.setName( mObj.getName());
+		vObj.setDescription( mObj.getDescription());
+		return vObj;
+	}
+
+	/**
+	 * @param searchCriteria
+	 * @return
+	 */
+	public VXCredentialStoreList searchXCredentialStores(SearchCriteria searchCriteria) {
+		VXCredentialStoreList returnList = new VXCredentialStoreList();
+		List<VXCredentialStore> xCredentialStoreList = new ArrayList<VXCredentialStore>();
+
+		@SuppressWarnings("unchecked")
+		List<XXCredentialStore> resultList = (List<XXCredentialStore>)searchResources(searchCriteria,
+				searchFields, sortFields, returnList);
+
+		// Iterate over the result list and create the return list
+		for (XXCredentialStore gjXCredentialStore : resultList) {
+			@SuppressWarnings("unchecked")
+			VXCredentialStore vXCredentialStore = populateViewBean((T)gjXCredentialStore);
+			xCredentialStoreList.add(vXCredentialStore);
+		}
+
+		returnList.setVXCredentialStores(xCredentialStoreList);
+		return returnList;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/7defc061/security-admin/src/main/java/com/xasecure/service/XGroupGroupService.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/com/xasecure/service/XGroupGroupService.java b/security-admin/src/main/java/com/xasecure/service/XGroupGroupService.java
new file mode 100644
index 0000000..102f11c
--- /dev/null
+++ b/security-admin/src/main/java/com/xasecure/service/XGroupGroupService.java
@@ -0,0 +1,30 @@
+package com.xasecure.service;
+
+import com.xasecure.entity.*;
+import com.xasecure.view.*;
+
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Service;
+
+import com.xasecure.biz.*;
+import com.xasecure.entity.*;
+import com.xasecure.service.*;
+import com.xasecure.view.*;
+
+@Service
+@Scope("singleton")
+public class XGroupGroupService extends XGroupGroupServiceBase<XXGroupGroup, VXGroupGroup> {
+
+	@Override
+	protected void validateForCreate(VXGroupGroup vObj) {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	protected void validateForUpdate(VXGroupGroup vObj, XXGroupGroup mObj) {
+		// TODO Auto-generated method stub
+
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/7defc061/security-admin/src/main/java/com/xasecure/service/XGroupGroupServiceBase.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/com/xasecure/service/XGroupGroupServiceBase.java b/security-admin/src/main/java/com/xasecure/service/XGroupGroupServiceBase.java
new file mode 100644
index 0000000..a48f828
--- /dev/null
+++ b/security-admin/src/main/java/com/xasecure/service/XGroupGroupServiceBase.java
@@ -0,0 +1,74 @@
+package com.xasecure.service;
+/*
+ * Copyright (c) 2014 XASecure
+ * All rights reserved.
+ *
+ * This software is the confidential and proprietary information of
+ * XASecure ("Confidential Information").  You shall not
+ * disclose such Confidential Information and shall use it only in
+ * accordance with the terms of the license agreement you entered into
+ * with XASecure
+ */
+
+/**
+ * 
+ */
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.xasecure.common.*;
+import com.xasecure.entity.*;
+import com.xasecure.view.*;
+import com.xasecure.service.*;
+
+public abstract class XGroupGroupServiceBase<T extends XXGroupGroup, V extends VXGroupGroup>
+		extends AbstractBaseResourceService<T, V> {
+	public static final String NAME = "XGroupGroup";
+
+	public XGroupGroupServiceBase() {
+
+	}
+
+	@SuppressWarnings("unchecked")
+	@Override
+	protected XXGroupGroup mapViewToEntityBean(VXGroupGroup vObj, XXGroupGroup mObj, int OPERATION_CONTEXT) {
+		mObj.setName( vObj.getName());
+		mObj.setParentGroupId( vObj.getParentGroupId());
+		mObj.setGroupId( vObj.getGroupId());
+		return mObj;
+	}
+
+	@SuppressWarnings("unchecked")
+	@Override
+	protected VXGroupGroup mapEntityToViewBean(VXGroupGroup vObj, XXGroupGroup mObj) {
+		vObj.setName( mObj.getName());
+		vObj.setParentGroupId( mObj.getParentGroupId());
+		vObj.setGroupId( mObj.getGroupId());
+		return vObj;
+	}
+
+	/**
+	 * @param searchCriteria
+	 * @return
+	 */
+	public VXGroupGroupList searchXGroupGroups(SearchCriteria searchCriteria) {
+		VXGroupGroupList returnList = new VXGroupGroupList();
+		List<VXGroupGroup> xGroupGroupList = new ArrayList<VXGroupGroup>();
+
+		@SuppressWarnings("unchecked")
+		List<XXGroupGroup> resultList = (List<XXGroupGroup>)searchResources(searchCriteria,
+				searchFields, sortFields, returnList);
+
+		// Iterate over the result list and create the return list
+		for (XXGroupGroup gjXGroupGroup : resultList) {
+			@SuppressWarnings("unchecked")
+			VXGroupGroup vXGroupGroup = populateViewBean((T)gjXGroupGroup);
+			xGroupGroupList.add(vXGroupGroup);
+		}
+
+		returnList.setVXGroupGroups(xGroupGroupList);
+		return returnList;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/7defc061/security-admin/src/main/java/com/xasecure/service/XGroupService.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/com/xasecure/service/XGroupService.java b/security-admin/src/main/java/com/xasecure/service/XGroupService.java
new file mode 100644
index 0000000..fa93014
--- /dev/null
+++ b/security-admin/src/main/java/com/xasecure/service/XGroupService.java
@@ -0,0 +1,233 @@
+package com.xasecure.service;
+
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import com.xasecure.common.XACommonEnums;
+import com.xasecure.common.MessageEnums;
+import com.xasecure.common.PropertiesUtil;
+import com.xasecure.common.SearchField;
+import com.xasecure.common.SortField;
+import com.xasecure.common.SortField.SORT_ORDER;
+import com.xasecure.common.StringUtil;
+import com.xasecure.entity.*;
+import com.xasecure.view.*;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Service;
+
+import com.xasecure.biz.*;
+import com.xasecure.common.AppConstants;
+import com.xasecure.common.view.VTrxLogAttr;
+import com.xasecure.db.XADaoManager;
+import com.xasecure.entity.*;
+import com.xasecure.service.*;
+import com.xasecure.util.XAEnumUtil;
+import com.xasecure.view.*;
+
+@Service
+@Scope("singleton")
+public class XGroupService extends XGroupServiceBase<XXGroup, VXGroup> {
+
+	public static Long createdByUserId = 1L;
+	
+	@Autowired
+	XADaoManager xADaoManager;
+	
+	@Autowired
+	XAEnumUtil xaEnumUtil;
+	
+	@Autowired
+	StringUtil stringUtil;
+	
+	static HashMap<String, VTrxLogAttr> trxLogAttrs = new HashMap<String, VTrxLogAttr>();
+	static {
+		trxLogAttrs.put("name", new VTrxLogAttr("name", "Group Name", false));
+		trxLogAttrs.put("description", new VTrxLogAttr("description", "Group Description", false));
+	}
+	
+	public XGroupService() {
+		searchFields.add(new SearchField("name", "obj.name",
+				SearchField.DATA_TYPE.STRING, SearchField.SEARCH_TYPE.PARTIAL));
+		searchFields.add(new SearchField("groupSource", "obj.groupSource",
+				SearchField.DATA_TYPE.STRING, SearchField.SEARCH_TYPE.FULL));
+		 createdByUserId = new Long(PropertiesUtil.getIntProperty(
+				"xa.xuser.createdByUserId", 1));		 
+		
+		 sortFields.add(new SortField("name", "obj.name",true,SortField.SORT_ORDER.ASC));
+	}
+
+	@Override
+	protected void validateForCreate(VXGroup vObj) {
+		XXGroup xxGroup = xADaoManager.getXXGroup().findByGroupName(
+				vObj.getName());
+		if (xxGroup != null) {
+			throw restErrorUtil.createRESTException("XGroup already exists",
+					MessageEnums.ERROR_DUPLICATE_OBJECT);
+		}
+
+	}
+
+	@Override
+	protected void validateForUpdate(VXGroup vObj, XXGroup mObj) {
+		if (!vObj.getName().equalsIgnoreCase(mObj.getName())) {
+			validateForCreate(vObj);
+		}
+	}
+
+	public VXGroup getGroupByGroupName(String groupName) {
+		XXGroup xxGroup = xADaoManager.getXXGroup().findByGroupName(groupName);
+
+		if (xxGroup == null) {
+			throw restErrorUtil.createRESTException(
+					groupName + " is Not Found", MessageEnums.DATA_NOT_FOUND);
+		}
+		return super.populateViewBean(xxGroup);
+	}
+	
+	public VXGroup createXGroupWithOutLogin(VXGroup vxGroup) {
+		XXGroup xxGroup = xADaoManager.getXXGroup().findByGroupName(
+				vxGroup.getName());
+		boolean groupExists = true;
+
+		if (xxGroup == null) {
+			xxGroup = new XXGroup();
+			groupExists = false;
+		}
+
+		xxGroup = mapViewToEntityBean(vxGroup, xxGroup, 0);
+		XXPortalUser xXPortalUser = xADaoManager.getXXPortalUser().getById(createdByUserId);
+		if (xXPortalUser != null) {
+			xxGroup.setAddedByUserId(createdByUserId);
+			xxGroup.setUpdatedByUserId(createdByUserId);
+		}
+		if (groupExists) {
+			xxGroup = getDao().update(xxGroup);
+		} else {
+			xxGroup = getDao().create(xxGroup);
+		}
+		vxGroup = postCreate(xxGroup);
+		return vxGroup;
+	}
+
+	public VXGroup readResourceWithOutLogin(Long id) {
+		XXGroup resource = getDao().getById(id);
+		if (resource == null) {
+			// Returns code 400 with DATA_NOT_FOUND as the error message
+			throw restErrorUtil.createRESTException(getResourceName()
+					+ " not found", MessageEnums.DATA_NOT_FOUND, id, null,
+					"preRead: " + id + " not found.");
+		}
+
+		VXGroup view = populateViewBean(resource);
+		if(view!=null){
+			view.setGroupSource(resource.getGroupSource());
+		}
+		return view;
+	}
+
+	public List<XXTrxLog> getTransactionLog(VXGroup vResource, String action){
+		return getTransactionLog(vResource, null, action);
+	}
+
+	public List<XXTrxLog> getTransactionLog(VXGroup vObj, XXGroup mObj, String action){
+		if(vObj == null && (action == null || !action.equalsIgnoreCase("update"))){
+			return null;
+		}
+		
+		List<XXTrxLog> trxLogList = new ArrayList<XXTrxLog>();
+		try {
+
+			Field nameField = vObj.getClass().getDeclaredField("name");
+			nameField.setAccessible(true);
+			String objectName = ""+nameField.get(vObj);
+			Field[] fields = vObj.getClass().getDeclaredFields();
+			
+			for(Field field : fields){
+				field.setAccessible(true);
+				String fieldName = field.getName();
+				if(!trxLogAttrs.containsKey(fieldName)){
+					continue;
+				}
+				
+				VTrxLogAttr vTrxLogAttr = trxLogAttrs.get(fieldName);
+				
+				XXTrxLog xTrxLog = new XXTrxLog();
+				xTrxLog.setAttributeName(vTrxLogAttr.getAttribUserFriendlyName());
+				
+				String value = null;
+				boolean isEnum = vTrxLogAttr.isEnum();
+				if(isEnum){
+					String enumName = XXGroup.getEnumName(fieldName);
+					int enumValue = field.get(vObj) == null ? 0 : Integer.parseInt(""+field.get(vObj));
+					value = xaEnumUtil.getLabel(enumName, enumValue);
+				} else {
+					value = ""+field.get(vObj);
+				}
+				
+				if(action.equalsIgnoreCase("create")){
+					if(stringUtil.isEmpty(value)){
+						continue;
+					}
+					xTrxLog.setNewValue(value);
+				} else if(action.equalsIgnoreCase("delete")){
+					xTrxLog.setPreviousValue(value);
+				} else if(action.equalsIgnoreCase("update")){
+					String oldValue = null;
+					Field[] mFields = mObj.getClass().getDeclaredFields();
+					for(Field mField : mFields){
+						mField.setAccessible(true);
+						String mFieldName = mField.getName();
+						if(fieldName.equalsIgnoreCase(mFieldName)){
+							if(isEnum){
+								String enumName = XXAsset.getEnumName(mFieldName);
+								int enumValue = mField.get(mObj) == null ? 0 : Integer.parseInt(""+mField.get(mObj));
+								oldValue = xaEnumUtil.getLabel(enumName, enumValue);
+							} else {
+								oldValue = mField.get(mObj)+"";
+							}
+							break;
+						}
+					}
+					if(value.equalsIgnoreCase(oldValue)){
+						continue;
+					}
+					xTrxLog.setPreviousValue(oldValue);
+					xTrxLog.setNewValue(value);
+				}
+				
+				xTrxLog.setAction(action);
+				xTrxLog.setObjectClassType(AppConstants.CLASS_TYPE_XA_GROUP);
+				xTrxLog.setObjectId(vObj.getId());
+				xTrxLog.setObjectName(objectName);
+				trxLogList.add(xTrxLog);
+				
+			}
+		} catch (IllegalArgumentException e) {
+			e.printStackTrace();
+		} catch (IllegalAccessException e) {
+			e.printStackTrace();
+		} catch (NoSuchFieldException e) {
+			e.printStackTrace();
+		} catch (SecurityException e) {
+			e.printStackTrace();
+		}
+		
+		return trxLogList;
+	}
+	
+	@Override
+	protected XXGroup mapViewToEntityBean(VXGroup vObj, XXGroup mObj, int OPERATION_CONTEXT) {
+		super.mapViewToEntityBean(vObj, mObj, OPERATION_CONTEXT);
+		return mObj;
+	}
+
+	@Override
+	protected VXGroup mapEntityToViewBean(VXGroup vObj, XXGroup mObj) {
+		super.mapEntityToViewBean(vObj, mObj);
+		return vObj;
+	}	
+}

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/7defc061/security-admin/src/main/java/com/xasecure/service/XGroupServiceBase.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/com/xasecure/service/XGroupServiceBase.java b/security-admin/src/main/java/com/xasecure/service/XGroupServiceBase.java
new file mode 100644
index 0000000..dd63914
--- /dev/null
+++ b/security-admin/src/main/java/com/xasecure/service/XGroupServiceBase.java
@@ -0,0 +1,76 @@
+package com.xasecure.service;
+/*
+ * Copyright (c) 2014 XASecure
+ * All rights reserved.
+ *
+ * This software is the confidential and proprietary information of
+ * XASecure ("Confidential Information").  You shall not
+ * disclose such Confidential Information and shall use it only in
+ * accordance with the terms of the license agreement you entered into
+ * with XASecure
+ */
+
+/**
+ * 
+ */
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.xasecure.common.*;
+import com.xasecure.entity.*;
+import com.xasecure.view.*;
+import com.xasecure.service.*;
+
+public abstract class XGroupServiceBase<T extends XXGroup, V extends VXGroup>
+		extends AbstractBaseResourceService<T, V> {
+	public static final String NAME = "XGroup";
+
+	public XGroupServiceBase() {
+
+	}
+
+	@SuppressWarnings("unchecked")
+	@Override
+	protected XXGroup mapViewToEntityBean(VXGroup vObj, XXGroup mObj, int OPERATION_CONTEXT) {
+		mObj.setName( vObj.getName());
+		mObj.setDescription( vObj.getDescription());
+		mObj.setGroupType( vObj.getGroupType());
+		mObj.setCredStoreId( vObj.getCredStoreId());
+		return mObj;
+	}
+
+	@SuppressWarnings("unchecked")
+	@Override
+	protected VXGroup mapEntityToViewBean(VXGroup vObj, XXGroup mObj) {
+		vObj.setName( mObj.getName());
+		vObj.setDescription( mObj.getDescription());
+		vObj.setGroupType( mObj.getGroupType());
+		vObj.setCredStoreId( mObj.getCredStoreId());
+		return vObj;
+	}
+
+	/**
+	 * @param searchCriteria
+	 * @return
+	 */
+	public VXGroupList searchXGroups(SearchCriteria searchCriteria) {
+		VXGroupList returnList = new VXGroupList();
+		List<VXGroup> xGroupList = new ArrayList<VXGroup>();
+
+		@SuppressWarnings("unchecked")
+		List<XXGroup> resultList = (List<XXGroup>)searchResources(searchCriteria,
+				searchFields, sortFields, returnList);
+
+		// Iterate over the result list and create the return list
+		for (XXGroup gjXGroup : resultList) {
+			@SuppressWarnings("unchecked")
+			VXGroup vXGroup = populateViewBean((T)gjXGroup);
+			xGroupList.add(vXGroup);
+		}
+
+		returnList.setVXGroups(xGroupList);
+		return returnList;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/7defc061/security-admin/src/main/java/com/xasecure/service/XGroupUserService.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/com/xasecure/service/XGroupUserService.java b/security-admin/src/main/java/com/xasecure/service/XGroupUserService.java
new file mode 100644
index 0000000..b511fe2
--- /dev/null
+++ b/security-admin/src/main/java/com/xasecure/service/XGroupUserService.java
@@ -0,0 +1,175 @@
+package com.xasecure.service;
+
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import com.xasecure.common.XACommonEnums;
+import com.xasecure.common.MessageEnums;
+import com.xasecure.common.PropertiesUtil;
+import com.xasecure.common.SearchField;
+import com.xasecure.entity.XXPortalUser;
+import com.xasecure.entity.XXGroup;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Service;
+
+import com.xasecure.common.AppConstants;
+import com.xasecure.common.view.VTrxLogAttr;
+import com.xasecure.db.XADaoManager;
+import com.xasecure.entity.*;
+import com.xasecure.util.XAEnumUtil;
+import com.xasecure.view.*;
+
+@Service
+@Scope("singleton")
+public class XGroupUserService extends
+		XGroupUserServiceBase<XXGroupUser, VXGroupUser> {
+
+	public static Long createdByUserId = 1L;
+	
+	@Autowired
+	XADaoManager xADaoManager;
+
+	@Autowired
+	XAEnumUtil xaEnumUtil;
+	
+	static HashMap<String, VTrxLogAttr> trxLogAttrs = new HashMap<String, VTrxLogAttr>();
+	static {
+		trxLogAttrs.put("parentGroupId", new VTrxLogAttr("parentGroupId", "Group Name", false));
+	}
+
+
+	public XGroupUserService() {
+		searchFields.add(new SearchField("xUserId", "obj.userId",
+				SearchField.DATA_TYPE.INTEGER, SearchField.SEARCH_TYPE.FULL));
+		searchFields.add(new SearchField("xGroupId", "obj.parentGroupId",
+				SearchField.DATA_TYPE.INTEGER, SearchField.SEARCH_TYPE.FULL));
+		createdByUserId = new Long(PropertiesUtil.getIntProperty(
+				"xa.xuser.createdByUserId", 1));
+		
+	}
+
+	@Override
+	protected void validateForCreate(VXGroupUser vObj) {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	protected void validateForUpdate(VXGroupUser vObj, XXGroupUser mObj) {
+		// TODO Auto-generated method stub
+
+	}
+	
+	public VXGroupUser createXGroupUserWithOutLogin(VXGroupUser vxGroupUser) {
+		XXGroupUser xxGroupUser = new XXGroupUser();
+		XXGroup xGroup = daoManager.getXXGroup().findByGroupName(vxGroupUser.getName());
+		vxGroupUser.setParentGroupId(xGroup.getId());
+		xxGroupUser = mapViewToEntityBean(vxGroupUser, xxGroupUser, 0);
+		XXPortalUser xXPortalUser = xADaoManager.getXXPortalUser().getById(createdByUserId);
+		if (xXPortalUser != null) {
+			xxGroupUser.setAddedByUserId(createdByUserId);
+			xxGroupUser.setUpdatedByUserId(createdByUserId);
+		}
+		xxGroupUser = getDao().create(xxGroupUser);
+		vxGroupUser = postCreate(xxGroupUser);
+		return vxGroupUser;
+	}
+
+	public VXGroupUser readResourceWithOutLogin(Long id) {
+		XXGroupUser resource = getDao().getById(id);
+		if (resource == null) {
+			// Returns code 400 with DATA_NOT_FOUND as the error message
+			throw restErrorUtil.createRESTException(getResourceName()
+					+ " not found", MessageEnums.DATA_NOT_FOUND, id, null,
+					"preRead: " + id + " not found.");
+		}
+
+		VXGroupUser view = populateViewBean(resource);
+		return view;
+	}
+	
+	public List<XXTrxLog> getTransactionLog(VXGroupUser vXGroupUser, String action){
+		return getTransactionLog(vXGroupUser, null, action);
+	}
+
+	public List<XXTrxLog> getTransactionLog(VXGroupUser vObj, XXGroupUser mObj, String action){
+//		if(vObj == null && (action == null || !action.equalsIgnoreCase("update"))){
+//			return null;
+//		}
+		
+		Long groupId = vObj.getParentGroupId();
+		XXGroup xGroup = xADaoManager.getXXGroup().getById(groupId);
+		String groupName = xGroup.getName();
+
+		Long userId = vObj.getUserId();
+		XXUser xUser = xADaoManager.getXXUser().getById(userId);
+		String userName = xUser.getName();
+
+		List<XXTrxLog> trxLogList = new ArrayList<XXTrxLog>();
+		Field[] fields = vObj.getClass().getDeclaredFields();
+		
+		try {
+			for(Field field : fields){
+				field.setAccessible(true);
+				String fieldName = field.getName();
+				if(!trxLogAttrs.containsKey(fieldName)){
+					continue;
+				}
+				
+				VTrxLogAttr vTrxLogAttr = trxLogAttrs.get(fieldName);
+				
+				XXTrxLog xTrxLog = new XXTrxLog();
+				xTrxLog.setAttributeName(vTrxLogAttr.getAttribUserFriendlyName());
+			
+				String value = null;
+				boolean isEnum = vTrxLogAttr.isEnum();
+				if(isEnum){
+					String enumName = XXAsset.getEnumName(fieldName);
+					int enumValue = field.get(vObj) == null ? 0 : Integer.parseInt(""+field.get(vObj));
+					value = xaEnumUtil.getLabel(enumName, enumValue);
+				} else {
+					value = ""+field.get(vObj);
+					XXGroup xXGroup = xADaoManager.getXXGroup().getById(Long.parseLong(value));
+					value = xXGroup.getName();
+				}
+				
+				if(action.equalsIgnoreCase("create")){
+					xTrxLog.setNewValue(value);
+				} else if(action.equalsIgnoreCase("delete")){
+					xTrxLog.setPreviousValue(value);
+				} else if(action.equalsIgnoreCase("update")){
+					// No Change.
+					xTrxLog.setNewValue(value);
+					xTrxLog.setPreviousValue(value);
+				}
+				
+				xTrxLog.setAction(action);
+				
+				xTrxLog.setObjectClassType(AppConstants.CLASS_TYPE_XA_GROUP_USER);
+				xTrxLog.setObjectId(vObj.getId());
+				xTrxLog.setObjectName(userName);
+				
+				xTrxLog.setParentObjectClassType(AppConstants.CLASS_TYPE_XA_GROUP);
+				xTrxLog.setParentObjectId(groupId);
+				xTrxLog.setParentObjectName(groupName);
+				
+				trxLogList.add(xTrxLog);
+				
+			}
+		} catch (IllegalArgumentException e) {
+			e.printStackTrace();
+		} catch (IllegalAccessException e) {
+			e.printStackTrace();
+		} catch (SecurityException e) {
+			e.printStackTrace();
+		}
+		
+		return trxLogList;
+	}
+
+	
+}

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/7defc061/security-admin/src/main/java/com/xasecure/service/XGroupUserServiceBase.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/com/xasecure/service/XGroupUserServiceBase.java b/security-admin/src/main/java/com/xasecure/service/XGroupUserServiceBase.java
new file mode 100644
index 0000000..3565bd6
--- /dev/null
+++ b/security-admin/src/main/java/com/xasecure/service/XGroupUserServiceBase.java
@@ -0,0 +1,74 @@
+package com.xasecure.service;
+/*
+ * Copyright (c) 2014 XASecure
+ * All rights reserved.
+ *
+ * This software is the confidential and proprietary information of
+ * XASecure ("Confidential Information").  You shall not
+ * disclose such Confidential Information and shall use it only in
+ * accordance with the terms of the license agreement you entered into
+ * with XASecure
+ */
+
+/**
+ * 
+ */
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.xasecure.common.*;
+import com.xasecure.entity.*;
+import com.xasecure.view.*;
+import com.xasecure.service.*;
+
+public abstract class XGroupUserServiceBase<T extends XXGroupUser, V extends VXGroupUser>
+		extends AbstractBaseResourceService<T, V> {
+	public static final String NAME = "XGroupUser";
+
+	public XGroupUserServiceBase() {
+
+	}
+
+	@SuppressWarnings("unchecked")
+	@Override
+	protected XXGroupUser mapViewToEntityBean(VXGroupUser vObj, XXGroupUser mObj, int OPERATION_CONTEXT) {
+		mObj.setName( vObj.getName());
+		mObj.setParentGroupId( vObj.getParentGroupId());
+		mObj.setUserId( vObj.getUserId());
+		return mObj;
+	}
+
+	@SuppressWarnings("unchecked")
+	@Override
+	protected VXGroupUser mapEntityToViewBean(VXGroupUser vObj, XXGroupUser mObj) {
+		vObj.setName( mObj.getName());
+		vObj.setParentGroupId( mObj.getParentGroupId());
+		vObj.setUserId( mObj.getUserId());
+		return vObj;
+	}
+
+	/**
+	 * @param searchCriteria
+	 * @return
+	 */
+	public VXGroupUserList searchXGroupUsers(SearchCriteria searchCriteria) {
+		VXGroupUserList returnList = new VXGroupUserList();
+		List<VXGroupUser> xGroupUserList = new ArrayList<VXGroupUser>();
+
+		@SuppressWarnings("unchecked")
+		List<XXGroupUser> resultList = (List<XXGroupUser>)searchResources(searchCriteria,
+				searchFields, sortFields, returnList);
+
+		// Iterate over the result list and create the return list
+		for (XXGroupUser gjXGroupUser : resultList) {
+			@SuppressWarnings("unchecked")
+			VXGroupUser vXGroupUser = populateViewBean((T)gjXGroupUser);
+			xGroupUserList.add(vXGroupUser);
+		}
+
+		returnList.setVXGroupUsers(xGroupUserList);
+		return returnList;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/7defc061/security-admin/src/main/java/com/xasecure/service/XPermMapService.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/com/xasecure/service/XPermMapService.java b/security-admin/src/main/java/com/xasecure/service/XPermMapService.java
new file mode 100644
index 0000000..76973db
--- /dev/null
+++ b/security-admin/src/main/java/com/xasecure/service/XPermMapService.java
@@ -0,0 +1,222 @@
+package com.xasecure.service;
+
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import com.xasecure.common.SearchCriteria;
+import com.xasecure.common.SearchField;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Service;
+
+import com.xasecure.common.AppConstants;
+import com.xasecure.common.view.VTrxLogAttr;
+import com.xasecure.db.XADaoManager;
+import com.xasecure.entity.*;
+import com.xasecure.util.XAEnumUtil;
+import com.xasecure.view.*;
+
+@Service
+@Scope("singleton")
+public class XPermMapService extends XPermMapServiceBase<XXPermMap, VXPermMap> {
+
+	@Autowired
+	XGroupService xGroupService;
+	
+	@Autowired
+	XUserService xUserService;
+	
+	@Autowired
+	XAEnumUtil xaEnumUtil;
+
+	@Autowired
+	XADaoManager xADaoManager;
+
+	static HashMap<String, VTrxLogAttr> trxLogAttrs = new HashMap<String, VTrxLogAttr>();
+	static {
+//		trxLogAttrs.put("groupId", new VTrxLogAttr("groupId", "Group Permission", false));
+//		trxLogAttrs.put("userId", new VTrxLogAttr("userId", "User Permission", false));
+		trxLogAttrs.put("permType", new VTrxLogAttr("permType", "Permission Type", true));
+		trxLogAttrs.put("ipAddress", new VTrxLogAttr("ipAddress", "IP Address", false));
+	}
+
+	
+	public XPermMapService() {
+		searchFields.add(new SearchField("resourceId", "obj.resourceId",
+				SearchField.DATA_TYPE.INTEGER, SearchField.SEARCH_TYPE.FULL));
+	}
+
+	@Override
+	protected void validateForCreate(VXPermMap vObj) {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	protected void validateForUpdate(VXPermMap vObj, XXPermMap mObj) {
+		// TODO Auto-generated method stub
+
+	}
+	
+	@Override
+	public VXPermMap populateViewBean(XXPermMap xXPermMap){
+		VXPermMap map = super.populateViewBean(xXPermMap);		
+		if(map.getPermFor() == AppConstants.XA_PERM_FOR_GROUP) {
+			String groupName = getGroupName(map.getGroupId());
+			if(groupName != null){
+				map.setGroupName(groupName);
+			}
+		} else if(map.getPermFor() == AppConstants.XA_PERM_FOR_USER) {
+			String username = getUserName(map.getUserId());
+			if(username != null){
+				map.setUserName(username);
+			}
+		}
+		return map;
+	}
+	
+	@Override
+	public VXPermMapList searchXPermMaps(SearchCriteria searchCriteria) {
+		VXPermMapList vXPermMapList = super.searchXPermMaps(searchCriteria);
+		if(vXPermMapList != null && vXPermMapList.getResultSize() != 0){
+			for(VXPermMap vXPermMap : vXPermMapList.getVXPermMaps()){
+				if(vXPermMap.getPermFor() == AppConstants.XA_PERM_FOR_GROUP) {
+					String groupName = getGroupName(vXPermMap.getGroupId());
+					vXPermMap.setGroupName(groupName);
+				} else if(vXPermMap.getPermFor() == AppConstants.XA_PERM_FOR_USER) {
+					String username = getUserName(vXPermMap.getUserId());
+					vXPermMap.setUserName(username);
+				}
+			}
+		}
+		return vXPermMapList;
+	}
+	
+	public String getGroupName(Long groupId){
+		if(groupId!=null && groupId!=0){
+		VXGroup vXGroup = xGroupService.readResource(groupId);
+			return vXGroup.getName();
+		}
+		else
+			return null;
+	}
+	
+	public String getUserName(Long userId){
+		if(userId!=null && userId!=0){
+		VXUser vXUser = xUserService.readResource(userId);
+			return vXUser.getName();
+		}
+		else
+			return null;
+	}
+
+	public List<XXTrxLog> getTransactionLog(VXPermMap vXPermMap, String action){
+		return getTransactionLog(vXPermMap, null, action);
+	}
+	
+	public List<XXTrxLog> getTransactionLog(VXPermMap vObj, VXPermMap mObj, String action){
+		if(vObj == null && (action == null || !action.equalsIgnoreCase("update"))){
+			return null;
+		}
+		
+		boolean isGroupPolicy = true;
+		if(vObj.getGroupId() == null){
+			isGroupPolicy = false;
+		}
+		
+		Long groupId = null;
+		Long userId = null;
+		String groupName = null;
+		String userName = null;
+		
+		if(isGroupPolicy){
+			groupId = vObj.getGroupId();
+			XXGroup xGroup = xADaoManager.getXXGroup().getById(groupId);
+			groupName = xGroup.getName();
+		} else {
+			userId = vObj.getUserId();
+			XXUser xUser = xADaoManager.getXXUser().getById(userId);
+			userName = xUser.getName();
+		}
+
+		List<XXTrxLog> trxLogList = new ArrayList<XXTrxLog>();
+		Field[] fields = vObj.getClass().getDeclaredFields();
+		
+		try {
+			for(Field field : fields){
+				field.setAccessible(true);
+				String fieldName = field.getName();
+				if(!trxLogAttrs.containsKey(fieldName)){
+					continue;
+//				} else {
+//					if(isGroupPolicy){
+//						if(fieldName.equalsIgnoreCase("userId")){
+//							continue;
+//						}
+//					} else {
+//						if (fieldName.equalsIgnoreCase("groupId")){
+//							continue;
+//						}
+//					}
+				}
+				
+				VTrxLogAttr vTrxLogAttr = trxLogAttrs.get(fieldName);
+				
+				XXTrxLog xTrxLog = new XXTrxLog();
+				xTrxLog.setAttributeName(vTrxLogAttr.getAttribUserFriendlyName());
+			
+				String value = null;
+				boolean isEnum = vTrxLogAttr.isEnum();
+				if(isEnum){
+					String enumName = XXPermMap.getEnumName(fieldName);
+					int enumValue = field.get(vObj) == null ? 0 : Integer.parseInt(""+field.get(vObj));
+					value = xaEnumUtil.getLabel(enumName, enumValue);
+				} else {
+					value = ""+field.get(vObj);
+//					XXUser xUser = xADaoManager.getXXUser().getById(Long.parseLong(value));
+//					value = xUser.getName();
+					if(value == null || value.equalsIgnoreCase("null") || stringUtil.isEmpty(value)){
+						continue;
+					}
+				}
+				
+				if(action.equalsIgnoreCase("create")){
+					xTrxLog.setNewValue(value);
+				} else if(action.equalsIgnoreCase("delete")){
+					xTrxLog.setPreviousValue(value);
+				} else if(action.equalsIgnoreCase("update")){
+					// Not Changed.
+					xTrxLog.setNewValue(value);
+					xTrxLog.setPreviousValue(value);
+				}
+				
+				xTrxLog.setAction(action);
+				xTrxLog.setObjectClassType(AppConstants.CLASS_TYPE_XA_PERM_MAP);
+				xTrxLog.setObjectId(vObj.getId());
+				if(isGroupPolicy){
+					xTrxLog.setParentObjectClassType(AppConstants.CLASS_TYPE_XA_GROUP);
+					xTrxLog.setParentObjectId(groupId);
+					xTrxLog.setParentObjectName(groupName);
+				} else {
+					xTrxLog.setParentObjectClassType(AppConstants.CLASS_TYPE_XA_USER);
+					xTrxLog.setParentObjectId(userId);
+					xTrxLog.setParentObjectName(userName);
+				}
+//				xTrxLog.setObjectName(objectName);
+				trxLogList.add(xTrxLog);
+				
+			}
+		} catch (IllegalArgumentException e) {
+			e.printStackTrace();
+		} catch (IllegalAccessException e) {
+			e.printStackTrace();
+		} catch (SecurityException e) {
+			e.printStackTrace();
+		}
+		
+		return trxLogList;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/7defc061/security-admin/src/main/java/com/xasecure/service/XPermMapServiceBase.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/com/xasecure/service/XPermMapServiceBase.java b/security-admin/src/main/java/com/xasecure/service/XPermMapServiceBase.java
new file mode 100644
index 0000000..ae0cec3
--- /dev/null
+++ b/security-admin/src/main/java/com/xasecure/service/XPermMapServiceBase.java
@@ -0,0 +1,88 @@
+package com.xasecure.service;
+/*
+ * Copyright (c) 2014 XASecure
+ * All rights reserved.
+ *
+ * This software is the confidential and proprietary information of
+ * XASecure ("Confidential Information").  You shall not
+ * disclose such Confidential Information and shall use it only in
+ * accordance with the terms of the license agreement you entered into
+ * with XASecure
+ */
+
+/**
+ * 
+ */
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.xasecure.common.*;
+import com.xasecure.entity.*;
+import com.xasecure.view.*;
+import com.xasecure.service.*;
+
+public abstract class XPermMapServiceBase<T extends XXPermMap, V extends VXPermMap>
+		extends AbstractBaseResourceService<T, V> {
+	public static final String NAME = "XPermMap";
+
+	public XPermMapServiceBase() {
+
+	}
+
+	@SuppressWarnings("unchecked")
+	@Override
+	protected XXPermMap mapViewToEntityBean(VXPermMap vObj, XXPermMap mObj, int OPERATION_CONTEXT) {
+		mObj.setPermGroup( vObj.getPermGroup());
+		mObj.setResourceId( vObj.getResourceId());
+		mObj.setGroupId( vObj.getGroupId());
+		mObj.setUserId( vObj.getUserId());
+		mObj.setPermFor( vObj.getPermFor());
+		mObj.setPermType( vObj.getPermType());
+		mObj.setIsRecursive( vObj.getIsRecursive());
+		mObj.setIsWildCard( vObj.isIsWildCard());
+		mObj.setGrantOrRevoke( vObj.isGrantOrRevoke());
+		mObj.setIpAddress( vObj.getIpAddress());
+		return mObj;
+	}
+
+	@SuppressWarnings("unchecked")
+	@Override
+	protected VXPermMap mapEntityToViewBean(VXPermMap vObj, XXPermMap mObj) {
+		vObj.setPermGroup( mObj.getPermGroup());
+		vObj.setResourceId( mObj.getResourceId());
+		vObj.setGroupId( mObj.getGroupId());
+		vObj.setUserId( mObj.getUserId());
+		vObj.setPermFor( mObj.getPermFor());
+		vObj.setPermType( mObj.getPermType());
+		vObj.setIsRecursive( mObj.getIsRecursive());
+		vObj.setIsWildCard( mObj.isIsWildCard());
+		vObj.setGrantOrRevoke( mObj.isGrantOrRevoke());
+		vObj.setIpAddress( mObj.getIpAddress());
+		return vObj;
+	}
+
+	/**
+	 * @param searchCriteria
+	 * @return
+	 */
+	public VXPermMapList searchXPermMaps(SearchCriteria searchCriteria) {
+		VXPermMapList returnList = new VXPermMapList();
+		List<VXPermMap> xPermMapList = new ArrayList<VXPermMap>();
+
+		@SuppressWarnings("unchecked")
+		List<XXPermMap> resultList = (List<XXPermMap>)searchResources(searchCriteria,
+				searchFields, sortFields, returnList);
+
+		// Iterate over the result list and create the return list
+		for (XXPermMap gjXPermMap : resultList) {
+			@SuppressWarnings("unchecked")
+			VXPermMap vXPermMap = populateViewBean((T)gjXPermMap);
+			xPermMapList.add(vXPermMap);
+		}
+
+		returnList.setVXPermMaps(xPermMapList);
+		return returnList;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/7defc061/security-admin/src/main/java/com/xasecure/service/XPolicyExportAuditService.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/com/xasecure/service/XPolicyExportAuditService.java b/security-admin/src/main/java/com/xasecure/service/XPolicyExportAuditService.java
new file mode 100644
index 0000000..9e77681
--- /dev/null
+++ b/security-admin/src/main/java/com/xasecure/service/XPolicyExportAuditService.java
@@ -0,0 +1,48 @@
+package com.xasecure.service;
+
+import com.xasecure.common.SearchField;
+import com.xasecure.common.SearchField.DATA_TYPE;
+import com.xasecure.common.SearchField.SEARCH_TYPE;
+import com.xasecure.common.SortField.SORT_ORDER;
+import com.xasecure.common.SortField;
+
+import com.xasecure.view.*;
+import com.xasecure.entity.*;
+
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Service;
+
+@Service
+@Scope("singleton")
+public class XPolicyExportAuditService extends XPolicyExportAuditServiceBase<XXPolicyExportAudit, VXPolicyExportAudit> {
+
+	public XPolicyExportAuditService(){
+		searchFields.add(new SearchField("httpRetCode", "obj.httpRetCode",
+				SearchField.DATA_TYPE.INTEGER, SearchField.SEARCH_TYPE.FULL));
+		searchFields.add(new SearchField("clientIP", "obj.clientIP",
+				SearchField.DATA_TYPE.STRING, SearchField.SEARCH_TYPE.PARTIAL));
+		searchFields.add(new SearchField("agentId", "obj.agentId",
+				SearchField.DATA_TYPE.STRING, SearchField.SEARCH_TYPE.PARTIAL));
+		searchFields.add(new SearchField("repositoryName", "obj.repositoryName",
+				SearchField.DATA_TYPE.STRING, SearchField.SEARCH_TYPE.PARTIAL));
+		searchFields.add(new SearchField("startDate", "obj.createTime", 
+				DATA_TYPE.DATE, SEARCH_TYPE.GREATER_EQUAL_THAN));
+		searchFields.add(new SearchField("endDate", "obj.createTime", 
+				DATA_TYPE.DATE, SEARCH_TYPE.LESS_EQUAL_THAN));
+		
+		sortFields.add(new SortField("createDate", "obj.createTime", true, SORT_ORDER.DESC));
+	}
+	
+	@Override
+	protected void validateForCreate(VXPolicyExportAudit vObj) {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	protected void validateForUpdate(VXPolicyExportAudit vObj, XXPolicyExportAudit mObj) {
+		// TODO Auto-generated method stub
+
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/7defc061/security-admin/src/main/java/com/xasecure/service/XPolicyExportAuditServiceBase.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/com/xasecure/service/XPolicyExportAuditServiceBase.java b/security-admin/src/main/java/com/xasecure/service/XPolicyExportAuditServiceBase.java
new file mode 100644
index 0000000..50a0cb0
--- /dev/null
+++ b/security-admin/src/main/java/com/xasecure/service/XPolicyExportAuditServiceBase.java
@@ -0,0 +1,82 @@
+package com.xasecure.service;
+/*
+ * Copyright (c) 2014 XASecure
+ * All rights reserved.
+ *
+ * This software is the confidential and proprietary information of
+ * XASecure ("Confidential Information").  You shall not
+ * disclose such Confidential Information and shall use it only in
+ * accordance with the terms of the license agreement you entered into
+ * with XASecure
+ */
+
+/**
+ * 
+ */
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.xasecure.common.*;
+import com.xasecure.entity.*;
+import com.xasecure.view.*;
+import com.xasecure.service.*;
+
+public abstract class XPolicyExportAuditServiceBase<T extends XXPolicyExportAudit, V extends VXPolicyExportAudit>
+		extends AbstractBaseResourceService<T, V> {
+	public static final String NAME = "XPolicyExportAudit";
+
+	public XPolicyExportAuditServiceBase() {
+
+	}
+
+	@SuppressWarnings("unchecked")
+	@Override
+	protected XXPolicyExportAudit mapViewToEntityBean(VXPolicyExportAudit vObj, XXPolicyExportAudit mObj, int OPERATION_CONTEXT) {
+		mObj.setClientIP( vObj.getClientIP());
+		mObj.setAgentId( vObj.getAgentId());
+		mObj.setRequestedEpoch( vObj.getRequestedEpoch());
+		mObj.setLastUpdated( vObj.getLastUpdated());
+		mObj.setRepositoryName( vObj.getRepositoryName());
+		mObj.setExportedJson( vObj.getExportedJson());
+		mObj.setHttpRetCode( vObj.getHttpRetCode());
+		return mObj;
+	}
+
+	@SuppressWarnings("unchecked")
+	@Override
+	protected VXPolicyExportAudit mapEntityToViewBean(VXPolicyExportAudit vObj, XXPolicyExportAudit mObj) {
+		vObj.setClientIP( mObj.getClientIP());
+		vObj.setAgentId( mObj.getAgentId());
+		vObj.setRequestedEpoch( mObj.getRequestedEpoch());
+		vObj.setLastUpdated( mObj.getLastUpdated());
+		vObj.setRepositoryName( mObj.getRepositoryName());
+		vObj.setExportedJson( mObj.getExportedJson());
+		vObj.setHttpRetCode( mObj.getHttpRetCode());
+		return vObj;
+	}
+
+	/**
+	 * @param searchCriteria
+	 * @return
+	 */
+	public VXPolicyExportAuditList searchXPolicyExportAudits(SearchCriteria searchCriteria) {
+		VXPolicyExportAuditList returnList = new VXPolicyExportAuditList();
+		List<VXPolicyExportAudit> xPolicyExportAuditList = new ArrayList<VXPolicyExportAudit>();
+
+		@SuppressWarnings("unchecked")
+		List<XXPolicyExportAudit> resultList = (List<XXPolicyExportAudit>)searchResources(searchCriteria,
+				searchFields, sortFields, returnList);
+
+		// Iterate over the result list and create the return list
+		for (XXPolicyExportAudit gjXPolicyExportAudit : resultList) {
+			@SuppressWarnings("unchecked")
+			VXPolicyExportAudit vXPolicyExportAudit = populateViewBean((T)gjXPolicyExportAudit);
+			xPolicyExportAuditList.add(vXPolicyExportAudit);
+		}
+
+		returnList.setVXPolicyExportAudits(xPolicyExportAuditList);
+		return returnList;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/7defc061/security-admin/src/main/java/com/xasecure/service/XPolicyService.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/com/xasecure/service/XPolicyService.java b/security-admin/src/main/java/com/xasecure/service/XPolicyService.java
new file mode 100644
index 0000000..41eb768
--- /dev/null
+++ b/security-admin/src/main/java/com/xasecure/service/XPolicyService.java
@@ -0,0 +1,300 @@
+/**
+ * 
+ */
+package com.xasecure.service;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map.Entry;
+import java.util.Random;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import com.xasecure.common.AppConstants;
+import com.xasecure.common.PropertiesUtil;
+import com.xasecure.common.RESTErrorUtil;
+import com.xasecure.common.SearchCriteria;
+import com.xasecure.common.StringUtil;
+import com.xasecure.db.XADaoManager;
+import com.xasecure.entity.XXGroup;
+import com.xasecure.entity.XXUser;
+import com.xasecure.view.VXAuditMap;
+import com.xasecure.view.VXAuditMapList;
+import com.xasecure.view.VXPermMap;
+import com.xasecure.view.VXPermMapList;
+import com.xasecure.view.VXPermObj;
+import com.xasecure.view.VXPolicy;
+import com.xasecure.view.VXPolicyList;
+import com.xasecure.view.VXResource;
+import com.xasecure.view.VXResourceList;
+
+/**
+ * @author tushar
+ * 
+ */
+
+@Service
+public class XPolicyService extends PublicAPIServiceBase<VXResource, VXPolicy> {
+
+	@Autowired
+	RESTErrorUtil restErrorUtil;
+
+	@Autowired
+	StringUtil stringUtil;
+
+	@Autowired
+	XADaoManager xaDaoMgr;
+
+	@Autowired
+	XPermMapService xPermMapService;
+
+	@Autowired
+	XAuditMapService xAuditMapService;
+
+	String version;
+
+	public XPolicyService() {
+		version = PropertiesUtil.getProperty("maven.project.version", "");
+	}
+
+	public VXPolicy mapXAToPublicObject(VXResource vXResource) {
+
+		VXPolicy vXPolicy = new VXPolicy();
+		vXPolicy = super.mapBaseAttributesToPublicObject(vXResource, vXPolicy);
+
+		vXPolicy.setPolicyName(vXResource.getPolicyName());
+		vXPolicy.setResourceName(vXResource.getName());
+		vXPolicy.setResourceType(AppConstants
+				.getLabelFor_ResourceType(vXResource.getResourceType()));
+		vXPolicy.setDescription(vXResource.getDescription());
+		vXPolicy.setRepositoryId(vXResource.getAssetId());
+		vXPolicy.setRepositoryName(vXResource.getAssetName());
+		vXPolicy.setRepositoryType(AppConstants
+				.getLabelFor_AssetType(vXResource.getAssetType()));
+		vXPolicy.setPermMapList(mapPermMapToPermObj(vXResource.getPermMapList()));
+		vXPolicy.setTables(vXResource.getTables());
+		vXPolicy.setColumnFamilies(vXResource.getColumnFamilies());
+		vXPolicy.setColumns(vXResource.getColumns());
+		vXPolicy.setDatabases(vXResource.getDatabases());
+		vXPolicy.setUdfs(vXResource.getUdfs());
+		vXPolicy.setTableType(AppConstants.getLabelFor_PolicyType(vXResource
+				.getTableType()));
+		vXPolicy.setColumnType(AppConstants.getLabelFor_PolicyType(vXResource
+				.getColumnType()));
+		vXPolicy.setTopologies(vXResource.getTopologies());
+		vXPolicy.setServices(vXResource.getServices());
+
+		boolean enable = true;
+		if (vXResource.getResourceStatus() == AppConstants.STATUS_DISABLED
+				|| vXResource.getResourceStatus() == AppConstants.STATUS_DELETED) {
+			enable = false;
+		}
+		vXPolicy.setEnabled(enable);
+		vXPolicy.setRecursive(AppConstants
+				.getBooleanFor_BooleanValue(vXResource.getIsRecursive()));
+
+		boolean auditEnable = true;
+		if (stringUtil.isEmpty(vXResource.getAuditList())) {
+			auditEnable = false;
+		}
+		vXPolicy.setAuditEnabled(auditEnable);
+
+		vXPolicy.setCheckParentPermission(AppConstants
+				.getBooleanFor_BooleanValue(vXResource
+						.getCheckParentPermission()));
+
+		vXPolicy.setVersion(version);
+
+		return vXPolicy;
+	}
+
+	public VXResource mapPublicToXAObject(VXPolicy vXPolicy,
+			int operationContext) {
+		VXResource vXResource = new VXResource();
+		vXResource = super.mapBaseAttributesToXAObject(vXPolicy, vXResource);
+
+		vXResource.setName(vXPolicy.getResourceName());
+		vXResource.setPolicyName(vXPolicy.getPolicyName());
+		vXResource.setDescription(vXPolicy.getDescription());
+		vXResource.setResourceType(AppConstants
+				.getEnumFor_ResourceType(vXPolicy.getResourceType()));
+		vXResource.setAssetId(vXPolicy.getRepositoryId());
+
+		if (operationContext == AbstractBaseResourceService.OPERATION_UPDATE_CONTEXT) {
+
+			SearchCriteria scAuditMap = new SearchCriteria();
+			scAuditMap.addParam("resourceId", vXPolicy.getId());
+			VXAuditMapList vXAuditMapList = xAuditMapService
+					.searchXAuditMaps(scAuditMap);
+			vXResource.setAuditList(vXAuditMapList.getVXAuditMaps());
+
+			SearchCriteria scPermMap = new SearchCriteria();
+			scPermMap.addParam("resourceId", vXPolicy.getId());
+			VXPermMapList vXPermMapList = xPermMapService
+					.searchXPermMaps(scPermMap);
+			vXResource.setPermMapList(vXPermMapList.getVXPermMaps());
+		} else if (operationContext == AbstractBaseResourceService.OPERATION_CREATE_CONTEXT) {
+
+			if (vXPolicy.isAuditEnabled()) {
+				VXAuditMap vXAuditMap = new VXAuditMap();
+				vXAuditMap.setAuditType(AppConstants.XA_AUDIT_TYPE_ALL);
+				List<VXAuditMap> auditList = new ArrayList<VXAuditMap>();
+				auditList.add(vXAuditMap);
+
+				vXResource.setAuditList(auditList);
+			}
+
+			if (!stringUtil.isEmpty(vXPolicy.getPermMapList())) {
+				List<VXPermMap> permMapList = mapPermObjToPermList(vXPolicy
+						.getPermMapList());
+				vXResource.setPermMapList(permMapList);
+			}
+		}
+
+		vXResource.setIsRecursive(AppConstants.getEnumFor_BooleanValue(vXPolicy
+				.isRecursive()));
+		vXResource.setDatabases(vXPolicy.getDatabases());
+		vXResource.setTables(vXPolicy.getTables());
+		vXResource.setColumnFamilies(vXPolicy.getColumnFamilies());
+		vXResource.setColumns(vXPolicy.getColumns());
+		vXResource.setUdfs(vXPolicy.getUdfs());
+		vXResource.setAssetName(vXPolicy.getRepositoryName());
+		vXResource.setAssetType(AppConstants.getEnumFor_AssetType(vXPolicy
+				.getRepositoryType()));
+
+		int resourceStatus = AppConstants.STATUS_ENABLED;
+		if (!vXPolicy.isEnabled()) {
+			resourceStatus = AppConstants.STATUS_DISABLED;
+		}
+		vXResource.setResourceStatus(resourceStatus);
+		vXResource.setCheckParentPermission(AppConstants
+				.getEnumFor_BooleanValue(vXPolicy.getCheckParentPermission()));
+		vXResource.setTopologies(vXPolicy.getTopologies());
+		vXResource.setServices(vXPolicy.getServices());
+		vXResource.setTableType(AppConstants.getEnumFor_PolicyType(vXPolicy
+				.getTableType()));
+		vXResource.setColumnType(AppConstants.getEnumFor_PolicyType(vXPolicy
+				.getColumnType()));
+
+		return vXResource;
+	}
+
+	private List<VXPermMap> mapPermObjToPermList(List<VXPermObj> permObjList) {
+
+		List<VXPermMap> permMapList = new ArrayList<VXPermMap>();
+		Random rand = new Random();
+
+		for (VXPermObj permObj : permObjList) {
+
+			if (!stringUtil.isEmpty(permObj.getUserList())) {
+				for (String user : permObj.getUserList()) {
+
+					String permGrp = new Date() + " : " + rand.nextInt(9999);
+
+					XXUser xxUser = xaDaoMgr.getXXUser().findByUserName(user);
+					for (String permission : permObj.getPermList()) {
+
+						VXPermMap vXPermMap = new VXPermMap();
+						int permType = AppConstants
+								.getEnumFor_XAPermType(permission);
+						vXPermMap.setPermFor(AppConstants.XA_PERM_FOR_USER);
+						vXPermMap.setPermGroup(permGrp);
+						vXPermMap.setPermType(permType);
+						vXPermMap.setUserId(xxUser.getId());
+
+						permMapList.add(vXPermMap);
+					}
+				}
+			}
+			if (!stringUtil.isEmpty(permObj.getGroupList())) {
+				for (String group : permObj.getGroupList()) {
+
+					String permGrp = new Date() + " : " + rand.nextInt(9999);
+
+					XXGroup xxGroup = xaDaoMgr.getXXGroup().findByGroupName(
+							group);
+					for (String permission : permObj.getPermList()) {
+
+						VXPermMap vXPermMap = new VXPermMap();
+						int permType = AppConstants
+								.getEnumFor_XAPermType(permission);
+						vXPermMap.setPermFor(AppConstants.XA_PERM_FOR_GROUP);
+						vXPermMap.setPermGroup(permGrp);
+						vXPermMap.setPermType(permType);
+						vXPermMap.setUserId(xxGroup.getId());
+
+						permMapList.add(vXPermMap);
+					}
+				}
+			}
+
+		}
+		return permMapList;
+	}
+
+	public List<VXPermObj> mapPermMapToPermObj(List<VXPermMap> permMapList) {
+
+		List<VXPermObj> permObjList = new ArrayList<VXPermObj>();
+		HashMap<String, List<VXPermMap>> sortedPemMap = new HashMap<String, List<VXPermMap>>();
+
+		for (VXPermMap vXPermMap : permMapList) {
+
+			String permGrp = vXPermMap.getPermGroup();
+			List<VXPermMap> sortedList = sortedPemMap.get(permGrp);
+			if (sortedList == null) {
+				sortedList = new ArrayList<VXPermMap>();
+				sortedPemMap.put(permGrp, sortedList);
+			}
+			sortedList.add(vXPermMap);
+		}
+
+		for (Entry<String, List<VXPermMap>> entry : sortedPemMap.entrySet()) {
+			VXPermObj vXPermObj = new VXPermObj();
+			List<String> userList = new ArrayList<String>();
+			List<String> groupList = new ArrayList<String>();
+			List<String> permList = new ArrayList<String>();
+			String ipAddress = "";
+
+			for (VXPermMap permMap : entry.getValue()) {
+				if (permMap.getPermFor() == AppConstants.XA_PERM_FOR_USER) {
+					// if (!userList.contains(permMap.getUserName())) {
+					userList.add(permMap.getUserName());
+					// }
+				} else if (permMap.getPermFor() == AppConstants.XA_PERM_FOR_GROUP) {
+					// if (!groupList.contains(permMap.getGroupName())) {
+					groupList.add(permMap.getGroupName());
+					// }
+				}
+				permList.add(AppConstants.getLabelFor_XAPermType(permMap
+						.getPermType()));
+				ipAddress = permMap.getIpAddress();
+			}
+			if (!userList.isEmpty()) {
+				vXPermObj.setUserList(userList);
+			}
+			if (!groupList.isEmpty()) {
+				vXPermObj.setGroupList(groupList);
+			}
+			vXPermObj.setPermList(permList);
+			vXPermObj.setIpAddress(ipAddress);
+
+			permObjList.add(vXPermObj);
+		}
+		return permObjList;
+	}
+
+	public VXPolicyList mapToVXPolicyList(VXResourceList vXResourceList) {
+
+		List<VXPolicy> policyList = new ArrayList<VXPolicy>();
+		for (VXResource vXAsset : vXResourceList.getVXResources()) {
+			VXPolicy vXRepo = mapXAToPublicObject(vXAsset);
+			policyList.add(vXRepo);
+		}
+		VXPolicyList vXPolicyList = new VXPolicyList(policyList);
+		return vXPolicyList;
+	}
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/7defc061/security-admin/src/main/java/com/xasecure/service/XPortalUserService.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/com/xasecure/service/XPortalUserService.java b/security-admin/src/main/java/com/xasecure/service/XPortalUserService.java
new file mode 100644
index 0000000..f69eb60
--- /dev/null
+++ b/security-admin/src/main/java/com/xasecure/service/XPortalUserService.java
@@ -0,0 +1,25 @@
+package com.xasecure.service;
+
+import com.xasecure.entity.*;
+import com.xasecure.view.*;
+
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Service;
+
+@Service
+@Scope("singleton")
+public class XPortalUserService extends XPortalUserServiceBase<XXPortalUser, VXPortalUser> {
+
+	@Override
+	protected void validateForCreate(VXPortalUser vObj) {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	protected void validateForUpdate(VXPortalUser vObj, XXPortalUser mObj) {
+		// TODO Auto-generated method stub
+
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/7defc061/security-admin/src/main/java/com/xasecure/service/XPortalUserServiceBase.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/com/xasecure/service/XPortalUserServiceBase.java b/security-admin/src/main/java/com/xasecure/service/XPortalUserServiceBase.java
new file mode 100644
index 0000000..bd35fa2
--- /dev/null
+++ b/security-admin/src/main/java/com/xasecure/service/XPortalUserServiceBase.java
@@ -0,0 +1,86 @@
+package com.xasecure.service;
+/*
+ * Copyright (c) 2014 XASecure
+ * All rights reserved.
+ *
+ * This software is the confidential and proprietary information of
+ * XASecure ("Confidential Information").  You shall not
+ * disclose such Confidential Information and shall use it only in
+ * accordance with the terms of the license agreement you entered into
+ * with XASecure
+ */
+
+/**
+ * 
+ */
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.xasecure.common.*;
+import com.xasecure.entity.*;
+import com.xasecure.view.*;
+import com.xasecure.service.*;
+
+public abstract class XPortalUserServiceBase<T extends XXPortalUser, V extends VXPortalUser>
+		extends AbstractBaseResourceService<T, V> {
+	public static final String NAME = "XPortalUser";
+
+	public XPortalUserServiceBase() {
+
+	}
+
+	@SuppressWarnings("unchecked")
+	@Override
+	protected XXPortalUser mapViewToEntityBean(VXPortalUser vObj, XXPortalUser mObj, int OPERATION_CONTEXT) {
+		mObj.setFirstName( vObj.getFirstName());
+		mObj.setLastName( vObj.getLastName());
+		mObj.setPublicScreenName( vObj.getPublicScreenName());
+		mObj.setLoginId( vObj.getLoginId());
+		mObj.setPassword( vObj.getPassword());
+		mObj.setEmailAddress( vObj.getEmailAddress());
+		mObj.setStatus( vObj.getStatus());
+		mObj.setUserSource( vObj.getUserSource());
+		mObj.setNotes( vObj.getNotes());
+		return mObj;
+	}
+
+	@SuppressWarnings("unchecked")
+	@Override
+	protected VXPortalUser mapEntityToViewBean(VXPortalUser vObj, XXPortalUser mObj) {
+		vObj.setFirstName( mObj.getFirstName());
+		vObj.setLastName( mObj.getLastName());
+		vObj.setPublicScreenName( mObj.getPublicScreenName());
+		vObj.setLoginId( mObj.getLoginId());
+		vObj.setPassword( mObj.getPassword());
+		vObj.setEmailAddress( mObj.getEmailAddress());
+		vObj.setStatus( mObj.getStatus());
+		vObj.setUserSource( mObj.getUserSource());
+		vObj.setNotes( mObj.getNotes());
+		return vObj;
+	}
+
+	/**
+	 * @param searchCriteria
+	 * @return
+	 */
+	public VXPortalUserList searchXPortalUsers(SearchCriteria searchCriteria) {
+		VXPortalUserList returnList = new VXPortalUserList();
+		List<VXPortalUser> xPortalUserList = new ArrayList<VXPortalUser>();
+
+		@SuppressWarnings("unchecked")
+		List<XXPortalUser> resultList = (List<XXPortalUser>)searchResources(searchCriteria,
+				searchFields, sortFields, returnList);
+
+		// Iterate over the result list and create the return list
+		for (XXPortalUser gjXPortalUser : resultList) {
+			@SuppressWarnings("unchecked")
+			VXPortalUser vXPortalUser = populateViewBean((T)gjXPortalUser);
+			xPortalUserList.add(vXPortalUser);
+		}
+
+		returnList.setVXPortalUsers(xPortalUserList);
+		return returnList;
+	}
+
+}


Mime
View raw message