Examples of Base64OutputStream


Examples of org.apache.commons.codec.binary.Base64OutputStream

                byte[] iv = XMLSecurityConstants.generateBytes(ivLen);
                IvParameterSpec ivParameterSpec = new IvParameterSpec(iv);
                symmetricCipher.init(Cipher.ENCRYPT_MODE, encryptionPartDef.getSymmetricKey(), ivParameterSpec);

                characterEventGeneratorOutputStream = new CharacterEventGeneratorOutputStream();
                Base64OutputStream base64EncoderStream =
                        new Base64OutputStream(characterEventGeneratorOutputStream, true, 0, null);
                base64EncoderStream.write(iv);

                OutputStream outputStream = new CipherOutputStream(base64EncoderStream, symmetricCipher);
                outputStream = applyTransforms(outputStream);
                //the trimmer output stream is needed to strip away the dummy wrapping element which must be added
                cipherOutputStream = new TrimmerOutputStream(outputStream, 8192 * 10, 3, 4);
View Full Code Here

Examples of org.apache.commons.codec.binary.Base64OutputStream

                        cipherOutputStream,
                        cipher, getSecretKey(), getIvLength());
                //buffering seems not to help
                //bufferedOutputStream = new BufferedOutputStream(new Base64OutputStream(ivSplittingOutputStream, false), 8192 * 5);
                ReplaceableOuputStream replaceableOuputStream = new ReplaceableOuputStream(ivSplittingOutputStream);
                OutputStream base64OutputStream = new Base64OutputStream(replaceableOuputStream, false);
                ivSplittingOutputStream.setParentOutputStream(replaceableOuputStream);
                OutputStreamWriter outputStreamWriter =
                        new OutputStreamWriter(base64OutputStream, inputProcessorChain.getDocumentContext().getEncoding());

                //read the encrypted data from the stream until an end-element occurs and write then
View Full Code Here

Examples of org.apache.commons.codec.binary.Base64OutputStream

  }

  /* package */ static void compressStream(InputStream inputStream, OutputStream outputStream) throws IOException {
    InputStream iStream = new BufferedInputStream(inputStream);
    GZIPOutputStream oStream =
        new GZIPOutputStream(new Base64OutputStream(new BufferedOutputStream(outputStream), true, -1, null), 2048);
    byte[] buffer = new byte[2048];
    int bytesRead;
    while ((bytesRead = iStream.read(buffer)) != -1) {
      oStream.write(buffer, 0, bytesRead);
    }
View Full Code Here

Examples of org.apache.commons.codec.binary.Base64OutputStream

                return new Base64InputStream(hasResourceStream.getInputStream(), doEncode);
            }

            @Override
            public long writeContent(OutputStream outputStream) throws IOException {
                Base64OutputStream codec = new Base64OutputStream(outputStream, doEncode);
                try {
                    return hasResourceStream.writeContent(codec);
                } finally {
                    codec.flush();
                    codec.close();
                }
            }
        };
    }
View Full Code Here

Examples of org.apache.commons.codec.binary.Base64OutputStream

        oos.writeObject(this);
        oos.close();

        ByteArrayOutputStream buf2 = new ByteArrayOutputStream();

        DataOutputStream dos = new DataOutputStream(new Base64OutputStream(buf2,true,-1,null));
        buf2.write(PREAMBLE);
        dos.writeInt(buf.size());
        buf.writeTo(dos);
        dos.close();
        buf2.write(POSTAMBLE);
View Full Code Here

