Java 类org.bouncycastle.asn1.DERApplicationSpecific 实例源码

项目:mDL-ILP    文件:DrivingLicence.java   
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();
    }
}
项目:mDL-ILP    文件:DrivingLicence.java   
private void parseDG11(byte[] DG11) {
    try {
        ASN1InputStream bIn = new ASN1InputStream(DG11);
        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]== 0x7F) {
                parseDG11(data);
            } else if (data[0] == (byte) 0x80) {
                this.setBSN(Arrays.copyOfRange(data, 2, data.length));
            }
        }
        bIn.close();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
项目:mDL-ILP    文件:PACEAPDUInterface.java   
private byte[] parseNonce(byte[] data) {
    try (ASN1InputStream bIn = new ASN1InputStream(data)) {
        DERApplicationSpecific app = (DERApplicationSpecific) bIn.readObject();

        ASN1Sequence seq = (ASN1Sequence) app.getObject(BERTags.SEQUENCE);

        byte[] tag80 = ((ASN1Primitive) seq.getObjects().nextElement()).getEncoded();

        if (tag80[0] == (byte) 0x80) {

            MessageDigest md = MessageDigest.getInstance("SHA-256");
            byte[] kpi =  md.digest(Bytes.concatenate(CAN.getBytes(), Bytes.bytes("00 00 00 03")));

            return AESUtils.decryptAESCBC(Bytes.allButFirst(tag80, 2), kpi);
        }
    } catch (IOException | NoSuchAlgorithmException e) {
        Log.e(getClass().getName(), "Failed to parse nonce from response data", e);
    }

    return null;
}
项目:mDL-ILP    文件:DrivingLicence.java   
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);
    }
}
项目:mDL-ILP    文件:DrivingLicence.java   
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);
    }
}
项目:mDL-ILP    文件:DrivingLicence.java   
private void parseDG11(byte[] DG11) {
    try (ASN1InputStream bIn = new ASN1InputStream(DG11)) {
        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]== 0x7F) {
                parseDG11(data);
            } else if (data[0] == (byte) 0x80) {
                this.setBSN(Arrays.copyOfRange(data, 2, data.length));
            }
        }
    } catch (IOException e) {
        Log.e(getClass().getName(), e.getMessage(), e);
    }
}
项目:ipack    文件:CVCertificateRequest.java   
private CVCertificateRequest(DERApplicationSpecific request)
    throws IOException
{
    if (request.getApplicationTag() == EACTags.AUTHENTIFICATION_DATA)
    {
        ASN1Sequence seq = ASN1Sequence.getInstance(request.getObject(BERTags.SEQUENCE));

        initCertBody(DERApplicationSpecific.getInstance(seq.getObjectAt(0)));

        outerSignature = DERApplicationSpecific.getInstance(seq.getObjectAt(seq.size() - 1)).getContents();
    }
    else
    {
        initCertBody(request);
    }
}
项目:ipack    文件:CVCertificateRequest.java   
public static CVCertificateRequest getInstance(Object obj)
{
    if (obj instanceof CVCertificateRequest)
    {
        return (CVCertificateRequest)obj;
    }
    else if (obj != null)
    {
        try
        {
            return new CVCertificateRequest(DERApplicationSpecific.getInstance(obj));
        }
        catch (IOException e)
        {
            throw new ASN1ParsingException("unable to parse data: " + e.getMessage(), e);
        }
    }

    return null;
}
项目:ipack    文件:CVCertificateRequest.java   
public ASN1Primitive toASN1Primitive()
{
    ASN1EncodableVector v = new ASN1EncodableVector();

    v.add(certificateBody);

    try
    {
        v.add(new DERApplicationSpecific(false, EACTags.STATIC_INTERNAL_AUTHENTIFICATION_ONE_STEP, new DEROctetString(innerSignature)));
    }
    catch (IOException e)
    {
        throw new IllegalStateException("unable to convert signature!");
    }

    return new DERApplicationSpecific(EACTags.CARDHOLDER_CERTIFICATE, v);
}
项目:ipack    文件:CVCertificate.java   
private void initFrom(ASN1InputStream aIS)
    throws IOException
{
    ASN1Primitive obj;
    while ((obj = aIS.readObject()) != null)
    {
        if (obj instanceof DERApplicationSpecific)
        {
            setPrivateData((DERApplicationSpecific)obj);
        }
        else
        {
            throw new IOException("Invalid Input Stream for creating an Iso7816CertificateStructure");
        }
    }
}
项目:ipack    文件:CVCertificate.java   
/**
 * Create an iso7816Certificate structure from an object.
 *
 * @param obj the Object to extract the certificate from.
 * @return the Iso7816CertificateStructure represented by the byte stream.
 * @throws IOException if there is a problem parsing the data.
 */
