1 package org.bouncycastle.asn1.cms;
2
3 import org.bouncycastle.asn1.*;
4
5 public class Attribute
6 implements DEREncodable
7 {
8 private DERObjectIdentifier attrType;
9 private ASN1Set attrValues;
10
11
17 public static Attribute getInstance(
18 Object o)
19 {
20 if (o == null || o instanceof Attribute)
21 {
22 return (Attribute)o;
23 }
24
25 if (o instanceof ASN1Sequence)
26 {
27 return new Attribute((ASN1Sequence)o);
28 }
29
30 throw new IllegalArgumentException("unknown object in factory");
31 }
32
33 public Attribute(
34 ASN1Sequence seq)
35 {
36 attrType = (DERObjectIdentifier)seq.getObjectAt(0);
37 attrValues = (ASN1Set)seq.getObjectAt(1);
38 }
39
40 public Attribute(
41 DERObjectIdentifier attrType,
42 ASN1Set attrValues)
43 {
44 this.attrType = attrType;
45 this.attrValues = attrValues;
46 }
47
48 public DERObjectIdentifier getAttrType()
49 {
50 return attrType;
51 }
52
53 public ASN1Set getAttrValues()
54 {
55 return attrValues;
56 }
57
58
66 public DERObject getDERObject()
67 {
68 DEREncodableVector v = new DEREncodableVector();
69
70 v.add(attrType);
71 v.add(attrValues);
72
73 return new DERSequence(v);
74 }
75 }
76