01: /*
02: * Title: Oyster Project
03: * Description: S/MIME email sending capabilities
04: * @Author Vladimir Radisic
05: * @Version 2.1.6
06: */
07:
08: package org.enhydra.oyster.der;
09:
10: import org.enhydra.oyster.exception.SMIMEException;
11:
12: /**
13: * DERClassContextSpecificPr can be both, primitive or structured type of DER
14: * encoded object with the context-specific class tag (part of object Identifier
15: * Octet) in ASN.1 notation. Difference bettween DERClassContextSpecific and
16: * DERClassContextSpecificPr is that class DERClassContextSpecific has public
17: * method addContent. Also, DERClassContextSpecific extends it's super class
18: * DERClassContextSpecificPr.
19: */
20: public class DERClassContextSpecificPr extends DERObject {
21:
22: /**
23: * Identifies if DERClassContextSpecificPr represents primitive or structured
24: * DER object.
25: */
26: private boolean structureIdentificator = false;
27:
28: /**
29: * Counter for objects added to DERClassContextSpecificPr. Couldn't be more than
30: * 1 for primitive DERClassContextSpecificPr
31: */
32: private int countOfAddings = 0;
33:
34: /**
35: * Constructs the structured or primitive DERClassContextSpecificPr object
36: * @param type0 define value of identifier octet
37: * @param structured0 used for defining structured complexity of Context Specific
38: * class (true = structured, and false = primitive)
39: * @exception SMIMEException thrown in super class constructor.
40: */
41: public DERClassContextSpecificPr(int type0, boolean structured0)
42: throws SMIMEException {
43: super (structured0 ? (type0 | 160) : (type0 | 128));
44: structureIdentificator = structured0;
45: }
46:
47: /**
48: * Adds content to DER encoded Context Specific Class Type
49: * @param content0 content for adding to Context Specific Class Type
50: * @exception SMIMEException when adding content to primitive
51: * DERClassContextSpecificPr object is performed more than once, or thrown in
52: * super class method addContent.
53: */
54: protected void addContent(byte[] content0) throws SMIMEException {
55: if (structureIdentificator == false & countOfAddings > 0)
56: throw new SMIMEException(1005);
57: super.addContent(content0);
58: countOfAddings++;
59: }
60: }
|