Search in sources :

Example 1 with WeGooCipherException

use of com.github.zhenwei.core.exception.WeGooCipherException in project LinLong-Java by zhenwei1108.

the class P7Builder method build.

/**
 * @param [typeEnum, data]
 * @return com.github.zhenwei.core.asn1.pkcs.ContentInfo
 * @author zhangzhenwei
 * @description 封装pkcs7
 * 参考 RFC-2315 / GMT-0010
 * ContentInfo ::= SEQUENCE {
 * contentType ContentType,
 * content [0] EXPLICIT ANY DEFINED BY contentType OPTIONAL }
 * @date 2022/3/1  7:27 下午
 * @since: 1.0.0
 */
public ContentInfo build(BasePkcs7TypeEnum typeEnum, byte[] data) throws WeGooCryptoException {
    ContentInfo contentInfo;
    // 根据枚举类型判断是否为国密类型。国密类型OID 有另定义
    if (typeEnum instanceof Pkcs7ContentInfoTypeEnum) {
        Pkcs7ContentInfoTypeEnum infoTypeEnum = (Pkcs7ContentInfoTypeEnum) typeEnum;
        contentInfo = genPkcs7ContentInfo(infoTypeEnum, data);
    } else if (typeEnum instanceof GmPkcs7ContentInfoTypeEnum) {
        GmPkcs7ContentInfoTypeEnum infoTypeEnum = (GmPkcs7ContentInfoTypeEnum) typeEnum;
        contentInfo = genGmPkcs7ContentInfo(infoTypeEnum, data, null, null, null, null);
    } else {
        throw new WeGooCipherException("");
    }
    return contentInfo;
}
Also used : WeGooCipherException(com.github.zhenwei.core.exception.WeGooCipherException)

Aggregations

WeGooCipherException (com.github.zhenwei.core.exception.WeGooCipherException)1