accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vi...@apache.org
Subject svn commit: r1469650 - in /accumulo/branches/1.5: core/src/main/java/org/apache/accumulo/core/cli/ core/src/main/java/org/apache/accumulo/core/client/security/tokens/ core/src/main/java/org/apache/accumulo/core/util/shell/ core/src/test/java/org/apache...
Date Fri, 19 Apr 2013 00:56:51 GMT
Author: vines
Date: Fri Apr 19 00:56:51 2013
New Revision: 1469650

URL: http://svn.apache.org/r1469650
Log:
ACCUMULO-1314 - destroyable properties. Also, fixed the tests broken with the fix for ACCUMULO-1323


Modified:
    accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/cli/ClientOpts.java
    accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/client/security/tokens/AuthenticationToken.java
    accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/client/security/tokens/NullToken.java
    accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/client/security/tokens/PasswordToken.java
    accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java
    accumulo/branches/1.5/core/src/test/java/org/apache/accumulo/core/util/shell/ShellTest.java
    accumulo/branches/1.5/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java
    accumulo/branches/1.5/server/src/main/java/org/apache/accumulo/server/monitor/servlets/trace/Basic.java
    accumulo/branches/1.5/server/src/main/java/org/apache/accumulo/server/trace/TraceServer.java
    accumulo/branches/1.5/test/src/test/java/org/apache/accumulo/test/ShellServerTest.java

Modified: accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/cli/ClientOpts.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/cli/ClientOpts.java?rev=1469650&r1=1469649&r2=1469650&view=diff
==============================================================================
--- accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/cli/ClientOpts.java
(original)
+++ accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/cli/ClientOpts.java
Fri Apr 19 00:56:51 2013
@@ -21,7 +21,6 @@ import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.Map;
 import java.util.Map.Entry;
-import java.util.Properties;
 import java.util.TreeMap;
 import java.util.UUID;
 
@@ -36,6 +35,7 @@ import org.apache.accumulo.core.client.m
 import org.apache.accumulo.core.client.mapreduce.AccumuloOutputFormat;
 import org.apache.accumulo.core.client.mock.MockInstance;
 import org.apache.accumulo.core.client.security.tokens.AuthenticationToken;
+import org.apache.accumulo.core.client.security.tokens.AuthenticationToken.Properties;
 import org.apache.accumulo.core.client.security.tokens.PasswordToken;
 import org.apache.accumulo.core.conf.AccumuloConfiguration;
 import org.apache.accumulo.core.conf.DefaultConfiguration;

Modified: accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/client/security/tokens/AuthenticationToken.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/client/security/tokens/AuthenticationToken.java?rev=1469650&r1=1469649&r2=1469650&view=diff
==============================================================================
--- accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/client/security/tokens/AuthenticationToken.java
(original)
+++ accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/client/security/tokens/AuthenticationToken.java
Fri Apr 19 00:56:51 2013
@@ -16,9 +16,12 @@
  */
 package org.apache.accumulo.core.client.security.tokens;
 
-import java.util.Properties;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
 import java.util.Set;
 
+import javax.security.auth.DestroyFailedException;
 import javax.security.auth.Destroyable;
 
 import org.apache.hadoop.io.Writable;
