1 module hunt.security.x509.GeneralNameInterface; 2 3 import hunt.security.util.DerOutputStream; 4 5 6 /** 7 * This interface specifies the abstract methods which have to be 8 * implemented by all the members of the GeneralNames ASN.1 object. 9 * 10 * @author Amit Kapoor 11 * @author Hemma Prafullchandra 12 */ 13 interface GeneralNameInterface { 14 /** 15 * The list of names supported. 16 */ 17 enum int NAME_ANY = 0; 18 enum int NAME_RFC822 = 1; 19 enum int NAME_DNS = 2; 20 enum int NAME_X400 = 3; 21 enum int NAME_DIRECTORY = 4; 22 enum int NAME_EDI = 5; 23 enum int NAME_URI = 6; 24 enum int NAME_IP = 7; 25 enum int NAME_OID = 8; 26 27 /** 28 * The list of constraint results. 29 */ 30 enum int NAME_DIFF_TYPE = -1; /* input name is different type from name (i.e. does not constrain) */ 31 enum int NAME_MATCH = 0; /* input name matches name */ 32 enum int NAME_NARROWS = 1; /* input name narrows name */ 33 enum int NAME_WIDENS = 2; /* input name widens name */ 34 enum int NAME_SAME_TYPE = 3; /* input name does not match, narrow, or widen, but is same type */ 35 36 /** 37 * Return the type of the general name, as 38 * defined above. 39 */ 40 int getType(); 41 42 /** 43 * Encode the name to the specified DerOutputStream. 44 * 45 * @param out the DerOutputStream to encode the GeneralName to. 46 * @exception IOException thrown if the GeneralName could not be 47 * encoded. 48 */ 49 void encode(DerOutputStream ot); 50 51 /** 52 * Return type of constraint inputName places on this name:<ul> 53 * <li>NAME_DIFF_TYPE = -1: input name is different type from name (i.e. does not constrain). 54 * <li>NAME_MATCH = 0: input name matches name. 55 * <li>NAME_NARROWS = 1: input name narrows name (is lower in the naming subtree) 56 * <li>NAME_WIDENS = 2: input name widens name (is higher in the naming subtree) 57 * <li>NAME_SAME_TYPE = 3: input name does not match or narrow name, but is same type. 58 * </ul>. These results are used in checking NameConstraints during 59 * certification path verification. 60 * 61 * @param inputName to be checked for being constrained 62 * @returns constraint type above 63 * @throws UnsupportedOperationException if name is same type, but comparison operations are 64 * not supported for this name type. 65 */ 66 int constrains(GeneralNameInterface inputName); 67 68 /** 69 * Return subtree depth of this name for purposes of determining 70 * NameConstraints minimum and maximum bounds and for calculating 71 * path lengths in name subtrees. 72 * 73 * @returns distance of name from root 74 * @throws UnsupportedOperationException if not supported for this name type 75 */ 76 int subtreeDepth(); 77 }