sentry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From linaataus...@apache.org
Subject sentry git commit: SENTRY-2141: Sentry Privilege TimeStamp is not converted to grantTime in HivePrivilegeInfo correctly (Na Li, reviewed by Sergio Pena, Kalyan Kumar Kalvagadda, Arjun Mishra, Steve Moist, Alexander Kolbasov, Liam Sargent, Xinran Tinney)
Date Tue, 20 Feb 2018 22:33:37 GMT
Repository: sentry
Updated Branches:
  refs/heads/master 5a5a9d883 -> 76b65ee1d


SENTRY-2141: Sentry Privilege TimeStamp is not converted to grantTime in HivePrivilegeInfo
correctly (Na Li, reviewed by Sergio Pena, Kalyan Kumar Kalvagadda, Arjun Mishra, Steve Moist,
Alexander Kolbasov, Liam Sargent, Xinran Tinney)


Project: http://git-wip-us.apache.org/repos/asf/sentry/repo
Commit: http://git-wip-us.apache.org/repos/asf/sentry/commit/76b65ee1
Tree: http://git-wip-us.apache.org/repos/asf/sentry/tree/76b65ee1
Diff: http://git-wip-us.apache.org/repos/asf/sentry/diff/76b65ee1

Branch: refs/heads/master
Commit: 76b65ee1d205bb700e1894a1bb75a19a3c87f2d8
Parents: 5a5a9d8
Author: lina.li <lina.li@cloudera.com>
Authored: Tue Feb 20 14:55:35 2018 -0600
Committer: lina.li <lina.li@cloudera.com>
Committed: Tue Feb 20 14:55:35 2018 -0600

----------------------------------------------------------------------
 .../apache/sentry/binding/util/SentryAuthorizerUtil.java  | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sentry/blob/76b65ee1/sentry-binding/sentry-binding-hive/src/main/java/org/apache/sentry/binding/util/SentryAuthorizerUtil.java
----------------------------------------------------------------------
diff --git a/sentry-binding/sentry-binding-hive/src/main/java/org/apache/sentry/binding/util/SentryAuthorizerUtil.java
b/sentry-binding/sentry-binding-hive/src/main/java/org/apache/sentry/binding/util/SentryAuthorizerUtil.java
index b536283..1c41639 100644
--- a/sentry-binding/sentry-binding-hive/src/main/java/org/apache/sentry/binding/util/SentryAuthorizerUtil.java
+++ b/sentry-binding/sentry-binding-hive/src/main/java/org/apache/sentry/binding/util/SentryAuthorizerUtil.java
@@ -20,6 +20,7 @@ import java.net.URISyntaxException;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Set;
+import java.util.concurrent.TimeUnit;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hive.common.JavaUtils;
 import org.apache.hadoop.hive.conf.HiveConf;
@@ -220,8 +221,15 @@ public class SentryAuthorizerUtil {
     HivePrincipal grantor = new HivePrincipal(UNKONWN_GRANTOR, HivePrincipalType.ROLE);
     boolean grantOption =
         tPrivilege.getGrantOption().equals(TSentryGrantOption.TRUE) ? true : false;
+
+    // Convert the timestamp in sentry, which is in milliseconds, to the timestamp in
+    // hive, which is in seconds
+    // The timestamp is the difference between the current time and midnight, January 1,
1970 UTC.
+    int hiveCreateTimeSeconds = (int)TimeUnit.SECONDS.convert(tPrivilege.getCreateTime(),
+        TimeUnit.MILLISECONDS);
+
     return new HivePrivilegeInfo(principal, hivePrivilege, hivePrivilegeObject, grantor,
-        grantOption, (int) tPrivilege.getCreateTime());
+        grantOption, hiveCreateTimeSeconds);
   }
 
   /**


Mime
View raw message