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.DERClassContextSpecificPr; 14 15 16 /*** 17 * SignedAttributes class is DER encoded container for holding particular signed 18 * attributes represented in ASN.1 notation according to RFC2630.<BR> 19 * <BR> 20 * signedAttrs [0] IMPLICIT SignedAttributes OPTIONAL<BR> 21 * <BR> 22 * SignedAttributes ::= SET SIZE (1..MAX) OF Attribute<BR> 23 * <BR> 24 * <DL> 25 * Attribute ::= SEQUENCE {<BR> 26 * <DD> attrType OBJECT IDENTIFIER,<BR> 27 * <DD> attrValues SET OF AttributeValue }<BR> 28 * </DL> 29 * <BR> 30 * attrType ::= OBJECT IDENTIFIER<BR> 31 * <BR> 32 * attrValues ::= SET OF AttributeValue<BR> 33 * <BR> 34 * AttributeValue ::= ANY<BR> 35 */ 36 public class SignedAttributes extends DERClassContextSpecificPr { 37 38 /*** 39 * Counter of added attributes. 40 */ 41 private int attributeIndicator = 0; 42 43 /*** 44 * Constructs structured DER encoded object with tag Class Context Specific 45 * @exception SMIMEException thrown in super class constructor. 46 */ 47 public SignedAttributes() throws SMIMEException { 48 super(0, true); 49 } 50 51 /*** 52 * Adds DER encoded Signed attribute. This function must be performed one or 53 * more times. 54 * @param content0 DER encoded Signed attribute for adding 55 * @exception SMIMEException thrown in super class addContent method. 56 */ 57 public void addSignedAttribute(byte[] content0) throws SMIMEException { 58 super.addContent(content0); 59 attributeIndicator++; 60 } 61 62 /*** 63 * Returns DER encoded Signed attributes. At least one attribute must be added 64 * before performing this function. 65 * @return Container with all aded signed attributes 66 * @exception SMIMEException if no attribute was added. Also, exception 67 * could be thrown in super class getDEREncoded method. 68 */ 69 public byte[] getSignedAttribute() throws SMIMEException { 70 if (attributeIndicator == 0) 71 throw new SMIMEException(this, 1025); 72 return super.getDEREncoded(); 73 } 74 } 75

This page was automatically generated by Maven