List of usage examples for org.apache.hadoop.fs.permission AclEntry getScope
public AclEntryScope getScope()
From source file:alluxio.underfs.hdfs.acl.SupportedHdfsAclProvider.java
License:Apache License
@Override public Pair<AccessControlList, DefaultAccessControlList> getAcl(FileSystem hdfs, String path) throws IOException { AclStatus hdfsAcl;// w w w . j a va 2s . c o m Path filePath = new Path(path); boolean isDir = hdfs.isDirectory(filePath); try { hdfsAcl = hdfs.getAclStatus(filePath); } catch (AclException e) { // When dfs.namenode.acls.enabled is false, getAclStatus throws AclException. return new Pair<>(null, null); } AccessControlList acl = new AccessControlList(); DefaultAccessControlList defaultAcl = new DefaultAccessControlList(); acl.setOwningUser(hdfsAcl.getOwner()); acl.setOwningGroup(hdfsAcl.getGroup()); defaultAcl.setOwningUser(hdfsAcl.getOwner()); defaultAcl.setOwningGroup(hdfsAcl.getGroup()); for (AclEntry entry : hdfsAcl.getEntries()) { alluxio.security.authorization.AclEntry.Builder builder = new alluxio.security.authorization.AclEntry.Builder(); builder.setType(getAclEntryType(entry)); builder.setSubject(entry.getName() == null ? "" : entry.getName()); FsAction permission = entry.getPermission(); if (permission.implies(FsAction.READ)) { builder.addAction(AclAction.READ); } else if (permission.implies(FsAction.WRITE)) { builder.addAction(AclAction.WRITE); } else if (permission.implies(FsAction.EXECUTE)) { builder.addAction(AclAction.EXECUTE); } if (entry.getScope().equals(AclEntryScope.ACCESS)) { acl.setEntry(builder.build()); } else { // default ACL, must be a directory defaultAcl.setEntry(builder.build()); } } if (isDir) { return new Pair<>(acl, defaultAcl); } else { // a null defaultACL indicates this is a file return new Pair<>(acl, null); } }
From source file:org.apache.sentry.hdfs.SentryAuthorizationProvider.java
License:Apache License
private void addToACLMap(Map<String, AclEntry> map, Collection<AclEntry> entries) { for (AclEntry ent : entries) { String key = (ent.getName() == null ? "" : ent.getName()) + ent.getScope() + ent.getType(); AclEntry aclEntry = map.get(key); if (aclEntry == null) { map.put(key, ent);/*from w ww.j a v a 2 s .c o m*/ } else { map.put(key, new AclEntry.Builder().setName(ent.getName()).setScope(ent.getScope()) .setType(ent.getType()) .setPermission(ent.getPermission().or(aclEntry.getPermission())).build()); } } }
From source file:org.apache.sentry.hdfs.SentryINodeAttributesProvider.java
License:Apache License
private static void addToACLMap(Map<String, AclEntry> map, Collection<AclEntry> entries) { for (AclEntry ent : entries) { String key = (ent.getName() == null ? "" : ent.getName()) + ent.getScope() + ent.getType(); AclEntry aclEntry = map.get(key); if (aclEntry == null) { map.put(key, ent);//from www.java2 s. c om } else { map.put(key, new AclEntry.Builder().setName(ent.getName()).setScope(ent.getScope()) .setType(ent.getType()) .setPermission(ent.getPermission().or(aclEntry.getPermission())).build()); } } }
From source file:org.trustedanalytics.servicebroker.hdfs.plans.provisioning.HdfsProvisioningClient.java
License:Apache License
private void setAclRecursively(String path, AclEntry acl) throws IOException { superUserHdfsClient.addAclEntry(path, acl); for (String file : superUserHdfsClient.listFiles(path, true)) { if (superUserHdfsClient.isDirectory(file) || !acl.getScope().equals(AclEntryScope.DEFAULT)) superUserHdfsClient.addAclEntry(file, acl); }/*from w ww . jav a2 s . c o m*/ }