Search in sources :

Example 1 with ASN1SequenceParser

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

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

the class CMSCompressedDataParser method getContent.

/**
 * Return a typed stream which will allow the reading of the compressed content in expanded form.
 *
 * @param expanderProvider a provider of expander algorithm implementations.
 * @return a type stream which will yield the un-compressed content.
 * @throws CMSException if there is an exception parsing the CompressedData object.
 */
public CMSTypedStream getContent(InputExpanderProvider expanderProvider) throws CMSException {
    try {
        CompressedDataParser comData = new CompressedDataParser((ASN1SequenceParser) _contentInfo.getContent(BERTags.SEQUENCE));
        ContentInfoParser content = comData.getEncapContentInfo();
        InputExpander expander = expanderProvider.get(comData.getCompressionAlgorithmIdentifier());
        ASN1OctetStringParser bytes = (ASN1OctetStringParser) content.getContent(BERTags.OCTET_STRING);
        return new CMSTypedStream(content.getContentType(), expander.getInputStream(bytes.getOctetStream()));
    } catch (IOException e) {
        throw new CMSException("IOException reading compressed content.", e);
    }
}
Also used : ContentInfoParser(com.github.zhenwei.pkix.util.asn1.cms.ContentInfoParser) CompressedDataParser(com.github.zhenwei.pkix.util.asn1.cms.CompressedDataParser) InputExpander(com.github.zhenwei.pkix.operator.InputExpander) IOException(java.io.IOException) ASN1OctetStringParser(com.github.zhenwei.core.asn1.ASN1OctetStringParser)

Example 3 with ASN1SequenceParser

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

the class AuthEnvelopedDataParser method getOriginatorInfo.

public OriginatorInfo getOriginatorInfo() throws IOException {
    originatorInfoCalled = true;
    if (nextObject == null) {
        nextObject = seq.readObject();
    }
    if (nextObject instanceof ASN1TaggedObjectParser) {
        ASN1TaggedObjectParser o = (ASN1TaggedObjectParser) nextObject;
        if (o.hasContextTag(0)) {
            ASN1SequenceParser originatorInfo = (ASN1SequenceParser) o.parseBaseUniversal(false, BERTags.SEQUENCE);
            nextObject = null;
            return OriginatorInfo.getInstance(originatorInfo.getLoadedObject());
        }
    }
    return null;
}
Also used : ASN1SequenceParser(com.github.zhenwei.core.asn1.ASN1SequenceParser) ASN1TaggedObjectParser(com.github.zhenwei.core.asn1.ASN1TaggedObjectParser)

Example 4 with ASN1SequenceParser

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

the class AuthEnvelopedDataParser method getAuthEncryptedContentInfo.

public EncryptedContentInfoParser getAuthEncryptedContentInfo() throws IOException {
    if (nextObject == null) {
        nextObject = seq.readObject();
    }
    if (nextObject != null) {
        ASN1SequenceParser o = (ASN1SequenceParser) nextObject;
        nextObject = null;
        EncryptedContentInfoParser encryptedContentInfoParser = new EncryptedContentInfoParser(o);
        isData = CMSObjectIdentifiers.data.equals(encryptedContentInfoParser.getContentType());
        return encryptedContentInfoParser;
    }
    return null;
}
Also used : ASN1SequenceParser(com.github.zhenwei.core.asn1.ASN1SequenceParser)

Example 5 with ASN1SequenceParser

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

the class AuthenticatedDataParser method getMacAlgorithm.

public AlgorithmIdentifier getMacAlgorithm() throws IOException {
    if (nextObject == null) {
        nextObject = seq.readObject();
    }
    if (nextObject != null) {
        ASN1SequenceParser o = (ASN1SequenceParser) nextObject;
        nextObject = null;
        return AlgorithmIdentifier.getInstance(o.toASN1Primitive());
    }
    return null;
}
Also used : ASN1SequenceParser(com.github.zhenwei.core.asn1.ASN1SequenceParser)

Aggregations

ASN1SequenceParser (com.github.zhenwei.core.asn1.ASN1SequenceParser)9 ASN1EncodableVector (com.github.zhenwei.core.asn1.ASN1EncodableVector)3 ASN1TaggedObjectParser (com.github.zhenwei.core.asn1.ASN1TaggedObjectParser)3 DERSet (com.github.zhenwei.core.asn1.DERSet)3 ContentInfoParser (com.github.zhenwei.pkix.util.asn1.cms.ContentInfoParser)3 ASN1Encodable (com.github.zhenwei.core.asn1.ASN1Encodable)2 ASN1SetParser (com.github.zhenwei.core.asn1.ASN1SetParser)2 ASN1StreamParser (com.github.zhenwei.core.asn1.ASN1StreamParser)2 BERSequenceGenerator (com.github.zhenwei.core.asn1.BERSequenceGenerator)2 AttributeTable (com.github.zhenwei.pkix.util.asn1.cms.AttributeTable)2 SignedDataParser (com.github.zhenwei.pkix.util.asn1.cms.SignedDataParser)2 ASN1OctetStringParser (com.github.zhenwei.core.asn1.ASN1OctetStringParser)1 ASN1Set (com.github.zhenwei.core.asn1.ASN1Set)1 DERTaggedObject (com.github.zhenwei.core.asn1.DERTaggedObject)1 InputExpander (com.github.zhenwei.pkix.operator.InputExpander)1 CompressedDataParser (com.github.zhenwei.pkix.util.asn1.cms.CompressedDataParser)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 List (java.util.List)1