accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ctubb...@apache.org
Subject [1/3] accumulo git commit: ACCUMULO-4348 Replace use of deprecated method
Date Wed, 22 Jun 2016 21:04:33 GMT
Repository: accumulo
Updated Branches:
  refs/heads/1.8 5ba1c88de -> 104eeb374
  refs/heads/master e3bd30eda -> 56af3a236


ACCUMULO-4348 Replace use of deprecated method

Replace use of deprecated KerberosToken constructor with explicit login
with UserGroupInformation first.


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/104eeb37
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/104eeb37
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/104eeb37

Branch: refs/heads/1.8
Commit: 104eeb37496fc2c8dc5898b78a36669d6f9c0748
Parents: 5ba1c88
Author: Christopher Tubbs <ctubbsii@apache.org>
Authored: Wed Jun 22 17:02:44 2016 -0400
Committer: Christopher Tubbs <ctubbsii@apache.org>
Committed: Wed Jun 22 17:02:44 2016 -0400

----------------------------------------------------------------------
 .../java/org/apache/accumulo/cluster/ClusterUser.java    |  6 +++---
 .../apache/accumulo/harness/AccumuloClusterHarness.java  |  5 ++---
 .../apache/accumulo/harness/SharedMiniClusterBase.java   | 11 ++++-------
 .../harness/conf/AccumuloMiniClusterConfiguration.java   |  5 ++---
 .../conf/StandaloneAccumuloClusterConfiguration.java     |  6 +++---
 .../org/apache/accumulo/test/randomwalk/Environment.java |  6 +++---
 6 files changed, 17 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/104eeb37/minicluster/src/main/java/org/apache/accumulo/cluster/ClusterUser.java
----------------------------------------------------------------------
diff --git a/minicluster/src/main/java/org/apache/accumulo/cluster/ClusterUser.java b/minicluster/src/main/java/org/apache/accumulo/cluster/ClusterUser.java
index e99ca0b..0231242 100644
--- a/minicluster/src/main/java/org/apache/accumulo/cluster/ClusterUser.java
+++ b/minicluster/src/main/java/org/apache/accumulo/cluster/ClusterUser.java
@@ -25,6 +25,7 @@ import java.io.IOException;
 import org.apache.accumulo.core.client.security.tokens.AuthenticationToken;
 import org.apache.accumulo.core.client.security.tokens.KerberosToken;
 import org.apache.accumulo.core.client.security.tokens.PasswordToken;
