1 17 18 package org.apache.geronimo.util.asn1.x509; 19 20 import org.apache.geronimo.util.asn1.ASN1EncodableVector; 21 import org.apache.geronimo.util.asn1.DERInteger; 22 import org.apache.geronimo.util.asn1.DERSequence; 23 import org.apache.geronimo.util.asn1.DERTaggedObject; 24 import org.apache.geronimo.util.asn1.DERUTCTime; 25 26 41 public class V1TBSCertificateGenerator 42 { 43 DERTaggedObject version = new DERTaggedObject(0, new DERInteger(0)); 44 45 DERInteger serialNumber; 46 AlgorithmIdentifier signature; 47 X509Name issuer; 48 Time startDate, endDate; 49 X509Name subject; 50 SubjectPublicKeyInfo subjectPublicKeyInfo; 51 52 public V1TBSCertificateGenerator() 53 { 54 } 55 56 public void setSerialNumber( 57 DERInteger serialNumber) 58 { 59 this.serialNumber = serialNumber; 60 } 61 62 public void setSignature( 63 AlgorithmIdentifier signature) 64 { 65 this.signature = signature; 66 } 67 68 public void setIssuer( 69 X509Name issuer) 70 { 71 this.issuer = issuer; 72 } 73 74 public void setStartDate( 75 Time startDate) 76 { 77 this.startDate = startDate; 78 } 79 80 public void setStartDate( 81 DERUTCTime startDate) 82 { 83 this.startDate = new Time(startDate); 84 } 85 86 public void setEndDate( 87 Time endDate) 88 { 89 this.endDate = endDate; 90 } 91 92 public void setEndDate( 93 DERUTCTime endDate) 94 { 95 this.endDate = new Time(endDate); 96 } 97 98 public void setSubject( 99 X509Name subject) 100 { 101 this.subject = subject; 102 } 103 104 public void setSubjectPublicKeyInfo( 105 SubjectPublicKeyInfo pubKeyInfo) 106 { 107 this.subjectPublicKeyInfo = pubKeyInfo; 108 } 109 110 public TBSCertificateStructure generateTBSCertificate() 111 { 112 if ((serialNumber == null) || (signature == null) 113 || (issuer == null) || (startDate == null) || (endDate == null) 114 || (subject == null) || (subjectPublicKeyInfo == null)) 115 { 116 throw new IllegalStateException ("not all mandatory fields set in V1 TBScertificate generator"); 117 } 118 119 ASN1EncodableVector seq = new ASN1EncodableVector(); 120 121 seq.add(serialNumber); 123 seq.add(signature); 124 seq.add(issuer); 125 126 ASN1EncodableVector validity = new ASN1EncodableVector(); 130 131 validity.add(startDate); 132 validity.add(endDate); 133 134 seq.add(new DERSequence(validity)); 135 136 seq.add(subject); 137 138 seq.add(subjectPublicKeyInfo); 139 140 return new TBSCertificateStructure(new DERSequence(seq)); 141 } 142 } 143 | Popular Tags |