Package org.apache.hadoop.hive.metastore.api

Examples of org.apache.hadoop.hive.metastore.api.HiveObjectRef$HiveObjectRefTupleScheme


        PrivilegeGrantInfo grantInfo =
            AuthorizationUtils.getThriftPrivilegeGrantInfo(priv, privInfo.getGrantorPrincipal(),
                privInfo.isGrantOption(), privInfo.getGrantTime());

        //only grantInfo is used
        HiveObjectPrivilege thriftObjectPriv = new HiveObjectPrivilege(new HiveObjectRef(
            AuthorizationUtils.getThriftHiveObjType(privObj.getType()),privObj.getDbname(),
            privObj.getTableViewURI(),null,null), principal.getName(),
            AuthorizationUtils.getThriftPrincipalType(principal.getType()), grantInfo);
        privList.add(thriftObjectPriv);
      }
View Full Code Here


            throw new HiveException(
                "For user-level privileges, column sets should be null. columns="
                    + privileges.get(idx).getColumns().toString());
          }

          privBag.addToPrivileges(new HiveObjectPrivilege(new HiveObjectRef(
              HiveObjectType.GLOBAL, null, null, null, null), null, null,
              new PrivilegeGrantInfo(priv.toString(), 0, grantor, grantorType,
                  grantOption)));
        }
      } else {
        org.apache.hadoop.hive.metastore.api.Partition partObj = null;
        List<String> partValues = null;
        if (tableObj != null) {
          if ((!tableObj.isPartitioned())
              && privSubjectDesc.getPartSpec() != null) {
            throw new HiveException(
                "Table is not partitioned, but partition name is present: partSpec="
                    + privSubjectDesc.getPartSpec().toString());
          }

          if (privSubjectDesc.getPartSpec() != null) {
            partObj = db.getPartition(tableObj, privSubjectDesc.getPartSpec(),
                false).getTPartition();
            partValues = partObj.getValues();
          }
        }

        for (PrivilegeDesc privDesc : privileges) {
          List<String> columns = privDesc.getColumns();
          Privilege priv = privDesc.getPrivilege();
          if (columns != null && columns.size() > 0) {
            if (!priv.supportColumnLevel()) {
              throw new HiveException(priv.toString()
                  + " does not support column level.");
            }
            if (privSubjectDesc == null || tableName == null) {
              throw new HiveException(
                  "For user-level/database-level privileges, column sets should be null. columns="
                      + columns);
            }
            for (int i = 0; i < columns.size(); i++) {
              privBag.addToPrivileges(new HiveObjectPrivilege(
                  new HiveObjectRef(HiveObjectType.COLUMN, dbName, tableName,
                      partValues, columns.get(i)), null, null,  new PrivilegeGrantInfo(priv.toString(), 0, grantor, grantorType, grantOption)));
            }
          } else {
            if (privSubjectDesc.getTable()) {
              if (privSubjectDesc.getPartSpec() != null) {
                privBag.addToPrivileges(new HiveObjectPrivilege(
                    new HiveObjectRef(HiveObjectType.PARTITION, dbName,
                        tableName, partValues, null), null, null,  new PrivilegeGrantInfo(priv.toString(), 0, grantor, grantorType, grantOption)));
              } else {
                privBag
                .addToPrivileges(new HiveObjectPrivilege(
                    new HiveObjectRef(HiveObjectType.TABLE, dbName,
                        tableName, null, null), null, null, new PrivilegeGrantInfo(priv.toString(), 0, grantor, grantorType, grantOption)));
              }
            } else {
              privBag.addToPrivileges(new HiveObjectPrivilege(
                  new HiveObjectRef(HiveObjectType.DATABASE, dbName, null,
                      null, null), null, null, new PrivilegeGrantInfo(priv.toString(), 0, grantor, grantorType, grantOption)));
            }
          }
        }
      }
