incubator-accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bil...@apache.org
Subject svn commit: r1214461 - in /incubator/accumulo/trunk: ./ src/core/src/main/java/org/apache/accumulo/core/client/mock/MockInstance.java src/core/src/main/java/org/apache/accumulo/core/client/mock/MockSecurityOperations.java
Date Wed, 14 Dec 2011 20:51:16 GMT
Author: billie
Date: Wed Dec 14 20:51:16 2011
New Revision: 1214461

URL: http://svn.apache.org/viewvc?rev=1214461&view=rev
Log:
ACCUMULO-217 merged to trunk

Modified:
    incubator/accumulo/trunk/   (props changed)
    incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockInstance.java
    incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockSecurityOperations.java

Propchange: incubator/accumulo/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Dec 14 20:51:16 2011
@@ -1,3 +1,3 @@
 /incubator/accumulo/branches/1.3:1190280,1190413,1190420,1190427,1190500,1195622,1195625,1195629,1195635,1196044,1196054,1196057,1196071-1196072,1196106,1197066,1198935,1199383,1203683,1204625,1205547,1205880,1206169,1208031,1209124,1209526,1209532,1209539,1209541,1209587,1209657,1210518,1210571,1210596,1210598,1213424,1214320
 /incubator/accumulo/branches/1.3.5rc:1209938
-/incubator/accumulo/branches/1.4:1201902-1214325
+/incubator/accumulo/branches/1.4:1201902-1214325,1214446-1214447

Modified: incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockInstance.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockInstance.java?rev=1214461&r1=1214460&r2=1214461&view=diff
==============================================================================
--- incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockInstance.java
(original)
+++ incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockInstance.java
Wed Dec 14 20:51:16 2011
@@ -27,7 +27,9 @@ import org.apache.accumulo.core.client.A
 import org.apache.accumulo.core.client.Connector;
 import org.apache.accumulo.core.client.Instance;
 import org.apache.accumulo.core.conf.AccumuloConfiguration;
+import org.apache.accumulo.core.security.Authorizations;
 import org.apache.accumulo.core.security.thrift.AuthInfo;
+import org.apache.accumulo.core.util.ByteBufferUtil;
 import org.apache.accumulo.core.util.TextUtil;
 import org.apache.hadoop.io.Text;
 
@@ -85,12 +87,14 @@ public class MockInstance implements Ins
   
   @Override
   public Connector getConnector(String user, byte[] pass) throws AccumuloException, AccumuloSecurityException
{
-    return new MockConnector(user, acu);
+    Connector conn = new MockConnector(user, acu);
+    conn.securityOperations().createUser(user, pass, new Authorizations());
+    return conn;
   }
   
   @Override
   public Connector getConnector(String user, ByteBuffer pass) throws AccumuloException, AccumuloSecurityException
{
-    return new MockConnector(user, acu);
+    return getConnector(user, ByteBufferUtil.toBytes(pass));
   }
   
   @Override

Modified: incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockSecurityOperations.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockSecurityOperations.java?rev=1214461&r1=1214460&r2=1214461&view=diff
==============================================================================
--- incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockSecurityOperations.java
(original)
+++ incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockSecurityOperations.java
Wed Dec 14 20:51:16 2011
@@ -26,6 +26,7 @@ import org.apache.accumulo.core.client.a
 import org.apache.accumulo.core.security.Authorizations;
 import org.apache.accumulo.core.security.SystemPermission;
 import org.apache.accumulo.core.security.TablePermission;
+import org.apache.accumulo.core.security.thrift.SecurityErrorCode;
 
 public class MockSecurityOperations implements SecurityOperations {
   
@@ -58,6 +59,8 @@ public class MockSecurityOperations impl
     MockUser user = acu.users.get(name);
     if (user != null)
       user.password = Arrays.copyOf(password, password.length);
+    else
+      throw new AccumuloSecurityException(name, SecurityErrorCode.USER_DOESNT_EXIST);
   }
   
   @Override
@@ -65,6 +68,8 @@ public class MockSecurityOperations impl
     MockUser user = acu.users.get(name);
     if (user != null)
       user.authorizations = authorizations;
+    else
+      throw new AccumuloSecurityException(name, SecurityErrorCode.USER_DOESNT_EXIST);
   }
   
   @Override
@@ -72,7 +77,8 @@ public class MockSecurityOperations impl
     MockUser user = acu.users.get(name);
     if (user != null)
       return user.authorizations;
-    return new Authorizations();
+    else
+      throw new AccumuloSecurityException(name, SecurityErrorCode.USER_DOESNT_EXIST);
   }
   
   @Override
@@ -80,14 +86,15 @@ public class MockSecurityOperations impl
     MockUser user = acu.users.get(name);
     if (user != null)
       return user.permissions.contains(perm);
-    return false;
+    else
+      throw new AccumuloSecurityException(name, SecurityErrorCode.USER_DOESNT_EXIST);
   }
   
   @Override
   public boolean hasTablePermission(String name, String tableName, TablePermission perm)
throws AccumuloException, AccumuloSecurityException {
     MockTable table = acu.tables.get(tableName);
     if (table == null)
-      return false;
+      throw new AccumuloSecurityException(tableName, SecurityErrorCode.TABLE_DOESNT_EXIST);
     EnumSet<TablePermission> perms = table.userPermissions.get(name);
     if (perms == null)
       return false;
@@ -99,15 +106,17 @@ public class MockSecurityOperations impl
     MockUser user = acu.users.get(name);
     if (user != null)
       user.permissions.add(permission);
+    else
+      throw new AccumuloSecurityException(name, SecurityErrorCode.USER_DOESNT_EXIST);
   }
   
   @Override
   public void grantTablePermission(String name, String tableName, TablePermission permission)
throws AccumuloException, AccumuloSecurityException {
     if (acu.users.get(name) == null)
-      return;
+      throw new AccumuloSecurityException(name, SecurityErrorCode.USER_DOESNT_EXIST);
     MockTable table = acu.tables.get(tableName);
     if (table == null)
-      return;
+      throw new AccumuloSecurityException(tableName, SecurityErrorCode.TABLE_DOESNT_EXIST);
     EnumSet<TablePermission> perms = table.userPermissions.get(name);
     if (perms == null)
       table.userPermissions.put(name, EnumSet.of(permission));
@@ -120,15 +129,17 @@ public class MockSecurityOperations impl
     MockUser user = acu.users.get(name);
     if (user != null)
       user.permissions.remove(permission);
+    else
+      throw new AccumuloSecurityException(name, SecurityErrorCode.USER_DOESNT_EXIST);
   }
   
   @Override
   public void revokeTablePermission(String name, String tableName, TablePermission permission)
throws AccumuloException, AccumuloSecurityException {
     if (acu.users.get(name) == null)
-      return;
+      throw new AccumuloSecurityException(name, SecurityErrorCode.USER_DOESNT_EXIST);
     MockTable table = acu.tables.get(tableName);
     if (table == null)
-      return;
+      throw new AccumuloSecurityException(tableName, SecurityErrorCode.TABLE_DOESNT_EXIST);
     EnumSet<TablePermission> perms = table.userPermissions.get(name);
     if (perms != null)
       perms.remove(permission);



Mime
View raw message