GlobalIdentifier { public static byte[] toBytes(final String guid) { final StringTokenizer st = new StringTokenizer(guid.substring(1, guid.length() - 1), "-"); final String data1 = st.nextToken(); final String data2 = st.nextToken(); final String data3 = st.nextToken(); final String data4 = st.nextToken(); final String data5 = st.nextToken(); final ByteBuffer guidBuffer = ByteBuffer.allocate(16); putBytes(guidBuffer, LdapUtils.hexDecode(data1.toCharArray()), true); putBytes(guidBuffer, LdapUtils.hexDecode(data2.toCharArray()), true); putBytes(guidBuffer, LdapUtils.hexDecode(data3.toCharArray()), true); putBytes(guidBuffer, LdapUtils.hexDecode(data4.toCharArray()), false); putBytes(guidBuffer, LdapUtils.hexDecode(data5.toCharArray()), false); return guidBuffer.array(); } private  GlobalIdentifier(); static String toString(final byte[] guid); static byte[] toBytes(final String guid);  }
@Test(groups = "ad", dataProvider = "guids") public void testToBytes(final String guidString, final byte[] guid) throws Exception { Assert.assertEquals(guid, GlobalIdentifier.toBytes(guidString)); }