builder.setPermissions(updatedPermissions); iter.set(builder.build());
Set<AclEntryPermission> permissions = acl.permissions().isEmpty() ? new HashSet<AclEntryPermission>() : EnumSet.copyOf(acl.permissions()); permissions.addAll(Arrays.asList(AclEntryPermission.ADD_FILE, AclEntryPermission.ADD_SUBDIRECTORY, AclEntryPermission.LIST_DIRECTORY)); builder.setPermissions(permissions); iter.set(builder.build()); builder.setPermissions(AclEntryPermission.ADD_FILE, AclEntryPermission.ADD_SUBDIRECTORY, AclEntryPermission.LIST_DIRECTORY); builder.setType(AclEntryType.ALLOW); builder.setPrincipal(owner);
@Override public List<AclEntry> value() { AclEntry.Builder builder = AclEntry.newBuilder(); builder.setType(AclEntryType.ALLOW); builder.setPermissions(EnumSet.allOf(AclEntryPermission.class)); builder.setPrincipal(owner); return Collections.singletonList(builder.build()); } });
private static void setWindowsPermissions(Path path) throws IOException { AclFileAttributeView view = Files.getFileAttributeView(path, AclFileAttributeView.class); UserPrincipal owner = view.getOwner(); List<AclEntry> acl = view.getAcl(); ListIterator<AclEntry> it = acl.listIterator(); while (it.hasNext()) { AclEntry entry = it.next(); if ("BUILTIN\\Administrators".equals(entry.principal().getName()) || "NT AUTHORITY\\SYSTEM".equals(entry.principal().getName())) { continue; } it.remove(); } AclEntry entry = AclEntry.newBuilder() .setType(AclEntryType.ALLOW) .setPrincipal(owner) .setPermissions(AclEntryPermission.READ_DATA, AclEntryPermission.WRITE_DATA, AclEntryPermission.APPEND_DATA, AclEntryPermission.READ_NAMED_ATTRS, AclEntryPermission.WRITE_NAMED_ATTRS, AclEntryPermission.EXECUTE, AclEntryPermission.READ_ATTRIBUTES, AclEntryPermission.WRITE_ATTRIBUTES, AclEntryPermission.DELETE, AclEntryPermission.READ_ACL, AclEntryPermission.SYNCHRONIZE) .build(); acl.add(entry); view.setAcl(acl); }
private static void setWindowsPermissions(Path path) throws IOException { AclFileAttributeView view = Files.getFileAttributeView(path, AclFileAttributeView.class); UserPrincipal owner = view.getOwner(); List<AclEntry> acl = view.getAcl(); ListIterator<AclEntry> it = acl.listIterator(); while (it.hasNext()) { AclEntry entry = it.next(); if ("BUILTIN\\Administrators".equals(entry.principal().getName()) || "NT AUTHORITY\\SYSTEM".equals(entry.principal().getName())) { continue; } it.remove(); } AclEntry entry = AclEntry.newBuilder() .setType(AclEntryType.ALLOW) .setPrincipal(owner) .setPermissions(AclEntryPermission.READ_DATA, AclEntryPermission.WRITE_DATA, AclEntryPermission.APPEND_DATA, AclEntryPermission.READ_NAMED_ATTRS, AclEntryPermission.WRITE_NAMED_ATTRS, AclEntryPermission.EXECUTE, AclEntryPermission.READ_ATTRIBUTES, AclEntryPermission.WRITE_ATTRIBUTES, AclEntryPermission.DELETE, AclEntryPermission.READ_ACL, AclEntryPermission.SYNCHRONIZE) .build(); acl.add(entry); view.setAcl(acl); }
private static void setWindowsPermissions(Path path) throws IOException { AclFileAttributeView view = Files.getFileAttributeView(path, AclFileAttributeView.class); UserPrincipal owner = view.getOwner(); List<AclEntry> acl = view.getAcl(); ListIterator<AclEntry> it = acl.listIterator(); while (it.hasNext()) { AclEntry entry = it.next(); if ("BUILTIN\\Administrators".equals(entry.principal().getName()) || "NT AUTHORITY\\SYSTEM".equals(entry.principal().getName())) { continue; } it.remove(); } AclEntry entry = AclEntry.newBuilder() .setType(AclEntryType.ALLOW) .setPrincipal(owner) .setPermissions(AclEntryPermission.READ_DATA, AclEntryPermission.WRITE_DATA, AclEntryPermission.APPEND_DATA, AclEntryPermission.READ_NAMED_ATTRS, AclEntryPermission.WRITE_NAMED_ATTRS, AclEntryPermission.EXECUTE, AclEntryPermission.READ_ATTRIBUTES, AclEntryPermission.WRITE_ATTRIBUTES, AclEntryPermission.DELETE, AclEntryPermission.READ_ACL, AclEntryPermission.SYNCHRONIZE) .build(); acl.add(entry); view.setAcl(acl); }
void fixSshKeyOnWindows(File key) throws GitException { if (launcher.isUnix()) return; Path file = Paths.get(key.toURI()); AclFileAttributeView fileAttributeView = Files.getFileAttributeView(file, AclFileAttributeView.class); if (fileAttributeView == null) return; String username = getWindowsUserName(fileAttributeView); if (StringUtils.isBlank(username)) return; try { UserPrincipalLookupService userPrincipalLookupService = file.getFileSystem().getUserPrincipalLookupService(); UserPrincipal userPrincipal = userPrincipalLookupService.lookupPrincipalByName(username); AclEntry aclEntry = AclEntry.newBuilder() .setType(AclEntryType.ALLOW) .setPrincipal(userPrincipal) .setPermissions(ACL_ENTRY_PERMISSIONS) .build(); fileAttributeView.setAcl(Collections.singletonList(aclEntry)); } catch (IOException | UnsupportedOperationException e) { throw new GitException("Error updating file permission for \"" + key.getAbsolutePath() + "\""); } }
/** * @param path Add "Everyone" with read enabled to this path's Windows ACL permissions. */ public static void setPublic(Path path) throws IOException { UserPrincipal everyone = getDefault().getUserPrincipalLookupService() .lookupPrincipalByName(WINDOWS_EVERYONE); AclFileAttributeView aclFileAttributes = java.nio.file.Files.getFileAttributeView( path, AclFileAttributeView.class); List<AclEntry> list = aclFileAttributes.getAcl(); list.add(AclEntry.newBuilder().setPrincipal(everyone).setPermissions( AclEntryPermission.READ_DATA, AclEntryPermission.READ_ACL, AclEntryPermission.READ_ATTRIBUTES, AclEntryPermission.READ_NAMED_ATTRS) .setType(AclEntryType.ALLOW) .build()); aclFileAttributes.setAcl(list); } }
/** * @param path Add "Everyone" with read enabled to this path's Windows ACL permissions. */ public static void setPublic(Path path) throws IOException { UserPrincipal everyone = getDefault().getUserPrincipalLookupService() .lookupPrincipalByName(WINDOWS_EVERYONE); AclFileAttributeView aclFileAttributes = java.nio.file.Files.getFileAttributeView( path, AclFileAttributeView.class); List<AclEntry> list = aclFileAttributes.getAcl(); list.add(AclEntry.newBuilder().setPrincipal(everyone).setPermissions( AclEntryPermission.READ_DATA, AclEntryPermission.READ_ACL, AclEntryPermission.READ_ATTRIBUTES, AclEntryPermission.READ_NAMED_ATTRS) .setType(AclEntryType.ALLOW) .build()); aclFileAttributes.setAcl(list); } }
/** * @param path Add "Everyone" with read enabled to this path's Windows ACL permissions. */ public static void setPublic(Path path) throws IOException { UserPrincipal everyone = getDefault().getUserPrincipalLookupService() .lookupPrincipalByName(WINDOWS_EVERYONE); AclFileAttributeView aclFileAttributes = java.nio.file.Files.getFileAttributeView( path, AclFileAttributeView.class); List<AclEntry> list = aclFileAttributes.getAcl(); list.add(AclEntry.newBuilder().setPrincipal(everyone).setPermissions( AclEntryPermission.READ_DATA, AclEntryPermission.READ_ACL, AclEntryPermission.READ_ATTRIBUTES, AclEntryPermission.READ_NAMED_ATTRS) .setType(AclEntryType.ALLOW) .build()); aclFileAttributes.setAcl(list); } }
public static AclEntry buildAclEntry(int aclType, int aclFlag, int aclMask, String aclWho) { UserPrincipal who = new DefaultGroupPrincipal(aclWho); return AclEntry.newBuilder() .setType(ValidateUtils.checkNotNull(decodeAclEntryType(aclType), "Unknown ACL type: %d", aclType)) .setFlags(decodeAclFlags(aclFlag)) .setPermissions(decodeAclMask(aclMask)) .setPrincipal(who) .build(); }
public static AclEntry buildAclEntry(int aclType, int aclFlag, int aclMask, String aclWho) { UserPrincipal who = new DefaultGroupPrincipal(aclWho); return AclEntry.newBuilder() .setType(ValidateUtils.checkNotNull(decodeAclEntryType(aclType), "Unknown ACL type: %d", aclType)) .setFlags(decodeAclFlags(aclFlag)) .setPermissions(decodeAclMask(aclMask)) .setPrincipal(who) .build(); }