Author: bdaw
Date: 2006-12-19 12:46:38 -0500 (Tue, 19 Dec 2006)
New Revision: 5905
Modified:
trunk/identity/src/main/org/jboss/portal/identity/auth/IdentityLoginModule.java
trunk/identity/src/main/org/jboss/portal/identity/db/HibernateUserProfileModuleImpl.java
trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPUserModuleImpl.java
Log:
- small fixes to ldap modules behaviour
Modified: trunk/identity/src/main/org/jboss/portal/identity/auth/IdentityLoginModule.java
===================================================================
---
trunk/identity/src/main/org/jboss/portal/identity/auth/IdentityLoginModule.java 2006-12-19
17:44:09 UTC (rev 5904)
+++
trunk/identity/src/main/org/jboss/portal/identity/auth/IdentityLoginModule.java 2006-12-19
17:46:38 UTC (rev 5905)
@@ -134,6 +134,11 @@
try
{
User user = getUserModule().findUserByUserName(getUsername());
+ //in case module implementation doesn't throw proper
exception...
+ if (user == null)
+ {
+ throw new NoSuchUserException("UserModule returned null
user object");
+ }
if (havingRole != null)
{
boolean hasTheRole = false;
Modified:
trunk/identity/src/main/org/jboss/portal/identity/db/HibernateUserProfileModuleImpl.java
===================================================================
---
trunk/identity/src/main/org/jboss/portal/identity/db/HibernateUserProfileModuleImpl.java 2006-12-19
17:44:09 UTC (rev 5904)
+++
trunk/identity/src/main/org/jboss/portal/identity/db/HibernateUserProfileModuleImpl.java 2006-12-19
17:46:38 UTC (rev 5905)
@@ -40,6 +40,7 @@
import java.util.Set;
import java.util.Iterator;
import java.util.HashMap;
+import java.util.Random;
/**
* @author <a href="mailto:boleslaw.dawidowicz@jboss.org">Boleslaw
Dawidowicz</a>
@@ -62,6 +63,8 @@
private String defaultSynchronizePassword;
+ private boolean randomSynchronizePassword = false;
+
protected void startService() throws Exception
{
//
@@ -217,6 +220,18 @@
{
user.updatePassword(getDefaultSynchronizePassword());
}
+ //really dummy password generation
+ //TODO: make something more sophisticated (risk of this part is documented)
+ else if (randomSynchronizePassword)
+ {
+ Random r = new Random();
+ StringBuffer password = new StringBuffer();
+ for (int i = 0; i < 10; i++)
+ {
+ password.append(r.nextDouble());
+ }
+ user.updatePassword(password.toString());
+ }
session = getCurrentSession();
session.save(hu);
return hu;
@@ -289,5 +304,16 @@
{
this.defaultSynchronizePassword = defaultSynchronizePassword;
}
+
+
+ public boolean isRandomSynchronizePassword()
+ {
+ return randomSynchronizePassword;
+ }
+
+ public void setRandomSynchronizePassword(boolean randomSynchronizePassword)
+ {
+ this.randomSynchronizePassword = randomSynchronizePassword;
+ }
}
Modified: trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPUserModuleImpl.java
===================================================================
---
trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPUserModuleImpl.java 2006-12-19
17:44:09 UTC (rev 5904)
+++
trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPUserModuleImpl.java 2006-12-19
17:46:38 UTC (rev 5905)
@@ -89,12 +89,13 @@
catch (NoSuchElementException e)
{
log.debug("No user found with name: " + userName, e);
+
}
catch (NamingException e)
{
throw new IdentityException("User search failed.", e);
}
- return null;
+ throw new NoSuchUserException("No user found with name: " + userName);
}
Show replies by date