Search in sources :

Example 31 with DERTaggedObject

use of org.bouncycastle.asn1.DERTaggedObject in project signer by demoiselle.

the class RevocationRefs method getValue.

@Override
public Attribute getValue() throws SignerException {
    try {
        int chainSize = certificates.length - 1;
        ArrayList<CrlValidatedID> crls = new ArrayList<CrlValidatedID>();
        for (int ix = 0; ix < chainSize; ix++) {
            X509Certificate cert = (X509Certificate) certificates[ix];
            Collection<ICPBR_CRL> icpCrls = crlRepository.getX509CRL(cert);
            for (ICPBR_CRL icpCrl : icpCrls) {
                crls.add(makeCrlValidatedID(icpCrl.getCRL()));
            }
        }
        int crlsIdSize = crls.size();
        CrlValidatedID[] crlsForId = new CrlValidatedID[crlsIdSize];
        int i = 0;
        for (CrlValidatedID crlVID : crls) {
            crlsForId[i] = crlVID;
            i++;
        }
        // CrlListID crlids = new CrlListID(crlsForId);
        DERSequence crlValidatedIDSeq = new DERSequence(crlsForId);
        // --CRLListID--/
        ASN1Encodable[] crlValidatedIDSeqArr = new ASN1Encodable[1];
        crlValidatedIDSeqArr[0] = crlValidatedIDSeq;
        DERSequence crlListID = new DERSequence(crlValidatedIDSeqArr);
        // CRLListID--/
        DERTaggedObject crlListIDTagged = new DERTaggedObject(0, crlListID);
        // CrlOcspRef--/
        ASN1Encodable[] crlListIDTaggedArr = new ASN1Encodable[1];
        crlListIDTaggedArr[0] = crlListIDTagged;
        DERSequence crlOscpRef = new DERSequence(crlListIDTaggedArr);
        // --CompleteRevocationRefs--/
        ASN1Encodable[] crlOscpRefArr = new ASN1Encodable[1];
        crlOscpRefArr[0] = crlOscpRef;
        DERSequence completeRevocationRefs = new DERSequence(crlOscpRefArr);
        // CrlOcspRef crlOcspRef = new CrlOcspRef(crlids, null, null);
        return new Attribute(new ASN1ObjectIdentifier(identifier), new DERSet(completeRevocationRefs));
    // CrlOcspRef[] crlOcspRefArray = new
    // CrlOcspRef[completeRevocationRefs.size()];
    } catch (NoSuchAlgorithmException | CRLException e) {
        throw new SignerException(e.getMessage());
    }
}
Also used : Attribute(org.bouncycastle.asn1.cms.Attribute) UnsignedAttribute(org.demoiselle.signer.policy.impl.cades.pkcs7.attribute.UnsignedAttribute) DERTaggedObject(org.bouncycastle.asn1.DERTaggedObject) ArrayList(java.util.ArrayList) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) DERSet(org.bouncycastle.asn1.DERSet) X509Certificate(java.security.cert.X509Certificate) ICPBR_CRL(org.demoiselle.signer.core.extension.ICPBR_CRL) CrlValidatedID(org.bouncycastle.asn1.esf.CrlValidatedID) DERSequence(org.bouncycastle.asn1.DERSequence) ASN1Encodable(org.bouncycastle.asn1.ASN1Encodable) CRLException(java.security.cert.CRLException) SignerException(org.demoiselle.signer.policy.impl.cades.SignerException) ASN1ObjectIdentifier(org.bouncycastle.asn1.ASN1ObjectIdentifier)

Example 32 with DERTaggedObject

use of org.bouncycastle.asn1.DERTaggedObject in project signer by demoiselle.

the class SignerRules method parse.

