You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by vi...@apache.org on 2013/03/05 00:45:48 UTC
svn commit: r1452601 - in /accumulo/branches/1.5:
core/src/main/java/org/apache/accumulo/core/cli/
core/src/main/java/org/apache/accumulo/core/client/
core/src/main/java/org/apache/accumulo/core/client/impl/
core/src/main/java/org/apache/accumulo/core/...
Author: vines
Date: Mon Mar 4 23:45:46 2013
New Revision: 1452601
URL: http://svn.apache.org/r1452601
Log:
ACCUMULO-1041 ACCUMULO-1129 - purging instance.getConnector(Credential)
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/Instance.java
accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/client/ZooKeeperInstance.java
accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/client/impl/OfflineScanner.java
accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/util/InputConfigurator.java
accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/client/mock/MockInstance.java
accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java
accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/PasswdCommand.java
accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/TraceCommand.java
accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/UserCommand.java
accumulo/branches/1.5/core/src/test/java/org/apache/accumulo/core/client/impl/TabletLocatorImplTest.java
accumulo/branches/1.5/core/src/test/java/org/apache/accumulo/core/client/mock/MockTableOperationsTest.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/client/HdfsZooInstance.java
accumulo/branches/1.5/server/src/main/java/org/apache/accumulo/server/master/balancer/TableLoadBalancer.java
accumulo/branches/1.5/server/src/main/java/org/apache/accumulo/server/problems/ProblemReports.java
accumulo/branches/1.5/server/src/main/java/org/apache/accumulo/server/security/SecurityConstants.java
accumulo/branches/1.5/server/src/main/java/org/apache/accumulo/server/util/Admin.java
accumulo/branches/1.5/server/src/main/java/org/apache/accumulo/server/util/CheckForMetadataProblems.java
accumulo/branches/1.5/server/src/main/java/org/apache/accumulo/server/util/FindOfflineTablets.java
accumulo/branches/1.5/server/src/main/java/org/apache/accumulo/server/util/VerifyTabletAssignments.java
accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/QueryMetadataTable.java
accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/WrongTabletTest.java
accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/performance/scan/CollectTabletStats.java
accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/State.java
accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/security/AlterTable.java
accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/security/AlterTablePerm.java
accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/security/Authenticate.java
accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/security/ChangePass.java
accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/security/CreateTable.java
accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/security/CreateUser.java
accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/security/DropTable.java
accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/security/DropUser.java
accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/security/SetAuths.java
accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/security/TableOp.java
accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/security/Validate.java
accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/security/WalkingSecurity.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=1452601&r1=1452600&r2=1452601&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 Mon Mar 4 23:45:46 2013
@@ -39,8 +39,6 @@ import org.apache.accumulo.core.conf.Def
import org.apache.accumulo.core.conf.Property;
import org.apache.accumulo.core.security.Authorizations;
import org.apache.accumulo.core.security.ColumnVisibility;
-import org.apache.accumulo.core.security.CredentialHelper;
-import org.apache.accumulo.core.security.thrift.TCredentials;
import org.apache.accumulo.trace.instrument.Trace;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
@@ -204,13 +202,9 @@ public class ClientOpts extends Help {
}
public Connector getConnector() throws AccumuloException, AccumuloSecurityException {
- return getInstance().getConnector(getCredentials());
- }
-
- public TCredentials getCredentials() throws AccumuloSecurityException {
if (this.principal == null || this.getToken() == null)
throw new AccumuloSecurityException("You must provide a user (-u) and password (-p)", SecurityErrorCode.BAD_CREDENTIALS);
- return CredentialHelper.create(principal, getToken(), getInstance().getInstanceID());
+ return getInstance().getConnector(principal, getToken());
}
public void setAccumuloConfigs(Job job) throws AccumuloSecurityException {
Modified: accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/client/Instance.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/client/Instance.java?rev=1452601&r1=1452600&r2=1452601&view=diff
==============================================================================
--- accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/client/Instance.java (original)
+++ accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/client/Instance.java Mon Mar 4 23:45:46 2013
@@ -23,7 +23,6 @@ import java.util.Properties;
import org.apache.accumulo.core.client.security.tokens.AuthenticationToken;
import org.apache.accumulo.core.conf.AccumuloConfiguration;
import org.apache.accumulo.core.security.handler.Authenticator;
-import org.apache.accumulo.core.security.thrift.TCredentials;
/**
* This class represents the information a client needs to know to connect to an instance of accumulo.
@@ -170,13 +169,6 @@ public interface Instance {
Connector getConnector(String principal, AuthenticationToken token) throws AccumuloException, AccumuloSecurityException;
/**
- * @param auth
- * @throws AccumuloException
- * @throws AccumuloSecurityException
- */
- Connector getConnector(TCredentials auth) throws AccumuloException, AccumuloSecurityException;
-
- /**
* @param principal
* The principal the authentication token corresponds to
* @param props
Modified: accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/client/ZooKeeperInstance.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/client/ZooKeeperInstance.java?rev=1452601&r1=1452600&r2=1452601&view=diff
==============================================================================
--- accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/client/ZooKeeperInstance.java (original)
+++ accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/client/ZooKeeperInstance.java Mon Mar 4 23:45:46 2013
@@ -229,9 +229,8 @@ public class ZooKeeperInstance implement
return getConnector(CredentialHelper.create(principal, token, getInstanceID()));
}
- @Override
- @Deprecated
- public Connector getConnector(TCredentials credential) throws AccumuloException, AccumuloSecurityException {
+ @SuppressWarnings("deprecation")
+ private Connector getConnector(TCredentials credential) throws AccumuloException, AccumuloSecurityException {
return new ConnectorImpl(this, credential);
}
Modified: accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/client/impl/OfflineScanner.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/client/impl/OfflineScanner.java?rev=1452601&r1=1452600&r2=1452601&view=diff
==============================================================================
--- accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/client/impl/OfflineScanner.java (original)
+++ accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/client/impl/OfflineScanner.java Mon Mar 4 23:45:46 2013
@@ -55,6 +55,7 @@ import org.apache.accumulo.core.iterator
import org.apache.accumulo.core.master.state.tables.TableState;
import org.apache.accumulo.core.security.Authorizations;
import org.apache.accumulo.core.security.ColumnVisibility;
+import org.apache.accumulo.core.security.CredentialHelper;
import org.apache.accumulo.core.security.thrift.TCredentials;
import org.apache.accumulo.core.util.ArgumentChecker;
import org.apache.accumulo.core.util.CachedConfiguration;
@@ -135,7 +136,7 @@ class OfflineIterator implements Iterato
this.readers = new ArrayList<SortedKeyValueIterator<Key,Value>>();
try {
- conn = instance.getConnector(credentials);
+ conn = instance.getConnector(credentials.getPrincipal(), CredentialHelper.extractToken(credentials));
nextTablet();
while (iter != null && !iter.hasTop())
Modified: accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/util/InputConfigurator.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/util/InputConfigurator.java?rev=1452601&r1=1452600&r2=1452601&view=diff
==============================================================================
--- accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/util/InputConfigurator.java (original)
+++ accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/util/InputConfigurator.java Mon Mar 4 23:45:46 2013
@@ -510,9 +510,7 @@ public class InputConfigurator extends C
throw new IOException("Instance info has not been set.");
// validate that we can connect as configured
try {
- Connector c = getInstance(implementingClass, conf).getConnector(
- new TCredentials(getPrincipal(implementingClass, conf), getTokenClass(implementingClass, conf), ByteBuffer.wrap(getToken(implementingClass, conf)),
- getInstance(implementingClass, conf).getInstanceID()));
+ Connector c = getInstance(implementingClass, conf).getConnector(getPrincipal(implementingClass, conf), CredentialHelper.extractToken(getTokenClass(implementingClass, conf), getToken(implementingClass, conf)));
if (!c.securityOperations().authenticateUser(getPrincipal(implementingClass, conf), CredentialHelper.extractToken(getTokenClass(implementingClass, conf), getToken(implementingClass, conf))))
throw new IOException("Unable to authenticate user");
if (!c.securityOperations().hasTablePermission(getPrincipal(implementingClass, conf), getInputTableName(implementingClass, conf), TablePermission.READ))
Modified: accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/client/mock/MockInstance.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/client/mock/MockInstance.java?rev=1452601&r1=1452600&r2=1452601&view=diff
==============================================================================
--- accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/client/mock/MockInstance.java (original)
+++ accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/client/mock/MockInstance.java Mon Mar 4 23:45:46 2013
@@ -32,10 +32,8 @@ import org.apache.accumulo.core.client.i
import org.apache.accumulo.core.client.security.tokens.AuthenticationToken;
import org.apache.accumulo.core.client.security.tokens.PasswordToken;
import org.apache.accumulo.core.conf.AccumuloConfiguration;
-import org.apache.accumulo.core.security.CredentialHelper;
import org.apache.accumulo.core.security.handler.Authenticator;
import org.apache.accumulo.core.security.handler.ZKAuthenticator;
-import org.apache.accumulo.core.security.thrift.TCredentials;
import org.apache.accumulo.core.util.ByteBufferUtil;
import org.apache.accumulo.core.util.CachedConfiguration;
import org.apache.accumulo.core.util.TextUtil;
@@ -171,15 +169,10 @@ public class MockInstance implements Ins
}
@Override
- public Connector getConnector(TCredentials credential) throws AccumuloException, AccumuloSecurityException {
- return getConnector(credential.principal, CredentialHelper.extractToken(credential));
- }
-
- @Override
public Connector getConnector(String principal, Properties props) throws AccumuloException, AccumuloSecurityException {
return getConnector(principal, getAuthenticator().login(props));
}
-
+
@Override
public Authenticator getAuthenticator() throws AccumuloException, AccumuloSecurityException {
return new ZKAuthenticator();
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=1452601&r1=1452600&r2=1452601&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 Mon Mar 4 23:45:46 2013
@@ -46,6 +46,7 @@ import org.apache.accumulo.core.client.I
import org.apache.accumulo.core.client.TableNotFoundException;
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.PasswordToken;
import org.apache.accumulo.core.conf.AccumuloConfiguration;
import org.apache.accumulo.core.conf.Property;
@@ -53,8 +54,6 @@ import org.apache.accumulo.core.data.Key
import org.apache.accumulo.core.data.Value;
import org.apache.accumulo.core.data.thrift.TConstraintViolationSummary;
import org.apache.accumulo.core.security.AuditLevel;
-import org.apache.accumulo.core.security.CredentialHelper;
-import org.apache.accumulo.core.security.thrift.TCredentials;
import org.apache.accumulo.core.tabletserver.thrift.ConstraintViolationException;
import org.apache.accumulo.core.trace.DistributedTrace;
import org.apache.accumulo.core.util.BadArgumentException;
@@ -169,7 +168,8 @@ public class Shell extends ShellOptions
protected Instance instance;
private Connector connector;
protected ConsoleReader reader;
- private TCredentials credentials;
+ private String principal;
+ private AuthenticationToken token;
private final Class<? extends Formatter> defaultFormatterClass = DefaultFormatter.class;
private final Class<? extends Formatter> binaryFormatterClass = BinaryFormatter.class;
public Map<String,List<IteratorSetting>> scanIteratorOptions = new HashMap<String,List<IteratorSetting>>();
@@ -277,8 +277,9 @@ public class Shell extends ShellOptions
pass = passw.getBytes();
this.setTableName("");
- connector = instance.getConnector(user, pass);
- this.credentials = CredentialHelper.create(user, new PasswordToken(pass), connector.getInstance().getInstanceID());
+ this.principal = user;
+ this.token = new PasswordToken(pass);
+ connector = instance.getConnector(principal, token);
} catch (Exception e) {
printException(e);
@@ -941,15 +942,21 @@ public class Shell extends ShellOptions
return reader;
}
- public void updateUser(TCredentials authInfo) throws AccumuloException, AccumuloSecurityException {
- connector = instance.getConnector(authInfo);
- credentials = authInfo;
+ public void updateUser(String principal, AuthenticationToken token) throws AccumuloException, AccumuloSecurityException {
+ connector = instance.getConnector(principal, token);
+ this.principal = principal;
+ this.token = token;
}
- public TCredentials getCredentials() {
- return credentials;
+ public String getPrincipal() {
+ return principal;
}
+ public AuthenticationToken getToken() {
+ return token;
+ }
+
+
/**
* Return the formatter for the current table.
*
Modified: accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/PasswdCommand.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/PasswdCommand.java?rev=1452601&r1=1452600&r2=1452601&view=diff
==============================================================================
--- accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/PasswdCommand.java (original)
+++ accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/PasswdCommand.java Mon Mar 4 23:45:46 2013
@@ -22,7 +22,6 @@ import org.apache.accumulo.core.client.A
import org.apache.accumulo.core.client.AccumuloSecurityException;
import org.apache.accumulo.core.client.impl.thrift.SecurityErrorCode;
import org.apache.accumulo.core.client.security.tokens.PasswordToken;
-import org.apache.accumulo.core.security.CredentialHelper;
import org.apache.accumulo.core.util.shell.Shell;
import org.apache.accumulo.core.util.shell.Shell.Command;
import org.apache.commons.cli.CommandLine;
@@ -69,7 +68,7 @@ public class PasswdCommand extends Comma
// update the current credentials if the password changed was for
// the current user
if (shellState.getConnector().whoami().equals(user)) {
- shellState.updateUser(CredentialHelper.create(user, new PasswordToken(pass), shellState.getConnector().getInstance().getInstanceID()));
+ shellState.updateUser(user, new PasswordToken(pass));
}
Shell.log.debug("Changed password for user " + user);
return 0;
Modified: accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/TraceCommand.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/TraceCommand.java?rev=1452601&r1=1452600&r2=1452601&view=diff
==============================================================================
--- accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/TraceCommand.java (original)
+++ accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/TraceCommand.java Mon Mar 4 23:45:46 2013
@@ -37,7 +37,7 @@ public class TraceCommand extends DebugC
public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws IOException {
if (cl.getArgs().length == 1) {
if (cl.getArgs()[0].equalsIgnoreCase("on")) {
- Trace.on("shell:" + shellState.getCredentials().getPrincipal());
+ Trace.on("shell:" + shellState.getPrincipal());
} else if (cl.getArgs()[0].equalsIgnoreCase("off")) {
if (Trace.isTracing()) {
final long trace = Trace.currentTrace().traceId();
Modified: accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/UserCommand.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/UserCommand.java?rev=1452601&r1=1452600&r2=1452601&view=diff
==============================================================================
--- accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/UserCommand.java (original)
+++ accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/UserCommand.java Mon Mar 4 23:45:46 2013
@@ -23,7 +23,6 @@ import java.util.Set;
import org.apache.accumulo.core.client.AccumuloException;
import org.apache.accumulo.core.client.AccumuloSecurityException;
import org.apache.accumulo.core.client.security.tokens.PasswordToken;
-import org.apache.accumulo.core.security.CredentialHelper;
import org.apache.accumulo.core.util.shell.Shell;
import org.apache.accumulo.core.util.shell.Shell.Command;
import org.apache.accumulo.core.util.shell.Token;
@@ -45,7 +44,7 @@ public class UserCommand extends Command
return 0;
} // user canceled
pass = p.getBytes();
- shellState.updateUser(CredentialHelper.create(user, new PasswordToken(pass), shellState.getConnector().getInstance().getInstanceID()));
+ shellState.updateUser(user, new PasswordToken(pass));
return 0;
}
Modified: accumulo/branches/1.5/core/src/test/java/org/apache/accumulo/core/client/impl/TabletLocatorImplTest.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/core/src/test/java/org/apache/accumulo/core/client/impl/TabletLocatorImplTest.java?rev=1452601&r1=1452600&r2=1452601&view=diff
==============================================================================
--- accumulo/branches/1.5/core/src/test/java/org/apache/accumulo/core/client/impl/TabletLocatorImplTest.java (original)
+++ accumulo/branches/1.5/core/src/test/java/org/apache/accumulo/core/client/impl/TabletLocatorImplTest.java Mon Mar 4 23:45:46 2013
@@ -50,7 +50,6 @@ import org.apache.accumulo.core.data.Par
import org.apache.accumulo.core.data.Range;
import org.apache.accumulo.core.data.Value;
import org.apache.accumulo.core.security.handler.Authenticator;
-import org.apache.accumulo.core.security.thrift.TCredentials;
import org.apache.accumulo.core.util.MetadataTable;
import org.apache.accumulo.core.util.Pair;
import org.apache.hadoop.io.Text;
@@ -450,11 +449,6 @@ public class TabletLocatorImplTest exten
throw new UnsupportedOperationException();
}
- @Override
- public Connector getConnector(TCredentials auth) throws AccumuloException, AccumuloSecurityException {
- return getConnector(auth.getPrincipal(), auth.getToken());
- }
-
@Deprecated
@Override
public Connector getConnector(org.apache.accumulo.core.security.thrift.AuthInfo auth) throws AccumuloException, AccumuloSecurityException {
Modified: accumulo/branches/1.5/core/src/test/java/org/apache/accumulo/core/client/mock/MockTableOperationsTest.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/core/src/test/java/org/apache/accumulo/core/client/mock/MockTableOperationsTest.java?rev=1452601&r1=1452600&r2=1452601&view=diff
==============================================================================
--- accumulo/branches/1.5/core/src/test/java/org/apache/accumulo/core/client/mock/MockTableOperationsTest.java (original)
+++ accumulo/branches/1.5/core/src/test/java/org/apache/accumulo/core/client/mock/MockTableOperationsTest.java Mon Mar 4 23:45:46 2013
@@ -53,7 +53,6 @@ import org.apache.accumulo.core.iterator
import org.apache.accumulo.core.iterators.user.VersioningIterator;
import org.apache.accumulo.core.security.Authorizations;
import org.apache.accumulo.core.security.ColumnVisibility;
-import org.apache.accumulo.core.security.CredentialHelper;
import org.apache.accumulo.core.util.Pair;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
@@ -67,7 +66,7 @@ public class MockTableOperationsTest {
@Test
public void testCreateUseVersions() throws AccumuloException, AccumuloSecurityException, TableExistsException, TableNotFoundException {
Instance instance = new MockInstance("topstest");
- Connector conn = instance.getConnector("user", "pass");
+ Connector conn = instance.getConnector("user", new PasswordToken("pass"));
String t = "tableName1";
{
@@ -128,7 +127,7 @@ public class MockTableOperationsTest {
@Test
public void testTableNotFound() throws AccumuloException, AccumuloSecurityException, TableExistsException, TableNotFoundException {
Instance instance = new MockInstance("topstest");
- Connector conn = instance.getConnector("user", "pass");
+ Connector conn = instance.getConnector("user", new PasswordToken("pass"));
String t = "tableName";
try {
conn.tableOperations().attachIterator(t, null);
@@ -187,7 +186,7 @@ public class MockTableOperationsTest {
public void testImport() throws Throwable {
ImportTestFilesAndData dataAndFiles = prepareTestFiles();
Instance instance = new MockInstance("foo");
- Connector connector = instance.getConnector(CredentialHelper.create("user", new PasswordToken(new byte[0]), "foo"));
+ Connector connector = instance.getConnector("user", new PasswordToken(new byte[0]));
TableOperations tableOperations = connector.tableOperations();
tableOperations.create("a_table");
tableOperations.importDirectory("a_table", dataAndFiles.importPath.toString(), dataAndFiles.failurePath.toString(), false);
@@ -234,7 +233,7 @@ public class MockTableOperationsTest {
@Test(expected = TableNotFoundException.class)
public void testFailsWithNoTable() throws Throwable {
Instance instance = new MockInstance("foo");
- Connector connector = instance.getConnector(CredentialHelper.create("user", new PasswordToken(new byte[0]), "foo"));
+ Connector connector = instance.getConnector("user", new PasswordToken(new byte[0]));
TableOperations tableOperations = connector.tableOperations();
ImportTestFilesAndData testFiles = prepareTestFiles();
tableOperations.importDirectory("doesnt_exist_table", testFiles.importPath.toString(), testFiles.failurePath.toString(), false);
@@ -243,7 +242,7 @@ public class MockTableOperationsTest {
@Test(expected = IOException.class)
public void testFailsWithNonEmptyFailureDirectory() throws Throwable {
Instance instance = new MockInstance("foo");
- Connector connector = instance.getConnector(CredentialHelper.create("user", new PasswordToken(new byte[0]), "foo"));
+ Connector connector = instance.getConnector("user", new PasswordToken(new byte[0]));
TableOperations tableOperations = connector.tableOperations();
ImportTestFilesAndData testFiles = prepareTestFiles();
FileSystem fs = testFiles.failurePath.getFileSystem(new Configuration());
@@ -254,7 +253,7 @@ public class MockTableOperationsTest {
@Test
public void testDeleteRows() throws Exception {
Instance instance = new MockInstance("rows");
- Connector connector = instance.getConnector("user", "foo");
+ Connector connector = instance.getConnector("user", new PasswordToken("foo".getBytes()));
TableOperations to = connector.tableOperations();
to.create("test");
BatchWriter bw = connector.createBatchWriter("test", new BatchWriterConfig());
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=1452601&r1=1452600&r2=1452601&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 Mon Mar 4 23:45:46 2013
@@ -154,7 +154,7 @@ public class ProxyServer implements Accu
TCredentials user = tokenCache.getIfPresent(login);
if (user == null)
throw new org.apache.accumulo.proxy.thrift.AccumuloSecurityException("unknown user");
- Connector connector = instance.getConnector(user);
+ Connector connector = instance.getConnector(user.getPrincipal(), CredentialHelper.extractToken(user));
return connector;
}
Modified: accumulo/branches/1.5/server/src/main/java/org/apache/accumulo/server/client/HdfsZooInstance.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/server/src/main/java/org/apache/accumulo/server/client/HdfsZooInstance.java?rev=1452601&r1=1452600&r2=1452601&view=diff
==============================================================================
--- accumulo/branches/1.5/server/src/main/java/org/apache/accumulo/server/client/HdfsZooInstance.java (original)
+++ accumulo/branches/1.5/server/src/main/java/org/apache/accumulo/server/client/HdfsZooInstance.java Mon Mar 4 23:45:46 2013
@@ -157,9 +157,8 @@ public class HdfsZooInstance implements
return getConnector(CredentialHelper.create(principal, token, getInstanceID()));
}
- @Override
- @Deprecated
- public Connector getConnector(TCredentials cred) throws AccumuloException, AccumuloSecurityException {
+ @SuppressWarnings("deprecation")
+ private Connector getConnector(TCredentials cred) throws AccumuloException, AccumuloSecurityException {
return new ConnectorImpl(this, cred);
}
Modified: accumulo/branches/1.5/server/src/main/java/org/apache/accumulo/server/master/balancer/TableLoadBalancer.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/server/src/main/java/org/apache/accumulo/server/master/balancer/TableLoadBalancer.java?rev=1452601&r1=1452600&r2=1452601&view=diff
==============================================================================
--- accumulo/branches/1.5/server/src/main/java/org/apache/accumulo/server/master/balancer/TableLoadBalancer.java (original)
+++ accumulo/branches/1.5/server/src/main/java/org/apache/accumulo/server/master/balancer/TableLoadBalancer.java Mon Mar 4 23:45:46 2013
@@ -119,7 +119,7 @@ public class TableLoadBalancer extends T
protected TableOperations getTableOperations() {
if (tops == null)
try {
- tops = configuration.getInstance().getConnector(SecurityConstants.getSystemCredentials()).tableOperations();
+ tops = configuration.getInstance().getConnector(SecurityConstants.getSystemPrincipal(), SecurityConstants.getSystemToken()).tableOperations();
} catch (AccumuloException e) {
log.error("Unable to access table operations from within table balancer", e);
} catch (AccumuloSecurityException e) {
Modified: accumulo/branches/1.5/server/src/main/java/org/apache/accumulo/server/problems/ProblemReports.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/server/src/main/java/org/apache/accumulo/server/problems/ProblemReports.java?rev=1452601&r1=1452600&r2=1452601&view=diff
==============================================================================
--- accumulo/branches/1.5/server/src/main/java/org/apache/accumulo/server/problems/ProblemReports.java (original)
+++ accumulo/branches/1.5/server/src/main/java/org/apache/accumulo/server/problems/ProblemReports.java Mon Mar 4 23:45:46 2013
@@ -152,7 +152,7 @@ public class ProblemReports implements I
return;
}
- Connector connector = HdfsZooInstance.getInstance().getConnector(SecurityConstants.getSystemCredentials());
+ Connector connector = HdfsZooInstance.getInstance().getConnector(SecurityConstants.getSystemPrincipal(), SecurityConstants.getSystemToken());
Scanner scanner = connector.createScanner(Constants.METADATA_TABLE_NAME, Constants.NO_AUTHS);
scanner.addScanIterator(new IteratorSetting(1, "keys-only", SortedKeyIterator.class));
@@ -207,7 +207,7 @@ public class ProblemReports implements I
if (iter2 == null) {
try {
if ((table == null || !table.equals(Constants.METADATA_TABLE_ID)) && iter1Count == 0) {
- Connector connector = HdfsZooInstance.getInstance().getConnector(SecurityConstants.getSystemCredentials());
+ Connector connector = HdfsZooInstance.getInstance().getConnector(SecurityConstants.getSystemPrincipal(), SecurityConstants.getSystemToken());
Scanner scanner = connector.createScanner(Constants.METADATA_TABLE_NAME, Constants.NO_AUTHS);
scanner.setTimeout(3, TimeUnit.SECONDS);
Modified: accumulo/branches/1.5/server/src/main/java/org/apache/accumulo/server/security/SecurityConstants.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/server/src/main/java/org/apache/accumulo/server/security/SecurityConstants.java?rev=1452601&r1=1452600&r2=1452601&view=diff
==============================================================================
--- accumulo/branches/1.5/server/src/main/java/org/apache/accumulo/server/security/SecurityConstants.java (original)
+++ accumulo/branches/1.5/server/src/main/java/org/apache/accumulo/server/security/SecurityConstants.java Mon Mar 4 23:45:46 2013
@@ -57,6 +57,10 @@ public class SecurityConstants {
return systemCredentials;
}
+ public static String getSystemPrincipal() {
+ return SYSTEM_PRINCIPAL;
+ }
+
private static AuthenticationToken makeSystemPassword() {
int wireVersion = Constants.WIRE_VERSION;
byte[] inst = HdfsZooInstance.getInstance().getInstanceID().getBytes(Constants.UTF8);
Modified: accumulo/branches/1.5/server/src/main/java/org/apache/accumulo/server/util/Admin.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/server/src/main/java/org/apache/accumulo/server/util/Admin.java?rev=1452601&r1=1452600&r2=1452601&view=diff
==============================================================================
--- accumulo/branches/1.5/server/src/main/java/org/apache/accumulo/server/util/Admin.java (original)
+++ accumulo/branches/1.5/server/src/main/java/org/apache/accumulo/server/util/Admin.java Mon Mar 4 23:45:46 2013
@@ -25,8 +25,10 @@ import org.apache.accumulo.core.client.A
import org.apache.accumulo.core.client.Instance;
import org.apache.accumulo.core.client.impl.ClientExec;
import org.apache.accumulo.core.client.impl.MasterClient;
+import org.apache.accumulo.core.client.security.tokens.AuthenticationToken;
import org.apache.accumulo.core.conf.Property;
import org.apache.accumulo.core.master.thrift.MasterClientService;
+import org.apache.accumulo.core.security.CredentialHelper;
import org.apache.accumulo.core.security.thrift.TCredentials;
import org.apache.accumulo.server.cli.ClientOpts;
import org.apache.accumulo.server.client.HdfsZooInstance;
@@ -81,18 +83,21 @@ public class Admin {
Instance instance = opts.getInstance();
try {
- TCredentials creds;
+ String principal;
+ AuthenticationToken token;
if (opts.getToken() == null) {
- creds = SecurityConstants.getSystemCredentials();
+ principal = SecurityConstants.getSystemPrincipal();
+ token = SecurityConstants.getSystemToken();
} else {
- creds = opts.getCredentials();
+ principal = opts.principal;
+ token = opts.getToken();
}
if (cl.getParsedCommand().equals("stop")) {
- stopTabletServer(instance, creds, stopOpts.args, opts.force);
+ stopTabletServer(instance, CredentialHelper.create(principal, token, instance.getInstanceID()), stopOpts.args, opts.force);
} else {
everything = cl.getParsedCommand().equals("stopAll");
- stopServer(instance, creds, everything);
+ stopServer(instance, CredentialHelper.create(principal, token, instance.getInstanceID()), everything);
}
} catch (AccumuloException e) {
log.error(e,e);
Modified: accumulo/branches/1.5/server/src/main/java/org/apache/accumulo/server/util/CheckForMetadataProblems.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/server/src/main/java/org/apache/accumulo/server/util/CheckForMetadataProblems.java?rev=1452601&r1=1452600&r2=1452601&view=diff
==============================================================================
--- accumulo/branches/1.5/server/src/main/java/org/apache/accumulo/server/util/CheckForMetadataProblems.java (original)
+++ accumulo/branches/1.5/server/src/main/java/org/apache/accumulo/server/util/CheckForMetadataProblems.java Mon Mar 4 23:45:46 2013
@@ -32,6 +32,7 @@ import org.apache.accumulo.core.data.Key
import org.apache.accumulo.core.data.KeyExtent;
import org.apache.accumulo.core.data.Mutation;
import org.apache.accumulo.core.data.Value;
+import org.apache.accumulo.core.security.CredentialHelper;
import org.apache.accumulo.core.tabletserver.thrift.ConstraintViolationException;
import org.apache.accumulo.core.util.CachedConfiguration;
import org.apache.accumulo.server.conf.ServerConfiguration;
@@ -84,7 +85,7 @@ public class CheckForMetadataProblems {
if (broke && opts.fix) {
KeyExtent ke = new KeyExtent(tabke);
ke.setPrevEndRow(lastEndRow);
- MetadataTable.updateTabletPrevEndRow(ke, opts.getCredentials());
+ MetadataTable.updateTabletPrevEndRow(ke, CredentialHelper.create(opts.principal, opts.getToken(), opts.instance));
System.out.println("KE " + tabke + " has been repaired to " + ke);
}
@@ -148,7 +149,7 @@ public class CheckForMetadataProblems {
System.out.println("Problem at key " + entry.getKey());
sawProblems = true;
if (opts.fix) {
- Writer t = MetadataTable.getMetadataTable(opts.getCredentials());
+ Writer t = MetadataTable.getMetadataTable(CredentialHelper.create(opts.principal, opts.getToken(), opts.instance));
Key k = entry.getKey();
Mutation m = new Mutation(k.getRow());
m.putDelete(k.getColumnFamily(), k.getColumnQualifier());
Modified: accumulo/branches/1.5/server/src/main/java/org/apache/accumulo/server/util/FindOfflineTablets.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/server/src/main/java/org/apache/accumulo/server/util/FindOfflineTablets.java?rev=1452601&r1=1452600&r2=1452601&view=diff
==============================================================================
--- accumulo/branches/1.5/server/src/main/java/org/apache/accumulo/server/util/FindOfflineTablets.java (original)
+++ accumulo/branches/1.5/server/src/main/java/org/apache/accumulo/server/util/FindOfflineTablets.java Mon Mar 4 23:45:46 2013
@@ -24,6 +24,7 @@ import org.apache.accumulo.core.client.I
import org.apache.accumulo.core.conf.DefaultConfiguration;
import org.apache.accumulo.core.data.Range;
import org.apache.accumulo.core.master.state.tables.TableState;
+import org.apache.accumulo.core.security.CredentialHelper;
import org.apache.accumulo.server.cli.ClientOpts;
import org.apache.accumulo.server.master.LiveTServerSet;
import org.apache.accumulo.server.master.LiveTServerSet.Listener;
@@ -43,9 +44,9 @@ public class FindOfflineTablets {
public static void main(String[] args) throws Exception {
ClientOpts opts = new ClientOpts();
opts.parseArgs(FindOfflineTablets.class.getName(), args);
- final AtomicBoolean scanning = new AtomicBoolean(false);
+ final AtomicBoolean scanning = new AtomicBoolean(false);
Instance instance = opts.getInstance();
- MetaDataTableScanner scanner = new MetaDataTableScanner(instance, opts.getCredentials(), new Range());
+ MetaDataTableScanner scanner = new MetaDataTableScanner(instance, CredentialHelper.create(opts.principal, opts.getToken(), opts.instance), new Range());
LiveTServerSet tservers = new LiveTServerSet(instance, DefaultConfiguration.getDefaultConfiguration(), new Listener() {
@Override
public void update(LiveTServerSet current, Set<TServerInstance> deleted, Set<TServerInstance> added) {
Modified: accumulo/branches/1.5/server/src/main/java/org/apache/accumulo/server/util/VerifyTabletAssignments.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/server/src/main/java/org/apache/accumulo/server/util/VerifyTabletAssignments.java?rev=1452601&r1=1452600&r2=1452601&view=diff
==============================================================================
--- accumulo/branches/1.5/server/src/main/java/org/apache/accumulo/server/util/VerifyTabletAssignments.java (original)
+++ accumulo/branches/1.5/server/src/main/java/org/apache/accumulo/server/util/VerifyTabletAssignments.java Mon Mar 4 23:45:46 2013
@@ -45,6 +45,7 @@ import org.apache.accumulo.core.data.thr
import org.apache.accumulo.core.data.thrift.TColumn;
import org.apache.accumulo.core.data.thrift.TKeyExtent;
import org.apache.accumulo.core.data.thrift.TRange;
+import org.apache.accumulo.core.security.CredentialHelper;
import org.apache.accumulo.core.security.thrift.TCredentials;
import org.apache.accumulo.core.tabletserver.thrift.NoSuchScanIDException;
import org.apache.accumulo.core.tabletserver.thrift.TabletClientService;
@@ -89,7 +90,7 @@ public class VerifyTabletAssignments {
Connector conn = opts.getConnector();
Instance inst = conn.getInstance();
- MetadataTable.getEntries(conn.getInstance(), opts.getCredentials(), tableName, false,
+ MetadataTable.getEntries(conn.getInstance(), CredentialHelper.create(opts.principal, opts.getToken(), opts.instance), tableName, false,
locations, tablets);
final HashSet<KeyExtent> failures = new HashSet<KeyExtent>();
@@ -121,7 +122,7 @@ public class VerifyTabletAssignments {
@Override
public void run() {
try {
- checkTabletServer(conf.getConfiguration(), opts.getCredentials(), entry, failures);
+ checkTabletServer(conf.getConfiguration(), CredentialHelper.create(opts.principal, opts.getToken(), opts.instance), entry, failures);
} catch (Exception e) {
System.err.println("Failure on ts " + entry.getKey() + " " + e.getMessage());
e.printStackTrace();
Modified: accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/QueryMetadataTable.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/QueryMetadataTable.java?rev=1452601&r1=1452600&r2=1452601&view=diff
==============================================================================
--- accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/QueryMetadataTable.java (original)
+++ accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/QueryMetadataTable.java Mon Mar 4 23:45:46 2013
@@ -31,11 +31,11 @@ import org.apache.accumulo.core.client.A
import org.apache.accumulo.core.client.Connector;
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.data.Key;
import org.apache.accumulo.core.data.KeyExtent;
import org.apache.accumulo.core.data.Range;
import org.apache.accumulo.core.data.Value;
-import org.apache.accumulo.core.security.thrift.TCredentials;
import org.apache.accumulo.server.cli.ClientOpts;
import org.apache.accumulo.server.client.HdfsZooInstance;
import org.apache.hadoop.io.Text;
@@ -43,7 +43,8 @@ import org.apache.hadoop.io.Text;
import com.beust.jcommander.Parameter;
public class QueryMetadataTable {
- private static TCredentials credentials;
+ private static String principal;
+ private static AuthenticationToken token;
static String location;
@@ -58,7 +59,7 @@ public class QueryMetadataTable {
try {
KeyExtent extent = new KeyExtent(row, (Text) null);
- Connector connector = HdfsZooInstance.getInstance().getConnector(credentials);
+ Connector connector = HdfsZooInstance.getInstance().getConnector(principal, token);
Scanner mdScanner = connector.createScanner(Constants.METADATA_TABLE_NAME, Constants.NO_AUTHS);
Text row = extent.getMetadataEntry();
Modified: accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/WrongTabletTest.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/WrongTabletTest.java?rev=1452601&r1=1452600&r2=1452601&view=diff
==============================================================================
--- accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/WrongTabletTest.java (original)
+++ accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/WrongTabletTest.java Mon Mar 4 23:45:46 2013
@@ -20,6 +20,7 @@ import org.apache.accumulo.trace.instrum
import org.apache.accumulo.server.cli.ClientOpts;
import org.apache.accumulo.core.data.KeyExtent;
import org.apache.accumulo.core.data.Mutation;
+import org.apache.accumulo.core.security.CredentialHelper;
import org.apache.accumulo.core.tabletserver.thrift.TabletClientService;
import org.apache.accumulo.core.util.ThriftUtil;
import org.apache.accumulo.server.conf.ServerConfiguration;
@@ -44,7 +45,7 @@ public class WrongTabletTest {
Mutation mutation = new Mutation(new Text("row_0003750001"));
mutation.putDelete(new Text("colf"), new Text("colq"));
- client.update(Tracer.traceInfo(), opts.getCredentials(), new KeyExtent(new Text("!!"), null, new Text("row_0003750000")).toThrift(), mutation.toThrift());
+ client.update(Tracer.traceInfo(), CredentialHelper.create(opts.principal, opts.getToken(), opts.instance), new KeyExtent(new Text("!!"), null, new Text("row_0003750000")).toThrift(), mutation.toThrift());
} catch (Exception e) {
throw new RuntimeException(e);
}
Modified: accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/performance/scan/CollectTabletStats.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/performance/scan/CollectTabletStats.java?rev=1452601&r1=1452600&r2=1452601&view=diff
==============================================================================
--- accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/performance/scan/CollectTabletStats.java (original)
+++ accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/performance/scan/CollectTabletStats.java Mon Mar 4 23:45:46 2013
@@ -63,6 +63,7 @@ import org.apache.accumulo.core.iterator
import org.apache.accumulo.core.iterators.system.MultiIterator;
import org.apache.accumulo.core.iterators.system.VisibilityFilter;
import org.apache.accumulo.core.security.Authorizations;
+import org.apache.accumulo.core.security.CredentialHelper;
import org.apache.accumulo.core.security.thrift.TCredentials;
import org.apache.accumulo.core.util.AddressUtil;
import org.apache.accumulo.core.util.CachedConfiguration;
@@ -119,7 +120,7 @@ public class CollectTabletStats {
}
Map<KeyExtent,String> locations = new HashMap<KeyExtent,String>();
- List<KeyExtent> candidates = findTablets(!opts.selectFarTablets, opts.getCredentials(), opts.tableName, instance, locations);
+ List<KeyExtent> candidates = findTablets(!opts.selectFarTablets, CredentialHelper.create(opts.principal, opts.getToken(), opts.instance), opts.tableName, instance, locations);
if (candidates.size() < opts.numThreads) {
System.err.println("ERROR : Unable to find " + opts.numThreads + " " + (opts.selectFarTablets ? "far" : "local") + " tablets");
@@ -131,7 +132,7 @@ public class CollectTabletStats {
Map<KeyExtent,List<String>> tabletFiles = new HashMap<KeyExtent,List<String>>();
for (KeyExtent ke : tabletsToTest) {
- List<String> files = getTabletFiles(opts.getCredentials(), opts.getInstance(), tableId, ke);
+ List<String> files = getTabletFiles(CredentialHelper.create(opts.principal, opts.getToken(), opts.instance), opts.getInstance(), tableId, ke);
tabletFiles.put(ke, files);
}
Modified: accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/State.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/State.java?rev=1452601&r1=1452600&r2=1452601&view=diff
==============================================================================
--- accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/State.java (original)
+++ accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/State.java Mon Mar 4 23:45:46 2013
@@ -29,6 +29,7 @@ import org.apache.accumulo.core.client.C
import org.apache.accumulo.core.client.Instance;
import org.apache.accumulo.core.client.MultiTableBatchWriter;
import org.apache.accumulo.core.client.ZooKeeperInstance;
+import org.apache.accumulo.core.client.security.tokens.AuthenticationToken;
import org.apache.accumulo.core.client.security.tokens.PasswordToken;
import org.apache.accumulo.core.security.CredentialHelper;
import org.apache.accumulo.core.security.thrift.TCredentials;
@@ -95,15 +96,23 @@ public class State {
public Connector getConnector() throws AccumuloException, AccumuloSecurityException {
if (connector == null) {
- connector = getInstance().getConnector(getCredentials());
+ connector = getInstance().getConnector(getUserName(), getToken());
}
return connector;
}
public TCredentials getCredentials() {
- String username = props.getProperty("USERNAME");
- String password = props.getProperty("PASSWORD");
- return CredentialHelper.createSquelchError(username, new PasswordToken(password), getInstance().getInstanceID());
+ String username = getUserName();
+ AuthenticationToken password = getToken();
+ return CredentialHelper.createSquelchError(username, password, getInstance().getInstanceID());
+ }
+
+ public String getUserName() {
+ return props.getProperty("USERNAME");
+ }
+
+ public AuthenticationToken getToken() {
+ return new PasswordToken(props.getProperty("PASSWORD"));
}
public Instance getInstance() {
Modified: accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/security/AlterTable.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/security/AlterTable.java?rev=1452601&r1=1452600&r2=1452601&view=diff
==============================================================================
--- accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/security/AlterTable.java (original)
+++ accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/security/AlterTable.java Mon Mar 4 23:45:46 2013
@@ -32,7 +32,7 @@ public class AlterTable extends Test {
@Override
public void visit(State state, Properties props) throws Exception {
- Connector conn = state.getInstance().getConnector(WalkingSecurity.get(state).getSysCredentials());
+ Connector conn = state.getInstance().getConnector(WalkingSecurity.get(state).getSysUserName(), WalkingSecurity.get(state).getSysToken());
String tableName = WalkingSecurity.get(state).getTableName();
Modified: accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/security/AlterTablePerm.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/security/AlterTablePerm.java?rev=1452601&r1=1452600&r2=1452601&view=diff
==============================================================================
--- accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/security/AlterTablePerm.java (original)
+++ accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/security/AlterTablePerm.java Mon Mar 4 23:45:46 2013
@@ -22,9 +22,10 @@ import java.util.Random;
import org.apache.accumulo.core.client.AccumuloException;
import org.apache.accumulo.core.client.AccumuloSecurityException;
import org.apache.accumulo.core.client.Connector;
+import org.apache.accumulo.core.client.security.tokens.AuthenticationToken;
+import org.apache.accumulo.core.security.CredentialHelper;
import org.apache.accumulo.core.security.SystemPermission;
import org.apache.accumulo.core.security.TablePermission;
-import org.apache.accumulo.core.security.thrift.TCredentials;
import org.apache.accumulo.test.randomwalk.State;
import org.apache.accumulo.test.randomwalk.Test;
@@ -38,7 +39,7 @@ public class AlterTablePerm extends Test
public static void alter(State state, Properties props) throws Exception {
String action = props.getProperty("task", "toggle");
String perm = props.getProperty("perm", "random");
- String sourceUser = props.getProperty("source", "system");
+ String sourceUserProp = props.getProperty("source", "system");
String targetUser = props.getProperty("target", "table");
boolean tabExists = WalkingSecurity.get(state).getTableExists();
@@ -61,17 +62,21 @@ public class AlterTablePerm extends Test
String tableName = WalkingSecurity.get(state).getTableName();
boolean hasPerm = WalkingSecurity.get(state).hasTablePermission(target, tableName, tabPerm);
boolean canGive;
- TCredentials source;
- if ("system".equals(sourceUser)) {
- source = WalkingSecurity.get(state).getSysCredentials();
- } else if ("table".equals(sourceUser)) {
- source = WalkingSecurity.get(state).getTabCredentials();
+ String sourceUser;
+ AuthenticationToken sourceToken;
+ if ("system".equals(sourceUserProp)) {
+ sourceUser = WalkingSecurity.get(state).getSysUserName();
+ sourceToken = WalkingSecurity.get(state).getSysToken();
+ } else if ("table".equals(sourceUserProp)) {
+ sourceUser = WalkingSecurity.get(state).getTabUserName();
+ sourceToken = WalkingSecurity.get(state).getTabToken();
} else {
- source = state.getCredentials();
+ sourceUser = state.getUserName();
+ sourceToken = state.getToken();
}
- Connector conn = state.getInstance().getConnector(source);
+ Connector conn = state.getInstance().getConnector(sourceUser, sourceToken);
- canGive = WalkingSecurity.get(state).canGrantTable(source, target, WalkingSecurity.get(state).getTableName());
+ canGive = WalkingSecurity.get(state).canGrantTable(CredentialHelper.create(sourceUser, sourceToken, state.getInstance().getInstanceID()), target, WalkingSecurity.get(state).getTableName());
// toggle
if (!"take".equals(action) && !"give".equals(action)) {
Modified: accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/security/Authenticate.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/security/Authenticate.java?rev=1452601&r1=1452600&r2=1452601&view=diff
==============================================================================
--- accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/security/Authenticate.java (original)
+++ accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/security/Authenticate.java Mon Mar 4 23:45:46 2013
@@ -22,8 +22,9 @@ import java.util.Properties;
import org.apache.accumulo.core.client.AccumuloException;
import org.apache.accumulo.core.client.AccumuloSecurityException;
import org.apache.accumulo.core.client.Connector;
+import org.apache.accumulo.core.client.security.tokens.AuthenticationToken;
import org.apache.accumulo.core.client.security.tokens.PasswordToken;
-import org.apache.accumulo.core.security.thrift.TCredentials;
+import org.apache.accumulo.core.security.CredentialHelper;
import org.apache.accumulo.test.randomwalk.State;
import org.apache.accumulo.test.randomwalk.Test;
@@ -31,14 +32,14 @@ public class Authenticate extends Test {
@Override
public void visit(State state, Properties props) throws Exception {
- authenticate(WalkingSecurity.get(state).getSysCredentials(), state, props);
+ authenticate(WalkingSecurity.get(state).getSysUserName(), WalkingSecurity.get(state).getSysToken(), state, props);
}
- public static void authenticate(TCredentials auth, State state, Properties props) throws Exception {
+ public static void authenticate(String principal, AuthenticationToken token, State state, Properties props) throws Exception {
String targetProp = props.getProperty("target");
boolean success = Boolean.parseBoolean(props.getProperty("valid"));
- Connector conn = state.getInstance().getConnector(auth);
+ Connector conn = state.getInstance().getConnector(principal, token);
String target;
@@ -50,7 +51,7 @@ public class Authenticate extends Test {
boolean exists = WalkingSecurity.get(state).userExists(target);
// Copy so if failed it doesn't mess with the password stored in state
byte[] password = Arrays.copyOf(WalkingSecurity.get(state).getUserPassword(target), WalkingSecurity.get(state).getUserPassword(target).length);
- boolean hasPermission = WalkingSecurity.get(state).canAskAboutUser(auth, target);
+ boolean hasPermission = WalkingSecurity.get(state).canAskAboutUser(CredentialHelper.create(principal, token, state.getInstance().getInstanceID()), target);
if (!success)
for (int i = 0; i < password.length; i++)
Modified: accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/security/ChangePass.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/security/ChangePass.java?rev=1452601&r1=1452600&r2=1452601&view=diff
==============================================================================
--- accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/security/ChangePass.java (original)
+++ accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/security/ChangePass.java Mon Mar 4 23:45:46 2013
@@ -22,8 +22,9 @@ import java.util.Random;
import org.apache.accumulo.core.client.AccumuloException;
import org.apache.accumulo.core.client.AccumuloSecurityException;
import org.apache.accumulo.core.client.Connector;
+import org.apache.accumulo.core.client.security.tokens.AuthenticationToken;
import org.apache.accumulo.core.client.security.tokens.PasswordToken;
-import org.apache.accumulo.core.security.thrift.TCredentials;
+import org.apache.accumulo.core.security.CredentialHelper;
import org.apache.accumulo.test.randomwalk.State;
import org.apache.accumulo.test.randomwalk.Test;
@@ -34,13 +35,16 @@ public class ChangePass extends Test {
String target = props.getProperty("target");
String source = props.getProperty("source");
- TCredentials auth;
+ String principal;
+ AuthenticationToken token;
if (source.equals("system")) {
- auth = WalkingSecurity.get(state).getSysCredentials();
+ principal = WalkingSecurity.get(state).getSysUserName();
+ token = WalkingSecurity.get(state).getSysToken();
} else {
- auth = WalkingSecurity.get(state).getTabCredentials();
+ principal = WalkingSecurity.get(state).getTabUserName();
+ token = WalkingSecurity.get(state).getTabToken();
}
- Connector conn = state.getInstance().getConnector(auth);
+ Connector conn = state.getInstance().getConnector(principal, token);
boolean hasPerm;
boolean targetExists;
@@ -51,7 +55,7 @@ public class ChangePass extends Test {
targetExists = WalkingSecurity.get(state).userExists(target);
- hasPerm = WalkingSecurity.get(state).canChangePassword(auth, target);
+ hasPerm = WalkingSecurity.get(state).canChangePassword(CredentialHelper.create(principal, token, state.getInstance().getInstanceID()), target);
Random r = new Random();
Modified: accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/security/CreateTable.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/security/CreateTable.java?rev=1452601&r1=1452600&r2=1452601&view=diff
==============================================================================
--- accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/security/CreateTable.java (original)
+++ accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/security/CreateTable.java Mon Mar 4 23:45:46 2013
@@ -31,7 +31,7 @@ public class CreateTable extends Test {
@Override
public void visit(State state, Properties props) throws Exception {
- Connector conn = state.getInstance().getConnector(WalkingSecurity.get(state).getSysCredentials());
+ Connector conn = state.getInstance().getConnector(WalkingSecurity.get(state).getSysUserName(), WalkingSecurity.get(state).getSysToken());
String tableName = WalkingSecurity.get(state).getTableName();
Modified: accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/security/CreateUser.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/security/CreateUser.java?rev=1452601&r1=1452600&r2=1452601&view=diff
==============================================================================
--- accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/security/CreateUser.java (original)
+++ accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/security/CreateUser.java Mon Mar 4 23:45:46 2013
@@ -29,7 +29,7 @@ public class CreateUser extends Test {
@Override
public void visit(State state, Properties props) throws Exception {
- Connector conn = state.getInstance().getConnector(WalkingSecurity.get(state).getSysCredentials());
+ Connector conn = state.getInstance().getConnector(WalkingSecurity.get(state).getSysUserName(), WalkingSecurity.get(state).getSysToken());
String tableUserName = WalkingSecurity.get(state).getTabUserName();
Modified: accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/security/DropTable.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/security/DropTable.java?rev=1452601&r1=1452600&r2=1452601&view=diff
==============================================================================
--- accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/security/DropTable.java (original)
+++ accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/security/DropTable.java Mon Mar 4 23:45:46 2013
@@ -24,7 +24,8 @@ import org.apache.accumulo.core.client.C
import org.apache.accumulo.core.client.TableExistsException;
import org.apache.accumulo.core.client.TableNotFoundException;
import org.apache.accumulo.core.client.impl.thrift.SecurityErrorCode;
-import org.apache.accumulo.core.security.thrift.TCredentials;
+import org.apache.accumulo.core.client.security.tokens.AuthenticationToken;
+import org.apache.accumulo.core.security.CredentialHelper;
import org.apache.accumulo.test.randomwalk.State;
import org.apache.accumulo.test.randomwalk.Test;
@@ -37,18 +38,21 @@ public class DropTable extends Test {
public static void dropTable(State state, Properties props) throws Exception {
String sourceUser = props.getProperty("source", "system");
- TCredentials auth;
+ String principal;
+ AuthenticationToken token;
if (sourceUser.equals("table")) {
- auth = WalkingSecurity.get(state).getTabCredentials();
+ principal = WalkingSecurity.get(state).getTabUserName();
+ token = WalkingSecurity.get(state).getTabToken();
} else {
- auth = WalkingSecurity.get(state).getSysCredentials();
+ principal = WalkingSecurity.get(state).getSysUserName();
+ token = WalkingSecurity.get(state).getSysToken();
}
- Connector conn = state.getInstance().getConnector(auth);
+ Connector conn = state.getInstance().getConnector(principal, token);
String tableName = WalkingSecurity.get(state).getTableName();
boolean exists = WalkingSecurity.get(state).getTableExists();
- boolean hasPermission = WalkingSecurity.get(state).canDeleteTable(auth, tableName);
+ boolean hasPermission = WalkingSecurity.get(state).canDeleteTable(CredentialHelper.create(principal, token, state.getInstance().getInstanceID()), tableName);
try {
conn.tableOperations().delete(tableName);
Modified: accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/security/DropUser.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/security/DropUser.java?rev=1452601&r1=1452600&r2=1452601&view=diff
==============================================================================
--- accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/security/DropUser.java (original)
+++ accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/security/DropUser.java Mon Mar 4 23:45:46 2013
@@ -28,7 +28,7 @@ public class DropUser extends Test {
@Override
public void visit(State state, Properties props) throws Exception {
- Connector conn = state.getInstance().getConnector(WalkingSecurity.get(state).getSysCredentials());
+ Connector conn = state.getInstance().getConnector(WalkingSecurity.get(state).getSysUserName(), WalkingSecurity.get(state).getSysToken());
String tableUserName = WalkingSecurity.get(state).getTabUserName();
Modified: accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/security/SetAuths.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/security/SetAuths.java?rev=1452601&r1=1452600&r2=1452601&view=diff
==============================================================================
--- accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/security/SetAuths.java (original)
+++ accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/security/SetAuths.java Mon Mar 4 23:45:46 2013
@@ -22,32 +22,35 @@ import java.util.Random;
import org.apache.accumulo.core.client.AccumuloException;
import org.apache.accumulo.core.client.AccumuloSecurityException;
import org.apache.accumulo.core.client.Connector;
+import org.apache.accumulo.core.client.security.tokens.AuthenticationToken;
import org.apache.accumulo.core.security.Authorizations;
-import org.apache.accumulo.core.security.thrift.TCredentials;
+import org.apache.accumulo.core.security.CredentialHelper;
import org.apache.accumulo.test.randomwalk.State;
import org.apache.accumulo.test.randomwalk.Test;
public class SetAuths extends Test {
@Override
- public void visit(State state, Properties props) throws Exception {
- TCredentials auth;
-
+ public void visit(State state, Properties props) throws Exception {
String authsString = props.getProperty("auths", "_random");
String targetUser = props.getProperty("system");
String target;
+ String authPrincipal;
+ AuthenticationToken authToken;
if ("table".equals(targetUser)) {
target = WalkingSecurity.get(state).getTabUserName();
- auth = WalkingSecurity.get(state).getSysCredentials();
+ authPrincipal = WalkingSecurity.get(state).getSysUserName();
+ authToken = WalkingSecurity.get(state).getSysToken();
} else {
target = WalkingSecurity.get(state).getSysUserName();
- auth = state.getCredentials();
+ authPrincipal = state.getUserName();
+ authToken = state.getToken();
}
- Connector conn = state.getInstance().getConnector(auth);
+ Connector conn = state.getInstance().getConnector(authPrincipal, authToken);
boolean exists = WalkingSecurity.get(state).userExists(target);
- boolean hasPermission = WalkingSecurity.get(state).canChangeAuthorizations(auth, target);
+ boolean hasPermission = WalkingSecurity.get(state).canChangeAuthorizations(CredentialHelper.create(authPrincipal, authToken, state.getInstance().getInstanceID()), target);
Authorizations auths;
if (authsString.equals("_random")) {
Modified: accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/security/TableOp.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/security/TableOp.java?rev=1452601&r1=1452600&r2=1452601&view=diff
==============================================================================
--- accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/security/TableOp.java (original)
+++ accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/security/TableOp.java Mon Mar 4 23:45:46 2013
@@ -53,7 +53,7 @@ public class TableOp extends Test {
@Override
public void visit(State state, Properties props) throws Exception {
- Connector conn = state.getInstance().getConnector(WalkingSecurity.get(state).getTabCredentials());
+ Connector conn = state.getInstance().getConnector(WalkingSecurity.get(state).getTabUserName(), WalkingSecurity.get(state).getTabToken());
String action = props.getProperty("action", "_random");
TablePermission tp;
Modified: accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/security/Validate.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/security/Validate.java?rev=1452601&r1=1452600&r2=1452601&view=diff
==============================================================================
--- accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/security/Validate.java (original)
+++ accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/security/Validate.java Mon Mar 4 23:45:46 2013
@@ -52,9 +52,9 @@ public class Validate extends Test {
Properties props = new Properties();
props.setProperty("target", "system");
- Authenticate.authenticate(state.getCredentials(), state, props);
+ Authenticate.authenticate(state.getUserName(), state.getToken(), state, props);
props.setProperty("target", "table");
- Authenticate.authenticate(state.getCredentials(), state, props);
+ Authenticate.authenticate(state.getUserName(), state.getToken(), state, props);
for (String user : new String[] {WalkingSecurity.get(state).getSysUserName(), WalkingSecurity.get(state).getTabUserName()}) {
for (SystemPermission sp : SystemPermission.values()) {
Modified: accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/security/WalkingSecurity.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/security/WalkingSecurity.java?rev=1452601&r1=1452600&r2=1452601&view=diff
==============================================================================
--- accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/security/WalkingSecurity.java (original)
+++ accumulo/branches/1.5/test/src/main/java/org/apache/accumulo/test/randomwalk/security/WalkingSecurity.java Mon Mar 4 23:45:46 2013
@@ -283,11 +283,19 @@ public class WalkingSecurity extends Sec
}
public TCredentials getSysCredentials() {
- return CredentialHelper.createSquelchError(getSysUserName(), new PasswordToken(getSysPassword()), state.getInstance().getInstanceID());
+ return CredentialHelper.createSquelchError(getSysUserName(), getSysToken(), state.getInstance().getInstanceID());
}
public TCredentials getTabCredentials() {
- return CredentialHelper.createSquelchError(getTabUserName(), new PasswordToken(getTabPassword()), state.getInstance().getInstanceID());
+ return CredentialHelper.createSquelchError(getTabUserName(), getTabToken(), state.getInstance().getInstanceID());
+ }
+
+ public AuthenticationToken getSysToken() {
+ return new PasswordToken(getSysPassword());
+ }
+
+ public AuthenticationToken getTabToken() {
+ return new PasswordToken(getTabPassword());
}
public byte[] getUserPassword(String user) {