@Override
    public ASN1Primitive deserialize(Asn1ObjectInputStream in, Class<? extends ASN1Primitive> type,
                                     Asn1ObjectMapper mapper) {
        final ASN1Primitive value;
        try {
            value = ASN1Primitive.fromByteArray(in.advanceToByteArray());
        } catch (IOException e) {
            throw new Asn1Exception("Could not decode ASN1Primitive", e);
        }
        if (!type.isInstance(value)) {
            throw new Asn1Exception("Property is a " + value.getClass(), " expected " + type);
        }
        return value;
    }
@Test
    public void shouldDeserialize() {
        assertEquals(new ASN1ObjectIdentifier("1.2.3.4"), deserialize(
            new BouncyCastlePrimitiveConverter(), ASN1ObjectIdentifier.class, new byte[] { 0x06, 3, 0x2a, 0x03, 0x04 }, true
        ));
    }