DEREncodableVector vec = new DEREncodableVector();
ASN1EncodableVector vec = new ASN1EncodableVector();
    public static GeneralNames getGeneralNamesFromAltName(String altName) {        DEREncodableVector vec = new DEREncodableVector();        // TODO: should support several emails as well, just like for dns etc        String email = CertTools.getEmailFromDN(altName);        if (email != null) {            GeneralName gn = new GeneralName(1, new DERIA5String(email));            vec.add(gn);        }                ArrayList dns = CertTools.getPartsFromDN(altName, CertTools.DNS);        if (!dns.isEmpty()) {                        Iterator iter = dns.iterator();            while (iter.hasNext()) {                GeneralName gn = new GeneralName(2, new DERIA5String((String)iter.next()));                vec.add(gn);            }        }                String directoryName = getDirectoryStringFromAltName(altName);        if (directoryName != null) {          X509Name x509DirectoryName = new X509Name(directoryName);          GeneralName gn = new GeneralName(4, x509DirectoryName);          vec.add(gn);        }                                        ArrayList uri = CertTools.getPartsFromDN(altName, CertTools.URI);        if (!uri.isEmpty()) {                        Iterator iter = uri.iterator();            while (iter.hasNext()) {                GeneralName gn = new GeneralName(6, new DERIA5String((String)iter.next()));                vec.add(gn);            }        }        uri = CertTools.getPartsFromDN(altName, CertTools.URI1);        if (!uri.isEmpty()) {                        Iterator iter = uri.iterator();            while (iter.hasNext()) {                GeneralName gn = new GeneralName(6, new DERIA5String((String)iter.next()));                vec.add(gn);            }        }        uri = CertTools.getPartsFromDN(altName, CertTools.URI2);        if (!uri.isEmpty()) {                        Iterator iter = uri.iterator();            while (iter.hasNext()) {                GeneralName gn = new GeneralName(6, new DERIA5String((String)iter.next()));                vec.add(gn);            }        }                                ArrayList ipstr = CertTools.getPartsFromDN(altName, CertTools.IPADDR);        if (!ipstr.isEmpty()) {                        Iterator iter = ipstr.iterator();            while (iter.hasNext()) {                byte[] ipoctets = StringTools.ipStringToOctets((String)iter.next());                GeneralName gn = new GeneralName(7, new DEROctetString(ipoctets));                vec.add(gn);            }        }                            ArrayList upn =  CertTools.getPartsFromDN(altName, CertTools.UPN);        if (!upn.isEmpty()) {                        Iterator iter = upn.iterator();                         while (iter.hasNext()) {                ASN1EncodableVector v = new ASN1EncodableVector();                v.add(new DERObjectIdentifier(CertTools.UPN_OBJECTID));                v.add(new DERTaggedObject(true, 0, new DERUTF8String((String)iter.next())));                //GeneralName gn = new GeneralName(new DERSequence(v), 0);                DERObject gn = new DERTaggedObject(false, 0, new DERSequence(v));                vec.add(gn);            }        }                        ArrayList guid =  CertTools.getPartsFromDN(altName, CertTools.GUID);        if (!guid.isEmpty()) {                        Iterator iter = guid.iterator();                            while (iter.hasNext()) {                                    ASN1EncodableVector v = new ASN1EncodableVector();                byte[] guidbytes = Hex.decode((String)iter.next());                if (guidbytes != null) {                    v.add(new DERObjectIdentifier(CertTools.GUID_OBJECTID));                    v.add(new DERTaggedObject(true, 0, new DEROctetString(guidbytes)));                    DERObject gn = new DERTaggedObject(false, 0, new DERSequence(v));                    vec.add(gn);                                    } else {                    log.error("Cannot decode hexadecimal guid: "+guid);                }            }        }        GeneralNames ret = null;         if (vec.size() > 0) {            ret = new GeneralNames(new DERSequence(vec));        }        return ret;    }