Search in sources :

Example 1 with FsPermissionExtension

use of org.apache.hadoop.hdfs.protocol.FsPermissionExtension in project hadoop by apache.

the class HttpFSFileSystem method toFsPermission.

/** Convert a string to a FsPermission object. */
static FsPermission toFsPermission(JSONObject json) {
    final String s = (String) json.get(PERMISSION_JSON);
    final Boolean aclBit = (Boolean) json.get(ACL_BIT_JSON);
    final Boolean encBit = (Boolean) json.get(ENC_BIT_JSON);
    FsPermission perm = new FsPermission(Short.parseShort(s, 8));
    final boolean aBit = (aclBit != null) ? aclBit : false;
    final boolean eBit = (encBit != null) ? encBit : false;
    if (aBit || eBit) {
        return new FsPermissionExtension(perm, aBit, eBit);
    } else {
        return perm;
    }
}
Also used : FsPermissionExtension(org.apache.hadoop.hdfs.protocol.FsPermissionExtension) FsPermission(org.apache.hadoop.fs.permission.FsPermission)

Example 2 with FsPermissionExtension

use of org.apache.hadoop.hdfs.protocol.FsPermissionExtension in project hadoop by apache.

the class JsonUtilClient method toFsPermission.

/** Convert a string to a FsPermission object. */
static FsPermission toFsPermission(final String s, Boolean aclBit, Boolean encBit) {
    FsPermission perm = new FsPermission(Short.parseShort(s, 8));
    final boolean aBit = (aclBit != null) ? aclBit : false;
    final boolean eBit = (encBit != null) ? encBit : false;
    if (aBit || eBit) {
        return new FsPermissionExtension(perm, aBit, eBit);
    } else {
        return perm;
    }
}
Also used : FsPermissionExtension(org.apache.hadoop.hdfs.protocol.FsPermissionExtension) FsPermission(org.apache.hadoop.fs.permission.FsPermission)

Example 3 with FsPermissionExtension

use of org.apache.hadoop.hdfs.protocol.FsPermissionExtension in project hadoop by apache.

the class FSDirStatAndListingOp method getPermissionForFileStatus.

/**
   * Returns an inode's FsPermission for use in an outbound FileStatus.  If the
   * inode has an ACL or is for an encrypted file/dir, then this method will
   * return an FsPermissionExtension.
   *
   * @param node INode to check
   * @param isEncrypted boolean true if the file/dir is encrypted
   * @return FsPermission from inode, with ACL bit on if the inode has an ACL
   * and encrypted bit on if it represents an encrypted file/dir.
   */
private static FsPermission getPermissionForFileStatus(INodeAttributes node, boolean isEncrypted) {
    FsPermission perm = node.getFsPermission();
    boolean hasAcl = node.getAclFeature() != null;
    if (hasAcl || isEncrypted) {
        perm = new FsPermissionExtension(perm, hasAcl, isEncrypted);
    }
    return perm;
}
Also used : FsPermissionExtension(org.apache.hadoop.hdfs.protocol.FsPermissionExtension) FsPermission(org.apache.hadoop.fs.permission.FsPermission)

Example 4 with FsPermissionExtension

use of org.apache.hadoop.hdfs.protocol.FsPermissionExtension in project hadoop by apache.

the class FSAclBaseTest method testSetPermissionCannotSetAclBit.

@Test
public void testSetPermissionCannotSetAclBit() throws IOException {
    FileSystem.mkdirs(fs, path, FsPermission.createImmutable((short) 0750));
    fs.setPermission(path, FsPermission.createImmutable((short) 0700));
    assertPermission((short) 0700);
    fs.setPermission(path, new FsPermissionExtension(FsPermission.createImmutable((short) 0755), true, true));
    INode inode = cluster.getNamesystem().getFSDirectory().getINode(path.toUri().getPath(), DirOp.READ_LINK);
    assertNotNull(inode);
    FsPermission perm = inode.getFsPermission();
    assertNotNull(perm);
    assertEquals(0755, perm.toShort());
    assertEquals(0755, perm.toExtendedShort());
    assertAclFeature(false);
}
Also used : FsPermissionExtension(org.apache.hadoop.hdfs.protocol.FsPermissionExtension) FsPermission(org.apache.hadoop.fs.permission.FsPermission) Test(org.junit.Test)

Aggregations

FsPermission (org.apache.hadoop.fs.permission.FsPermission)4 FsPermissionExtension (org.apache.hadoop.hdfs.protocol.FsPermissionExtension)4 Test (org.junit.Test)1