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.DERInteger; 23 import org.apache.geronimo.util.asn1.DERObjectIdentifier; 24 import org.apache.geronimo.util.asn1.DERSequence; 25 import org.apache.geronimo.util.asn1.DERGeneralizedTime; 26 import org.apache.geronimo.util.asn1.DERBitString; 27 import org.apache.geronimo.util.asn1.DERSet; 28 29 46 public class V2AttributeCertificateInfoGenerator 47 { 48 private DERInteger version; 49 private Holder holder; 50 private AttCertIssuer issuer; 51 private AlgorithmIdentifier signature; 52 private DERInteger serialNumber; 53 private AttCertValidityPeriod attrCertValidityPeriod; 54 private ASN1EncodableVector attributes; 55 private DERBitString issuerUniqueID; 56 private X509Extensions extensions; 57 private DERGeneralizedTime startDate, endDate; 58 59 public V2AttributeCertificateInfoGenerator() 60 { 61 this.version = new DERInteger(1); 62 attributes = new ASN1EncodableVector(); 63 } 64 65 public void setHolder(Holder holder) 66 { 67 this.holder = holder; 68 } 69 70 public void addAttribute(String oid, ASN1Encodable value) 71 { 72 attributes.add(new Attribute(new DERObjectIdentifier(oid), new DERSet(value))); 73 } 74 75 78 public void addAttribute(Attribute attribute) 79 { 80 attributes.add(attribute); 81 } 82 83 public void setSerialNumber( 84 DERInteger serialNumber) 85 { 86 this.serialNumber = serialNumber; 87 } 88 89 public void setSignature( 90 AlgorithmIdentifier signature) 91 { 92 this.signature = signature; 93 } 94 95 public void setIssuer( 96 AttCertIssuer issuer) 97 { 98 this.issuer = issuer; 99 } 100 101 public void setStartDate( 102 DERGeneralizedTime startDate) 103 { 104 this.startDate = startDate; 105 } 106 107 public void setEndDate( 108 DERGeneralizedTime endDate) 109 { 110 this.endDate = endDate; 111 } 112 113 public void setIssuerUniqueID( 114 DERBitString issuerUniqueID) 115 { 116 this.issuerUniqueID = issuerUniqueID; 117 } 118 119 public void setExtensions( 120 X509Extensions extensions) 121 { 122 this.extensions = extensions; 123 } 124 125 public AttributeCertificateInfo generateAttributeCertificateInfo() 126 { 127 if ((serialNumber == null) || (signature == null) 128 || (issuer == null) || (startDate == null) || (endDate == null) 129 || (holder == null) || (attributes == null)) 130 { 131 throw new IllegalStateException ("not all mandatory fields set in V2 AttributeCertificateInfo generator"); 132 } 133 134 ASN1EncodableVector v = new ASN1EncodableVector(); 135 136 v.add(version); 137 v.add(holder); 138 v.add(issuer); 139 v.add(signature); 140 v.add(serialNumber); 141 142 AttCertValidityPeriod validity = new AttCertValidityPeriod(startDate, endDate); 146 v.add(validity); 147 148 v.add(new DERSequence(attributes)); 150 151 if (issuerUniqueID != null) 152 { 153 v.add(issuerUniqueID); 154 } 155 156 if (extensions != null) 157 { 158 v.add(extensions); 159 } 160 161 return new AttributeCertificateInfo(new DERSequence(v)); 162 } 163 } 164 | Popular Tags |