/** * Copy constructor * * @param other other permission */ public Permission(final Permission other) { this.set(other.user, other.group, other.other, other.sticky, other.setuid, other.setgid); }
/** * Construct by the given {@link Action}. * * @param u user action * @param g group action * @param o other action */ public Permission(final Action u, final Action g, final Action o) { this.set(u, g, o, false, false, false); }
public Permission(final Action u, final Action g, final Action o, final boolean stickybit, final boolean setuid, final boolean setgid) { this.set(u, g, o, stickybit, setuid, setgid); }
private void set(final Permission other) { this.set(other.user, other.group, other.other, other.sticky, other.setuid, other.setgid); }
public Permission() { this.set(Action.none, Action.none, Action.none, false, false, false); }
private void fromInteger(int n) { Action[] v = Action.values(); set( v[(n >>> 6) & 7], v[(n >>> 3) & 7], v[n & 7], ((n >>> 9) & 1) == 1, ((n >>> 9) & 4) == 4, ((n >>> 9) & 2) == 2 ); }
/** * Modes may be absolute or symbolic. An absolute mode is an octal number constructed from the sum of one or more of the following values: * <p/> * 4000 (the set-user-ID-on-execution bit) Executable files with this bit set will run with effective uid set to the uid of the file owner. * Directories with the set-user-id bit set will force all files and sub-directories created in them to be owned by the directory owner * and not by the uid of the creating process, if the underlying file system supports this feature: see chmod(2) and the suiddir option to * mount(8). * 2000 (the set-group-ID-on-execution bit) Executable files with this bit set will run with effective gid set to the gid of the file owner. * 1000 (the sticky bit) See chmod(2) and sticky(8). * 0400 Allow read by owner. * 0200 Allow write by owner. * 0100 For files, allow execution by owner. For directories, allow the owner to search in the directory. * 0040 Allow read by group members. * 0020 Allow write by group members. * 0010 For files, allow execution by group members. For directories, allow group members to search in the directory. * 0004 Allow read by others. * 0002 Allow write by others. * 0001 For files, allow execution by others. For directories allow others to search in the directory. * * @param mode Mode */ public Permission(final int mode) { try { this.fromInteger(Integer.valueOf(Integer.toString(mode), 8)); } catch(NumberFormatException e) { log.warn(String.format("Failure parsing %s", mode)); this.set(Permission.EMPTY); } }
this.set(Permission.EMPTY);