ObjectIdentifierUtils { public static String toString(byte[] oid) throws TLVException { try { TLV obj; try { obj = TLV.fromBER(oid); } catch (TLVException ex) { obj = new TLV(); obj.setTagNum(0x06); obj.setValue(oid); } return ASN1ObjectIdentifier.getInstance(obj.toBER()).getId(); } catch (IllegalArgumentException ex) { throw new TLVException("Failed to parse OID.", ex); } }  static byte[] toByteArray(String oid); static String toString(byte[] oid); static byte[] getValue(String oid);  }
@Test public void testToString() throws Exception { byte[] oid = new byte[]{0x06, 0x08, 0x04, 0x00, 0x7F, 0x00, 0x07, 0x02, 0x02, 0x04}; String expResult = "0.4.0.127.0.7.2.2.4"; String result = ObjectIdentifierUtils.toString(oid); assertEquals(expResult, result); }
@Test public void testToString2() throws Exception { byte[] oid = new byte[]{0x04, 0x00, 0x7F, 0x00, 0x07, 0x02, 0x02, 0x04}; String expResult = "0.4.0.127.0.7.2.2.4"; String result = ObjectIdentifierUtils.toString(oid); assertEquals(expResult, result); }