Author: bdaw
Date: 2008-05-20 10:18:07 -0400 (Tue, 20 May 2008)
New Revision: 10783
Modified:
modules/identity/branches/JBP_IDENTITY_BRANCH_1_0/identity/src/main/org/jboss/portal/identity/IdentityConfiguration.java
modules/identity/branches/JBP_IDENTITY_BRANCH_1_0/identity/src/main/org/jboss/portal/identity/auth/IdentityLoginModule.java
modules/identity/branches/JBP_IDENTITY_BRANCH_1_0/identity/src/main/org/jboss/portal/identity/ldap/LDAPUserModule.java
Log:
Add option to make portal authentication non case sensitive - customer request
Modified:
modules/identity/branches/JBP_IDENTITY_BRANCH_1_0/identity/src/main/org/jboss/portal/identity/IdentityConfiguration.java
===================================================================
---
modules/identity/branches/JBP_IDENTITY_BRANCH_1_0/identity/src/main/org/jboss/portal/identity/IdentityConfiguration.java 2008-05-20
14:03:57 UTC (rev 10782)
+++
modules/identity/branches/JBP_IDENTITY_BRANCH_1_0/identity/src/main/org/jboss/portal/identity/IdentityConfiguration.java 2008-05-20
14:18:07 UTC (rev 10783)
@@ -71,6 +71,8 @@
public static final String USER_ALLOW_EMPTY_PASSWORDS =
"allowEmptyPasswords";
+ public static final String USER_USER_NAME_TO_LOWER_CASE =
"userNameToLowerCase";
+
//public static final String ROLE_CONTAINER_DN = "roleContainerDN";
public static final String ROLE_RID_ATTRIBUTE_ID = "ridAttributeID";
Modified:
modules/identity/branches/JBP_IDENTITY_BRANCH_1_0/identity/src/main/org/jboss/portal/identity/auth/IdentityLoginModule.java
===================================================================
---
modules/identity/branches/JBP_IDENTITY_BRANCH_1_0/identity/src/main/org/jboss/portal/identity/auth/IdentityLoginModule.java 2008-05-20
14:03:57 UTC (rev 10782)
+++
modules/identity/branches/JBP_IDENTITY_BRANCH_1_0/identity/src/main/org/jboss/portal/identity/auth/IdentityLoginModule.java 2008-05-20
14:18:07 UTC (rev 10783)
@@ -74,6 +74,8 @@
protected String validateUserNameCase;
+ protected String userNameToLowerCase;
+
public void initialize(Subject subject, CallbackHandler callbackHandler, Map
sharedState, Map options)
{
super.initialize(subject, callbackHandler, sharedState, options);
@@ -88,6 +90,7 @@
additionalRole = (String) options.get("additionalRole");
havingRole = (String) options.get("havingRole");
validateUserNameCase = (String) options.get("validateUserNameCase");
+ userNameToLowerCase = (String) options.get("userNameToLowerCase");
// Some info
log.trace("userModuleJNDIName = " + userModuleJNDIName);
@@ -97,6 +100,7 @@
log.trace("additionalRole = " + additionalRole);
log.trace("havingRole = " + havingRole);
log.trace("validateUserNameCase = " + validateUserNameCase);
+ log.trace("userNameToLowerCase = " + userNameToLowerCase);
}
private UserModule userModule;
@@ -356,4 +360,28 @@
{
return new UserPrincipal(username);
}
+
+ protected String getUsername()
+ {
+ if (userNameToLowerCase != null &&
userNameToLowerCase.equalsIgnoreCase("true"))
+ {
+ return super.getUsername().toLowerCase();
+ }
+ return super.getUsername();
+ }
+
+ protected String[] getUsernameAndPassword() throws LoginException
+ {
+ String[] names = super.getUsernameAndPassword();
+
+ if (userNameToLowerCase != null &&
userNameToLowerCase.equalsIgnoreCase("true"))
+ {
+ if (names[0] != null)
+ {
+ names[0] = names[0].toLowerCase();
+ }
+ }
+ return names;
+
+ }
}
Modified:
modules/identity/branches/JBP_IDENTITY_BRANCH_1_0/identity/src/main/org/jboss/portal/identity/ldap/LDAPUserModule.java
===================================================================
---
modules/identity/branches/JBP_IDENTITY_BRANCH_1_0/identity/src/main/org/jboss/portal/identity/ldap/LDAPUserModule.java 2008-05-20
14:03:57 UTC (rev 10782)
+++
modules/identity/branches/JBP_IDENTITY_BRANCH_1_0/identity/src/main/org/jboss/portal/identity/ldap/LDAPUserModule.java 2008-05-20
14:18:07 UTC (rev 10783)
@@ -199,8 +199,16 @@
//make DN as user ID
ldapu = new LDAPUserImpl(dn,getIdentityContext(), dn);
- ldapu.setUserName(uida.get().toString());
+ if (isUserNameToLowerCase())
+ {
+ ldapu.setUserName(uida.get().toString().toLowerCase());
+ }
+ else
+ {
+ ldapu.setUserName(uida.get().toString());
+ }
+
log.debug("user uid: " + ldapu.getId());
log.debug("user dn: " + ldapu.getDn());
@@ -415,7 +423,16 @@
return Boolean.FALSE.booleanValue();
}
+ protected boolean isUserNameToLowerCase()
+ {
+ String userNameToLowerCase =
getIdentityConfiguration().getValue(IdentityConfiguration.USER_USER_NAME_TO_LOWER_CASE);
+ if (userNameToLowerCase != null &&
userNameToLowerCase.equalsIgnoreCase("true"))
+ {
+ return Boolean.TRUE.booleanValue();
+ }
+ return Boolean.FALSE.booleanValue();
+ }
/*protected String getEmailAttributeId() throws IdentityException
Show replies by date