public static boolean isAuthorizationEnabled(Configuration conf) {
    if (!HiveConf.getBoolVar(conf, HiveConf.ConfVars.HIVE_AUTHORIZATION_ENABLED)) {
      return false;
    }
    // If the V2 api of authorizer in use, the session state getAuthorizer return null.
    // Here we disable authorization if we use V2 api or the DefaultHiveAuthorizationProvider
    // The additional authorization checks happening in hcatalog are designed to
    // work with  storage based authorization (on client side). It should not try doing
    // additional checks if a V2 authorizer or DefaultHiveAuthorizationProvider is in use.
    // The recommended configuration is to use storage based authorization in metastore server.
    // However, if user define a custom V1 authorization, it will be honored.
    if (SessionState.get().getAuthorizer() == null ||
        DefaultHiveAuthorizationProvider.class.getName().equals(HiveConf.getVar(conf, HiveConf.ConfVars.HIVE_AUTHORIZATION_MANAGER))) {
      LOG.info("Metastore authorizer is skipped for V2 authorizer or"
        + " DefaultHiveAuthorizationProvider");
      return false;
    }
    return true;
  }
@Test
  public void authEnabledV1Auth() throws Exception {
    HiveConf hcatConf = new HiveConfForTest(this.getClass());
    hcatConf.setBoolVar(ConfVars.HIVE_AUTHORIZATION_ENABLED, true);
    hcatConf.setVar(ConfVars.HIVE_AUTHORIZATION_MANAGER, StorageBasedAuthorizationProvider.class.getName());
    SessionState.start(hcatConf);
    assertTrue("hcat auth should be enabled", HCatAuthUtil.isAuthorizationEnabled(hcatConf));
  }