@Test public void testDecodeIA5StringWithData() { String value = Asn1Utils.decodeIA5String(ByteBuffer.wrap(new byte[] { 0x1b, 4, 0x61, 0x72, 0x75, 0x6e })); assertEquals("arun", value); }
public static String decodeIA5String(ByteBuffer buf) { DerId id = DerId.decode(buf); if (!id.matches(DerId.TagClass.UNIVERSAL, DerId.EncodingType.PRIMITIVE, ASN1_IA5STRING_TAG_NUM)) { throw new IllegalArgumentException("Expected IA5String identifier, received " + id); } int len = DerUtils.decodeLength(buf); if (buf.remaining() < len) { throw new IllegalArgumentException("Insufficient content for IA5String"); } byte[] dst = new byte[len]; buf.get(dst); return new String(dst); }
Asn1Utils { public static String decodeIA5String(ByteBuffer buf) { DerId id = DerId.decode(buf); if (!id.matches(DerId.TagClass.UNIVERSAL, DerId.EncodingType.PRIMITIVE, ASN1_IA5STRING_TAG_NUM)) { throw new IllegalArgumentException("Expected IA5String identifier, received " + id); } int len = DerUtils.decodeLength(buf); if (buf.remaining() < len) { throw new IllegalArgumentException("Insufficient content for IA5String"); } byte[] dst = new byte[len]; buf.get(dst); return new String(dst); } }
Asn1Utils { public static String decodeIA5String(ByteBuffer buf) { DerId id = DerId.decode(buf); if (!id.matches(DerId.TagClass.UNIVERSAL, DerId.EncodingType.PRIMITIVE, ASN1_IA5STRING_TAG_NUM)) { throw new IllegalArgumentException("Expected IA5String identifier, received " + id); } int len = DerUtils.decodeLength(buf); if (buf.remaining() < len) { throw new IllegalArgumentException("Insufficient content for IA5String"); } byte[] dst = new byte[len]; buf.get(dst); return new String(dst); } private  Asn1Utils(); }
Asn1Utils { public static String decodeIA5String(ByteBuffer buf) { DerId id = DerId.decode(buf); if (!id.matches(DerId.TagClass.UNIVERSAL, DerId.EncodingType.PRIMITIVE, ASN1_IA5STRING_TAG_NUM)) { throw new IllegalArgumentException("Expected IA5String identifier, received " + id); } int len = DerUtils.decodeLength(buf); if (buf.remaining() < len) { throw new IllegalArgumentException("Insufficient content for IA5String"); } byte[] dst = new byte[len]; buf.get(dst); return new String(dst); } private  Asn1Utils(); static BitSet decodeBitString(ByteBuffer buf); static Date decodeGeneralizedTime(ByteBuffer buf); static String decodeIA5String(ByteBuffer buf); static int decodeInteger(ByteBuffer buf); static short[] decodeOctetString(ByteBuffer buf); static int decodeSequence(ByteBuffer buf); static int encodeBitString(BitSet value, int nbits, ByteBuffer buf); static int encodeGeneralizedTime(Date date, ByteBuffer buf); static int encodeIA5String(String value, ByteBuffer buf); static int encodeInteger(int value, ByteBuffer buf); static int encodeOctetString(short[] octets, ByteBuffer buf); static int encodeSequence(int contentLength, ByteBuffer buf); static int sizeOfBitString(BitSet value, int nbits); static int sizeOfGeneralizedTime(Date date); static int sizeOfIA5String(String value); static int sizeOfInteger(int value); static int sizeOfOctetString(short[] octets); static int sizeOfSequence(int length); }
Asn1Utils { public static String decodeIA5String(ByteBuffer buf) { DerId id = DerId.decode(buf); if (!id.matches(DerId.TagClass.UNIVERSAL, DerId.EncodingType.PRIMITIVE, ASN1_IA5STRING_TAG_NUM)) { throw new IllegalArgumentException("Expected IA5String identifier, received " + id); } int len = DerUtils.decodeLength(buf); if (buf.remaining() < len) { throw new IllegalArgumentException("Insufficient content for IA5String"); } byte[] dst = new byte[len]; buf.get(dst); return new String(dst); } private  Asn1Utils(); static BitSet decodeBitString(ByteBuffer buf); static Date decodeGeneralizedTime(ByteBuffer buf); static String decodeIA5String(ByteBuffer buf); static int decodeInteger(ByteBuffer buf); static short[] decodeOctetString(ByteBuffer buf); static int decodeSequence(ByteBuffer buf); static int encodeBitString(BitSet value, int nbits, ByteBuffer buf); static int encodeGeneralizedTime(Date date, ByteBuffer buf); static int encodeIA5String(String value, ByteBuffer buf); static int encodeInteger(int value, ByteBuffer buf); static int encodeOctetString(short[] octets, ByteBuffer buf); static int encodeSequence(int contentLength, ByteBuffer buf); static int sizeOfBitString(BitSet value, int nbits); static int sizeOfGeneralizedTime(Date date); static int sizeOfIA5String(String value); static int sizeOfInteger(int value); static int sizeOfOctetString(short[] octets); static int sizeOfSequence(int length);  }