适配ofd签章SES_CertList

import org.bouncycastle.asn1.*;

import java.io.IOException;

/**
 * 签章者证书信息列表
 *
 * @author 权观宇
 * @since 2020-04-19 17:19:36
 */
public class SES_CertList extends ASN1Object
        implements ASN1Choice {
    /**
     * 签章者证书列表
     */
    private final CertInfoList certs;

    /**
     * 签章者证书杂凑值列表
     */
    private final CertDigestList certDigestList;


    public SES_CertList(CertInfoList certs) {
        this.certs = certs;
        this.certDigestList = null;
    }

    public SES_CertList(CertDigestList certDigestList) {
        this.certs = null;
        this.certDigestList = certDigestList;
    }


    public static SES_CertList getInstance(ASN1Integer type, Object obj) {
        if (obj instanceof SES_CertList) {
            return (SES_CertList) obj;
        }

        if (obj != null) {
            if (obj instanceof ASN1Encodable) {
                final int t = type.getValue().intValue();
                /*
                if (t == 1) {
                    return new SES_CertList(CertInfoList.getInstance(obj));
                } else if (t == 2) {
                    return new SES_CertList(CertDigestList.getInstance(obj));
                } else {
                    throw new IllegalArgumentException("unknown type in getInstance(): " + obj.getClass().getName());
                }*/
                if (t == 2) {
                    return new SES_CertList(CertDigestList.getInstance(obj));
                } else {
                	return new SES_CertList(CertInfoList.getInstance(obj));
                }
            }
            if (obj instanceof byte[]) {
                try {
                    return getInstance(type, ASN1Primitive.fromByteArray((byte[]) obj));
                } catch (IOException e) {
                    throw new IllegalArgumentException("unknown encoding in getInstance()");
                }
            }
            throw new IllegalArgumentException("unknown object in getInstance(): " + obj.getClass().getName());
        }

        return null;
    }

    public ASN1Object get() {
        if (certs != null) {
            return certs;
        } else return certDigestList;
    }


    public CertInfoList getCerts() {
        return certs;
    }

    public CertDigestList getCertDigestList() {
        return certDigestList;
    }

    @Override
    public ASN1Primitive toASN1Primitive() {
        return get().toASN1Primitive();
    }
}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值