1 18 19 package jcifs.smb; 20 21 public class SecurityDescriptor { 22 23 public int type; 24 public ACE[] aces; 25 26 public SecurityDescriptor() { 27 } 28 public SecurityDescriptor(byte[] buffer, int bufferIndex, int len) { 29 this.decode(buffer, bufferIndex, len); 30 } 31 public int decode(byte[] buffer, int bufferIndex, int len) { 32 int start = bufferIndex; 33 34 bufferIndex++; bufferIndex++; 36 type = ServerMessageBlock.readInt2(buffer, bufferIndex); 37 bufferIndex += 2; 38 ServerMessageBlock.readInt4(buffer, bufferIndex); bufferIndex += 4; 40 ServerMessageBlock.readInt4(buffer, bufferIndex); bufferIndex += 4; 42 ServerMessageBlock.readInt4(buffer, bufferIndex); bufferIndex += 4; 44 int daclOffset = ServerMessageBlock.readInt4(buffer, bufferIndex); 45 46 bufferIndex = start + daclOffset; 47 48 bufferIndex++; bufferIndex++; 50 int size = ServerMessageBlock.readInt2(buffer, bufferIndex); 51 bufferIndex += 2; 52 int numAces = ServerMessageBlock.readInt4(buffer, bufferIndex); 53 bufferIndex += 4; 54 55 if (numAces > 4096) 56 throw new RuntimeException ( "Invalid SecurityDescriptor" ); 57 58 aces = new ACE[numAces]; 59 for (int i = 0; i < numAces; i++) { 60 aces[i] = new ACE(); 61 bufferIndex += aces[i].decode(buffer, bufferIndex); 62 } 63 64 return bufferIndex - start; 65 } 66 public String toString() { 67 String ret = "SecurityDescriptor:\n"; 68 for (int ai = 0; ai < aces.length; ai++) { 69 ret += aces[ai].toString() + "\n"; 70 } 71 return ret; 72 } 73 } 74 | Popular Tags |