Examples of DEREncoder


Examples of codec.asn1.DEREncoder

      X509Extension theEx = (X509Extension) it.next();
      if (theEx.getOID().toString().equals(ex)) {
    try {
        ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream();
        theEx.encode(new DEREncoder(baos));
        res = baos.toByteArray();
    } catch (Exception ignore) {
    }
      }
View Full Code Here

Examples of codec.asn1.DEREncoder

     */
    public byte[] getTBSCertList() throws java.security.cert.CRLException {

  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  try {
      TBSCertList.encode(new DEREncoder(baos));
  } catch (Exception e) {
      throw new java.security.cert.CRLException(e.getMessage());
  }

  return baos.toByteArray();
View Full Code Here

Examples of codec.asn1.DEREncoder

     *                 defined by the installed providers.
     */
    public PublicKey getPublicKey() throws NoSuchAlgorithmException {
  ByteArrayOutputStream bos;
  X509EncodedKeySpec spec;
  DEREncoder enc;
  KeyFactory kf;
  String alg;

  try {
      bos = new ByteArrayOutputStream();
      enc = new DEREncoder(bos);
      encode(enc);
      spec = new X509EncodedKeySpec(bos.toByteArray());
      enc.close();

      alg = algorithm_.getAlgorithmOID().toString();
      kf = KeyFactory.getInstance(alg);

      return kf.generatePublic(spec);
View Full Code Here

Examples of codec.asn1.DEREncoder

     *                 if an internal error occurs while the key is encoded.
     *                 This should never happen.
     */
    protected void setRawKey(ASN1Type key) {
  ByteArrayOutputStream bos;
  DEREncoder enc;

  try {
      bos = new ByteArrayOutputStream();
      enc = new DEREncoder(bos);
      key.encode(enc);
      encodedKey_ = new ASN1BitString(bos.toByteArray(), 0);
      enc.close();
      set(1, encodedKey_);
  } catch (ASN1Exception e) {
      throw new InconsistentStateException("Internal, encoding error!");
  } catch (IOException e) {
      throw new InconsistentStateException(
View Full Code Here

Examples of codec.asn1.DEREncoder

     * @throws IOException DOCUMENT ME!
     */
    public byte[] getEncoded() throws ASN1Exception, IOException
    {
        ByteArrayOutputStream out;
        DEREncoder encoder;
        byte[] encodedAsn1Object;

        out         = new ByteArrayOutputStream();
        encoder     = new DEREncoder(out);

        this.encode(encoder);
        encodedAsn1Object = out.toByteArray();
        encoder.close();

        return encodedAsn1Object;
    }
View Full Code Here

Examples of codec.asn1.DEREncoder

     * @throws IOException DOCUMENT ME!
     */
    public byte[] getEncoded() throws ASN1Exception, IOException
    {
        ByteArrayOutputStream out;
        DEREncoder encoder;
        byte[] encodedAsn1Object;

        out         = new ByteArrayOutputStream();
        encoder     = new DEREncoder(out);

        this.encode(encoder);
        encodedAsn1Object = out.toByteArray();
        encoder.close();

        return encodedAsn1Object;
    }
View Full Code Here

Examples of codec.asn1.DEREncoder

     */
    public static void main(String[] args)
    {
        ASN1IA5String asn1Object;
        ByteArrayOutputStream out;
        DEREncoder encoder;
        byte[] encodedAsn1Object;
        StringBuffer buf;
        String octet;
        ASN1IA5String newAsn1Object;
        ByteArrayInputStream in;
        DERDecoder decoder;
        ASN1Type asn1Type;


        /* Create ASN.1 object.
         */
        asn1Object = new ASN1IA5String("Hello World !");

        /* Print the ASN.1 object to the standard output.
         */
        System.out.println("ASN.1 object: ");
        System.out.println(asn1Object.toString());
        System.out.println();

        /* Encoding process.
         */
        /* Initialize an output stream to which the encoded data will be
         * written.
         */
        out     = new ByteArrayOutputStream();

        /* Initialize encoder instance with this output stream.
         */
        encoder     = new DEREncoder(out);

        /* Byte array to store the encoded data.
         */
        encodedAsn1Object = null;

        try
        {
            /* Encoder reads the data stored in the variable asn1Object and
             * encodes it writing the output to the output stream.
             */
            asn1Object.encode(encoder);

            /* Store the data in the output stream in a byte array. This array
             * will be decoded later.
             */
            encodedAsn1Object = out.toByteArray();

            /* Close the stream.
             */
            encoder.close();
        }
        catch (ASN1Exception e)
        {
            System.out.println("Error during encoding.");
            e.printStackTrace();
View Full Code Here

Examples of codec.asn1.DEREncoder

     * @throws IOException DOCUMENT ME!
     */
    public byte[] getEncoded() throws ASN1Exception, IOException
    {
        ByteArrayOutputStream out;
        DEREncoder encoder;
        byte[] encodedAsn1Object;

        out         = new ByteArrayOutputStream();
        encoder     = new DEREncoder(out);

        this.encode(encoder);
        encodedAsn1Object = out.toByteArray();
        encoder.close();

        return encodedAsn1Object;
    }
View Full Code Here

Examples of codec.asn1.DEREncoder

     * @throws IOException DOCUMENT ME!
     */
    public byte[] getEncoded() throws ASN1Exception, IOException
    {
        ByteArrayOutputStream out;
        DEREncoder encoder;
        byte[] encodedAsn1Object;

        out         = new ByteArrayOutputStream();
        encoder     = new DEREncoder(out);

        this.encode(encoder);
        encodedAsn1Object = out.toByteArray();
        encoder.close();

        return encodedAsn1Object;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.