Examples of HiveAuthzBinding


Examples of org.apache.sentry.binding.hive.authz.HiveAuthzBinding

  public void testHiveMetaStoreSSLConfig() throws Exception {
    // prepare the hive and auth configs
    hiveConf.setBoolVar(ConfVars.METASTORE_USE_THRIFT_SASL, false);
    hiveConf.setBoolVar(ConfVars.METASTORE_EXECUTE_SET_UGI, true);
    authzConf.set(AuthzConfVars.SENTRY_TESTING_MODE.getVar(), "false");
    testAuth = new HiveAuthzBinding(HiveAuthzBinding.HiveHook.HiveMetaStore, hiveConf, authzConf);
  }
View Full Code Here

Examples of org.apache.sentry.binding.hive.authz.HiveAuthzBinding

  public void testHiveMetaStoreUGIConfig() throws Exception {
    // prepare the hive and auth configs
    hiveConf.setBoolVar(ConfVars.METASTORE_USE_THRIFT_SASL, true);
    hiveConf.setBoolVar(ConfVars.METASTORE_EXECUTE_SET_UGI, false);
    authzConf.set(AuthzConfVars.SENTRY_TESTING_MODE.getVar(), "true");
    testAuth = new HiveAuthzBinding(HiveAuthzBinding.HiveHook.HiveMetaStore, hiveConf, authzConf);
  }
View Full Code Here

Examples of org.apache.sentry.binding.hive.authz.HiveAuthzBinding

    // perpare the hive and auth configs
    hiveConf.setBoolVar(ConfVars.HIVE_SERVER2_ENABLE_DOAS, true);
    hiveConf.setVar(ConfVars.HIVE_SERVER2_AUTHENTICATION, "Kerberos");
    authzConf.set(AuthzConfVars.SENTRY_TESTING_MODE.getVar(), "false");
    authzConf.set(AuthzConfVars.AUTHZ_ALLOW_HIVE_IMPERSONATION.getVar(), "true");
    testAuth = new HiveAuthzBinding(hiveConf, authzConf);

    // following check should pass, even with impersonation
    inputTabHierarcyList.add(buildObjectHierarchy(SERVER1, CUSTOMER_DB, PURCHASES_TAB));
    testAuth.authorize(HiveOperation.QUERY, queryPrivileges, ADMIN_SUBJECT,
        inputTabHierarcyList, outputTabHierarcyList);
View Full Code Here

Examples of org.apache.sentry.binding.hive.authz.HiveAuthzBinding

  @Test(expected=InvalidConfigurationException.class)
  public void testNoAuthenticationRestriction() throws Exception {
    // perpare the hive and auth configs
    hiveConf.setVar(ConfVars.HIVE_SERVER2_AUTHENTICATION, "None");
    authzConf.set(AuthzConfVars.SENTRY_TESTING_MODE.getVar(), "false");
    testAuth = new HiveAuthzBinding(hiveConf, authzConf);
  }
View Full Code Here

Examples of org.apache.sentry.binding.hive.authz.HiveAuthzBinding

  public void testDeprecatedHiveAuthzConfs() throws Exception {
    // verify that a non-existant AuthorizationProvider throws an Exception
    authzConf.set(AuthzConfVars.AUTHZ_PROVIDER.getVar(),
      "org.apache.sentry.provider.BogusProvider");
    try {
      new HiveAuthzBinding(hiveConf, authzConf);
      Assert.fail("Expected exception");
    } catch (ClassNotFoundException e) {}

    // verify HadoopGroupResourceAuthorizationProvider
    authzConf.set(AuthzConfVars.AUTHZ_PROVIDER.getVar(),
      "org.apache.sentry.provider.file.HadoopGroupResourceAuthorizationProvider");
    new HiveAuthzBinding(hiveConf, authzConf);

    // verify LocalGroupResourceAuthorizationProvider
    authzConf.set(AuthzConfVars.AUTHZ_PROVIDER.getVar(),
      "org.apache.sentry.provider.file.LocalGroupResourceAuthorizationProvider");
    new HiveAuthzBinding(hiveConf, authzConf);
  }