public static CVCertificate getInstance(Object obj)
{
    if (obj instanceof CVCertificate)
    {
        return (CVCertificate)obj;
    }
    else if (obj != null)
    {
        try
        {
            return new CVCertificate(DERApplicationSpecific.getInstance(obj));
        }
        catch (IOException e)
        {
            throw new ASN1ParsingException("unable to parse data: " + e.getMessage(), e);
        }
    }

    return null;
}
项目:ipack    文件:CVCertificate.java   
/**
 * @see org.bouncycastle.asn1.ASN1Object#toASN1Primitive()
 */
public ASN1Primitive toASN1Primitive()
{
    ASN1EncodableVector v = new ASN1EncodableVector();

    if (valid != (signValid | bodyValid))
    {
        return null;
    }
    v.add(certificateBody);

    try
    {
        v.add(new DERApplicationSpecific(false, EACTags.STATIC_INTERNAL_AUTHENTIFICATION_ONE_STEP, new DEROctetString(signature)));
    }
    catch (IOException e)
    {
        throw new IllegalStateException("unable to convert signature!");
    }

    return new DERApplicationSpecific(EACTags.CARDHOLDER_CERTIFICATE, v);
}
项目:ipack    文件:CertificateHolderAuthorization.java   
private void setPrivateData(ASN1InputStream cha)
    throws IOException
{
    ASN1Primitive obj;
    obj = cha.readObject();
    if (obj instanceof ASN1ObjectIdentifier)
    {
        this.oid = (ASN1ObjectIdentifier)obj;
    }
    else
    {
        throw new IllegalArgumentException("no Oid in CerticateHolderAuthorization");
    }
    obj = cha.readObject();
    if (obj instanceof DERApplicationSpecific)
    {
        this.accessRights = (DERApplicationSpecific)obj;
    }
    else
    {
        throw new IllegalArgumentException("No access rights in CerticateHolderAuthorization");
    }
}
项目:gwt-crypto    文件:CVCertificateRequest.java   
public ASN1Primitive toASN1Primitive()
{
    ASN1EncodableVector v = new ASN1EncodableVector();

    v.add(certificateBody);

    try
    {
        v.add(new DERApplicationSpecific(false, EACTags.STATIC_INTERNAL_AUTHENTIFICATION_ONE_STEP, new DEROctetString(innerSignature)));
    }
    catch (IOException e)
    {
        throw new IllegalStateException("unable to convert signature!");
    }

    return new DERApplicationSpecific(EACTags.CARDHOLDER_CERTIFICATE, v);
}
项目:gwt-crypto    文件:CVCertificate.java   
private void initFrom(ASN1InputStream aIS)
    throws IOException
{
    ASN1Primitive obj;
    while ((obj = aIS.readObject()) != null)
    {
        if (obj instanceof DERApplicationSpecific)
        {
            setPrivateData((DERApplicationSpecific)obj);
        }
        else
        {
            throw new IOException("Invalid Input Stream for creating an Iso7816CertificateStructure");
        }
    }
}
项目:gwt-crypto    文件:CVCertificate.java   
/**
 * Create an iso7816Certificate structure from an object.
 *
 * @param obj the Object to extract the certificate from.
 * @return the Iso7816CertificateStructure represented by the byte stream.
 */