View Full Code Here

    StringBuilder builder = new StringBuilder();
    //sort the list to get sorted (deterministic) output (for ease of testing)
    Collections.sort(privileges);

    for (HiveObjectPrivilege privilege : privileges) {
      HiveObjectRef resource = privilege.getHiveObject();
      PrivilegeGrantInfo grantInfo = privilege.getGrantInfo();

      appendNonNull(builder, resource.getDbName(), true);
      appendNonNull(builder, resource.getObjectName());
      appendNonNull(builder, resource.getPartValues());
      appendNonNull(builder, resource.getColumnName());
      appendNonNull(builder, privilege.getPrincipalName());
      appendNonNull(builder, privilege.getPrincipalType());
      appendNonNull(builder, grantInfo.getPrivilege());
      appendNonNull(builder, grantInfo.isGrantOption());
      appendNonNull(builder, testMode ? -1 : grantInfo.getCreateTime() * 1000L);
 
View Full Code Here

        LOG.warn("Unexpected exception while adding "+PUBLIC +" roles" , e);
      }
      LOG.info("Added "+PUBLIC+ " role in metastore");
      // now grant all privs to admin
      PrivilegeBag privs = new PrivilegeBag();
      privs.addToPrivileges(new HiveObjectPrivilege( new HiveObjectRef(HiveObjectType.GLOBAL, null,
        null, null, null), ADMIN, PrincipalType.ROLE, new PrivilegeGrantInfo("All", 0, ADMIN,
        PrincipalType.ROLE, true)));
      try {
        ms.grantPrivileges(privs);
      } catch (InvalidObjectException e) {
View Full Code Here

          return Collections.emptyList();
        }
        List<HiveObjectPrivilege> result = new ArrayList<HiveObjectPrivilege>();
        for (int i = 0; i < mTableCols.size(); i++) {
          MTableColumnPrivilege sCol = mTableCols.get(i);
          HiveObjectRef objectRef = new HiveObjectRef(
              HiveObjectType.COLUMN, dbName, tableName, null, sCol.getColumnName());
          HiveObjectPrivilege secObj = new HiveObjectPrivilege(
              objectRef, sCol.getPrincipalName(), principalType,
              new PrivilegeGrantInfo(sCol.getPrivilege(), sCol
                  .getCreateTime(), sCol.getGrantor(), PrincipalType
View Full Code Here

          return Collections.emptyList();
        }
        List<HiveObjectPrivilege> result = new ArrayList<HiveObjectPrivilege>();
        for (int i = 0; i < mPartitionCols.size(); i++) {
          MPartitionColumnPrivilege sCol = mPartitionCols.get(i);
          HiveObjectRef objectRef = new HiveObjectRef(
              HiveObjectType.COLUMN, dbName, tableName, partValues, sCol.getColumnName());
          HiveObjectPrivilege secObj = new HiveObjectPrivilege(objectRef,
              sCol.getPrincipalName(), principalType,
              new PrivilegeGrantInfo(sCol.getPrivilege(), sCol
                  .getCreateTime(), sCol.getGrantor(), PrincipalType
View Full Code Here

          return Collections.<HiveObjectPrivilege>emptyList();
        }
        List<HiveObjectPrivilege> result = new ArrayList<HiveObjectPrivilege>();
        for (int i = 0; i < mDbs.size(); i++) {
          MDBPrivilege sDB = mDbs.get(i);
          HiveObjectRef objectRef = new HiveObjectRef(
              HiveObjectType.DATABASE, dbName, null, null, null);
          HiveObjectPrivilege secObj = new HiveObjectPrivilege(objectRef,
              sDB.getPrincipalName(), principalType,
              new PrivilegeGrantInfo(sDB.getPrivilege(), sDB
                  .getCreateTime(), sDB.getGrantor(), PrincipalType
View Full Code Here

          return Collections.<HiveObjectPrivilege> emptyList();
        }
        List<HiveObjectPrivilege> result = new ArrayList<HiveObjectPrivilege>();
        for (int i = 0; i < mParts.size(); i++) {
          MPartitionPrivilege sPart = mParts.get(i);
          HiveObjectRef objectRef = new HiveObjectRef(
              HiveObjectType.PARTITION, dbName, tableName, partValues, null);
          HiveObjectPrivilege secObj = new HiveObjectPrivilege(objectRef,
              sPart.getPrincipalName(), principalType,
              new PrivilegeGrantInfo(sPart.getPrivilege(), sPart
                  .getCreateTime(), sPart.getGrantor(), PrincipalType
View Full Code Here

          return Collections.<HiveObjectPrivilege> emptyList();
        }
        List<HiveObjectPrivilege> result = new ArrayList<HiveObjectPrivilege>();
        for (int i = 0; i < mTbls.size(); i++) {
          MTablePrivilege sTbl = mTbls.get(i);
          HiveObjectRef objectRef = new HiveObjectRef(
              HiveObjectType.TABLE, dbName, tableName, null, null);
          HiveObjectPrivilege secObj = new HiveObjectPrivilege(objectRef,
              sTbl.getPrincipalName(), principalType,
              new PrivilegeGrantInfo(sTbl.getPrivilege(), sTbl.getCreateTime(), sTbl
                  .getGrantor(), PrincipalType.valueOf(sTbl
View Full Code Here

          return Collections.<HiveObjectPrivilege> emptyList();
        }
        List<HiveObjectPrivilege> result = new ArrayList<HiveObjectPrivilege>();
        for (int i = 0; i < mUsers.size(); i++) {
          MGlobalPrivilege sUsr = mUsers.get(i);
          HiveObjectRef objectRef = new HiveObjectRef(
              HiveObjectType.GLOBAL, null, null, null, null);
          HiveObjectPrivilege secUser = new HiveObjectPrivilege(
              objectRef, sUsr.getPrincipalName(), principalType,
              new PrivilegeGrantInfo(sUsr.getPrivilege(), sUsr
                  .getCreateTime(), sUsr.getGrantor(), PrincipalType
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hive.metastore.api.HiveObjectRef$HiveObjectRefTupleScheme

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.