示例#1
0
 /** Example SID from "http://www.pcreview.co.uk/forums/thread-1458615.php". */
 public void testConvertStringSidToBinary() throws Exception {
   byte[] expectedSid = {
     (byte) 0x01,
     (byte) 0x05,
     (byte) 0x00,
     (byte) 0x00,
     (byte) 0x00,
     (byte) 0x00,
     (byte) 0x00,
     (byte) 0x05,
     (byte) 0x15,
     (byte) 0x00,
     (byte) 0x00,
     (byte) 0x00,
     (byte) 0xe9,
     (byte) 0x67,
     (byte) 0xbb,
     (byte) 0x98,
     (byte) 0xd6,
     (byte) 0xb7,
     (byte) 0xd7,
     (byte) 0xbf,
     (byte) 0x82,
     (byte) 0x05,
     (byte) 0x1e,
     (byte) 0x6c,
     (byte) 0x28,
     (byte) 0x06,
     (byte) 0x00,
     (byte) 0x00
   };
   byte[] result =
       LdapUtils.convertStringSidToBinary("S-1-5-21-2562418665-3218585558-1813906818-1576");
   assertTrue("incorrect length of array", ArrayUtils.isSameLength(expectedSid, result));
   for (int i = 0; i < result.length; i++) {
     assertEquals("i=" + i + ",", expectedSid[i], result[i]);
   }
 }
示例#2
0
 /** Hand-crafted SID. */
 public void testConvertHandCraftedStringSidToBinary() throws Exception {
   byte[] expectedSid = {
     (byte) 0x01,
     (byte) 0x05,
     (byte) 0x00,
     (byte) 0x00,
     (byte) 0x00,
     (byte) 0x00,
     (byte) 0x00,
     (byte) 0x05,
     (byte) 0x15,
     (byte) 0x00,
     (byte) 0x00,
     (byte) 0x00,
     (byte) 0x01,
     (byte) 0x00,
     (byte) 0x00,
     (byte) 0x00,
     (byte) 0x02,
     (byte) 0x00,
     (byte) 0x00,
     (byte) 0x00,
     (byte) 0x03,
     (byte) 0x00,
     (byte) 0x00,
     (byte) 0x00,
     (byte) 0x04,
     (byte) 0x00,
     (byte) 0x00,
     (byte) 0x00
   };
   byte[] result = LdapUtils.convertStringSidToBinary("S-1-5-21-1-2-3-4");
   assertTrue("incorrect length of array", ArrayUtils.isSameLength(expectedSid, result));
   for (int i = 0; i < result.length; i++) {
     assertEquals("i=" + i + ",", expectedSid[i], result[i]);
   }
 }