⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 x509name.java

📁 kmlnjlkj nlkjlkjkljl okopokipoipo oipipipo i
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
package org.bouncycastle.asn1.x509;import org.bouncycastle.asn1.ASN1Encodable;import org.bouncycastle.asn1.ASN1EncodableVector;import org.bouncycastle.asn1.ASN1Sequence;import org.bouncycastle.asn1.ASN1Set;import org.bouncycastle.asn1.ASN1TaggedObject;import org.bouncycastle.asn1.DEREncodable;import org.bouncycastle.asn1.DERObject;import org.bouncycastle.asn1.DERObjectIdentifier;import org.bouncycastle.asn1.DERSequence;import org.bouncycastle.asn1.DERSet;import org.bouncycastle.asn1.DERString;import org.bouncycastle.asn1.DERUniversalString;import org.bouncycastle.asn1.ASN1Object;import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;import org.bouncycastle.util.Strings;import org.bouncycastle.util.encoders.Hex;import java.util.Enumeration;import java.util.Hashtable;import java.util.Vector;import java.io.IOException;/** * <pre> *     RDNSequence ::= SEQUENCE OF RelativeDistinguishedName * *     RelativeDistinguishedName ::= SET SIZE (1..MAX) OF AttributeTypeAndValue * *     AttributeTypeAndValue ::= SEQUENCE { *                                   type  OBJECT IDENTIFIER, *                                   value ANY } * </pre> */public class X509Name    extends ASN1Encodable{    /**     * country code - StringType(SIZE(2))     */    public static final DERObjectIdentifier C = new DERObjectIdentifier("2.5.4.6");    /**     * organization - StringType(SIZE(1..64))     */    public static final DERObjectIdentifier O = new DERObjectIdentifier("2.5.4.10");    /**     * organizational unit name - StringType(SIZE(1..64))     */    public static final DERObjectIdentifier OU = new DERObjectIdentifier("2.5.4.11");    /**     * Title     */    public static final DERObjectIdentifier T = new DERObjectIdentifier("2.5.4.12");    /**     * common name - StringType(SIZE(1..64))     */    public static final DERObjectIdentifier CN = new DERObjectIdentifier("2.5.4.3");    /**     * device serial number name - StringType(SIZE(1..64))     */    public static final DERObjectIdentifier SN = new DERObjectIdentifier("2.5.4.5");    /**     * street - StringType(SIZE(1..64))     */    public static final DERObjectIdentifier STREET = new DERObjectIdentifier("2.5.4.9");        /**     * device serial number name - StringType(SIZE(1..64))     */    public static final DERObjectIdentifier SERIALNUMBER = SN;    /**     * locality name - StringType(SIZE(1..64))     */    public static final DERObjectIdentifier L = new DERObjectIdentifier("2.5.4.7");    /**     * state, or province name - StringType(SIZE(1..64))     */    public static final DERObjectIdentifier ST = new DERObjectIdentifier("2.5.4.8");    /**     * Naming attributes of type X520name     */    public static final DERObjectIdentifier SURNAME = new DERObjectIdentifier("2.5.4.4");    public static final DERObjectIdentifier GIVENNAME = new DERObjectIdentifier("2.5.4.42");    public static final DERObjectIdentifier INITIALS = new DERObjectIdentifier("2.5.4.43");    public static final DERObjectIdentifier GENERATION = new DERObjectIdentifier("2.5.4.44");    public static final DERObjectIdentifier UNIQUE_IDENTIFIER = new DERObjectIdentifier("2.5.4.45");    /**     * businessCategory - DirectoryString(SIZE(1..128)     */    public static final DERObjectIdentifier BUSINESS_CATEGORY = new DERObjectIdentifier(                    "2.5.4.15");    /**     * postalCode - DirectoryString(SIZE(1..40)     */    public static final DERObjectIdentifier POSTAL_CODE = new DERObjectIdentifier(                    "2.5.4.17");        /**     * dnQualifier - DirectoryString(SIZE(1..64)     */    public static final DERObjectIdentifier DN_QUALIFIER = new DERObjectIdentifier(                    "2.5.4.46");    /**     * RFC 3039 Pseudonym - DirectoryString(SIZE(1..64)     */    public static final DERObjectIdentifier PSEUDONYM = new DERObjectIdentifier(                    "2.5.4.65");    /**     * RFC 3039 DateOfBirth - GeneralizedTime - YYYYMMDD000000Z     */    public static final DERObjectIdentifier DATE_OF_BIRTH = new DERObjectIdentifier(                    "1.3.6.1.5.5.7.9.1");    /**     * RFC 3039 PlaceOfBirth - DirectoryString(SIZE(1..128)     */    public static final DERObjectIdentifier PLACE_OF_BIRTH = new DERObjectIdentifier(                    "1.3.6.1.5.5.7.9.2");    /**     * RFC 3039 Gender - PrintableString (SIZE(1)) -- "M", "F", "m" or "f"     */    public static final DERObjectIdentifier GENDER = new DERObjectIdentifier(                    "1.3.6.1.5.5.7.9.3");    /**     * RFC 3039 CountryOfCitizenship - PrintableString (SIZE (2)) -- ISO 3166     * codes only     */    public static final DERObjectIdentifier COUNTRY_OF_CITIZENSHIP = new DERObjectIdentifier(                    "1.3.6.1.5.5.7.9.4");    /**     * RFC 3039 CountryOfResidence - PrintableString (SIZE (2)) -- ISO 3166     * codes only     */    public static final DERObjectIdentifier COUNTRY_OF_RESIDENCE = new DERObjectIdentifier(                    "1.3.6.1.5.5.7.9.5");    /**     * ISIS-MTT NameAtBirth - DirectoryString(SIZE(1..64)     */    public static final DERObjectIdentifier NAME_AT_BIRTH =  new DERObjectIdentifier("1.3.36.8.3.14");    /**     * RFC 3039 PostalAddress - SEQUENCE SIZE (1..6) OF     * DirectoryString(SIZE(1..30))     */    public static final DERObjectIdentifier POSTAL_ADDRESS = new DERObjectIdentifier("2.5.4.16");    /**     * id-at-telephoneNumber     */    public static final DERObjectIdentifier TELEPHONE_NUMBER = X509ObjectIdentifiers.id_at_telephoneNumber;    /**     * id-at-name     */    public static final DERObjectIdentifier NAME = X509ObjectIdentifiers.id_at_name;    /**     * Email address (RSA PKCS#9 extension) - IA5String.     * <p>Note: if you're trying to be ultra orthodox, don't use this! It shouldn't be in here.     */    public static final DERObjectIdentifier EmailAddress = PKCSObjectIdentifiers.pkcs_9_at_emailAddress;        /**     * more from PKCS#9     */    public static final DERObjectIdentifier UnstructuredName = PKCSObjectIdentifiers.pkcs_9_at_unstructuredName;    public static final DERObjectIdentifier UnstructuredAddress = PKCSObjectIdentifiers.pkcs_9_at_unstructuredAddress;        /**     * email address in Verisign certificates     */    public static final DERObjectIdentifier E = EmailAddress;        /*     * others...     */    public static final DERObjectIdentifier DC = new DERObjectIdentifier("0.9.2342.19200300.100.1.25");    /**     * LDAP User id.     */    public static final DERObjectIdentifier UID = new DERObjectIdentifier("0.9.2342.19200300.100.1.1");    /**     * determines whether or not strings should be processed and printed     * from back to front.     */    public static boolean DefaultReverse = false;    /**     * default look up table translating OID values into their common symbols following     * the convention in RFC 2253 with a few extras     */    public static final Hashtable DefaultSymbols = new Hashtable();    /**     * look up table translating OID values into their common symbols following the convention in RFC 2253     *      */    public static final Hashtable RFC2253Symbols = new Hashtable();    /**     * look up table translating OID values into their common symbols following the convention in RFC 1779     *      */    public static final Hashtable RFC1779Symbols = new Hashtable();    /**     * look up table translating common symbols into their OIDS.     */    public static final Hashtable DefaultLookUp = new Hashtable();    /**     * look up table translating OID values into their common symbols     * @deprecated use DefaultSymbols     */    public static final Hashtable OIDLookUp = DefaultSymbols;    /**     * look up table translating string values into their OIDS -     * @deprecated use DefaultLookUp     */    public static final Hashtable SymbolLookUp = DefaultLookUp;    private static final Boolean TRUE = new Boolean(true); // for J2ME compatibility    private static final Boolean FALSE = new Boolean(false);    static    {        DefaultSymbols.put(C, "C");        DefaultSymbols.put(O, "O");        DefaultSymbols.put(T, "T");        DefaultSymbols.put(OU, "OU");        DefaultSymbols.put(CN, "CN");        DefaultSymbols.put(L, "L");        DefaultSymbols.put(ST, "ST");        DefaultSymbols.put(SN, "SERIALNUMBER");        DefaultSymbols.put(EmailAddress, "E");        DefaultSymbols.put(DC, "DC");        DefaultSymbols.put(UID, "UID");        DefaultSymbols.put(STREET, "STREET");        DefaultSymbols.put(SURNAME, "SURNAME");        DefaultSymbols.put(GIVENNAME, "GIVENNAME");        DefaultSymbols.put(INITIALS, "INITIALS");        DefaultSymbols.put(GENERATION, "GENERATION");        DefaultSymbols.put(UnstructuredAddress, "unstructuredAddress");        DefaultSymbols.put(UnstructuredName, "unstructuredName");        DefaultSymbols.put(UNIQUE_IDENTIFIER, "UniqueIdentifier");        DefaultSymbols.put(DN_QUALIFIER, "DN");        DefaultSymbols.put(PSEUDONYM, "Pseudonym");        DefaultSymbols.put(POSTAL_ADDRESS, "PostalAddress");        DefaultSymbols.put(NAME_AT_BIRTH, "NameAtBirth");        DefaultSymbols.put(COUNTRY_OF_CITIZENSHIP, "CountryOfCitizenship");        DefaultSymbols.put(COUNTRY_OF_RESIDENCE, "CountryOfResidence");        DefaultSymbols.put(GENDER, "Gender");        DefaultSymbols.put(PLACE_OF_BIRTH, "PlaceOfBirth");        DefaultSymbols.put(DATE_OF_BIRTH, "DateOfBirth");        DefaultSymbols.put(POSTAL_CODE, "PostalCode");        DefaultSymbols.put(BUSINESS_CATEGORY, "BusinessCategory");        DefaultSymbols.put(TELEPHONE_NUMBER, "TelephoneNumber");        DefaultSymbols.put(NAME, "Name");        RFC2253Symbols.put(C, "C");        RFC2253Symbols.put(O, "O");        RFC2253Symbols.put(OU, "OU");        RFC2253Symbols.put(CN, "CN");        RFC2253Symbols.put(L, "L");        RFC2253Symbols.put(ST, "ST");        RFC2253Symbols.put(STREET, "STREET");        RFC2253Symbols.put(DC, "DC");        RFC2253Symbols.put(UID, "UID");        RFC1779Symbols.put(C, "C");        RFC1779Symbols.put(O, "O");        RFC1779Symbols.put(OU, "OU");        RFC1779Symbols.put(CN, "CN");        RFC1779Symbols.put(L, "L");        RFC1779Symbols.put(ST, "ST");        RFC1779Symbols.put(STREET, "STREET");        DefaultLookUp.put("c", C);        DefaultLookUp.put("o", O);        DefaultLookUp.put("t", T);        DefaultLookUp.put("ou", OU);        DefaultLookUp.put("cn", CN);        DefaultLookUp.put("l", L);        DefaultLookUp.put("st", ST);        DefaultLookUp.put("sn", SN);        DefaultLookUp.put("serialnumber", SN);        DefaultLookUp.put("street", STREET);        DefaultLookUp.put("emailaddress", E);        DefaultLookUp.put("dc", DC);        DefaultLookUp.put("e", E);        DefaultLookUp.put("uid", UID);        DefaultLookUp.put("surname", SURNAME);        DefaultLookUp.put("givenname", GIVENNAME);        DefaultLookUp.put("initials", INITIALS);        DefaultLookUp.put("generation", GENERATION);        DefaultLookUp.put("unstructuredaddress", UnstructuredAddress);        DefaultLookUp.put("unstructuredname", UnstructuredName);        DefaultLookUp.put("uniqueidentifier", UNIQUE_IDENTIFIER);        DefaultLookUp.put("dn", DN_QUALIFIER);        DefaultLookUp.put("pseudonym", PSEUDONYM);        DefaultLookUp.put("postaladdress", POSTAL_ADDRESS);        DefaultLookUp.put("nameofbirth", NAME_AT_BIRTH);        DefaultLookUp.put("countryofcitizenship", COUNTRY_OF_CITIZENSHIP);        DefaultLookUp.put("countryofresidence", COUNTRY_OF_RESIDENCE);        DefaultLookUp.put("gender", GENDER);        DefaultLookUp.put("placeofbirth", PLACE_OF_BIRTH);        DefaultLookUp.put("dateofbirth", DATE_OF_BIRTH);        DefaultLookUp.put("postalcode", POSTAL_CODE);        DefaultLookUp.put("businesscategory", BUSINESS_CATEGORY);        DefaultLookUp.put("telephonenumber", TELEPHONE_NUMBER);        DefaultLookUp.put("name", NAME);    }    private X509NameEntryConverter  converter = null;    private Vector                  ordering = new Vector();    private Vector                  values = new Vector();    private Vector                  added = new Vector();    private ASN1Sequence            seq;    /**     * Return a X509Name based on the passed in tagged object.     *      * @param obj tag object holding name.     * @param explicit true if explicitly tagged false otherwise.     * @return the X509Name     */    public static X509Name getInstance(        ASN1TaggedObject obj,        boolean          explicit)    {        return getInstance(ASN1Sequence.getInstance(obj, explicit));    }    public static X509Name getInstance(        Object  obj)    {        if (obj == null || obj instanceof X509Name)        {            return (X509Name)obj;        }        else if (obj instanceof ASN1Sequence)        {            return new X509Name((ASN1Sequence)obj);        }        throw new IllegalArgumentException("unknown object in factory: " + obj.getClass().getName());    }    /**     * Constructor from ASN1Sequence     *     * the principal will be a list of constructed sets, each containing an (OID, String) pair.     */    public X509Name(        ASN1Sequence  seq)    {        this.seq = seq;        Enumeration e = seq.getObjects();        while (e.hasMoreElements())        {            ASN1Set         set = ASN1Set.getInstance(e.nextElement());            for (int i = 0; i < set.size(); i++)             {                   ASN1Sequence s = ASN1Sequence.getInstance(set.getObjectAt(i));                   if (s.size() != 2)                   {                       throw new IllegalArgumentException("badly sized pair");                   }                   ordering.addElement(DERObjectIdentifier.getInstance(s.getObjectAt(0)));                                      DEREncodable value = s.getObjectAt(1);                   if (value instanceof DERString && !(value instanceof DERUniversalString))                   {                       String v = ((DERString)value).getString();                       if (v.length() > 0 && v.charAt(0) == '#')                       {                           values.addElement("\\" + v);                       }                       else                       {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -