public HierarcyBuilder addUriToOutput(Server server, String uriPath, String warehouseDirPath) throws MetaException { List<DBModelAuthorizable> uriHierarchy = new ArrayList<DBModelAuthorizable>(); addServerToOutput(server); uriHierarchy.add(server); try { uriHierarchy.add(new AccessURI(PathUtils.parseDFSURI(warehouseDirPath, uriPath))); } catch (URISyntaxException e) { throw new MetaException("Error paring the URI " + e.getMessage()); } authHierarchy.add(uriHierarchy); return this; }
HiveConf conf = SessionState.get().getConf(); String warehouseDir = conf.getVar(ConfVars.METASTOREWAREHOUSE); URI scratchURI = new URI(PathUtils.parseDFSURI(warehouseDir, conf.getVar(HiveConf.ConfVars.SCRATCHDIR))); URI requestURI = new URI(PathUtils.parseDFSURI(warehouseDir, writeEntity.getLocation().getPath())); LOG.debug("scratchURI = " + scratchURI + ", requestURI = " + requestURI);
private List<Authorizable> toAuthorizable(SentryHivePrivilegeObjectDesc privSubjectDesc) throws HiveException{ List<Authorizable> authorizableHeirarchy = new ArrayList<Authorizable>(); authorizableHeirarchy.add(new Server(server)); String dbName = null; if (privSubjectDesc.getTable()) { DatabaseTable dbTable = parseDBTable(privSubjectDesc.getObject()); dbName = dbTable.getDatabase(); String tableName = dbTable.getTable(); authorizableHeirarchy.add(new Table(tableName)); authorizableHeirarchy.add(new Database(dbName)); } else if (privSubjectDesc.getUri()) { String uriPath = privSubjectDesc.getObject(); String warehouseDir = conf.getVar(HiveConf.ConfVars.METASTOREWAREHOUSE); try { authorizableHeirarchy.add(new AccessURI(PathUtils.parseDFSURI(warehouseDir, uriPath))); } catch(URISyntaxException e) { throw new HiveException(e.getMessage()); } } else { dbName = privSubjectDesc.getObject(); authorizableHeirarchy.add(new Database(dbName)); } return authorizableHeirarchy; }
private void authorizeCreateTable(PreCreateTableEvent context) throws InvalidOperationException, MetaException { HierarcyBuilder inputBuilder = new HierarcyBuilder(); inputBuilder.addDbToOutput(getAuthServer(), context.getTable().getDbName()); HierarcyBuilder outputBuilder = new HierarcyBuilder(); outputBuilder.addDbToOutput(getAuthServer(), context.getTable().getDbName()); if (!StringUtils.isEmpty(context.getTable().getSd().getLocation())) { String uriPath; try { uriPath = PathUtils.parseDFSURI(warehouseDir, getSdLocation(context.getTable().getSd())); } catch(URISyntaxException e) { throw new MetaException(e.getMessage()); } inputBuilder.addUriToOutput(getAuthServer(), uriPath, warehouseDir); } authorizeMetastoreAccess(HiveOperation.CREATETABLE, inputBuilder.build(), outputBuilder.build()); }
String newLocationUri; try { oldLocationUri = PathUtils.parseDFSURI(warehouseDir, getSdLocation(context.getOldTable().getSd())); newLocationUri = PathUtils.parseDFSURI(warehouseDir, getSdLocation(context.getNewTable().getSd())); } catch (URISyntaxException e) {
uriPath = PathUtils.parseDFSURI(warehouseDir, partitionLocation); } catch (URISyntaxException e) { throw new MetaException(e.getMessage());
String uriPath; try { uriPath = PathUtils.parseDFSURI(warehouseDir, mapiPart .getSd().getLocation()); } catch (URISyntaxException e) {