Examples of DEROutputStream


Examples of org.apache.geronimo.util.asn1.DEROutputStream

     * return a DER encoded byte array representing this object
     */
    public byte[] getEncoded()
    {
        ByteArrayOutputStream   bOut = new ByteArrayOutputStream();
        DEROutputStream         dOut = new DEROutputStream(bOut);

        try
        {
            dOut.writeObject(this);
        }
        catch (IOException e)
        {
            throw new RuntimeException(e.toString());
        }
View Full Code Here

Examples of org.apache.geronimo.util.asn1.DEROutputStream

        TBSCertificateStructure tbsCert = tbsGen.generateTBSCertificate();

        try
        {
            ByteArrayOutputStream   bOut = new ByteArrayOutputStream();
            DEROutputStream         dOut = new DEROutputStream(bOut);

            dOut.writeObject(tbsCert);

            sig.update(bOut.toByteArray());
        }
        catch (Exception e)
        {
View Full Code Here

Examples of org.apache.geronimo.util.asn1.DEROutputStream

     * return a DER encoded byte array representing this object
     */
    public byte[] getEncoded()
    {
        ByteArrayOutputStream   bOut = new ByteArrayOutputStream();
        DEROutputStream         dOut = new DEROutputStream(bOut);

        try
        {
            dOut.writeObject(this);
        }
        catch (IOException e)
        {
            throw new RuntimeException(e.toString());
        }
View Full Code Here

Examples of org.apache.geronimo.util.asn1.DEROutputStream

        if (!csr.verify()) {
            throw new KeyStoreException("CSR verification failed");
        }

        ByteArrayOutputStream os = new ByteArrayOutputStream();
        DEROutputStream deros = new DEROutputStream(os);
        deros.writeObject(csr.getDERObject());
        String b64 = new String(Base64.encode(os.toByteArray()));

        final String BEGIN_CERT_REQ = "-----BEGIN CERTIFICATE REQUEST-----";
        final String END_CERT_REQ = "-----END CERTIFICATE REQUEST-----";
        final int CERT_REQ_LINE_LENGTH = 70;
View Full Code Here

Examples of org.apache.harmony.security.asn1.DerOutputStream

     */
    public final void testGeneralizedEncoder() throws Exception {
        // full fractional seconds
        Date myDate = getGmtDate(1101980374187L);
        byte[] encoded =
            new DerOutputStream(gTime, myDate).encoded;
        String rep = new String(encoded, 2, encoded[1] & 0xff, "UTF-8");
        assertEquals("full", "20041202093934.187Z", rep);

        // 2 digit fractional seconds (last 0 must be trimmed out)
        myDate = getGmtDate(1101980374180L);
        encoded =
            new DerOutputStream(gTime, myDate).encoded;
        rep = new String(encoded, 2, encoded[1] & 0xff, "UTF-8");
        assertEquals("2 fraction", "20041202093934.18Z", rep);

        // 1 digit fractional seconds (last 2 0s must be trimmed out)
        myDate = getGmtDate(1101980374100L);
        encoded =
            new DerOutputStream(gTime, myDate).encoded;
        rep = new String(encoded, 2, encoded[1] & 0xff, "UTF-8");
        assertEquals("1 fraction", "20041202093934.1Z", rep);

        // no fractional seconds (last 3 0s and "." must be trimmed out)
        myDate = getGmtDate(1101980374000L);
        encoded =
            new DerOutputStream(gTime, myDate).encoded;
        rep = new String(encoded, 2, encoded[1] & 0xff, "UTF-8");
        assertEquals("no fraction", "20041202093934Z", rep);

        // midnight
        SimpleDateFormat sdf =
            new SimpleDateFormat("dd.MM.yyyy HH:mm");
        sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
        myDate = sdf.parse("06.06.2004 00:00");
        encoded =
            new DerOutputStream(gTime, myDate).encoded;
        rep = new String(encoded, 2, encoded[1] & 0xff, "UTF-8");
        assertEquals("midnight", "20040606000000Z", rep);
    }
View Full Code Here

Examples of org.bouncycastle.asn1.DEROutputStream

        throw new CertificateException("input stream does not contain a ASN1 SEQUENCE while reading PkiPath encoded data to load CertPath" );
    }
    Enumeration enumx = ((ASN1Sequence)derObject).getObjects();
    InputStream certInStream;
    ByteArrayOutputStream outStream;
    DEROutputStream derOutStream;
    certificates = new ArrayList();
    CertificateFactory certFactory= CertificateFactory.getInstance( "X.509", "BC" );
    while ( enumx.hasMoreElements() ) {
        outStream = new ByteArrayOutputStream();
        derOutStream = new DEROutputStream(outStream);
   
              derOutStream.writeObject(enumx.nextElement());
              derOutStream.close();

        certInStream = new ByteArrayInputStream(outStream.toByteArray());
        certificates.add(0,certFactory.generateCertificate(certInStream));
    }
      }
View Full Code Here

Examples of org.bouncycastle.asn1.DEROutputStream

  if ( encoded == null )
      return null;

  ByteArrayOutputStream outStream = new ByteArrayOutputStream();
        DEROutputStream derOutStream = new DEROutputStream(outStream);

  try {
      derOutStream.writeObject( encoded );
      derOutStream.close();
  } catch ( IOException ex ) {
      throw new CertificateEncodingException( "IOExeption thrown: " + ex.toString() );
  }

        return outStream.toByteArray();
View Full Code Here

Examples of org.bouncycastle.asn1.DEROutputStream

    }

    public byte[] getEncoded()
    {
        ByteArrayOutputStream   bOut = new ByteArrayOutputStream();
        DEROutputStream         dOut = new DEROutputStream(bOut);
        X962Parameters          params = null;

        if (ecSpec instanceof ECNamedCurveParameterSpec)
        {
            params = new X962Parameters(X962NamedCurves.getOID(((ECNamedCurveParameterSpec)ecSpec).getName()));
        }
        else
        {
            X9ECParameters          ecP = new X9ECParameters(
                                            ecSpec.getCurve(),
                                            ecSpec.getG(),
                                            ecSpec.getN(),
                                            ecSpec.getH(),
                                            ecSpec.getSeed());
            params = new X962Parameters(ecP);
        }

        ASN1OctetString    p = (ASN1OctetString)(new X9ECPoint(this.getQ()).getDERObject());

        SubjectPublicKeyInfo info = new SubjectPublicKeyInfo(new AlgorithmIdentifier(X9ObjectIdentifiers.id_ecPublicKey, params.getDERObject()), p.getOctets());

        try
        {
            dOut.writeObject(info);
            dOut.close();
        }
        catch (IOException e)
        {
            throw new RuntimeException("Error encoding EC public key");
        }
View Full Code Here

Examples of org.bouncycastle.asn1.DEROutputStream

    private byte[] derEncode(
        byte[]  hash)
        throws IOException
    {
        ByteArrayOutputStream   bOut = new ByteArrayOutputStream();
        DEROutputStream         dOut = new DEROutputStream(bOut);
        DigestInfo              dInfo = new DigestInfo(algId, hash);

        dOut.writeObject(dInfo);

        return bOut.toByteArray();
    }
View Full Code Here

Examples of org.bouncycastle.asn1.DEROutputStream

     * @return a PKCS8 representation of the key.
     */
    public byte[] getEncoded()
    {
        ByteArrayOutputStream   bOut = new ByteArrayOutputStream();
        DEROutputStream         dOut = new DEROutputStream(bOut);
        X962Parameters          params = null;

        if (ecSpec instanceof ECNamedCurveParameterSpec)
        {
            params = new X962Parameters(X962NamedCurves.getOID(((ECNamedCurveParameterSpec)ecSpec).getName()));
        }
        else
        {
            X9ECParameters          ecP = new X9ECParameters(
                                            ecSpec.getCurve(),
                                            ecSpec.getG(),
                                            ecSpec.getN(),
                                            ecSpec.getH(),
                                            ecSpec.getSeed());
            params = new X962Parameters(ecP);
        }

        PrivateKeyInfo          info = new PrivateKeyInfo(new AlgorithmIdentifier(X9ObjectIdentifiers.id_ecPublicKey, params.getDERObject()), new ECPrivateKeyStructure(this.getD()).getDERObject());

        try
        {
            dOut.writeObject(info);
            dOut.close();
        }
        catch (IOException e)
        {
            throw new RuntimeException("Error encoding EC private key");
        }
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.