01: /*
02: *
03: *
04: * Copyright 1990-2007 Sun Microsystems, Inc. All Rights Reserved.
05: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
06: *
07: * This program is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU General Public License version
09: * 2 only, as published by the Free Software Foundation.
10: *
11: * This program is distributed in the hope that it will be useful, but
12: * WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * General Public License version 2 for more details (a copy is
15: * included at /legal/license.txt).
16: *
17: * You should have received a copy of the GNU General Public License
18: * version 2 along with this work; if not, write to the Free Software
19: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20: * 02110-1301 USA
21: *
22: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
23: * Clara, CA 95054 or visit www.sun.com if you need additional
24: * information or have any questions.
25: */
26:
27: package acl_data;
28:
29: import java.util.Vector;
30: import java.io.*;
31: import java.security.*;
32: import java.security.cert.CertificateException;
33:
34: /**
35: * Print class implementation
36: */
37: public class Print {
38:
39: /**
40: * Main function
41: * @param args program argument - input file name.
42: */
43: public static void main(String[] args) {
44: new Print().run(args);
45: }
46:
47: /**
48: * Check the program argument and start processing.
49: * @param args program argument - input file name.
50: */
51: void run(String[] args) {
52: if (args.length < 1) {
53: System.err.println("No file");
54: }
55: try {
56: FileInputStream f;
57: ByteArrayOutputStream b;
58:
59: for (int i = 0; i < args.length; i++) {
60: int ch;
61:
62: System.out.println("File: " + args[i]);
63: f = new FileInputStream(args[i]);
64: b = new ByteArrayOutputStream();
65: while ((ch = f.read()) != -1) {
66: b.write(ch);
67: }
68: f.close();
69: byte[] cont = b.toByteArray();
70: if (cont.length == 0) {
71: System.out.println(" empty");
72: } else {
73: int index = 0;
74: while (index < cont.length) {
75: if (index != 0) {
76: System.out.println("---");
77: }
78: TLV tlv = new TLV(cont, index);
79: tlv.print();
80: index = tlv.valueOffset + tlv.length;
81: }
82: }
83: System.out
84: .println("======================================");
85: }
86: } catch (Exception e) {
87: e.printStackTrace();
88: }
89: }
90:
91: }
|