int parse ( final IntBuffer buff , final int start ) { int pos = start ; // Check for a SID (http://msdn.microsoft.com/en-us/library/cc230371.aspx) final byte [ ] sidHeader = NumberFacility . getBytes ( buff . get ( pos ) ) ; // Revision(1 byte): An 8-bit unsigned integer that specifies the revision level of the SID. // This value MUST be set to 0x01. revision = sidHeader [ 0 ] ; //SubAuthorityCount (1 byte): An 8-bit unsigned integer that specifies the number of elements //in the SubAuthority array. The maximum number of elements allowed is 15. int subAuthorityCount = NumberFacility . getInt ( sidHeader [ 1 ] ) ; // IdentifierAuthority (6 bytes): A SID_IDENTIFIER_AUTHORITY structure that indicates the // authority under which the SID was created. It describes the entity that created the SID. // The Identifier Authority value {0,0,0,0,0,5} denotes SIDs created by the NT SID authority. identifierAuthority = new byte [ 6 ] ; System . arraycopy ( sidHeader , 2 , identifierAuthority , 0 , 2 ) ; pos ++ ; System . arraycopy ( NumberFacility . getBytes ( buff . get ( pos ) ) , 0 , identifierAuthority , 2 , 4 ) ; // SubAuthority (variable): A variable length array of unsigned 32-bit integers that uniquely // identifies a principal relative to the IdentifierAuthority. Its length is determined by // SubAuthorityCount. for ( int j = 0 ; j < subAuthorityCount ; j ++ ) { pos ++ ; subAuthorities . add ( Hex . reverse ( NumberFacility . getBytes ( buff . get ( pos ) ) ) ) ; } return pos ; }
Load the SID from the buffer returning the last SID segment position into the buffer .