Package codec.asn1

Examples of codec.asn1.DERDecoder


    public X509Certificate(InputStream in)
      throws java.security.cert.CertificateEncodingException {
  this();

  try {
      decode(new DERDecoder(in));
  } catch (Exception e) {
      throw new java.security.cert.CertificateEncodingException(e
        .getMessage());
  }
    }
View Full Code Here


  }
    }

    public void readExternal(ObjectInput s) throws IOException {
  try {
      decode(new DERDecoder((ObjectInputStream) s));
  } catch (ASN1Exception e) {
      throw new RuntimeException(e.toString());
  }
    }
View Full Code Here

  }
    }

    public void readExternal(ObjectInput s) throws IOException {
  try {
      decode(new DERDecoder((ObjectInputStream) s));
  } catch (ASN1Exception e) {
      throw new RuntimeException(e.toString());
  }
    }
View Full Code Here

   * better to just catch it and throw a runtime exception (an error).
   *
   * --volker roth
   */
  ByteArrayInputStream in;
  DERDecoder dec;

  if (b == null) {
      throw new NullPointerException("input array");
  }
  in = new ByteArrayInputStream(b);
  dec = new DERDecoder(in);

  decode(dec);

  /*
   * Let stream free resources.
View Full Code Here

     * extension did not contain a DER encoded ASN.1 type, the ASN1OctetString
     * containing the original value is returned.
     */
    public Object getValue() {
  ByteArrayInputStream bis;
  DERDecoder dec;
  ASN1Type res = null;

  try {
      bis = new ByteArrayInputStream(extnValue.getByteArray());
      dec = new DERDecoder(bis);
      res = dec.readType();
      dec.close();
  } catch (IOException e) {
      System.err.println("Internal error: shouldn't happen!");
      e.printStackTrace();
  } catch (ASN1Exception e) {
      res = extnValue;
View Full Code Here

     * template. This implicitly checks the syntax of the decoded type.
     */
    protected void decodeExtensionValue(ASN1Type t) throws ASN1Exception,
      IOException {
  ByteArrayInputStream bis;
  DERDecoder dec;

  if (t == null) {
      throw new NullPointerException("input parameter");
  }
  bis = new ByteArrayInputStream(extnValue.getByteArray());
  dec = new DERDecoder(bis);

  t.decode(dec);
  dec.close();
    }
View Full Code Here

     * @throws IOException DOCUMENT ME!
     */
    public void decode(byte[] encodedData) throws ASN1Exception, IOException
    {
        ByteArrayInputStream in;
        DERDecoder decoder;

        in          = new ByteArrayInputStream(encodedData);
        decoder     = new DERDecoder(in);

        this.decode(decoder);
        decoder.close();
    }
View Full Code Here

     * @throws IOException DOCUMENT ME!
     */
    public void decode(byte[] encodedData) throws ASN1Exception, IOException
    {
        ByteArrayInputStream in;
        DERDecoder decoder;

        in          = new ByteArrayInputStream(encodedData);
        decoder     = new DERDecoder(in);

        this.decode(decoder);
        decoder.close();
    }
View Full Code Here

     * @throws IOException DOCUMENT ME!
     */
    public void decode(byte[] encodedData) throws ASN1Exception, IOException
    {
        ByteArrayInputStream in;
        DERDecoder decoder;

        in          = new ByteArrayInputStream(encodedData);
        decoder     = new DERDecoder(in);

        this.decode(decoder);
        decoder.close();
    }
View Full Code Here

     *          null if the extension is not present
     */
    public int getBasicConstraints() {
  int res = -1;
  byte[] ext_value;
  DERDecoder dec;
  ByteArrayInputStream bais;
  ASN1Sequence seq;
  ASN1Integer pathLen;
  ASN1Boolean ca;

  String bc_oid = "2.5.29.19";

  // get the extension "basic constraints"
  ext_value = getExtensionValue(bc_oid);

  // is it present?
  if (ext_value != null) {

      // read the extension value through a byte array input stream
      bais = new ByteArrayInputStream(ext_value);

      try {

    // build outer sequence
    seq = new ASN1Sequence();

    ca = new ASN1Boolean();
    ca.setOptional(true);
    seq.add(ca);

    pathLen = new ASN1Integer();
    pathLen.setOptional(true);
    seq.add(pathLen);

    /*
     * Switched decoding to the correct way of doing it, which is to
     * take the ASN.1 object and to call its decode() method, rather
     * than calling readX() methods of the decoder. --volker roth
     */
    dec = new DERDecoder(bais);
    seq.decode(dec);
    bais.close();

    if (ca.isTrue()) {
        /*
 
View Full Code Here

TOP

Related Classes of codec.asn1.DERDecoder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.