/** * Gets a HBase delegation token and stores it in the given Credentials. * * @return the same Credentials instance as the one given in parameter. */ public static Credentials obtainToken(Configuration hConf, Credentials credentials) { if (!User.isHBaseSecurityEnabled(hConf)) { return credentials; } try { Class c = Class.forName("org.apache.hadoop.hbase.security.token.TokenUtil"); Method method = c.getMethod("obtainToken", Configuration.class); Token<? extends TokenIdentifier> token = castToken(method.invoke(null, hConf)); credentials.addToken(token.getService(), token); return credentials; } catch (Exception e) { throw Throwables.propagate(e); } }
/** * Gets a HBase delegation token and stores it in the given Credentials. * * @return the same Credentials instance as the one given in parameter. */ public static Credentials obtainToken(Configuration hConf, Credentials credentials) { if (!User.isHBaseSecurityEnabled(hConf)) { return credentials; } try { Class c = Class.forName("org.apache.hadoop.hbase.security.token.TokenUtil"); Method method = c.getMethod("obtainToken", Configuration.class); Token<? extends TokenIdentifier> token = castToken(method.invoke(null, hConf)); credentials.addToken(token.getService(), token); return credentials; } catch (Exception e) { throw Throwables.propagate(e); } }