You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by kt...@apache.org on 2012/09/14 00:01:41 UTC

svn commit: r1384558 - in /accumulo/trunk/core/src: main/java/org/apache/accumulo/core/security/Authorizations.java test/java/org/apache/accumulo/core/security/AuthorizationsTest.java

Author: kturner
Date: Thu Sep 13 22:01:41 2012
New Revision: 1384558

URL: http://svn.apache.org/viewvc?rev=1384558&view=rev
Log:
ACCUMULO-241 fixed bug in Authorizations serialization introduced in recent changes

Modified:
    accumulo/trunk/core/src/main/java/org/apache/accumulo/core/security/Authorizations.java
    accumulo/trunk/core/src/test/java/org/apache/accumulo/core/security/AuthorizationsTest.java

Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/security/Authorizations.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/security/Authorizations.java?rev=1384558&r1=1384557&r2=1384558&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/security/Authorizations.java (original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/security/Authorizations.java Thu Sep 13 22:01:41 2012
@@ -111,11 +111,14 @@ public class Authorizations implements I
     String authsString = new String(authorizations);
     if (authsString.startsWith(HEADER)) {
       // its the new format
-      for (String encAuth : authsString.substring(HEADER.length()).split(",")) {
-        byte[] auth = Base64.decodeBase64(encAuth.getBytes());
-        auths.add(new ArrayByteSequence(auth));
+      authsString = authsString.substring(HEADER.length());
+      if (authsString.length() > 0) {
+        for (String encAuth : authsString.split(",")) {
+          byte[] auth = Base64.decodeBase64(encAuth.getBytes());
+          auths.add(new ArrayByteSequence(auth));
+        }
+        checkAuths();
       }
-      checkAuths();
     } else {
       // its the old format
       ArgumentChecker.notNull(authorizations);

Modified: accumulo/trunk/core/src/test/java/org/apache/accumulo/core/security/AuthorizationsTest.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/test/java/org/apache/accumulo/core/security/AuthorizationsTest.java?rev=1384558&r1=1384557&r2=1384558&view=diff
==============================================================================
--- accumulo/trunk/core/src/test/java/org/apache/accumulo/core/security/AuthorizationsTest.java (original)
+++ accumulo/trunk/core/src/test/java/org/apache/accumulo/core/security/AuthorizationsTest.java Thu Sep 13 22:01:41 2012
@@ -35,6 +35,12 @@ public class AuthorizationsTest {
     byte[] array = a.getAuthorizationsArray();
     Authorizations b = new Authorizations(array);
     assertEquals(a, b);
+    
+    // test encoding empty auths
+    a = new Authorizations();
+    array = a.getAuthorizationsArray();
+    b = new Authorizations(array);
+    assertEquals(a, b);
   }
   
 }