public static CVCertificate getInstance(Object obj)
{
    if (obj instanceof CVCertificate)
    {
        return (CVCertificate)obj;
    }
    else if (obj != null)
    {
        try
        {
            return new CVCertificate(DERApplicationSpecific.getInstance(obj));
        }
        catch (IOException e)
        {
            throw new ASN1ParsingException("unable to parse data: " + e.getMessage(), e);
        }
    }

    return null;
}
项目:gwt-crypto    文件:CVCertificate.java   
/**
 * @see org.bouncycastle.asn1.ASN1Object#toASN1Primitive()
 */
public ASN1Primitive toASN1Primitive()
{
    ASN1EncodableVector v = new ASN1EncodableVector();

    v.add(certificateBody);

    try
    {
        v.add(new DERApplicationSpecific(false, EACTags.STATIC_INTERNAL_AUTHENTIFICATION_ONE_STEP, new DEROctetString(signature)));
    }
    catch (IOException e)
    {
        throw new IllegalStateException("unable to convert signature!");
    }

    return new DERApplicationSpecific(EACTags.CARDHOLDER_CERTIFICATE, v);
}
项目:gwt-crypto    文件:CertificateHolderAuthorization.java   
private void setPrivateData(ASN1InputStream cha)
    throws IOException
{
    ASN1Primitive obj;
    obj = cha.readObject();
    if (obj instanceof ASN1ObjectIdentifier)
    {
        this.oid = (ASN1ObjectIdentifier)obj;
    }
    else
    {
        throw new IllegalArgumentException("no Oid in CerticateHolderAuthorization");
    }
    obj = cha.readObject();
    if (obj instanceof DERApplicationSpecific)
    {
        this.accessRights = (DERApplicationSpecific)obj;
    }
    else
    {
        throw new IllegalArgumentException("No access rights in CerticateHolderAuthorization");
    }
}
项目:Aki-SSL    文件:CVCertificateRequest.java   
public ASN1Primitive toASN1Primitive()
{
    ASN1EncodableVector v = new ASN1EncodableVector();

    v.add(certificateBody);

    try
    {
        v.add(new DERApplicationSpecific(false, EACTags.STATIC_INTERNAL_AUTHENTIFICATION_ONE_STEP, new DEROctetString(innerSignature)));
    }
    catch (IOException e)
    {
        throw new IllegalStateException("unable to convert signature!");
    }

    return new DERApplicationSpecific(EACTags.CARDHOLDER_CERTIFICATE, v);
}
项目:Aki-SSL    文件:CVCertificate.java   
private void initFrom(ASN1InputStream aIS)
    throws IOException
{
    ASN1Primitive obj;
    while ((obj = aIS.readObject()) != null)
    {
        if (obj instanceof DERApplicationSpecific)
        {
            setPrivateData((DERApplicationSpecific)obj);
        }
        else
        {
            throw new IOException("Invalid Input Stream for creating an Iso7816CertificateStructure");
        }
    }
}
项目:Aki-SSL    文件:CVCertificate.java   
/**
 * Create an iso7816Certificate structure from an object.
 *
 * @param obj the Object to extract the certificate from.
 * @return the Iso7816CertificateStructure represented by the byte stream.
 */
public static CVCertificate getInstance(Object obj)
{
    if (obj instanceof CVCertificate)
    {
        return (CVCertificate)obj;
    }
    else if (obj != null)
    {
        try
        {
            return new CVCertificate(DERApplicationSpecific.getInstance(obj));
        }
        catch (IOException e)
        {
            throw new ASN1ParsingException("unable to parse data: " + e.getMessage(), e);
        }
    }

    return null;
}
项目:Aki-SSL    文件:CVCertificate.java   
/**
 * @see org.bouncycastle.asn1.ASN1Object#toASN1Primitive()
 */
