org.apache.hadoop.fs.XAttr#getNameSpace ( )源码实例Demo

下面列出了org.apache.hadoop.fs.XAttr#getNameSpace ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: hadoop   文件: XAttrPermissionFilter.java
static void checkPermissionForApi(FSPermissionChecker pc, XAttr xAttr,
    boolean isRawPath)
    throws AccessControlException {
  final boolean isSuperUser = pc.isSuperUser();
  if (xAttr.getNameSpace() == XAttr.NameSpace.USER || 
      (xAttr.getNameSpace() == XAttr.NameSpace.TRUSTED && isSuperUser)) {
    return;
  }
  if (xAttr.getNameSpace() == XAttr.NameSpace.RAW &&
      isRawPath && isSuperUser) {
    return;
  }
  if (XAttrHelper.getPrefixName(xAttr).
      equals(SECURITY_XATTR_UNREADABLE_BY_SUPERUSER)) {
    if (xAttr.getValue() != null) {
      throw new AccessControlException("Attempt to set a value for '" +
          SECURITY_XATTR_UNREADABLE_BY_SUPERUSER +
          "'. Values are not allowed for this xattr.");
    }
    return;
  }
  throw new AccessControlException("User doesn't have permission for xattr: "
      + XAttrHelper.getPrefixName(xAttr));
}
 
源代码2 项目: hadoop   文件: FSDirXAttrOp.java
private static void checkXAttrChangeAccess(
    FSDirectory fsd, INodesInPath iip, XAttr xAttr,
    FSPermissionChecker pc)
    throws AccessControlException {
  if (fsd.isPermissionEnabled() && xAttr.getNameSpace() == XAttr.NameSpace
      .USER) {
    final INode inode = iip.getLastINode();
    if (inode != null &&
        inode.isDirectory() &&
        inode.getFsPermission().getStickyBit()) {
      if (!pc.isSuperUser()) {
        fsd.checkOwner(pc, iip);
      }
    } else {
      fsd.checkPathAccess(pc, iip, FsAction.WRITE);
    }
  }
}
 
源代码3 项目: big-c   文件: XAttrPermissionFilter.java
static void checkPermissionForApi(FSPermissionChecker pc, XAttr xAttr,
    boolean isRawPath)
    throws AccessControlException {
  final boolean isSuperUser = pc.isSuperUser();
  if (xAttr.getNameSpace() == XAttr.NameSpace.USER || 
      (xAttr.getNameSpace() == XAttr.NameSpace.TRUSTED && isSuperUser)) {
    return;
  }
  if (xAttr.getNameSpace() == XAttr.NameSpace.RAW &&
      isRawPath && isSuperUser) {
    return;
  }
  if (XAttrHelper.getPrefixName(xAttr).
      equals(SECURITY_XATTR_UNREADABLE_BY_SUPERUSER)) {
    if (xAttr.getValue() != null) {
      throw new AccessControlException("Attempt to set a value for '" +
          SECURITY_XATTR_UNREADABLE_BY_SUPERUSER +
          "'. Values are not allowed for this xattr.");
    }
    return;
  }
  throw new AccessControlException("User doesn't have permission for xattr: "
      + XAttrHelper.getPrefixName(xAttr));
}
 
源代码4 项目: big-c   文件: FSDirXAttrOp.java
private static void checkXAttrChangeAccess(
    FSDirectory fsd, INodesInPath iip, XAttr xAttr,
    FSPermissionChecker pc)
    throws AccessControlException {
  if (fsd.isPermissionEnabled() && xAttr.getNameSpace() == XAttr.NameSpace
      .USER) {
    final INode inode = iip.getLastINode();
    if (inode != null &&
        inode.isDirectory() &&
        inode.getFsPermission().getStickyBit()) {
      if (!pc.isSuperUser()) {
        fsd.checkOwner(pc, iip);
      }
    } else {
      fsd.checkPathAccess(pc, iip, FsAction.WRITE);
    }
  }
}
 
源代码5 项目: hadoop   文件: FSImageLoader.java
/**
 * Return the JSON formatted XAttrs of the specified file.
 *
 * @param path
 *          a path specifies a file
 * @return JSON formatted XAttrs
 * @throws IOException
 *           if failed to serialize fileStatus to JSON.
 */
String getXAttrs(String path, List<String> names, String encoder)
        throws IOException {

  List<XAttr> xAttrs = getXAttrList(path);
  List<XAttr> filtered;
  if (names == null || names.size() == 0) {
    filtered = xAttrs;
  } else {
    filtered = Lists.newArrayListWithCapacity(names.size());
    for (String name : names) {
      XAttr search = XAttrHelper.buildXAttr(name);

      boolean found = false;
      for (XAttr aXAttr : xAttrs) {
        if (aXAttr.getNameSpace() == search.getNameSpace()
                && aXAttr.getName().equals(search.getName())) {

          filtered.add(aXAttr);
          found = true;
          break;
        }
      }

      if (!found) {
        throw new IOException(
                "At least one of the attributes provided was not found.");
      }
    }

  }
  return JsonUtil.toJsonString(filtered,
          new XAttrEncodingParam(encoder).getEncoding());
}
 
