Java 类org.apache.hadoop.fs.permission.AclStatus 实例源码

项目:hadoop    文件:FSOperations.java   
/** Converts an <code>AclStatus</code> object into a JSON object.
 *
 * @param aclStatus AclStatus object
 *
 * @return The JSON representation of the ACLs for the file
 */
@SuppressWarnings({"unchecked"})
private static Map<String,Object> aclStatusToJSON(AclStatus aclStatus) {
  Map<String,Object> json = new LinkedHashMap<String,Object>();
  Map<String,Object> inner = new LinkedHashMap<String,Object>();
  JSONArray entriesArray = new JSONArray();
  inner.put(HttpFSFileSystem.OWNER_JSON, aclStatus.getOwner());
  inner.put(HttpFSFileSystem.GROUP_JSON, aclStatus.getGroup());
  inner.put(HttpFSFileSystem.ACL_STICKY_BIT_JSON, aclStatus.isStickyBit());
  for ( AclEntry e : aclStatus.getEntries() ) {
    entriesArray.add(e.toString());
  }
  inner.put(HttpFSFileSystem.ACL_ENTRIES_JSON, entriesArray);
  json.put(HttpFSFileSystem.ACL_STATUS_JSON, inner);
  return json;
}
项目:hadoop    文件:TestJsonUtil.java   
@Test
public void testToAclStatus() throws IOException {
  String jsonString =
      "{\"AclStatus\":{\"entries\":[\"user::rwx\",\"user:user1:rw-\",\"group::rw-\",\"other::r-x\"],\"group\":\"supergroup\",\"owner\":\"testuser\",\"stickyBit\":false}}";
  ObjectReader reader = new ObjectMapper().reader(Map.class);
  Map<?, ?> json = reader.readValue(jsonString);

  List<AclEntry> aclSpec =
      Lists.newArrayList(aclEntry(ACCESS, USER, ALL),
          aclEntry(ACCESS, USER, "user1", READ_WRITE),
          aclEntry(ACCESS, GROUP, READ_WRITE),
          aclEntry(ACCESS, OTHER, READ_EXECUTE));

  AclStatus.Builder aclStatusBuilder = new AclStatus.Builder();
  aclStatusBuilder.owner("testuser");
  aclStatusBuilder.group("supergroup");
  aclStatusBuilder.addEntries(aclSpec);
  aclStatusBuilder.stickyBit(false);

  Assert.assertEquals("Should be equal", aclStatusBuilder.build(),
      JsonUtil.toAclStatus(json));
}
项目:hadoop    文件:TestJsonUtil.java   
@Test
public void testToJsonFromAclStatus() {
  String jsonString =
      "{\"AclStatus\":{\"entries\":[\"user:user1:rwx\",\"group::rw-\"],\"group\":\"supergroup\",\"owner\":\"testuser\",\"stickyBit\":false}}";
  AclStatus.Builder aclStatusBuilder = new AclStatus.Builder();
  aclStatusBuilder.owner("testuser");
  aclStatusBuilder.group("supergroup");
  aclStatusBuilder.stickyBit(false);

  List<AclEntry> aclSpec =
      Lists.newArrayList(aclEntry(ACCESS, USER,"user1", ALL),
          aclEntry(ACCESS, GROUP, READ_WRITE));

  aclStatusBuilder.addEntries(aclSpec);
  Assert.assertEquals(jsonString,
      JsonUtil.toJsonString(aclStatusBuilder.build()));

}
项目:hadoop    文件:FSAclBaseTest.java   
@Test
public void testModifyAclEntriesOnlyAccess() throws IOException {
  fs.create(path).close();
  fs.setPermission(path, FsPermission.createImmutable((short)0640));
  List<AclEntry> aclSpec = Lists.newArrayList(
    aclEntry(ACCESS, USER, ALL),
    aclEntry(ACCESS, USER, "foo", ALL),
    aclEntry(ACCESS, GROUP, READ_EXECUTE),
    aclEntry(ACCESS, OTHER, NONE));
  fs.setAcl(path, aclSpec);
  aclSpec = Lists.newArrayList(
    aclEntry(ACCESS, USER, "foo", READ_EXECUTE));
  fs.modifyAclEntries(path, aclSpec);
  AclStatus s = fs.getAclStatus(path);
  AclEntry[] returned = s.getEntries().toArray(new AclEntry[0]);
  assertArrayEquals(new AclEntry[] {
    aclEntry(ACCESS, USER, "foo", READ_EXECUTE),
    aclEntry(ACCESS, GROUP, READ_EXECUTE) }, returned);
  assertPermission((short)010750);
  assertAclFeature(true);
}
项目:hadoop    文件:FSAclBaseTest.java   
@Test
public void testModifyAclEntriesOnlyDefault() throws IOException {
  FileSystem.mkdirs(fs, path, FsPermission.createImmutable((short)0750));
  List<AclEntry> aclSpec = Lists.newArrayList(
    aclEntry(DEFAULT, USER, "foo", ALL));
  fs.setAcl(path, aclSpec);
  aclSpec = Lists.newArrayList(
    aclEntry(DEFAULT, USER, "foo", READ_EXECUTE));
  fs.modifyAclEntries(path, aclSpec);
  AclStatus s = fs.getAclStatus(path);
  AclEntry[] returned = s.getEntries().toArray(new AclEntry[0]);
  assertArrayEquals(new AclEntry[] {
    aclEntry(DEFAULT, USER, ALL),
    aclEntry(DEFAULT, USER, "foo", READ_EXECUTE),
    aclEntry(DEFAULT, GROUP, READ_EXECUTE),
    aclEntry(DEFAULT, MASK, READ_EXECUTE),
    aclEntry(DEFAULT, OTHER, NONE) }, returned);
  assertPermission((short)010750);
  assertAclFeature(true);
}
项目:hadoop    文件:FSAclBaseTest.java   
@Test
public void testModifyAclEntriesMinimalDefault() throws IOException {
  FileSystem.mkdirs(fs, path, FsPermission.createImmutable((short)0750));
  List<AclEntry> aclSpec = Lists.newArrayList(
    aclEntry(DEFAULT, USER, ALL),
    aclEntry(DEFAULT, GROUP, READ_EXECUTE),
    aclEntry(DEFAULT, OTHER, NONE));
  fs.modifyAclEntries(path, aclSpec);
  AclStatus s = fs.getAclStatus(path);
  AclEntry[] returned = s.getEntries().toArray(new AclEntry[0]);
  assertArrayEquals(new AclEntry[] {
    aclEntry(DEFAULT, USER, ALL),
    aclEntry(DEFAULT, GROUP, READ_EXECUTE),
    aclEntry(DEFAULT, OTHER, NONE) }, returned);
  assertPermission((short)010750);
  assertAclFeature(true);
}
项目:hadoop    文件:FSAclBaseTest.java   
@Test
public void testModifyAclEntriesCustomMask() throws IOException {
  fs.create(path).close();
  fs.setPermission(path, FsPermission.createImmutable((short)0640));
  List<AclEntry> aclSpec = Lists.newArrayList(
    aclEntry(ACCESS, USER, "foo", ALL),
    aclEntry(ACCESS, MASK, NONE));
  fs.modifyAclEntries(path, aclSpec);
  AclStatus s = fs.getAclStatus(path);
  AclEntry[] returned = s.getEntries().toArray(new AclEntry[0]);
  assertArrayEquals(new AclEntry[] {
    aclEntry(ACCESS, USER, "foo", ALL),
    aclEntry(ACCESS, GROUP, READ) }, returned);
  assertPermission((short)010600);
  assertAclFeature(true);
}
项目:hadoop    文件:FSAclBaseTest.java   
@Test
public void testRemoveAclEntries() throws IOException {
  FileSystem.mkdirs(fs, path, FsPermission.createImmutable((short)0750));
  List<AclEntry> aclSpec = Lists.newArrayList(
    aclEntry(ACCESS, USER, ALL),
    aclEntry(ACCESS, USER, "foo", ALL),
    aclEntry(ACCESS, GROUP, READ_EXECUTE),
    aclEntry(ACCESS, OTHER, NONE),
    aclEntry(DEFAULT, USER, "foo", ALL));
  fs.setAcl(path, aclSpec);
  aclSpec = Lists.newArrayList(
    aclEntry(ACCESS, USER, "foo"),
    aclEntry(DEFAULT, USER, "foo"));
  fs.removeAclEntries(path, aclSpec);
  AclStatus s = fs.getAclStatus(path);
  AclEntry[] returned = s.getEntries().toArray(new AclEntry[0]);
  assertArrayEquals(new AclEntry[] {
    aclEntry(ACCESS, GROUP, READ_EXECUTE),
    aclEntry(DEFAULT, USER, ALL),
    aclEntry(DEFAULT, GROUP, READ_EXECUTE),
    aclEntry(DEFAULT, MASK, READ_EXECUTE),
    aclEntry(DEFAULT, OTHER, NONE) }, returned);
  assertPermission((short)010750);
  assertAclFeature(true);
}
项目:hadoop    文件:FSAclBaseTest.java   
@Test
public void testRemoveAclEntriesOnlyAccess() throws IOException {
  fs.create(path).close();
  fs.setPermission(path, FsPermission.createImmutable((short)0640));
  List<AclEntry> aclSpec = Lists.newArrayList(
    aclEntry(ACCESS, USER, ALL),
    aclEntry(ACCESS, USER, "foo", ALL),
    aclEntry(ACCESS, USER, "bar", READ_WRITE),
    aclEntry(ACCESS, GROUP, READ_WRITE),
    aclEntry(ACCESS, OTHER, NONE));
  fs.setAcl(path, aclSpec);
  aclSpec = Lists.newArrayList(
    aclEntry(ACCESS, USER, "foo"));
  fs.removeAclEntries(path, aclSpec);
  AclStatus s = fs.getAclStatus(path);
  AclEntry[] returned = s.getEntries().toArray(new AclEntry[0]);
  assertArrayEquals(new AclEntry[] {
    aclEntry(ACCESS, USER, "bar", READ_WRITE),
    aclEntry(ACCESS, GROUP, READ_WRITE) }, returned);
  assertPermission((short)010760);
  assertAclFeature(true);
}
项目:hadoop    文件:FSAclBaseTest.java   
@Test
public void testRemoveAclEntriesMinimal() throws IOException {
  fs.create(path).close();
  fs.setPermission(path, FsPermission.createImmutable((short)0760));
  List<AclEntry> aclSpec = Lists.newArrayList(
    aclEntry(ACCESS, USER, ALL),
    aclEntry(ACCESS, USER, "foo", ALL),
    aclEntry(ACCESS, GROUP, READ_WRITE),
    aclEntry(ACCESS, OTHER, NONE));
  fs.setAcl(path, aclSpec);
  aclSpec = Lists.newArrayList(
    aclEntry(ACCESS, USER, "foo"),
    aclEntry(ACCESS, MASK));
  fs.removeAclEntries(path, aclSpec);
  AclStatus s = fs.getAclStatus(path);
  AclEntry[] returned = s.getEntries().toArray(new AclEntry[0]);
  assertArrayEquals(new AclEntry[] { }, returned);
  assertPermission((short)0760);
  assertAclFeature(false);
}
项目:hadoop    文件:FSAclBaseTest.java   
@Test
public void testRemoveAclEntriesMinimalDefault() throws IOException {
  FileSystem.mkdirs(fs, path, FsPermission.createImmutable((short)0750));
  List<AclEntry> aclSpec = Lists.newArrayList(
    aclEntry(ACCESS, USER, ALL),
    aclEntry(ACCESS, USER, "foo", ALL),
    aclEntry(ACCESS, GROUP, READ_EXECUTE),
    aclEntry(ACCESS, OTHER, NONE),
    aclEntry(DEFAULT, USER, "foo", ALL));
  fs.setAcl(path, aclSpec);
  aclSpec = Lists.newArrayList(
    aclEntry(ACCESS, USER, "foo"),
    aclEntry(ACCESS, MASK),
    aclEntry(DEFAULT, USER, "foo"),
    aclEntry(DEFAULT, MASK));
  fs.removeAclEntries(path, aclSpec);
  AclStatus s = fs.getAclStatus(path);
  AclEntry[] returned = s.getEntries().toArray(new AclEntry[0]);
  assertArrayEquals(new AclEntry[] {
    aclEntry(DEFAULT, USER, ALL),
    aclEntry(DEFAULT, GROUP, READ_EXECUTE),
    aclEntry(DEFAULT, OTHER, NONE) }, returned);
  assertPermission((short)010750);
  assertAclFeature(true);
}
项目:hadoop    文件:FSAclBaseTest.java   
@Test
public void testRemoveAclEntriesStickyBit() throws IOException {
  FileSystem.mkdirs(fs, path, FsPermission.createImmutable((short)01750));
  List<AclEntry> aclSpec = Lists.newArrayList(
    aclEntry(ACCESS, USER, ALL),
    aclEntry(ACCESS, USER, "foo", ALL),
    aclEntry(ACCESS, GROUP, READ_EXECUTE),
    aclEntry(ACCESS, OTHER, NONE),
    aclEntry(DEFAULT, USER, "foo", ALL));
  fs.setAcl(path, aclSpec);
  aclSpec = Lists.newArrayList(
    aclEntry(ACCESS, USER, "foo"),
    aclEntry(DEFAULT, USER, "foo"));
  fs.removeAclEntries(path, aclSpec);
  AclStatus s = fs.getAclStatus(path);
  AclEntry[] returned = s.getEntries().toArray(new AclEntry[0]);
  assertArrayEquals(new AclEntry[] {
    aclEntry(ACCESS, GROUP, READ_EXECUTE),
    aclEntry(DEFAULT, USER, ALL),
    aclEntry(DEFAULT, GROUP, READ_EXECUTE),
    aclEntry(DEFAULT, MASK, READ_EXECUTE),
    aclEntry(DEFAULT, OTHER, NONE) }, returned);
  assertPermission((short)011750);
  assertAclFeature(true);
}
项目:hadoop    文件:FSAclBaseTest.java   
@Test
public void testRemoveDefaultAcl() throws Exception {
  FileSystem.mkdirs(fs, path, FsPermission.createImmutable((short)0750));
  List<AclEntry> aclSpec = Lists.newArrayList(
    aclEntry(ACCESS, USER, ALL),
    aclEntry(ACCESS, USER, "foo", ALL),
    aclEntry(ACCESS, GROUP, READ_EXECUTE),
    aclEntry(ACCESS, OTHER, NONE),
    aclEntry(DEFAULT, USER, "foo", ALL));
  fs.setAcl(path, aclSpec);
  fs.removeDefaultAcl(path);
  AclStatus s = fs.getAclStatus(path);
  AclEntry[] returned = s.getEntries().toArray(new AclEntry[0]);
  assertArrayEquals(new AclEntry[] {
    aclEntry(ACCESS, USER, "foo", ALL),
    aclEntry(ACCESS, GROUP, READ_EXECUTE) }, returned);
  assertPermission((short)010770);
  assertAclFeature(true);
  // restart of the cluster
  restartCluster();
  s = fs.getAclStatus(path);
  AclEntry[] afterRestart = s.getEntries().toArray(new AclEntry[0]);
  assertArrayEquals(returned, afterRestart);
}
项目:hadoop    文件:FSAclBaseTest.java   
@Test
public void testRemoveDefaultAclOnlyAccess() throws Exception {
  fs.create(path).close();
  fs.setPermission(path, FsPermission.createImmutable((short)0640));
  List<AclEntry> aclSpec = Lists.newArrayList(
    aclEntry(ACCESS, USER, ALL),
    aclEntry(ACCESS, USER, "foo", ALL),
    aclEntry(ACCESS, GROUP, READ_EXECUTE),
    aclEntry(ACCESS, OTHER, NONE));
  fs.setAcl(path, aclSpec);
  fs.removeDefaultAcl(path);
  AclStatus s = fs.getAclStatus(path);
  AclEntry[] returned = s.getEntries().toArray(new AclEntry[0]);
  assertArrayEquals(new AclEntry[] {
    aclEntry(ACCESS, USER, "foo", ALL),
    aclEntry(ACCESS, GROUP, READ_EXECUTE) }, returned);
  assertPermission((short)010770);
  assertAclFeature(true);
  // restart of the cluster
  restartCluster();
  s = fs.getAclStatus(path);
  AclEntry[] afterRestart = s.getEntries().toArray(new AclEntry[0]);
  assertArrayEquals(returned, afterRestart);
}
项目:hadoop    文件:FSAclBaseTest.java   
@Test
public void testRemoveDefaultAclOnlyDefault() throws Exception {
  FileSystem.mkdirs(fs, path, FsPermission.createImmutable((short)0750));
  List<AclEntry> aclSpec = Lists.newArrayList(
    aclEntry(DEFAULT, USER, "foo", ALL));
  fs.setAcl(path, aclSpec);
  fs.removeDefaultAcl(path);
  AclStatus s = fs.getAclStatus(path);
  AclEntry[] returned = s.getEntries().toArray(new AclEntry[0]);
  assertArrayEquals(new AclEntry[] { }, returned);
  assertPermission((short)0750);
  assertAclFeature(false);
  // restart of the cluster
  restartCluster();
  s = fs.getAclStatus(path);
  AclEntry[] afterRestart = s.getEntries().toArray(new AclEntry[0]);
  assertArrayEquals(returned, afterRestart);
}
项目:hadoop    文件:FSAclBaseTest.java   
@Test
public void testRemoveDefaultAclStickyBit() throws Exception {
  FileSystem.mkdirs(fs, path, FsPermission.createImmutable((short)01750));
  List<AclEntry> aclSpec = Lists.newArrayList(
    aclEntry(ACCESS, USER, ALL),
    aclEntry(ACCESS, USER, "foo", ALL),
    aclEntry(ACCESS, GROUP, READ_EXECUTE),
    aclEntry(ACCESS, OTHER, NONE),
    aclEntry(DEFAULT, USER, "foo", ALL));
  fs.setAcl(path, aclSpec);
  fs.removeDefaultAcl(path);
  AclStatus s = fs.getAclStatus(path);
  AclEntry[] returned = s.getEntries().toArray(new AclEntry[0]);
  assertArrayEquals(new AclEntry[] {
    aclEntry(ACCESS, USER, "foo", ALL),
    aclEntry(ACCESS, GROUP, READ_EXECUTE) }, returned);
  assertPermission((short)011770);
  assertAclFeature(true);
  // restart of the cluster
  restartCluster();
  s = fs.getAclStatus(path);
  AclEntry[] afterRestart = s.getEntries().toArray(new AclEntry[0]);
  assertArrayEquals(returned, afterRestart);
}
项目:hadoop    文件:FSAclBaseTest.java   
@Test
public void testRemoveAclOnlyDefault() throws IOException {
  FileSystem.mkdirs(fs, path, FsPermission.createImmutable((short)0750));
  List<AclEntry> aclSpec = Lists.newArrayList(
    aclEntry(ACCESS, USER, ALL),
    aclEntry(ACCESS, GROUP, READ_EXECUTE),
    aclEntry(ACCESS, OTHER, NONE),
    aclEntry(DEFAULT, USER, "foo", ALL));
  fs.setAcl(path, aclSpec);
  fs.removeAcl(path);
  AclStatus s = fs.getAclStatus(path);
  AclEntry[] returned = s.getEntries().toArray(new AclEntry[0]);
  assertArrayEquals(new AclEntry[] { }, returned);
  assertPermission((short)0750);
  assertAclFeature(false);
}
项目:hadoop    文件:FSAclBaseTest.java   
@Test
public void testSetAcl() throws IOException {
  FileSystem.mkdirs(fs, path, FsPermission.createImmutable((short)0750));
  List<AclEntry> aclSpec = Lists.newArrayList(
    aclEntry(ACCESS, USER, ALL),
    aclEntry(ACCESS, USER, "foo", ALL),
    aclEntry(ACCESS, GROUP, READ_EXECUTE),
    aclEntry(ACCESS, OTHER, NONE),
    aclEntry(DEFAULT, USER, "foo", ALL));
  fs.setAcl(path, aclSpec);
  AclStatus s = fs.getAclStatus(path);
  AclEntry[] returned = s.getEntries().toArray(new AclEntry[0]);
  assertArrayEquals(new AclEntry[] {
    aclEntry(ACCESS, USER, "foo", ALL),
    aclEntry(ACCESS, GROUP, READ_EXECUTE),
    aclEntry(DEFAULT, USER, ALL),
    aclEntry(DEFAULT, USER, "foo", ALL),
    aclEntry(DEFAULT, GROUP, READ_EXECUTE),
    aclEntry(DEFAULT, MASK, ALL),
    aclEntry(DEFAULT, OTHER, NONE) }, returned);
  assertPermission((short)010770);
  assertAclFeature(true);
}
项目:hadoop    文件:FSAclBaseTest.java   
@Test
public void testSetAclOnlyAccess() throws IOException {
  fs.create(path).close();
  fs.setPermission(path, FsPermission.createImmutable((short)0640));
  List<AclEntry> aclSpec = Lists.newArrayList(
    aclEntry(ACCESS, USER, READ_WRITE),
    aclEntry(ACCESS, USER, "foo", READ),
    aclEntry(ACCESS, GROUP, READ),
    aclEntry(ACCESS, OTHER, NONE));
  fs.setAcl(path, aclSpec);
  AclStatus s = fs.getAclStatus(path);
  AclEntry[] returned = s.getEntries().toArray(new AclEntry[0]);
  assertArrayEquals(new AclEntry[] {
    aclEntry(ACCESS, USER, "foo", READ),
    aclEntry(ACCESS, GROUP, READ) }, returned);
  assertPermission((short)010640);
  assertAclFeature(true);
}
项目:hadoop    文件:FSAclBaseTest.java   
@Test
public void testSetAclOnlyDefault() throws IOException {
  FileSystem.mkdirs(fs, path, FsPermission.createImmutable((short)0750));
  List<AclEntry> aclSpec = Lists.newArrayList(
    aclEntry(DEFAULT, USER, "foo", ALL));
  fs.setAcl(path, aclSpec);
  AclStatus s = fs.getAclStatus(path);
  AclEntry[] returned = s.getEntries().toArray(new AclEntry[0]);
  assertArrayEquals(new AclEntry[] {
    aclEntry(DEFAULT, USER, ALL),
    aclEntry(DEFAULT, USER, "foo", ALL),
    aclEntry(DEFAULT, GROUP, READ_EXECUTE),
    aclEntry(DEFAULT, MASK, ALL),
    aclEntry(DEFAULT, OTHER, NONE) }, returned);
  assertPermission((short)010750);
  assertAclFeature(true);
}
项目:hadoop    文件:FSAclBaseTest.java   
@Test
public void testSetAclMinimalDefault() throws IOException {
  FileSystem.mkdirs(fs, path, FsPermission.createImmutable((short)0750));
  List<AclEntry> aclSpec = Lists.newArrayList(
    aclEntry(DEFAULT, USER, ALL),
    aclEntry(DEFAULT, GROUP, READ_EXECUTE),
    aclEntry(DEFAULT, OTHER, NONE));
  fs.setAcl(path, aclSpec);
  AclStatus s = fs.getAclStatus(path);
  AclEntry[] returned = s.getEntries().toArray(new AclEntry[0]);
  assertArrayEquals(new AclEntry[] {
    aclEntry(DEFAULT, USER, ALL),
    aclEntry(DEFAULT, GROUP, READ_EXECUTE),
    aclEntry(DEFAULT, OTHER, NONE) }, returned);
  assertPermission((short)010750);
  assertAclFeature(true);
}
项目:hadoop    文件:FSAclBaseTest.java   
@Test
public void testSetAclCustomMask() throws IOException {
  fs.create(path).close();
  fs.setPermission(path, FsPermission.createImmutable((short)0640));
  List<AclEntry> aclSpec = Lists.newArrayList(
    aclEntry(ACCESS, USER, READ_WRITE),
    aclEntry(ACCESS, USER, "foo", READ),
    aclEntry(ACCESS, GROUP, READ),
    aclEntry(ACCESS, MASK, ALL),
    aclEntry(ACCESS, OTHER, NONE));
  fs.setAcl(path, aclSpec);
  AclStatus s = fs.getAclStatus(path);
  AclEntry[] returned = s.getEntries().toArray(new AclEntry[0]);
  assertArrayEquals(new AclEntry[] {
    aclEntry(ACCESS, USER, "foo", READ),
    aclEntry(ACCESS, GROUP, READ) }, returned);
  assertPermission((short)010670);
  assertAclFeature(true);
}
项目:hadoop    文件:FSAclBaseTest.java   
@Test
public void testSetPermission() throws IOException {
  FileSystem.mkdirs(fs, path, FsPermission.createImmutable((short)0750));
  List<AclEntry> aclSpec = Lists.newArrayList(
    aclEntry(ACCESS, USER, ALL),
    aclEntry(ACCESS, USER, "foo", ALL),
    aclEntry(ACCESS, GROUP, READ_EXECUTE),
    aclEntry(ACCESS, OTHER, NONE),
    aclEntry(DEFAULT, USER, "foo", ALL));
  fs.setAcl(path, aclSpec);
  fs.setPermission(path, FsPermission.createImmutable((short)0700));
  AclStatus s = fs.getAclStatus(path);
  AclEntry[] returned = s.getEntries().toArray(new AclEntry[0]);
  assertArrayEquals(new AclEntry[] {
    aclEntry(ACCESS, USER, "foo", ALL),
    aclEntry(ACCESS, GROUP, READ_EXECUTE),
    aclEntry(DEFAULT, USER, ALL),
    aclEntry(DEFAULT, USER, "foo", ALL),
    aclEntry(DEFAULT, GROUP, READ_EXECUTE),
    aclEntry(DEFAULT, MASK, ALL),
    aclEntry(DEFAULT, OTHER, NONE) }, returned);
  assertPermission((short)010700);
  assertAclFeature(true);
}
项目:hadoop    文件:FSAclBaseTest.java   
@Test
public void testSetPermissionOnlyAccess() throws IOException {
  fs.create(path).close();
  fs.setPermission(path, FsPermission.createImmutable((short)0640));
  List<AclEntry> aclSpec = Lists.newArrayList(
    aclEntry(ACCESS, USER, READ_WRITE),
    aclEntry(ACCESS, USER, "foo", READ),
    aclEntry(ACCESS, GROUP, READ),
    aclEntry(ACCESS, OTHER, NONE));
  fs.setAcl(path, aclSpec);
  fs.setPermission(path, FsPermission.createImmutable((short)0600));
  AclStatus s = fs.getAclStatus(path);
  AclEntry[] returned = s.getEntries().toArray(new AclEntry[0]);
  assertArrayEquals(new AclEntry[] {
    aclEntry(ACCESS, USER, "foo", READ),
    aclEntry(ACCESS, GROUP, READ) }, returned);
  assertPermission((short)010600);
  assertAclFeature(true);
}
项目:hadoop    文件:FSAclBaseTest.java   
@Test
public void testSetPermissionOnlyDefault() throws IOException {
  FileSystem.mkdirs(fs, path, FsPermission.createImmutable((short)0750));
  List<AclEntry> aclSpec = Lists.newArrayList(
    aclEntry(ACCESS, USER, ALL),
    aclEntry(ACCESS, GROUP, READ_EXECUTE),
    aclEntry(ACCESS, OTHER, NONE),
    aclEntry(DEFAULT, USER, "foo", ALL));
  fs.setAcl(path, aclSpec);
  fs.setPermission(path, FsPermission.createImmutable((short)0700));
  AclStatus s = fs.getAclStatus(path);
  AclEntry[] returned = s.getEntries().toArray(new AclEntry[0]);
  assertArrayEquals(new AclEntry[] {
    aclEntry(DEFAULT, USER, ALL),
    aclEntry(DEFAULT, USER, "foo", ALL),
    aclEntry(DEFAULT, GROUP, READ_EXECUTE),
    aclEntry(DEFAULT, MASK, ALL),
    aclEntry(DEFAULT, OTHER, NONE) }, returned);
  assertPermission((short)010700);
  assertAclFeature(true);
}
项目:hadoop    文件:FSAclBaseTest.java   
@Test
public void testDefaultAclNewFile() throws Exception {
  FileSystem.mkdirs(fs, path, FsPermission.createImmutable((short)0750));
  List<AclEntry> aclSpec = Lists.newArrayList(
    aclEntry(DEFAULT, USER, "foo", ALL));
  fs.setAcl(path, aclSpec);
  Path filePath = new Path(path, "file1");
  fs.create(filePath).close();
  AclStatus s = fs.getAclStatus(filePath);
  AclEntry[] returned = s.getEntries().toArray(new AclEntry[0]);
  assertArrayEquals(new AclEntry[] {
    aclEntry(ACCESS, USER, "foo", ALL),
    aclEntry(ACCESS, GROUP, READ_EXECUTE) }, returned);
  assertPermission(filePath, (short)010640);
  assertAclFeature(filePath, true);
}
项目:hadoop    文件:FSAclBaseTest.java   
@Test
public void testDefaultMinimalAclNewFile() throws Exception {
  FileSystem.mkdirs(fs, path, FsPermission.createImmutable((short)0750));
  List<AclEntry> aclSpec = Lists.newArrayList(
    aclEntry(DEFAULT, USER, ALL),
    aclEntry(DEFAULT, GROUP, READ_EXECUTE),
    aclEntry(DEFAULT, OTHER, NONE));
  fs.setAcl(path, aclSpec);
  Path filePath = new Path(path, "file1");
  fs.create(filePath).close();
  AclStatus s = fs.getAclStatus(filePath);
  AclEntry[] returned = s.getEntries().toArray(new AclEntry[0]);
  assertArrayEquals(new AclEntry[] { }, returned);
  assertPermission(filePath, (short)0640);
  assertAclFeature(filePath, false);
}
项目:hadoop    文件:FSAclBaseTest.java   
@Test
public void testDefaultAclNewDir() throws Exception {
  FileSystem.mkdirs(fs, path, FsPermission.createImmutable((short)0750));
  List<AclEntry> aclSpec = Lists.newArrayList(
    aclEntry(DEFAULT, USER, "foo", ALL));
  fs.setAcl(path, aclSpec);
  Path dirPath = new Path(path, "dir1");
  fs.mkdirs(dirPath);
  AclStatus s = fs.getAclStatus(dirPath);
  AclEntry[] returned = s.getEntries().toArray(new AclEntry[0]);
  assertArrayEquals(new AclEntry[] {
    aclEntry(ACCESS, USER, "foo", ALL),
    aclEntry(ACCESS, GROUP, READ_EXECUTE),
    aclEntry(DEFAULT, USER, ALL),
    aclEntry(DEFAULT, USER, "foo", ALL),
    aclEntry(DEFAULT, GROUP, READ_EXECUTE),
    aclEntry(DEFAULT, MASK, ALL),
    aclEntry(DEFAULT, OTHER, NONE) }, returned);
  assertPermission(dirPath, (short)010750);
  assertAclFeature(dirPath, true);
}
项目:hadoop    文件:FSAclBaseTest.java   
@Test
public void testDefaultMinimalAclNewDir() throws Exception {
  FileSystem.mkdirs(fs, path, FsPermission.createImmutable((short)0750));
  List<AclEntry> aclSpec = Lists.newArrayList(
    aclEntry(DEFAULT, USER, ALL),
    aclEntry(DEFAULT, GROUP, READ_EXECUTE),
    aclEntry(DEFAULT, OTHER, NONE));
  fs.setAcl(path, aclSpec);
  Path dirPath = new Path(path, "dir1");
  fs.mkdirs(dirPath);
  AclStatus s = fs.getAclStatus(dirPath);
  AclEntry[] returned = s.getEntries().toArray(new AclEntry[0]);
  assertArrayEquals(new AclEntry[] {
    aclEntry(DEFAULT, USER, ALL),
    aclEntry(DEFAULT, GROUP, READ_EXECUTE),
    aclEntry(DEFAULT, OTHER, NONE) }, returned);
  assertPermission(dirPath, (short)010750);
  assertAclFeature(dirPath, true);
}
项目:hadoop    文件:FSAclBaseTest.java   
@Test
public void testDefaultAclNewDirWithMode() throws Exception {
  FileSystem.mkdirs(fs, path, FsPermission.createImmutable((short)0755));
  List<AclEntry> aclSpec = Lists.newArrayList(
    aclEntry(DEFAULT, USER, "foo", ALL));
  fs.setAcl(path, aclSpec);
  Path dirPath = new Path(path, "dir1");
  fs.mkdirs(dirPath, new FsPermission((short)0740));
  AclStatus s = fs.getAclStatus(dirPath);
  AclEntry[] returned = s.getEntries().toArray(new AclEntry[0]);
  assertArrayEquals(new AclEntry[] {
    aclEntry(ACCESS, USER, "foo", ALL),
    aclEntry(ACCESS, GROUP, READ_EXECUTE),
    aclEntry(DEFAULT, USER, ALL),
    aclEntry(DEFAULT, USER, "foo", ALL),
    aclEntry(DEFAULT, GROUP, READ_EXECUTE),
    aclEntry(DEFAULT, MASK, ALL),
    aclEntry(DEFAULT, OTHER, READ_EXECUTE) }, returned);
  assertPermission(dirPath, (short)010740);
  assertAclFeature(dirPath, true);
}
项目:hadoop    文件:FSAclBaseTest.java   
@Test
public void testDefaultAclRenamedFile() throws Exception {
  Path dirPath = new Path(path, "dir");
  FileSystem.mkdirs(fs, dirPath, FsPermission.createImmutable((short)0750));
  List<AclEntry> aclSpec = Lists.newArrayList(
    aclEntry(DEFAULT, USER, "foo", ALL));
  fs.setAcl(dirPath, aclSpec);
  Path filePath = new Path(path, "file1");
  fs.create(filePath).close();
  fs.setPermission(filePath, FsPermission.createImmutable((short)0640));
  Path renamedFilePath = new Path(dirPath, "file1");
  fs.rename(filePath, renamedFilePath);
  AclEntry[] expected = new AclEntry[] { };
  AclStatus s = fs.getAclStatus(renamedFilePath);
  AclEntry[] returned = s.getEntries().toArray(new AclEntry[0]);
  assertArrayEquals(expected, returned);
  assertPermission(renamedFilePath, (short)0640);
  assertAclFeature(renamedFilePath, false);
}
项目:hadoop    文件:FSAclBaseTest.java   
@Test
public void testDefaultAclRenamedDir() throws Exception {
  Path dirPath = new Path(path, "dir");
  FileSystem.mkdirs(fs, dirPath, FsPermission.createImmutable((short)0750));
  List<AclEntry> aclSpec = Lists.newArrayList(
    aclEntry(DEFAULT, USER, "foo", ALL));
  fs.setAcl(dirPath, aclSpec);
  Path subdirPath = new Path(path, "subdir");
  FileSystem.mkdirs(fs, subdirPath, FsPermission.createImmutable((short)0750));
  Path renamedSubdirPath = new Path(dirPath, "subdir");
  fs.rename(subdirPath, renamedSubdirPath);
  AclEntry[] expected = new AclEntry[] { };
  AclStatus s = fs.getAclStatus(renamedSubdirPath);
  AclEntry[] returned = s.getEntries().toArray(new AclEntry[0]);
  assertArrayEquals(expected, returned);
  assertPermission(renamedSubdirPath, (short)0750);
  assertAclFeature(renamedSubdirPath, false);
}
项目:hadoop    文件:TestAclWithSnapshot.java   
private static void doSnapshotRootChangeAssertions(Path path,
    Path snapshotPath) throws Exception {
  AclStatus s = hdfs.getAclStatus(path);
  AclEntry[] returned = s.getEntries().toArray(new AclEntry[0]);
  assertArrayEquals(new AclEntry[] {
    aclEntry(ACCESS, USER, "diana", READ_EXECUTE),
    aclEntry(ACCESS, GROUP, NONE) }, returned);
  assertPermission((short)010550, path);

  s = hdfs.getAclStatus(snapshotPath);
  returned = s.getEntries().toArray(new AclEntry[0]);
  assertArrayEquals(new AclEntry[] {
    aclEntry(ACCESS, USER, "bruce", READ_EXECUTE),
    aclEntry(ACCESS, GROUP, NONE) }, returned);
  assertPermission((short)010750, snapshotPath);

  assertDirPermissionDenied(fsAsBruce, BRUCE, path);
  assertDirPermissionGranted(fsAsDiana, DIANA, path);
  assertDirPermissionGranted(fsAsBruce, BRUCE, snapshotPath);
  assertDirPermissionDenied(fsAsDiana, DIANA, snapshotPath);
}
项目:hadoop    文件:TestAclWithSnapshot.java   
private static void doSnapshotRootRemovalAssertions(Path path,
    Path snapshotPath) throws Exception {
  AclStatus s = hdfs.getAclStatus(path);
  AclEntry[] returned = s.getEntries().toArray(new AclEntry[0]);
  assertArrayEquals(new AclEntry[] { }, returned);
  assertPermission((short)0700, path);

  s = hdfs.getAclStatus(snapshotPath);
  returned = s.getEntries().toArray(new AclEntry[0]);
  assertArrayEquals(new AclEntry[] {
    aclEntry(ACCESS, USER, "bruce", READ_EXECUTE),
    aclEntry(ACCESS, GROUP, NONE) }, returned);
  assertPermission((short)010750, snapshotPath);

  assertDirPermissionDenied(fsAsBruce, BRUCE, path);
  assertDirPermissionDenied(fsAsDiana, DIANA, path);
  assertDirPermissionGranted(fsAsBruce, BRUCE, snapshotPath);
  assertDirPermissionDenied(fsAsDiana, DIANA, snapshotPath);
}
项目:hadoop    文件:TestAclWithSnapshot.java   
@Test
public void testRemoveReadsCurrentState() throws Exception {
  FileSystem.mkdirs(hdfs, path, FsPermission.createImmutable((short)0700));

  SnapshotTestHelper.createSnapshot(hdfs, path, snapshotName);

  List<AclEntry> aclSpec = Lists.newArrayList(
    aclEntry(ACCESS, USER, "bruce", ALL));
  hdfs.modifyAclEntries(path, aclSpec);

  hdfs.removeAcl(path);

  AclEntry[] expected = new AclEntry[] { };
  AclStatus s = hdfs.getAclStatus(path);
  AclEntry[] returned = s.getEntries().toArray(new AclEntry[0]);
  assertArrayEquals(expected, returned);
  assertPermission((short)0700, path);
  assertDirPermissionDenied(fsAsBruce, BRUCE, path);
  assertDirPermissionDenied(fsAsDiana, DIANA, path);
}
项目:hadoop-oss    文件:AclCommands.java   
@Override
protected void processPath(PathData item) throws IOException {
  out.println("# file: " + item);
  out.println("# owner: " + item.stat.getOwner());
  out.println("# group: " + item.stat.getGroup());
  FsPermission perm = item.stat.getPermission();
  if (perm.getStickyBit()) {
    out.println("# flags: --" +
      (perm.getOtherAction().implies(FsAction.EXECUTE) ? "t" : "T"));
  }

  AclStatus aclStatus = null;
  List<AclEntry> entries = null;
  if (perm.getAclBit()) {
    aclStatus = item.fs.getAclStatus(item.path);
    entries = aclStatus.getEntries();
  } else {
    aclStatus = null;
    entries = Collections.<AclEntry> emptyList();
  }
  ScopedAclEntries scopedEntries = new ScopedAclEntries(
    AclUtil.getAclFromPermAndEntries(perm, entries));
  printAclEntriesForSingleScope(aclStatus, perm,
      scopedEntries.getAccessEntries());
  printAclEntriesForSingleScope(aclStatus, perm,
      scopedEntries.getDefaultEntries());
  out.println();
}
项目:hadoop    文件:TestAclCommands.java   
public AclStatus getAclStatus(Path path) throws IOException {
  if (getConf().getBoolean("stubfs.noRpcForGetAclStatus", false)) {
    throw new RemoteException(RpcNoSuchMethodException.class.getName(),
      "test exception");
  }
  return super.getAclStatus(path);
}
项目:hadoop-oss    文件:ViewFileSystem.java   
@Override
public AclStatus getAclStatus(Path path) throws IOException {
  checkPathIsSlash(path);
  return new AclStatus.Builder().owner(ugi.getUserName())
      .group(ugi.getGroupNames()[0])
      .addEntries(AclUtil.getMinimalAcl(PERMISSION_555))
      .stickyBit(false).build();
}
项目:hadoop    文件:TestAclWithSnapshot.java   
@Test
public void testGetAclStatusDotSnapshotPath() throws Exception {
  hdfs.mkdirs(path);
  SnapshotTestHelper.createSnapshot(hdfs, path, snapshotName);
  AclStatus s = hdfs.getAclStatus(new Path(path, ".snapshot"));
  AclEntry[] returned = s.getEntries().toArray(new AclEntry[0]);
  assertArrayEquals(new AclEntry[] { }, returned);
}
项目:hadoop-oss    文件:FileContext.java   
/**
 * Gets the ACLs of files and directories.
 *
 * @param path Path to get
 * @return RemoteIterator<AclStatus> which returns each AclStatus
 * @throws IOException if an ACL could not be read
 */
public AclStatus getAclStatus(Path path) throws IOException {
  Path absF = fixRelativePart(path);
  return new FSLinkResolver<AclStatus>() {
    @Override
    public AclStatus next(final AbstractFileSystem fs, final Path p)
        throws IOException {
      return fs.getAclStatus(p);
    }
  }.resolve(this, absF);
}