use of com.github.zhenwei.core.asn1.ocsp.Signature in project LinLong-Java by zhenwei1108.
the class TBSCertificate method toASN1Primitive.
public ASN1Primitive toASN1Primitive() {
if (Properties.getPropertyValue("com.github.zhenwei.provider.x509.allow_non-der_tbscert") != null) {
if (Properties.isOverrideSet("com.github.zhenwei.provider.x509.allow_non-der_tbscert")) {
return seq;
}
} else {
return seq;
}
ASN1EncodableVector v = new ASN1EncodableVector();
// DEFAULT Zero
if (!version.hasValue(0)) {
v.add(new DERTaggedObject(true, 0, version));
}
v.add(serialNumber);
v.add(signature);
v.add(issuer);
//
// before and after dates
//
{
ASN1EncodableVector validity = new ASN1EncodableVector(2);
validity.add(startDate);
validity.add(endDate);
v.add(new DERSequence(validity));
}
if (subject != null) {
v.add(subject);
} else {
v.add(new DERSequence());
}
v.add(subjectPublicKeyInfo);
// Note: implicit tag
if (issuerUniqueId != null) {
v.add(new DERTaggedObject(false, 1, issuerUniqueId));
}
// Note: implicit tag
if (subjectUniqueId != null) {
v.add(new DERTaggedObject(false, 2, subjectUniqueId));
}
if (extensions != null) {
v.add(new DERTaggedObject(true, 3, extensions));
}
return new DERSequence(v);
}
use of com.github.zhenwei.core.asn1.ocsp.Signature in project LinLong-Java by zhenwei1108.
the class V1TBSCertificateGenerator method generateTBSCertificate.
public TBSCertificate generateTBSCertificate() {
if ((serialNumber == null) || (signature == null) || (issuer == null) || (startDate == null) || (endDate == null) || (subject == null) || (subjectPublicKeyInfo == null)) {
throw new IllegalStateException("not all mandatory fields set in V1 TBScertificate generator");
}
ASN1EncodableVector seq = new ASN1EncodableVector(6);
// seq.add(version); - not required as default value.
seq.add(serialNumber);
seq.add(signature);
seq.add(issuer);
//
// before and after dates
//
{
ASN1EncodableVector validity = new ASN1EncodableVector(2);
validity.add(startDate);
validity.add(endDate);
seq.add(new DERSequence(validity));
}
seq.add(subject);
seq.add(subjectPublicKeyInfo);
return TBSCertificate.getInstance(new DERSequence(seq));
}
use of com.github.zhenwei.core.asn1.ocsp.Signature in project LinLong-Java by zhenwei1108.
the class V2TBSCertListGenerator method generateTBSCertList.
public TBSCertList generateTBSCertList() {
if ((signature == null) || (issuer == null) || (thisUpdate == null)) {
throw new IllegalStateException("Not all mandatory fields set in V2 TBSCertList generator.");
}
ASN1EncodableVector v = new ASN1EncodableVector(7);
v.add(version);
v.add(signature);
v.add(issuer);
v.add(thisUpdate);
if (nextUpdate != null) {
v.add(nextUpdate);
}
// Add CRLEntries if they exist
if (crlentries.size() != 0) {
v.add(new DERSequence(crlentries));
}
if (extensions != null) {
v.add(new DERTaggedObject(0, extensions));
}
return new TBSCertList(new DERSequence(v));
}
use of com.github.zhenwei.core.asn1.ocsp.Signature in project LinLong-Java by zhenwei1108.
the class Signature method toASN1Primitive.
/**
* Produce an object suitable for an ASN1OutputStream.
* <pre>
* Signature ::= SEQUENCE {
* signatureAlgorithm AlgorithmIdentifier,
* signature BIT STRING,
* certs [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL}
* </pre>
*/
public ASN1Primitive toASN1Primitive() {
ASN1EncodableVector v = new ASN1EncodableVector(3);
v.add(signatureAlgorithm);
v.add(signature);
if (certs != null) {
v.add(new DERTaggedObject(true, 0, certs));
}
return new DERSequence(v);
}
use of com.github.zhenwei.core.asn1.ocsp.Signature in project LinLong-Java by zhenwei1108.
the class BasicOCSPResponse method toASN1Primitive.
/**
* Produce an object suitable for an ASN1OutputStream.
* <pre>
* BasicOCSPResponse ::= SEQUENCE {
* tbsResponseData ResponseData,
* signatureAlgorithm AlgorithmIdentifier,
* signature BIT STRING,
* certs [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL }
* </pre>
*/
public ASN1Primitive toASN1Primitive() {
ASN1EncodableVector v = new ASN1EncodableVector(4);
v.add(tbsResponseData);
v.add(signatureAlgorithm);
v.add(signature);
if (certs != null) {
v.add(new DERTaggedObject(true, 0, certs));
}
return new DERSequence(v);
}
Aggregations