Search in sources :

Example 61 with DERTaggedObject

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

the class PolicyInfo method parse.

@Override
public void parse(ASN1Primitive derObject) {
    ASN1Sequence derSequence = ASN1Object.getDERSequence(derObject);
    ASN1Primitive firstObject = derSequence.getObjectAt(0).toASN1Primitive();
    this.policyName = new DirectoryString(firstObject.toString());
    ASN1Primitive secondObject = derSequence.getObjectAt(1).toASN1Primitive();
    String fieldOfApplication = secondObject.toString();
    this.fieldOfApplication = new DirectoryString(fieldOfApplication);
    this.signingPeriod = new SigningPeriod();
    this.signingPeriod.parse(derSequence.getObjectAt(2).toASN1Primitive());
    int indice = 3;
    ASN1Primitive revocationObject = derSequence.getObjectAt(indice).toASN1Primitive();
    if (!(secondObject instanceof DERTaggedObject)) {
        indice = 4;
    }
    if (indice == 3) {
        this.revocationDate = new Time();
        this.revocationDate.parse(revocationObject);
    }
}
Also used : SigningPeriod(org.demoiselle.signer.policy.engine.asn1.etsi.SigningPeriod) ASN1Sequence(org.bouncycastle.asn1.ASN1Sequence) DERTaggedObject(org.bouncycastle.asn1.DERTaggedObject) DirectoryString(org.bouncycastle.asn1.x500.DirectoryString) DirectoryString(org.bouncycastle.asn1.x500.DirectoryString) ASN1Primitive(org.bouncycastle.asn1.ASN1Primitive)

Example 62 with DERTaggedObject

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

the class TimestampTrustCondition 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 ttsCertificateTrustTrees:
                        this.ttsCertificateTrustTrees = new CertificateTrustTrees();
                        this.ttsCertificateTrustTrees.parse(object);
                        break;
                    case ttsRevReq:
                        this.ttsRevReq = new CertRevReq();
                        this.ttsRevReq.parse(object);
                        break;
                    case ttsNameConstraints:
                        this.ttsNameConstraints = new NameConstraints();
                        this.ttsNameConstraints.parse(object);
                        break;
                    case cautionPeriod:
                        this.cautionPeriod = new DeltaTime();
                        this.cautionPeriod.parse(object);
                        break;
                    case signatureTimestampDelay:
                        this.signatureTimestampDelay = new DeltaTime();
                        this.signatureTimestampDelay.parse(object);
                        break;
                    default:
                        break;
                }
            }
        }
    }
}
Also used : ASN1Sequence(org.bouncycastle.asn1.ASN1Sequence) DERTaggedObject(org.bouncycastle.asn1.DERTaggedObject) ASN1Primitive(org.bouncycastle.asn1.ASN1Primitive)

Example 63 with DERTaggedObject

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

the class AlgorithmConstraintSet 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 signerAlgorithmConstraints:
                        this.signerAlgorithmConstraints = new AlgorithmConstraints();
                        this.signerAlgorithmConstraints.parse(object);
                        break;
                    case eeCertAlgorithmConstraints:
                        this.eeCertAlgorithmConstraints = new AlgorithmConstraints();
                        this.eeCertAlgorithmConstraints.parse(object);
                        break;
                    case caCertAlgorithmConstraints:
                        this.caCertAlgorithmConstraints = new AlgorithmConstraints();
                        this.caCertAlgorithmConstraints.parse(object);
                        break;
                    case aaCertAlgorithmConstraints:
                        this.aaCertAlgorithmConstraints = new AlgorithmConstraints();
                        this.aaCertAlgorithmConstraints.parse(object);
                        break;
                    case tsaCertAlgorithmConstraints:
                        this.tsaCertAlgorithmConstraints = new AlgorithmConstraints();
                        this.tsaCertAlgorithmConstraints.parse(object);
                        break;
                    default:
                        break;
                }
            }
        }
    }
}
Also used : ASN1Sequence(org.bouncycastle.asn1.ASN1Sequence) DERTaggedObject(org.bouncycastle.asn1.DERTaggedObject) ASN1Primitive(org.bouncycastle.asn1.ASN1Primitive)

Example 64 with DERTaggedObject

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

the class AttributeTrustCondition 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 attrCertificateTrustTrees:
                        this.attrCertificateTrustTrees = new CertificateTrustTrees();
                        this.attrCertificateTrustTrees.parse(object);
                        break;
                    case attrRevReq:
                        this.attrRevReq = new CertRevReq();
                        this.attrRevReq.parse(object);
                        break;
                    case attributeConstraints:
                        this.attributeConstraints = new AttributeConstraints();
                        this.attributeConstraints.parse(object);
                        break;
                    default:
                        break;
                }
            }
        }
    }
    super.parse(derObject);
}
Also used : ASN1Sequence(org.bouncycastle.asn1.ASN1Sequence) DERTaggedObject(org.bouncycastle.asn1.DERTaggedObject) ASN1Primitive(org.bouncycastle.asn1.ASN1Primitive)

Example 65 with DERTaggedObject

use of org.bouncycastle.asn1.DERTaggedObject in project candlepin by candlepin.

the class X509CRLStreamWriter method offsetNextUpdate.

/**
 * Write a new nextUpdate time that is the same amount of time ahead of the new thisUpdate
 * time as the old nextUpdate was from the old thisUpdate.
 *
 * @param out
 * @param tagNo
 * @param oldThisUpdate
 * @throws IOException
 */
protected void offsetNextUpdate(OutputStream out, int tagNo, Date oldThisUpdate) throws IOException {
    int originalLength = readLength(crlIn, null);
    byte[] oldBytes = new byte[originalLength];
    readFullyAndTrack(crlIn, oldBytes, null);
    ASN1Object oldTime = null;
    if (tagNo == UTC_TIME) {
        ASN1TaggedObject t = new DERTaggedObject(UTC_TIME, new DEROctetString(oldBytes));
        oldTime = ASN1UTCTime.getInstance(t, false);
    } else {
        ASN1TaggedObject t = new DERTaggedObject(GENERALIZED_TIME, new DEROctetString(oldBytes));
        oldTime = ASN1GeneralizedTime.getInstance(t, false);
    }
    /* Determine the time between the old thisUpdate and old nextUpdate and add it
        /* to the new nextUpdate. */
    Date oldNextUpdate = Time.getInstance(oldTime).getDate();
    long delta = oldNextUpdate.getTime() - oldThisUpdate.getTime();
    Date newNextUpdate = new Date(new Date().getTime() + delta);
    ASN1Object newTime = null;
    if (tagNo == UTC_TIME) {
        newTime = new DERUTCTime(newNextUpdate);
    } else {
        newTime = new DERGeneralizedTime(newNextUpdate);
    }
    writeNewTime(out, newTime, originalLength);
}
Also used : DERGeneralizedTime(org.bouncycastle.asn1.DERGeneralizedTime) DERUTCTime(org.bouncycastle.asn1.DERUTCTime) DERTaggedObject(org.bouncycastle.asn1.DERTaggedObject) ASN1TaggedObject(org.bouncycastle.asn1.ASN1TaggedObject) ASN1Object(org.bouncycastle.asn1.ASN1Object) DEROctetString(org.bouncycastle.asn1.DEROctetString) Date(java.util.Date)

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