ranger-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sneet...@apache.org
Subject [4/4] git commit: ARGUS-6-parameter-handling-code-for-case-conversion
Date Mon, 18 Aug 2014 06:36:43 GMT
ARGUS-6-parameter-handling-code-for-case-conversion

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

Branch: refs/heads/master
Commit: 466f72fb4a20a1a133065d9d029f50af9d53d130
Parents: bce5a1c
Author: sneethiraj <sneethir@apache.org>
Authored: Mon Aug 18 01:33:54 2014 -0400
Committer: sneethiraj <sneethir@apache.org>
Committed: Mon Aug 18 01:33:54 2014 -0400

----------------------------------------------------------------------
 .../process/LdapUserGroupBuilder.java           | 49 +++++++++++++++++++-
 unixauthservice/conf/unixauthservice.properties |  5 ++
 2 files changed, 53 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/466f72fb/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
index 34bf538..5bc502b 100644
--- a/ugsync/src/main/java/com/xasecure/ldapusersync/process/LdapUserGroupBuilder.java
+++ b/ugsync/src/main/java/com/xasecure/ldapusersync/process/LdapUserGroupBuilder.java
@@ -36,6 +36,12 @@ public class LdapUserGroupBuilder implements UserGroupSource {
 	private DirContext dirContext;
 	private SearchControls searchControls;
 	
+	private boolean userNameCaseConversionFlag = false ;
+	private boolean groupNameCaseConversionFlag = false ;
+	private boolean userNameLowerCaseFlag = false ;
+	private boolean groupNameLowerCaseFlag = false ;
+
+	
 	public static void main(String[] args) throws Throwable {
 		LdapUserGroupBuilder  ugBuilder = new LdapUserGroupBuilder();
 		ugBuilder.init();
@@ -43,6 +49,27 @@ public class LdapUserGroupBuilder implements UserGroupSource {
 	
 	public LdapUserGroupBuilder() {
 		LOG.info("LdapUserGroupBuilder created") ;
+		
+		String userNameCaseConversion = config.getUserNameCaseConversion() ;
+		
+		if (UserGroupSyncConfig.UGSYNC_NONE_CASE_CONVERSION_VALUE.equalsIgnoreCase(userNameCaseConversion))
{
+		    userNameCaseConversionFlag = false ;
+		}
+		else {
+		    userNameCaseConversionFlag = true ;
+		    userNameLowerCaseFlag = UserGroupSyncConfig.UGSYNC_LOWER_CASE_CONVERSION_VALUE.equalsIgnoreCase(userNameCaseConversion)
;
+		}
+		
+		String groupNameCaseConversion = config.getGroupNameCaseConversion() ;
+		
+		if (UserGroupSyncConfig.UGSYNC_NONE_CASE_CONVERSION_VALUE.equalsIgnoreCase(groupNameCaseConversion))
{
+		    groupNameCaseConversionFlag = false ;
+		}
+		else {
+		    groupNameCaseConversionFlag = true ;
+		    groupNameLowerCaseFlag = UserGroupSyncConfig.UGSYNC_LOWER_CASE_CONVERSION_VALUE.equalsIgnoreCase(groupNameCaseConversion)
;
+		}
+		
 	}
 
 	@Override
@@ -140,6 +167,17 @@ public class LdapUserGroupBuilder implements UserGroupSource {
 				final SearchResult userEntry = searchResultEnum.next();
 				String userName = (String) userEntry.getAttributes()
 						.get(userNameAttribute).get();
+				
+				
+				if (userNameCaseConversionFlag) {
+					if (userNameLowerCaseFlag) {
+						userName = userName.toLowerCase() ;
+					}
+					else {
+						userName = userName.toUpperCase() ;
+					}
+				}
+				
 				Set<String> groups = new HashSet<String>();
 				Set<String> userGroupNameAttributeSet = config.getUserGroupNameAttributeSet();
 				for (String useGroupNameAttribute : userGroupNameAttributeSet) {
@@ -147,7 +185,16 @@ public class LdapUserGroupBuilder implements UserGroupSource {
 					if(userGroupfAttribute != null) {
 						NamingEnumeration<?> groupEnum = userGroupfAttribute.getAll();
 						while (groupEnum.hasMore()) {
-							groups.add(getShortGroupName((String) groupEnum.next()));
+							String gName = getShortGroupName((String) groupEnum
+									.next());
+							if (groupNameCaseConversionFlag) {
+								if (groupNameLowerCaseFlag) {
+									gName = gName.toLowerCase();
+								} else {
+									gName = gName.toUpperCase();
+								}
+							}
+							groups.add(gName);
 						}
 					}
 				}

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/466f72fb/unixauthservice/conf/unixauthservice.properties
----------------------------------------------------------------------
diff --git a/unixauthservice/conf/unixauthservice.properties b/unixauthservice/conf/unixauthservice.properties
index d37c340..f0c9406 100644
--- a/unixauthservice/conf/unixauthservice.properties
+++ b/unixauthservice/conf/unixauthservice.properties
@@ -127,3 +127,8 @@ ldapGroupSync.userNameAttribute = cn
 # default value: memberof, ismemberof
 ldapGroupSync.userGroupNameAttribute =  memberof, ismemberof
 
+#
+# UserSync - Case Conversion Flags
+# possible values:  none, lower, upper
+ldapGroupSync.username.caseConversion=lower
+ldapGroupSync.groupname.caseConversion=lower


Mime
View raw message