All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.commons.ssl.asn1.ASN1ObjectParser Maven / Gradle / Ivy

package org.apache.commons.ssl.asn1;

import java.io.IOException;
import java.io.InputStream;

public class ASN1ObjectParser {
    private int _baseTag;
    private int _tagNumber;

    private ASN1StreamParser _aIn;

    protected ASN1ObjectParser(
        int baseTag,
        int tagNumber,
        InputStream contentStream) {
        _baseTag = baseTag;
        _tagNumber = tagNumber;
        _aIn = new ASN1StreamParser(contentStream);
    }

    /**
     * Return the tag number for this object.
     *
     * @return the tag number.
     */
    int getTagNumber() {
        return _tagNumber;
    }

    int getBaseTag() {
        return _baseTag;
    }

    DEREncodable readObject()
        throws IOException {
        return _aIn.readObject();
    }

    ASN1EncodableVector readVector()
        throws IllegalStateException {
        ASN1EncodableVector v = new ASN1EncodableVector();
        DEREncodable obj;

        try {
            while ((obj = readObject()) != null) {
                v.add(obj.getDERObject());
            }
        }
        catch (IOException e) {
            throw new IllegalStateException(e.getMessage());
        }

        return v;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy