Search in sources :

Example 6 with GeneralizedTime

use of org.demoiselle.signer.policy.engine.asn1.GeneralizedTime in project signer by demoiselle.

the class PolicyInfo method parse.

@Override
public void parse(ASN1Primitive primitive) {
    ASN1Sequence sequence1 = ASN1Object.getDERSequence(primitive);
    this.signingPeriod = new SigningPeriod();
    this.signingPeriod.parse(sequence1.getObjectAt(0).toASN1Primitive());
    int indice = 2;
    ASN1Primitive secondObject = sequence1.getObjectAt(1).toASN1Primitive();
    if (secondObject instanceof ASN1ObjectIdentifier) {
        indice = 1;
    }
    if (indice == 2) {
        this.revocationDate = new GeneralizedTime();
        this.revocationDate.parse(secondObject);
    }
    this.policyOID = new ObjectIdentifier();
    this.policyOID.parse(sequence1.getObjectAt(indice).toASN1Primitive());
    DERIA5String policyURI = (DERIA5String) sequence1.getObjectAt(indice + 1);
    this.policyURI = policyURI.getString();
    ASN1Primitive policyDigest = sequence1.getObjectAt(indice + 2).toASN1Primitive();
    ASN1Sequence sequence2 = ASN1Sequence.getInstance(policyDigest);
    DEROctetString derOctetString = (DEROctetString) sequence2.getObjectAt(1).toASN1Primitive();
    ASN1Sequence sequence3 = ASN1Object.getDERSequence(sequence2.getObjectAt(0).toASN1Primitive());
    ASN1ObjectIdentifier objectIdentifier = (ASN1ObjectIdentifier) sequence3.getObjectAt(0).toASN1Primitive();
    AlgorithmIdentifier algorithmIdentifier = new AlgorithmIdentifier(objectIdentifier);
    this.policyDigest = new OtherHashAlgAndValue(algorithmIdentifier, derOctetString);
}
Also used : SigningPeriod(org.demoiselle.signer.policy.engine.asn1.etsi.SigningPeriod) ASN1Sequence(org.bouncycastle.asn1.ASN1Sequence) DERIA5String(org.bouncycastle.asn1.DERIA5String) GeneralizedTime(org.demoiselle.signer.policy.engine.asn1.GeneralizedTime) ASN1Primitive(org.bouncycastle.asn1.ASN1Primitive) ASN1ObjectIdentifier(org.bouncycastle.asn1.ASN1ObjectIdentifier) DEROctetString(org.bouncycastle.asn1.DEROctetString) OtherHashAlgAndValue(org.bouncycastle.asn1.esf.OtherHashAlgAndValue) ASN1ObjectIdentifier(org.bouncycastle.asn1.ASN1ObjectIdentifier) ObjectIdentifier(org.demoiselle.signer.policy.engine.asn1.etsi.ObjectIdentifier) AlgorithmIdentifier(org.bouncycastle.asn1.x509.AlgorithmIdentifier)

Aggregations

GeneralizedTime (org.demoiselle.signer.policy.engine.asn1.GeneralizedTime)6 ASN1Sequence (org.bouncycastle.asn1.ASN1Sequence)4 ASN1Primitive (org.bouncycastle.asn1.ASN1Primitive)2 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 GregorianCalendar (java.util.GregorianCalendar)1 ASN1Integer (org.bouncycastle.asn1.ASN1Integer)1 ASN1ObjectIdentifier (org.bouncycastle.asn1.ASN1ObjectIdentifier)1 DERIA5String (org.bouncycastle.asn1.DERIA5String)1 DEROctetString (org.bouncycastle.asn1.DEROctetString)1 DLSequence (org.bouncycastle.asn1.DLSequence)1 OtherHashAlgAndValue (org.bouncycastle.asn1.esf.OtherHashAlgAndValue)1 AlgorithmIdentifier (org.bouncycastle.asn1.x509.AlgorithmIdentifier)1 ObjectIdentifier (org.demoiselle.signer.policy.engine.asn1.etsi.ObjectIdentifier)1 SigningPeriod (org.demoiselle.signer.policy.engine.asn1.etsi.SigningPeriod)1 PolicyException (org.demoiselle.signer.policy.engine.exception.PolicyException)1 PolicyFactory (org.demoiselle.signer.policy.engine.factory.PolicyFactory)1