Examples of org.apache.james.mime4j.codec.Base64OutputStream

    public static void main(String[] args) throws Exception {
        byte[] data = initData(1024);

        OutputStream nullOut = new NullOutputStream();
        Base64OutputStream base64Out = new Base64OutputStream(nullOut);

        // warmup

        for (int i = 0; i < 2000; i++) {
            base64Out.write(data);
        }
        Thread.sleep(100);

        // test

        long t0 = System.currentTimeMillis();

        final int repetitions = 500000;
        for (int i = 0; i < repetitions; i++) {
            base64Out.write(data);
        }
        base64Out.close();

        long dt = System.currentTimeMillis() - t0;
        long totalBytes = data.length * (long) repetitions;

        double mbPerSec = (totalBytes / 1024.0 / 1024) / (dt / 1000.0);
View Full Code Here

Examples of org.apache.james.mime4j.codec.Base64OutputStream

    }

    protected OutputStream encodeStream(OutputStream out, String encoding,
            boolean binaryBody) throws IOException {
        if (MimeUtil.isBase64Encoding(encoding)) {
            return new Base64OutputStream(out);
        } else if (MimeUtil.isQuotedPrintableEncoded(encoding)) {
            return new QuotedPrintableOutputStream(out, binaryBody);
        } else {
            return out;
        }
View Full Code Here

Examples of org.apache.james.mime4j.decoder.Base64OutputStream

    String str_encoded = "QmFzZTY0IEVuY29kaW5nIGlzIGEgcG9wdWxhciB3YXkgdG8gY29udmVydCB0aGUgOGJpdCBhbmQgdGhlIGJpbmFyeSB0byB0aGUgN2JpdCBmb3IgbmV0d29yayB0cmFucyB1c2luZyBTb2NrZXQsIGFuZCBhIHNlY3VyaXR5IG1ldGhvZCB0byBoYW5kbGUgdGV4dCBvciBmaWxlLCBvZnRlbiB1c2VkIGluIEF1dGhlbnRpY2FsIExvZ2luIGFuZCBNYWlsIEF0dGFjaG1lbnQsIGFsc28gc3RvcmVkIGluIHRleHQgZmlsZSBvciBkYXRhYmFzZS4gTW9zdCBTTVRQIHNlcnZlciB3aWxsIGhhbmRsZSB0aGUgbG9naW4gVXNlck5hbWUgYW5kIFBhc3N3b3JkIGluIHRoaXMgd2F5Lg==";
   
    // create a Base64OutputStream
    StringWriter strwriter = new StringWriter();
    BufferedWriter buffwriter = new BufferedWriter(strwriter);
    Base64OutputStream b64_out = new Base64OutputStream(buffwriter);
   
    byte[] b = str.getBytes();
   
    // write the bytes in different lengths to test whether leftover
    // data is persisted across calls to write
    b64_out.write(b, 0, 33);
    b64_out.write(b, 33, 1);
    b64_out.write(b, 34, 1);
    b64_out.write(b, 35, 2);
    b64_out.write(b, 37, 3);
    b64_out.write(b, 40, 3);
    b64_out.write(b, 43, 3);
    b64_out.write(b, 46, 5);
    b64_out.write(b, 51, 4);
    b64_out.write(b, 55, 5);
    b64_out.write(b, 60, 6);
    b64_out.write(b, 66, 10);
    b64_out.write(b, 76, 51);
    b64_out.write(b, 127, 150);
    b64_out.write(b, 277, 22);
    b64_out.write(b, 299, 21);
    b64_out.write(b, 320, 2);
   
    // remember to add padding characters (if necessary)
    b64_out.close();
   
    // compare the contents of the outputstream with the expected encoded string
    assertEquals(strwriter.toString(), str_encoded)
 
View Full Code Here

Examples of org.apache.james.mime4j.decoder.Base64OutputStream

   
    byte[] bytes = str.getBytes();
   
    StringWriter strwriter = new StringWriter();
    BufferedWriter buffwriter = new BufferedWriter(strwriter);
    Base64OutputStream b64_out = new Base64OutputStream(buffwriter);
   
    GZIPOutputStream zip = new GZIPOutputStream(b64_out);
   
    zip.write(bytes, 0, bytes.length);
    zip.finish();
    buffwriter.flush();
    b64_out.close();
   
    assertEquals(str_encoded, strwriter.toString());
   
  }
View Full Code Here

Examples of org.apache.james.mime4j.decoder.Base64OutputStream

  private void _testWriteChar(String str, String str_encoded) throws IOException
  {
    // create a Base64OutputStream
    StringWriter strwriter = new StringWriter();
    BufferedWriter buffwriter = new BufferedWriter(strwriter);
    Base64OutputStream b64_out = new Base64OutputStream(buffwriter);
   
    // write out each char in str to the stream
    for (int i = 0; i<str.length(); i++)
    {
      b64_out.write(str.charAt(i));
    }
    // remember to add padding characters (if necessary)
    b64_out.close();
       
    // compare the contents of the outputstream with the expected encoded string
    assertEquals(strwriter.toString(), str_encoded)
  }
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.