[4/7] git commit: Merge branch '1.5.2-SNAPSHOT' into 1.6.1-SNAPSHOT
Merge branch '1.5.2-SNAPSHOT' into 1.6.1-SNAPSHOT Conflicts: core/src/main/java/org/apache/accumulo/core/security/ColumnVisibility.java Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/f506e2c7 Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/f506e2c7 Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/f506e2c7 Branch: refs/heads/master Commit: f506e2c735bb8c9b39afec2be948046ed7485f39 Parents: f573a14 9199759 Author: Josh Elser els...@apache.org Authored: Thu Jun 26 12:58:36 2014 -0400 Committer: Josh Elser els...@apache.org Committed: Thu Jun 26 12:58:36 2014 -0400 -- .../core/security/ColumnVisibility.java | 66 ++-- .../accumulo_user_manual/chapters/security.tex | 10 ++- 2 files changed, 41 insertions(+), 35 deletions(-) -- http://git-wip-us.apache.org/repos/asf/accumulo/blob/f506e2c7/core/src/main/java/org/apache/accumulo/core/security/ColumnVisibility.java -- diff --cc core/src/main/java/org/apache/accumulo/core/security/ColumnVisibility.java index 75091d2,af44ab5..e76b0ef --- a/core/src/main/java/org/apache/accumulo/core/security/ColumnVisibility.java +++ b/core/src/main/java/org/apache/accumulo/core/security/ColumnVisibility.java @@@ -35,6 -35,38 +35,38 @@@ import org.apache.hadoop.io.WritableCom /** * Validate the column visibility is a valid expression and set the visibility for a Mutation. See {@link ColumnVisibility#ColumnVisibility(byte[])} for the * definition of an expression. + * + * P + * The expression is a sequence of characters from the set [A-Za-z0-9_-.] along with the - * binary operators and | indicating that both operands are necessary, or the either ++ * binary operators amp; and | indicating that both operands are necessary, or the either + * is necessary. The following are valid expressions for visibility: + * + * pre + * A + * A|B - * (A|B)(C|D) - * orange|(redyellow) ++ * (A|B)amp;(C|D) ++ * orange|(redamp;yellow) + * /pre + * + * P + * The following are not valid expressions for visibility: + * + * pre - * A|BC ++ * A|Bamp;C + * A=B + * A|B| - * A|B ++ * Aamp;|B + * () + * ) + * dog|!cat + * /pre + * + * P + * In addition to the base set of visibilities, any character can be used in the expression if it is quoted. If the quoted term contains 'quot;' or '\', then escape + * the character with '\'. The {@link #quote(String)} method can be used to properly quote and escape terms automatically. The following is an example of a quoted term: + * pre + * quot;A#Cquot;span /amp;span /B + * /pre */ public class ColumnVisibility { @@@ -401,42 -410,10 +433,10 @@@ } /** - * Set the column visibility for a Mutation. - * + * Creates a column visibility for a Mutation. + * * @param expression -* An expression of the rights needed to see this mutation. The expression is a sequence of characters from the set [A-Za-z0-9_-] along with the -* binary operators amp; and | indicating that both operands are necessary, or that either is necessary. The following are valid expressions for -* visibility: -* -* pre -* A -* A|B -* (A|B)amp;(C|D) -* orange|(redamp;yellow) -* -* /pre -* -* P -* The following are not valid expressions for visibility: -* -* pre -* A|Bamp;C -* A=B -* A|B| -* Aamp;|B -* () -* ) -* dog|!cat -* /pre -* -* P -* You can use any character you like in your column visibility expression with quoting. If your quoted term contains 'quot;' or '\' then escape -* them with '\'. The {@link #quote(String)} method will properly quote and escape terms for you. -* -* pre -* quot;A#Cquot;span /amp;span /B -* /pre -* +* An expression of the rights needed to see this mutation. The expression syntax is defined at the class-level documentation */ public ColumnVisibility(String expression) { this(expression.getBytes(Constants.UTF8)); http://git-wip-us.apache.org/repos/asf/accumulo/blob/f506e2c7/docs/src/main/latex/accumulo_user_manual/chapters/security.tex --
[4/7] git commit: Merge branch '1.5.2-SNAPSHOT' into 1.6.1-SNAPSHOT
Merge branch '1.5.2-SNAPSHOT' into 1.6.1-SNAPSHOT Conflicts: core/src/test/java/org/apache/accumulo/core/client/mapred/AccumuloInputFormatTest.java Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/934ca6fd Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/934ca6fd Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/934ca6fd Branch: refs/heads/master Commit: 934ca6fd4fc3ad34838e872574e5e9965132 Parents: 9348032 2422d49 Author: Josh Elser els...@apache.org Authored: Thu Jun 26 16:09:03 2014 -0400 Committer: Josh Elser els...@apache.org Committed: Thu Jun 26 16:09:03 2014 -0400 -- .../client/mapred/AccumuloInputFormatTest.java | 55 ++ .../core/client/mapred/RangeInputSplitTest.java | 105 +++ .../mapreduce/AccumuloInputFormatTest.java | 2 +- 3 files changed, 161 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/accumulo/blob/934ca6fd/core/src/test/java/org/apache/accumulo/core/client/mapred/AccumuloInputFormatTest.java -- diff --cc core/src/test/java/org/apache/accumulo/core/client/mapred/AccumuloInputFormatTest.java index 9e6958a,402e687..9991206 --- a/core/src/test/java/org/apache/accumulo/core/client/mapred/AccumuloInputFormatTest.java +++ b/core/src/test/java/org/apache/accumulo/core/client/mapred/AccumuloInputFormatTest.java @@@ -36,10 -39,13 +39,13 @@@ import org.apache.accumulo.core.data.Mu import org.apache.accumulo.core.data.Value; import org.apache.accumulo.core.iterators.user.RegExFilter; import org.apache.accumulo.core.iterators.user.WholeRowIterator; + import org.apache.accumulo.core.security.Authorizations; -import org.apache.accumulo.core.util.CachedConfiguration; +import org.apache.accumulo.core.util.Base64; + import org.apache.accumulo.core.util.Pair; -import org.apache.commons.codec.binary.Base64; +import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configured; import org.apache.hadoop.io.Text; + import org.apache.hadoop.mapred.InputSplit; import org.apache.hadoop.mapred.JobClient; import org.apache.hadoop.mapred.JobConf; import org.apache.hadoop.mapred.Mapper; @@@ -48,8 -54,8 +54,10 @@@ import org.apache.hadoop.mapred.Reporte import org.apache.hadoop.mapred.lib.NullOutputFormat; import org.apache.hadoop.util.Tool; import org.apache.hadoop.util.ToolRunner; + import org.apache.log4j.Level; + import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; import org.junit.Test; public class AccumuloInputFormatTest { @@@ -282,4 -285,51 +290,51 @@@ assertNull(e1); assertNull(e2); } + + @Test + public void testCorrectRangeInputSplits() throws Exception { + JobConf job = new JobConf(); + + String username = user, table = table, instance = mapred_testCorrectRangeInputSplits; + PasswordToken password = new PasswordToken(password); + Authorizations auths = new Authorizations(foo); + CollectionPairText,Text fetchColumns = Collections.singleton(new PairText,Text(new Text(foo), new Text(bar))); + boolean isolated = true, localIters = true; + Level level = Level.WARN; + + Instance inst = new MockInstance(instance); + Connector connector = inst.getConnector(username, password); + connector.tableOperations().create(table); + + AccumuloInputFormat.setConnectorInfo(job, username, password); + AccumuloInputFormat.setInputTableName(job, table); + AccumuloInputFormat.setScanAuthorizations(job, auths); + AccumuloInputFormat.setMockInstance(job, instance); + AccumuloInputFormat.setScanIsolation(job, isolated); + AccumuloInputFormat.setLocalIterators(job, localIters); + AccumuloInputFormat.fetchColumns(job, fetchColumns); + AccumuloInputFormat.setLogLevel(job, level); + + AccumuloInputFormat aif = new AccumuloInputFormat(); + + InputSplit[] splits = aif.getSplits(job, 1); + + Assert.assertEquals(1, splits.length); + + InputSplit split = splits[0]; + + Assert.assertEquals(RangeInputSplit.class, split.getClass()); + + RangeInputSplit risplit = (RangeInputSplit) split; + + Assert.assertEquals(username, risplit.getPrincipal()); -Assert.assertEquals(table, risplit.getTable()); ++Assert.assertEquals(table, risplit.getTableName()); + Assert.assertEquals(password, risplit.getToken()); + Assert.assertEquals(auths, risplit.getAuths()); + Assert.assertEquals(instance, risplit.getInstanceName()); + Assert.assertEquals(isolated, risplit.isIsolatedScan()); + Assert.assertEquals(localIters, risplit.usesLocalIterators()); + Assert.assertEquals(fetchColumns, risplit.getFetchedColumns()); + Assert.assertEquals(level,
[4/7] git commit: Merge branch '1.5.2-SNAPSHOT' into 1.6.1-SNAPSHOT
Merge branch '1.5.2-SNAPSHOT' into 1.6.1-SNAPSHOT Conflicts: core/src/main/java/org/apache/accumulo/core/client/BatchWriterConfig.java Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/344b4d3a Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/344b4d3a Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/344b4d3a Branch: refs/heads/master Commit: 344b4d3a31bab7b42538497843df6420bb95b593 Parents: c86b067 f99b565 Author: Josh Elser els...@apache.org Authored: Thu Jun 19 13:11:29 2014 -0700 Committer: Josh Elser els...@apache.org Committed: Thu Jun 19 13:11:29 2014 -0700 -- .../accumulo/core/client/BatchWriterConfig.java | 107 +++ .../core/client/BatchWriterConfigTest.java | 26 + 2 files changed, 113 insertions(+), 20 deletions(-) -- http://git-wip-us.apache.org/repos/asf/accumulo/blob/344b4d3a/core/src/main/java/org/apache/accumulo/core/client/BatchWriterConfig.java -- diff --cc core/src/main/java/org/apache/accumulo/core/client/BatchWriterConfig.java index 5b149fa,28955f5..105a5d6 --- a/core/src/main/java/org/apache/accumulo/core/client/BatchWriterConfig.java +++ b/core/src/main/java/org/apache/accumulo/core/client/BatchWriterConfig.java @@@ -23,7 -24,7 +23,8 @@@ import java.util.ArrayList import java.util.List; import java.util.concurrent.TimeUnit; +import org.apache.accumulo.core.Constants; + import org.apache.commons.lang.builder.HashCodeBuilder; import org.apache.hadoop.io.Writable; import org.apache.hadoop.util.StringUtils; @@@ -179,9 -180,9 +180,9 @@@ public class BatchWriterConfig implemen if (timeout != null) addField(fields, timeout, timeout); String output = StringUtils.join(,, fields); - + -byte[] bytes = output.getBytes(Charset.forName(UTF-8)); -byte[] len = String.format(%6s#, Integer.toString(bytes.length, 36)).getBytes(UTF-8); +byte[] bytes = output.getBytes(Constants.UTF8); +byte[] len = String.format(%6s#, Integer.toString(bytes.length, 36)).getBytes(Constants.UTF8); if (len.length != 7) throw new IllegalStateException(encoded length does not match expected value); out.write(len); @@@ -203,8 -204,8 +204,8 @@@ throw new IllegalStateException(length was not encoded correctly); byte[] bytes = new byte[Integer.parseInt(strLen.substring(strLen.lastIndexOf(' ') + 1, strLen.length() - 1), 36)]; in.readFully(bytes); - + -String strFields = new String(bytes, Charset.forName(UTF-8)); +String strFields = new String(bytes, Constants.UTF8); String[] fields = StringUtils.split(strFields, '\\', ','); for (String field : fields) { String[] keyValue = StringUtils.split(field, '\\', '='); http://git-wip-us.apache.org/repos/asf/accumulo/blob/344b4d3a/core/src/test/java/org/apache/accumulo/core/client/BatchWriterConfigTest.java -- diff --cc core/src/test/java/org/apache/accumulo/core/client/BatchWriterConfigTest.java index 26f23a5,ddd201a..259cb06 --- a/core/src/test/java/org/apache/accumulo/core/client/BatchWriterConfigTest.java +++ b/core/src/test/java/org/apache/accumulo/core/client/BatchWriterConfigTest.java @@@ -155,9 -155,35 +155,35 @@@ public class BatchWriterConfigTest bwConfig.setMaxWriteThreads(24); bwConfig.setTimeout(3, TimeUnit.SECONDS); bytes = createBytes(bwConfig); -assertEquals( v#maxWriteThreads=24,timeout=3000, new String(bytes, Charset.forName(UTF-8))); +assertEquals( v#maxWriteThreads=24,timeout=3000, new String(bytes, Constants.UTF8)); checkBytes(bwConfig, bytes); } + + @Test + public void testDefaultEquality() { + BatchWriterConfig cfg1 = new BatchWriterConfig(), cfg2 = new BatchWriterConfig(); + assertEquals(cfg1, cfg2); + assertEquals(cfg1.hashCode(), cfg2.hashCode()); + cfg2.setMaxMemory(1); + assertNotEquals(cfg1, cfg2); + } + + @Test + public void testManualEquality() { + BatchWriterConfig cfg1 = new BatchWriterConfig(), cfg2 = new BatchWriterConfig(); + cfg1.setMaxLatency(10, TimeUnit.SECONDS); + cfg2.setMaxLatency(1, TimeUnit.MILLISECONDS); + + cfg1.setMaxMemory(100); + cfg2.setMaxMemory(100); + + cfg1.setTimeout(10, TimeUnit.SECONDS); + cfg2.setTimeout(1, TimeUnit.MILLISECONDS); + + assertEquals(cfg1, cfg2); + + assertEquals(cfg1.hashCode(), cfg2.hashCode()); + } private byte[] createBytes(BatchWriterConfig bwConfig) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream();
[4/7] git commit: Merge branch '1.5.2-SNAPSHOT' into 1.6.1-SNAPSHOT
Merge branch '1.5.2-SNAPSHOT' into 1.6.1-SNAPSHOT Conflicts: server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/ShellServlet.java Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/eb6b3253 Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/eb6b3253 Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/eb6b3253 Branch: refs/heads/master Commit: eb6b3253b7df7c7e3c4b8ed7df055d951c0e5621 Parents: eb7aac3 5d4cf3b Author: Josh Elser els...@apache.org Authored: Fri May 23 20:24:18 2014 -0400 Committer: Josh Elser els...@apache.org Committed: Fri May 23 20:24:18 2014 -0400 -- .../accumulo/monitor/servlets/ShellServlet.java | 43 +++- 1 file changed, 33 insertions(+), 10 deletions(-) -- http://git-wip-us.apache.org/repos/asf/accumulo/blob/eb6b3253/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/ShellServlet.java -- diff --cc server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/ShellServlet.java index 03f6831,000..665b132 mode 100644,00..100644 --- a/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/ShellServlet.java +++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/ShellServlet.java @@@ -1,333 -1,0 +1,356 @@@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the License); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.accumulo.monitor.servlets; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.io.PrintWriter; +import java.util.HashMap; +import java.util.Map; ++import java.util.UUID; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import jline.console.ConsoleReader; + +import org.apache.accumulo.core.Constants; +import org.apache.accumulo.core.util.shell.Shell; + +public class ShellServlet extends BasicServlet { + private static final long serialVersionUID = 1L; + private MapString,ShellExecutionThread userShells = new HashMapString,ShellExecutionThread(); + private ExecutorService service = Executors.newCachedThreadPool(); - ++ ++ public static final String CSRF_KEY = csrf_token; ++ + @Override + protected String getTitle(HttpServletRequest req) { +return Shell; + } + + @Override + protected void pageBody(HttpServletRequest req, HttpServletResponse response, StringBuilder sb) throws IOException { +HttpSession session = req.getSession(true); ++final String CSRF_TOKEN; ++if (null == session.getAttribute(CSRF_KEY)) { ++ // No token, make one ++ CSRF_TOKEN = UUID.randomUUID().toString(); ++ session.setAttribute(CSRF_KEY, CSRF_TOKEN); ++} else { ++ // Pull the token out of the session ++ CSRF_TOKEN = (String) session.getAttribute(CSRF_KEY); ++ if (null == CSRF_TOKEN) { ++throw new RuntimeException(No valid CSRF token exists in session); ++ } ++} ++ +String user = (String) session.getAttribute(user); +if (user == null) { + // user attribute is null, check to see if username and password are passed as parameters + user = req.getParameter(user); + String pass = req.getParameter(pass); + String mock = req.getParameter(mock); + if (user == null || pass == null) { +// username or password are null, re-authenticate - sb.append(authenticationForm(req.getRequestURI())); ++sb.append(authenticationForm(req.getRequestURI(), CSRF_TOKEN)); +return; + } + try { +// get a new shell for this user +ShellExecutionThread shellThread = new ShellExecutionThread(user, pass, mock); +service.submit(shellThread); +userShells.put(session.getId(), shellThread); + }