@Override
public void parse(ASN1Primitive primitive) {
    ASN1Sequence derSequence = ASN1Object.getDERSequence(primitive);
    int total = derSequence.size();
    if (total > 0) {
        for (int i = 0; i < total; i++) {
            ASN1Primitive object = derSequence.getObjectAt(i).toASN1Primitive();
            if (object instanceof DERTaggedObject) {
                DERTaggedObject derTaggedObject = (DERTaggedObject) object;
                TAG tag = TAG.getTag(derTaggedObject.getTagNo());
                switch(tag) {
                    case mandatedCertificateRef:
                        this.mandatedCertificateRef = CertRefReq.parse(object);
                        break;
                    case mandatedCertificateInfo:
                        this.mandatedCertificateInfo = CertInfoReq.parse(object);
                        break;
                    case signPolExtensions:
                        this.signPolExtensions = new SignPolExtensions();
                        this.signPolExtensions.parse(object);
                        break;
                    default:
                        break;
                }
            }
        }
    }
    int i = 0;
    ASN1Encodable object = derSequence.getObjectAt(i);
    if (!(object instanceof DERSequence)) {
        if (object instanceof ASN1Boolean) {
            this.externalSignedData = ((ASN1Boolean) object).isTrue();
        }
        i++;
    }
    this.mandatedSignedAttr = new CMSAttrs();
    this.mandatedSignedAttr.parse(derSequence.getObjectAt(i).toASN1Primitive());
    i++;
    this.mandatedUnsignedAttr = new CMSAttrs();
    this.mandatedUnsignedAttr.parse(derSequence.getObjectAt(i).toASN1Primitive());
}
Also used : ASN1Sequence(org.bouncycastle.asn1.ASN1Sequence) DERSequence(org.bouncycastle.asn1.DERSequence) DERTaggedObject(org.bouncycastle.asn1.DERTaggedObject) ASN1Encodable(org.bouncycastle.asn1.ASN1Encodable) ASN1Boolean(org.bouncycastle.asn1.ASN1Boolean) ASN1Primitive(org.bouncycastle.asn1.ASN1Primitive)

Example 33 with DERTaggedObject

use of org.bouncycastle.asn1.DERTaggedObject in project signer by demoiselle.

the class PolicyConstraints method parse.

@Override
public void parse(ASN1Primitive derObject) {
    ASN1Sequence derSequence = ASN1Object.getDERSequence(derObject);
    int total = derSequence.size();
    if (total > 0) {
        for (int i = 0; i < total; i++) {
            ASN1Primitive object = derSequence.getObjectAt(i).toASN1Primitive();
            if (object instanceof DERTaggedObject) {
                DERTaggedObject derTaggedObject = (DERTaggedObject) object;
                TAG tag = TAG.getTag(derTaggedObject.getTagNo());
                switch(tag) {
                    case requireExplicitPolicy:
                        this.requireExplicitPolicy = new SkipCerts();
                        this.requireExplicitPolicy.parse(object);
                        break;
                    case inhibitPolicyMapping:
                        this.inhibitPolicyMapping = new SkipCerts();
                        this.inhibitPolicyMapping.parse(object);
                        break;
                    default:
                        break;
                }
            }
        }
    }
}
Also used : ASN1Sequence(org.bouncycastle.asn1.ASN1Sequence) DERTaggedObject(org.bouncycastle.asn1.DERTaggedObject) ASN1Primitive(org.bouncycastle.asn1.ASN1Primitive)

Example 34 with DERTaggedObject

use of org.bouncycastle.asn1.DERTaggedObject in project signer by demoiselle.

the class CertificateTrustPoint method parse.

