public List<String> getValues() { ArrayList<String> list = new ArrayList<String>(); Enumeration e = values.getObjects(); while(e.hasMoreElements()) { list.add(DERUTF8String.getInstance(e.nextElement()).getString()); } return list; }
/** * This method copies the contents of a generalSubtrees sequence into * the given vector. Static to protect the internal data structures from * access. * * @param subSeq * the subsequence to copy. * @param vector * The target to copy the parsed GeneralSubtree objects. */ private static void copyCondSequenceToVector(DERSequence subSeq, List<GeneralSubtree> vector) { Enumeration<?> subTreeEnum = subSeq.getObjects(); while (subTreeEnum.hasMoreElements()) { ASN1Primitive object = (ASN1Primitive) subTreeEnum.nextElement(); vector.add(GeneralSubtree.getInstance(object)); } }
private int getBodyLength() throws IOException { if (bodyLength < 0) { int length = 0; for (Enumeration e = this.getObjects(); e.hasMoreElements();) { Object obj = e.nextElement(); length += ((ASN1Encodable)obj).toASN1Primitive().toDERObject().encodedLength(); } bodyLength = length; } return bodyLength; }
private int getBodyLength() throws IOException { if (bodyLength < 0) { int length = 0; for (Enumeration e = this.getObjects(); e.hasMoreElements();) { Object obj = e.nextElement(); length += ((ASN1Encodable)obj).toASN1Primitive().toDERObject().encodedLength(); } bodyLength = length; } return bodyLength; }
private DERObject[] readDERObjects(DERObject container) throws IOException { // do operation varying from the type of container if (container instanceof DERSequence) { // decode using enumerator List<DERObject> objects = new ArrayList<DERObject>(); DERSequence seq = (DERSequence) container; Enumeration enumer = seq.getObjects(); while (enumer.hasMoreElements()) { DERObject curObj = (DERObject) enumer.nextElement(); objects.add(untag(curObj)); } return objects.toArray(new DERObject[0]); } if (container instanceof DERApplicationSpecific) { DERApplicationSpecific aps = (DERApplicationSpecific) container; byte[] bytes = aps.getContents(); return readDERObjects(bytes); } if (container instanceof DEROctetString) { DEROctetString octets = (DEROctetString) container; byte[] bytes = octets.getOctets(); return readDERObjects(bytes); } throw new IllegalArgumentException("Unable to decode sequence from "+container); }
void encode( ASN1OutputStream out) throws IOException { ASN1OutputStream dOut = out.getDERSubStream(); int length = getBodyLength(); out.write(BERTags.SEQUENCE | BERTags.CONSTRUCTED); out.writeLength(length); for (Enumeration e = this.getObjects(); e.hasMoreElements();) { Object obj = e.nextElement(); dOut.writeObject((ASN1Encodable)obj); } } }
void encode( ASN1OutputStream out) throws IOException { ASN1OutputStream dOut = out.getDERSubStream(); int length = getBodyLength(); out.write(BERTags.SEQUENCE | BERTags.CONSTRUCTED); out.writeLength(length); for (Enumeration e = this.getObjects(); e.hasMoreElements();) { Object obj = e.nextElement(); dOut.writeObject((ASN1Encodable)obj); } } }