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.DERSequencePr; 14 15 16 /*** 17 * EncryptedContentInfo class is DER encoded Encrypted Content Info represented 18 * in ASN.1 notation according to RFC2630. This class is used for construction 19 * of CMS object for encrypted messages. Between other information, encrypted content 20 * is stored in the object of this class.<BR> 21 * <BR> 22 * <DL> 23 * EncryptedContentInfo ::= SEQUENCE {<BR> 24 * <DD> contentType ContentType,<BR> 25 * <DD> contentEncryptionAlgorithm ContentEncryptionAlgorithmIdentifier,<BR> 26 * <DD> encryptedContent [0] IMPLICIT EncryptedContent OPTIONAL }<BR> 27 * </DL> 28 * <BR> 29 * ContentType ::= OBJECT IDENTIFIER<BR> 30 * <BR> 31 * <DL> 32 * ContentEncryptionAlgorithmIdentifier ::= SEQUENCE {<BR> 33 * <DD> algorithm AlgorithmIdentifier,<BR> 34 * <DD> parameter RC2CBCParameter }<BR> 35 * </DL> 36 * <BR> 37 * AlgorithmIdentifier ::= OBJECT IDENTIFIER<BR> 38 */ 39 public class EncryptedContentInfo extends DERSequencePr { 40 41 /*** 42 * Determinate order of adding commponents 43 */ 44 int orderIdentifier = 0; 45 46 /*** 47 * Constructs empty Encrypted Content Info. All methods: addContentType, 48 * addEncryptAlgorithmID and addEncryptContent must be performed after 49 * construction for obtaining valid CMS object. 50 * @exception SMIMEException thrown from super class constructor. 51 */ 52 public EncryptedContentInfo() throws SMIMEException {} 53 54 /*** 55 * Adds Content Type 56 * @param contType0 Content Type represented as byte array 57 * @exception SMIMEException if order of adding components is wrong. Also, it 58 * can be thrown from super class addContent method. 59 */ 60 public void addContentType(byte[] contType0) throws SMIMEException { 61 if (orderIdentifier == 0) { 62 super.addContent(contType0); 63 orderIdentifier++; 64 } else 65 throw new SMIMEException(this, 1018); 66 } 67 68 /*** 69 * Adds Encrypted Algorithm Identifier 70 * @param alg0 Encrypted Algorithm Identifier represented as byte array 71 * @exception SMIMEException if order of adding components is wrong. Also, it 72 * can be thrown from super class addContent method. 73 */ 74 public void addEncryptAlgorithmID(byte[] alg0) throws SMIMEException { 75 if (orderIdentifier == 1) { 76 super.addContent(alg0); 77 orderIdentifier++; 78 } else 79 throw new SMIMEException(this, 1018); 80 } 81 82 /*** 83 * Adds Encrypted Content 84 * @param cont0 encrypted content as byte array 85 * @exception SMIMEException if order of adding components is wrong. Also, it 86 * can be thrown from super class addContent method. 87 */ 88 public void addEncryptContent(byte[] cont0) throws SMIMEException { 89 if (orderIdentifier == 2) { 90 super.addContent(cont0); 91 orderIdentifier++; 92 } else 93 throw new SMIMEException(this, 1018); 94 } 95 } 96

This page was automatically generated by Maven