@@ -27,6 +30,38 @@ import org.apache.hadoop.io.Writable;
  * @since 1.5.0
  */
 public interface AuthenticationToken extends Writable, Destroyable, Cloneable {
+  public class Properties extends HashMap<String, char[]> implements Destroyable {
+    private static final long serialVersionUID = 507486847276806489L;
+    boolean destroyed = false;
+    
+    public char[] put(String key, CharSequence value) {
+      char[] toPut = new char[value.length()];
+      for (int i = 0; i < value.length(); i++)
+        toPut[i] = value.charAt(i);
+      return this.put(key, toPut);
+    }
+    
+    public void putAllStrings(Map<String, ? extends CharSequence> map) {
+      for (Map.Entry<String,? extends CharSequence> entry : map.entrySet()) {
+        put(entry.getKey(), entry.getValue());
+      }
+    }
+
+    @Override
+    public void destroy() throws DestroyFailedException {
+      for (String key : this.keySet()) {
+        char[] val = this.get(key);
+        Arrays.fill(val, (char) 0);
+      }
+      this.clear();
+      destroyed = true;
+    }
+
+    @Override
+    public boolean isDestroyed() {
+      return destroyed;
+    }
+  }
   
   public static class TokenProperty implements Comparable<TokenProperty> {
     private String key, description;

Modified: accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/client/security/tokens/NullToken.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/client/security/tokens/NullToken.java?rev=1469650&r1=1469649&r2=1469650&view=diff
==============================================================================
--- accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/client/security/tokens/NullToken.java
(original)
+++ accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/client/security/tokens/NullToken.java
Fri Apr 19 00:56:51 2013
@@ -20,7 +20,6 @@ import java.io.DataInput;
 import java.io.DataOutput;
 import java.io.IOException;
 import java.util.Collections;
-import java.util.Properties;
 import java.util.Set;
 
 import javax.security.auth.DestroyFailedException;

Modified: accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/client/security/tokens/PasswordToken.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/client/security/tokens/PasswordToken.java?rev=1469650&r1=1469649&r2=1469650&view=diff
==============================================================================
--- accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/client/security/tokens/PasswordToken.java
(original)
+++ accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/client/security/tokens/PasswordToken.java
Fri Apr 19 00:56:51 2013
@@ -20,9 +20,9 @@ import java.io.DataInput;
 import java.io.DataOutput;
 import java.io.IOException;
 import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
 import java.util.Arrays;
 import java.util.LinkedHashSet;
-import java.util.Properties;
 import java.util.Set;
 
 import javax.security.auth.DestroyFailedException;
@@ -125,9 +125,11 @@ public class PasswordToken implements Au
   
   @Override
   public void init(Properties properties) {
-    if (properties.containsKey("password"))
-      this.password = properties.getProperty("password").getBytes(Constants.UTF8);
-    else
+    if (properties.containsKey("password")){
+      // encode() kicks back a C-string, which is not compatible with the old passwording
system
+      this.password = new byte[properties.get("password").length];
+      Constants.UTF8.encode(CharBuffer.wrap(properties.get("password"))).get(this.password,
0, this.password.length);
+    }else
       throw new IllegalArgumentException("Missing 'password' property");
   }
   

Modified: accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java?rev=1469650&r1=1469649&r2=1469650&view=diff
==============================================================================
--- accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java
(original)
+++ accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java
Fri Apr 19 00:56:51 2013
@@ -30,7 +30,6 @@ import java.util.List;
 import java.util.Locale;
 import java.util.Map;
 import java.util.Map.Entry;
-import java.util.Properties;
 import java.util.Set;
 import java.util.TreeMap;
 import java.util.UUID;
@@ -48,6 +47,7 @@ import org.apache.accumulo.core.client.T
 import org.apache.accumulo.core.client.ZooKeeperInstance;
 import org.apache.accumulo.core.client.mock.MockInstance;
 import org.apache.accumulo.core.client.security.tokens.AuthenticationToken;
+import org.apache.accumulo.core.client.security.tokens.AuthenticationToken.Properties;
 import org.apache.accumulo.core.client.security.tokens.PasswordToken;
 import org.apache.accumulo.core.conf.AccumuloConfiguration;
 import org.apache.accumulo.core.conf.Property;

Modified: accumulo/branches/1.5/core/src/test/java/org/apache/accumulo/core/util/shell/ShellTest.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/core/src/test/java/org/apache/accumulo/core/util/shell/ShellTest.java?rev=1469650&r1=1469649&r2=1469650&view=diff
==============================================================================
--- accumulo/branches/1.5/core/src/test/java/org/apache/accumulo/core/util/shell/ShellTest.java
(original)
+++ accumulo/branches/1.5/core/src/test/java/org/apache/accumulo/core/util/shell/ShellTest.java
Fri Apr 19 00:56:51 2013
@@ -83,7 +83,7 @@ public class ShellTest {
     output = new TestOutputStream();
     shell = new Shell(new ConsoleReader(new FileInputStream(FileDescriptor.in), new OutputStreamWriter(output)));
     shell.setLogErrorsToConsole();
-    shell.config("--fake", "-p", "");
+    shell.config("--fake", "-u", "test", "-p", "secret");
   }
   
   void assertGoodExit(String s, boolean stringPresent) {
@@ -150,10 +150,10 @@ public class ShellTest {
     exec("setauths x,y,z", false, "Missing required option");
     exec("setauths -s x,y,z -u notauser", false, "user does not exist");
     exec("setauths -s x,y,z", true);
-    exec("getauths -u notauser", false,"user does not exist");
-    exec("getauths", true,"y,z,x");
-    exec("addauths -u notauser", false,"Missing required option");
-    exec("addauths -u notauser -s foo", false,"user does not exist");
+    exec("getauths -u notauser", false, "user does not exist");
+    exec("getauths", true, "y,z,x");
+    exec("addauths -u notauser", false, "Missing required option");
+    exec("addauths -u notauser -s foo", false, "user does not exist");
     exec("addauths -s a", true);
     exec("getauths", true, "y,z,a,x");
     exec("setauths -c", true);
@@ -162,7 +162,8 @@ public class ShellTest {
   @Test
   public void userTest() throws Exception {
     Shell.log.debug("Starting user test --------------------------");
-    //exec("createuser root", false, "user exists");
+    // Test cannot be done via junit because createuser only prompts for password
+    //    exec("createuser root", false, "user exists");
   }
   
   @Test
@@ -172,7 +173,7 @@ public class ShellTest {
     exec("du", true, "0 [t]");
     exec("deletetable t -f", true, "Table: [t] has been deleted");
   }
-
+  
   @Test
   public void duTest() throws IOException {
     Shell.log.debug("Starting DU test --------------------------");

Modified: accumulo/branches/1.5/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java?rev=1469650&r1=1469649&r2=1469650&view=diff
==============================================================================
--- accumulo/branches/1.5/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java (original)
+++ accumulo/branches/1.5/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java Fri
Apr 19 00:56:51 2013
@@ -1247,8 +1247,8 @@ public class ProxyServer implements Accu
   }
   
   private AuthenticationToken getToken(String principal, Map<String,String> properties)
throws AccumuloSecurityException, AccumuloException {
-    Properties props = new Properties();
-    props.putAll(properties);
+    AuthenticationToken.Properties props = new AuthenticationToken.Properties();
+    props.putAllStrings(properties);
     AuthenticationToken token;
     try {
       token = tokenClass.newInstance();

Modified: accumulo/branches/1.5/server/src/main/java/org/apache/accumulo/server/monitor/servlets/trace/Basic.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/server/src/main/java/org/apache/accumulo/server/monitor/servlets/trace/Basic.java?rev=1469650&r1=1469649&r2=1469650&view=diff
==============================================================================
--- accumulo/branches/1.5/server/src/main/java/org/apache/accumulo/server/monitor/servlets/trace/Basic.java
(original)
+++ accumulo/branches/1.5/server/src/main/java/org/apache/accumulo/server/monitor/servlets/trace/Basic.java
Fri Apr 19 00:56:51 2013
@@ -19,7 +19,6 @@ package org.apache.accumulo.server.monit
 import java.util.Date;
 import java.util.Map;
 import java.util.Map.Entry;
-import java.util.Properties;
 
 import javax.servlet.http.HttpServletRequest;
 
@@ -29,6 +28,7 @@ import org.apache.accumulo.core.client.C
 import org.apache.accumulo.core.client.Scanner;
 import org.apache.accumulo.core.client.TableNotFoundException;
 import org.apache.accumulo.core.client.security.tokens.AuthenticationToken;
+import org.apache.accumulo.core.client.security.tokens.AuthenticationToken.Properties;
 import org.apache.accumulo.core.client.security.tokens.PasswordToken;
 import org.apache.accumulo.core.conf.AccumuloConfiguration;
 import org.apache.accumulo.core.conf.Property;

Modified: accumulo/branches/1.5/server/src/main/java/org/apache/accumulo/server/trace/TraceServer.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/server/src/main/java/org/apache/accumulo/server/trace/TraceServer.java?rev=1469650&r1=1469649&r2=1469650&view=diff
==============================================================================
--- accumulo/branches/1.5/server/src/main/java/org/apache/accumulo/server/trace/TraceServer.java
(original)
+++ accumulo/branches/1.5/server/src/main/java/org/apache/accumulo/server/trace/TraceServer.java
Fri Apr 19 00:56:51 2013
@@ -21,7 +21,6 @@ import java.net.ServerSocket;
 import java.nio.channels.ServerSocketChannel;
 import java.util.Map;
 import java.util.Map.Entry;
-import java.util.Properties;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.accumulo.core.Constants;
@@ -31,6 +30,7 @@ import org.apache.accumulo.core.client.C
 import org.apache.accumulo.core.client.Instance;
 import org.apache.accumulo.core.client.MutationsRejectedException;
 import org.apache.accumulo.core.client.security.tokens.AuthenticationToken;
+import org.apache.accumulo.core.client.security.tokens.AuthenticationToken.Properties;
 import org.apache.accumulo.core.client.security.tokens.PasswordToken;
 import org.apache.accumulo.core.conf.AccumuloConfiguration;
 import org.apache.accumulo.core.conf.Property;

Modified: accumulo/branches/1.5/test/src/test/java/org/apache/accumulo/test/ShellServerTest.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/test/src/test/java/org/apache/accumulo/test/ShellServerTest.java?rev=1469650&r1=1469649&r2=1469650&view=diff
==============================================================================
--- accumulo/branches/1.5/test/src/test/java/org/apache/accumulo/test/ShellServerTest.java
(original)
+++ accumulo/branches/1.5/test/src/test/java/org/apache/accumulo/test/ShellServerTest.java
Fri Apr 19 00:56:51 2013
@@ -707,7 +707,6 @@ public class ShellServerTest {
     exec("deletetable -f t");
     exec("sleep 1");
     String trace = exec("trace off");
-    //System.out.println("trace: " + trace);
     assertTrue(trace.contains("binMutations"));
     assertTrue(trace.contains("update"));
     assertTrue(trace.contains("DeleteTable"));



Mime
View raw message