DN implements DEREncoder { @Override public byte[] encode() { final List<DEREncoder> typeEncoders = new ArrayList<>(); for (final RDN rdn : rdns) { typeEncoders.add(rdn::encode); } final ConstructedDEREncoder se = new ConstructedDEREncoder( UniversalDERTag.SEQ, typeEncoders.toArray(new DEREncoder[0])); return se.encode(); } DN(final Collection<RDN> names);  DN(final RDN... names); RDN[] getRDNs(); @Override byte[] encode(); static DN decode(final DERBuffer encoded); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString();  }
@Test(groups = "asn1", dataProvider = "dns") public void encode(final byte[] expected, final DN sequence) throws Exception { Assert.assertEquals(sequence.encode(), expected); }