ranger-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sneet...@apache.org
Subject git commit: ARGUS-29:Allow kerberized username during repo creation
Date Thu, 04 Sep 2014 13:19:21 GMT
Repository: incubator-argus
Updated Branches:
  refs/heads/master a735e9f09 -> 933bae568


ARGUS-29:Allow kerberized username during repo creation

Signed-off-by: sneethiraj <sneethir@apache.org>


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

Branch: refs/heads/master
Commit: 933bae568a1b002eb1d09e1ed030923953d9e7ef
Parents: a735e9f
Author: vperiasamy <vperiasamy@hortonworks.com>
Authored: Wed Sep 3 12:42:08 2014 -0400
Committer: sneethiraj <sneethir@apache.org>
Committed: Thu Sep 4 09:16:46 2014 -0400

----------------------------------------------------------------------
 .../src/main/java/com/xasecure/biz/AssetMgr.java       |  8 ++++----
 .../src/main/java/com/xasecure/common/StringUtil.java  | 13 +++++++++++++
 .../src/main/webapp/scripts/views/asset/AssetForm.js   |  4 ++--
 3 files changed, 19 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/933bae56/security-admin/src/main/java/com/xasecure/biz/AssetMgr.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/com/xasecure/biz/AssetMgr.java b/security-admin/src/main/java/com/xasecure/biz/AssetMgr.java
index e635b9d..2f8bb05 100644
--- a/security-admin/src/main/java/com/xasecure/biz/AssetMgr.java
+++ b/security-admin/src/main/java/com/xasecure/biz/AssetMgr.java
@@ -130,7 +130,7 @@ public class AssetMgr extends AssetMgrBase {
 	@Autowired
 	@Qualifier(value = "transactionManager")
 	PlatformTransactionManager txManager;
-
+	
 	static Logger logger = Logger.getLogger(AssetMgr.class);
 
 	@Override
@@ -1207,7 +1207,7 @@ public class AssetMgr extends AssetMgrBase {
 		int assetType = vXAsset.getAssetType();
 
 		Map<String, String> configMap = jsonUtil.jsonToMap(config);
-		String userName = configMap.get("username");
+		String userName = stringUtil.getValidUserName(configMap.get("username"));
 
 		VXResource vXResource = new VXResource();
 		vXResource.setAssetId(vXAsset.getId());
@@ -1939,7 +1939,7 @@ public class AssetMgr extends AssetMgrBase {
 	public void updateDefaultPolicy(VXAsset vXAsset, String config) {
 		int assetType = vXAsset.getAssetType();
 		Map<String, String> configMap = jsonUtil.jsonToMap(config);
-		String userName = configMap.get("username");
+		String userName = stringUtil.getValidUserName(configMap.get("username"));
 		VXResource vxResource = fetchDefaultPolicyForAsset(vXAsset.getId(),
 				assetType);
 		if (vxResource != null) {
@@ -2241,7 +2241,7 @@ public class AssetMgr extends AssetMgrBase {
 			return ;
 		}
 		Map<String, String> configMap = jsonUtil.jsonToMap(config);
-		String userName = configMap.get("username");
+		String userName = stringUtil.getValidUserName(configMap.get("username"));
 		VXResource vXResource = new VXResource();
 		vXResource.setAssetId(vXAsset.getId());
 		vXResource.setAssetName(vXAsset.getName());

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/933bae56/security-admin/src/main/java/com/xasecure/common/StringUtil.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/com/xasecure/common/StringUtil.java b/security-admin/src/main/java/com/xasecure/common/StringUtil.java
index a186781..1a66459 100644
--- a/security-admin/src/main/java/com/xasecure/common/StringUtil.java
+++ b/security-admin/src/main/java/com/xasecure/common/StringUtil.java
@@ -221,5 +221,18 @@ public class StringUtil implements Serializable {
 		}
 		return false;
 	}
+	
+	/**
+	 * Returns a valid user name from the passed string
+	 * @param str
+	 * @return
+	 */
+	public String getValidUserName(String str) {
+		return str.indexOf("/") >= 0 ? 
+				 str.substring(0,str.indexOf("/"))
+				:	str.indexOf("@") >= 0 ? 
+						str.substring(0,str.indexOf("@")) 
+						: str; 
+	}
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/933bae56/security-admin/src/main/webapp/scripts/views/asset/AssetForm.js
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/scripts/views/asset/AssetForm.js b/security-admin/src/main/webapp/scripts/views/asset/AssetForm.js
index 08a0ae7..e5fff85 100644
--- a/security-admin/src/main/webapp/scripts/views/asset/AssetForm.js
+++ b/security-admin/src/main/webapp/scripts/views/asset/AssetForm.js
@@ -69,8 +69,8 @@ define(function(require){
 					type : 'Text',
 //					fieldClass : "hdfs hive knox",
 					title : this.model.propertiesNameMap.userName+" *",//'xalogin.username'
-					validators  : ['required',{type:'regexp',regexp:/^[a-z][a-z0-9,._'-]+$/i,message :'Please
enter valid username'}],
-					editorAttrs :{'class':'stretchTextInput','maxlength': 32}
+					validators  : ['required'],//{type:'regexp',regexp:/^[a-z][a-z0-9,._'-]+$/i,message
:'Please enter valid username'}],
+					editorAttrs :{'class':'stretchTextInput'}//,'maxlength': 48}
 				},
 				passwordKeytabfile : {
 					type : 'Password',


Mime
View raw message