01: package org.bouncycastle.asn1.esf;
02:
03: import org.bouncycastle.asn1.x509.NoticeReference;
04: import org.bouncycastle.asn1.x509.DisplayText;
05: import org.bouncycastle.asn1.*;
06:
07: import java.util.Enumeration;
08:
09: public class SPUserNotice {
10: private NoticeReference noticeRef;
11: private DisplayText explicitText;
12:
13: public static SPUserNotice getInstance(Object obj) {
14: if (obj == null || obj instanceof SPUserNotice) {
15: return (SPUserNotice) obj;
16: } else if (obj instanceof ASN1Sequence) {
17: return new SPUserNotice((ASN1Sequence) obj);
18: }
19:
20: throw new IllegalArgumentException(
21: "unknown object in 'SPUserNotice' factory : "
22: + obj.getClass().getName() + ".");
23: }
24:
25: public SPUserNotice(ASN1Sequence seq) {
26: Enumeration e = seq.getObjects();
27: while (e.hasMoreElements()) {
28: DEREncodable object = (DEREncodable) e.nextElement();
29: if (object instanceof NoticeReference) {
30: noticeRef = NoticeReference.getInstance(object);
31: } else if (object instanceof DisplayText) {
32: explicitText = DisplayText.getInstance(object);
33: } else {
34: throw new IllegalArgumentException(
35: "Invalid element in 'SPUserNotice'.");
36: }
37: }
38: }
39:
40: public SPUserNotice(NoticeReference noticeRef,
41: DisplayText explicitText) {
42: this .noticeRef = noticeRef;
43: this .explicitText = explicitText;
44: }
45:
46: public NoticeReference getNoticeRef() {
47: return noticeRef;
48: }
49:
50: public DisplayText getExplicitText() {
51: return explicitText;
52: }
53:
54: /**
55: * <pre>
56: * SPUserNotice ::= SEQUENCE {
57: * noticeRef NoticeReference OPTIONAL,
58: * explicitText DisplayText OPTIONAL }
59: * </pre>
60: */
61: public DERObject toASN1Object() {
62: ASN1EncodableVector v = new ASN1EncodableVector();
63:
64: if (noticeRef != null) {
65: v.add(noticeRef);
66: }
67:
68: if (explicitText != null) {
69: v.add(explicitText);
70: }
71:
72: return new DERSequence(v);
73: }
74: }
|