public static void main(String[] args) throws Exception {
    if (args.length < 3 || args.length > 6) {
      System.out.println("Invalid arguments!");
      System.out.println(
        "Usage: HttpDoAsClient host port doAsUserName [security=true] [principal] [keytab]");
      System.exit(-1);
    }

    host = args[0];
    port = Integer.parseInt(args[1]);
    doAsUser = args[2];
    if (args.length > 3) {
      secure = Boolean.parseBoolean(args[3]);
      if (args.length > 4) {
        principal = args[4];
        keyTab = args[5];
        if (!new File(keyTab).exists()) {
          System.err.printf("ERROR: KeyTab File %s not found %n", keyTab);
          System.exit(-1);
        }
      } else {
        principal = getSubject().getPrincipals().iterator().next().getName();
      }
    }

    final HttpDoAsClient client = new HttpDoAsClient();
    Subject.doAs(getSubject(), new PrivilegedExceptionAction<Void>() {
      @Override
      public Void run() throws Exception {
        client.run();
        return null;
      }
    });
  }
See the instructions under hbase-examples/README.txt
hbase-examples/src/main/java/org/apache/hadoop/hbase/thrift/HttpDoAsClient.java