当前位置: 首页>>代码示例>>Java>>正文


Java ASN1Primitive类代码示例

本文整理汇总了Java中org.bouncycastle.asn1.ASN1Primitive的典型用法代码示例。如果您正苦于以下问题:Java ASN1Primitive类的具体用法?Java ASN1Primitive怎么用?Java ASN1Primitive使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ASN1Primitive类属于org.bouncycastle.asn1包,在下文中一共展示了ASN1Primitive类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parseDG1

import org.bouncycastle.asn1.ASN1Primitive; //导入依赖的package包/类
private void parseDG1(byte[] DG1) {
    try {
        ASN1InputStream bIn = new ASN1InputStream(DG1);
        org.bouncycastle.asn1.DERApplicationSpecific app = (DERApplicationSpecific) bIn.readObject();

        ASN1Sequence seq = (ASN1Sequence) app.getObject(BERTags.SEQUENCE);
        Enumeration secEnum = seq.getObjects();
        while (secEnum.hasMoreElements()) {
            ASN1Primitive seqObj = (ASN1Primitive) secEnum.nextElement();
            byte[] data = seqObj.getEncoded();
            if (data[0]== 0x41) {
                Log.d("type approval number", ByteUtils.bytesToHex(data));
                this.set5F01(data);
            } else if (data[0] == 0x42) {
                byte[] input = Arrays.copyOfRange(data, 3, data.length);
                parse5F02(input);
            } else if (data[0] == 0x7F) {
                parse7F63(data);
            }
        }
        bIn.close();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
 
开发者ID:mDL-ILP,项目名称:mDL-ILP,代码行数:27,代码来源:DrivingLicence.java

示例2: parseObject

import org.bouncycastle.asn1.ASN1Primitive; //导入依赖的package包/类
public Object parseObject(PemObject obj)
    throws IOException
{
    try
    {
        PrivateKeyInfo info = PrivateKeyInfo.getInstance(ASN1Primitive.fromByteArray(obj.getContent()));
        PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(obj.getContent());

        KeyFactory keyFact = KeyFactory.getInstance(info.getPrivateKeyAlgorithm().getAlgorithm().getId(), provider);

        return keyFact.generatePrivate(keySpec);
    }
    catch (Exception e)
    {
        throw new PEMException("problem parsing PRIVATE KEY: " + e.toString(), e);
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:18,代码来源:PEMReader.java

示例3: getIssuerX509Principal

import org.bouncycastle.asn1.ASN1Primitive; //导入依赖的package包/类
/**
 * return the issuer of the given cert as an X509PrincipalObject.
 */
public static X509Principal getIssuerX509Principal(
    X509Certificate cert)
    throws CertificateEncodingException
{
    try
    {
        TBSCertificateStructure tbsCert = TBSCertificateStructure.getInstance(
                ASN1Primitive.fromByteArray(cert.getTBSCertificate()));

        return new X509Principal(X509Name.getInstance(tbsCert.getIssuer()));
    }
    catch (IOException e)
    {
        throw new CertificateEncodingException(e.toString());
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:20,代码来源:PrincipalUtil.java

示例4: toASN1Primitive

import org.bouncycastle.asn1.ASN1Primitive; //导入依赖的package包/类
/**
 * Produce an object suitable for an ASN1OutputStream.
 * <pre>
 * BasicConstraints := SEQUENCE {
 *    cA                  BOOLEAN DEFAULT FALSE,
 *    pathLenConstraint   INTEGER (0..MAX) OPTIONAL
 * }
 * </pre>
 */
public ASN1Primitive toASN1Primitive()
{
    ASN1EncodableVector  v = new ASN1EncodableVector();

    if (cA != null)
    {
        v.add(cA);
    }

    if (pathLenConstraint != null)  // yes some people actually do this when cA is false...
    {
        v.add(pathLenConstraint);
    }

    return new DERSequence(v);
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:26,代码来源:BasicConstraints.java

示例5: toASN1Primitive

import org.bouncycastle.asn1.ASN1Primitive; //导入依赖的package包/类
/**
 * Produce an object suitable for an ASN1OutputStream.
 * <p/>
 * Returns:
 * <p/>
 * <pre>
 *               ProcurationSyntax ::= SEQUENCE {
 *                 country [1] EXPLICIT PrintableString(SIZE(2)) OPTIONAL,
 *                 typeOfSubstitution [2] EXPLICIT DirectoryString (SIZE(1..128)) OPTIONAL,
 *                 signingFor [3] EXPLICIT SigningFor
 *               }
 * <p/>
 *               SigningFor ::= CHOICE
 *               {
 *                 thirdPerson GeneralName,
 *                 certRef IssuerSerial
 *               }
 * </pre>
 *
 * @return a DERObject
 */
public ASN1Primitive toASN1Primitive()
{
    ASN1EncodableVector vec = new ASN1EncodableVector();
    if (country != null)
    {
        vec.add(new DERTaggedObject(true, 1, new DERPrintableString(country, true)));
    }
    if (typeOfSubstitution != null)
    {
        vec.add(new DERTaggedObject(true, 2, typeOfSubstitution));
    }
    if (thirdPerson != null)
    {
        vec.add(new DERTaggedObject(true, 3, thirdPerson));
    }
    else
    {
        vec.add(new DERTaggedObject(true, 3, certRef));
    }

    return new DERSequence(vec);
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:44,代码来源:ProcurationSyntax.java

示例6: toASN1Primitive

import org.bouncycastle.asn1.ASN1Primitive; //导入依赖的package包/类
public ASN1Primitive toASN1Primitive()
{
    ASN1EncodableVector v = new ASN1EncodableVector();

    if (permitted != null)
    {
        v.add(new DERTaggedObject(false, 0, new DERSequence(permitted)));
    }

    if (excluded != null)
    {
        v.add(new DERTaggedObject(false, 1, new DERSequence(excluded)));
    }

    return new DERSequence(v);
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:17,代码来源:NameConstraints.java

示例7: parseDG1

import org.bouncycastle.asn1.ASN1Primitive; //导入依赖的package包/类
private void parseDG1(byte[] DG1) {
    try (ASN1InputStream bIn = new ASN1InputStream(DG1)) {

        org.bouncycastle.asn1.DERApplicationSpecific app = (DERApplicationSpecific) bIn.readObject();

        ASN1Sequence seq = (ASN1Sequence) app.getObject(BERTags.SEQUENCE);
        Enumeration secEnum = seq.getObjects();
        while (secEnum.hasMoreElements()) {
            ASN1Primitive seqObj = (ASN1Primitive) secEnum.nextElement();
            byte[] data = seqObj.getEncoded();
            if (data[0]== 0x41) {
                Log.d("type approval number", ByteUtils.bytesToHex(data));
                this.set5F01(Bytes.allButFirst(data, 1));
            } else if (data[0] == 0x42) {
                byte[] input = Arrays.copyOfRange(data, 3, data.length);
                parse5F02(input);
            } else if (data[0] == 0x7F) {
                parse7F63(data);
            }
        }
    } catch (IOException e) {
        Log.e(getClass().getName(), e.getMessage(), e);
    }
}
 
开发者ID:mDL-ILP,项目名称:mDL-ILP,代码行数:25,代码来源:DrivingLicence.java

示例8: parse7F63

import org.bouncycastle.asn1.ASN1Primitive; //导入依赖的package包/类
private void parse7F63(byte[] input) {
    Log.d("input", ByteUtils.bytesToHex(input));
    try (ASN1InputStream bIn = new ASN1InputStream(input)) {
        ASN1Primitive obj = bIn.readObject();
        DERApplicationSpecific app = (DERApplicationSpecific) obj;
        ASN1Sequence seq = (ASN1Sequence) app.getObject(BERTags.SEQUENCE);
        Enumeration secEnum = seq.getObjects();
        List<byte[]> categories = new ArrayList<>();
        while (secEnum.hasMoreElements()) {
            ASN1Primitive seqObj = (ASN1Primitive) secEnum.nextElement();
            byte[] data = seqObj.getEncoded();
            Log.d("5F02data", ByteUtils.bytesToHex(data));
            switch (data[0]) {
                case 0x02:
                    Log.d("#CATEGORY","number of categories:" + data[data.length-1]);
                    break;
                case (byte) 0x87:
                    categories.add(Arrays.copyOfRange(data, 2, data.length));
                    break;
            }
        }
        this.set7F63(categories);
    } catch (IOException e) {
        Log.e(getClass().getName(), e.getMessage(), e);
    }
}
 
开发者ID:mDL-ILP,项目名称:mDL-ILP,代码行数:27,代码来源:DrivingLicence.java

示例9: toASN1Primitive

import org.bouncycastle.asn1.ASN1Primitive; //导入依赖的package包/类
/** 
 * Produce an object suitable for an ASN1OutputStream.
 * <pre>
 * KEKIdentifier ::= SEQUENCE {
 *     keyIdentifier OCTET STRING,
 *     date GeneralizedTime OPTIONAL,
 *     other OtherKeyAttribute OPTIONAL 
 * }
 * </pre>
 */
public ASN1Primitive toASN1Primitive()
{
    ASN1EncodableVector  v = new ASN1EncodableVector();

    v.add(keyIdentifier);
    
    if (date != null)
    {
        v.add(date);
    }

    if (other != null)
    {
        v.add(other);
    }
    
    return new DERSequence(v);
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:29,代码来源:KEKIdentifier.java

示例10: toASN1Primitive

import org.bouncycastle.asn1.ASN1Primitive; //导入依赖的package包/类
/**
 * <pre>
 * PollRepContent ::= SEQUENCE OF SEQUENCE {
 *         certReqId              INTEGER,
 *         checkAfter             INTEGER,  -- time in seconds
 *         reason                 PKIFreeText OPTIONAL
 *     }
 * </pre>
 * @return a basic ASN.1 object representation.
 */
public ASN1Primitive toASN1Primitive()
{
    ASN1EncodableVector outer = new ASN1EncodableVector();

    for (int i = 0; i != certReqId.length; i++)
    {
        ASN1EncodableVector v = new ASN1EncodableVector();

        v.add(certReqId[i]);
        v.add(checkAfter[i]);

        if (reason[i] != null)
        {
            v.add(reason[i]);
        }

        outer.add(new DERSequence(v));
    }
    
    return new DERSequence(outer);
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:32,代码来源:PollRepContent.java

示例11: getInstance

import org.bouncycastle.asn1.ASN1Primitive; //导入依赖的package包/类
public static Asn1CreateSecretKeyParams getInstance(Object obj) throws BadAsn1ObjectException {
    if (obj == null || obj instanceof Asn1CreateSecretKeyParams) {
        return (Asn1CreateSecretKeyParams) obj;
    }

    try {
        if (obj instanceof ASN1Sequence) {
            return new Asn1CreateSecretKeyParams((ASN1Sequence) obj);
        } else if (obj instanceof byte[]) {
            return getInstance(ASN1Primitive.fromByteArray((byte[]) obj));
        } else {
            throw new BadAsn1ObjectException("unknown object: " + obj.getClass().getName());
        }
    } catch (IOException | IllegalArgumentException ex) {
        throw new BadAsn1ObjectException("unable to parse encoded object: " + ex.getMessage(),
                ex);
    }
}
 
开发者ID:xipki,项目名称:xitk,代码行数:19,代码来源:Asn1CreateSecretKeyParams.java

示例12: canonicalize

import org.bouncycastle.asn1.ASN1Primitive; //导入依赖的package包/类
public static String canonicalize(String s)
{
    String value = Strings.toLowerCase(s.trim());

    if (value.length() > 0 && value.charAt(0) == '#')
    {
        ASN1Primitive obj = decodeObject(value);

        if (obj instanceof ASN1String)
        {
            value = Strings.toLowerCase(((ASN1String)obj).getString().trim());
        }
    }

    value = stripInternalSpaces(value);

    return value;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:19,代码来源:IETFUtils.java

示例13: getInstance

import org.bouncycastle.asn1.ASN1Primitive; //导入依赖的package包/类
public static Asn1P11Params getInstance(Object obj) throws BadAsn1ObjectException {
    if (obj == null || obj instanceof Asn1P11Params) {
        return (Asn1P11Params) obj;
    }

    try {
        if (obj instanceof ASN1TaggedObject) {
            return new Asn1P11Params((ASN1TaggedObject) obj);
        } else if (obj instanceof byte[]) {
            return getInstance(ASN1Primitive.fromByteArray((byte[]) obj));
        } else {
            throw new BadAsn1ObjectException("unknown object: " + obj.getClass().getName());
        }
    } catch (IOException | IllegalArgumentException ex) {
        throw new BadAsn1ObjectException("unable to parse encoded object: " + ex.getMessage(),
                ex);
    }
}
 
开发者ID:xipki,项目名称:xitk,代码行数:19,代码来源:Asn1P11Params.java

示例14: toASN1Primitive

import org.bouncycastle.asn1.ASN1Primitive; //导入依赖的package包/类
/**
 * Produce an object suitable for an ASN1OutputStream.
 * <pre>
 *  Curve ::= SEQUENCE {
 *      a               FieldElement,
 *      b               FieldElement,
 *      seed            BIT STRING      OPTIONAL
 *  }
 * </pre>
 */
public ASN1Primitive toASN1Primitive()
{
    ASN1EncodableVector v = new ASN1EncodableVector();

    if (fieldIdentifier.equals(prime_field)) 
    { 
        v.add(new X9FieldElement(curve.getA()).toASN1Primitive());
        v.add(new X9FieldElement(curve.getB()).toASN1Primitive());
    } 
    else if (fieldIdentifier.equals(characteristic_two_field)) 
    {
        v.add(new X9FieldElement(curve.getA()).toASN1Primitive());
        v.add(new X9FieldElement(curve.getB()).toASN1Primitive());
    }

    if (seed != null)
    {
        v.add(new DERBitString(seed));
    }

    return new DERSequence(v);
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:33,代码来源:X9Curve.java

示例15: OtherRevRefs

import org.bouncycastle.asn1.ASN1Primitive; //导入依赖的package包/类
private OtherRevRefs(ASN1Sequence seq)
{
    if (seq.size() != 2)
    {
        throw new IllegalArgumentException("Bad sequence size: "
            + seq.size());
    }
    this.otherRevRefType = new ASN1ObjectIdentifier(((ASN1ObjectIdentifier)seq.getObjectAt(0)).getId());
    try
    {
        this.otherRevRefs = ASN1Primitive.fromByteArray(seq.getObjectAt(1)
            .toASN1Primitive().getEncoded(ASN1Encoding.DER));
    }
    catch (IOException e)
    {
        throw new IllegalStateException();
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:19,代码来源:OtherRevRefs.java


注:本文中的org.bouncycastle.asn1.ASN1Primitive类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。