1package org.bouncycastle.asn1.x500; 2 3import org.bouncycastle.asn1.ASN1Encodable; 4import org.bouncycastle.asn1.ASN1ObjectIdentifier; 5 6/** 7 * It turns out that the number of standard ways the fields in a DN should be 8 * encoded into their ASN.1 counterparts is rapidly approaching the 9 * number of machines on the internet. By default the X500Name class 10 * will produce UTF8Strings in line with the current recommendations (RFC 3280). 11 * <p> 12 */ 13public interface X500NameStyle 14{ 15 /** 16 * Convert the passed in String value into the appropriate ASN.1 17 * encoded object. 18 * 19 * @param oid the OID associated with the value in the DN. 20 * @param value the value of the particular DN component. 21 * @return the ASN.1 equivalent for the value. 22 */ 23 ASN1Encodable stringToValue(ASN1ObjectIdentifier oid, String value); 24 25 /** 26 * Return the OID associated with the passed in name. 27 * 28 * @param attrName the string to match. 29 * @return an OID 30 */ 31 ASN1ObjectIdentifier attrNameToOID(String attrName); 32 33 /** 34 * Return an array of RDN generated from the passed in String. 35 * @param dirName the String representation. 36 * @return an array of corresponding RDNs. 37 */ 38 RDN[] fromString(String dirName); 39 40 /** 41 * Return true if the two names are equal. 42 * 43 * @param name1 first name for comparison. 44 * @param name2 second name for comparison. 45 * @return true if name1 = name 2, false otherwise. 46 */ 47 boolean areEqual(X500Name name1, X500Name name2); 48 49 /** 50 * Calculate a hashCode for the passed in name. 51 * 52 * @param name the name the hashCode is required for. 53 * @return the calculated hashCode. 54 */ 55 int calculateHashCode(X500Name name); 56 57 /** 58 * Convert the passed in X500Name to a String. 59 * @param name the name to convert. 60 * @return a String representation. 61 */ 62 String toString(X500Name name); 63 64 /** 65 * Return the display name for toString() associated with the OID. 66 * 67 * @param oid the OID of interest. 68 * @return the name displayed in toString(), null if no mapping provided. 69 */ 70 String oidToDisplayName(ASN1ObjectIdentifier oid); 71 72 /** 73 * Return the acceptable names in a String DN that map to OID. 74 * 75 * @param oid the OID of interest. 76 * @return an array of String aliases for the OID, zero length if there are none. 77 */ 78 String[] oidToAttrNames(ASN1ObjectIdentifier oid); 79} 80