mina-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ber...@apache.org
Subject [4/9] git commit: fix HBase storage stuff
Date Mon, 08 Jul 2013 09:51:43 GMT
fix HBase storage stuff


Project: http://git-wip-us.apache.org/repos/asf/mina-vysper/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina-vysper/commit/9bbab821
Tree: http://git-wip-us.apache.org/repos/asf/mina-vysper/tree/9bbab821
Diff: http://git-wip-us.apache.org/repos/asf/mina-vysper/diff/9bbab821

Branch: refs/heads/master
Commit: 9bbab82127be14a53a28c1605b64168978eb7f82
Parents: 39f8518
Author: Bernd Fondermann <bernd@brainlounge.de>
Authored: Fri Jul 5 23:12:40 2013 +0200
Committer: Bernd Fondermann <bernd@brainlounge.de>
Committed: Fri Jul 5 23:12:40 2013 +0200

----------------------------------------------------------------------
 .../vysper/storage/hbase/roster/HBaseRosterManager.java  |  2 ++
 .../vysper/storage/hbase/user/HBaseUserManagement.java   | 11 ++++++-----
 2 files changed, 8 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mina-vysper/blob/9bbab821/server/storage/hbase/src/main/java/org/apache/vysper/storage/hbase/roster/HBaseRosterManager.java
----------------------------------------------------------------------
diff --git a/server/storage/hbase/src/main/java/org/apache/vysper/storage/hbase/roster/HBaseRosterManager.java
b/server/storage/hbase/src/main/java/org/apache/vysper/storage/hbase/roster/HBaseRosterManager.java
index a7417d6..0396e2d 100644
--- a/server/storage/hbase/src/main/java/org/apache/vysper/storage/hbase/roster/HBaseRosterManager.java
+++ b/server/storage/hbase/src/main/java/org/apache/vysper/storage/hbase/roster/HBaseRosterManager.java
@@ -72,6 +72,8 @@ public class HBaseRosterManager extends AbstractRosterManager {
         MutableRoster roster = new MutableRoster();
 
         final NavigableMap<byte[],byte[]> contacts = entityRow.getFamilyMap(COLUMN_FAMILY_NAME_CONTACT_BYTES);
+        if (contacts == null) return roster;
+        
         for (byte[] contactBytes : contacts.keySet()) {
             String contactAsString = null;
             EntityImpl contactJID = null;

http://git-wip-us.apache.org/repos/asf/mina-vysper/blob/9bbab821/server/storage/hbase/src/main/java/org/apache/vysper/storage/hbase/user/HBaseUserManagement.java
----------------------------------------------------------------------
diff --git a/server/storage/hbase/src/main/java/org/apache/vysper/storage/hbase/user/HBaseUserManagement.java
b/server/storage/hbase/src/main/java/org/apache/vysper/storage/hbase/user/HBaseUserManagement.java
index 72a2b0e..99d6995 100644
--- a/server/storage/hbase/src/main/java/org/apache/vysper/storage/hbase/user/HBaseUserManagement.java
+++ b/server/storage/hbase/src/main/java/org/apache/vysper/storage/hbase/user/HBaseUserManagement.java
@@ -33,6 +33,7 @@ import org.slf4j.LoggerFactory;
 
 import java.io.IOException;
 import java.security.MessageDigest;
+import java.util.Arrays;
 
 import static org.apache.vysper.storage.hbase.HBaseStorage.COLUMN_FAMILY_NAME_BASIC;
 import static org.apache.vysper.storage.hbase.HBaseUtils.entityAsBytes;
@@ -72,15 +73,15 @@ public class HBaseUserManagement implements UserAuthentication, AccountManagemen
             final Result entityRow = hBaseStorage.getEntityRow(jid, COLUMN_FAMILY_NAME_BASIC);
             if (entityRow == null) return false;
 
-            final String encryptedGivenPassword = encryptPassword(passwordCleartext);
+            final byte[] encryptedGivenPassword = encryptPassword(passwordCleartext);
             final byte[] passwordSavedBytes = entityRow.getValue(COLUMN_FAMILY_NAME_BASIC.getBytes(),
PASSWORD_COLUMN);
-            return new String(passwordSavedBytes, "UTF-8").equals(encryptedGivenPassword);
+            return Arrays.equals(passwordSavedBytes, encryptedGivenPassword);
         } catch (Exception e) {
             return false;
         }
     }
 
-    protected String encryptPassword(String passwordCleartext) {
+    protected byte[] encryptPassword(String passwordCleartext) {
         if (passwordCleartext == null) passwordCleartext = "";
         try {
             passwordCleartext = passwordCleartext + encryptionSalt;
@@ -91,7 +92,7 @@ public class HBaseUserManagement implements UserAuthentication, AccountManagemen
             for (int i = 0; i < rounds; i++) {
                 pwdBytes = digest.digest(pwdBytes);
             }
-            return new String(pwdBytes, "UTF-8");
+            return pwdBytes;
         } catch (Exception e) {
             throw new RuntimeException(e);
         }
@@ -129,7 +130,7 @@ public class HBaseUserManagement implements UserAuthentication, AccountManagemen
 
     private void setPasswordInHBase(Entity username, String password) throws IOException
{
         final Put put = new Put(entityAsBytes(username));
-        put.add(COLUMN_FAMILY_NAME_BASIC.getBytes(), PASSWORD_COLUMN, encryptPassword(password).getBytes("UTF-8"));
+        put.add(COLUMN_FAMILY_NAME_BASIC.getBytes(), PASSWORD_COLUMN, encryptPassword(password));
         hBaseStorage.getTable(HBaseStorage.TABLE_NAME_USER).put(put);
     }
 


Mime
View raw message