private void setIso7816CertificateBody(DERApplicationSpecific appSpe) throws IOException { byte[] content; if (appSpe.getApplicationTag() == EACTags.CERTIFICATE_CONTENT_TEMPLATE) { content = appSpe.getContents(); } else { throw new IOException("Bad tag : not an iso7816 CERTIFICATE_CONTENT_TEMPLATE"); } ASN1InputStream aIS = new ASN1InputStream(content); ASN1Primitive obj; while ((obj = aIS.readObject()) != null) { DERApplicationSpecific aSpe; if (obj instanceof DERApplicationSpecific) { aSpe = (DERApplicationSpecific) obj; } else { throw new IOException( "Not a valid iso7816 content : not a DERApplicationSpecific Object :" + EACTags.encodeTag(appSpe) + obj.getClass()); } switch (aSpe.getApplicationTag()) { case EACTags.INTERCHANGE_PROFILE: setCertificateProfileIdentifier(aSpe); break; case EACTags.ISSUER_IDENTIFICATION_NUMBER: setCertificationAuthorityReference(aSpe); break; case EACTags.CARDHOLDER_PUBLIC_KEY_TEMPLATE: setPublicKey(PublicKeyDataObject.getInstance(aSpe.getObject(BERTags.SEQUENCE))); break; case EACTags.CARDHOLDER_NAME: setCertificateHolderReference(aSpe); break; case EACTags.CERTIFICATE_HOLDER_AUTHORIZATION_TEMPLATE: setCertificateHolderAuthorization(new CertificateHolderAuthorization(aSpe)); break; case EACTags.APPLICATION_EFFECTIVE_DATE: setCertificateEffectiveDate(aSpe); break; case EACTags.APPLICATION_EXPIRATION_DATE: setCertificateExpirationDate(aSpe); break; default: certificateType = 0; throw new IOException( "Not a valid iso7816 DERApplicationSpecific tag " + aSpe.getApplicationTag()); } } }
public Object parseObject(PemObject obj) throws IOException { try { Object param = ASN1Primitive.fromByteArray(obj.getContent()); if (param instanceof ASN1ObjectIdentifier) { return ASN1Primitive.fromByteArray(obj.getContent()); } else if (param instanceof ASN1Sequence) { return X9ECParameters.getInstance(param); } else { return null; // implicitly CA } } catch (IOException e) { throw e; } catch (Exception e) { throw new PEMException("exception extracting EC named curve: " + e.toString()); } }
private static EncryptedPrivateKeyInfo parseBytes(byte[] pkcs8Encoding) throws IOException { try { return EncryptedPrivateKeyInfo.getInstance(ASN1Primitive.fromByteArray(pkcs8Encoding)); } catch (ClassCastException e) { throw new CertIOException("malformed data: " + e.getMessage(), e); } catch (IllegalArgumentException e) { throw new CertIOException("malformed data: " + e.getMessage(), e); } }
private static PKIMessage parseBytes(byte[] encoding) throws IOException { try { return PKIMessage.getInstance(ASN1Primitive.fromByteArray(encoding)); } catch (ClassCastException e) { throw new CertIOException("malformed data: " + e.getMessage(), e); } catch (IllegalArgumentException e) { throw new CertIOException("malformed data: " + e.getMessage(), e); } }