1 package org.bouncycastle.x509; 2 3 import org.bouncycastle.asn1.ASN1Encodable; 4 import org.bouncycastle.asn1.ASN1EncodableVector; 5 import org.bouncycastle.asn1.ASN1Object; 6 import org.bouncycastle.asn1.ASN1ObjectIdentifier; 7 import org.bouncycastle.asn1.ASN1Primitive; 8 import org.bouncycastle.asn1.ASN1Set; 9 import org.bouncycastle.asn1.DERSet; 10 import org.bouncycastle.asn1.x509.Attribute; 11 12 /** 13 * Class for carrying the values in an X.509 Attribute. 14 * @deprecated see X509CertificateHolder class in the PKIX package. 15 */ 16 public class X509Attribute 17 extends ASN1Object 18 { 19 Attribute attr; 20 21 /** 22 * @param at an object representing an attribute. 23 */ 24 X509Attribute( 25 ASN1Encodable at) 26 { 27 this.attr = Attribute.getInstance(at); 28 } 29 30 /** 31 * Create an X.509 Attribute with the type given by the passed in oid and 32 * the value represented by an ASN.1 Set containing value. 33 * 34 * @param oid type of the attribute 35 * @param value value object to go into the atribute's value set. 36 */ 37 public X509Attribute( 38 String oid, 39 ASN1Encodable value) 40 { 41 this.attr = new Attribute(new ASN1ObjectIdentifier(oid), new DERSet(value)); 42 } 43 44 /** 45 * Create an X.59 Attribute with the type given by the passed in oid and the 46 * value represented by an ASN.1 Set containing the objects in value. 47 * 48 * @param oid type of the attribute 49 * @param value vector of values to go in the attribute's value set. 50 */ 51 public X509Attribute( 52 String oid, 53 ASN1EncodableVector value) 54 { 55 this.attr = new Attribute(new ASN1ObjectIdentifier(oid), new DERSet(value)); 56 } 57 58 public String getOID() 59 { 60 return attr.getAttrType().getId(); 61 } 62 63 public ASN1Encodable[] getValues() 64 { 65 ASN1Set s = attr.getAttrValues(); 66 ASN1Encodable[] values = new ASN1Encodable[s.size()]; 67 68 for (int i = 0; i != s.size(); i++) 69 { 70 values[i] = (ASN1Encodable)s.getObjectAt(i); 71 } 72 73 return values; 74 } 75 76 public ASN1Primitive toASN1Primitive() 77 { 78 return attr.toASN1Primitive(); 79 } 80 } 81