// --- BEGIN COPYRIGHT BLOCK --- // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; version 2 of the License. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // (C) 2007 Red Hat, Inc. // All rights reserved. // --- END COPYRIGHT BLOCK --- package com.netscape.cmstools; import java.io.BufferedInputStream; import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStreamReader; import com.netscape.cmsutil.util.Utils; /** * The AtoB class is a utility program designed to "translate" an ASCII * BASE 64 encoded blob into a BINARY BASE 64 encoded blob. It assumes * that the name of a data file is passed to the program via the command line, * and that the contents contain a blob encoded in an ASCII BASE 64 * format. Note that the data file may contain an optional "-----BEGIN" header * and/or an optional "-----END" trailer. * *
* The program may be invoked as follows: * *
* * AtoB <input filename> <output filename> * * NOTE: <input filename> must contain an ASCII * BASE 64 encoded blob * * <output filename> contains a BINARY * BASE 64 encoded blob ** * @version $Revision$, $Date$ */ public class AtoB { // Define constants public static final int ARGC = 2; public static final String HEADER = "-----BEGIN"; public static final String TRAILER = "-----END"; public static void main(String argv[]) { BufferedReader inputBlob = null; String asciiBASE64BlobChunk = new String(); String asciiBASE64Blob = new String(); byte binaryBASE64Blob[] = null; FileOutputStream outputBlob = null; // (1) Check that two arguments were submitted to the program if (argv.length != ARGC) { System.out.println("Usage: AtoB " + " " + "