/** * Converts bytes in the buffer to an OID by reading from the current position to the limit, which assumes the bytes * of the integer are in big-endian order. * * @param encoded buffer containing DER-encoded data where the buffer is positioned at the start of OID bytes and * the limit is set beyond the last byte of OID data. * * @return decoded bytes as an OID. */ public static String decode(final ByteBuffer encoded) { final ByteBuffer buffer = ByteBuffer.wrap(readBuffer(encoded)); final StringBuilder sb = new StringBuilder(); final int firstId = buffer.get(); // CheckStyle:MagicNumber OFF if (firstId < 40) { sb.append("0").append(".").append(firstId).append("."); } else if (firstId < 80) { sb.append("1").append(".").append(firstId - 40).append("."); } else { sb.append("2").append(".").append(firstId - 80).append("."); } // CheckStyle:MagicNumber ON while (buffer.hasRemaining()) { sb.append(readInt(buffer)).append("."); } sb.setLength(sb.length() - 1); return sb.toString(); }
/** * Converts bytes in the buffer to an OID by reading from the current position to the limit, which assumes the bytes * of the integer are in big-endian order. * * @param encoded buffer containing DER-encoded data where the buffer is positioned at the start of OID bytes and * the limit is set beyond the last byte of OID data. * * @return decoded bytes as an OID. */ public static String decode(final ByteBuffer encoded) { final ByteBuffer buffer = ByteBuffer.wrap(readBuffer(encoded)); final StringBuilder sb = new StringBuilder(); final int firstId = buffer.get(); // CheckStyle:MagicNumber OFF if (firstId < 40) { sb.append("0").append(".").append(firstId).append("."); } else if (firstId < 80) { sb.append("1").append(".").append(firstId - 40).append("."); } else { sb.append("2").append(".").append(firstId - 80).append("."); } // CheckStyle:MagicNumber ON while (buffer.hasRemaining()) { sb.append(readInt(buffer)).append("."); } sb.setLength(sb.length() - 1); return sb.toString(); }
/** * Converts bytes in the buffer to an OID by reading from the current position to the limit, which assumes the bytes * of the integer are in big-endian order. * * @param encoded buffer containing DER-encoded data where the buffer is positioned at the start of OID bytes and * the limit is set beyond the last byte of OID data. * * @return decoded bytes as an OID. */ public static String decode(final ByteBuffer encoded) { final ByteBuffer buffer = ByteBuffer.wrap(readBuffer(encoded)); final StringBuilder sb = new StringBuilder(); final int firstId = buffer.get(); // CheckStyle:MagicNumber OFF if (firstId < 40) { sb.append("0").append(".").append(firstId).append("."); } else if (firstId < 80) { sb.append("1").append(".").append(firstId - 40).append("."); } else { sb.append("2").append(".").append(firstId - 80).append("."); } // CheckStyle:MagicNumber ON while (buffer.hasRemaining()) { sb.append(readInt(buffer)).append("."); } sb.setLength(sb.length() - 1); return sb.toString(); }