james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [4/7] james-project git commit: JAMES-1956 Cassandra users repository should specify Locale when calling toLowerCase
Date Tue, 14 Mar 2017 09:01:44 GMT
JAMES-1956 Cassandra users repository should specify Locale when calling toLowerCase


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/1fda029d
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/1fda029d
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/1fda029d

Branch: refs/heads/master
Commit: 1fda029d1da19b4886e0607a334cc8ceb8900461
Parents: bdf1f07
Author: benwa <btellier@linagora.com>
Authored: Mon Mar 13 10:16:47 2017 +0700
Committer: benwa <btellier@linagora.com>
Committed: Tue Mar 14 15:59:55 2017 +0700

----------------------------------------------------------------------
 .../james/domainlist/cassandra/CassandraDomainList.java     | 9 +++++----
 .../james/user/cassandra/CassandraUsersRepository.java      | 7 ++++---
 2 files changed, 9 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/1fda029d/server/data/data-cassandra/src/main/java/org/apache/james/domainlist/cassandra/CassandraDomainList.java
----------------------------------------------------------------------
diff --git a/server/data/data-cassandra/src/main/java/org/apache/james/domainlist/cassandra/CassandraDomainList.java
b/server/data/data-cassandra/src/main/java/org/apache/james/domainlist/cassandra/CassandraDomainList.java
index 6114453..10599a8 100644
--- a/server/data/data-cassandra/src/main/java/org/apache/james/domainlist/cassandra/CassandraDomainList.java
+++ b/server/data/data-cassandra/src/main/java/org/apache/james/domainlist/cassandra/CassandraDomainList.java
@@ -25,6 +25,7 @@ import static com.datastax.driver.core.querybuilder.QueryBuilder.insertInto;
 import static com.datastax.driver.core.querybuilder.QueryBuilder.select;
 
 import java.util.List;
+import java.util.Locale;
 import java.util.stream.Collectors;
 
 import javax.annotation.Resource;
@@ -60,7 +61,7 @@ public class CassandraDomainList extends AbstractDomainList {
     public boolean containsDomain(String domain) throws DomainListException {
         return session.execute(select(CassandraDomainsTable.DOMAIN)
             .from(CassandraDomainsTable.TABLE_NAME)
-            .where(eq(CassandraDomainsTable.DOMAIN, domain.toLowerCase())))
+            .where(eq(CassandraDomainsTable.DOMAIN, domain.toLowerCase(Locale.US))))
             .one() != null;
     }
 
@@ -68,11 +69,11 @@ public class CassandraDomainList extends AbstractDomainList {
     public void addDomain(String domain) throws DomainListException {
         boolean executed = session.execute(insertInto(CassandraDomainsTable.TABLE_NAME)
             .ifNotExists()
-            .value(CassandraDomainsTable.DOMAIN, domain.toLowerCase()))
+            .value(CassandraDomainsTable.DOMAIN, domain.toLowerCase(Locale.US)))
             .one()
             .getBool(CassandraConstants.LIGHTWEIGHT_TRANSACTION_APPLIED);
         if (!executed) {
-            throw new DomainListException(domain.toLowerCase() + " already exists.");
+            throw new DomainListException(domain.toLowerCase(Locale.US) + " already exists.");
         }
     }
 
@@ -81,7 +82,7 @@ public class CassandraDomainList extends AbstractDomainList {
         ResultSet resultSet = session.execute(delete()
             .from(CassandraDomainsTable.TABLE_NAME)
             .ifExists()
-            .where(eq(CassandraDomainsTable.DOMAIN, domain.toLowerCase())));
+            .where(eq(CassandraDomainsTable.DOMAIN, domain.toLowerCase(Locale.US))));
         if (!resultSet.one().getBool(CassandraConstants.LIGHTWEIGHT_TRANSACTION_APPLIED))
{
             throw new DomainListException(domain + " was not found");
         }

http://git-wip-us.apache.org/repos/asf/james-project/blob/1fda029d/server/data/data-cassandra/src/main/java/org/apache/james/user/cassandra/CassandraUsersRepository.java
----------------------------------------------------------------------
diff --git a/server/data/data-cassandra/src/main/java/org/apache/james/user/cassandra/CassandraUsersRepository.java
b/server/data/data-cassandra/src/main/java/org/apache/james/user/cassandra/CassandraUsersRepository.java
index e87a1ba..e3d8824 100644
--- a/server/data/data-cassandra/src/main/java/org/apache/james/user/cassandra/CassandraUsersRepository.java
+++ b/server/data/data-cassandra/src/main/java/org/apache/james/user/cassandra/CassandraUsersRepository.java
@@ -32,6 +32,7 @@ import static org.apache.james.user.cassandra.tables.CassandraUserTable.REALNAME
 import static org.apache.james.user.cassandra.tables.CassandraUserTable.TABLE_NAME;
 
 import java.util.Iterator;
+import java.util.Locale;
 import java.util.Optional;
 
 import javax.annotation.Resource;
@@ -67,7 +68,7 @@ public class CassandraUsersRepository extends AbstractUsersRepository {
         ResultSet result = session.execute(
                 select(REALNAME, PASSWORD, ALGORITHM)
                 .from(TABLE_NAME)
-                .where(eq(NAME, name.toLowerCase())));
+                .where(eq(NAME, name.toLowerCase(Locale.US))));
         return Optional.ofNullable(result.one())
             .map(row -> new DefaultUser(row.getString(REALNAME), row.getString(PASSWORD),
row.getString(ALGORITHM)))
             .filter(user -> user.getUserName().equals(name))
@@ -83,7 +84,7 @@ public class CassandraUsersRepository extends AbstractUsersRepository {
                     .with(set(REALNAME, defaultUser.getUserName()))
                     .and(set(PASSWORD, defaultUser.getHashedPassword()))
                     .and(set(ALGORITHM, defaultUser.getHashAlgorithm()))
-                    .where(eq(NAME, defaultUser.getUserName().toLowerCase()))
+                    .where(eq(NAME, defaultUser.getUserName().toLowerCase(Locale.US)))
                     .ifExists())
                 .one()
                 .getBool(CassandraConstants.LIGHTWEIGHT_TRANSACTION_APPLIED);
@@ -148,7 +149,7 @@ public class CassandraUsersRepository extends AbstractUsersRepository
{
         user.setPassword(password);
         boolean executed = session.execute(
             insertInto(TABLE_NAME)
-                .value(NAME, user.getUserName().toLowerCase())
+                .value(NAME, user.getUserName().toLowerCase(Locale.US))
                 .value(REALNAME, user.getUserName())
                 .value(PASSWORD, user.getHashedPassword())
                 .value(ALGORITHM, user.getHashAlgorithm())


---------------------------------------------------------------------
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