1 package jcifs.smb; 2 3 import jcifs.util.Hexdump; 4 5 46 47 public class ACE { 48 49 public static final int FILE_READ_DATA = 0x00000001; public static final int FILE_WRITE_DATA = 0x00000002; public static final int FILE_APPEND_DATA = 0x00000004; public static final int FILE_READ_EA = 0x00000008; public static final int FILE_WRITE_EA = 0x00000010; public static final int FILE_EXECUTE = 0x00000020; public static final int FILE_DELETE = 0x00000040; public static final int FILE_READ_ATTRIBUTES = 0x00000080; public static final int FILE_WRITE_ATTRIBUTES = 0x00000100; public static final int DELETE = 0x00010000; public static final int READ_CONTROL = 0x00020000; public static final int WRITE_DAC = 0x00040000; public static final int WRITE_OWNER = 0x00080000; public static final int SYNCHRONIZE = 0x00100000; public static final int GENERIC_ALL = 0x10000000; public static final int GENERIC_EXECUTE = 0x20000000; public static final int GENERIC_WRITE = 0x40000000; public static final int GENERIC_READ = 0x80000000; 68 public static final int FLAGS_OBJECT_INHERIT = 0x01; 69 public static final int FLAGS_CONTAINER_INHERIT = 0x02; 70 public static final int FLAGS_NO_PROPAGATE = 0x04; 71 public static final int FLAGS_INHERIT_ONLY = 0x08; 72 public static final int FLAGS_INHERITED = 0x10; 73 74 boolean allow; 75 int flags; 76 int access; 77 SID sid; 78 79 82 public boolean isAllow() { 83 return allow; 84 } 85 93 public boolean isInherited() { 94 return (flags & FLAGS_INHERITED) != 0; 95 } 96 100 public int getFlags() { 101 return flags; 102 } 103 108 public String getApplyToText() { 109 switch (flags & (FLAGS_OBJECT_INHERIT | FLAGS_CONTAINER_INHERIT | FLAGS_INHERIT_ONLY)) { 110 case 0x00: 111 return "This folder only"; 112 case 0x03: 113 return "This folder, subfolders and files"; 114 case 0x0B: 115 return "Subfolders and files only"; 116 case 0x02: 117 return "This folder and subfolders"; 118 case 0x0A: 119 return "Subfolders only"; 120 case 0x01: 121 return "This folder and files"; 122 case 0x09: 123 return "Files only"; 124 } 125 return "Invalid"; 126 } 127 133 public int getAccessMask() { 134 return access; 135 } 136 137 140 public SID getSID() { 141 return sid; 142 } 143 144 int decode( byte[] buf, int bi ) { 145 allow = buf[bi++] == (byte)0x00; 146 flags = buf[bi++] & 0xFF; 147 int size = ServerMessageBlock.readInt2(buf, bi); 148 bi += 2; 149 access = ServerMessageBlock.readInt4(buf, bi); 150 bi += 4; 151 sid = new SID(buf, bi); 152 return size; 153 } 154 155 void appendCol(StringBuffer sb, String str, int width) { 156 sb.append(str); 157 int count = width - str.length(); 158 for (int i = 0; i < count; i++) { 159 sb.append(' '); 160 } 161 } 162 168 public String toString() { 169 int count, i; 170 String str; 171 172 StringBuffer sb = new StringBuffer (); 173 sb.append( isAllow() ? "Allow " : "Deny " ); 174 appendCol(sb, sid.toDisplayString(), 25); 175 sb.append( " 0x" ).append( Hexdump.toHexString( access, 8 )).append(' '); 176 sb.append(isInherited() ? "Inherited " : "Direct "); 177 appendCol(sb, getApplyToText(), 34); 178 return sb.toString(); 179 } 180 } 181 | Popular Tags |