SecurityIdentifier { public static String toString(final byte[] sid) { final ByteBuffer sidBuffer = ByteBuffer.wrap(sid); final StringBuilder sb = new StringBuilder("S"); sb.append("-").append(sidBuffer.get() & 0xFF); final int countSubAuth = sidBuffer.get() & 0xFF; sidBuffer.limit(8); sb.append("-").append(getLong(sidBuffer, true)); for (int i = 0; i < countSubAuth; i++) { sidBuffer.limit(sidBuffer.position() + 4); sb.append("-").append(getLong(sidBuffer, false)); } return sb.toString(); } private  SecurityIdentifier(); static String toString(final byte[] sid); static byte[] toBytes(final String sid);  }
@Test(groups = "ad", dataProvider = "sids") public void testToString(final String sidString, final byte[] sid) throws Exception { Assert.assertEquals(sidString, SecurityIdentifier.toString(sid)); }