diff --git hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/HcatDelegator.java hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/HcatDelegator.java index cd9128e..a8f1ebc 100644 --- hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/HcatDelegator.java +++ hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/HcatDelegator.java @@ -57,10 +57,11 @@ public HcatDelegator(AppConfig appConf, ExecService execService) { public ExecBean run(String user, String exec, boolean format, String group, String permissions) throws NotAuthorizedException, BusyException, ExecuteException, IOException { - SecureProxySupport proxy = new SecureProxySupport(); + SecureProxySupport proxy = null; try { + proxy = new SecureProxySupport(user); List args = makeArgs(exec, format, group, permissions); - proxy.open(user, appConf); + proxy.open(appConf); // Setup the hadoop vars to specify the user. String cp = makeOverrideClasspath(appConf); diff --git hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/SecureProxySupport.java hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/SecureProxySupport.java index 8966897..71ab4ee 100644 --- hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/SecureProxySupport.java +++ hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/SecureProxySupport.java @@ -46,9 +46,16 @@ private Path tokenPath; public static final String HCAT_SERVICE = "hcat"; private final boolean isEnabled; - private String user; + private final String user; - public SecureProxySupport() { + /** + * @param user not null, not empty + */ + public SecureProxySupport(String user) { + if(user == null || user.length() <=0) { + throw new IllegalArgumentException("user='" + user + "' is invalid."); + } + this.user = user; isEnabled = UserGroupInformation.isSecurityEnabled(); } @@ -71,11 +78,10 @@ public String getHcatServiceStr() { /** * Create the delegation token. */ - public Path open(String user, Configuration conf) + public Path open(Configuration conf) throws IOException, InterruptedException { close(); if (isEnabled) { - this.user = user; File t = File.createTempFile("templeton", null); tokenPath = new Path(t.toURI()); Token fsToken = getFSDelegationToken(user, conf);