public ASN1Primitive toASN1Primitive()
{
    ASN1EncodableVector v = new ASN1EncodableVector();

    v.add(certificateBody);

    try
    {
        v.add(new DERApplicationSpecific(false, EACTags.STATIC_INTERNAL_AUTHENTIFICATION_ONE_STEP, new DEROctetString(signature)));
    }
    catch (IOException e)
    {
        throw new IllegalStateException("unable to convert signature!");
    }

    return new DERApplicationSpecific(EACTags.CARDHOLDER_CERTIFICATE, v);
}
项目:Aki-SSL    文件:CertificateHolderAuthorization.java   
private void setPrivateData(ASN1InputStream cha)
    throws IOException
{
    ASN1Primitive obj;
    obj = cha.readObject();
    if (obj instanceof ASN1ObjectIdentifier)
    {
        this.oid = (ASN1ObjectIdentifier)obj;
    }
    else
    {
        throw new IllegalArgumentException("no Oid in CerticateHolderAuthorization");
    }
    obj = cha.readObject();
    if (obj instanceof DERApplicationSpecific)
    {
        this.accessRights = (DERApplicationSpecific)obj;
    }
    else
    {
        throw new IllegalArgumentException("No access rights in CerticateHolderAuthorization");
    }
}
项目:animamea    文件:CVCertBody.java   
/**
 * CVCertBody contains:
 * - Certificate Profile Identifier
 * - Certificate Authority Reference
 * - Public Key
 * - Certificate Holder Reference
 * - Certificate Holder Authorization Template
 * - Certificate Effective Date
 * - Certificate Expiration Date
 * - Certificate Extensions (OPTIONAL)
 * 
 */
