accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ktur...@apache.org
Subject svn commit: r1448472 - in /accumulo/trunk/core/src: main/java/org/apache/accumulo/core/security/Authorizations.java test/java/org/apache/accumulo/core/security/AuthorizationsTest.java
Date Wed, 20 Feb 2013 23:39:53 GMT
Author: kturner
Date: Wed Feb 20 23:39:52 2013
New Revision: 1448472

URL: http://svn.apache.org/r1448472
Log:
ACCUMULO-1051 checking in patch from Kevin Faro

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=1448472&r1=1448471&r2=1448472&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
Wed Feb 20 23:39:52 2013
@@ -26,6 +26,8 @@ import java.util.Collections;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Set;
+import java.util.TreeSet;
 
 import org.apache.accumulo.core.data.ArrayByteSequence;
 import org.apache.accumulo.core.data.ByteSequence;
@@ -37,7 +39,7 @@ public class Authorizations implements I
   
   private static final long serialVersionUID = 1L;
   
-  private HashSet<ByteSequence> auths = new HashSet<ByteSequence>();
+  private Set<ByteSequence> auths = new HashSet<ByteSequence>();
   private List<byte[]> authsList = new ArrayList<byte[]>();
   private List<byte[]> immutableList = Collections.unmodifiableList(authsList);
   
@@ -74,8 +76,9 @@ public class Authorizations implements I
   }
   
   private void checkAuths() {
+    Set<ByteSequence> sortedAuths = new TreeSet<ByteSequence>(auths);
     
-    for (ByteSequence bs : auths) {
+    for (ByteSequence bs : sortedAuths) {
       if (bs.length() == 0) {
         throw new IllegalArgumentException("Empty authorization");
       }
@@ -233,10 +236,10 @@ public class Authorizations implements I
   public String serialize() {
     StringBuilder sb = new StringBuilder(HEADER);
     String sep = "";
-    for (ByteSequence auth : auths) {
+    for (byte[] auth : immutableList) {
       sb.append(sep);
       sep = ",";
-      sb.append(new String(Base64.encodeBase64(auth.toArray())));
+      sb.append(new String(Base64.encodeBase64(auth)));
     }
     
     return sb.toString();

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=1448472&r1=1448471&r2=1448472&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
Wed Feb 20 23:39:52 2013
@@ -43,4 +43,12 @@ public class AuthorizationsTest {
     assertEquals(a, b);
   }
   
+  @Test
+  public void testSerialization() {
+    Authorizations a1 = new Authorizations("a", "b");
+    Authorizations a2 = new Authorizations("b", "a");
+    
+    assertEquals(a1, a2);
+    assertEquals(a1.serialize(), a2.serialize());
+  }
 }



Mime
View raw message