View Javadoc
1 /* 2 * Title: S/MIME Project 3 * Description: S/MIME email sending capabilities 4 * @Author Vladimir Radisic 5 * @Version 2.0.1 6 */ 7 8 9 package org.webdocwf.util.smime.cms; 10 11 12 import org.webdocwf.util.smime.exception.SMIMEException; 13 import org.webdocwf.util.smime.der.DERSetPr; 14 15 16 /*** 17 * DigestAlgorithmIdentifiers class is DER encoded set of Digest Algorithm 18 * Identifiers represented in ASN.1 notation according to RFC2630. This class is 19 * used in CMS objects for signed messages and represents container for all Digest 20 * Algorithm Identifiers (one or more) used in the process of signing.<BR> 21 * <BR> 22 * DigestAlgorithmIdentifiers ::= SET OF DigestAlgorithmIdentifier<BR> 23 * <BR> 24 * <DL> 25 * DigestAlgorithmIdentifier ::= SEQUENCE {<BR> 26 * <DD> algorithm AlgorithmIdentifier,<BR> 27 * <DD> parameters ANY DEFINED BY algorithm OPTIONAL }<BR> 28 * </DL> 29 * <BR> 30 * AlgorithmIdentifier ::= OBJECT IDENTIFIER<BR> 31 */ 32 public class DigestAlgorithmIdentifiers extends DERSetPr { 33 34 /*** 35 * Construction of empty container for Digest Algorithm Identifiers 36 * @exception SMIMEException thrown from super class constructor. 37 */ 38 public DigestAlgorithmIdentifiers() throws SMIMEException {} 39 40 /*** 41 * Adds Digest Object Identifier to the instance of class 42 * DigestAlgorithmIdentifiers with no additional parameters. This method has two 43 * different forms, depend on parameter typeConstruction0, which can be: 44 * DOT_SEPARATED_ARRAY or NAME_STRING. If typeConstruction0 parameter is 45 * DOT_SEPARATED_ARRAY then id0 definition is represented by numbers separated 46 * with dots (example: "1.3.14.3.2.26"). In case of NAME_STRING id0 definition is 47 * name of object identifier (example: "SHA1"). 48 * @param id0 defines Object Identifier in representation determined by second 49 * parameter - typeConstruction0. 50 * @param typeConstruction0 can take values DOT_SEPARATED_ARRAY and NAME_STRING 51 * @exception SMIMEException if wrong type of parameters are passed. Also, it 52 * can be thrown from super class addContent method. 53 */ 54 public void addDigestAlgId(String id0, String typeConstruction0) throws SMIMEException { 55 AlgorithmIdentifier algID = new AlgorithmIdentifier(id0, typeConstruction0); // Finding apropriate identifier 56 57 super.addContent(algID.getDEREncoded()); // Adding identifier to DigestAlgorithmIdentifier 58 } 59 60 /*** 61 * Adds Digest Object Identifier to the instance of class DigestAlgorithmIdentifiers 62 * with DER encoded null value for parameter. This method has two different 63 * forms, depend on parameter typeConstruction0, which can be: DOT_SEPARATED_ARRAY 64 * or NAME_STRING. If typeConstruction0 parameter is DOT_SEPARATED_ARRAY then id0 65 * definition is represented by numbers separated with dots (example: "1.3.14.3.2.26"). 66 * In case of NAME_STRING id0 definition is name of object identifier (example: 67 * "SHA1"). 68 * @param id0 defines Object Identifier in representation determined by second 69 * parameter - typeConstruction0. 70 * @param typeConstruction0 can take values DOT_SEPARATED_ARRAY and NAME_STRING 71 * @exception SMIMEException if wrong type of parameters are passed. Also, it 72 * can be thrown from super class addContent method. 73 */ 74 public void addDigestAlgIdNullPar(String id0, String typeConstruction0) throws SMIMEException { 75 AlgorithmIdentifier algID = new AlgorithmIdentifier(id0, typeConstruction0); // Finding apropriate identifier 76 77 algID.addNullToAlgorithmId(); // Adding null parameter 78 super.addContent(algID.getDEREncoded()); // Adding identifier to DigestAlgorithmIdentifier 79 } 80 81 /*** 82 * Adds Digest Object Identifier to the instance of class 83 * DigestAlgorithmIdentifiers with parameters represented as byte array. This 84 * method has two different forms, depend on parameter typeConstruction0, which 85 * can be: DOT_SEPARATED_ARRAY or NAME_STRING. If typeConstruction0 parameter is 86 * DOT_SEPARATED_ARRAY then id0 definition is represented by numbers separated 87 * with dots (example: "1.3.14.3.2.26"). In case of NAME_STRING id0 definition is 88 * name of object identifier (example: "SHA1"). 89 * @param id0 defines Object Identifier in representation determined by second 90 * parameter - typeConstruction0. 91 * @param typeConstruction0 can take values DOT_SEPARATED_ARRAY and NAME_STRING 92 * @param algParam0 byte array representation of Digest Algorithm Identifier 93 * parameter 94 * @exception SMIMEException if wrong type of parameters are passed. Also, it 95 * can be thrown from super class addContent method. 96 */ 97 public void addDigestAlgId(String id0, String typeConstruction0, byte[] algParam0) throws SMIMEException { 98 AlgorithmIdentifier algID = new AlgorithmIdentifier(id0, typeConstruction0); // Finding apropriate identifier 99 100 algID.addParamToAlgorithmId(algParam0); // If algorithm parameter have to be other than null 101 super.addContent(algID.getDEREncoded()); // Adding identifier to DigestAlgorithmIdentifier 102 } 103 104 /*** 105 * Adds Digest Object Identifier to the instance of class 106 * DigestAlgorithmIdentifiers with no additional parameters. Array of numbers 107 * is Digest Algorithm Identifier which will be added. All numbers in the array 108 * represent one number between dots in object identifier string. 109 * @param arrayID0 array of given numbers (example: for SHA1 algorithm, 110 * numbers are 1, 3, 14, 3, 2 and 26). 111 * @exception SMIMEException if wrong type of parameters are passed. Also, it 112 * can be thrown from super class addContent method. 113 */ 114 public void addDigestAlgId(int[] arrayID0) throws SMIMEException { 115 AlgorithmIdentifier algID = new AlgorithmIdentifier(arrayID0); // Finding apropriate identifier 116 117 super.addContent(algID.getDEREncoded()); // Adding identifier to DigestAlgorithmIdentifier 118 } 119 120 /*** 121 * Adds Digest Object Identifier to the instance of class DigestAlgorithmIdentifiers 122 * with DER encoded null value for parameter. Array of numbers is 123 * Digest Algorithm Identifier which will be added. All numbers in the array 124 * represent one number between dots in object identifier string. 125 * @param arrayID0 array of given numbers (example: for SHA1 algorithm, 126 * numbers are 1, 3, 14, 3, 2 and 26). 127 * @exception SMIMEException if wrong type of parameters are passed. Also, it 128 * can be thrown from super class addContent method. 129 */ 130 public void addDigestAlgIdNullPar(int[] arrayID0) throws SMIMEException { 131 AlgorithmIdentifier algID = new AlgorithmIdentifier(arrayID0); // Finding apropriate identifier 132 133 algID.addNullToAlgorithmId(); // Adding null parameter 134 super.addContent(algID.getDEREncoded()); // Adding identifier to DigestAlgorithmIdentifier 135 } 136 137 /*** 138 * Adds Digest Object Identifier to the instance of class 139 * DigestAlgorithmIdentifiers with parameters represented as byte array. Array of 140 * numbers is used for construction of Digest Algorithm Identifier which will be 141 * added. All numbers in the array represent one number between dots in object 142 * identifier string. 143 * @param arrayID0 array of given numbers (example: for SHA1 algorithm, 144 * numbers are 1, 3, 14, 3, 2 and 26). 145 * @param algParam0 byte array representation of Digest Algorithm Identifier 146 * parameter 147 * @exception SMIMEException if wrong type of parameters are passed. Also, it 148 * can be thrown from super class addContent method. 149 */ 150 public void addDigestAlgId(int[] arrayID0, byte[] algParam0) throws SMIMEException { 151 AlgorithmIdentifier algID = new AlgorithmIdentifier(arrayID0); // Finding apropriate identifier 152 153 algID.addParamToAlgorithmId(algParam0); // If algorithm parameter have to be other than null 154 super.addContent(algID.getDEREncoded()); // Adding identifier to DigestAlgorithmIdentifier 155 } 156 } 157

This page was automatically generated by Maven