public byte [ ] toByteArray ( ) { final ByteBuffer buff = ByteBuffer . allocate ( getSize ( ) ) ; // add revision buff . put ( revision ) ; // add reserved buff . put ( ( byte ) 0x00 ) ; // add contro flags buff . put ( controlFlags [ 1 ] ) ; buff . put ( controlFlags [ 0 ] ) ; // add offset owner buff . position ( 4 ) ; int nextAvailablePosition = 20 ; // add owner SID if ( owner == null ) { buff . putInt ( 0 ) ; } else { buff . put ( Hex . reverse ( NumberFacility . getBytes ( nextAvailablePosition ) ) ) ; buff . position ( nextAvailablePosition ) ; buff . put ( owner . toByteArray ( ) ) ; nextAvailablePosition += owner . getSize ( ) ; } // add offset group buff . position ( 8 ) ; // add group SID if ( group == null ) { buff . putInt ( 0 ) ; } else { buff . put ( Hex . reverse ( NumberFacility . getBytes ( nextAvailablePosition ) ) ) ; buff . position ( nextAvailablePosition ) ; buff . put ( group . toByteArray ( ) ) ; nextAvailablePosition += group . getSize ( ) ; } // add offset sacl buff . position ( 12 ) ; // add SACL if ( sacl == null ) { buff . putInt ( 0 ) ; } else { buff . put ( Hex . reverse ( NumberFacility . getBytes ( nextAvailablePosition ) ) ) ; buff . position ( nextAvailablePosition ) ; buff . put ( sacl . toByteArray ( ) ) ; nextAvailablePosition += sacl . getSize ( ) ; } // add offset dacl buff . position ( 16 ) ; // add DACL if ( dacl == null ) { buff . putInt ( 0 ) ; } else { buff . put ( Hex . reverse ( NumberFacility . getBytes ( nextAvailablePosition ) ) ) ; buff . position ( nextAvailablePosition ) ; buff . put ( dacl . toByteArray ( ) ) ; } return buff . array ( ) ; }
Serializes SDDL as byte array .