View Full Code Here

Examples of org.apache.sentry.binding.hive.authz.HiveAuthzBinding

    HiveConf hiveConf = session.getConf();
    if(hiveConf == null) {
      throw new IllegalStateException("Session HiveConf is null");
    }
    authzConf = loadAuthzConf(hiveConf);
    hiveAuthzBinding = new HiveAuthzBinding(hiveConf, authzConf);
  }
View Full Code Here

Examples of org.apache.sentry.binding.hive.authz.HiveAuthzBinding

  private void authorizeMetastoreAccess(HiveOperation hiveOp,
      List<List<DBModelAuthorizable>> inputHierarchy,
      List<List<DBModelAuthorizable>> outputHierarchy)
      throws InvalidOperationException {
    try {
      HiveAuthzBinding hiveAuthzBinding = getHiveAuthzBinding();
      hiveAuthzBinding.authorize(hiveOp, HiveAuthzPrivilegesMap
          .getHiveAuthzPrivileges(hiveOp), new Subject(getUserName()),
          inputHierarchy, outputHierarchy);
    } catch (AuthorizationException e1) {
      throw invalidOperationException(e1);
    } catch (LoginException e1) {
View Full Code Here

Examples of org.apache.sentry.binding.hive.authz.HiveAuthzBinding

    return result;
  }

  private HiveAuthzBinding getHiveAuthzBinding() throws Exception {
    if (hiveAuthzBinding == null) {
      hiveAuthzBinding = new HiveAuthzBinding(HiveAuthzBinding.HiveHook.HiveMetaStore, hiveConf, authzConf);
    }
    return hiveAuthzBinding;
  }
View Full Code Here

Examples of org.apache.sentry.binding.hive.authz.HiveAuthzBinding

  /**
   * Raise error if the given query contains transforms
   */
  @Override
  public void run(HookContext hookContext) throws Exception {
    HiveAuthzBinding hiveAuthzBinding =  HiveAuthzBinding.get(hookContext.getConf());
    try {
      QueryPlan qPlan = hookContext.getQueryPlan();
      if ((qPlan == null) || (qPlan.getQueryProperties() == null)) {
        return;
      }
      // validate server level permissions permission for transforms
      if (qPlan.getQueryProperties().usesScript()) {
        if (hiveAuthzBinding == null) {
          LOG.warn("No authorization binding found, skipping the authorization for transform");
          return;
        }
        List<List<DBModelAuthorizable>> inputHierarchy = new ArrayList<List<DBModelAuthorizable>> ();
        List<List<DBModelAuthorizable>> outputHierarchy = new ArrayList<List<DBModelAuthorizable>> ();
        List<DBModelAuthorizable> serverHierarchy = new ArrayList<DBModelAuthorizable>();

        serverHierarchy.add(hiveAuthzBinding.getAuthServer());
        inputHierarchy.add(serverHierarchy);
        hiveAuthzBinding.authorize(HiveOperation.QUERY,
          HiveAuthzPrivilegesMap.getHiveExtendedAuthzPrivileges(HiveExtendedOperation.TRANSFORM),
          new Subject(hookContext.getUserName()), inputHierarchy, outputHierarchy);
      }
    } finally {
      if (hiveAuthzBinding != null) {
        hiveAuthzBinding.clear(hookContext.getConf());
      }
    }
  }
View Full Code Here

Examples of org.apache.sentry.binding.hive.authz.HiveAuthzBinding

        "org.apache.sentry.provider.file.LocalGroupResourceAuthorizationProvider");
    authzConf.set(AuthzConfVars.AUTHZ_PROVIDER_RESOURCE.getVar(),
        new File(baseDir, RESOURCE_PATH).getPath());
    authzConf.set(AuthzConfVars.AUTHZ_SERVER_NAME.getVar(), SERVER1);
    authzConf.set(AuthzConfVars.ACCESS_TESTING_MODE.getVar(), "true");
    testAuth = new HiveAuthzBinding(hiveConf, authzConf);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.