Search in sources :

Example 6 with AttributeCertificateInfo

use of com.github.zhenwei.core.asn1.x509.AttributeCertificateInfo in project LinLong-Java by zhenwei1108.

the class V2AttributeCertificateInfoGenerator method generateAttributeCertificateInfo.

public AttributeCertificateInfo generateAttributeCertificateInfo() {
    if ((serialNumber == null) || (signature == null) || (issuer == null) || (startDate == null) || (endDate == null) || (holder == null) || (attributes == null)) {
        throw new IllegalStateException("not all mandatory fields set in V2 AttributeCertificateInfo generator");
    }
    ASN1EncodableVector v = new ASN1EncodableVector(9);
    v.add(version);
    v.add(holder);
    v.add(issuer);
    v.add(signature);
    v.add(serialNumber);
    // 
    // before and after dates => AttCertValidityPeriod
    // 
    AttCertValidityPeriod validity = new AttCertValidityPeriod(startDate, endDate);
    v.add(validity);
    // Attributes
    v.add(new DERSequence(attributes));
    if (issuerUniqueID != null) {
        v.add(issuerUniqueID);
    }
    if (extensions != null) {
        v.add(extensions);
    }
    return AttributeCertificateInfo.getInstance(new DERSequence(v));
}
Also used : DERSequence(com.github.zhenwei.core.asn1.DERSequence) ASN1EncodableVector(com.github.zhenwei.core.asn1.ASN1EncodableVector)

Example 7 with AttributeCertificateInfo

use of com.github.zhenwei.core.asn1.x509.AttributeCertificateInfo in project LinLong-Java by zhenwei1108.

the class CertUtils method generateAttrStructure.

private static AttributeCertificate generateAttrStructure(AttributeCertificateInfo attrInfo, AlgorithmIdentifier sigAlgId, byte[] signature) {
    ASN1EncodableVector v = new ASN1EncodableVector();
    v.add(attrInfo);
    v.add(sigAlgId);
    v.add(new DERBitString(signature));
    return AttributeCertificate.getInstance(new DERSequence(v));
}
Also used : DERSequence(com.github.zhenwei.core.asn1.DERSequence) ASN1EncodableVector(com.github.zhenwei.core.asn1.ASN1EncodableVector) DERBitString(com.github.zhenwei.core.asn1.DERBitString)

Aggregations

ASN1EncodableVector (com.github.zhenwei.core.asn1.ASN1EncodableVector)4 DERSequence (com.github.zhenwei.core.asn1.DERSequence)4 IOException (java.io.IOException)3 OutputStream (java.io.OutputStream)3 ObjectOutputStream (java.io.ObjectOutputStream)2 AttributeCertificateInfo (org.bouncycastle.asn1.x509.AttributeCertificateInfo)2 ContentVerifier (org.bouncycastle.operator.ContentVerifier)2 DERBitString (com.github.zhenwei.core.asn1.DERBitString)1 AttributeCertificateInfo (com.github.zhenwei.core.asn1.x509.AttributeCertificateInfo)1 ContentVerifier (com.github.zhenwei.pkix.operator.ContentVerifier)1 DEROutputStream (org.bouncycastle.asn1.DEROutputStream)1