1 17 18 package org.apache.geronimo.util.asn1.x509; 19 20 import org.apache.geronimo.util.asn1.ASN1Encodable; 21 import org.apache.geronimo.util.asn1.ASN1EncodableVector; 22 import org.apache.geronimo.util.asn1.ASN1Sequence; 23 import org.apache.geronimo.util.asn1.ASN1Set; 24 import org.apache.geronimo.util.asn1.DERObject; 25 import org.apache.geronimo.util.asn1.DERObjectIdentifier; 26 import org.apache.geronimo.util.asn1.DERSequence; 27 28 public class Attribute 29 extends ASN1Encodable 30 { 31 private DERObjectIdentifier attrType; 32 private ASN1Set attrValues; 33 34 40 public static Attribute getInstance( 41 Object o) 42 { 43 if (o == null || o instanceof Attribute) 44 { 45 return (Attribute)o; 46 } 47 48 if (o instanceof ASN1Sequence) 49 { 50 return new Attribute((ASN1Sequence)o); 51 } 52 53 throw new IllegalArgumentException ("unknown object in factory"); 54 } 55 56 public Attribute( 57 ASN1Sequence seq) 58 { 59 attrType = (DERObjectIdentifier)seq.getObjectAt(0); 60 attrValues = (ASN1Set)seq.getObjectAt(1); 61 } 62 63 public Attribute( 64 DERObjectIdentifier attrType, 65 ASN1Set attrValues) 66 { 67 this.attrType = attrType; 68 this.attrValues = attrValues; 69 } 70 71 public DERObjectIdentifier getAttrType() 72 { 73 return attrType; 74 } 75 76 public ASN1Set getAttrValues() 77 { 78 return attrValues; 79 } 80 81 90 public DERObject toASN1Object() 91 { 92 ASN1EncodableVector v = new ASN1EncodableVector(); 93 94 v.add(attrType); 95 v.add(attrValues); 96 97 return new DERSequence(v); 98 } 99 } 100 | Popular Tags |