@Override
public ASN1Primitive toASN1Primitive() {
    ASN1EncodableVector v = new ASN1EncodableVector();
    try {
        v.add(new DERApplicationSpecific(0x29, profileIdentifier));
        v.add(new DERApplicationSpecific(0x02, authorityReference));
        v.add(publicKey);
        v.add(new DERApplicationSpecific(0x20, chr));
        v.add(chat);
        v.add(new DERApplicationSpecific(0x25, effectiveDate));
        v.add(new DERApplicationSpecific(0x24, expirationDate));
        if (extensions!=null) v.add(new DERApplicationSpecific(0x05, extensions));
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

       return new DERApplicationSpecific(0x4E, v);
}
项目:TinyTravelTracker    文件:CVCertificateRequest.java   
private CVCertificateRequest(DERApplicationSpecific request)
    throws IOException
{
    if (request.getApplicationTag() == EACTags.AUTHENTIFICATION_DATA)
    {
        ASN1Sequence seq = ASN1Sequence.getInstance(request.getObject(BERTags.SEQUENCE));

        initCertBody(DERApplicationSpecific.getInstance(seq.getObjectAt(0)));

        outerSignature = DERApplicationSpecific.getInstance(seq.getObjectAt(seq.size() - 1)).getContents();
    }
    else
    {
        initCertBody(request);
    }
}
项目:TinyTravelTracker    文件:CVCertificateRequest.java   
public static CVCertificateRequest getInstance(Object obj)
{
    if (obj instanceof CVCertificateRequest)
    {
        return (CVCertificateRequest)obj;
    }
    else if (obj != null)
    {
        try
        {
            return new CVCertificateRequest(DERApplicationSpecific.getInstance(obj));
        }
        catch (IOException e)
        {
            throw new ASN1ParsingException("unable to parse data: " + e.getMessage(), e);
        }
    }

    return null;
}
项目:TinyTravelTracker    文件:CVCertificateRequest.java   
public ASN1Primitive toASN1Primitive()
{
    ASN1EncodableVector v = new ASN1EncodableVector();

    v.add(certificateBody);

    try
    {
        v.add(new DERApplicationSpecific(false, EACTags.STATIC_INTERNAL_AUTHENTIFICATION_ONE_STEP, new DEROctetString(innerSignature)));
    }
    catch (IOException e)
    {
        throw new IllegalStateException("unable to convert signature!");
    }

    return new DERApplicationSpecific(EACTags.CARDHOLDER_CERTIFICATE, v);
}
项目:TinyTravelTracker    文件:CVCertificate.java   
private void initFrom(ASN1InputStream aIS)
    throws IOException
{
    ASN1Primitive obj;
    while ((obj = aIS.readObject()) != null)
    {
        if (obj instanceof DERApplicationSpecific)
        {
            setPrivateData((DERApplicationSpecific)obj);
        }
        else
        {
            throw new IOException("Invalid Input Stream for creating an Iso7816CertificateStructure");
        }
    }
}
项目:TinyTravelTracker    文件:CVCertificate.java   
/**
 * Create an iso7816Certificate structure from an object.
 *
 * @param obj the Object to extract the certificate from.
 * @return the Iso7816CertificateStructure represented by the byte stream.
 */
public static CVCertificate getInstance(Object obj)
{
    if (obj instanceof CVCertificate)
    {
        return (CVCertificate)obj;
    }
    else if (obj != null)
    {
        try
        {
            return new CVCertificate(DERApplicationSpecific.getInstance(obj));
        }
        catch (IOException e)
        {
            throw new ASN1ParsingException("unable to parse data: " + e.getMessage(), e);
        }
    }

    return null;
}
项目:TinyTravelTracker    文件:CVCertificate.java   
/**
 * @see org.bouncycastle.asn1.ASN1Object#toASN1Primitive()
 */
public ASN1Primitive toASN1Primitive()
{
    ASN1EncodableVector v = new ASN1EncodableVector();

    if (valid != (signValid | bodyValid))
    {
        return null;
    }
    v.add(certificateBody);

    try
    {
        v.add(new DERApplicationSpecific(false, EACTags.STATIC_INTERNAL_AUTHENTIFICATION_ONE_STEP, new DEROctetString(signature)));
    }
    catch (IOException e)
    {
        throw new IllegalStateException("unable to convert signature!");
    }

    return new DERApplicationSpecific(EACTags.CARDHOLDER_CERTIFICATE, v);
}
项目:TinyTravelTracker    文件:CertificateHolderAuthorization.java   
private void setPrivateData(ASN1InputStream cha)
    throws IOException
{
    ASN1Primitive obj;
    obj = cha.readObject();
    if (obj instanceof ASN1ObjectIdentifier)
    {
        this.oid = (ASN1ObjectIdentifier)obj;
    }
    else
    {
        throw new IllegalArgumentException("no Oid in CerticateHolderAuthorization");
    }
    obj = cha.readObject();
    if (obj instanceof DERApplicationSpecific)
    {
        this.accessRights = (DERApplicationSpecific)obj;
    }
    else
    {
        throw new IllegalArgumentException("No access rights in CerticateHolderAuthorization");
    }
}
项目:InflatableDonkey    文件:DER.java   
static ASN1Primitive asApplicationSpecific(int tag, ASN1Encodable encodable) {
    try {
        DERApplicationSpecific specific = as(DERApplicationSpecific.class, encodable);

        if (specific.getApplicationTag() == tag) {
            return specific.getObject();

        } else {
            throw new IllegalArgumentException(
                    "tag mismatch, expected " + tag + " got " + specific.getApplicationTag());
        }

    } catch (IOException ex) {
        throw new IllegalArgumentException(ex);
    }
}
项目:CryptMeme    文件:CVCertificateRequest.java   
private CVCertificateRequest(DERApplicationSpecific request)
    throws IOException
{
    if (request.getApplicationTag() == EACTags.AUTHENTIFICATION_DATA)
    {
        ASN1Sequence seq = ASN1Sequence.getInstance(request.getObject(BERTags.SEQUENCE));

        initCertBody(DERApplicationSpecific.getInstance(seq.getObjectAt(0)));

        outerSignature = DERApplicationSpecific.getInstance(seq.getObjectAt(seq.size() - 1)).getContents();
    }
    else
    {
        initCertBody(request);
    }
}
项目:CryptMeme    文件:CVCertificateRequest.java   
public static CVCertificateRequest getInstance(Object obj)
{
    if (obj instanceof CVCertificateRequest)
    {
        return (CVCertificateRequest)obj;
    }
    else if (obj != null)
    {
        try
        {
            return new CVCertificateRequest(DERApplicationSpecific.getInstance(obj));
        }
        catch (IOException e)
        {
            throw new ASN1ParsingException("unable to parse data: " + e.getMessage(), e);
        }
    }

    return null;
}
项目:CryptMeme    文件:CVCertificateRequest.java   
public ASN1Primitive toASN1Primitive()
{
    ASN1EncodableVector v = new ASN1EncodableVector();

    v.add(certificateBody);

    try
    {
        v.add(new DERApplicationSpecific(false, EACTags.STATIC_INTERNAL_AUTHENTIFICATION_ONE_STEP, new DEROctetString(innerSignature)));
    }
    catch (IOException e)
    {
        throw new IllegalStateException("unable to convert signature!");
    }

    return new DERApplicationSpecific(EACTags.CARDHOLDER_CERTIFICATE, v);
}
项目:CryptMeme    文件:CVCertificate.java   
private void initFrom(ASN1InputStream aIS)
    throws IOException
{
    ASN1Primitive obj;
    while ((obj = aIS.readObject()) != null)
    {
        if (obj instanceof DERApplicationSpecific)
        {
            setPrivateData((DERApplicationSpecific)obj);
        }
        else
        {
            throw new IOException("Invalid Input Stream for creating an Iso7816CertificateStructure");
        }
    }
}
项目:CryptMeme    文件:CVCertificate.java   
/**
 * Create an iso7816Certificate structure from an object.
 *
 * @param obj the Object to extract the certificate from.
 * @return the Iso7816CertificateStructure represented by the byte stream.
 * @throws IOException if there is a problem parsing the data.
 */
public static CVCertificate getInstance(Object obj)
{
    if (obj instanceof CVCertificate)
    {
        return (CVCertificate)obj;
    }
    else if (obj != null)
    {
        try
        {
            return new CVCertificate(DERApplicationSpecific.getInstance(obj));
        }
        catch (IOException e)
        {
            throw new ASN1ParsingException("unable to parse data: " + e.getMessage(), e);
        }
    }

    return null;
}
项目:CryptMeme    文件:CVCertificate.java   
/**
 * @see org.bouncycastle.asn1.ASN1Object#toASN1Primitive()
 */
public ASN1Primitive toASN1Primitive()
{
    ASN1EncodableVector v = new ASN1EncodableVector();

    if (valid != (signValid | bodyValid))
    {
        return null;
    }
    v.add(certificateBody);

    try
    {
        v.add(new DERApplicationSpecific(false, EACTags.STATIC_INTERNAL_AUTHENTIFICATION_ONE_STEP, new DEROctetString(signature)));
    }
    catch (IOException e)
    {
        throw new IllegalStateException("unable to convert signature!");
    }

    return new DERApplicationSpecific(EACTags.CARDHOLDER_CERTIFICATE, v);
}
项目:CryptMeme    文件:CertificateHolderAuthorization.java   
private void setPrivateData(ASN1InputStream cha)
    throws IOException
{
    ASN1Primitive obj;
    obj = cha.readObject();
    if (obj instanceof ASN1ObjectIdentifier)
    {
        this.oid = (ASN1ObjectIdentifier)obj;
    }
    else
    {
        throw new IllegalArgumentException("no Oid in CerticateHolderAuthorization");
    }
    obj = cha.readObject();
    if (obj instanceof DERApplicationSpecific)
    {
        this.accessRights = (DERApplicationSpecific)obj;
    }
    else
    {
        throw new IllegalArgumentException("No access rights in CerticateHolderAuthorization");
    }
}
项目:irma_future_id    文件:CVCertificateRequest.java   
private CVCertificateRequest(DERApplicationSpecific request)
    throws IOException
{
    if (request.getApplicationTag() == EACTags.AUTHENTIFICATION_DATA)
    {
        ASN1Sequence seq = ASN1Sequence.getInstance(request.getObject(BERTags.SEQUENCE));

        initCertBody(DERApplicationSpecific.getInstance(seq.getObjectAt(0)));

        outerSignature = DERApplicationSpecific.getInstance(seq.getObjectAt(seq.size() - 1)).getContents();
    }
    else
    {
        initCertBody(request);
    }
}