源代码6 项目: hadoop   文件: FSDirXAttrOp.java
static List<XAttr> getXAttrs(FSDirectory fsd, final String srcArg,
                             List<XAttr> xAttrs)
    throws IOException {
  String src = srcArg;
  checkXAttrsConfigFlag(fsd);
  FSPermissionChecker pc = fsd.getPermissionChecker();
  final boolean isRawPath = FSDirectory.isReservedRawName(src);
  boolean getAll = xAttrs == null || xAttrs.isEmpty();
  if (!getAll) {
    XAttrPermissionFilter.checkPermissionForApi(pc, xAttrs, isRawPath);
  }
  byte[][] pathComponents = FSDirectory.getPathComponentsForReservedPath(src);
  src = fsd.resolvePath(pc, src, pathComponents);
  final INodesInPath iip = fsd.getINodesInPath(src, true);
  if (fsd.isPermissionEnabled()) {
    fsd.checkPathAccess(pc, iip, FsAction.READ);
  }
  List<XAttr> all = FSDirXAttrOp.getXAttrs(fsd, src);
  List<XAttr> filteredAll = XAttrPermissionFilter.
      filterXAttrsForApi(pc, all, isRawPath);

  if (getAll) {
    return filteredAll;
  }
  if (filteredAll == null || filteredAll.isEmpty()) {
    return null;
  }
  List<XAttr> toGet = Lists.newArrayListWithCapacity(xAttrs.size());
  for (XAttr xAttr : xAttrs) {
    boolean foundIt = false;
    for (XAttr a : filteredAll) {
      if (xAttr.getNameSpace() == a.getNameSpace() && xAttr.getName().equals(
          a.getName())) {
        toGet.add(a);
        foundIt = true;
        break;
      }
    }
    if (!foundIt) {
      throw new IOException(
          "At least one of the attributes provided was not found.");
    }
  }
  return toGet;
}
 
源代码7 项目: hadoop   文件: FSDirXAttrOp.java
private static boolean isUserVisible(XAttr xAttr) {
  XAttr.NameSpace ns = xAttr.getNameSpace();
  return ns == XAttr.NameSpace.USER || ns == XAttr.NameSpace.TRUSTED;
}
 
源代码8 项目: hadoop   文件: BlockStoragePolicySuite.java
public static boolean isStoragePolicyXAttr(XAttr xattr) {
  return xattr != null && xattr.getNameSpace() == XAttrNS
      && xattr.getName().equals(STORAGE_POLICY_XATTR_NAME);
}
 
源代码9 项目: big-c   文件: FSDirXAttrOp.java
static List<XAttr> getXAttrs(FSDirectory fsd, final String srcArg,
                             List<XAttr> xAttrs)
    throws IOException {
  String src = srcArg;
  checkXAttrsConfigFlag(fsd);
  FSPermissionChecker pc = fsd.getPermissionChecker();
  final boolean isRawPath = FSDirectory.isReservedRawName(src);
  boolean getAll = xAttrs == null || xAttrs.isEmpty();
  if (!getAll) {
    XAttrPermissionFilter.checkPermissionForApi(pc, xAttrs, isRawPath);
  }
  byte[][] pathComponents = FSDirectory.getPathComponentsForReservedPath(src);
  src = fsd.resolvePath(pc, src, pathComponents);
  final INodesInPath iip = fsd.getINodesInPath(src, true);
  if (fsd.isPermissionEnabled()) {
    fsd.checkPathAccess(pc, iip, FsAction.READ);
  }
  List<XAttr> all = FSDirXAttrOp.getXAttrs(fsd, src);
  List<XAttr> filteredAll = XAttrPermissionFilter.
      filterXAttrsForApi(pc, all, isRawPath);

  if (getAll) {
    return filteredAll;
  }
  if (filteredAll == null || filteredAll.isEmpty()) {
    return null;
  }
  List<XAttr> toGet = Lists.newArrayListWithCapacity(xAttrs.size());
  for (XAttr xAttr : xAttrs) {
    boolean foundIt = false;
    for (XAttr a : filteredAll) {
      if (xAttr.getNameSpace() == a.getNameSpace() && xAttr.getName().equals(
          a.getName())) {
        toGet.add(a);
        foundIt = true;
        break;
      }
    }
    if (!foundIt) {
      throw new IOException(
          "At least one of the attributes provided was not found.");
    }
  }
  return toGet;
}
 
源代码10 项目: big-c   文件: FSDirXAttrOp.java
private static boolean isUserVisible(XAttr xAttr) {
  XAttr.NameSpace ns = xAttr.getNameSpace();
  return ns == XAttr.NameSpace.USER || ns == XAttr.NameSpace.TRUSTED;
}
 
源代码11 项目: big-c   文件: BlockStoragePolicySuite.java
public static boolean isStoragePolicyXAttr(XAttr xattr) {
  return xattr != null && xattr.getNameSpace() == XAttrNS
      && xattr.getName().equals(STORAGE_POLICY_XATTR_NAME);
}