Package org.apache.hadoop.hbase.client

Examples of org.apache.hadoop.hbase.client.UserProvider


   * @param args
   */
   void doMain(final String[] args) throws Exception {
     processOptions(args);
    // login the server principal (if using secure Hadoop)
    UserProvider provider = UserProvider.instantiate(conf);
    if (provider.isHadoopSecurityEnabled() && provider.isHBaseSecurityEnabled()) {
      String machineName =
          Strings.domainNamePointerToHostName(DNS.getDefaultHost(
            conf.get("hbase.thrift.dns.interface", "default"),
            conf.get("hbase.thrift.dns.nameserver", "default")));

      provider.login("hbase.thrift.keytab.file",
        "hbase.thrift.kerberos.principal", machineName);
    }
     serverRunner = new ThriftServerRunner(conf);

     // Put up info server.
View Full Code Here


    // We would need even more libraries that hbase-server depends on
    TableMapReduceUtil.addDependencyJars(job.getConfiguration(), Counter.class);
  }

  public static void initCredentials(Job job) throws IOException {
    UserProvider provider = UserProvider.instantiate(job.getConfiguration());

    if (provider.isHadoopSecurityEnabled()) {
      // propagate delegation related props from launcher job to MR job
      if (System.getenv("HADOOP_TOKEN_FILE_LOCATION") != null) {
        job.getConfiguration().set("mapreduce.job.credentials.binary",
                                   System.getenv("HADOOP_TOKEN_FILE_LOCATION"));
      }
    }

    if (provider.isHBaseSecurityEnabled()) {
      try {
        // init credentials for remote cluster
        String quorumAddress = job.getConfiguration().get(
            TableOutputFormat.QUORUM_ADDRESS);
        User user = provider.getCurrent();
        if (quorumAddress != null) {
          String[] parts = ZKUtil.transformClusterKey(quorumAddress);
          Configuration peerConf = HBaseConfiguration.create(job
              .getConfiguration());
          peerConf.set(HConstants.ZOOKEEPER_QUORUM, parts[0]);
View Full Code Here

   * @param quorumAddress string that contains the 3 required configuratins
   * @throws IOException When the authentication token cannot be obtained.
   */
  public static void initCredentialsForCluster(Job job, String quorumAddress)
      throws IOException {
    UserProvider userProvider = UserProvider.instantiate(job.getConfiguration());
    if (userProvider.isHBaseSecurityEnabled()) {
      try {
        Configuration peerConf = HBaseConfiguration.create(job.getConfiguration());
        ZKUtil.applyClusterKeyToConf(peerConf, quorumAddress);
        obtainAuthTokenForJob(job, peerConf, userProvider.getCurrent());
      } catch (InterruptedException e) {
        LOG.info("Interrupted obtaining user authentication token");
        Thread.interrupted();
      }
    }
View Full Code Here

    Log LOG = LogFactory.getLog("RESTServer");

    VersionInfo.logVersion();
    Configuration conf = HBaseConfiguration.create();
    // login the server principal (if using secure Hadoop)
    UserProvider provider = UserProvider.instantiate(conf);
    if (provider.isHadoopSecurityEnabled() && provider.isHBaseSecurityEnabled()) {
      String machineName = Strings.domainNamePointerToHostName(
        DNS.getDefaultHost(conf.get("hbase.rest.dns.interface", "default"),
          conf.get("hbase.rest.dns.nameserver", "default")));
      provider.login("hbase.rest.keytab.file", "hbase.rest.kerberos.principal",
        machineName);
    }

    RESTServlet servlet = RESTServlet.getInstance(conf);
View Full Code Here

  /**
   * Returns a new {@code PermissionCache} initialized with permission assignments
   * from the {@code hbase.superuser} configuration key.
   */
  private PermissionCache<Permission> initGlobal(Configuration conf) throws IOException {
    UserProvider userProvider = UserProvider.instantiate(conf);
    User user = userProvider.getCurrent();
    if (user == null) {
      throw new IOException("Unable to obtain the current user, " +
          "authorization checks for internal operations will not work correctly!");
    }
    PermissionCache<Permission> newCache = new PermissionCache<Permission>();
View Full Code Here

    boolean ugiUsernamePresent = in.readBoolean();
    if (ugiUsernamePresent) {
      String username = in.readUTF();
      boolean realUserNamePresent = in.readBoolean();
      Configuration conf = HBaseConfiguration.create();
      UserProvider provider = UserProvider.instantiate(conf);
      if (realUserNamePresent) {
        String realUserName = in.readUTF();
        UserGroupInformation realUserUgi =
            UserGroupInformation.createRemoteUser(realUserName);
        user = provider.create(
            UserGroupInformation.createProxyUser(username, realUserUgi));
      } else {
        user = provider.create(UserGroupInformation.createRemoteUser(username));
      }
    } else {
      user = null;
    }
  }
View Full Code Here

    }
    initCredentials(job);
  }

  public static void initCredentials(JobConf job) throws IOException {
    UserProvider provider = UserProvider.instantiate(job);

    if (provider.isHadoopSecurityEnabled()) {
      // propagate delegation related props from launcher job to MR job
      if (System.getenv("HADOOP_TOKEN_FILE_LOCATION") != null) {
        job.set("mapreduce.job.credentials.binary",
                System.getenv("HADOOP_TOKEN_FILE_LOCATION"));
      }
    }

    if (provider.isHBaseSecurityEnabled()) {
      try {
        User user = provider.getCurrent();
        Token<?> authToken = getAuthToken(job, user);
        if (authToken == null) {
          user.obtainAuthTokenForJob(job);
        } else {
          job.getCredentials().addToken(authToken.getService(), authToken);
View Full Code Here

    // login the zookeeper client principal (if using security)
    ZKUtil.loginClient(this.conf, "hbase.zookeeper.client.keytab.file",
      "hbase.zookeeper.client.kerberos.principal", this.isa.getHostName());

    // initialize server principal (if using secure Hadoop)
    UserProvider provider = UserProvider.instantiate(conf);
    provider.login("hbase.master.keytab.file",
      "hbase.master.kerberos.principal", this.isa.getHostName());

    // set the thread name now we have an address
    setName(MASTER + "-" + this.serverName.toString());
View Full Code Here

    }

    Configuration conf = getConf();
    Path hbaseDir = new Path(conf.get(HConstants.HBASE_DIR));
    FileSystem fs = hbaseDir.getFileSystem(conf);
    UserProvider provider = UserProvider.instantiate(conf);
    User user = provider.getCurrent();
    FileStatus[] files = fs.listStatus(hbaseDir);
    for (FileStatus file : files) {
      try {
        FSUtils.checkAccess(user, file, FsAction.WRITE);
      } catch (AccessControlException ace) {
View Full Code Here

    // login the zookeeper client principal (if using security)
    ZKUtil.loginClient(this.conf, "hbase.zookeeper.client.keytab.file",
      "hbase.zookeeper.client.kerberos.principal", this.isa.getHostName());

    // login the server principal (if using secure Hadoop)
    UserProvider provider = UserProvider.instantiate(conf);
    provider.login("hbase.regionserver.keytab.file",
      "hbase.regionserver.kerberos.principal", this.isa.getHostName());
    regionServerAccounting = new RegionServerAccounting();
    cacheConfig = new CacheConfig(conf);
    uncaughtExceptionHandler = new UncaughtExceptionHandler() {
      public void uncaughtException(Thread t, Throwable e) {
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.client.UserProvider

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.