/** * Constructs the instance on the base of ASN.1 encoded * form of X.509 certificate provided via array of bytes. * @param encoding byte array containing ASN.1 encoded form of certificate. * @throws IOException if some decoding problems occur. */ public X509CertImpl(byte[] encoding) throws IOException { this((Certificate) Certificate.ASN1.decode(encoding)); }
/** * Creates X.509 CRL on the base of ASN.1 DER encoded form of * the CRL (CertificateList structure described in RFC 3280) * provided via array of bytes. * @throws IOException if decoding errors occur. */ public X509CRLImpl(byte[] encoding) throws IOException { this((CertificateList) CertificateList.ASN1.decode(encoding)); }
public PolicyConstraints(byte[] encoding) throws IOException { super(encoding); PolicyConstraints pc = (PolicyConstraints) ASN1.decode(encoding); this.requireExplicitPolicy = pc.requireExplicitPolicy; this.inhibitPolicyMapping = pc.inhibitPolicyMapping; }
public static NameConstraints decode(byte[] encoding) throws IOException { return (NameConstraints) ASN1.decode(encoding); }
private void processNameConstraints() { try { // decode and check nameConstraints NameConstraints.ASN1.decode(nameConstraints); } catch (IOException e) { throw new IllegalArgumentException(e.getMessage()); } } }
this.nameConstraints = (bytes == null) ? null : (NameConstraints) NameConstraints.ASN1.decode(bytes);
/** * Sets the criterion for the subject public key. * * @param key * the subject public key in ASN.1 DER encoded format or {@code null} to * not check the key. * @throws IOException * if decoding the the public key fails. */ public void setSubjectPublicKey(byte[] key) throws IOException { if (key == null) { subjectPublicKey = null; subjectPublicKeyImpl = null; return; } subjectPublicKey = new byte[key.length]; System.arraycopy(key, 0, subjectPublicKey, 0, key.length); subjectPublicKeyImpl = ((SubjectPublicKeyInfo) SubjectPublicKeyInfo.ASN1.decode(key)) .getPublicKey(); }
/** * Creates a new {@code PolicyQualifierInfo} from the specified encoded * form. * * @param encoded * the DER encoded policy qualifier. * @throws IOException * the policy qualifier cannot be decoded. */ public PolicyQualifierInfo(byte[] encoded) throws IOException { if (encoded == null) { throw new NullPointerException("encoded == null"); } if (encoded.length == 0) { throw new IOException("encoded.length == 0"); } this.encoded = new byte[encoded.length]; System.arraycopy(encoded, 0, this.encoded, 0, this.encoded.length); // DER Decoding: Object[] decoded = (Object[]) org.apache.harmony.security.x509.PolicyQualifierInfo.ASN1 .decode(this.encoded); policyQualifierId = ObjectIdentifier.toString((int[]) decoded[0]); policyQualifier = (byte[]) decoded[1]; }
/** * Builds the instance of X509CertPathImpl on the base of the list of * ASN.1 encodings of X.509 certificates provided via PkiPath structure. * This method participates in decoding process. */ public Object getDecodedObject(BerInputStream in) throws IOException { // retrieve the decoded content final List<byte[]> encodedCerts = (List<byte[]>) in.content; final int size = encodedCerts.size(); final List<X509Certificate> certificates = new ArrayList<X509Certificate>(size); for (int i = size - 1; i >= 0; i--) { // create the X.509 certificate on the base of its encoded form // and add it to the list. certificates.add(new X509CertImpl((Certificate) Certificate.ASN1 .decode(encodedCerts.get(i)))); } // create and return the resulting object return new X509CertPathImpl(certificates, Encoding.PKI_PATH); }
/** * Constructs the instance on the base of ASN.1 encoded * form of X.509 certificate provided via stream parameter. * @param in input stream containing ASN.1 encoded form of certificate. * @throws CertificateException if some decoding problems occur. */ public X509CertImpl(InputStream in) throws CertificateException { try { // decode the Certificate object this.certificate = (Certificate) Certificate.ASN1.decode(in); // cache the values of TBSCertificate and Extensions this.tbsCert = certificate.getTbsCertificate(); this.extensions = tbsCert.getExtensions(); } catch (IOException e) { throw new CertificateException(e); } }
/** * Generates certification path object on the base of encoding provided via * array of bytes. The format of provided encoded form is specified by * parameter {@code encoding}. * * @throws CertificateException if specified encoding form is not supported, * or some problems occurred during the decoding. */ public static X509CertPathImpl getInstance(byte[] in, String encoding) throws CertificateException { try { final Encoding encType = Encoding.findByApiName(encoding); if (encType == null) { throw new CertificateException("Unsupported encoding: " + encoding); } switch (encType) { case PKI_PATH: return (X509CertPathImpl) ASN1.decode(in); case PKCS7: return getCertPathFromContentInfo((ContentInfo) ContentInfo.ASN1.decode(in)); default: throw new CertificateException("Unsupported encoding: " + encoding); } } catch (IOException e) { throw new CertificateException("Failed to decode CertPath", e); } }
/** * Generates certification path object on the basis of encoding provided via * input stream. The format of provided encoded form is specified by * parameter <code>encoding</code>. * * @throws CertificateException if specified encoding form is not supported, * or some problems occurred during the decoding. */ public static X509CertPathImpl getInstance(InputStream in, String encoding) throws CertificateException { try { final Encoding encType = Encoding.findByApiName(encoding); if (encType == null) { throw new CertificateException("Unsupported encoding: " + encoding); } switch (encType) { case PKI_PATH: return (X509CertPathImpl) ASN1.decode(in); case PKCS7: return getCertPathFromContentInfo((ContentInfo) ContentInfo.ASN1.decode(in)); default: throw new CertificateException("Unsupported encoding: " + encoding); } } catch (IOException e) { throw new CertificateException("Failed to decode CertPath", e); } }
/** * Creates X.509 CRL on the base of ASN.1 DER encoded form of * the CRL (CertificateList structure described in RFC 3280) * provided via input stream. * @throws CRLException if decoding errors occur. */ public X509CRLImpl(InputStream in) throws CRLException { try { // decode CertificateList structure this.crl = (CertificateList) CertificateList.ASN1.decode(in); this.tbsCertList = crl.getTbsCertList(); this.extensions = tbsCertList.getCrlExtensions(); } catch (IOException e) { throw new CRLException(e); } }
ContentInfo info = (ContentInfo)ContentInfo.ASN1.decode(bis); SignedData signedData = info.getSignedData(); if (signedData == null) {
@Override protected Object getDecodedObject(BerInputStream in) throws IOException { Object[] values = (Object[]) in.content; int[] oid = (int[]) values[0]; if (Arrays.equals(oid, DATA)) { if (values[1] != null) { return new ContentInfo(oid, ASN1OctetString.getInstance().decode((byte[])values[1]), in.getEncoded()); } else { return new ContentInfo((int[])values[0], null, in.getEncoded()); } } if (Arrays.equals(oid, SIGNED_DATA)) { return new ContentInfo((int[])values[0], SignedData.ASN1.decode((byte[])values[1]), in.getEncoded()); } return new ContentInfo((int[]) values[0], values[1], in.getEncoded()); } };
.decode(encoding); } catch (IOException e) { throw new InvalidKeySpecException("Failed to decode keySpec encoding: " + e); try { threeInts = (ThreeIntegerSequence) ThreeIntegerSequence.ASN1 .decode(ai.getParameters()); } catch (IOException e) { throw new InvalidKeySpecException("Failed to decode parameters: " + e);
Object[] values; values = (Object[])asn1.decode(encoded);