Search in sources :

Example 1 with ASN1SetParser

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

the class CMSAuthenticatedDataParser method getUnauthAttrs.

/**
 * return a table of the unauthenticated attributes indexed by the OID of the attribute.
 *
 * @throws IOException
 */
public AttributeTable getUnauthAttrs() throws IOException {
    if (unauthAttrs == null && unauthAttrNotRead) {
        ASN1SetParser set = authData.getUnauthAttrs();
        unauthAttrNotRead = false;
        if (set != null) {
            ASN1EncodableVector v = new ASN1EncodableVector();
            ASN1Encodable o;
            while ((o = set.readObject()) != null) {
                ASN1SequenceParser seq = (ASN1SequenceParser) o;
                v.add(seq.toASN1Primitive());
            }
            unauthAttrs = new AttributeTable(new DERSet(v));
        }
    }
    return unauthAttrs;
}
Also used : ASN1SequenceParser(com.github.zhenwei.core.asn1.ASN1SequenceParser) ASN1SetParser(com.github.zhenwei.core.asn1.ASN1SetParser) AttributeTable(com.github.zhenwei.pkix.util.asn1.cms.AttributeTable) ASN1EncodableVector(com.github.zhenwei.core.asn1.ASN1EncodableVector) ASN1Encodable(com.github.zhenwei.core.asn1.ASN1Encodable) DERSet(com.github.zhenwei.core.asn1.DERSet)

Example 2 with ASN1SetParser

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

the class AuthenticatedDataParser method getUnauthAttrs.

public ASN1SetParser getUnauthAttrs() throws IOException {
    if (nextObject == null) {
        nextObject = seq.readObject();
    }
    if (nextObject != null) {
        ASN1TaggedObject o = (ASN1TaggedObject) nextObject;
        nextObject = null;
        return (ASN1SetParser) ASN1Util.parseContextBaseUniversal(o, 3, false, BERTags.SET_OF);
    }
    return null;
}
Also used : ASN1TaggedObject(com.github.zhenwei.core.asn1.ASN1TaggedObject) ASN1SetParser(com.github.zhenwei.core.asn1.ASN1SetParser)

Example 3 with ASN1SetParser

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

the class AuthenticatedDataParser method getRecipientInfos.

public ASN1SetParser getRecipientInfos() throws IOException {
    if (!originatorInfoCalled) {
        getOriginatorInfo();
    }
    if (nextObject == null) {
        nextObject = seq.readObject();
    }
    ASN1SetParser recipientInfos = (ASN1SetParser) nextObject;
    nextObject = null;
    return recipientInfos;
}
Also used : ASN1SetParser(com.github.zhenwei.core.asn1.ASN1SetParser)

Example 4 with ASN1SetParser

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

the class CMSAuthenticatedDataParser method getAuthAttrSet.

private ASN1Set getAuthAttrSet() throws IOException {
    if (authAttrs == null && authAttrNotRead) {
        ASN1SetParser set = authData.getAuthAttrs();
        if (set != null) {
            authAttrSet = (ASN1Set) set.toASN1Primitive();
        }
        authAttrNotRead = false;
    }
    return authAttrSet;
}
Also used : ASN1SetParser(com.github.zhenwei.core.asn1.ASN1SetParser)

Example 5 with ASN1SetParser

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

the class CMSSignedDataParser method getSignerInfos.

/**
 * return the collection of signers that are associated with the signatures for the message.
 *
 * @throws CMSException
 */
public SignerInformationStore getSignerInfos() throws CMSException {
    if (_signerInfoStore == null) {
        populateCertCrlSets();
        List signerInfos = new ArrayList();
        Map hashes = new HashMap();
        Iterator it = digests.keySet().iterator();
        while (it.hasNext()) {
            Object digestKey = it.next();
            hashes.put(digestKey, ((DigestCalculator) digests.get(digestKey)).getDigest());
        }
        try {
            ASN1SetParser s = _signedData.getSignerInfos();
            ASN1Encodable o;
            while ((o = s.readObject()) != null) {
                SignerInfo info = SignerInfo.getInstance(o.toASN1Primitive());
                byte[] hash = (byte[]) hashes.get(info.getDigestAlgorithm().getAlgorithm());
                signerInfos.add(new SignerInformation(info, _signedContentType, null, hash));
            }
        } catch (IOException e) {
            throw new CMSException("io exception: " + e.getMessage(), e);
        }
        _signerInfoStore = new SignerInformationStore(signerInfos);
    }
    return _signerInfoStore;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ASN1SetParser(com.github.zhenwei.core.asn1.ASN1SetParser) IOException(java.io.IOException) SignerInfo(com.github.zhenwei.pkix.util.asn1.cms.SignerInfo) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) BERTaggedObject(com.github.zhenwei.core.asn1.BERTaggedObject) DERTaggedObject(com.github.zhenwei.core.asn1.DERTaggedObject) ASN1Encodable(com.github.zhenwei.core.asn1.ASN1Encodable) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

ASN1SetParser (com.github.zhenwei.core.asn1.ASN1SetParser)14 ASN1TaggedObjectParser (com.github.zhenwei.core.asn1.ASN1TaggedObjectParser)6 ASN1Encodable (com.github.zhenwei.core.asn1.ASN1Encodable)3 ASN1EncodableVector (com.github.zhenwei.core.asn1.ASN1EncodableVector)2 ASN1SequenceParser (com.github.zhenwei.core.asn1.ASN1SequenceParser)2 DERSet (com.github.zhenwei.core.asn1.DERSet)2 AttributeTable (com.github.zhenwei.pkix.util.asn1.cms.AttributeTable)2 IOException (java.io.IOException)2 ASN1ParsingException (com.github.zhenwei.core.asn1.ASN1ParsingException)1 ASN1TaggedObject (com.github.zhenwei.core.asn1.ASN1TaggedObject)1 BERTaggedObject (com.github.zhenwei.core.asn1.BERTaggedObject)1 DERTaggedObject (com.github.zhenwei.core.asn1.DERTaggedObject)1 SignerInfo (com.github.zhenwei.pkix.util.asn1.cms.SignerInfo)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Map (java.util.Map)1