package org.bouncycastle.crypto.tls;

import java.util.Vector;

public class CertificateRequest
{
    private short[] certificateTypes;
    private Vector certificateAuthorities;

    public CertificateRequest(short[] certificateTypes, Vector certificateAuthorities)
    {
        this.certificateTypes = certificateTypes;
        this.certificateAuthorities = certificateAuthorities;
    }

    public short[] getCertificateTypes()
    {
        return certificateTypes;
    }

    /**
     * @return Vector of X500Name
     */
    public Vector getCertificateAuthorities()
    {
        return certificateAuthorities;
    }
}

@@ -47,19 +47,273 @@
 ava.
-util.Vector
+io.ByteArrayInputStream;%0Aimport java.io.IOException;%0Aimport java.io.InputStream;%0Aimport java.io.OutputStream;%0Aimport java.util.Vector;%0A%0Aimport org.bouncycastle.asn1.ASN1Encoding;%0Aimport org.bouncycastle.asn1.ASN1Primitive;%0Aimport org.bouncycastle.asn1.x500.X500Name
 ;%0A%0Ap
@@ -342,17 +342,17 @@
 eRequest
-%0A
+ 
 %7B%0A    pr
@@ -513,20 +513,16 @@
 orities)
-%0A   
  %7B%0A     
@@ -671,28 +671,24 @@
 icateTypes()
-%0A   
  %7B%0A        r
@@ -813,20 +813,16 @@
 rities()
-%0A   
  %7B%0A     
@@ -860,11 +860,1947 @@
 s;%0A    %7D
+%0A%0A    public void encode(OutputStream output) throws IOException %7B%0A%0A        if (certificateTypes == null %7C%7C certificateTypes.length == 0) %7B%0A            TlsUtils.writeUint8((short) 0, output);%0A        %7D else %7B%0A            TlsUtils.writeUint8((short) certificateTypes.length, output);%0A            TlsUtils.writeUint8Array(certificateTypes, output);%0A        %7D%0A%0A        if (certificateAuthorities == null %7C%7C certificateAuthorities.isEmpty()) %7B%0A            TlsUtils.writeUint16(0, output);%0A        %7D else %7B%0A%0A            Vector encDNs = new Vector(certificateAuthorities.size());%0A            int totalLength = 0;%0A            for (int i = 0; i %3C certificateAuthorities.size(); ++i) %7B%0A                X500Name authorityDN = (X500Name) certificateAuthorities.get(i);%0A                byte%5B%5D encDN = authorityDN.getEncoded(ASN1Encoding.DER);%0A                encDNs.addElement(encDN);%0A                totalLength += encDN.length;%0A            %7D%0A%0A            TlsUtils.writeUint16(totalLength, output);%0A%0A            for (int i = 0; i %3C encDNs.size(); ++i) %7B%0A                byte%5B%5D encDN = (byte%5B%5D) encDNs.elementAt(i);%0A                output.write(encDN);%0A            %7D%0A        %7D%0A    %7D%0A%0A    public static CertificateRequest parse(InputStream input) throws IOException %7B%0A        int numTypes = TlsUtils.readUint8(input);%0A        short%5B%5D certificateTypes = new short%5BnumTypes%5D;%0A        for (int i = 0; i %3C numTypes; ++i) %7B%0A            certificateTypes%5Bi%5D = TlsUtils.readUint8(input);%0A        %7D%0A%0A        byte%5B%5D authorities = TlsUtils.readOpaque16(input);%0A%0A        Vector authorityDNs = new Vector();%0A%0A        ByteArrayInputStream bis = new ByteArrayInputStream(authorities);%0A        while (bis.available() %3E 0) %7B%0A            byte%5B%5D dnBytes = TlsUtils.readOpaque16(bis);%0A            authorityDNs.addElement(X500Name.getInstance(ASN1Primitive.fromByteArray(dnBytes)));%0A        %7D%0A%0A        return new CertificateRequest(certificateTypes, authorityDNs);%0A    %7D
 %0A%7D%0A

Add encode and parse methods