/** * Decode the next element from the given DER decoder as an X.509 certificate chain. * * @param decoder the DER decoder * @return the X.509 certificate chain * @throws ASN1Exception if the next element from the given decoder is not an X.509 * certificate chain or if an error occurs while decoding the X.509 certificate chain */ public static X509Certificate[] decodeX509CertificateChain(final DERDecoder decoder) throws ASN1Exception { if (decoder.peekType() != SET_TYPE) { throw saslEntity.asnUnexpectedTag(); } byte[] certChain = decoder.drainElement(); try { CertificateFactory certFactory = CertificateFactory.getInstance("X.509"); certChain[0] = SEQUENCE_TYPE; // CertificateFactory#generateCertPath requires a DER SEQUE CertPath certPath = certFactory.generateCertPath(new ByteArrayInputStream(certChain)); List<? extends Certificate> certs = certPath.getCertificates(); return certs.toArray(new X509Certificate[certs.size()]); } catch (CertificateException e) { throw new ASN1Exception(e); } }
if (decoder.isNextType(CONTEXT_SPECIFIC_MASK, trustedAuthorityType, true)) { decoder.decodeImplicit(trustedAuthorityType); byte[] cert = decoder.drainElement(); cert[0] = SEQUENCE_TYPE; // Replace the trusted authority type tag with a DER SEQUENCE tag, as required by CertificateFactory#generateCertificate try {
decoder.startSequence(); String typeId = decoder.decodeObjectIdentifier(); byte[] encodedValue = decoder.drainElement(); decoder.endSequence(); generalName = new OtherName(typeId, encodedValue);
/** * <p> * Create an {@code OtherName} that is defined as: * * <pre> * OtherName ::= SEQUENCE { * type-id OBJECT IDENTIFIER, * value [0] EXPLICIT ANY DEFINED BY type-id } * </pre> * </p> * * @param encodedName the DER encoded form of the name, as a byte array * @throws ASN1Exception if {@code encodedName} is not DER encoded */ public OtherName(final byte[] encodedName) throws ASN1Exception { super(OTHER_NAME); this.encodedName = encodedName; final DERDecoder decoder = new DERDecoder(encodedName); decoder.startSequence(); typeId = decoder.decodeObjectIdentifier(); encodedValue = decoder.drainElement(); decoder.endSequence(); }
if (decoder.isNextType(CONTEXT_SPECIFIC_MASK, trustedAuthorityType, true)) { decoder.decodeImplicit(trustedAuthorityType); byte[] cert = decoder.drainElement(); cert[0] = SEQUENCE_TYPE; // Replace the trusted authority type tag with a DER SEQUENCE tag, as required by CertificateFactory#generateCertificate try {
final byte[] publicBytes = decoder.drainElement(); final byte[] privateBytes = decoder.drainElement(); decoder.endSequence(); final KeyFactory keyFactory = KeyFactory.getInstance(matchedAlgorithm); int i = 0; while (decoder.hasNextElement()) { final byte[] certBytes = decoder.drainElement(); array[i ++] = (X509Certificate) certificateFactory.generateCertificate(new ByteArrayInputStream(certBytes));
if (decoder.isNextType(CONTEXT_SPECIFIC_MASK, trustedAuthorityType, true)) { decoder.decodeImplicit(trustedAuthorityType); byte[] cert = decoder.drainElement(); cert[0] = SEQUENCE_TYPE; // Replace the trusted authority type tag with a DER SEQUENCE tag, as required by CertificateFactory#generateCertificate try {
/** * Decode the next element from the given DER decoder as an X.509 certificate chain. * * @param decoder the DER decoder * @return the X.509 certificate chain * @throws ASN1Exception if the next element from the given decoder is not an X.509 * certificate chain or if an error occurs while decoding the X.509 certificate chain */ public static X509Certificate[] decodeX509CertificateChain(final DERDecoder decoder) throws ASN1Exception { if (decoder.peekType() != SET_TYPE) { throw saslEntity.asnUnexpectedTag(); } byte[] certChain = decoder.drainElement(); try { CertificateFactory certFactory = CertificateFactory.getInstance("X.509"); certChain[0] = SEQUENCE_TYPE; // CertificateFactory#generateCertPath requires a DER SEQUE CertPath certPath = certFactory.generateCertPath(new ByteArrayInputStream(certChain)); List<? extends Certificate> certs = certPath.getCertificates(); return certs.toArray(new X509Certificate[certs.size()]); } catch (CertificateException e) { throw new ASN1Exception(e); } }
if (decoder.isNextType(CONTEXT_SPECIFIC_MASK, trustedAuthorityType, true)) { decoder.decodeImplicit(trustedAuthorityType); byte[] cert = decoder.drainElement(); cert[0] = SEQUENCE_TYPE; // Replace the trusted authority type tag with a DER SEQUENCE tag, as required by CertificateFactory#generateCertificate try {
/** * Decode the next element from the given DER decoder as an X.509 certificate chain. * * @param decoder the DER decoder * @return the X.509 certificate chain * @throws ASN1Exception if the next element from the given decoder is not an X.509 * certificate chain or if an error occurs while decoding the X.509 certificate chain */ public static X509Certificate[] decodeX509CertificateChain(final DERDecoder decoder) throws ASN1Exception { if (decoder.peekType() != SET_TYPE) { throw saslEntity.asnUnexpectedTag(); } byte[] certChain = decoder.drainElement(); try { CertificateFactory certFactory = CertificateFactory.getInstance("X.509"); certChain[0] = SEQUENCE_TYPE; // CertificateFactory#generateCertPath requires a DER SEQUE CertPath certPath = certFactory.generateCertPath(new ByteArrayInputStream(certChain)); List<? extends Certificate> certs = certPath.getCertificates(); return certs.toArray(new X509Certificate[certs.size()]); } catch (CertificateException e) { throw new ASN1Exception(e); } }
decoder.startSequence(); String typeId = decoder.decodeObjectIdentifier(); byte[] encodedValue = decoder.drainElement(); decoder.endSequence(); generalName = new OtherName(typeId, encodedValue);
/** * Decode the next element from the given DER decoder as an X.509 certificate chain. * * @param decoder the DER decoder * @return the X.509 certificate chain * @throws ASN1Exception if the next element from the given decoder is not an X.509 * certificate chain or if an error occurs while decoding the X.509 certificate chain */ public static X509Certificate[] decodeX509CertificateChain(final DERDecoder decoder) throws ASN1Exception { if (decoder.peekType() != SET_TYPE) { throw saslEntity.asnUnexpectedTag(); } byte[] certChain = decoder.drainElement(); try { CertificateFactory certFactory = CertificateFactory.getInstance("X.509"); certChain[0] = SEQUENCE_TYPE; // CertificateFactory#generateCertPath requires a DER SEQUE CertPath certPath = certFactory.generateCertPath(new ByteArrayInputStream(certChain)); List<? extends Certificate> certs = certPath.getCertificates(); return certs.toArray(new X509Certificate[certs.size()]); } catch (CertificateException e) { throw new ASN1Exception(e); } }
decoder.startSequence(); String typeId = decoder.decodeObjectIdentifier(); byte[] encodedValue = decoder.drainElement(); decoder.endSequence(); generalName = new OtherName(typeId, encodedValue);
/** * <p> * Create an {@code OtherName} that is defined as: * * <pre> * OtherName ::= SEQUENCE { * type-id OBJECT IDENTIFIER, * value [0] EXPLICIT ANY DEFINED BY type-id } * </pre> * </p> * * @param encodedName the DER encoded form of the name, as a byte array * @throws ASN1Exception if {@code encodedName} is not DER encoded */ public OtherName(final byte[] encodedName) throws ASN1Exception { super(OTHER_NAME); this.encodedName = encodedName; final DERDecoder decoder = new DERDecoder(encodedName); decoder.startSequence(); typeId = decoder.decodeObjectIdentifier(); encodedValue = decoder.drainElement(); decoder.endSequence(); }
decoder.startSequence(); String typeId = decoder.decodeObjectIdentifier(); byte[] encodedValue = decoder.drainElement(); decoder.endSequence(); generalName = new OtherName(typeId, encodedValue);
/** * <p> * Create an {@code OtherName} that is defined as: * * <pre> * OtherName ::= SEQUENCE { * type-id OBJECT IDENTIFIER, * value [0] EXPLICIT ANY DEFINED BY type-id } * </pre> * </p> * * @param encodedName the DER encoded form of the name, as a byte array * @throws ASN1Exception if {@code encodedName} is not DER encoded */ public OtherName(final byte[] encodedName) throws ASN1Exception { super(OTHER_NAME); this.encodedName = encodedName; final DERDecoder decoder = new DERDecoder(encodedName); decoder.startSequence(); typeId = decoder.decodeObjectIdentifier(); encodedValue = decoder.drainElement(); decoder.endSequence(); }
/** * <p> * Create an {@code OtherName} that is defined as: * * <pre> * OtherName ::= SEQUENCE { * type-id OBJECT IDENTIFIER, * value [0] EXPLICIT ANY DEFINED BY type-id } * </pre> * </p> * * @param encodedName the DER encoded form of the name, as a byte array * @throws ASN1Exception if {@code encodedName} is not DER encoded */ public OtherName(final byte[] encodedName) throws ASN1Exception { super(OTHER_NAME); this.encodedName = encodedName; final DERDecoder decoder = new DERDecoder(encodedName); decoder.startSequence(); typeId = decoder.decodeObjectIdentifier(); encodedValue = decoder.drainElement(); decoder.endSequence(); }
final byte[] publicBytes = decoder.drainElement(); final byte[] privateBytes = decoder.drainElement(); decoder.endSequence(); final KeyFactory keyFactory = KeyFactory.getInstance(matchedAlgorithm); int i = 0; while (decoder.hasNextElement()) { final byte[] certBytes = decoder.drainElement(); array[i ++] = (X509Certificate) certificateFactory.generateCertificate(new ByteArrayInputStream(certBytes));
final byte[] publicBytes = decoder.drainElement(); final byte[] privateBytes = decoder.drainElement(); decoder.endSequence(); final KeyFactory keyFactory = KeyFactory.getInstance(matchedAlgorithm); int i = 0; while (decoder.hasNextElement()) { final byte[] certBytes = decoder.drainElement(); array[i ++] = (X509Certificate) certificateFactory.generateCertificate(new ByteArrayInputStream(certBytes));
final byte[] publicBytes = decoder.drainElement(); final byte[] privateBytes = decoder.drainElement(); decoder.endSequence(); final KeyFactory keyFactory = KeyFactory.getInstance(matchedAlgorithm); int i = 0; while (decoder.hasNextElement()) { final byte[] certBytes = decoder.drainElement(); array[i ++] = (X509Certificate) certificateFactory.generateCertificate(new ByteArrayInputStream(certBytes));