@Override
public void parse(ASN1Primitive derObject) {
    ASN1Sequence derSequence = ASN1Object.getDERSequence(derObject);
    DERSequence x509Sequence = (DERSequence) derSequence.getObjectAt(0).toASN1Primitive();
    try {
        ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(x509Sequence.getEncoded());
        this.trustpoint = (X509Certificate) CertificateFactory.getInstance("X509").generateCertificate(byteArrayInputStream);
    } catch (Throwable error) {
        error.printStackTrace();
    }
    int total = derSequence.size();
    if (total > 0) {
        for (int i = 0; i < total; i++) {
            ASN1Primitive object = derSequence.getObjectAt(i).toASN1Primitive();
            if (object instanceof DERTaggedObject) {
                DERTaggedObject derTaggedObject = (DERTaggedObject) object;
                TAG tag = TAG.getTag(derTaggedObject.getTagNo());
                switch(tag) {
                    case pathLenConstraint:
                        this.pathLenConstraint = new PathLenConstraint();
                        this.pathLenConstraint.parse(object);
                        break;
                    case acceptablePolicySet:
                        this.acceptablePolicySet = new AcceptablePolicySet();
                        this.acceptablePolicySet.parse(object);
                        break;
                    case nameConstraints:
                        this.nameConstraints = new NameConstraints();
                        this.nameConstraints.parse(object);
                        break;
                    case policyConstraints:
                        this.policyConstraints = new PolicyConstraints();
                        this.policyConstraints.parse(object);
                        break;
                    default:
                        break;
                }
            }
        }
    }
}
Also used : ASN1Sequence(org.bouncycastle.asn1.ASN1Sequence) DERSequence(org.bouncycastle.asn1.DERSequence) ByteArrayInputStream(java.io.ByteArrayInputStream) DERTaggedObject(org.bouncycastle.asn1.DERTaggedObject) ASN1Primitive(org.bouncycastle.asn1.ASN1Primitive)

Example 35 with DERTaggedObject

use of org.bouncycastle.asn1.DERTaggedObject in project signer by demoiselle.

the class CommitmentType method parse.

@Override
public void parse(ASN1Primitive derObject) {
    ASN1Sequence derSequence = ASN1Object.getDERSequence(derObject);
    this.identifier = new CommitmentTypeIdentifier();
    this.identifier.parse(derSequence.getObjectAt(0).toASN1Primitive());
    int total = derSequence.size();
    if (total > 0) {
        for (int i = 0; i < total; i++) {
            ASN1Primitive object = derSequence.getObjectAt(i).toASN1Primitive();
            if (object instanceof DERTaggedObject) {
                DERTaggedObject derTaggedObject = (DERTaggedObject) object;
                TAG tag = TAG.getTag(derTaggedObject.getTagNo());
                switch(tag) {
                    case fieldOfApplication:
                        this.fieldOfApplication = new FieldOfApplication();
                        this.fieldOfApplication.parse(object);
                        break;
                    case semantics:
                        break;
                    default:
                        break;
                }
            }
        }
    }
}
Also used : ASN1Sequence(org.bouncycastle.asn1.ASN1Sequence) DERTaggedObject(org.bouncycastle.asn1.DERTaggedObject) ASN1Primitive(org.bouncycastle.asn1.ASN1Primitive)

Aggregations

DERTaggedObject (org.bouncycastle.asn1.DERTaggedObject)73 ASN1EncodableVector (org.bouncycastle.asn1.ASN1EncodableVector)42 DERSequence (org.bouncycastle.asn1.DERSequence)40 ASN1Sequence (org.bouncycastle.asn1.ASN1Sequence)22 DEROctetString (org.bouncycastle.asn1.DEROctetString)21 ASN1ObjectIdentifier (org.bouncycastle.asn1.ASN1ObjectIdentifier)18 ASN1Primitive (org.bouncycastle.asn1.ASN1Primitive)16 DERUTF8String (org.bouncycastle.asn1.DERUTF8String)16 DLSequence (org.bouncycastle.asn1.DLSequence)14 IOException (java.io.IOException)11 ASN1Encodable (org.bouncycastle.asn1.ASN1Encodable)11 ASN1OctetString (org.bouncycastle.asn1.ASN1OctetString)11 DERIA5String (org.bouncycastle.asn1.DERIA5String)10 GeneralName (org.bouncycastle.asn1.x509.GeneralName)10 ASN1Integer (org.bouncycastle.asn1.ASN1Integer)9 BigInteger (java.math.BigInteger)7 DERPrintableString (org.bouncycastle.asn1.DERPrintableString)7 BERSequence (org.bouncycastle.asn1.BERSequence)6 DERGeneralizedTime (org.bouncycastle.asn1.DERGeneralizedTime)6 DERSet (org.bouncycastle.asn1.DERSet)6