priv.setTableName((String) privObj[3]); priv.setColumnName((String) privObj[4]); priv.setURI((String) privObj[5]); priv.setAction((String) privObj[6]); priv.setGrantOption((Boolean) privObj[7]);
my.setURI("hdfs://namenode:9000/path"); your.setURI("hdfs://namenode:9000/path/to/../../other"); assertFalse(my.implies(your)); my.setURI("file:///path"); your.setURI("file:///path/to/../../other"); assertFalse(my.implies(your)); my.setURI("blah"); your.setURI("hdfs://namenode:9000/path/to/some/dir"); assertFalse(my.implies(your)); my.setURI("hdfs://namenode:9000/path/to/some/dir"); your.setURI("blah"); assertFalse(my.implies(your)); my.setURI("hdfs://namenode:9000/path"); your.setURI("file:///path/to/some/dir"); assertFalse(my.implies(your)); my.setURI("hdfs://namenode:9000/path"); your.setURI("file://namenode:9000/path/to/some/dir"); assertFalse(my.implies(your)); my.setURI("hdfs://namenode1:9000/path"); your.setURI("hdfs://namenode2:9000/path"); assertFalse(my.implies(your)); my.setURI("hdfs://namenode:9000/path"); your.setURI("hdfs://namenode:9001/path"); assertFalse(my.implies(your));
my.setURI("hdfs://namenode:9000/path"); your.setURI("hdfs://namenode:9000/path/to/../../other"); assertFalse(my.implies(your)); my.setURI("file:///path"); your.setURI("file:///path/to/../../other"); assertFalse(my.implies(your)); my.setURI("blah"); your.setURI("hdfs://namenode:9000/path/to/some/dir"); assertFalse(my.implies(your)); my.setURI("hdfs://namenode:9000/path/to/some/dir"); your.setURI("blah"); assertFalse(my.implies(your)); my.setURI("hdfs://namenode:9000/path"); your.setURI("file:///path/to/some/dir"); assertFalse(my.implies(your)); my.setURI("hdfs://namenode:9000/path"); your.setURI("file://namenode:9000/path/to/some/dir"); assertFalse(my.implies(your)); my.setURI("hdfs://namenode1:9000/path"); your.setURI("hdfs://namenode2:9000/path"); assertFalse(my.implies(your)); my.setURI("hdfs://namenode:9000/path"); your.setURI("hdfs://namenode:9001/path"); assertFalse(my.implies(your));
your.setServerName("server1"); your.setAction(actionMap[actions][1]); my.setURI("hdfs://namenode:9000/path"); your.setURI("hdfs://namenode:9000/path"); assertTrue(my.implies(your)); my.setURI("hdfs://namenode:9000/path"); your.setURI("hdfs://namenode:9000/path/to/some/dir"); assertTrue(my.implies(your)); my.setURI("file:///path"); your.setURI("file:///path"); assertTrue(my.implies(your)); my.setURI("file:///path"); your.setURI("file:///path/to/some/dir"); assertTrue(my.implies(your)); my.setURI(""); your.setURI("file:///path"); assertTrue(my.implies(your));
your.setServerName("server1"); your.setAction(actionMap[actions][1]); my.setURI("hdfs://namenode:9000/path"); your.setURI("hdfs://namenode:9000/path"); assertTrue(my.implies(your)); my.setURI("hdfs://namenode:9000/path"); your.setURI("hdfs://namenode:9000/path/to/some/dir"); assertTrue(my.implies(your)); my.setURI("file:///path"); your.setURI("file:///path"); assertTrue(my.implies(your)); my.setURI("file:///path"); your.setURI("file:///path/to/some/dir"); assertTrue(my.implies(your)); my.setURI(""); your.setURI("file:///path"); assertTrue(my.implies(your));
/** * Converts thrift object to model object. Additionally does normalization * such as trimming whitespace and setting appropriate case. * @throws SentryInvalidInputException */ private MSentryPrivilege convertToMSentryPrivilege(TSentryPrivilege privilege) throws SentryInvalidInputException { MSentryPrivilege mSentryPrivilege = new MSentryPrivilege(); mSentryPrivilege.setServerName(toNULLCol(safeTrimLower(privilege.getServerName()))); mSentryPrivilege.setDbName(toNULLCol(safeTrimLower(privilege.getDbName()))); mSentryPrivilege.setTableName(toNULLCol(safeTrimLower(privilege.getTableName()))); mSentryPrivilege.setColumnName(toNULLCol(safeTrimLower(privilege.getColumnName()))); mSentryPrivilege.setPrivilegeScope(safeTrim(privilege.getPrivilegeScope())); mSentryPrivilege.setAction(toNULLCol(safeTrimLower(privilege.getAction()))); mSentryPrivilege.setCreateTime(System.currentTimeMillis()); mSentryPrivilege.setURI(toNULLCol(safeTrim(privilege.getURI()))); if ( !privilege.getGrantOption().equals(TSentryGrantOption.UNSET) ) { mSentryPrivilege.setGrantOption(Boolean.valueOf(privilege.getGrantOption().toString())); } else { mSentryPrivilege.setGrantOption(null); } return mSentryPrivilege; }
/** * Converts thrift object to model object. Additionally does normalization * such as trimming whitespace and setting appropriate case. * @throws SentryInvalidInputException */ private MSentryPrivilege convertToMSentryPrivilege(TSentryPrivilege privilege) throws SentryInvalidInputException { MSentryPrivilege mSentryPrivilege = new MSentryPrivilege(); mSentryPrivilege.setServerName(toNULLCol(safeTrimLower(privilege.getServerName()))); mSentryPrivilege.setDbName(toNULLCol(safeTrimLower(privilege.getDbName()))); mSentryPrivilege.setTableName(toNULLCol(safeTrimLower(privilege.getTableName()))); mSentryPrivilege.setColumnName(toNULLCol(safeTrimLower(privilege.getColumnName()))); mSentryPrivilege.setPrivilegeScope(safeTrim(privilege.getPrivilegeScope())); mSentryPrivilege.setAction(toNULLCol(safeTrimLower(privilege.getAction()))); mSentryPrivilege.setCreateTime(System.currentTimeMillis()); mSentryPrivilege.setURI(toNULLCol(safeTrim(privilege.getURI()))); if ( !privilege.getGrantOption().equals(TSentryGrantOption.UNSET) ) { mSentryPrivilege.setGrantOption(Boolean.valueOf(privilege.getGrantOption().toString())); } else { mSentryPrivilege.setGrantOption(null); } return mSentryPrivilege; } private static String safeTrim(String s) {
hivePrivilege.setPrivilegeScope("table"); hivePrivilege.setAction("select"); hivePrivilege.setURI(SentryConstants.NULL_COL); hivePrivilege.setColumnName(SentryConstants.NULL_COL); hivePrivilege.setGrantOption(true);
hivePrivilege.setPrivilegeScope("table"); hivePrivilege.setAction("select"); hivePrivilege.setURI(SentryConstants.NULL_COL); hivePrivilege.setColumnName(SentryConstants.NULL_COL); hivePrivilege.setGrantOption(true);
hivePrivilege.setPrivilegeScope("table"); hivePrivilege.setAction("select"); hivePrivilege.setURI(SentryStore.NULL_COL); hivePrivilege.setColumnName(SentryStore.NULL_COL); hivePrivilege.setGrantOption(true);
hivePrivilege.setPrivilegeScope("table"); hivePrivilege.setAction("select"); hivePrivilege.setURI(SentryStore.NULL_COL); hivePrivilege.setColumnName(SentryStore.NULL_COL); hivePrivilege.setGrantOption(true);
hivePrivilege.setPrivilegeScope("table"); hivePrivilege.setAction("select"); hivePrivilege.setURI(SentryConstants.NULL_COL); hivePrivilege.setColumnName(SentryConstants.NULL_COL); hivePrivilege.setGrantOption(true);
hivePrivilege.setPrivilegeScope("table"); hivePrivilege.setAction("select"); hivePrivilege.setURI(SentryStore.NULL_COL); hivePrivilege.setColumnName(SentryStore.NULL_COL); hivePrivilege.setGrantOption(true);
hivePrivilege.setPrivilegeScope("table"); hivePrivilege.setAction("select"); hivePrivilege.setURI(SentryConstants.NULL_COL); hivePrivilege.setColumnName(SentryConstants.NULL_COL); hivePrivilege.setGrantOption(true);
hivePrivilege.setPrivilegeScope("table"); hivePrivilege.setAction("select"); hivePrivilege.setURI(SentryConstants.NULL_COL); hivePrivilege.setColumnName(SentryConstants.NULL_COL); hivePrivilege.setGrantOption(true);