Package org.apache.geronimo.crypto.asn1

Examples of org.apache.geronimo.crypto.asn1.ASN1OutputStream


    public X500Principal getIssuerX500Principal()
    {
        try
        {
            ByteArrayOutputStream   bOut = new ByteArrayOutputStream();
            ASN1OutputStream        aOut = new ASN1OutputStream(bOut);

            aOut.writeObject(c.getIssuer());

            return new X500Principal(bOut.toByteArray());
        }
        catch (IOException e)
        {
View Full Code Here


            DERBitString    bitSig = null;

            try
            {
                ByteArrayOutputStream   bOut = new ByteArrayOutputStream();
                ASN1OutputStream        aOut = new ASN1OutputStream(bOut);

                aOut.writeObject(tbsReq);

                sig.update(bOut.toByteArray());

                bitSig = new DERBitString(sig.sign());
            }
View Full Code Here

        String provider)
        throws OCSPException, NoSuchProviderException
    {
        List                    certs = new ArrayList();
        ByteArrayOutputStream   bOut = new ByteArrayOutputStream();
        ASN1OutputStream        aOut = new ASN1OutputStream(bOut);
        CertificateFactory      cf;

        try
        {
            cf = CertificateFactory.getInstance("X.509", provider);
        }
        catch (CertificateException ex)
        {
            throw new OCSPException("can't get certificate factory.", ex);
        }

        //
        // load the certificates and revocation lists if we have any
        //
        ASN1Sequence s = resp.getCerts();

        if (s != null)
        {
            Enumeration e = s.getObjects();

            while (e.hasMoreElements())
            {
                try
                {
                    aOut.writeObject(e.nextElement());

                    certs.add(cf.generateCertificate(
                        new ByteArrayInputStream(bOut.toByteArray())));
                }
                catch (IOException ex)
View Full Code Here

     */
    public byte[] getEncoded()
        throws IOException
    {
        ByteArrayOutputStream   bOut = new ByteArrayOutputStream();
        ASN1OutputStream        aOut = new ASN1OutputStream(bOut);

        aOut.writeObject(resp);

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

            ByteArrayInputStream    bIn = new ByteArrayInputStream(((Key)o).getEncoded());
            ASN1InputStream         aIn = new ASN1InputStream(bIn);
           
            PrivateKeyInfo          info = new PrivateKeyInfo((ASN1Sequence)aIn.readObject());
            ByteArrayOutputStream   bOut = new ByteArrayOutputStream();
            ASN1OutputStream        aOut = new ASN1OutputStream(bOut);
           
            if (o instanceof RSAPrivateKey)
            {
                type = "RSA PRIVATE KEY";
               
                aOut.writeObject(info.getPrivateKey());
            }
            else if (o instanceof DSAPrivateKey)
            {
                type = "DSA PRIVATE KEY";
               
                DSAParameter        p = DSAParameter.getInstance(info.getAlgorithmId().getParameters());
                ASN1EncodableVector v = new ASN1EncodableVector();
               
                v.add(new DERInteger(0));
                v.add(new DERInteger(p.getP()));
                v.add(new DERInteger(p.getQ()));
                v.add(new DERInteger(p.getG()));
               
                BigInteger x = ((DSAPrivateKey)o).getX();
                BigInteger y = p.getG().modPow(x, p.getP());
               
                v.add(new DERInteger(y));
                v.add(new DERInteger(x));
               
                aOut.writeObject(new DERSequence(v));
            }
            else
            {
                throw new IOException("Cannot identify private key");
            }
View Full Code Here

                k.getPrimeExponentQ(),
                k.getCrtCoefficient());
      
            // convert to bytearray
            ByteArrayOutputStream bOut = new ByteArrayOutputStream();
            ASN1OutputStream      aOut = new ASN1OutputStream(bOut);
           
            aOut.writeObject(keyStruct);
            aOut.close();
           
            keyData = bOut.toByteArray();
        }
      
        byte[]  encData = null;
View Full Code Here

     */
    public byte[] getEncoded()
        throws IOException
    {
        ByteArrayOutputStream   bOut = new ByteArrayOutputStream();
        ASN1OutputStream        aOut = new ASN1OutputStream(bOut);

        aOut.writeObject(resp);

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

            };
       
        try
        {
            ByteArrayOutputStream   bOut = new ByteArrayOutputStream();
            ASN1OutputStream        aOut = new ASN1OutputStream(bOut);
           
            for (int i = 0; i != values.length; i++)
            {
                aOut.writeObject(values[i]);
            }
           
            DERObject[] readValues = new DERObject[values.length];
           
            ByteArrayInputStream    bIn = new ByteArrayInputStream(bOut.toByteArray());
View Full Code Here

            }
           
            n = new X509Name("C=AU, O=The Legion of the Bouncy Castle, L=Melbourne + OU=Ascot Vale");
           
            ByteArrayOutputStream   bOut = new ByteArrayOutputStream();
            ASN1OutputStream        aOut = new ASN1OutputStream(bOut);
           
            aOut.writeObject(n);
           
            byte[]  enc2 = bOut.toByteArray();
           
            if (enc.length != enc2.length)
            {
                return new SimpleTestResult(false, getName() + ": Failed composite string to encoding test");
            }
           
            for (int i = 0; i != enc.length; i++)
            {
                if (enc[i] != enc2[i])
                {
                    return new SimpleTestResult(false, getName() + ": Failed composite string to encoding test");
                }
            }

            //
            // general subjects test
            //
            for (int i = 0; i != subjects.length; i++)
            {
                X509Name    name = new X509Name(subjects[i]);

                bOut = new ByteArrayOutputStream();
                aOut = new ASN1OutputStream(bOut);
           
                aOut.writeObject(name);

                aIn = new ASN1InputStream(new ByteArrayInputStream(bOut.toByteArray()));

                name = X509Name.getInstance(aIn.readObject());
View Full Code Here

            encInfo = new EncryptedPrivateKeyInfo(encInfo.getEncryptionAlgorithm(), encInfo.getEncryptedData());
           
            b = new SafeBag(PKCSObjectIdentifiers.pkcs8ShroudedKeyBag, encInfo.toASN1Object(), b.getBagAttributes());
           
            ByteArrayOutputStream abOut = new ByteArrayOutputStream();
            ASN1OutputStream      berOut = new ASN1OutputStream(abOut);
           
            berOut.writeObject(new DERSequence(b));
           
            c[0] = new ContentInfo(PKCSObjectIdentifiers.data, new BERConstructedOctetString(abOut.toByteArray()));
           
            //
            // certificates
            //
            if (!c[1].getContentType().equals(PKCSObjectIdentifiers.encryptedData))
            {
                return new SimpleTestResult(false, getName() + ": failed comparison encryptedData test");
            }
           
            EncryptedData   eData = EncryptedData.getInstance(c[1].getContent());
           
            c[1] = new ContentInfo(PKCSObjectIdentifiers.encryptedData, eData);
           
            //
            // create an octet stream represent the BER encoding of authSafe
            //
            authSafe = new AuthenticatedSafe(c);
           
            abOut = new ByteArrayOutputStream();
            berOut = new ASN1OutputStream(abOut);

            berOut.writeObject(authSafe);
           
            info = new ContentInfo(PKCSObjectIdentifiers.data, new BERConstructedOctetString(abOut.toByteArray()));
           
            mData = new MacData(new DigestInfo(algId, dInfo.getDigest()), salt, itCount);
           
            bag = new Pfx(info, mData);

            //
            // comparison test
            //
           
            ByteArrayOutputStream   bOut = new ByteArrayOutputStream();
            ASN1OutputStream        aOut = new ASN1OutputStream(bOut);
           
            aOut.writeObject(bag);
           
            if (!isSameAs(bOut.toByteArray(), pkcs12))
            {
                return new SimpleTestResult(false, getName() + ": failed comparison test");
            }
View Full Code Here

TOP

Related Classes of org.apache.geronimo.crypto.asn1.ASN1OutputStream

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.