+import org.apache.hadoop.security.UserGroupInformation;
 
 /**
  * Simple wrapper around a principal and its credentials: a password or a keytab.
@@ -81,9 +82,8 @@ public class ClusterUser {
     if (null != password) {
       return new PasswordToken(password);
     } else if (null != keytab) {
-      @SuppressWarnings("deprecation")
-      KerberosToken krbToken = new KerberosToken(principal, keytab, true);
-      return krbToken;
+      UserGroupInformation.loginUserFromKeytab(principal, keytab.getAbsolutePath());
+      return new KerberosToken();
     }
 
     throw new IllegalStateException("One of password and keytab must be non-null");

http://git-wip-us.apache.org/repos/asf/accumulo/blob/104eeb37/test/src/main/java/org/apache/accumulo/harness/AccumuloClusterHarness.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/harness/AccumuloClusterHarness.java b/test/src/main/java/org/apache/accumulo/harness/AccumuloClusterHarness.java
index 7483184..7d7b73a 100644
--- a/test/src/main/java/org/apache/accumulo/harness/AccumuloClusterHarness.java
+++ b/test/src/main/java/org/apache/accumulo/harness/AccumuloClusterHarness.java
@@ -170,9 +170,8 @@ public abstract class AccumuloClusterHarness extends AccumuloITBase implements
M
           UserGroupInformation.loginUserFromKeytab(systemUser.getPrincipal(), systemUser.getKeytab().getAbsolutePath());
 
           // Open a connector as the system user (ensures the user will exist for us to assign
permissions to)
-          @SuppressWarnings("deprecation")
-          KerberosToken krbToken = new KerberosToken(systemUser.getPrincipal(), systemUser.getKeytab(),
true);
-          Connector conn = cluster.getConnector(systemUser.getPrincipal(), krbToken);
+          UserGroupInformation.loginUserFromKeytab(systemUser.getPrincipal(), systemUser.getKeytab().getAbsolutePath());
+          Connector conn = cluster.getConnector(systemUser.getPrincipal(), new KerberosToken());
 
           // Then, log back in as the "root" user and do the grant
           UserGroupInformation.loginUserFromKeytab(rootUser.getPrincipal(), rootUser.getKeytab().getAbsolutePath());

http://git-wip-us.apache.org/repos/asf/accumulo/blob/104eeb37/test/src/main/java/org/apache/accumulo/harness/SharedMiniClusterBase.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/harness/SharedMiniClusterBase.java b/test/src/main/java/org/apache/accumulo/harness/SharedMiniClusterBase.java
index 5b90597..cb0fa7b 100644
--- a/test/src/main/java/org/apache/accumulo/harness/SharedMiniClusterBase.java
+++ b/test/src/main/java/org/apache/accumulo/harness/SharedMiniClusterBase.java
@@ -74,10 +74,8 @@ public abstract class SharedMiniClusterBase extends AccumuloITBase implements
Cl
       // Login as the client
       ClusterUser rootUser = krb.getRootUser();
       // Get the krb token
-      principal = rootUser.getPrincipal();
-      @SuppressWarnings("deprecation")
-      KerberosToken krbToken = new KerberosToken(principal, rootUser.getKeytab(), true);
-      token = krbToken;
+      UserGroupInformation.loginUserFromKeytab(rootUser.getPrincipal(), rootUser.getKeytab().getAbsolutePath());
+      token = new KerberosToken();
     } else {
       rootPassword = "rootPasswordShared1";
       token = new PasswordToken(rootPassword);
@@ -91,9 +89,8 @@ public abstract class SharedMiniClusterBase extends AccumuloITBase implements
Cl
       final ClusterUser systemUser = krb.getAccumuloServerUser(), rootUser = krb.getRootUser();
       // Login as the trace user
       // Open a connector as the system user (ensures the user will exist for us to assign
permissions to)
-      @SuppressWarnings("deprecation")
-      KerberosToken krbToken = new KerberosToken(systemUser.getPrincipal(), systemUser.getKeytab(),
true);
-      Connector conn = cluster.getConnector(systemUser.getPrincipal(), krbToken);
+      UserGroupInformation.loginUserFromKeytab(systemUser.getPrincipal(), systemUser.getKeytab().getAbsolutePath());
+      Connector conn = cluster.getConnector(systemUser.getPrincipal(), new KerberosToken());
 
       // Then, log back in as the "root" user and do the grant
       UserGroupInformation.loginUserFromKeytab(rootUser.getPrincipal(), rootUser.getKeytab().getAbsolutePath());

http://git-wip-us.apache.org/repos/asf/accumulo/blob/104eeb37/test/src/main/java/org/apache/accumulo/harness/conf/AccumuloMiniClusterConfiguration.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/harness/conf/AccumuloMiniClusterConfiguration.java
b/test/src/main/java/org/apache/accumulo/harness/conf/AccumuloMiniClusterConfiguration.java
index 63f90ea..dea72e5 100644
--- a/test/src/main/java/org/apache/accumulo/harness/conf/AccumuloMiniClusterConfiguration.java
+++ b/test/src/main/java/org/apache/accumulo/harness/conf/AccumuloMiniClusterConfiguration.java
@@ -86,9 +86,8 @@ public class AccumuloMiniClusterConfiguration extends AccumuloClusterPropertyCon
 
       ClusterUser rootUser = AccumuloClusterHarness.getKdc().getRootUser();
       try {
-        @SuppressWarnings("deprecation")
-        KerberosToken krbToken = new KerberosToken(rootUser.getPrincipal(), rootUser.getKeytab(),
true);
-        return krbToken;
+        UserGroupInformation.loginUserFromKeytab(rootUser.getPrincipal(), rootUser.getKeytab().getAbsolutePath());
+        return new KerberosToken();
       } catch (IOException e) {
         throw new RuntimeException(e);
       }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/104eeb37/test/src/main/java/org/apache/accumulo/harness/conf/StandaloneAccumuloClusterConfiguration.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/harness/conf/StandaloneAccumuloClusterConfiguration.java
b/test/src/main/java/org/apache/accumulo/harness/conf/StandaloneAccumuloClusterConfiguration.java
index e72d965..99a1cdc 100644
--- a/test/src/main/java/org/apache/accumulo/harness/conf/StandaloneAccumuloClusterConfiguration.java
+++ b/test/src/main/java/org/apache/accumulo/harness/conf/StandaloneAccumuloClusterConfiguration.java
@@ -37,6 +37,7 @@ import org.apache.accumulo.core.client.security.tokens.PasswordToken;
 import org.apache.accumulo.harness.AccumuloClusterHarness.ClusterType;
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.security.UserGroupInformation;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -162,9 +163,8 @@ public class StandaloneAccumuloClusterConfiguration extends AccumuloClusterPrope
     if (clientConf.getBoolean(ClientProperty.INSTANCE_RPC_SASL_ENABLED.getKey(), false))
{
       File keytab = getAdminKeytab();
       try {
-        @SuppressWarnings("deprecation")
-        KerberosToken krbToken = new KerberosToken(getAdminPrincipal(), keytab, true);
-        return krbToken;
+        UserGroupInformation.loginUserFromKeytab(getAdminPrincipal(), keytab.getAbsolutePath());
+        return new KerberosToken();
       } catch (IOException e) {
         // The user isn't logged in
         throw new RuntimeException("Failed to create KerberosToken", e);

http://git-wip-us.apache.org/repos/asf/accumulo/blob/104eeb37/test/src/main/java/org/apache/accumulo/test/randomwalk/Environment.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/Environment.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/Environment.java
index b5036b7..44619bb 100644
--- a/test/src/main/java/org/apache/accumulo/test/randomwalk/Environment.java
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/Environment.java
@@ -35,6 +35,7 @@ import org.apache.accumulo.core.client.ZooKeeperInstance;
 import org.apache.accumulo.core.client.security.tokens.AuthenticationToken;
 import org.apache.accumulo.core.client.security.tokens.KerberosToken;
 import org.apache.accumulo.core.client.security.tokens.PasswordToken;
+import org.apache.hadoop.security.UserGroupInformation;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -169,9 +170,8 @@ public class Environment {
         throw new IllegalArgumentException("Provided keytab is not a normal file: " + keytab);
       }
       try {
-        @SuppressWarnings("deprecation")
-        KerberosToken krbToken = new KerberosToken(getUserName(), keytabFile, true);
-        return krbToken;
+        UserGroupInformation.loginUserFromKeytab(getUserName(), keytabFile.getAbsolutePath());
+        return new KerberosToken();
       } catch (IOException e) {
         throw new RuntimeException("Failed to login", e);
       }


Mime
View raw message