Search in sources :

Example 66 with ASN1Primitive

use of com.github.zhenwei.core.asn1.ASN1Primitive in project signer by demoiselle.

the class PolicyFactory method loadLPA.

/**
 * @return LPA ICP Brasil signature policy v1
 * @deprecated Politics DISCONTINUED
 */
@Deprecated
public LPA loadLPA() {
    org.demoiselle.signer.policy.engine.asn1.icpb.LPA listaPoliticaAssinatura = new org.demoiselle.signer.policy.engine.asn1.icpb.LPA();
    InputStream is = this.getClass().getResourceAsStream(ListOfSubscriptionPolicies.LPAV1.getFile());
    ASN1Primitive primitive = this.readANS1FromStream(is);
    listaPoliticaAssinatura.parse(primitive);
    return listaPoliticaAssinatura;
}
Also used : FileInputStream(java.io.FileInputStream) ASN1InputStream(org.bouncycastle.asn1.ASN1InputStream) InputStream(java.io.InputStream) LPA(org.demoiselle.signer.policy.engine.asn1.icpb.LPA) ASN1Primitive(org.bouncycastle.asn1.ASN1Primitive) LPA(org.demoiselle.signer.policy.engine.asn1.icpb.LPA)

Example 67 with ASN1Primitive

use of com.github.zhenwei.core.asn1.ASN1Primitive in project signer by demoiselle.

the class PolicyFactory method loadLPAv2.

/**
 * @return LPA ICP Brasil signature policy v2
 * @deprecated Politics DISCONTINUED 28/11/2016
 */
@Deprecated
public org.demoiselle.signer.policy.engine.asn1.icpb.v2.LPA loadLPAv2() {
    org.demoiselle.signer.policy.engine.asn1.icpb.v2.LPA listaPoliticaAssinatura = new org.demoiselle.signer.policy.engine.asn1.icpb.v2.LPA();
    InputStream is = this.getClass().getResourceAsStream(ListOfSubscriptionPolicies.LPAV2.getFile());
    ASN1Primitive primitive = this.readANS1FromStream(is);
    listaPoliticaAssinatura.parse(primitive);
    return listaPoliticaAssinatura;
}
Also used : FileInputStream(java.io.FileInputStream) ASN1InputStream(org.bouncycastle.asn1.ASN1InputStream) InputStream(java.io.InputStream) LPA(org.demoiselle.signer.policy.engine.asn1.icpb.LPA) ASN1Primitive(org.bouncycastle.asn1.ASN1Primitive)

Example 68 with ASN1Primitive

use of com.github.zhenwei.core.asn1.ASN1Primitive 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 69 with ASN1Primitive

use of com.github.zhenwei.core.asn1.ASN1Primitive 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 70 with ASN1Primitive

use of com.github.zhenwei.core.asn1.ASN1Primitive in project signer by demoiselle.

the class SelectedCommitmentTypes method parse.

@Override
public void parse(ASN1Primitive derObject) {
    ASN1Sequence derSequence = ASN1Object.getDERSequence(derObject);
    ASN1Primitive object = derSequence.getObjectAt(0).toASN1Primitive();
    if (object instanceof DERNull) {
        this.recognizedCommitmentType = null;
    } else if (object instanceof DERSequence) {
        this.recognizedCommitmentType = new CommitmentType();
        this.recognizedCommitmentType.parse(object);
    }
}
Also used : ASN1Sequence(org.bouncycastle.asn1.ASN1Sequence) DERSequence(org.bouncycastle.asn1.DERSequence) DERNull(org.bouncycastle.asn1.DERNull) ASN1Primitive(org.bouncycastle.asn1.ASN1Primitive)

Aggregations

ASN1EncodableVector (com.github.zhenwei.core.asn1.ASN1EncodableVector)253 DERSequence (com.github.zhenwei.core.asn1.DERSequence)231 ASN1Primitive (org.bouncycastle.asn1.ASN1Primitive)177 IOException (java.io.IOException)107 ASN1InputStream (org.bouncycastle.asn1.ASN1InputStream)62 ASN1Sequence (org.bouncycastle.asn1.ASN1Sequence)57 DERTaggedObject (com.github.zhenwei.core.asn1.DERTaggedObject)55 ASN1Integer (com.github.zhenwei.core.asn1.ASN1Integer)42 DEROctetString (com.github.zhenwei.core.asn1.DEROctetString)38 ByteArrayInputStream (java.io.ByteArrayInputStream)38 ASN1OctetString (org.bouncycastle.asn1.ASN1OctetString)32 ASN1Primitive (com.github.zhenwei.core.asn1.ASN1Primitive)31 ASN1ObjectIdentifier (org.bouncycastle.asn1.ASN1ObjectIdentifier)31 ASN1Encodable (org.bouncycastle.asn1.ASN1Encodable)30 DEROctetString (org.bouncycastle.asn1.DEROctetString)28 BigInteger (java.math.BigInteger)24 GeneralSecurityException (java.security.GeneralSecurityException)24 X509Certificate (java.security.cert.X509Certificate)24 ASN1Integer (org.bouncycastle.asn1.ASN1Integer)23 DERIA5String (org.bouncycastle.asn1.DERIA5String)22