james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e...@apache.org
Subject svn commit: r1241454 - /james/server/trunk/data-jpa/src/main/java/org/apache/james/user/jpa/JPAUsersRepository.java
Date Tue, 07 Feb 2012 13:07:38 GMT
Author: eric
Date: Tue Feb  7 13:07:38 2012
New Revision: 1241454

URL: http://svn.apache.org/viewvc?rev=1241454&view=rev
Log:
Lower cases and check if existing before JPA user creation (JAMES-1369)

Modified:
    james/server/trunk/data-jpa/src/main/java/org/apache/james/user/jpa/JPAUsersRepository.java

Modified: james/server/trunk/data-jpa/src/main/java/org/apache/james/user/jpa/JPAUsersRepository.java
URL: http://svn.apache.org/viewvc/james/server/trunk/data-jpa/src/main/java/org/apache/james/user/jpa/JPAUsersRepository.java?rev=1241454&r1=1241453&r2=1241454&view=diff
==============================================================================
--- james/server/trunk/data-jpa/src/main/java/org/apache/james/user/jpa/JPAUsersRepository.java
(original)
+++ james/server/trunk/data-jpa/src/main/java/org/apache/james/user/jpa/JPAUsersRepository.java
Tue Feb  7 13:07:38 2012
@@ -273,11 +273,15 @@ public class JPAUsersRepository extends 
      * org.apache.james.user.lib.AbstractUsersRepository#doAddUser(java.lang.String, java.lang.String)
      */
     protected void doAddUser(String username, String password) throws UsersRepositoryException
{
+        String lowerCasedUsername = username.toLowerCase();
+        if (contains(lowerCasedUsername)) {
+            throw new UsersRepositoryException(lowerCasedUsername + " already exists.");
+        }
         EntityManager entityManager = entityManagerFactory.createEntityManager();
         final EntityTransaction transaction = entityManager.getTransaction();
         try {
             transaction.begin();
-            JPAUser user = new JPAUser(username, password, algo);
+            JPAUser user = new JPAUser(lowerCasedUsername, password, algo);
             entityManager.persist(user);
             transaction.commit();
         } catch (PersistenceException e) {



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message